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 #ifndef __MAINWINDOW_H__ 22 #define __MAINWINDOW_H__ 23 24 #include "Images.h" 25 26 #include "Layouter.h" 27 28 class VoxelEditGroup_c; 29 class ChangeSize; 30 class ToolTab; 31 class puzzle_c; 32 class solveThread_c; 33 class disasmToMoves_c; 34 class gridType_c; 35 class guiGridType_c; 36 class layouter_c; 37 38 class PieceSelector; 39 class ProblemSelector; 40 class ColorSelector; 41 class ResultViewer_c; 42 class PiecesList; 43 class PieceVisibility; 44 class ColorConstraintsEdit; 45 class ToolTabContainer; 46 class ButtonGroup_c; 47 class FlatButton; 48 class LStatusLine; 49 class LBlockListGroup_c; 50 class LView3dGroup; 51 52 class Fl_Tabs; 53 class Fl_Group; 54 class Fl_Check_Button; 55 class Fl_Value_Output; 56 class Fl_Output; 57 class Fl_Value_Slider; 58 class Fl_Value_Input; 59 class Fl_Menu_Bar; 60 class Fl_Choice; 61 class Fl_Progress; 62 63 class mainWindow_c : public LFl_Double_Window { 64 65 puzzle_c * puzzle; 66 guiGridType_c * ggt; // this is the guigridtype for the puzzle, is must always be in sync 67 char * fname; 68 disasmToMoves_c * disassemble; 69 solveThread_c *assmThread; 70 bool SolutionEmpty; 71 bool changed; 72 int editSymmetries; 73 74 bool expertMode; 75 76 pixmapList_c pm; 77 78 Fl_Tabs *TaskSelectionTab; 79 layouter_c *TabPieces; 80 Fl_Group *MinSizeSelector; 81 82 PieceSelector * PcSel; 83 ProblemSelector * problemSelector; 84 ProblemSelector * solutionProblem; 85 ColorSelector * colorAssignmentSelector; 86 PieceSelector * shapeAssignmentSelector; 87 ResultViewer_c * problemResult; 88 PiecesList * PiecesCountList; 89 PieceVisibility * PcVis; 90 ColorConstraintsEdit * colconstrList; 91 92 layouter_c *TabProblems; 93 94 ToolTabContainer * pieceTools; 95 ButtonGroup_c *editChoice; 96 ButtonGroup_c *editMode; 97 98 layouter_c *TabSolve; 99 Fl_Check_Button *SolveDisasm, *JustCount, *DropDisassemblies, *KeepMirrors, *KeepRotations, *CompleteRotations; 100 101 FlatButton *BtnPrepare, *BtnStart, *BtnCont, *BtnStop, *BtnPlacement, *BtnStep, *BtnMovement; 102 FlatButton *BtnNewShape, *BtnDelShape, *BtnCpyShape, *BtnRenShape, *BtnShapeLeft, *BtnShapeRight, *BtnWeightInc, *BtnWeightDec; 103 FlatButton *BtnNewColor, *BtnDelColor, *BtnChnColor; 104 FlatButton *BtnNewProb, *BtnDelProb, *BtnCpyProb, *BtnRenProb, *BtnProbLeft, *BtnProbRight; 105 FlatButton *BtnColSrtPc, *BtnColSrtRes, *BtnColAdd, *BtnColRem; 106 FlatButton *BtnSetResult, *BtnAddShape, *BtnRemShape, *BtnMinZero, *BtnAddAll, *BtnRemAll, *BtnGroup, *BtnProbShapeLeft, *BtnProbShapeRight; 107 108 Fl_Progress *SolvingProgress; 109 Fl_Value_Output *OutputAssemblies; 110 Fl_Value_Output *OutputSolutions; 111 Fl_Output *OutputActivity; 112 Fl_Check_Button *ReducePositions; 113 Fl_Value_Slider *SolutionSel; 114 Fl_Value_Slider *SolutionAnim; 115 Fl_Value_Output *SolutionsInfo; 116 Fl_Output *MovesInfo; 117 118 Fl_Output *TimeUsed, *TimeEst; 119 120 LView3dGroup * View3D; 121 122 Fl_Group *MinSizeTools; 123 Fl_Menu_Bar *MainMenu; 124 LStatusLine *StatusLine; 125 static Fl_Menu_Item menu_MainMenu[]; 126 127 ColorSelector * colorSelector; 128 129 VoxelEditGroup_c *pieceEdit; 130 131 Fl_Choice * sortMethod; 132 Fl_Value_Input *solDrop, *solLimit; 133 134 Fl_Value_Output *SolutionNumber, *AssemblyNumber; 135 136 FlatButton *BtnSrtFind, *BtnSrtLevel, *BtnSrtMoves, *BtnSrtPieces; 137 FlatButton *BtnDelAll, *BtnDelBefore, *BtnDelAt, *BtnDelAfter, *BtnDelDisasm; 138 FlatButton *BtnDisasmDel, *BtnDisasmDelAll, *BtnDisasmAdd, *BtnDisasmAddAll, *BtnDisasmAddMissing; 139 140 // the zoom levels for all 3 tabs independent, so that the problem 141 // tab can have a wider view 142 double ViewSizes[3]; 143 int currentTab; 144 145 bool tryToLoad(const char *fname); 146 147 void CreateShapeTab(void); 148 void CreateProblemTab(void); 149 void CreateSolveTab(void); 150 151 152 bool is3DViewBig; 153 bool shapeEditorWithBig3DView; 154 155 void Toggle3DView(void); 156 void Big3DView(void); 157 void Small3DView(void); 158 159 void StatPieceInfo(unsigned int pc); 160 void StatProblemInfo(unsigned int pr); 161 162 void changeShape(unsigned int nr); 163 void changeProblem(unsigned int nr); 164 void changeColor(unsigned int nr); 165 166 void ReplacePuzzle(puzzle_c * newPuzzle); 167 168 void activateShape(unsigned int number); 169 void activateProblem(unsigned int prob); 170 void activateSolution(unsigned int prob, unsigned int num); 171 void activateClear(void); 172 173 bool threadStopped(void); 174 175 void updateInterface(void); 176 177 public: 178 179 mainWindow_c(gridType_c * gt); 180 virtual ~mainWindow_c(); 181 182 int handle(int event); 183 184 void show(int argn, char ** argv); 185 186 // overwrite hide to check for changes in all possible exit situations 187 void hide(void); 188 189 /* this is used on assert to save the current puzzle */ getPuzzle(void)190 const puzzle_c * getPuzzle(void) const { return puzzle; } 191 192 /* update the interface to represent the latest state of 193 * the solving progress, that works in background 194 */ 195 void update(void); 196 197 /* return an index into the main menu array with the given text */ 198 int findMenuEntry(const char * txt); 199 200 /* the callback functions, as they are called from normal functions we need 201 * to make them public, even though they should not be used from the outside 202 */ 203 void cb_AddColor(void); 204 void cb_RemoveColor(void); 205 void cb_ChangeColor(void); 206 207 void cb_NewShape(void); 208 void cb_DeleteShape(void); 209 void cb_CopyShape(void); 210 void cb_NameShape(void); 211 void cb_ShapeExchange(int with); 212 void cb_WeightChange(int by); 213 214 void cb_NewProblem(void); 215 void cb_DeleteProblem(void); 216 void cb_CopyProblem(void); 217 void cb_RenameProblem(void); 218 void cb_ProblemExchange(int with); 219 220 void cb_ColorAssSel(void); 221 void cb_ColorConstrSel(void); 222 223 void cb_ShapeToResult(void); 224 225 void cb_TaskSelectionTab(Fl_Tabs*); 226 227 void cb_SelectProblemShape(void); 228 void cb_AddShapeToProblem(void); 229 void cb_SetShapeMinimumToZero(void); 230 void cb_AddAllShapesToProblem(void); 231 void cb_RemoveShapeFromProblem(void); 232 void cb_RemoveAllShapesFromProblem(void); 233 void cb_ProbShapeExchange(int with); 234 235 void cb_PcSel(LBlockListGroup_c* reason); 236 void cb_ColSel(LBlockListGroup_c* reason); 237 void cb_ProbSel(LBlockListGroup_c* reason); 238 239 void cb_PiecesClicked(void); 240 241 void cb_TransformPiece(void); 242 void cb_pieceEdit(VoxelEditGroup_c* o); 243 void cb_EditChoice(void); 244 void cb_EditSym(int onoff, int value); 245 void cb_EditMode(void); 246 247 void cb_TransformResult(void); 248 249 void cb_AllowColor(void); 250 void cb_DisallowColor(void); 251 void cb_CCSort(bool byResult); 252 253 void cb_BtnPrepare(void); 254 void cb_BtnStart(bool prep_only); 255 void cb_BtnCont(bool prep_only); 256 void cb_BtnStop(void); 257 void cb_BtnPlacementBrowser(void); 258 void cb_BtnMovementBrowser(void); 259 void cb_BtnAssemblerStep(void); 260 261 void cb_SolutionSel(Fl_Value_Slider*); 262 void cb_SolutionAnim(Fl_Value_Slider*); 263 264 void cb_PcVis(void); 265 266 void cb_Status(void); 267 void cb_3dClick(void); 268 269 void cb_New(void); 270 void cb_Load(void); 271 void cb_Load_Ps3d(void); 272 void cb_Save(void); 273 void cb_SaveAs(void); 274 void cb_Convert(void); 275 void cb_AssembliesToShapes(void); 276 void cb_Quit(void); 277 void cb_About(void); 278 void cb_Help(void); 279 void cb_Config(void); 280 void cb_Coment(void); 281 void cb_Toggle3D(void); 282 void cb_SolProbSel(LBlockListGroup_c* reason); 283 284 void cb_ShapeGroup(void); 285 void cb_ImageExport(void); 286 void cb_ImageExportVector(void); 287 void cb_STLExport(void); 288 void cb_StatusWindow(void); 289 290 void cb_SortSolutions(unsigned int by); 291 void cb_DeleteSolutions(unsigned int which); 292 293 void cb_DeleteDisasm(void); 294 void cb_DeleteAllDisasm(void); 295 void cb_AddDisasm(void); 296 void cb_AddAllDisasm(bool all); 297 298 void activateConfigOptions(void); 299 }; 300 301 #endif 302