Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

GraphicsFltkReps.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *cr
00003  *cr            (C) Copyright 1995-2008 The Board of Trustees of the
00004  *cr                        University of Illinois
00005  *cr                         All Rights Reserved
00006  *cr
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  * RCS INFORMATION:
00011  *
00012  *      $RCSfile: GraphicsFltkReps.h,v $
00013  *      $Author: johns $        $Locker:  $             $State: Exp $
00014  *      $Revision: 1.69 $       $Date: 2008/08/13 21:11:23 $
00015  *
00016  ***************************************************************************
00017  * DESCRIPTION:
00018  *  generated by Fast Light User Interface Designer (fluid) version 1.0011
00019  ***************************************************************************/
00020 
00021 #include <stdio.h>
00022 #include <stdlib.h>
00023 #include "FL/forms.H"
00024 #include "FL/Fl_Counter.H"
00025 #include "FL/Fl_Value_Slider.H"
00026 #include "FL/Fl_Float_Input.H"
00027 #include "FL/Fl_Tabs.H"
00028 #include "AtomRep.h"
00029 #include "Molecule.h"
00030 #include "VMDApp.h"
00031 #include "MoleculeList.h"
00032 
00036 class GraphicsFltkRep : public Fl_Group {
00037 protected:
00038   GraphicsFltkRep()
00039   : Fl_Group(10, 380, 295, 220) {}
00040   virtual void do_reset() {}
00041 
00042   char cmdbuf[256];
00043 
00044 public:
00045   virtual int is_volumetric() { return 0; }
00046   virtual const char *repcmd() = 0;
00047   virtual void set_values(AtomRep *) = 0;
00048   void reset() { do_reset(); }
00049 };
00050 
00051 
00052 #define CTRWIDTH 120
00053 #define CTRHEIGHT 25
00054 
00055 class RadiusCounter : public Fl_Counter {
00056 public:
00057   RadiusCounter(int x, int y, const char *nm)
00058   : Fl_Counter(x, y, CTRWIDTH, CTRHEIGHT, nm) {
00059     minimum(0);
00060     precision(1);
00061     step(.1);
00062     lstep(1);
00063     align(FL_ALIGN_LEFT);
00064     when(FL_WHEN_RELEASE);
00065   }
00066 };
00067 
00068 
00070 class ResolutionCounter : public Fl_Counter {
00071 public:
00072   ResolutionCounter(int x, int y, const char *nm)
00073   : Fl_Counter(x, y, CTRWIDTH, CTRHEIGHT, nm) {
00074     minimum(1);
00075     precision(0);
00076     step(1);
00077     lstep(5);
00078     align(FL_ALIGN_LEFT);
00079     when(FL_WHEN_RELEASE);
00080   }
00081 };
00082 
00084 class StepCounter : public Fl_Counter {
00085 public:
00086   StepCounter(int x, int y, const char *nm)
00087   : Fl_Counter(x, y, 90, CTRHEIGHT, nm) {
00088     minimum(1);
00089     precision(0);
00090     step(1);
00091     lstep(4);
00092     align(FL_ALIGN_LEFT);
00093     when(FL_WHEN_RELEASE);
00094   }
00095 };
00096 
00097 
00099 class RepChoice : public Fl_Choice {
00100 public:
00101   RepChoice(int x, int y, const char *nm)  
00102   : Fl_Choice(x, y, CTRWIDTH, CTRHEIGHT, nm) {
00103     color(FL_PALEGREEN);
00104     selection_color(FL_BLACK);
00105     align(FL_ALIGN_LEFT);
00106   }
00107   int setvalue(int newvalue) {
00108     if (newvalue >= 0 && newvalue < size())
00109       return Fl_Choice::value(newvalue);
00110     return value();
00111   }
00112 };
00113 
00114 
00116 class IsoSlider : public Fl_Value_Slider {
00117 public:
00118   IsoSlider(int x, int y, const char *nm)
00119   : Fl_Value_Slider(x, y, CTRWIDTH+90, CTRHEIGHT, nm) {
00120     color(FL_WHITE);
00121     align(FL_ALIGN_LEFT);
00122     type(FL_HOR_SLIDER);
00123   }
00124 };
00125 
00127 class ShortSlider : public Fl_Value_Slider {
00128 public:
00129   ShortSlider(int x, int y, const char *nm)
00130   : Fl_Value_Slider(x, y, CTRWIDTH+50, CTRHEIGHT, nm) {
00131     color(FL_WHITE);
00132     align(FL_ALIGN_LEFT);
00133     type(FL_HOR_SLIDER);
00134   }
00135 };
00136 
00138 class GraphicsFltkRepLines : public GraphicsFltkRep {
00139 public:
00140   GraphicsFltkRepLines(Fl_Callback *cb, void *v) {
00141     thickness = new ResolutionCounter(x()+170, y()+120, "Thickness");
00142     thickness->callback(cb, v);
00143     Fl_Group::end();
00144   }
00145   const char *repcmd() {
00146     sprintf(cmdbuf, "Lines %f", thickness->value());
00147     return cmdbuf;
00148   }
00149   void set_values(AtomRep *rep) {
00150     thickness->value(rep->get_data(AtomRep::LINETHICKNESS));
00151   }
00152  
00153 protected:
00154   void do_reset() {
00155     thickness->value(1);
00156   }
00157 
00158 private:
00159   Fl_Counter *thickness;
00160 };
00161 
00162 
00164 class GraphicsFltkRepBonds : public GraphicsFltkRep {
00165 public:
00166   GraphicsFltkRepBonds(Fl_Callback *cb, void *v) {
00167     radius = new RadiusCounter(x()+170, y()+90, "Bond Radius");
00168     resolution= new ResolutionCounter(x()+170,y()+120,"Bond Resolution");
00169     radius->callback(cb, v);
00170     resolution->callback(cb, v);
00171     Fl_Group::end();
00172   }
00173   const char *repcmd() {
00174     sprintf(cmdbuf, "Bonds %f %f", radius->value(), resolution->value());
00175     return cmdbuf;
00176   }
00177   void set_values(AtomRep *rep) {
00178     radius->value(rep->get_data(AtomRep::BONDRAD));
00179     resolution->value(rep->get_data(AtomRep::BONDRES));
00180   }
00181 
00182 protected:
00183   void do_reset() {
00184     radius->value(0.3);
00185     resolution->value(6);
00186   }
00187 
00188 protected:
00189   Fl_Counter *radius;
00190   Fl_Counter *resolution;
00191 };
00192 
00193 
00195 class GraphicsFltkRepDynamicBonds : public GraphicsFltkRep {
00196 private:
00197   Fl_Counter *distance;
00198   Fl_Counter *radius;
00199   Fl_Counter *resolution;
00200 public:
00201   GraphicsFltkRepDynamicBonds(Fl_Callback *cb, void *v) {
00202     distance = new RadiusCounter(x()+170,y()+60,"Distance Cutoff");
00203     distance->callback(cb, v);
00204     radius = new RadiusCounter(x()+170, y()+90, "Bond Radius");
00205     radius->callback(cb, v);
00206     resolution= new ResolutionCounter(x()+170,y()+120,"Bond Resolution");
00207     resolution->callback(cb, v);
00208     Fl_Group::end();
00209   }
00210 protected:
00211   void do_reset() {
00212     distance->value(1.6);
00213     radius->value(0.3);
00214     resolution->value(6);
00215   }
00216 public:
00217   const char *repcmd() {
00218     sprintf(cmdbuf, "DynamicBonds %f %f %f", distance->value(), radius->value(),
00219       resolution->value());
00220     return cmdbuf;
00221   }
00222   void set_values(AtomRep *rep) {
00223     distance->value(rep->get_data(AtomRep::SPHERERAD));
00224     radius->value(rep->get_data(AtomRep::BONDRAD));
00225     resolution->value(rep->get_data(AtomRep::BONDRES));
00226   }
00227 };
00228 
00229  
00231 class GraphicsFltkRepCPK : public GraphicsFltkRep {
00232 public:
00233   GraphicsFltkRepCPK(Fl_Callback *cb, void *v) {
00234     bradius = new RadiusCounter(x()+170,y()+90,"Bond Radius");
00235     bresolution= new ResolutionCounter(x()+170,y()+120,"Bond Resolution");
00236     bradius->callback(cb, v);
00237     bresolution->callback(cb, v);
00238 
00239     sradius = new RadiusCounter(x()+170,y()+30,"Sphere Scale");
00240     sresolution= new ResolutionCounter(x()+170,y()+60,"Sphere Resolution");
00241     sradius->callback(cb, v);
00242     sresolution->callback(cb, v);
00243 
00244     Fl_Group::end();
00245   }
00246 
00247   const char *repcmd() {
00248     sprintf(cmdbuf, "CPK %f %f %f %f", sradius->value(), bradius->value(),
00249         sresolution->value(), bresolution->value());
00250     return cmdbuf;
00251   }
00252   void set_values(AtomRep *rep) {
00253     bradius->value(rep->get_data(AtomRep::BONDRAD));
00254     bresolution->value(rep->get_data(AtomRep::BONDRES));
00255     sradius->value(rep->get_data(AtomRep::SPHERERAD));
00256     sresolution->value(rep->get_data(AtomRep::SPHERERES));
00257   }
00258 
00259 protected:
00260   void do_reset() {
00261     bradius->value(0.3);
00262     bresolution->value(6);
00263     sradius->value(1.0);
00264     sresolution->value(8);
00265   }
00266 
00267 private:
00268   Fl_Counter *bradius;
00269   Fl_Counter *bresolution;
00270   Fl_Counter *sradius;
00271   Fl_Counter *sresolution;
00272 };
00273 
00274 
00276 class GraphicsFltkRepPoints : public GraphicsFltkRep {
00277 public:
00278   GraphicsFltkRepPoints(Fl_Callback *cb, void *v) {
00279     size = new ResolutionCounter(x()+170, y()+120, "Size");
00280     size->callback(cb, v);
00281     Fl_Group::end();
00282   }
00283   const char *repcmd() {
00284     sprintf(cmdbuf, "Points %f", size->value());
00285     return cmdbuf;
00286   }
00287   void set_values(AtomRep *rep) {
00288     size->value(rep->get_data(AtomRep::LINETHICKNESS));
00289   }
00290 
00291 protected:
00292   void do_reset() {
00293     size->value(1);
00294   }
00295 
00296 private:
00297   Fl_Counter *size;
00298 };
00299 
00300 
00301  
00303 class GraphicsFltkRepVDW : public GraphicsFltkRep {
00304 public:
00305   GraphicsFltkRepVDW(Fl_Callback *cb, void *v) {
00306     radius = new RadiusCounter(x()+170,y()+90,"Sphere Scale");
00307     resolution= new ResolutionCounter(x()+170,y()+120,"Sphere Resolution");
00308     radius->callback(cb, v);
00309     resolution->callback(cb, v);
00310     Fl_Group::end();
00311   }
00312 
00313   const char *repcmd() {
00314     sprintf(cmdbuf, "VDW %f %f", radius->value(), resolution->value());
00315     return cmdbuf;
00316   }
00317   void set_values(AtomRep *rep) {
00318     radius->value(rep->get_data(AtomRep::SPHERERAD));
00319     resolution->value(rep->get_data(AtomRep::SPHERERES));
00320   }
00321 
00322 protected:
00323   void do_reset() {
00324     radius->value(1.0);
00325     resolution->value(8);
00326   }
00327 
00328 protected:
00329   Fl_Counter *radius;
00330   Fl_Counter *resolution;
00331 };
00332 
00333 
00335 class GraphicsFltkRepBeads : public GraphicsFltkRepVDW {
00336 public:
00337   GraphicsFltkRepBeads(Fl_Callback *cb, void *v)
00338   : GraphicsFltkRepVDW(cb, v) {}
00339   const char *repcmd() {
00340     sprintf(cmdbuf, "Beads %f %f", radius->value(), resolution->value()); 
00341     return cmdbuf;
00342   }
00343 };
00344 
00345 
00347 class GraphicsFltkRepDotted : public GraphicsFltkRepVDW {
00348 public:
00349   GraphicsFltkRepDotted(Fl_Callback *cb, void *v)
00350   : GraphicsFltkRepVDW(cb, v) {}
00351   const char *repcmd() {
00352     sprintf(cmdbuf, "Dotted %f %f", radius->value(), resolution->value()); 
00353     return cmdbuf;
00354   }
00355 };
00356 
00357 
00359 class GraphicsFltkRepTrace : public GraphicsFltkRepBonds {
00360 public:
00361   GraphicsFltkRepTrace(Fl_Callback *cb, void *v)
00362   : GraphicsFltkRepBonds(cb, v) {}
00363   const char *repcmd() {
00364     sprintf(cmdbuf, "Trace %f %f", radius->value(), resolution->value());
00365     return cmdbuf;
00366   }
00367 };
00368 
00369 
00371 class GraphicsFltkRepLicorice : public GraphicsFltkRepBonds {
00372 private:
00373   Fl_Counter *sresolution;
00374 public:
00375   GraphicsFltkRepLicorice(Fl_Callback *cb, void *v)
00376   :  GraphicsFltkRepBonds(cb, v) {
00377     Fl_Group::begin();
00378     sresolution= new ResolutionCounter(x()+170,y()+60,"Sphere Resolution");
00379     sresolution->callback(cb, v);
00380 
00381     Fl_Group::end();
00382   }
00383 protected:
00384   void do_reset() {
00385     GraphicsFltkRepBonds::do_reset();
00386     resolution->value(10);
00387     sresolution->value(10);
00388   }
00389 public:
00390   const char *repcmd() {
00391     sprintf(cmdbuf, "Licorice %f %f %f", radius->value(), sresolution->value(),
00392       resolution->value());
00393     return cmdbuf;
00394   }
00395   void set_values(AtomRep *rep) {
00396     GraphicsFltkRepBonds::set_values(rep);
00397     sresolution->value(rep->get_data(AtomRep::SPHERERES));
00398   }
00399 };
00400     
00401 
00402 #ifdef VMDPOLYHEDRA
00403 
00404 class GraphicsFltkRepPolyhedra : public GraphicsFltkRep {
00405 private:
00406   Fl_Counter *distance;
00407 public:
00408   GraphicsFltkRepPolyhedra(Fl_Callback *cb, void *v) {
00409     distance = new RadiusCounter(x()+170,y()+60,"Distance Cutoff");
00410     distance->callback(cb, v);
00411     Fl_Group::end();
00412   }
00413 protected:
00414   void do_reset() {
00415     distance->value(1.6);
00416   }
00417 public:
00418   const char *repcmd() {
00419     sprintf(cmdbuf, "Polyhedra %f", distance->value());
00420     return cmdbuf;
00421   }
00422   void set_values(AtomRep *rep) {
00423     distance->value(rep->get_data(AtomRep::SPHERERAD));
00424   }
00425 };
00426 #endif
00427 
00429 class GraphicsFltkRepTube : public GraphicsFltkRepBonds {
00430 public:
00431   GraphicsFltkRepTube(Fl_Callback *cb, void *v)
00432   : GraphicsFltkRepBonds(cb, v) {
00433     radius->label("Radius");
00434     resolution->label("Resolution");
00435   }
00436   const char *repcmd() {
00437     sprintf(cmdbuf, "Tube %f %f", radius->value(), resolution->value());
00438     return cmdbuf;
00439   }
00440 };
00441     
00442 
00444 class GraphicsFltkRepRibbons : public GraphicsFltkRepBonds {
00445 protected:
00446   Fl_Counter *thickness;
00447 public:
00448   GraphicsFltkRepRibbons(Fl_Callback *cb, void *v)
00449   : GraphicsFltkRepBonds(cb, v) {
00450     radius->label("Radius"); 
00451     resolution->label("Resolution");
00452     Fl_Group::begin();
00453     thickness = new ResolutionCounter(x()+170,y()+60,"Width");
00454     thickness->callback(cb, v);
00455     Fl_Group::end();
00456   }
00457 protected:
00458   void do_reset() {
00459     GraphicsFltkRepBonds::do_reset();
00460     thickness->value(2);
00461   }
00462 public:
00463   const char *repcmd() {
00464     sprintf(cmdbuf, "Ribbons %f %f %f", radius->value(), resolution->value(),
00465       thickness->value());
00466     return cmdbuf;
00467   }
00468   void set_values(AtomRep *rep) {
00469     GraphicsFltkRepBonds::set_values(rep);
00470     thickness->value(rep->get_data(AtomRep::LINETHICKNESS));
00471   }
00472 };
00473 
00474 
00476 class GraphicsFltkRepNewRibbons : public GraphicsFltkRep {
00477 private:
00478   RepChoice *basis;
00479   IsoSlider *thickness, *ratio;
00480   ResolutionCounter *resolution;
00481 public:
00482   GraphicsFltkRepNewRibbons(Fl_Callback *cb, void *v) {
00483 
00484     Fl_Group::begin();
00485     thickness = new IsoSlider(x()+80, y()+90, "Thickness");
00486     thickness->callback(cb, v);
00487     thickness->minimum(0.1);
00488     thickness->maximum(10.0);
00489 
00490     resolution= new ResolutionCounter(x()+170,y()+120,"Resolution");
00491     resolution->callback(cb, v);
00492     resolution->maximum(50.0);
00493 
00494     ratio= new IsoSlider(x()+80, y()+60, "Aspect Ratio");
00495     ratio->callback(cb, v);
00496     ratio->minimum(1.0);
00497     ratio->maximum(10.0);
00498 
00499     basis = new RepChoice(x()+170,y()+30,"Spline Style");
00500     basis->add("Catmull-Rom");
00501     basis->add("B-Spline");
00502     basis->callback(cb, v);
00503     Fl_Group::end();
00504   }
00505 protected:
00506   void do_reset() {
00507     thickness->value(0.3);
00508     resolution->value(6);
00509     ratio->value(3);
00510     basis->value(0);
00511   }
00512 public:
00513   const char *repcmd() {
00514     sprintf(cmdbuf, "NewRibbons %f %f %f %d", thickness->value(), 
00515         resolution->value(), ratio->value(), basis->value());
00516     return cmdbuf;
00517   }
00518   void set_values(AtomRep *rep) {
00519     ratio->value(rep->get_data(AtomRep::LINETHICKNESS));
00520     basis->value((int)rep->get_data(AtomRep::SPHERERAD));
00521     thickness->value(rep->get_data(AtomRep::BONDRAD));
00522     resolution->value(rep->get_data(AtomRep::BONDRES));
00523   }
00524 };
00525 
00526 
00528 class GraphicsFltkRepCartoon : public GraphicsFltkRepRibbons {
00529 public:
00530   GraphicsFltkRepCartoon(Fl_Callback *cb, void *v)
00531   : GraphicsFltkRepRibbons(cb, v) {
00532     radius->label("Helix/Coil Radius");
00533     resolution->label("Helix/Coil Resolution");
00534     thickness->label("Beta Sheet Thickness");
00535   }
00536   const char *repcmd() {
00537     sprintf(cmdbuf, "Cartoon %f %f %f", radius->value(), resolution->value(),
00538       thickness->value());
00539     return cmdbuf;
00540   }
00541 protected:
00542   void do_reset() {
00543     radius->value(2.1);
00544     resolution->value(12.0);
00545     thickness->value(5.0);
00546   }
00547 };
00548 
00549 
00551 class GraphicsFltkRepNewCartoon : public GraphicsFltkRep {
00552 private:
00553   RepChoice *basis;
00554   IsoSlider *thickness, *ratio;
00555   ResolutionCounter *resolution;
00556 public:
00557   GraphicsFltkRepNewCartoon(Fl_Callback *cb, void *v) {
00558 
00559     Fl_Group::begin();
00560     thickness = new IsoSlider(x()+80, y()+90, "Thickness");
00561     thickness->callback(cb, v);
00562     thickness->minimum(0.1);
00563     thickness->maximum(10.0);
00564 
00565     resolution= new ResolutionCounter(x()+170,y()+120,"Resolution");
00566     resolution->callback(cb, v);
00567     resolution->maximum(50.0);
00568 
00569     ratio= new IsoSlider(x()+80, y()+60, "Aspect Ratio");
00570     ratio->callback(cb, v);
00571     ratio->minimum(1.0);
00572     ratio->maximum(10.0);
00573 
00574     basis = new RepChoice(x()+170,y()+30,"Spline Style");
00575     basis->add("Catmull-Rom");
00576     basis->add("B-Spline");
00577     basis->callback(cb, v);
00578     Fl_Group::end();
00579   }
00580 protected:
00581   void do_reset() {
00582     thickness->value(0.3);
00583     resolution->value(6);
00584     ratio->value(4.1);
00585     basis->value(0);
00586   }
00587 public:
00588   const char *repcmd() {
00589     sprintf(cmdbuf, "NewCartoon %f %f %f %d", thickness->value(), 
00590         resolution->value(), ratio->value(), basis->value());
00591     return cmdbuf;
00592   }
00593   void set_values(AtomRep *rep) {
00594     ratio->value(rep->get_data(AtomRep::LINETHICKNESS));
00595     basis->value((int)rep->get_data(AtomRep::SPHERERAD));
00596     thickness->value(rep->get_data(AtomRep::BONDRAD));
00597     resolution->value(rep->get_data(AtomRep::BONDRES));
00598   }
00599 };
00600 
00601 #ifdef VMDWITHCARBS
00602 
00604 class GraphicsFltkRepWithRingSize : public GraphicsFltkRep {
00605 protected:
00606   ResolutionCounter *max_ring_size;
00607   Fl_Callback *parentcb;
00608   void *parentdata;
00609   
00610   static void sync_cb(Fl_Widget *, void *v) {
00611     GraphicsFltkRepWithRingSize *self = (GraphicsFltkRepWithRingSize *)v;
00612     GraphicsFltkMenu *menu = (GraphicsFltkMenu *) self->parentdata;
00613     
00614     int max_ring_size = (int)self->max_ring_size->value();
00615     
00616     Molecule *m = menu->app->moleculeList->molecule(menu->molindex);
00617     assert(m != NULL);
00618     
00619     for (int i=0; i<m->components(); i++) {
00620       DrawMolItem *d = m->component(i);
00621       assert(d != NULL);
00622  
00623       AtomRep *ar = d->atomRep;
00624 
00625       if (ar->method() == AtomRep::RINGS_PAPERCHAIN || ar->method() == AtomRep::RINGS_TWISTER) {
00626         GraphicsFltkRepWithRingSize *rep;
00627         
00628         if (ar->method() == AtomRep::RINGS_PAPERCHAIN)
00629           rep = (GraphicsFltkRepWithRingSize *) menu->repcontrols.data("PaperChain");
00630         else
00631           rep = (GraphicsFltkRepWithRingSize *) menu->repcontrols.data("Twister");
00632 
00633         rep->set_values(ar);              
00634         rep->max_ring_size->value(max_ring_size);
00635         ar->change(rep->repcmd());
00636         d->force_recalc(d->MOL_REGEN);
00637       }        
00638     }
00639 
00640     // Don't call parent since we've already updated ourselves.
00641     // (self->parentcb)(self->max_ring_size, self->parentdata);
00642   }
00643 };
00644 
00646 class GraphicsFltkRepPaperChain : public GraphicsFltkRepWithRingSize {
00647 private:
00648   ShortSlider *bipyramid_height;
00649 public:
00650   GraphicsFltkRepPaperChain(Fl_Callback *cb, void *v) {
00651     parentcb = cb;
00652     parentdata = v;
00653 
00654     Fl_Group::begin();
00655 
00656     bipyramid_height = new ShortSlider(x()+120, y()+30, "Bipyramid Height");
00657     bipyramid_height->callback(cb, v);
00658     bipyramid_height->minimum(0.1);
00659     bipyramid_height->maximum(10.0);
00660 
00661     max_ring_size = new ResolutionCounter(x()+150, y()+60, "Max. Ring Size");
00662     max_ring_size->callback(sync_cb,this);
00663     max_ring_size->minimum(2);
00664     max_ring_size->maximum(500);
00665 
00666     Fl_Group::end();
00667   }
00668 protected:
00669   void do_reset() {
00670     bipyramid_height->value(1.0);
00671     max_ring_size->value(10);
00672   }
00673 public:
00674   const char *repcmd() {
00675     sprintf(cmdbuf, "PaperChain %f %f", bipyramid_height->value(),
00676                                          max_ring_size->value());
00677     return cmdbuf;
00678   }
00679   void set_values(AtomRep *rep) {
00680     bipyramid_height->value(rep->get_data(AtomRep::LINETHICKNESS));
00681     max_ring_size->value((int)rep->get_data(AtomRep::ISOSTEPSIZE));
00682   }
00683 };
00684 
00686 class GraphicsFltkRepTwister : public GraphicsFltkRepWithRingSize {
00687 private:
00688   RepChoice *start_end_centroid;
00689   RepChoice *hide_shared_links;
00690   ResolutionCounter *rib_steps;
00691   ShortSlider *rib_width;
00692   ShortSlider *rib_height;
00693   ResolutionCounter *max_path_length;
00694 
00695 public:
00696   GraphicsFltkRepTwister(Fl_Callback *cb, void *v) {
00697     parentcb = cb;
00698     parentdata = v;
00699 
00700     Fl_Group::begin();
00701 
00702     start_end_centroid = new RepChoice(x()+150, y()+30, "Start Ribbons At");
00703     start_end_centroid->callback(cb,v);
00704     start_end_centroid->add("Ring Edge");
00705     start_end_centroid->add("Ring Centroid");
00706     
00707     hide_shared_links = new RepChoice(x()+150, y()+60,"Hide Shared Links");
00708     hide_shared_links->callback(cb,v);
00709     hide_shared_links->add("No");
00710     hide_shared_links->add("Yes");
00711     
00712     rib_steps = new ResolutionCounter(x()+150, y()+90, "Steps in Ribbon");
00713     rib_steps->callback(cb,v);
00714     rib_steps->minimum(5);
00715     rib_steps->maximum(500);
00716 
00717     max_ring_size = new ResolutionCounter(x()+150, y()+120, "Max. Ring Size");
00718     max_ring_size->callback(sync_cb,this);
00719     max_ring_size->minimum(2);
00720     max_ring_size->maximum(500);
00721 
00722     max_path_length = new ResolutionCounter(x()+150, y()+150, "Max. Linking Distance");
00723     max_path_length->callback(cb,v);
00724     max_path_length->minimum(1);
00725     max_path_length->maximum(500);
00726 
00727     rib_width = new ShortSlider(x()+110, y()+180, "Ribbon Width");
00728     rib_width->callback(cb,v);
00729     rib_width->minimum(0.01);
00730     rib_width->maximum(10.0);
00731 
00732     rib_height = new ShortSlider(x()+110, y()+210, "Ribbon Height");
00733     rib_height->callback(cb,v);
00734     rib_height->minimum(0.01);
00735     rib_height->maximum(10.0);
00736 
00737     Fl_Group::end();
00738   }
00739 protected:
00740   void do_reset() {
00741     start_end_centroid->value(1);
00742     hide_shared_links->value(0);
00743     rib_steps->value(10);
00744     rib_width->value(0.3);
00745     rib_height->value(0.05);
00746     max_ring_size->value(10);
00747     max_path_length->value(5);
00748   }
00749 public:
00750   const char *repcmd() {
00751     sprintf(cmdbuf, "Twister %f %f %f %f %f %f %f", (float) start_end_centroid->value(),
00752                                                     (float) hide_shared_links->value(),
00753                                                     (float) rib_steps->value(),
00754                                                     rib_width->value(), rib_height->value(),
00755                                                     max_ring_size->value(), max_path_length->value());
00756     return cmdbuf;
00757   }
00758   void set_values(AtomRep *rep) {
00759     start_end_centroid->value((int)rep->get_data(AtomRep::LINETHICKNESS));
00760     hide_shared_links->value((int)rep->get_data(AtomRep::BONDRES));
00761     rib_steps->value((int)rep->get_data(AtomRep::SPHERERAD));
00762     rib_width->value(rep->get_data(AtomRep::BONDRAD));
00763     rib_height->value(rep->get_data(AtomRep::SPHERERES));
00764     max_ring_size->value((int)rep->get_data(AtomRep::ISOSTEPSIZE));
00765     max_path_length->value((int)rep->get_data(AtomRep::ISOLINETHICKNESS));
00766   }
00767 };
00768 
00769 #endif
00770 
00772 class GraphicsFltkRepSolvent : public GraphicsFltkRep {
00773 private:
00774   RepChoice *method;
00775   Fl_Counter *detail;
00776   Fl_Counter *probe; 
00777 public:
00778   GraphicsFltkRepSolvent(Fl_Callback *cb, void *v) {
00779     method = new RepChoice(x()+170,y()+60,"Representation Method");
00780     method->add("Points");
00781     method->add("Crosses");
00782     method->add("Mesh");
00783     detail = new ResolutionCounter(x()+170,y()+90,"Detail Level");
00784     detail->maximum(13);
00785     probe = new RadiusCounter(x()+170,y()+120,"Probe Radius");
00786     method->callback(cb, v);
00787     detail->callback(cb, v);
00788     probe->callback(cb, v);
00789     Fl_Group::end();
00790   }
00791 protected:
00792   void do_reset() {
00793     method->value(0);
00794     detail->value(7.0);
00795     probe->value(0);
00796   }
00797 public:
00798   const char *repcmd() {
00799     sprintf(cmdbuf, "Solvent %f %f %f", probe->value(), detail->value(),
00800       (float)(method->value()+1));
00801     return cmdbuf;
00802   }
00803   void set_values(AtomRep *rep) {
00804     method->setvalue((int)rep->get_data(AtomRep::LINETHICKNESS)-1);
00805     detail->value(rep->get_data(AtomRep::SPHERERES));
00806     probe->value(rep->get_data(AtomRep::SPHERERAD));
00807   }
00808 };
00809  
00810 
00812 class GraphicsFltkRepMSMS : public GraphicsFltkRep {
00813 private:
00814   Fl_Counter *density;
00815   Fl_Counter *probe;
00816   RepChoice *method;
00817   RepChoice *whichatoms;
00818 public:
00819   GraphicsFltkRepMSMS(Fl_Callback *cb, void *v) {
00820     density = new RadiusCounter(x()+170,y()+90,"Sample Density");
00821     density->minimum(0.1);
00822     density->maximum(30.0);
00823     density->callback(cb, v);
00824     probe = new RadiusCounter(x()+170,y()+120, "Probe Radius");
00825     probe->minimum(0.1);
00826     probe->maximum(8.0);
00827     probe->callback(cb, v);
00828     method = new RepChoice(x()+170,y()+60,"Representation Method");
00829     method->add("Solid Surface");
00830     method->add("Wireframe");
00831     method->callback(cb, v);
00832     whichatoms = new RepChoice(x()+170,y()+30, "Which Atoms");
00833     whichatoms->add("Selected");
00834     whichatoms->add("All");
00835     whichatoms->callback(cb, v);
00836     Fl_Group::end();
00837   }
00838 protected:
00839   void do_reset() {
00840     density->value(1.5);
00841     probe->value(1.5);
00842     method->value(0);
00843     whichatoms->value(0);
00844   }
00845 public:
00846   const char *repcmd() {
00847     sprintf(cmdbuf, "MSMS %f %f %f %f", probe->value(), density->value(),
00848       (float)whichatoms->value(), (float)method->value());
00849     return cmdbuf;
00850   }
00851   void set_values(AtomRep *rep) {
00852     density->value(rep->get_data(AtomRep::SPHERERES));
00853     probe->value(rep->get_data(AtomRep::SPHERERAD));
00854     method->setvalue((int)rep->get_data(AtomRep::BONDRES));
00855     whichatoms->setvalue((int)rep->get_data(AtomRep::LINETHICKNESS));
00856   }
00857 };
00858   
00859 
00861 class GraphicsFltkRepHBonds : public GraphicsFltkRep {
00862 private:
00863   Fl_Counter *distance;
00864   Fl_Counter *angle;
00865   Fl_Counter *thickness;
00866 public:
00867   GraphicsFltkRepHBonds(Fl_Callback *cb, void *v) {
00868     distance = new RadiusCounter(x()+170,y()+60,"Distance Cutoff");
00869     distance->callback(cb, v);
00870     angle = new RadiusCounter(x()+170,y()+90,"Angle Cutoff");
00871     angle->precision(0);
00872     angle->step(1);
00873     angle->lstep(10);
00874     angle->callback(cb, v);
00875     thickness = new ResolutionCounter(x()+170,y()+120, "Line Thickness");
00876     thickness->callback(cb, v);
00877     Fl_Group::end();
00878   }
00879 protected:
00880   void do_reset() {
00881     distance->value(3.0);
00882     angle->value(20.0);
00883     thickness->value(1.0);
00884   }
00885 public:
00886   const char *repcmd() {
00887     sprintf(cmdbuf, "HBonds %f %f %f", distance->value(), angle->value(),
00888       thickness->value());
00889     return cmdbuf;
00890   }
00891   void set_values(AtomRep *rep) {
00892     distance->value(rep->get_data(AtomRep::BONDRAD));
00893     angle->value(rep->get_data(AtomRep::SPHERERAD));
00894     thickness->value(rep->get_data(AtomRep::LINETHICKNESS));
00895   }
00896 };
00897      
00898 
00900 class GraphicsFltkRepSurf : public GraphicsFltkRep {
00901 private:
00902   Fl_Counter *probe;
00903   RepChoice *method;
00904 public:
00905   GraphicsFltkRepSurf(Fl_Callback *cb, void *v) {
00906     probe = new RadiusCounter(x()+170,y()+120,"Probe Radius");
00907     probe->minimum(0.1);
00908     probe->callback(cb, v);
00909     method = new RepChoice(x()+170,y()+90, "Representation Method");
00910     method->add("Solid Surface");
00911     method->add("Wireframe");
00912     method->callback(cb, v);
00913     Fl_Group::end();
00914   }
00915 protected:
00916   void do_reset() {
00917     probe->value(1.4);
00918     method->value(0);
00919   }
00920 public:
00921   const char *repcmd() {
00922     sprintf(cmdbuf, "Surf %f %f", probe->value(), (float)method->value());
00923     return cmdbuf;
00924   }
00925   void set_values(AtomRep *rep) {
00926     probe->value(rep->get_data(AtomRep::SPHERERAD));
00927     method->setvalue((int)rep->get_data(AtomRep::BONDRES));
00928   }
00929 };
00930  
00931 
00936 class GraphicsFltkRepVolumetric: public GraphicsFltkRep {
00937 protected:
00938   RepChoice *dataset;
00939 
00941   struct minmax {
00942     double minval, maxval;
00943     minmax(double themin=0, double themax=0) : minval(themin), maxval(themax) {}
00944     int operator==(const minmax &v) {
00945       return (minval == v.minval && maxval == v.maxval);
00946     }
00947   };
00948   ResizeArray<minmax> minmaxlist;
00949 
00950   GraphicsFltkRepVolumetric(Fl_Callback *cb, void *v) {
00951     dataset = new RepChoice(x()+170, y()+30, "Vol");
00952     dataset->callback(cb, v);
00953   }
00954   virtual void do_dataset_clear() {}
00955   virtual void do_dataset_append(const char *, double, double) {}
00956 
00957 public:
00958   int is_volumetric() { return 1; }
00959   void dataset_clear() {
00960     dataset->clear();
00961     dataset->deactivate();
00962     minmaxlist.clear();
00963     do_dataset_clear();
00964   }
00965   void dataset_append(const char *nm, double newmin, double newmax) {
00966     // Fltk doesn't allow adding a menu item with the same name as
00967     // an existing item, so we use replace, which also avoids 
00968     // problems with the escape characters interpreted by add()
00969     int ind = dataset->add("foobar"); 
00970     char *datalabel = new char[strlen(nm)+32];
00971     sprintf(datalabel, "vol%d: %s", ind, nm);
00972     dataset->replace(ind, datalabel);
00973     delete[] datalabel;
00974     
00975     minmaxlist.append(minmax(newmin, newmax));
00976     dataset->value(minmaxlist.num()-1);
00977     do_dataset_append(nm, newmin, newmax);
00978     dataset->activate();
00979   }
00980 };
00981   
00982         
00984 class GraphicsFltkRepIsosurface : public GraphicsFltkRepVolumetric {
00985 private:
00986   Fl_Slider *isovalue;
00987   Fl_Float_Input *isoinput;
00988   Fl_Float_Input *isomininput, *isomaxinput;
00989   Fl_Counter *resolution;
00990   Fl_Counter *thickness;
00991   RepChoice *method;
00992   RepChoice *boundary;
00993   Fl_Callback *parentcb;
00994   void *parentdata;
00995   int gridstepsize;
00996 
00997   static void datasetchanged_cb(Fl_Widget *w, void *v) {
00998     GraphicsFltkRepIsosurface *self = (GraphicsFltkRepIsosurface *)v;
00999     minmax &m = self->minmaxlist[self->dataset->value()];
01000     self->isovalue->range(m.minval, m.maxval);
01001 
01002     (self->parentcb)(w, self->parentdata);
01003   }
01004 
01005   static void inputcb(Fl_Widget *, void *v) {
01006     GraphicsFltkRepIsosurface *self = (GraphicsFltkRepIsosurface *)v;
01007     char *endptr = NULL;
01008     const char *strval = self->isoinput->value();
01009     double val = strtod(strval, &endptr);
01010     if (endptr != strval) {
01011       // valid conversion performed
01012       self->isovalue->value(val);
01013       (self->parentcb)(self->isovalue, self->parentdata);
01014     }
01015   }
01016   
01017   static void minmaxinputcb(Fl_Widget *, void *v) {
01018     GraphicsFltkRepIsosurface *self = (GraphicsFltkRepIsosurface *)v;
01019     // parse values in input fields
01020     char *endptr = NULL;
01021     const char *minstrval = self->isomininput->value();
01022     double minval = strtod(minstrval, &endptr);
01023     if (endptr == minstrval) return; // invalid
01024     const char *maxstrval = self->isomaxinput->value();
01025     double maxval = strtod(maxstrval, &endptr);
01026     if (endptr == maxstrval) return; // invalid
01027 
01028     // fields are valid; update cached minmax
01029     minmax &m = self->minmaxlist[self->dataset->value()];
01030     m.minval = minval;
01031     m.maxval = maxval;
01032 
01033     // update the slider itself.  If we made the value change, trigger
01034     // appropriate callbacks.
01035     self->isovalue->range(minval, maxval);
01036     if (self->isovalue->value() < minval) {
01037       self->isovalue->value(minval);
01038       slidercb(NULL, v);
01039     } else if (self->isovalue->value() > maxval) {
01040       self->isovalue->value(maxval);
01041       slidercb(NULL, v);
01042     } else {
01043       self->setInputFromSlider();
01044     }
01045   }
01046 
01047   void setInputFromSlider() {
01048     char buf[128];
01049     sprintf(buf, "%8g", (float)isovalue->value()); 
01050     isoinput->value(buf);
01051     sprintf(buf, "%8g", (float)isovalue->minimum());
01052     isomininput->value(buf);
01053     sprintf(buf, "%8g", (float)isovalue->maximum());
01054     isomaxinput->value(buf);
01055   }
01056 
01057   static void slidercb(Fl_Widget *, void *v) {
01058     GraphicsFltkRepIsosurface *self = (GraphicsFltkRepIsosurface *)v;
01059     self->setInputFromSlider();
01060     (self->parentcb)(self->isovalue, self->parentdata);
01061   }
01062 
01063 protected:
01064   void do_dataset_clear() { 
01065     isovalue->deactivate();
01066     isoinput->deactivate();
01067     boundary->deactivate();
01068     method->deactivate();
01069     resolution->deactivate();
01070     thickness->deactivate();
01071   }
01072   void do_dataset_append(const char *, double min, double max) { 
01073     isovalue->activate();
01074     isoinput->activate();
01075     boundary->activate();
01076     method->activate();
01077     resolution->activate();
01078     thickness->activate();
01079     isovalue->range(min,max);
01080     setInputFromSlider();
01081   }
01082   void do_reset() {
01083     set_grid_stepsize(1); 
01084     resolution->value(1); 
01085     thickness->value(1);  
01086     method->value(2);     
01087     boundary->value(2);   
01088     dataset->value(0);    
01089   }
01090 
01091 public:
01092   GraphicsFltkRepIsosurface(Fl_Callback *cb, void *v)
01093   : GraphicsFltkRepVolumetric(datasetchanged_cb, this) {
01094     parentcb = cb;
01095     parentdata = v;
01096 
01097     resolution= new StepCounter(x()+35,y()+90, "Step");
01098     resolution->callback(cb, v);
01099     thickness= new StepCounter(x()+35,y()+120, "Size");
01100     thickness->callback(cb, v);
01101     method = new RepChoice(x()+170,y()+90,"Draw");
01102     method->add("Solid Surface");
01103     method->add("Wireframe");
01104     method->add("Points");
01105     method->add("Shaded Points");
01106     method->callback(cb, v);
01107     boundary = new RepChoice(x()+170, y()+120, "Show");
01108     boundary->add("Isosurface");
01109     boundary->add("Box");
01110     boundary->add("Box+Isosurface");
01111     boundary->callback(cb, v); 
01112     isovalue = new Fl_Slider(x()+150,y()+60, 140, CTRHEIGHT, "");
01113     isovalue->type(FL_HOR_SLIDER);
01114     isovalue->color(FL_WHITE);
01115     isovalue->when(FL_WHEN_CHANGED);
01116     isovalue->callback(slidercb, this); 
01117     isoinput = new Fl_Float_Input(x()+80, y()+60, 70, CTRHEIGHT, "Isovalue");
01118     isoinput->when(FL_WHEN_ENTER_KEY);
01119     isoinput->selection_color(FL_YELLOW);
01120     isoinput->callback(inputcb, this);
01121     isovalue->when(FL_WHEN_CHANGED | FL_WHEN_RELEASE_ALWAYS);
01122 
01123     isomininput = new Fl_Float_Input(x()+45, y()+30, 45, CTRHEIGHT, "Range");
01124     isomininput->when(FL_WHEN_ENTER_KEY);
01125     isomininput->selection_color(FL_YELLOW);
01126     isomininput->callback(minmaxinputcb, this);
01127     isomaxinput = new Fl_Float_Input(x()+90, y()+30, 45, CTRHEIGHT);
01128     isomaxinput->when(FL_WHEN_ENTER_KEY);
01129     isomaxinput->selection_color(FL_YELLOW);
01130     isomaxinput->callback(minmaxinputcb, this);
01131 
01132     Fl_Group::end();
01133   }
01134   const char *repcmd() {
01135     if (dataset->size() > 0) {
01136       sprintf(cmdbuf, "Isosurface %f %f %f %f %d %d", 
01137               (float) isovalue->value(), 
01138               (float) dataset->value(), 
01139               (float) boundary->value(), 
01140               (float) method->value(), 
01141               gridstepsize + (int) resolution->value() - 1,
01142               (int) thickness->value());
01143     } else {
01144       sprintf(cmdbuf, "Isosurface");
01145     }
01146     return cmdbuf;
01147   }
01148   void set_values(AtomRep *rep) {
01149     dataset->setvalue((int)rep->get_data(AtomRep::SPHERERES));
01150     // minmax needs to update whenever dataset is changed or 
01151     // the selected rep is switched
01152     minmax &m = minmaxlist[dataset->value()]; 
01153     isovalue->range(m.minval, m.maxval);
01154     isovalue->value(rep->get_data(AtomRep::SPHERERAD));
01155     method->setvalue((int)rep->get_data(AtomRep::BONDRES));
01156     boundary->setvalue((int)rep->get_data(AtomRep::LINETHICKNESS));
01157     resolution->value(rep->get_data(AtomRep::ISOSTEPSIZE) - gridstepsize + 1);
01158     thickness->value(rep->get_data(AtomRep::ISOLINETHICKNESS));
01159     setInputFromSlider();
01160   }
01161   void set_grid_stepsize(int step) {
01162     gridstepsize = step;
01163   }
01164 };
01165  
01166 
01168 class GraphicsFltkRepVolumeSlice : public GraphicsFltkRepVolumetric {
01169 private:
01170   Fl_Value_Slider *slice;
01171   RepChoice *axis;
01172   RepChoice *quality;  // texture filtering mode
01173 
01174 protected:
01175   void do_dataset_clear() {
01176     slice->deactivate();
01177     axis->deactivate();
01178     quality->deactivate();
01179   }
01180   void do_dataset_append(const char *, double, double) {
01181     slice->activate();
01182     axis->activate();
01183     quality->activate();
01184   }
01185   void do_reset() {
01186     slice->value(0.5);
01187     axis->value(0);
01188     quality->value(2);
01189   }
01190 public:
01191   GraphicsFltkRepVolumeSlice(Fl_Callback *cb, void *v)
01192   : GraphicsFltkRepVolumetric(cb, v) {
01193     slice = new IsoSlider(x()+80, y()+60, "Slice Offset");
01194     slice->callback(cb, v);
01195     axis = new RepChoice(x()+170, y()+90, "Slice Axis");
01196     axis->add("X");
01197     axis->add("Y");
01198     axis->add("Z");
01199     axis->callback(cb, v);
01200     quality = new RepChoice(x()+170,y()+120, "Render Quality");
01201     quality->add("Low");
01202     quality->add("Medium");
01203     quality->add("High");
01204     quality->callback(cb, v);
01205     Fl_Group::end();
01206   }
01207   const char *repcmd() {
01208     if (dataset->size() > 0) {
01209       sprintf(cmdbuf, "VolumeSlice %f %f %f %f", slice->value(),
01210         (float)dataset->value(), (float)axis->value(), 
01211         (float)quality->value()); 
01212     } else {
01213       sprintf(cmdbuf, "VolumeSlice");
01214     }
01215     return cmdbuf;
01216   }
01217   void set_values(AtomRep *rep) {
01218     dataset->setvalue((int)rep->get_data(AtomRep::SPHERERES));
01219     slice->value(rep->get_data(AtomRep::SPHERERAD));
01220     axis->setvalue((int)rep->get_data(AtomRep::LINETHICKNESS)); 
01221     quality->setvalue((int)rep->get_data(AtomRep::BONDRES));
01222   }
01223 };
01224 
01225 
01226 #ifdef VMDFIELDLINES
01227 
01229 class GraphicsFltkRepFieldLines : public GraphicsFltkRepVolumetric {
01230 private:
01231   Fl_Counter *thickness;
01232   Fl_Value_Slider *gradmag;
01233   Fl_Value_Slider *minlen;
01234   Fl_Value_Slider *maxlen;
01235 
01236 protected:
01237   void do_dataset_clear() {
01238     gradmag->deactivate();
01239     minlen->deactivate();
01240     maxlen->deactivate();
01241     thickness->deactivate();
01242   }
01243   void do_dataset_append(const char *, double, double) {
01244     gradmag->activate();
01245     minlen->activate();
01246     maxlen->activate();
01247     thickness->activate();
01248   }
01249   void do_reset() {
01250     gradmag->value(1.8);
01251     minlen->value(10);
01252     maxlen->value(50);
01253     thickness->value(1);
01254   }
01255 
01256 public:
01257   GraphicsFltkRepFieldLines(Fl_Callback *cb, void *v)
01258   : GraphicsFltkRepVolumetric(cb, v) {
01259     thickness = new ResolutionCounter(x()+20, y()+30, "Size");
01260     thickness->callback(cb, v);
01261     gradmag = new IsoSlider(x()+80,  y()+60, "GradientMag");
01262     gradmag->callback(cb, v);
01263     minlen = new IsoSlider(x()+80,  y()+90, "Min Length");
01264     minlen->callback(cb, v);
01265     maxlen = new IsoSlider(x()+80, y()+120, "Max Length");
01266     maxlen->callback(cb, v);
01267     Fl_Group::end();
01268   }
01269   const char *repcmd() {
01270     if (dataset->size() > 0) {
01271       sprintf(cmdbuf, "FieldLines %f %f %f %f %f", 
01272         (float)dataset->value(), gradmag->value(), minlen->value(), maxlen->value(), thickness->value());
01273     } else {
01274       sprintf(cmdbuf, "FieldLines");
01275     }
01276     return cmdbuf;
01277   }
01278   void set_values(AtomRep *rep) {
01279     dataset->setvalue((int)rep->get_data(AtomRep::SPHERERES));
01280     gradmag->range(0.05, 25.0);
01281     gradmag->value(rep->get_data(AtomRep::SPHERERAD));
01282     minlen->range(1, 500.0);
01283     minlen->value(rep->get_data(AtomRep::BONDRAD));
01284     maxlen->range(1, 500.0);
01285     maxlen->value(rep->get_data(AtomRep::BONDRES));
01286     thickness->range(1, 10);
01287     thickness->value(rep->get_data(AtomRep::LINETHICKNESS));
01288   }
01289 };
01290 
01291 #endif
01292 

Generated on Sat Aug 30 01:26:45 2008 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002