00001 #ifndef _GUI_H_
00002 #define _GUI_H_
00003
00004 #include <TROOT.h>
00005 #include <TApplication.h>
00006 #include <TGLabel.h>
00007 #include <TGFrame.h>
00008 #include <TGMenu.h>
00009 #include <TRootEmbeddedCanvas.h>
00010 #include <TLatex.h>
00011 #include <TGScrollBar.h>
00012 #include <TGButton.h>
00013 #include <TGDoubleSlider.h>
00014 #include <TGTextEntry.h>
00015 #include <TGTextBuffer.h>
00016 #include <TGNumberEntry.h>
00017 #include <TGComboBox.h>
00018 #include <TG3DLine.h>
00019 #include <TGTab.h>
00020 #include <TGListView.h>
00021 #include <TGMsgBox.h>
00022 #include <TGFileDialog.h>
00023 #include <TGSplitter.h>
00024 #include <TObjectTable.h>
00025 #include <TSystem.h>
00026 #include <RQ_OBJECT.h>
00027
00028 #include <time.h>
00029 #include "enum.h"
00030 #include "lattice.h"
00031 #include "configuration.h"
00032 #include "formula.h"
00033
00034 class LVPicture : public TGPicture
00035 {
00036 public:
00037 LVPicture();
00038 virtual ~LVPicture();
00039 };
00040
00041
00042 class TGNumEntry : public TGTextEntry
00043 {
00044 public:
00045 TGNumEntry(const TGWindow* p, const char* t, Int_t id = -1)
00046 : TGTextEntry(p, t, id) {}
00047 TGNumEntry(const TGWindow* p, Double_t f, Int_t id = -1);
00048 TGNumEntry(const TGWindow* p, TGTextBuffer* t, Int_t id = -1)
00049 : TGTextEntry(p, t, id) {}
00050 virtual void Insert(const char*);
00051 Double_t GetDoubleNum() { return atof(GetText()); }
00052 Int_t GetIntNum() { return atoi(GetText()); }
00053 };
00054
00055 class TGFuncNameEntry : public TGTextEntry
00056 {
00057 public:
00058 TGFuncNameEntry(const TGWindow* p, const char* t, Int_t id = -1)
00059 : TGTextEntry(p, t, id) {}
00060
00061 virtual void Insert(const char*);
00062 };
00063
00064 class TGToggleButton : public TGTextButton
00065 {
00066 public:
00067 TGToggleButton(const TGWindow* p, const char* s, Int_t id = -1, GContext_t norm = GetDefaultGC()(), FontStruct_t font = GetDefaultFontStruct(), UInt_t option = kRaisedFrame|kDoubleBorder)
00068 : TGTextButton(p, s, id, norm, font, option) {}
00069
00070 virtual void SetState(EButtonState);
00071 };
00072
00073 class ScrollView : public TGCanvas
00074 {
00075 public:
00076 ScrollView(const TGWindow* p, UInt_t w, UInt_t h, UInt_t options = kSunkenFrame|kDoubleBorder, ULong_t back = fgDefaultFrameBackground)
00077 : TGCanvas(p, w, h, options, back) {}
00078
00079 virtual void Layout() {
00080 UInt_t cw, ch;
00081 Bool_t fixedw;
00082 TGFrame *container;
00083
00084 TGCanvas::Layout();
00085
00086 container = fVport->GetContainer();
00087 if (!container) {
00088 Error("Layout", "no canvas container set yet");
00089 return;
00090 }
00091
00092 cw = fWidth - (fBorderWidth << 1);
00093 ch = fHeight - (fBorderWidth << 1);
00094
00095 if (container->GetDefaultHeight() > ch) {
00096 if (fScrolling & kCanvasScrollVertical) {
00097 cw -= fVScrollbar->GetDefaultWidth();
00098 if ((Int_t) cw < 0) {
00099 cw = 10;
00100 }
00101 }
00102 }
00103
00104 fixedw = (container->GetOptions() & kFixedWidth) ? kTRUE : kFALSE;
00105 if (!fixedw) {
00106 container->SetWidth(cw);
00107 container->Layout();
00108 }
00109 }
00110 };
00111
00112 class TempControl;
00113
00114 class MainFrame : public TGMainFrame
00115 {
00116 public:
00117 friend class TempControl;
00118
00119 MainFrame(const TGWindow*, UInt_t, UInt_t);
00120 virtual ~MainFrame();
00121
00122 void CloseWindow();
00123 void HandleMenu(Int_t);
00124 void DoButtons(Int_t wid = -1, Int_t id = -1);
00125 void DoTempText(const char*);
00126
00127 void SetInfoAtoms(Int_t);
00128 void SetInfoDefects(Int_t);
00129 void SetInfoEnergy(Double_t);
00130 void SetInfoMoves(Int_t);
00131 void SetInfoImages(Int_t);
00132 void SetInfoStatus();
00133
00134 Bool_t IsInfoEnabled() { return pMenuView->IsEntryChecked(M_VIEW_INFO); }
00135
00136 Layer* GetLayer() { return pLayer; }
00137
00138 private:
00139 void FillParamCont(TGCompositeFrame*);
00140 void ClearEnFuncCombo(TGComboBox*);
00141 void FillEnFuncCombo(TGComboBox*);
00142
00143 TList *pCleanup;
00144 TList *pParamElems, *pParamVals;
00145 TGVSplitter *pSplitter;
00146 TGCompositeFrame *pMainCont, *pControlFrame;
00147 TGCompositeFrame *pSplitFrame, *pParamCont;
00148 TGCompositeFrame *pSimToolFr, *pSimBtFr;
00149 TGCompositeFrame *pSimTmpFr, *pSimLaunchBtFr;
00150 TGCompositeFrame *pInfoFr, *pFr;
00151 TGDoubleVSlider *pSimTmpSlider;
00152 TGNumEntry *pSimTmpEntry;
00153 TGTextBuffer *pSimTmpEBuf;
00154 TGLabel *pFuncL, *pLabel;
00155 TGLabel *pNumAtomL, *pNumDefL, *pEnergyL;
00156 TGLabel *pMovesL, *pImgL, *pStatusL;
00157 TGComboBox *pFuncCombo;
00158 ScrollView *pParamSV;
00159 TGGroupFrame *pParamGrFr, *pSimGrFr;
00160 TGToggleButton *pSimStartBt, *pSimStopBt;
00161 TGTextButton *pSimInsBt, *pSimRemBt, *pSimTempRangeBt;
00162 TGTextButton *pSimRemAllBt, *pSimUpdBt;
00163 TGTextButton *pParamSetBt, *pSimEnBt, *pSimOptsBt;
00164 TGHorizontal3DLine *pSimSep;
00165 TGLayoutHints *pL, *pL2;
00166 TGMenuBar* pMenuBar;
00167 TGPopupMenu *pMenuProg, *pMenuSim, *pMenuOpts;
00168 TGPopupMenu *pMenuView, *pMenuPlot;
00169 TGLayoutHints *pMenuBarLayout;
00170 TGLayoutHints *pMenuBarItemLayout;
00171 time_t simStartTime;
00172
00173 TRootEmbeddedCanvas* pRECanvas;
00174 TEFormula* pEFormula;
00175 TEF1* pEPlot1;
00176 TEF2* pEPlot2;
00177 Layer* pLayer;
00178 Configuration* pConfig;
00179 TempControl* pTempControl;
00180 };
00181
00182 class ParamFrame : public TGCompositeFrame
00183 {
00184 public:
00185 ParamFrame(TGCompositeFrame* fr, const char* id, const char* name, Double_t value, const char* descr);
00186 virtual ~ParamFrame();
00187
00188 void SetId(Int_t id);
00189
00190 TGCheckButton *pChk;
00191 TGTextEntry *pName, *pDescr;
00192 TGNumEntry *pValue;
00193
00194 protected:
00195 TGLayoutHints *pL1, *pL2, *pL3;
00196 TGCompositeFrame *pFr;
00197 };
00198
00199
00200
00201 class ConfigDialog
00202 {
00203 RQ_OBJECT("ConfigDialog");
00204
00205 public:
00206 ConfigDialog(Configuration*, const TGWindow*, const TGWindow*, UInt_t, UInt_t, UInt_t = kVerticalFrame);
00207 virtual ~ConfigDialog();
00208
00209 void CloseWindow();
00210 void DoOk();
00211 void DoCancel();
00212 Int_t DoSave();
00213 void DoTab(Int_t);
00214 void DoTabButtons(Int_t wid = -1, Int_t id = -1);
00215 static char* ParseExpression(Configuration*, const char*);
00216
00217 friend class AddFuncDlg;
00218 friend class RenFuncDlg;
00219
00220 private:
00221 void LoadParameters();
00222 void LoadFunctions(Int_t = -1);
00223 void RemoveFunctions();
00224 Int_t VerifyFunction(Int_t, Bool_t = kTRUE, Bool_t = kTRUE);
00225
00226 TGTransientFrame* pMain;
00227 TGHorizontalFrame *pFr1;
00228 TGTextButton *pOkButton, *pCancelButton, *pSaveButton;
00229 TGTab *pTab;
00230 TGCompositeFrame *pTabFrame;
00231 TGLayoutHints *pL, *pL1, *pL2, *pL3, *pL4;
00232 TList *pCleanup;
00233 TEFormula *pEFormula;
00234
00235
00236 Int_t curFuncId;
00237 TGCompositeFrame *pEnergyFr, *pParVarFr, *pFr;
00238 TGGroupFrame *pParListGrFr, *pVarGrFr, *pEnGrFr;
00239 TGLabel *pLabel;
00240 TGLabel *pXLabel, *pYLabel, *pZLabel;
00241 TGComboBox *pEnFunCombo;
00242 TGListView *pParLV;
00243 TGLVContainer *pParLVCont;
00244 TGHorizontal3DLine *pEnLine;
00245 TGTextEntry *pEnFunExp, *pEnFunLat;
00246 TGTextEntry *pXEntry, *pYEntry, *pZEntry;
00247 const LVPicture *pPic;
00248 TRootEmbeddedCanvas* pLatexCanv;
00249 TLatex *pLatexExpr;
00250 TGCompositeFrame *pLatexFr, *pLatexBtFr;
00251 TGCompositeFrame *pEnFunBtFr, *pEnBtFr;
00252 TGTextButton *pEnFunBtVer, *pEnFunBtRen;
00253 TGTextButton *pEnBtAdd, *pEnBtDel, *pEnBtRev;
00254 TGTextButton *pLatMBt, *pLatPBt;
00255
00256
00257 TGTextButton *pParamBtAdd, *pParamBtDel, *pParamBtRev;
00258 ParamFrame *pPFr;
00259 TGLabel *pParHeadL1, *pParHeadL2, *pParHeadL3;
00260 TGGroupFrame *pParGrFr;
00261 TGCompositeFrame *pParHeadFr;
00262 TGCompositeFrame *pParamFr, *pParLineFr;
00263 TGCompositeFrame *pParamBtFr;
00264 ScrollView *pParSV;
00265 TGCheckButton *pChkBox;
00266 TList *pParamLFr;
00267
00268
00269 Configuration* pConfig;
00270 };
00271
00272
00273 class SimulationDialog
00274 {
00275 RQ_OBJECT("SimulationDialog");
00276
00277 public:
00278 SimulationDialog(Configuration*, Lattice*, const TGWindow*, const TGWindow*, UInt_t, UInt_t, UInt_t = kVerticalFrame);
00279 virtual ~SimulationDialog();
00280
00281 void CloseWindow();
00282 void DoOk();
00283 void DoCancel();
00284 void DoTabButtons(Int_t wid = -1);
00285
00286 private:
00287 TGTransientFrame* pMain;
00288 TGTextButton *pOkButton, *pCancelButton, *pTryButton;
00289 TGTab *pTab;
00290 TGCompositeFrame *pTabFrame, *pBtFrame;
00291 TGCompositeFrame *pLatticeFr, *pFr;
00292 TGCompositeFrame *pMCFr, *pImgFr;
00293 TGGroupFrame *pAlgFr, *pGraphFr;
00294 TGGroupFrame *pAtomFr, *pDefectFr;
00295 TGGroupFrame *pInsRemFr;
00296 TGLabel *pBoltzmL, *pIntLimL, *pIntLimL2;
00297 TGLabel *pAShapeL, *pASizeL, *pAColorL;
00298 TGLabel *pDShapeL, *pDSizeL, *pDColorL;
00299 TGLabel *pUpdateL, *pUpdateL2;
00300 TGLabel *pImgFormatL, *pImgPathL, *pImgPrefixL;
00301 TGLabel *pAutoSaveL, *pAutoSaveL2;
00302 TGLabel *pInsL, *pInsL2, *pRemL, *pRemL2;
00303 TGCheckButton *pUpdateChBt, *pAutoSaveChBt;
00304 TGComboBox *pAShapeC, *pAColorC;
00305 TGComboBox *pDShapeC, *pDColorC;
00306 TGComboBox *pImgFormatC;
00307 TGTextEntry *pImgPathE, *pImgPrefixE;
00308 TGNumEntry *pBoltzmE, *pIntLimE;
00309 TGNumberEntry *pASizeE, *pDSizeE, *pUpdateNum;
00310 TGNumberEntry *pAutoSaveNum, *pInsE, *pRemE;
00311 TGLayoutHints *pL, *pL1, *pL2, *pL3, *pL4;
00312 TList *pCleanup;
00313
00314 Configuration *pConfig;
00315 Lattice *pLattice;
00316 };
00317
00318
00319 class AddFuncDlg
00320 {
00321 RQ_OBJECT("AddFuncDlg");
00322
00323 public:
00324 AddFuncDlg(ConfigDialog*, const TGWindow*, const TGWindow*, UInt_t, UInt_t, UInt_t = kVerticalFrame);
00325 virtual ~AddFuncDlg();
00326
00327 void DoButtons(Int_t = -1, Int_t = -1);
00328 void CloseWindow();
00329
00330 private:
00331 ConfigDialog *confDlg;
00332 TGTransientFrame* pMain;
00333 TGTextButton *pOkButton, *pCancelButton;
00334 TGCompositeFrame *pDlgFrame, *pBtFrame;
00335 TGLabel *pNameL;
00336 TGFuncNameEntry *pNameT;
00337 TGRadioButton *pEmptyRad, *pCloneRad;
00338 TGComboBox *pFuncList;
00339 TGGroupFrame *pGrpFrame;
00340 TGLayoutHints *pL;
00341 TList *pCleanup;
00342 };
00343
00344 class RenFuncDlg
00345 {
00346 RQ_OBJECT("RenFuncDlg");
00347
00348 public:
00349 RenFuncDlg(ConfigDialog*, const TGWindow*, const TGWindow*, UInt_t, UInt_t, UInt_t = kVerticalFrame);
00350 virtual ~RenFuncDlg();
00351
00352 void DoButtons(Int_t = -1);
00353 void CloseWindow();
00354
00355 private:
00356 ConfigDialog *confDlg;
00357 char *strLabel;
00358 Int_t id;
00359 TGTransientFrame* pMain;
00360 TGTextButton *pOkButton, *pCancelButton;
00361 TGCompositeFrame *pDlgFrame, *pBtFrame;
00362 TGLabel *pNameL;
00363 TGFuncNameEntry *pNameT;
00364 TGLayoutHints *pL;
00365 TList *pCleanup;
00366 };
00367
00368 class SliderRangeDlg
00369 {
00370 RQ_OBJECT("SliderRangeDlg");
00371
00372 public:
00373 SliderRangeDlg(TGDoubleSlider*, Configuration*, const TGWindow*, const TGWindow*, UInt_t, UInt_t, UInt_t = kVerticalFrame);
00374 virtual ~SliderRangeDlg();
00375
00376 void DoButtons(Int_t = -1);
00377 void CloseWindow();
00378
00379 private:
00380 Configuration *pConfig;
00381 TGDoubleSlider *slider;
00382 TGTransientFrame* pMain;
00383 TGLabel *pLabel;
00384 TGCompositeFrame *pDlgFrame;
00385 TGCompositeFrame *pRangeFr, *pBtFrame;
00386 TGNumEntry *pFromEntry, *pToEntry;
00387 TGTextButton *pOkButton, *pCancelButton;
00388 TGLayoutHints *pL;
00389 TList *pCleanup;
00390 };
00391
00392 class TempControl
00393 {
00394 RQ_OBJECT("TempControl");
00395
00396 public:
00397 TempControl(Configuration*, MainFrame*, const TGWindow*, const TGWindow*, UInt_t, UInt_t, UInt_t = kVerticalFrame);
00398 virtual ~TempControl();
00399
00400 void DoMinRange(char*);
00401 void DoMaxRange(char*);
00402 void CloseWindow();
00403 void DoSlider();
00404
00405 private:
00406 Configuration *pConfig;
00407 MainFrame *pMainFrame;
00408 TGTransientFrame* pMain;
00409 TGLabel *pTempL;
00410 TGCompositeFrame *pDlgFrame, *pRangeFrame;
00411 TGDoubleHSlider *pTempSlider;
00412 TGNumEntry *pFromEntry, *pToEntry;
00413 TGLayoutHints *pL1, *pL2;
00414 };
00415
00416 class LatticeDlg
00417 {
00418 RQ_OBJECT("LatticeDlg");
00419
00420 public:
00421 LatticeDlg(Layer*, const TGWindow*, const TGWindow*, UInt_t, UInt_t, UInt_t = kVerticalFrame);
00422 virtual ~LatticeDlg();
00423
00424 void DoButtons(Int_t = -1);
00425 void CloseWindow();
00426
00427 private:
00428 Layer *pLayer;
00429 TGTransientFrame* pMain;
00430 TGTextButton *pOkButton, *pCancelButton;
00431 TGCompositeFrame *pDlgFrame, *pBtFrame;
00432 TGLabel *pLatticeL, *pNumXL, *pNumYL, *pNumSizeL;
00433 TGComboBox *pLatticeCombo;
00434 TGNumEntry *pNumXE, *pNumYE, *pNumSizeE;
00435 TGLayoutHints *pL;
00436 TList *pCleanup;
00437 };
00438
00439
00440 #endif // _GUI_H_