//IMPLEMENT_CLASS(MyApp, wxApp)
BEGIN_EVENT_TABLE(MyApp, wxApp)
- //EVT_KEY_DOWN(MyApp::OnChar)
- //EVT_MOUSE_EVENTS(MyApp::OnMouseEvent)
EVT_COMMAND(MyDocumentEvent_scriptMenuModified, MyDocumentEvent, MyApp::OnScriptMenuModified)
EVT_COMMAND(MyDocumentEvent_openFilesByIPC, MyDocumentEvent, MyApp::OnOpenFilesByIPC)
EVT_UPDATE_UI_RANGE(myMenuID_MyFirstMenuItem, myMenuID_MyLastMenuItem, MyApp::OnUpdateUI)
EVT_MENU(myMenuID_EmptyConsoleWindow, MyApp::OnEmptyConsoleWindow)
EVT_MENU(myMenuID_ViewGlobalParameters, MyApp::OnViewGlobalParameters)
EVT_MENU(myMenuID_ViewParameterFilesList, MyApp::OnViewParameterFilesList)
-// EVT_MENU(myMenuID_ImportAmberLib, MyApp::OnImportAmberLib)
#if defined(__WXMAC__)
EVT_ACTIVATE(MyApp::OnActivate)
#endif
show_menu->Append(myMenuID_CenterSelection, _T("Center Selection"));
show_menu->AppendSeparator();
show_menu->Append(myMenuID_ShowUnitCell, _T("Show Unit Cell"), _T(""), wxITEM_CHECK);
-/* show_menu->Append(myMenuID_ShowPeriodicBox, _T("Show Periodic Box"), _T(""), wxITEM_CHECK); */
show_menu->Append(myMenuID_ShowHydrogens, _T("Show Hydrogen Atoms"), _T(""), wxITEM_CHECK);
show_menu->Append(myMenuID_ShowDummyAtoms, _T("Show Dummy Atoms"), _T(""), wxITEM_CHECK);
show_menu->Append(myMenuID_ShowExpandedAtoms, _T("Show Expanded Atoms"), _T(""), wxITEM_CHECK);
md_menu->Append(myMenuID_Minimize, _T("Minimize..."));
md_menu->Append(myMenuID_StopMDRun, _T("Stop\tCtrl-."));
md_menu->AppendSeparator();
-// md_menu->Append(myMenuID_ReadParameters, _T("Read Parameters..."));
-// md_menu->Append(myMenuID_RunAntechamber, _T("Auto Guess MM/MD Parameters..."));
-// md_menu->Append(myMenuID_GuessUFFParameters, _T("Guess UFF Parameters..."));
md_menu->Append(myMenuID_ViewGlobalParameters, _T("View Global Parameters..."));
md_menu->Append(myMenuID_ViewParameterFilesList, _T("Load/Unload Global Parameters..."));
-// md_menu->AppendSeparator();
-// md_menu->Append(myMenuID_DefinePeriodicBox, _T("Define Unit Cell..."));
-// md_menu->Append(myMenuID_ShowPeriodicImage, _T("Show Periodic Image..."));
-/* md_menu->Append(myMenuID_PressureControl, _T("Pressure Control...")); */
-/* md_menu->Append(myMenuID_DefineSymmetry, _T("Define Symmetry Operations..."));
- md_menu->Append(myMenuID_ExpandBySymmetry, _T("Expand by Symmetry...")); */
-// md_menu->AppendSeparator();
-
-// wxMenu *md_tools_menu = new wxMenu;
-/* md_tools_menu->Append(myMenuID_RunAntechamber, _T("Antechamber/parmchk...")); */
-// md_tools_menu->Append(myMenuID_RunResp, _T("GAMESS/RESP..."));
-// md_tools_menu->Append(myMenuID_CreateSanderInput, _T("Create SANDER input..."));
-// md_tools_menu->Append(myMenuID_ImportAmberLib, _T("Import AMBER Lib..."));
-// md_tools_menu->Append(myMenuID_ImportAmberFrcmod, _T("Import AMBER Frcmod..."));
-// md_menu->Append(myMenuID_MDTools, _T("Tools"), md_tools_menu);
-
-// wxMenu *qc_menu = new wxMenu;
-// qc_menu->Append(myMenuID_CreateGamessInput, _T("Create GAMESS input..."));
-// qc_menu->Append(myMenuID_CreateMOPACInput, _T("Create MOPAC input..."));
-// qc_menu->Append(myMenuID_CreateMOCube, _T("Create MO cube..."));
wxMenu *script_menu = new wxMenu;
script_menu->Append(myMenuID_ExecuteScript, _T("Execute Script..."));
menu_bar->Append(edit_menu, _T("&Edit"));
menu_bar->Append(show_menu, _T("Show"));
menu_bar->Append(md_menu, _T("MM/MD"));
-// menu_bar->Append(qc_menu, _T("QChem"));
menu_bar->Append(script_menu, _T("&Script"));
menu_bar->Append(help_menu, _T("&Help"));
}
}
-/*
-#warning "TODO: Move this to MyDocument and 'import parameters' "
-
- void
-MyApp::OnReadParameters(wxCommandEvent& event)
-{
- wxFileDialog *dialog = new wxFileDialog(NULL, _T("Choose Parameter File"), _T(""), _T(""), _T("All files (*.*)|*.*"), wxFD_OPEN | wxFD_CHANGE_DIR | wxFD_FILE_MUST_EXIST);
- if (dialog->ShowModal() == wxID_OK) {
- char *p = strdup((const char *)(dialog->GetPath().mb_str(wxConvFile)));
- char *wbuf;
- ParameterReadFromFile(NULL, p, &wbuf, NULL);
- if (wbuf != NULL) {
- SetConsoleColor(1);
- AppendConsoleMessage(wbuf);
- SetConsoleColor(0);
- free(wbuf);
- }
- free(p);
- }
- dialog->Destroy();
-}
-*/
-
void
MyApp::OnOpenConsoleWindow(wxCommandEvent& event)
{
parameterFilesFrame->Raise();
}
-/*
-void
-MyApp::OnImportAmberLib(wxCommandEvent &event)
-{
- MolActionCreateAndPerform(NULL, SCRIPT_ACTION(""), "cmd_import_amberlib");
-}
-*/
-
int
MyApp::LookupScriptMenu(const char *title)
{
MyApp::OnScriptMenuModified(wxCommandEvent& event)
{
scriptMenuModifiedEventPosted = false;
-// UpdateScriptMenu(GetMainFrame()->GetMenuBar());
UpdateScriptMenu(consoleFrame->GetMenuBar());
event.Skip();
}
void
MyApp::OnScriptMenuSelected(wxCommandEvent& event)
{
-// char *cmd;
-// int methodType;
MainView *mview;
Molecule *mol;
int index = event.GetId() - myMenuID_CustomScript;
if (index < 0 || index >= countScriptMenu)
return;
-// cmd = scriptMenuCommands[index];
-// methodType = Ruby_methodType("Molecule", cmd);
-// if (methodType == 0)
-// return;
mview = MainViewCallback_activeView();
if (mview == NULL)
mol = NULL;
else mol = mview->mol;
MolActionCreateAndPerform(NULL, SCRIPT_ACTION("iM"), "lambda { |n, m| $script_menu_commands[n].call(m) }", index, mol);
-// if (methodType == 1 && mol != NULL) /* Instance method (with no arguments) */
-// MolActionCreateAndPerform(mol, SCRIPT_ACTION(""), cmd);
-// else if (methodType == 2) /* Class method (with molecule as an only argument) */
-// MolActionCreateAndPerform(NULL, SCRIPT_ACTION("M"), cmd, mol);
-// else return;
}
void
else mol = mview->mol;
MolActionCreateAndPerform(NULL, SCRIPT_ACTION("iM;r"), "lambda { |n, m| $script_menu_enablers[n].call(m) }", index, mol, &retval);
event.Enable(retval != NULL && retval != RubyNil);
- // char *cmd;
- // int methodType;
- // Molecule *mol;
- // int index = uid - myMenuID_CustomScript;
- // cmd = scriptMenuCommands[index];
- // methodType = Ruby_methodType("Molecule", cmd);
- // event.Enable(false);
- // if (methodType != 0) {
- // if (mview == NULL)
- // mol = NULL;
- // else mol = mview->mol;
- // if (methodType == 1 && mol != NULL) /* Instance method (with no arguments) */
- // event.Enable(true);
- // else if (methodType == 2) /* Class method (with molecule as an only argument) */
- // event.Enable(true);
- // }
} else if (uid >= myMenuID_PredefinedFragment && uid <= myMenuID_PredefinedFragment + m_CountNamedFragments) {
event.Enable(true);
} else {
case myMenuID_EmptyConsoleWindow:
case myMenuID_ViewParameterFilesList:
case myMenuID_ViewGlobalParameters:
- case myMenuID_MDTools:
- case myMenuID_ImportAmberLib:
event.Enable(true);
return;
default:
wxProcess *proc = new wxProcess(this, -1);
proc->Redirect();
int flag = wxEXEC_ASYNC;
-//#if !__WXMSW__
flag |= wxEXEC_MAKE_GROUP_LEADER;
-//#endif
m_processTerminated = false;
m_processExitCode = 0;
long pid = ::wxExecute(cmdstr, flag, proc);
if (pid == 0) {
- // MyAppCallback_errorMessageBox("Cannot start %s", procname);
proc->Detach();
if (procname != NULL)
HideProgressPanel();
if (m_processTerminated || !wxProcess::Exists(pid)) {
if (m_processExitCode != 0) {
/* Error from subprocess */
- // MyAppCallback_errorMessageBox("%s failed with exit code %d.", procname, m_processExitCode);
status = (m_processExitCode & 255);
} else status = 0;
break;
*((char **)callback_data) = membuf;
}
-/* if (len_total > 0)
- MyAppCallback_showRubyPrompt(); */
-
return status;
}
void
MyApp::CheckIfAllWindowsAreGone(wxTopLevelWindow *frame)
{
-#if 1 || defined(__WXMSW__)
/* On Windows, we should avoid the situation where all windows are hidden and
still the program is running. So that we check whether all windows are gone
and if so ask the user to quit the program. If user chooses not to quit, then
m_frameToBeDestroyed = frame;
wxCommandEvent myEvent(MyDocumentEvent, myMenuID_Internal_CheckIfAllWindowsAreGone);
this->AddPendingEvent(myEvent);
-#endif
}
#pragma mark ====== MyFrame (top-level window) ======
myMenuID_MolecularDynamics = 200,
myMenuID_Minimize = 201,
myMenuID_StopMDRun = 202,
- myMenuID_RunAntechamber = 203,
- myMenuID_GuessUFFParameters = 204,
myMenuID_ViewGlobalParameters = 205,
myMenuID_ViewParameterFilesList = 206,
- myMenuID_DefinePeriodicBox = 207,
- myMenuID_ShowPeriodicImage = 208,
- myMenuID_PressureControl = 209,
- myMenuID_DefineSymmetry = 210,
- myMenuID_ExpandBySymmetry = 211,
- myMenuID_MDTools = 212,
- myMenuID_RunResp = 213,
- myMenuID_CreateSanderInput = 214,
- myMenuID_ImportAmberLib = 215,
- myMenuID_ImportAmberFrcmod = 216,
- myMenuID_CreateGamessInput = 250,
- myMenuID_CreateMOPACInput = 251,
- myMenuID_CreateMOCube = 252,
myMenuID_ExecuteScript = 300,
myMenuID_OpenConsoleWindow = 301,
myMenuID_EmptyConsoleWindow = 302,
myMenuIndex_Edit = 1,
myMenuIndex_Show = 2,
myMenuIndex_MMMD = 3,
- myMenuIndex_QChem = 4,
- myMenuIndex_Script = 5
+ myMenuIndex_Script = 4
};
// Global Setting Keys
wxMenuBar *CreateMenuBar(int kind, wxMenu **out_file_history_menu = NULL, wxMenu **out_edit_menu = NULL);
-// void OnReadParameters(wxCommandEvent& event);
-
static wxString FindResourcePath();
static wxString DefaultSettingsPath();
void OnViewGlobalParameters(wxCommandEvent &event);
void OnViewParameterFilesList(wxCommandEvent &event);
-// void OnImportAmberLib(wxCommandEvent &event);
-
void OnEndProcess(wxProcessEvent &event);
int CallSubProcess(const char *cmdline, const char *procname, int (*callback)(void *) = NULL, void *callback_data = NULL, FILE *fpout = NULL, FILE *fperr = NULL);
EVT_MENU(myMenuID_MolecularDynamics, MyDocument::OnMolecularDynamics)
EVT_MENU(myMenuID_Minimize, MyDocument::OnMinimize)
EVT_MENU(myMenuID_StopMDRun, MyDocument::OnStopMDRun)
-// EVT_MENU(myMenuID_DefinePeriodicBox, MyDocument::OnDefinePeriodicBox)
-// EVT_MENU(myMenuID_ShowPeriodicImage, MyDocument::OnShowPeriodicImage)
-// EVT_MENU(myMenuID_PressureControl, MyDocument::OnPressureControl)
-// EVT_MENU(myMenuID_DefineSymmetry, MyDocument::OnDefineSymmetry)
-// EVT_MENU(myMenuID_ExpandBySymmetry, MyDocument::OnExpandBySymmetry)
-// EVT_MENU(myMenuID_RunAntechamber, MyDocument::OnInvokeAntechamber)
-// EVT_MENU(myMenuID_GuessUFFParameters, MyDocument::OnGuessUFFParameters)
-// EVT_MENU(myMenuID_RunResp, MyDocument::OnInvokeResp)
-// EVT_MENU(myMenuID_CreateSanderInput, MyDocument::OnCreateSanderInput)
-// EVT_MENU(myMenuID_ImportAmberFrcmod, MyDocument::OnImportAmberFrcmod)
-// EVT_MENU(myMenuID_CreateGamessInput, MyDocument::OnCreateGamessInput)
-// EVT_MENU(myMenuID_CreateMOPACInput, MyDocument::OnCreateMOPACInput)
-// EVT_MENU(myMenuID_CreateMOCube, MyDocument::OnCreateMOCube)
EVT_MENU(myMenuID_ShowAllAtoms, MyDocument::OnShowAllAtoms)
EVT_MENU(myMenuID_HideReverse, MyDocument::OnHideReverse)
EVT_MENU(myMenuID_HideSelected, MyDocument::OnHideSelected)
wxGetApp().DisableTimerForDocument(this);
}
-/*
-MainView *
-MyDocument::GetMainView()
-{
- MoleculeView *view = (MoleculeView *)GetFirstView();
- if (view != NULL)
- return view->mview;
- else return NULL;
-}
-*/
-
void
MyDocument::SetMolecule(Molecule *aMolecule)
{
void
MyDocument::UpdateModifyFlag()
{
-// printf("isDirty = %d\n", (GetCommandProcessor()->IsDirty()));
Modify(GetCommandProcessor()->IsDirty());
}
void
MyDocument::OnDocumentModified(wxCommandEvent& event)
{
-// printf("MyDocument::OnDocumentModified invoked\n");
isModifyNotificationSent = false;
MoleculeClearModifyCount(GetMainView()->mol);
MyDocument::OnCopy(wxCommandEvent& event)
{
wxWindow *focusWindow = wxWindow::FindFocus();
-/* printf("focus window class = %ls\n", focusWindow->GetClassInfo()->GetClassName()); */
if (focusWindow->IsKindOf(CLASSINFO(wxTextCtrl))) {
event.Skip();
return;
IntGroupRelease(ig);
MainView_refreshTable(mview);
row = MainView_indexToTableRow(mview, idx);
-/* MainViewCallback_ensureVisible(mview, row); */ /* Invoked from startEditText */
MainViewCallback_startEditText(mview, row, 1);
}
ring->count++;
MoleculeUnlock(mol);
- /* Create a new frame and copy the new coordinates */
- /* MoleculeLock(mol);
- ig = IntGroupNewWithPoints(MoleculeGetNumberOfFrames(mol), 1, -1);
- MolActionCreateAndPerform(mol, gMolActionInsertFrames, ig, 0, NULL);
- IntGroupRelease(ig);
- md_copy_coordinates_from_internal(mol->arena);
- MoleculeUnlock(mol); */
-
if (minimize && mol->arena->minimize_complete) {
r = -2; /* Minimization complete */
break;
}
}
-/*
-void
-MyDocument::OnDefinePeriodicBox(wxCommandEvent &event)
-{
- MoleculeLock(mol);
- MolActionCreateAndPerform(mol, SCRIPT_ACTION(""), "cmd_define_unit_cell");
- MoleculeUnlock(mol);
-}
-
-void
-MyDocument::OnShowPeriodicImage(wxCommandEvent &event)
-{
- MolActionCreateAndPerform(mol, SCRIPT_ACTION(""), "cmd_show_periodic_image");
-}
-*/
-/*
-void
-MyDocument::OnPressureControl(wxCommandEvent &event)
-{
- MoleculeLock(mol);
- MolActionCreateAndPerform(mol, SCRIPT_ACTION(""), "cmd_pressure_control");
- MoleculeUnlock(mol);
-}
-
-void
-MyDocument::OnDefineSymmetry(wxCommandEvent &event)
-{
-}
-
-void
-MyDocument::OnExpandBySymmetry(wxCommandEvent &event)
-{
-}
-*/
-
static wxString
sCreateTemporaryLogDirectoryForAC(const wxString& filename)
{
-// char *ante_dir;
char *log_dir;
int i, status;
}
}
-/*
-void
-MyDocument::OnGuessUFFParameters(wxCommandEvent &event)
-{
- MolActionCreateAndPerform(mol, SCRIPT_ACTION(""), "guess_uff_parameters");
-}
-
-void
-MyDocument::OnInvokeAntechamber(wxCommandEvent &event)
-{
- MolActionCreateAndPerform(mol, SCRIPT_ACTION(""), "cmd_antechamber");
- MyAppCallback_showRubyPrompt();
-}
-
-void
-MyDocument::OnInvokeResp(wxCommandEvent &event)
-{
- MolActionCreateAndPerform(mol, SCRIPT_ACTION(""), "cmd_gamess_resp");
-}
-
-void
-MyDocument::OnCreateSanderInput(wxCommandEvent &event)
-{
- MolActionCreateAndPerform(mol, SCRIPT_ACTION(""), "export_prmtop");
-}
-
-void
-MyDocument::OnImportAmberFrcmod(wxCommandEvent &event)
-{
- MolActionCreateAndPerform(mol, SCRIPT_ACTION(""), "cmd_import_frcmod");
-}
-*/
-/*
-void
-MyDocument::OnCreateGamessInput(wxCommandEvent &event)
-{
- MolActionCreateAndPerform(mol, SCRIPT_ACTION(""), "cmd_create_gamess_input");
-}
-
-void
-MyDocument::OnCreateMOPACInput(wxCommandEvent &event)
-{
- MolActionCreateAndPerform(mol, SCRIPT_ACTION(""), "cmd_create_mopac_input");
-}
-
-void
-MyDocument::OnCreateMOCube(wxCommandEvent &event)
-{
- MolActionCreateAndPerform(mol, SCRIPT_ACTION(""), "cmd_create_cube");
-}
-*/
-
void
MyDocument::OnUpdateUI(wxUpdateUIEvent& event)
{
int uid = event.GetId();
IntGroup *ig = MoleculeGetSelection(mol);
Int nselected = (ig == NULL ? 0 : IntGroupGetCount(ig));
-// wxMenuItem *item = (wxMenuItem *)event.GetEventObject();
switch (uid) {
case wxID_COPY:
case wxID_CUT:
return;
case myMenuID_MolecularDynamics:
case myMenuID_Minimize:
- case myMenuID_DefinePeriodicBox:
- case myMenuID_PressureControl:
if (mol != NULL && mol->mutex == NULL)
event.Enable(true);
else event.Enable(false);
event.Enable(true);
else event.Enable(false);
return;
- case myMenuID_ShowPeriodicImage:
- event.Enable(true);
- return;
- case myMenuID_RunAntechamber:
- case myMenuID_RunResp:
- case myMenuID_CreateSanderInput:
- case myMenuID_GuessUFFParameters:
- if (mol != NULL && mol->natoms > 0)
- event.Enable(true);
- else event.Enable(false);
- return;
- case myMenuID_CreateGamessInput:
- case myMenuID_CreateMOPACInput:
- if (mol != NULL && mol->natoms > 0)
- event.Enable(true);
- else event.Enable(false);
- return;
- case myMenuID_CreateMOCube:
- if (mol == NULL || mol->bset == NULL || mol->bset->natoms == 0)
- event.Enable(false);
- else
- event.Enable(true);
- return;
}
event.Skip();
}
}
}
-/*
-static NSString *
-sMoleculePasteboardType(const char *type)
-{
- static NSMutableArray *array;
- NSString *str;
- unsigned int idx;
- if (array == nil)
- array = [[NSMutableArray array] retain];
- str = [NSString stringWithUTF8String: type];
- idx = [array indexOfObject: str];
- if (idx == NSNotFound) {
- [array addObject: str];
- return str;
- } else {
- return [array objectAtIndex: idx];
- }
-}
-*/
-
static wxDataObject *
sMoleculePasteboardObjectOfType(const char *type, const void *data, int length)
{
E420BDF41885749000A2B983 /* listctrl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = listctrl.cpp; sourceTree = "<group>"; };
E420BDF51885749000A2B983 /* MoleculeView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MoleculeView.cpp; sourceTree = "<group>"; };
E420BDF61885749000A2B983 /* MoleculeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MoleculeView.h; sourceTree = "<group>"; };
- E420BDF71885749000A2B983 /* MyApp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MyApp.cpp; sourceTree = "<group>"; };
+ E420BDF71885749000A2B983 /* MyApp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MyApp.cpp; sourceTree = "<group>"; wrapsLines = 1; };
E420BDF81885749000A2B983 /* MyApp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MyApp.h; sourceTree = "<group>"; };
E420BDF91885749000A2B983 /* MyClipboardData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MyClipboardData.cpp; sourceTree = "<group>"; };
E420BDFA1885749000A2B983 /* MyClipboardData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MyClipboardData.h; sourceTree = "<group>"; };