{
int i, natoms;
Atom *ap, *ap0;
- if (arena->mol->nsyms == 0)
- return;
ap = ap0 = arena->mol->atoms;
natoms = arena->mol->natoms;
+ if (arena->mol->nsyms > 0) {
+ for (i = 0; i < natoms; i++, ap++) {
+ Symop symop;
+ if (!ap->symop.alive)
+ continue;
+ symop = ap->symop;
+ ap0 = arena->mol->atoms + ap->symbase;
+ md_transform_vec_by_symmetry(arena, &(ap->r), &(ap0->r), symop, 0);
+ md_transform_vec_by_symmetry(arena, &(ap->f), &(ap0->f), symop, 1);
+ md_transform_vec_by_symmetry(arena, &(ap->v), &(ap0->v), symop, 1);
+ }
+ }
+ ap = arena->mol->atoms;
for (i = 0; i < natoms; i++, ap++) {
- Symop symop;
- if (!ap->symop.alive)
+ Int *ip, j;
+ if (ap->anchor == NULL)
continue;
- symop = ap->symop;
- ap0 = arena->mol->atoms + ap->symbase;
- md_transform_vec_by_symmetry(arena, &(ap->r), &(ap0->r), symop, 0);
- md_transform_vec_by_symmetry(arena, &(ap->f), &(ap0->f), symop, 1);
- md_transform_vec_by_symmetry(arena, &(ap->v), &(ap0->v), symop, 1);
+ ip = AtomConnectData(&ap->anchor->connect);
+ VecZero(ap->r);
+ for (j = 0; j < ap->anchor->connect.count; j++) {
+ Double w = ap->anchor->coeffs[j];
+ ap0 = arena->mol->atoms + ip[j];
+ VecScaleInc(ap->r, ap0->r, w);
+ }
}
-
}
void
MoleculeUnlock(arena->xmol); */
}
+ md_amend_by_symmetry(arena);
+
arena->setjmp_buf = NULL;
if (arena->is_running) {
if (iibuf[0] < 0 || iibuf[0] >= mp->natoms || iibuf[1] < 0 || iibuf[1] >= mp->natoms || iibuf[2] < 0 || iibuf[2] >= mp->natoms || iibuf[0] == iibuf[1] || iibuf[1] == iibuf[2]) {
s_append_asprintf(errbuf, "line %d: warning: bad angle specification (%d-%d-%d) - skipped\n", lineNumber, iibuf[0], iibuf[1], iibuf[2]);
nwarnings++;
- } else if (MoleculeAreAtomsConnected(mp, iibuf[0], iibuf[1]) == 0 || MoleculeAreAtomsConnected(mp, iibuf[1], iibuf[2]) == 0) {
+ } else if (MoleculeAreAtomsConnected(mp, iibuf[1], iibuf[0]) == 0 || MoleculeAreAtomsConnected(mp, iibuf[1], iibuf[2]) == 0) {
s_append_asprintf(errbuf, "line %d: warning: angle with non-bonded atoms (%d-%d-%d) - skipped\n", lineNumber, iibuf[0], iibuf[1], iibuf[2]);
nwarnings++;
} else if (MoleculeLookupAngle(mp, iibuf[0], iibuf[1], iibuf[2]) >= 0) {
if (iibuf[0] < 0 || iibuf[0] >= mp->natoms || iibuf[1] < 0 || iibuf[1] >= mp->natoms || iibuf[2] < 0 || iibuf[2] >= mp->natoms || iibuf[3] < 0 || iibuf[3] >= mp->natoms || iibuf[0] == iibuf[1] || iibuf[1] == iibuf[2] || iibuf[2] == iibuf[3] || iibuf[0] == iibuf[2] || iibuf[1] == iibuf[3] || iibuf[0] == iibuf[3]) {
s_append_asprintf(errbuf, "line %d: warning: bad dihedral specification (%d-%d-%d-%d) - skipped\n", lineNumber, iibuf[0], iibuf[1], iibuf[2], iibuf[3]);
nwarnings++;
- } else if (MoleculeAreAtomsConnected(mp, iibuf[0], iibuf[1]) == 0 || MoleculeAreAtomsConnected(mp, iibuf[1], iibuf[2]) == 0 || MoleculeAreAtomsConnected(mp, iibuf[2], iibuf[3]) == 0) {
+ } else if (MoleculeAreAtomsConnected(mp, iibuf[1], iibuf[0]) == 0 || MoleculeAreAtomsConnected(mp, iibuf[1], iibuf[2]) == 0 || MoleculeAreAtomsConnected(mp, iibuf[2], iibuf[3]) == 0) {
s_append_asprintf(errbuf, "line %d: warning: dihedral with non-bonded atoms (%d-%d-%d-%d) - skipped\n", lineNumber, iibuf[0], iibuf[1], iibuf[2], iibuf[3]);
nwarnings++;
} else if (MoleculeLookupDihedral(mp, iibuf[0], iibuf[1], iibuf[2], iibuf[3]) >= 0) {
if (iibuf[0] < 0 || iibuf[0] >= mp->natoms || iibuf[1] < 0 || iibuf[1] >= mp->natoms || iibuf[2] < 0 || iibuf[2] >= mp->natoms || iibuf[3] < 0 || iibuf[3] >= mp->natoms || iibuf[0] == iibuf[1] || iibuf[1] == iibuf[2] || iibuf[2] == iibuf[3] || iibuf[0] == iibuf[2] || iibuf[1] == iibuf[3] || iibuf[0] == iibuf[3]) {
s_append_asprintf(errbuf, "line %d: warning: bad improper specification (%d-%d-%d-%d) - skipped\n", lineNumber, iibuf[0], iibuf[1], iibuf[2], iibuf[3]);
nwarnings++;
- } else if (MoleculeAreAtomsConnected(mp, iibuf[0], iibuf[2]) == 0 || MoleculeAreAtomsConnected(mp, iibuf[1], iibuf[2]) == 0 || MoleculeAreAtomsConnected(mp, iibuf[2], iibuf[3]) == 0) {
+ } else if (MoleculeAreAtomsConnected(mp, iibuf[2], iibuf[0]) == 0 || MoleculeAreAtomsConnected(mp, iibuf[2], iibuf[1]) == 0 || MoleculeAreAtomsConnected(mp, iibuf[2], iibuf[3]) == 0) {
s_append_asprintf(errbuf, "line %d: warning: improper with non-bonded atoms (%d-%d-%d-%d) - skipped\n", lineNumber, iibuf[0], iibuf[1], iibuf[2], iibuf[3]);
nwarnings++;
} else if (MoleculeLookupImproper(mp, iibuf[0], iibuf[1], iibuf[2], iibuf[3]) >= 0) {
free(vp);
}
} else {
- *groupout = NULL;
- *vpout = NULL;
+ if (groupout != NULL && vpout != NULL) {
+ *groupout = NULL;
+ *vpout = NULL;
+ }
}
return count;
}
for (i = 0, api = ATOM_AT_INDEX(mp->atoms, i); i < mp->natoms; i++, api = ATOM_NEXT(api)) {
int j;
Int *cp;
+ cp = AtomConnectData(&api->connect);
for (j = 0; j < api->connect.count; j++) {
- cp = AtomConnectData(&api->connect);
if (cp[j] >= pos)
cp[j]++;
}
+ if (api->anchor != NULL) {
+ cp = AtomConnectData(&api->anchor->connect);
+ for (j = 0; j < api->anchor->connect.count; j++) {
+ if (cp[j] >= pos)
+ cp[j]++;
+ }
+ }
}
for (i = 0; i < mp->nbonds * 2; i++) {
if (mp->bonds[i] >= pos)
rb_define_method(rb_mKernel, "call_subprocess", s_Kernel_CallSubProcess, 2);
rb_define_method(rb_mKernel, "message_box", s_Kernel_MessageBox, -1);
rb_define_method(rb_mKernel, "error_message_box", s_Kernel_ErrorMessageBox, 1);
-
+
s_ID_equal = rb_intern("==");
}
static VALUE s_ruby_top_self = Qfalse;
static VALUE
-s_evalRubyScriptOnMoleculeSubSub(VALUE tagval, VALUE val)
+s_evalRubyScriptOnMoleculeSub(VALUE val)
{
void **ptr = (void **)val;
Molecule *mol = (Molecule *)ptr[1];
}
}
-static VALUE
-s_evalRubyScriptOnMoleculeSub(VALUE val)
-{
- return rb_catch("molby_top", s_evalRubyScriptOnMoleculeSubSub, val);
-}
-
RubyValue
Molby_evalRubyScriptOnMolecule(const char *script, Molecule *mol, const char *fname, int *status)
{
save_ruby_sourcefile = ruby_sourcefile;
save_ruby_sourceline = ruby_sourceline;
retval = (RubyValue)rb_protect(s_evalRubyScriptOnMoleculeSub, (VALUE)args, status);
+ if (*status != 0) {
+ /* Is this 'exit' exception? */
+ VALUE last_exception = rb_gv_get("$!");
+ if (rb_obj_is_kind_of(last_exception, rb_eSystemExit)) {
+ /* Capture exit and return the status value */
+ retval = (RubyValue)rb_funcall(last_exception, rb_intern("status"), 0);
+ *status = 0;
+ }
+ }
s_SetInterruptFlag(Qnil, save_interrupt_flag);
ruby_sourcefile = save_ruby_sourcefile;
ruby_sourceline = save_ruby_sourceline;
end
end
-if Molby::HasGUI
- def exit(val = nil)
- throw(:molby_top, val)
- end
-end
-
load "transform.rb"
load "molecule.rb"
load "loadsave.rb"
// Set the default font (fixed-pitch)
wxTextAttr attr;
#if defined(__WXMSW__)
-// wxFont font = wxSystemSettings::GetFont(wxSYS_ANSI_FIXED_FONT);
- wxFont font(10, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
+ default_font = new wxFont(10, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
+ if (!default_font->SetFaceName(wxT("Consolas")))
+ default_font->SetFaceName(wxT("Courier"));
+#elif defined(__WXMAC__)
+ default_font = new wxFont(11, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
+ default_font->SetFaceName(wxT("Monaco"));
#else
- wxFont font(11, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
+ default_font = new wxFont(10, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
#endif
- attr.SetFont(font);
+ attr.SetFont(*default_font);
textCtrl->SetDefaultStyle(attr);
-
+ textCtrl->SetFont(*default_font);
+
// Connect "OnKeyDown" event handler
textCtrl->Connect(-1, wxEVT_KEY_DOWN, wxKeyEventHandler(ConsoleFrame::OnKeyDown), NULL, this);
wxMenu *file_history_menu;
wxMenu *edit_menu;
+ wxFont *default_font;
+
ConsoleFrame(wxMDIParentFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size, long type);
virtual ~ConsoleFrame();
MoleculeView::OnMoleculeReplaced()
{
Molecule *mol = ((MyDocument *)GetDocument())->GetMolecule();
- if ((mol == NULL && mview == NULL) || (mol != NULL && mol->mview == mview))
+ if (mol == NULL && mview == NULL)
return;
+ if (mol != NULL && mol->mview == mview) {
+ /* Clear internal cache */
+ MainView_refreshCachedInfo(mol->mview);
+ return;
+ }
if (mview != NULL)
MainView_setViewObject(mview, NULL);
if (mol != NULL) {
+ int tableIndex;
mview = mol->mview;
MainView_setViewObject(mview, this);
+ /* Force updating the table */
+ tableIndex = mview->tableIndex;
+ mview->tableIndex = -1;
+ SelectTable(tableIndex);
}
}
file_menu->Append(wxID_CLOSE, _T("&Close\tCtrl-W"));
file_menu->Append(wxID_SAVE, _T("&Save\tCtrl-S"));
file_menu->Append(wxID_SAVEAS, _T("Save &As..."));
- file_menu->Append(wxID_REVERT, _T("Revert..."));
+ file_menu->Append(wxID_REVERT, _T("Revert to Saved"));
file_menu->AppendSeparator();
file_menu->Append(myMenuID_Import, _T("Import..."));
MyApp::SetConsoleColor(int color)
{
wxTextCtrl *textCtrl = consoleFrame->textCtrl;
- static wxTextAttr *col[4];
+ wxTextAttr attr(textCtrl->GetDefaultStyle());
+ static const wxColour *col[4];
if (col[0] == NULL) {
- col[0] = new wxTextAttr(*wxBLACK);
- col[1] = new wxTextAttr(*wxRED);
- col[2] = new wxTextAttr(*wxGREEN);
- col[3] = new wxTextAttr(*wxBLUE);
+ col[0] = wxBLACK;
+ col[1] = wxRED;
+ col[2] = wxGREEN;
+ col[3] = wxBLUE;
}
- textCtrl->SetDefaultStyle(*(col[color % 4]));
+ attr.SetTextColour(*col[color % 4]);
+ textCtrl->SetDefaultStyle(attr);
}
void
return true;
}
+bool
+MyDocument::Revert()
+{
+ if (wxDocument::Revert()) {
+ MainViewCallback_selectTable(mol->mview, 0);
+ return true;
+ } else return false;
+}
+
/* Override to intercept view creation for running script */
bool
MyDocument::OnCreate(const wxString& path, long flags)
virtual bool DoSaveDocument(const wxString& file);
virtual bool DoOpenDocument(const wxString& file);
virtual bool OnCreate(const wxString& path, long flags);
+ virtual bool Revert();
private:
DECLARE_DYNAMIC_CLASS(MyDocument)