1 /* 2 * (c) 2005 Iowa State University 3 * see the LICENSE file in the top level directory 4 */ 5 6 /*************************************** 7 * MolDisplayWin.h 8 * 9 * Defines a class that overloads the wxFrame class. This class is used for 10 * the document window(s). 11 ***************************************/ 12 13 #ifndef MolDisplayWin_H 14 #define MolDisplayWin_H 1 15 16 #include "wx/wx.h" 17 #include <wx/print.h> 18 19 #ifdef __WXOSX_COCOA__ 20 #include <OpenGL/glu.h> 21 #elif __WXMAC__ 22 #include <AGL/glu.h> 23 #else 24 #include <GL/glu.h> 25 #endif 26 27 #include "mpGLCanvas.h" 28 #include "MoleculeData.h" 29 #include "Prefs.h" 30 #include "Progress.h" 31 #include <deque> 32 #include "MyTypes.h" 33 34 typedef class BondsDlg BondsDlg; 35 typedef class CoordinatesWindow CoordinatesWindow; 36 typedef class EnergyPlotDialog EnergyPlotDialog; 37 typedef class FrequenciesDialog FrequenciesDialog; 38 typedef class SurfacesWindow SurfacesWindow; 39 typedef class InputBuilderWindow InputBuilderWindow; 40 typedef class ModeAnimation ModeAnimation; 41 typedef class ZMatrixCalculator ZMatrixCalculator; 42 typedef class setPreference setPreference; 43 typedef struct qtData qtData; 44 typedef class MolStatusBar MolStatusBar; 45 typedef class UndoSnapShot UndoSnapShot; 46 //typedef class ExportOptionsDialog ExportOptionsDialog; 47 class ExportOptionsDialog; 48 49 //#define ID_LOCAL_PREFERENCES 501 50 /** MMP_EventID contains a series of ids used mostly for menu items within the 51 * MolDisplayWin class. They are defined here so they can be reused for the same menus 52 * in subwindows of MolDisplayWin to allow the menu item to transparently be passed up 53 * to the parent window. 54 */ 55 enum MMP_EventID { 56 MMP_SHRINK10=wxID_HIGHEST+1, 57 MMP_ENLARGE10, 58 MMP_SHOWMODE, 59 MMP_PREVMODE, 60 MMP_NEXTMODE, 61 MMP_SHOWGRADIENT, 62 MMP_SHOWAXIS, 63 MMP_SHOWBUILDTOOLS, 64 MMP_SHOWSYMMETRYOPERATOR, 65 MMP_ATOMLABELSSUBMENU, 66 MMP_NO_ATOMLABEL, 67 MMP_SHOWATOMLABELS, 68 MMP_SHOWATOMNUMBER, 69 MMP_SHOWPATTERN, 70 MMP_BOTHATOMLABELS, 71 MMP_DISPLAYMODESUBMENU, 72 MMP_WIREFRAMEMODE, 73 MMP_BALLANDSTICKMODE, 74 MMP_EFP_WIREFRAME, 75 MMP_TOGGLEVISSUBMENU, 76 MMP_TOGGLEABINITIO, 77 MMP_TOGGLEMMATOMS, 78 MMP_TOGGLEEFPATOMS, 79 MMP_ADDMARKANNOTATION, 80 MMP_ADDLENGTHANNOTATION, 81 MMP_ADDANGLEANNOTATION, 82 MMP_ADDDIHEDRALANNOTATION, 83 MMP_DELETEALLANNOTATIONS, 84 MMP_CENTER, 85 MMP_AUTOROTATE, 86 MMP_ROTATESUBMENU, 87 MMP_ROTATETOXAXIS, 88 MMP_ROTATETOYAXIS, 89 MMP_ROTATETOZAXIS, 90 MMP_ROTATE180HOR, 91 MMP_ROTATE180VER, 92 MMP_ROTATEPRINC, 93 MMP_ROTATEOTHER, 94 MMP_CREATELLMPATH, 95 MMP_MINFRAMEMOVEMENTS, 96 MMP_CONVERTTOBOHR, 97 MMP_CONVERTTOANGSTROMS, 98 MMP_INVERTNORMALMODE, 99 MMP_ADDHYDROGENS, 100 MMP_DELETEHYDROGENS, 101 // The following is grouped together to be used in an UPDATE_UI_RANGE with the same handler 102 MMP_NEWFRAME, 103 MMP_COPYCOORDS, 104 MMP_COPYNWCOORDS, 105 MMP_ENERGYEDIT, 106 MMP_SETBONDLENGTH, 107 MMP_DETERMINEPG, 108 MMP_SYMADAPTCOORDS, 109 MMP_EXPORT, 110 MMP_ANNOTATIONSSUBMENU, 111 112 MMP_ADDFRAMES, 113 MMP_DELETEFRAME, 114 MMP_IMPORTMENU, 115 MMP_MOLECULEDISPLAYWINDOW, 116 MMP_BONDSWINDOW, 117 MMP_COORDSWINDOW, 118 MMP_ENERGYPLOTWINDOW, 119 MMP_FREQUENCIESWINDOW, 120 MMP_INPUTBUILDERWINDOW, 121 MMP_INPUT_WIZARD, 122 MMP_SURFACESWINDOW, 123 MMP_FRAMESCROLLBAR, 124 MMP_PRINTOPTIONS, 125 MMP_ANIMATEFRAMES, 126 MMP_ANIMATEFRAMESTIMER, 127 MMP_ANIMATEMODE, 128 MMP_ANIMATEMODETIMER, 129 MMP_STATUS_TIMER, 130 MMP_ROTATE_TIMER, 131 MMP_OFFSETMODE, 132 MMP_WINDOWPARAMETERS, 133 MMP_ZMATRIXCALC, 134 MMP_LOCAL_PREFERENCES, 135 MMP_SHOW_TOOLBAR, 136 MMP_CURPOINTGROUP, 137 MMP_POINTGROUPORDER, 138 MMP_PGC1, 139 MMP_PGCS, 140 MMP_PGCI, 141 MMP_PGCNH, 142 MMP_PGCNV, 143 MMP_PGCN, 144 MMP_PGS2N, 145 MMP_PGDND, 146 MMP_PGDNH, 147 MMP_PGDN, 148 MMP_PGTD, 149 MMP_PGTH, 150 MMP_PGT, 151 MMP_PGOH, 152 MMP_PGO, 153 MMP_PGORDER2, 154 MMP_PGORDER3, 155 MMP_PGORDER4, 156 MMP_PGORDER5, 157 MMP_PGORDER6, 158 MMP_PGORDER7, 159 MMP_PGORDER8, 160 MMP_TOOL_ARROW, 161 MMP_TOOL_LASSO, 162 MMP_TOOL_HAND, 163 MMP_SELECT_ALL, 164 MMP_SELECT_NONE, 165 MMP_SHOWBONDSITES, 166 MMP_SYMMETRY_EDIT, 167 /* MMP_SYMMETRY_REGEN, */ 168 MMP_SAVESTRUCTURE, 169 MMP_SHOW_FULLSCREEN, 170 171 Number_MMP_Ids 172 }; 173 174 /** 175 Abstract class to hold snapshot data. All you can do with a snapshot is 176 create it and restore it. 177 */ 178 class UndoSnapShot { 179 public: ~UndoSnapShot()180 virtual ~UndoSnapShot() {} Restore()181 virtual void Restore() {} 182 }; 183 184 /** 185 Class to hold snapshot data based on a single frame. This class will save/restore the basic 186 data of a single frame, ie atoms and bonds. 187 */ 188 class FrameSnapShot : public UndoSnapShot { 189 public: 190 /** Create a snapshot from the provided frame pointer. 191 */ 192 FrameSnapShot(MoleculeData * target); 193 virtual ~FrameSnapShot(); 194 /** Restore the saved data. Note the frame point is stored here 195 so you can't restore if the original frame memory has been 196 destroyed. 197 */ 198 virtual void Restore(); 199 private: 200 MoleculeData * targetData; ///< The target data structure 201 Frame * mTarget; ///< The target Frame. 202 mpAtom * Atoms; ///< Saved atom list 203 Bond * Bonds; ///< Saved bond list 204 long NumAtoms; ///< atom count 205 long NumBonds; ///< bond count 206 std::vector<std::string> FragmentNames; ///< Effective Fragment name for each fragment (FRAGNAME) 207 Internals * IntCoords; ///< Set of internal coordinate definitions 208 }; 209 210 /** Container class for undo/redo data. This class manages the list of 211 snapshots such that the program just needs to add or retrieve snapshots. 212 Normally each of the MolDisplayWins will contain one of these classes. 213 */ 214 class UndoData { 215 public: UndoData()216 UndoData() : operationCount(0), position(0) {} ~UndoData()217 ~UndoData() {Clear();} 218 ///How many snapshots are saved. GetOperationCount()219 int GetOperationCount() const {return operationCount;} 220 ///Obtains the position in the snapshot list. GetPosition()221 int GetPosition() const {return position;} 222 ///Move the snapshot position manually (not normally needed). SetPosition(int p)223 void SetPosition(int p) {if ((p>=0)&&(p<operationCount)) position = p;} 224 ///Is undo possible? undoPossible()225 bool undoPossible() const {return ((operationCount > 0)&&(position > 0));} 226 ///Is redo possible? redoPossible()227 bool redoPossible() const {return ((position+1) < operationCount);} 228 ///Remove all snapshots and free their memory. 229 void Clear(); 230 ///Add a snapshot to the stack. 231 void AddSnapshot(UndoSnapShot *); 232 ///Undo to the previous snapshot. 233 void UndoOperation(); 234 ///Redo to the next snapshot. 235 void RedoOperation(); 236 private: 237 std::deque<UndoSnapShot *> UndoList; 238 int operationCount; 239 int position; 240 }; 241 242 /** 243 * Subclasses wxFrame to define the main application window. This is a 244 * document window. There can be multiple instances of the window in the 245 * application, and each main window owns its dialogs. 246 */ 247 class MolDisplayWin : public wxFrame { 248 friend class MpGLCanvas; 249 private: 250 wxMenuBar *menuBar; 251 wxMenu *menuFile; 252 wxMenu *menuEdit; 253 wxMenu *menuView; 254 wxMenu *menuViewLabels; 255 wxMenu *menuViewStyle; 256 wxMenu *menuViewAnnotations; 257 wxMenu *menuViewRotate; 258 wxMenu *menuBuild; 259 wxMenu *menuMolecule; 260 wxMenu *menuSetPG; 261 wxMenu *menuPointGroup; 262 wxMenu *menuPGOrder; 263 wxMenu *menuWindow; 264 wxMenu *menuHelp; 265 266 wxString currFilePath; 267 MoleculeData *MainData; 268 WinPrefs *Prefs; 269 UndoData mUndoBuffer; 270 bool Dirty; ///< Flag to indicate a save is needed 271 bool OperationInProgress; 272 bool timerRunning; 273 bool show_fullscreen; 274 bool edit_symmetrically; 275 bool do_rotate_annotation; 276 bool GLUpdateInProgress; ///< flag to prevent multiple simultaneous GL updates 277 278 Progress *ProgressInd; ///< Progress indicator window for long operations 279 MpGLCanvas *glCanvas; 280 MolStatusBar *myStatus; 281 ModeAnimation *ModeAnimationData; 282 wxTimer m_timer; 283 wxTimer status_timer; 284 wxTimer rotate_timer; 285 286 BondsDlg *bondsWindow; 287 CoordinatesWindow *coordsWindow; 288 EnergyPlotDialog *energyPlotWindow; 289 FrequenciesDialog *frequenciesWindow; 290 SurfacesWindow *surfacesWindow; 291 InputBuilderWindow *inputBuilderWindow; 292 setPreference *prefsDlg; 293 ZMatrixCalculator *zMatCalcDlg; 294 295 WindowData winData; 296 297 wxPageSetupDialogData *pageSetupData; 298 wxPrintData *printData; 299 300 bool mHighliteState; 301 bool stale_click; 302 wxToolBar *toolbar; 303 bool mAltModifyingToolBar; 304 305 bool is_lassoing; 306 bool lasso_has_area; 307 wxPoint lasso_start; 308 wxPoint lasso_end; 309 310 wxPoint mouse_start; 311 wxPoint inertia; 312 313 bool show_bond_sites; 314 bool window_just_focused; 315 316 myGLTriangle *transpTriList; ///< The list of transparent triangles 317 float *transpSortVertex; ///< The rotated screen Z coordinate to sort on. 318 long *transpIndex; ///< The sorted triangle list 319 long triangleCount; ///< The number of transparent triangles 320 321 GLuint MainDisplayList; ///< id for a main display list 322 GLuint SurfaceDisplayList; 323 bool MainListActive; 324 bool SurfaceListActive; 325 bool haveTransparentSurfaces; ///< Flag if there are transparent surfaces 326 GLuint length_anno_tex_id; ///< texture id for length annotations 327 GLuint sphere_list; 328 GLuint shader_program; 329 GLuint depth_fbo; 330 GLuint depth_tex_id; 331 GLfloat fg_color[3]; 332 GLfloat light_pos[4]; 333 334 ///Called by the constructor to setup the initial menubar 335 void createMenuBar(); 336 /** 337 * Called by the GAMESS log file code to specifically handle IRC type log files. 338 * @param Buffer The file buffer to parse. 339 * @param flip Indicator that the IRC distance should be multiplied by -1. 340 * @param offset Amount to offset the transition state for the IRC. 341 * @param NumOccAlpha number of alpha occupied orbitals. 342 * @param NumOccBeta Number of beta occupied orbitals. 343 * @param NumFragmentAtoms Number of EFP style atoms. 344 */ 345 long OpenGAMESSIRCLog(BufferFile * Buffer, long flip, float offset, 346 long NumOccAlpha, long NumOccBeta, long NumFragmentAtoms); 347 /** 348 * Called by the GAMESS log file code to specifically handle GlobOp type log files. 349 * @param Buffer The file buffer to parse. 350 * @param NumOccAlpha number of alpha occupied orbitals. 351 * @param NumOccBeta Number of beta occupied orbitals. 352 * @param NumFragmentAtoms Number of EFP style atoms. 353 */ 354 long OpenGAMESSGlobOpLog(BufferFile * Buffer, long NumOccAlpha, long NumOccBeta, 355 long NumFragmentAtoms); 356 /** 357 * Callback for when the user clicks on a button in the toolbar. The function ensures 358 * at exactly one button is always selected. 359 */ 360 void OnToggleTool(wxCommandEvent& event); 361 void OnStatusTimer(wxTimerEvent& event); 362 void OnRotateTimer(wxTimerEvent& event); 363 void OnShowNormalScreen(wxUpdateUIEvent& event); 364 void OnSaveUpdate(wxUpdateUIEvent& event); 365 void ShowToolbar(bool enable = true); 366 void OnShowToolbarUpdate(wxUpdateUIEvent& event); 367 void OnShowBuildToolsUpdate(wxUpdateUIEvent& event); 368 369 void OnSaveStructureUpdate(wxUpdateUIEvent& event); 370 void DeleteSelected(); 371 void RegenerateSymmetryDependent(); 372 void DoPrefDependent(); 373 std::map<std::string, EFrag>::const_iterator FindFragmentDef(std::string fragName); 374 375 DECLARE_EVENT_TABLE() 376 377 public: 378 /** 379 * Constructor that provides some useful default values. 380 * @param title The text that will be displayed in the new window's title bar. 381 * @param position The initial position of the new window. 382 * @param size The initial size of the new window. 383 * @param style The style of the new window. See wxFrame class docs. 384 * @param name The name of the new window. 385 */ 386 MolDisplayWin(const wxString &title, 387 const wxPoint &position = wxDefaultPosition, 388 const wxSize &size = wxDefaultSize, 389 long style = wxDEFAULT_FRAME_STYLE, 390 const wxString &name = wxT("MpMainFrame")); 391 392 /** 393 * Destructor, mostly for cleaning up data that we've allocated 394 * independently of wxWidgets. 395 */ 396 virtual ~MolDisplayWin(); 397 398 /** 399 * Gets the dimensions of the glCanvas. 400 * @param width A pointer to an integer that will be set to the width 401 * @param height A pointer to an integer that will be set to the height 402 */ 403 void getCanvasSize(long *width, long *height); 404 405 //Call to update the menu bar itesm for the current data 406 void AdjustMenus(); 407 void ClearMenus(); 408 // Below are the event handler functions for the menu. The initial 409 // list was taken from the original MacMolPlt menus. 410 411 void menuFileOpen(wxCommandEvent &event); 412 void menuFileSave(wxCommandEvent &event); 413 void menuFileSave_as(wxCommandEvent &event); 414 bool CreateCustomFileIcon(const wxString & filePath); 415 void menuFileClose(wxCommandEvent &event); 416 void FileClose(wxCloseEvent &event); 417 void menuFileAppendNewFrame(wxCommandEvent &event); 418 void menuFileAddFramesFromFile(wxCommandEvent &event); 419 void menuFileDeleteFrame(wxCommandEvent &event); 420 void menuFileImport(wxCommandEvent &event); 421 void menuFileExport(wxCommandEvent &event); 422 void menuFilePage_setup(wxCommandEvent &event); 423 void menuFilePrintOptions(wxCommandEvent &event); 424 void menuFilePrint_preview(wxCommandEvent &event); 425 void menuFilePrint(wxCommandEvent &event); 426 427 void menuEditUndo(wxCommandEvent &event); 428 void menuEditRedo(wxCommandEvent &event); 429 void OnUndoUpdate( wxUpdateUIEvent& event ); 430 void OnRedoUpdate( wxUpdateUIEvent& event ); 431 void menuEditCut(wxCommandEvent &event); 432 void menuEditCopy(wxCommandEvent &event); 433 /// Callback for the GAMESS style copy coords menu item 434 void menuEditCopyCoordinates(wxCommandEvent &event); 435 /// Callback for the NWChem style copy coords menu item 436 void menuEditCopyNWChemCoordinates(wxCommandEvent &event); 437 /// Place a text copy of the coordinates into the copy buffer 438 /** 439 * Creates a text copy of the coorindates and places on to the copy buffer. 440 * @param[in] coordtype specifies GAMESS style cartesians (0), GAMESS Z-matrix (1) or NWChem style Cartesians(2) 441 */ 442 void CopyCoordinates(short coordtype) const; 443 void menuEditPaste(wxCommandEvent &event); 444 /// wxEVT_UPDATE_UI event handler for wxID_PASTE 445 void OnPasteUpdate( wxUpdateUIEvent& event ); 446 void PasteText(); 447 void menuEditClear(wxCommandEvent &event); 448 void menuEditSelectAll(wxCommandEvent &event); 449 void menuEditSelectNone(wxCommandEvent &event); 450 /// wxEVT_UPDATE_UI event handler for selection changes 451 void OnSelectAllUpdate(wxUpdateUIEvent& event); 452 void OnSelectNoneUpdate(wxUpdateUIEvent& event); 453 void OnDeleteUpdate(wxUpdateUIEvent& event); 454 455 void menuViewShowFullScreen(wxCommandEvent &event); 456 void menuViewShowNormalMode(wxCommandEvent &event); 457 void menuViewPrevNormalMode(wxCommandEvent &event); 458 void menuViewNextNormalMode(wxCommandEvent &event); 459 // void menuViewDisplay_frequencyDOSTUFF(wxCommandEvent &event); 460 void menuViewOffsetAlongMode(wxCommandEvent &event); 461 void menuViewAnimateMode(wxCommandEvent &event); 462 void menuViewAnimateFrames(wxCommandEvent &event); 463 /// Update UI event handler for the Show Gradient menu item. 464 void OnViewGradientUpdate(wxUpdateUIEvent& event); 465 /// Event handler for the user toggling the show Gradient menu item. 466 void menuViewShowGradient(wxCommandEvent &event); 467 //void menuViewShow_special_atoms(wxCommandEvent &event); 468 //void menuVeiwShow_hydrogen_labels(wxCommandEvent &event); 469 void menuViewShowAxis(wxCommandEvent &event); 470 void menuViewShowSymmetryOperators(wxCommandEvent &event); 471 void menuViewHideAtomLabels(wxCommandEvent &event); 472 void menuViewShowAtomLabel(wxCommandEvent &event); 473 void menuViewShowAtomNumber(wxCommandEvent &event); 474 void menuViewShowBothAtomLabels(wxCommandEvent &event); 475 void menuViewAddAnnotation(wxCommandEvent &event); 476 void menuViewAddMarkAnnotation(wxCommandEvent &event); 477 ///Menu item handler to toggle the visibility of ab inito atoms 478 void menuViewToggleAIAtomsVis(wxCommandEvent & event); 479 ///Menu item handler to toggle the visibility of Molecular mechanics atoms 480 void menuViewToggleMMAtomsVis(wxCommandEvent & event); 481 ///Menu item handler to toggle the visibility of effective fragment potential atoms 482 void menuViewToggleEFPAtomsVis(wxCommandEvent & event); 483 void OnAnnotationMarkUpdate(wxUpdateUIEvent &event); 484 void OnAnnotationLengthUpdate(wxUpdateUIEvent &event); 485 void OnAnnotationAngleUpdate(wxUpdateUIEvent &event); 486 void OnAnnotationDihedralUpdate(wxUpdateUIEvent &event); 487 void OnShowSymOpsUpdate(wxUpdateUIEvent &event); 488 void menuViewDeleteAllAnnotations(wxCommandEvent &event); 489 void OnDeleteAnnotationsUpdate(wxUpdateUIEvent &event); 490 void menuViewShow2DPattern(wxCommandEvent &event); 491 void OnShowPatternUpdate(wxUpdateUIEvent &event); 492 void menuViewWireFrameStyle(wxCommandEvent &event); 493 void menuViewBallAndStickStyle(wxCommandEvent &event); 494 void menuViewEFP_Wireframe(wxCommandEvent &event); 495 void OnEFPWireFrameUpdate(wxUpdateUIEvent &event); 496 void menuViewShrink_10(wxCommandEvent &event); 497 void menuViewEnlarge_10(wxCommandEvent &event); 498 void menuViewCenter(wxCommandEvent &event); 499 void menuViewToggleAutoRotation(wxCommandEvent &event); 500 void OnAutoRotationUpdate(wxUpdateUIEvent &event); 501 void menuViewRotateInPlace(const Matrix4D new_m); 502 void menuViewRotateTo_X_axis(wxCommandEvent &event); 503 void menuViewRotateTo_Y_axis(wxCommandEvent &event); 504 void menuViewRotateTo_Z_axis(wxCommandEvent &event); 505 void menuViewRotate180_horizontal(wxCommandEvent &event); 506 void menuViewRotate180_vertical(wxCommandEvent &event); 507 void menuViewRotatePrinciple_orientation(wxCommandEvent &event); 508 void menuViewRotateOther(wxCommandEvent &event); 509 void menuViewSetWindowParameters(wxCommandEvent &event); 510 //void menuViewStereo(wxCommandEvent &event); 511 512 void menuBuilderSaveStructure(wxCommandEvent &event); 513 514 void menuPreferences(wxCommandEvent &event); 515 void ClosePrefsWindow(); 516 517 void menuMoleculeSetBondLength(wxCommandEvent &event); 518 void menuMoleculeSetFrameEnergy(wxCommandEvent &event); 519 /** 520 * Updates the Create LLM menu item. 521 */ 522 void OnMoleculeCreateLLMPathUpdate(wxUpdateUIEvent &event); 523 /** 524 * Put up the Create LLM dialog. This should only be called when there is at 525 * least one frame after the current frame. 526 */ 527 void menuMoleculeCreateLLMPath(wxCommandEvent &event); 528 void menuMoleculeMinimizeFrameMovements(wxCommandEvent &event); 529 void OnShowPointGroupUpdate(wxUpdateUIEvent &event); 530 void menuSetPointGroup(wxCommandEvent &event); 531 void menuSetPointGroupOrder(wxCommandEvent &event); 532 void menuMoleculeDetermineSym(wxCommandEvent &event); 533 void menuMoleculeSymCoords(wxCommandEvent &event); 534 void menuMoleculeConvertToBohr(wxCommandEvent &event); 535 void menuMoleculeConvertToAngstroms(wxCommandEvent &event); 536 void menuMoleculeInvertNormalMode(wxCommandEvent &event); 537 538 void Dirtify(bool is_dirty = true); 539 540 /** 541 * Fills out the coordination of every atom with hydrogens. 542 * @param event The command event (not used). 543 */ 544 void menuBuilderAddHydrogens(wxCommandEvent &event); 545 /** 546 * Deletes all hydrogen atoms, except non-bonded atoms, and atoms that are 547 * part of fragments or SIMOMM. 548 * @param event The command event (not used). 549 */ 550 void menuBuilderDeleteHydrogens(wxCommandEvent &event); 551 /** 552 * Toggles the display of bonding sites when in edit mode in the molecule builder. 553 * @param event The command event (not used). 554 */ 555 void menuBuilderShowBondSites(wxCommandEvent &event); 556 void menuBuilderSymmetryEdit(wxCommandEvent &event); 557 /* void menuBuilderRegenSymmetry(wxCommandEvent &event); */ 558 /** 559 * Toggles the toolbar. When active a toolbar is added to the main 560 * display window. 561 * @param event The command event (not used). 562 */ 563 void menuBuilderShowToolbar(wxCommandEvent &event); 564 /** 565 * Toggles the build tools palette. 566 * @param event The command event (not used). 567 */ 568 void menuBuilderShowBuildTools(wxCommandEvent &event); 569 /** 570 * Updates the add hydrogens menu item based on the current edit mode and ability to add 571 * hydrogens. 572 * @param event The UpdateUI event. 573 */ 574 void OnAddHydrogensUpdate( wxUpdateUIEvent& event ); 575 /** 576 * Updates the show bond sites menu item based on the edit mode. 577 * @param event The UpdateUI event. 578 */ 579 void OnShowBondSitesUpdate(wxUpdateUIEvent& event); 580 void OnShowSymmetryEdit(wxUpdateUIEvent& event); 581 void UpdateAtomsOptions(wxUpdateUIEvent& event); 582 583 //Commands to open (or raise) the various data subviews. 584 585 /// Raise the main molecule display window. 586 /// Passed up from subwindows. 587 void menuWindowMoleculeDisplay(wxCommandEvent &event); 588 void menuWindowBonds(wxCommandEvent &event); 589 void menuWindowCoordinates(wxCommandEvent &event); 590 void menuWindowEnergy_plot(wxCommandEvent &event); 591 void menuWindowFrequencies(wxCommandEvent &event); 592 void menuWindowInput_builder(wxCommandEvent &event); 593 void menuWindowSurfaces(wxCommandEvent &event); 594 void menuWindowZMatrixCalc(wxCommandEvent &event); 595 void KeyHandler(wxKeyEvent &event); 596 /** 597 * Handles KEY_UP events received by the window. 598 * @param event The event to handle. 599 */ 600 void KeyUpHandler(wxKeyEvent &event); 601 void CloseBondsWindow(); 602 void CloseCoordsWindow(); 603 void CloseEnergy_plotWindow(); 604 void CloseFrequenciesWindow(); 605 void CloseSurfacesWindow(); 606 void CloseInputBuilderWindow(); 607 void CloseZMatrixCalc(); 608 void OnActivate(wxActivateEvent & event); 609 610 //File handling routines 611 long OpenFile(wxString fileName, float offset=0.0, bool flip=false, bool append=false); 612 long OpenCMLFile(BufferFile * Buffer, bool readPrefs=true, bool readWindows=true); 613 long OpenGAMESSlog(BufferFile *Buffer, bool Append, long flip, float offset); 614 /** 615 Open a GAMESS IRC file (pre 2009). 616 @param Buffer The buffer connected to the DRC file. 617 @param Append true if this file is to be appended to existing points. 618 @param flip is a multiplier for the x-coordinate (such as -1). 619 @param offset is added to the x-coordinate. 620 \return Returns 1 upon open success or 0 on error or failure to open 621 */ 622 long OpenGAMESSIRC(BufferFile * Buffer, bool Append, long flip, float offset); 623 /** 624 Open a GAMESS DRC (aka DRP) file (pre 2009). 625 @param Buffer The buffer connected to the DRC file. 626 @param LogFile true if this is a DRC GAMESS log file, false if the .irc file. 627 @param Append true if this file is to be appended to existing points. 628 @param flip is a multiplier for the x-coordinate (such as -1). 629 @param offset is added to the x-coordinate. 630 \return Returns 1 upon open success or 0 on error or failure to open 631 */ 632 long OpenGAMESSDRC(BufferFile * Buffer, bool LogFile, bool Append, 633 long flip, float offset); 634 /** 635 Open a GAMESS trajectory file. 636 @param Buffer The buffer connected to the TRJ file. 637 @param Append true if this file is to be appended to existing points. 638 @param flip is a multiplier for the x-coordinate (such as -1). 639 @param offset is added to the x-coordinate. 640 \return Returns 1 upon open success or 0 on error or failure to open 641 */ 642 long OpenGAMESSTRJ(BufferFile * Buffer, bool Append, long flip, float offset); 643 long OpenXYZFile(BufferFile * Buffer); 644 /** 645 * Parses the Protein Databank Format (just atoms). 646 * @param Buffer A BufferFileObject which the PDB file is buffered into 647 * @return Returns 1 upon open success or 0 on error or failure to open 648 */ 649 long OpenPDBFile(BufferFile * Buffer); 650 /** 651 * Parses the MDL Mol Format (just atoms). 652 * @param Buffer A BufferFileObject which the MDL mol file is buffered into 653 * @return Returns 1 upon open success or 0 on error or failure to open 654 */ 655 long OpenMDLMolFile(BufferFile * Buffer); 656 /** 657 Open a GAMESS input or ".INP" format file. 658 @param Buffer The buffer connected to the INP file. 659 */ 660 long OpenGAMESSInput(BufferFile * Buffer); 661 long OpenMolPltFile(BufferFile * Buffer); 662 long OpenMoldenFile(BufferFile * Buffer); 663 /** 664 Open a Molekel or ".MKL" format file. 665 @param Buffer The buffer connected to the MKL file. 666 \return Returns 1 upon open success or 0 on error or failure to open 667 */ 668 long OpenMKLFile(BufferFile * Buffer); 669 long ParseSIMMOMLogFile(BufferFile * Buffer, long EnergyPos); 670 /** 671 Open a MOPAC ".MOP" or archive ".ARC" file. 672 @param Buffer The buffer connected to the MOP file. 673 @param fileType char designating which file extension is used 674 \return Returns 1 upon open success or 0 on error or failure to open 675 */ 676 long OpenMOPACFile(BufferFile * Buffer, TextFileType fileType); 677 /** 678 Output the coordinates in gamess input format ($DATA and $EFRAG group). 679 If AllFrames then a series of $DATA groups will be output for the user to divide as needed. 680 @param Buffer A buffer to write the text to. 681 @param AllFrames Should the data for all frames be included or just the current frame? 682 */ 683 void ExportGAMESS(BufferFile * Buffer, bool AllFrames); 684 /** 685 Output the plotted energies for the system to a tab de-limited text file. 686 @param Buffer A buffer to write the text to. 687 @param AllFrames Should the data for all frames be included or just the current frame? 688 */ 689 void WriteTabbedEnergies(BufferFile * Buffer, bool AllFrames); 690 /** 691 Output the frequencies for the current frame to a text file. 692 @param Buffer A buffer to write the text to. 693 */ 694 void WriteFrequencies(BufferFile * Buffer); 695 /** 696 Export the current system to an XYZ format file. 697 @param Buffer A buffer to write the text to. 698 @param AllFrames Should the data for all frames be included or just the current frame? 699 @param AllModes Should the normal modes be output or just the current one? 700 @param AnimateMode Flag to produce a sequence of geometries animating the current normal mode. 701 */ 702 void WriteXYZFile(BufferFile * Buffer, bool AllFrames, bool AllModes, bool AnimateMode); 703 /** 704 Export the current system to an MDL mol file. 705 @param Buffer A buffer to write the text to. 706 */ 707 void WriteMDLMolFile(BufferFile * Buffer); 708 /** 709 Export the current model to a Virtual Reality Markup Language file. 710 @param Buffer A buffer to write the output to. 711 */ 712 void WriteVRMLFile(BufferFile * Buffer); 713 /** 714 Export the current model to a POV-ray input file. 715 @param Buffer A buffer to write the output to. 716 */ 717 void WritePOVFile(BufferFile *Buffer); 718 /** 719 Export a series of frames or normal mode animation to an animated GIF file. 720 @param filepath The target name for the file 721 @param dlg The export options dialog to be used to retrieve the various movie setup options 722 */ 723 void WriteGIFMovie(wxString & filepath, ExportOptionsDialog * dlg); 724 #ifdef __MAC_USE_QUICKTIME__ 725 //quicktime movie export 726 void WriteQTMovie(wxString & filepath); 727 void CreateFrameMovie(GWorldPtr lgWorld, Handle CompressedData, 728 const qtData & myqtData, bool IncludeEPlot); 729 void CreateModeMovie(GWorldPtr lgWorld, Handle CompressedData, 730 const qtData & myqtData); 731 #endif 732 #ifdef HAVE_LIBMING 733 void WriteFlashMovie(wxString & filepath); 734 void CreateFrameMovie(wxString & filePath, const bool includeEP); 735 void CreateModeMovie(wxString & filePath); 736 #endif 737 //Call to dump the message and close the window 738 void AbortOpen(const char * msg); 739 740 //General Utility routines 741 /** 742 Call when the atoms list is updated to cause all subwindows to update. 743 @param updateCoordsWin Should the coordinates window be updated (if open)? 744 @param updateDisplay Should the main molecule display be updated? 745 */ 746 void AtomsChanged(bool updateCoordsWin=false, bool updateDisplay=false); 747 /** 748 Call when the bonds list is changed to update the bonds subwindow and the main display. 749 */ 750 void BondsChanged(); 751 /** 752 Call to update surfaces (as needed) and the main display window. Generally this 753 is called after the frame is changed or after a significant change to the frame data. 754 */ 755 void FrameChanged(); 756 void ChangeFrames(long NewFrame); 757 /** 758 Call to insert the selected atoms at the provided index. 759 @param index The position in the atom list to insert the 1st selected atom. 760 */ 761 void ChangeAtomOrder(long index); 762 void ModeChanged(); 763 void ChangeModes(long NewMode); 764 void UpdateModelDisplay(); GetData()765 MoleculeData * GetData() const {return MainData;} GetPrefs()766 WinPrefs * GetPrefs() const {return Prefs;} 767 void SetWindowPreferences(WinPrefs * NewPrefs); 768 /* void ChangePrefs(WinPrefs * newPrefs); */ 769 void ResetView(); 770 void ResetModel(bool Center); 771 void ResetAllWindows(); 772 void UpdateFrameText(); 773 void BeginOperation(); 774 void FinishOperation(); OperInProgress()775 bool OperInProgress() const {return OperationInProgress;} 776 /** 777 * Updates the visibility and position information. This should 778 * be called before saving the state of the file. 779 */ 780 void UpdateWindowData(); 781 /** 782 * Pulls the window data for this document, copies it to the default and 783 * saves it in the user preferences. 784 */ 785 void SetDefaultWindowData(); 786 787 //OpenGL drawing routines 788 void DrawGL(int do_shader = true); 789 void SortTransparentTriangles(); 790 void DrawTransparentTriangles(); 791 void DrawMoleculeCoreGL(); 792 void AddAxisGL(); 793 void AddSymmetryOperators(); 794 void ReleaseLists(); 795 void Rotate(wxMouseEvent&); 796 void ShowRotation(bool ShowAngles, bool ShowTrackball); 797 static void DrawHydrogenBond(const Bond& bond, const mpAtom& atom1, 798 const mpAtom& atom2, 799 const WinPrefs& Prefs, 800 GLUquadric *quadric, GLuint sphere_list, 801 bool highlighting_on = false); 802 static void DrawBond(const Bond& bond, const mpAtom& atom1, 803 const mpAtom& atom2, const WinPrefs& Prefs, 804 GLUquadric *quadric, GLdouble *modelview, 805 GLdouble *proj, GLint *viewport, 806 GLuint sphere_list, bool highlighting_on = false, 807 bool cap_dependent = false); 808 void PrintGL(wxDC * dc, const float & scaleFactor); SetHighliteMode(bool state)809 void SetHighliteMode(bool state) { mHighliteState = state; } 810 void DrawStaticLabel(const char* label, GLfloat x, GLfloat y); 811 void DrawLabel(); 812 void SelectionChanged(bool mode); GetLengthTexId()813 GLuint GetLengthTexId() const {return length_anno_tex_id;} GetSphereList()814 GLuint GetSphereList() const { return sphere_list; } 815 816 bool IsRotating(); 817 void eventSize(wxSizeEvent &event); 818 /* void SizeChanged(); */ 819 void OnFrameAnimationTimer(wxTimerEvent & event); 820 //Called during normal mode animations 821 void OnModeAnimation(wxTimerEvent & event); 822 //Function to be called when window loses focus to stop animations 823 void OnMenuOpen(wxMenuEvent & event); 824 void OnKillFocus(wxFocusEvent & event); 825 void StopAnimations(); 826 void LassoStart(const int x, const int y); 827 void LassoGrown(const int x, const int y); 828 void LassoEnd(); 829 bool LassoContains(const int x, const int y); 830 bool LassoHasArea(); 831 bool InSelectionMode(); 832 bool InViewMode(); 833 bool InEditMode(); 834 bool InSymmetryEditMode(); 835 void DrawBondingSites(long iatom, float radius, GLUquadricObj *qobj, int site_id=0, CPoint3D * vector=NULL); 836 void SetStatusText(const wxString& label); 837 /** 838 Call to push a snapshot of the current coordinates to the undo stack. 839 */ 840 void CreateFrameSnapShot(); 841 void ToggleBuilderPalette(); GetPrefs()842 WinPrefs *GetPrefs() {return Prefs;} 843 bool JustFocused(); 844 }; 845 846 class MolPrintOut : public wxPrintout { 847 public: 848 MolPrintOut(MolDisplayWin * parent, wxString & title); 849 bool OnPrintPage(int page); 850 bool HasPage(int page); 851 bool OnBeginDocument(int startPage, int endPage); 852 void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo); 853 private: 854 MolDisplayWin * Parent; 855 }; 856 857 #endif /* #ifndef MolDisplayWin_H */ 858 859