1 /* BurrTools
2  *
3  * BurrTools is the legal property of its developers, whose
4  * names are listed in the COPYRIGHT file, which is included
5  * within the source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20  */
21 
22 /* often requested here it is: export solutions, just the assembly or the disassembly animation
23  * into a (set of) image files (png files)
24  */
25 
26 /* following parameters can be chosen:
27  * pixel size of the images
28  * for animations: how many files are to be saved
29  * the rotation for each step
30  * file name, number are appended for multiple images
31  */
32 
33 /* fixed parameters (for now):
34  * transparent background
35  * 3x3 antialiasing
36  * block justification of the images, except for the last line
37  */
38 
39 /* the images are measured and then sized so, that they do fit onto the
40  * requested number of pages
41  * then they are taken at the requires size times 3
42  * smoothly downscaled and put onto the page
43  * add a line of text explaining what is currently done
44  */
45 #ifndef __IMAGE_EXPORT_H__
46 #define __IMAGE_EXPORT_H__
47 
48 #include "Layouter.h"
49 #include "voxelframe.h"
50 
51 #include <vector>
52 
53 class LView3dGroup;
54 class LBlockListGroup;
55 class ImageInfo;
56 class image_c;
57 class puzzle_c;
58 
59 class imageExport_c : public LFl_Double_Window, public VoxelViewCallbacks {
60 
61   private:
62 
63     /* the puzzle that is going to be exported */
64     puzzle_c * puzzle;
65 
66     /* The different window elements */
67     LView3dGroup *view3D;
68     LFl_Int_Input *SizePixelX, *SizePixelY;
69     LFl_Radio_Button *AA1, *AA2, *AA3, *AA4, *AA5;
70     LFl_Radio_Button *BgWhite, *BgTransp;
71     LFl_Radio_Button *ColPiece, *ColConst;
72     LFl_Radio_Button *SzA4Port, *SzA4Land, *SzLetterPort, *SzLetterLand, *SzManual;
73     LFl_Input *SzDPI, *SzX, *SzY;
74     LFl_Input *Fname, *Pname;
75     LFl_Int_Input *NumPages;
76     LFl_Box *status;
77     LFl_Radio_Button *ExpShape, *ExpProblem, *ExpAssembly, *ExpSolution, *ExpSolutionDisassm;
78     LFl_Check_Button *DimStatic;
79     LFl_Button *BtnStart, *BtnAbbort;
80     PieceSelector * ShapeSelect;
81     ProblemSelector * ProblemSelect;
82 
83     /* true, when there is an export in execution */
84     bool working;
85 
86     /* this vector is set up at the beginning of an export with
87      * all the images that need to be in the target image
88      */
89     std::vector<ImageInfo*> images;
90 
91     /* some internal variables for the image export */
92     unsigned int state;        /* what is currently done, 0: preview, 1: export */
93     image_c *i;                  /* current page that is worked on */
94     unsigned int curWidth;     /* how much of the current line is filled */
95     unsigned int curLine;      /* current line number */
96     unsigned int curPage;      /* number of the current page */
97     unsigned int im;           /* number of the image int images that is worked on */
98     unsigned int imgHeight;    /* how many pixels high is one line */
99 
100     void nextImage(bool finish);
101 
getColorMode(void)102     voxelFrame_c::colorMode getColorMode(void) {
103       return (ColConst->value() == 1)?(voxelFrame_c::paletteColor):(voxelFrame_c::pieceColor);
104     }
105 
106   public:
107 
108     imageExport_c(puzzle_c * p);
109 
110     /* returns true, when there is currently a image export in progress */
isWorking(void)111     bool isWorking(void) { return working; }
112 
113     /* this must be called cyclically, this updates the buttons activation
114      * status and also it sets up a new redraw cycle, and thus getting the next tile
115      * so when isWorking returns true, call as fast as possible, otherwise call
116      * from time to time
117      */
118     void update(void);
119 
120     void cb_Abort(void);
121     void cb_Export(void);
122     void cb_Update3DView(void);
123     void cb_SzUpdate(void);
124 
125     /* the 2 functions that do the export are stored inside the callback of the voxelView */
126     virtual bool PreDraw(void);
127     virtual void PostDraw(void);
128 };
129 
130 #endif
131