Skip to content

Commit

Permalink
Changed handling of refresh events to gui widgets (hopefully for the …
Browse files Browse the repository at this point in the history
…better). Removed some obsolete definitions from GuiQt (e.g. addGrid(), addForcefield() etc.).
  • Loading branch information
t.youngs committed Mar 27, 2008
1 parent 82ac767 commit 3ba0f21
Show file tree
Hide file tree
Showing 25 changed files with 231 additions and 272 deletions.
18 changes: 9 additions & 9 deletions aten.kdevelop
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<projectname>aten</projectname>
<projectdirectory>.</projectdirectory>
<absoluteprojectpath>false</absoluteprojectpath>
<description/>
<defaultencoding/>
<description></description>
<defaultencoding></defaultencoding>
<versioncontrol>kdevsubversion</versioncontrol>
</general>
<kdevautoproject>
Expand Down Expand Up @@ -57,20 +57,20 @@
<envvar value="1" name="WANT_AUTOMAKE_1_6" />
</envvars>
<abortonerror>true</abortonerror>
<runmultiplejobs>false</runmultiplejobs>
<runmultiplejobs>true</runmultiplejobs>
<numberofjobs>4</numberofjobs>
<dontact>false</dontact>
<makebin/>
<makebin></makebin>
<prio>4</prio>
</make>
</kdevautoproject>
<kdevdebugger>
<general>
<dbgshell>libtool</dbgshell>
<gdbpath/>
<configGdbScript/>
<runShellScript/>
<runGdbScript/>
<gdbpath></gdbpath>
<configGdbScript></configGdbScript>
<runShellScript></runShellScript>
<runGdbScript></runGdbScript>
<breakonloadinglibs>true</breakonloadinglibs>
<separatetty>false</separatetty>
<floatingtoolbar>false</floatingtoolbar>
Expand Down Expand Up @@ -179,7 +179,7 @@
<includeTypedefs>false</includeTypedefs>
</codecompletion>
<creategettersetter>
<prefixGet/>
<prefixGet></prefixGet>
<prefixSet>set</prefixSet>
<prefixVariable>m_,_</prefixVariable>
<parameterName>theValue</parameterName>
Expand Down
2 changes: 1 addition & 1 deletion aten.spec
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ BuildRoot : %{_tmppath}/%{fullname}

# Boolean that specifies if you want to automatically determine some
# dependencies.
AutoReqProv: no
AutoReqProv: yes

# In-depth description.
%description
Expand Down
68 changes: 28 additions & 40 deletions src/base/master.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ void Master::clear()
// Set the active model
void Master::setCurrentModel(Model *m)
{
dbgBegin(Debug::Calls,"master::setCurrentModel");
dbgBegin(Debug::Calls,"Master::setCurrentModel");
// Set current.m and tell the mainview canvas to display it
current.m = m;
// Set other Bundle objects based on model
current.p = m->patterns();
current.i = NULL;
current.m->calculateViewMatrix();
current.m->projectAll();
gui.refresh();
dbgEnd(Debug::Calls,"master::setCurrentModel");
gui.updateModelLists();
dbgEnd(Debug::Calls,"Master::setCurrentModel");
}

/*
Expand Down Expand Up @@ -130,21 +130,21 @@ int Master::nModels() const
// Add model
Model *Master::addModel()
{
dbgBegin(Debug::Calls,"master::addModel");
dbgBegin(Debug::Calls,"Master::addModel");
current.m = models_.add();
char newname[16];
sprintf(newname,"Unnamed%03i",++modelId_);
current.m->setName(newname);
gui.addModel(current.m);
dbgEnd(Debug::Calls,"master::addModel");
dbgEnd(Debug::Calls,"Master::addModel");
return current.m;
}

// Remove model
void Master::removeModel(Model *xmodel)
{
// Remove this model from the model_list in the main window
dbgBegin(Debug::Calls,"master::removeModel");
dbgBegin(Debug::Calls,"Master::removeModel");
Model *m;
// Unset the datamodel for the canvas
// Delete the current model, but don't allow there to be zero models_...
Expand All @@ -156,17 +156,17 @@ void Master::removeModel(Model *xmodel)
int id = models_.indexOf(xmodel);
models_.remove(xmodel);
gui.removeModel(id);
dbgEnd(Debug::Calls,"master::removeModel");
dbgEnd(Debug::Calls,"Master::removeModel");
}

// Find model by name
Model *Master::findModel(const char *s) const
{
// Search model list for name 's' (script function)
dbgBegin(Debug::Calls,"master::findModel");
dbgBegin(Debug::Calls,"Master::findModel");
Model *result = NULL;
for (result = models_.first(); result != NULL; result = result->next) if (strcmp(s,result->name()) == 0) break;
dbgEnd(Debug::Calls,"master::findModel");
dbgEnd(Debug::Calls,"Master::findModel");
return result ;
}

Expand Down Expand Up @@ -195,11 +195,7 @@ Grid *Master::grid(int id)
// Add new surface
Grid *Master::addGrid()
{
dbgBegin(Debug::Calls,"master::addGrid");
current.g = grids_.add();
gui.addGrid(current.g);
gui.selectGrid(current.g);
dbgEnd(Debug::Calls,"master::addGrid");
return current.g;
}

Expand All @@ -208,8 +204,6 @@ void Master::removeGrid(Grid *xgrid)
{
Grid *g;
xgrid->next != NULL ? g = xgrid->next : g = xgrid->prev;
gui.removeGrid(xgrid);
gui.selectGrid(g);
// Finally, delete the old surface
grids_.remove(xgrid);
}
Expand All @@ -221,57 +215,51 @@ void Master::removeGrid(Grid *xgrid)
// Load forcefield
Forcefield *Master::loadForcefield(const char *filename)
{
dbgBegin(Debug::Calls,"master::loadForcefield");
dbgBegin(Debug::Calls,"Master::loadForcefield");
Forcefield *newff = forcefields_.add();
if (!newff->load(filename))
{
msg(Debug::None,"Couldn't load forcefield file '%s'.\n",filename);
forcefields_.remove(newff);
dbgEnd(Debug::Calls,"master::loadForcefield");
dbgEnd(Debug::Calls,"Master::loadForcefield");
return NULL;
}
else
{
gui.addForcefield(newff);
current.ff = newff;
}
dbgEnd(Debug::Calls,"master::loadForcefield");
else current.ff = newff;
dbgEnd(Debug::Calls,"Master::loadForcefield");
return newff;
}

// Unload forcefield from the master's list
void Master::removeForcefield(Forcefield *xff)
{
dbgBegin(Debug::Calls,"master::removeForcefield");
dbgBegin(Debug::Calls,"Master::removeForcefield");
Forcefield *newff;
// If possible, set the active row to the next model. Otherwise, the previous.
xff->next != NULL ? newff = xff->next : newff = xff->prev;
current.ff = newff;
dereferenceForcefield(xff);
gui.removeForcefield(xff);
gui.selectForcefield(newff);
// Finally, delete the ff
forcefields_.remove(xff);
dbgEnd(Debug::Calls,"master::removeForcefield");
dbgEnd(Debug::Calls,"Master::removeForcefield");
}

// Find forcefield by name
Forcefield *Master::findForcefield(const char *s) const
{
// Search forcefield list for name 's' (script function)
dbgBegin(Debug::Calls,"master::findForcefield");
dbgBegin(Debug::Calls,"Master::findForcefield");
Forcefield *ff;
for (ff = forcefields_.first(); ff != NULL; ff = ff->next) if (strcmp(s,ff->name()) == 0) break;
if (ff == NULL) msg(Debug::None,"Forcefield '%s' is not loaded.\n",s);
dbgEnd(Debug::Calls,"master::findForcefield");
dbgEnd(Debug::Calls,"Master::findForcefield");
return ff;
}

// Dereference forcefield
void Master::dereferenceForcefield(Forcefield *xff)
{
// Remove references to the forcefield in the models
dbgBegin(Debug::Calls,"master::dereferenceForcefield");
dbgBegin(Debug::Calls,"Master::dereferenceForcefield");
for (Model *m = models_.first(); m != NULL; m = m->next)
{
if (m->forcefield() == xff)
Expand All @@ -293,7 +281,7 @@ void Master::dereferenceForcefield(Forcefield *xff)
}
}
}
dbgEnd(Debug::Calls,"master::dereferenceForcefield");
dbgEnd(Debug::Calls,"Master::dereferenceForcefield");
}

// Set the default forcefield
Expand Down Expand Up @@ -353,7 +341,7 @@ Forcefield *Master::defaultForcefield() const
// Load filters
bool Master::openFilters(const char *path, bool isdatadir)
{
dbgBegin(Debug::Calls,"master::openFilters");
dbgBegin(Debug::Calls,"Master::openFilters");
// Load in model filters
Filter *f;
int n;
Expand Down Expand Up @@ -381,7 +369,7 @@ bool Master::openFilters(const char *path, bool isdatadir)
printf("%s ",parser.argc(0));
if (!loadFilter(longname))
{
dbgEnd(Debug::Calls,"master::openFilters");
dbgEnd(Debug::Calls,"Master::openFilters");
return FALSE;
}
}
Expand All @@ -399,14 +387,14 @@ bool Master::openFilters(const char *path, bool isdatadir)
msg(Debug::None,"Expression (%i/%i) ", filters_[FT_EXPRESSION_IMPORT].nItems(), filters_[FT_EXPRESSION_EXPORT].nItems());
msg(Debug::None,"Grid (%i/%i)\n", filters_[FT_GRID_IMPORT].nItems(), filters_[FT_GRID_EXPORT].nItems());
}
dbgEnd(Debug::Calls,"master::openFilters");
dbgEnd(Debug::Calls,"Master::openFilters");
return TRUE;
}

// Read commands from filter file
bool Master::loadFilter(const char *filename)
{
dbgBegin(Debug::Calls,"master::loadFilter");
dbgBegin(Debug::Calls,"Master::loadFilter");
FilterType ft;
Filter *newfilter;
bool foundmain, error;
Expand Down Expand Up @@ -445,14 +433,14 @@ bool Master::loadFilter(const char *filename)
}
filterfile.close();
//variables.print();
dbgEnd(Debug::Calls,"master::loadFilter");
dbgEnd(Debug::Calls,"Master::loadFilter");
return (!error);
}

// Set filter partners
void Master::partnerFilters()
{
dbgBegin(Debug::Calls,"master::partnerFilters");
dbgBegin(Debug::Calls,"Master::partnerFilters");
// Loop through import filters and search / set export partners
Filter *imp, *exp;
int importid;
Expand Down Expand Up @@ -500,18 +488,18 @@ void Master::partnerFilters()
if (exp == NULL) printf("o]");
}
printf("\n");
dbgEnd(Debug::Calls,"master::partnerFilters");
dbgEnd(Debug::Calls,"Master::partnerFilters");
}

// Find filter with specified type and nickname
Filter *Master::findFilter(FilterType ft, const char *nickname) const
{
dbgBegin(Debug::Calls,"master::findFilter");
dbgBegin(Debug::Calls,"Master::findFilter");
Filter *result;
for (result = filters_[ft].first(); result != NULL; result = result->next)
if (strcmp(result->nickname(), nickname) == 0) break;
if (result == NULL) msg(Debug::None,"No %s filter with nickname '%s' defined.\n",text_from_FT(ft),nickname);
dbgEnd(Debug::Calls,"master::findFilter");
dbgEnd(Debug::Calls,"Master::findFilter");
return result;
}

Expand Down
2 changes: 1 addition & 1 deletion src/command/ff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ int CommandData::function_CA_FFPATTERNID(Command *&c, Bundle &obj)
int nodeid = c->argi(0) - 1;
if ((nodeid < 0) || (nodeid > obj.m->nPatterns()))
{
msg(Debug::None,"Pattern ID %i is out of range for model (which has %i atterns).\n", nodeid, obj.m->nPatterns());
msg(Debug::None,"Pattern ID %i is out of range for model (which has %i patterns).\n", nodeid, obj.m->nPatterns());
return CR_FAIL;
}
else obj.m->pattern(nodeid)->setForcefield(obj.ff);
Expand Down
20 changes: 10 additions & 10 deletions src/command/prefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ int CommandData::function_CA_ATOMDETAIL(Command *&c, Bundle &obj)
{
prefs.setAtomDetail(c->argi(0));
if (obj.m != NULL) obj.m->logChange(LOG_VISUAL);
if (gui.exists()) gui.refresh();
gui.mainView.postRedisplay();
return CR_SUCCESS;
}

Expand All @@ -39,7 +39,7 @@ int CommandData::function_CA_BONDDETAIL(Command *&c, Bundle &obj)
{
prefs.setBondDetail(c->argi(0));
if (obj.m != NULL) obj.m->logChange(LOG_VISUAL);
if (gui.exists()) gui.refresh();
gui.mainView.postRedisplay();
return CR_SUCCESS;
}

Expand All @@ -52,7 +52,7 @@ int CommandData::function_CA_COLOUR(Command *&c, Bundle &obj)
GLfloat alpha = (c->hasArg(4) ? (GLfloat) c->argd(4) : 1.0f);
prefs.setColour(col, colvec.x, colvec.y, colvec.z, alpha);
if (obj.m != NULL) obj.m->logChange(LOG_VISUAL);
if (gui.exists()) gui.refresh();
gui.mainView.postRedisplay();
return CR_SUCCESS;
}

Expand Down Expand Up @@ -103,7 +103,7 @@ int CommandData::function_CA_ELEMENTAMBIENT(Command *&c, Bundle &obj)
elements.setAmbientColour(el,1,c->argi(2));
elements.setAmbientColour(el,2,c->argi(3));
if (obj.m != NULL) obj.m->logChange(LOG_VISUAL);
if (gui.exists()) gui.refresh();
gui.mainView.postRedisplay();
return CR_SUCCESS;
}

Expand All @@ -116,7 +116,7 @@ int CommandData::function_CA_ELEMENTDIFFUSE(Command *&c, Bundle &obj)
elements.setDiffuseColour(el,1,c->argi(2));
elements.setDiffuseColour(el,2,c->argi(3));
if (obj.m != NULL) obj.m->logChange(LOG_VISUAL);
if (gui.exists()) gui.refresh();
gui.mainView.postRedisplay();
return CR_SUCCESS;
}

Expand All @@ -127,7 +127,7 @@ int CommandData::function_CA_ELEMENTRADIUS(Command *&c, Bundle &obj)
if (el == 0) return CR_FAIL;
elements.setAtomicRadius(el, c->argd(1));
if (obj.m != NULL) obj.m->logChange(LOG_VISUAL);
if (gui.exists()) gui.refresh();
gui.mainView.postRedisplay();
return CR_SUCCESS;
}

Expand All @@ -149,7 +149,7 @@ int CommandData::function_CA_GL(Command *&c, Bundle &obj)
else prefs.removeGlOption(go);
if (gui.exists()) gui.mainView.initGl();
if (obj.m != NULL) obj.m->logChange(LOG_VISUAL);
if (gui.exists()) gui.refresh();
gui.mainView.postRedisplay();
return CR_SUCCESS;
}

Expand Down Expand Up @@ -194,7 +194,7 @@ int CommandData::function_CA_SHININESS(Command *&c, Bundle &obj)
{
prefs.setShininess(c->argi(0));
if (obj.m != NULL) obj.m->logChange(LOG_VISUAL);
if (gui.exists()) gui.refresh();
gui.mainView.postRedisplay();
return CR_SUCCESS;
}

Expand All @@ -206,7 +206,7 @@ int CommandData::function_CA_SHOW(Command *&c, Bundle &obj)
{
prefs.setVisible(vo, c->argb(1));
if (obj.m != NULL) obj.m->logChange(LOG_VISUAL);
if (gui.exists()) gui.refresh();
gui.mainView.postRedisplay();
}
else return CR_FAIL;
return CR_SUCCESS;
Expand All @@ -220,7 +220,7 @@ int CommandData::function_CA_STYLE(Command *&c, Bundle &obj)
{
prefs.setRenderStyle(ds);
if (obj.m != NULL) obj.m->logChange(LOG_VISUAL);
if (gui.exists()) gui.refresh();
gui.mainView.postRedisplay();
}
else return CR_FAIL;
return CR_SUCCESS;
Expand Down
Loading

0 comments on commit 3ba0f21

Please sign in to comment.