www.pudn.com > fi_treegen10.zip > guiTreeGen.cxx


// generated by Fast Light User Interface Designer (fluid) version 1.0010 
 
#include "guiTreeGen.h" 
 
inline void UI::cb_quit_i(Fl_Button*, void*) { 
  ogl_window->quit(); 
} 
void UI::cb_quit(Fl_Button* o, void* v) { 
  ((UI*)(o->parent()->user_data()))->cb_quit_i(o,v); 
} 
 
inline void UI::cb_zoom_i(Fl_Value_Slider* o, void*) { 
  ogl_window->setGlobalScale( (float)((Fl_Value_Slider *)o)->value() ); 
ogl_window->draw(); 
} 
void UI::cb_zoom(Fl_Value_Slider* o, void* v) { 
  ((UI*)(o->parent()->user_data()))->cb_zoom_i(o,v); 
} 
 
inline void UI::cb_recursion_i(Fl_Value_Slider* o, void*) { 
  ogl_window->recDepth = (unsigned int)((Fl_Value_Slider *)o)->value(); 
ogl_window->tree.setMaxRecursionLevel( (unsigned int)((Fl_Value_Slider *)o)->value() ); 
ogl_window->draw(); 
} 
void UI::cb_recursion(Fl_Value_Slider* o, void* v) { 
  ((UI*)(o->parent()->user_data()))->cb_recursion_i(o,v); 
} 
 
inline void UI::cb_toggleTreeBase_i(Fl_Repeat_Button*, void*) { 
  static bool state = false; 
 
if( state == false ) 
{ 
  toggleTreeBase->label( "Normal Tree Base" ); 
  state = true; 
} 
else 
{ 
  toggleTreeBase->label( "Spiral Tree Base" ); 
  state = false; 
} 
ogl_window->tree.toggleTreeBase(); 
ogl_window->draw(); // show changes; 
} 
void UI::cb_toggleTreeBase(Fl_Repeat_Button* o, void* v) { 
  ((UI*)(o->parent()->user_data()))->cb_toggleTreeBase_i(o,v); 
} 
 
inline void UI::cb_reset_i(Fl_Button*, void*) { 
  resetUI(); // resets all the sliders, rollers, and dials 
ogl_window->draw(); // and show the changes; 
} 
void UI::cb_reset(Fl_Button* o, void* v) { 
  ((UI*)(o->parent()->user_data()))->cb_reset_i(o,v); 
} 
 
inline void UI::cb_levelOfDetail_i(Fl_Value_Slider* o, void*) { 
  float sliderVal = (float)((Fl_Value_Slider *)o)->value(); 
float lod = (sliderVal+2.0f) / 12.0f; // scale LOD to range between [0,1] 
ogl_window->tree.setLevelOfDetail( lod ); 
ogl_window->draw(); 
} 
void UI::cb_levelOfDetail(Fl_Value_Slider* o, void* v) { 
  ((UI*)(o->parent()->user_data()))->cb_levelOfDetail_i(o,v); 
} 
 
inline void UI::cb_linePrim_i(Fl_Round_Button*, void*) { 
  levelOfDetail->deactivate(); // grey it out because it doesn't apply 
ogl_window->tree.setPrimitiveType( LINE ); 
ogl_window->draw(); 
} 
void UI::cb_linePrim(Fl_Round_Button* o, void* v) { 
  ((UI*)(o->parent()->parent()->user_data()))->cb_linePrim_i(o,v); 
} 
 
inline void UI::cb_planePrim_i(Fl_Round_Button*, void*) { 
  levelOfDetail->deactivate(); // grey it out because it doesn't apply 
ogl_window->tree.setPrimitiveType( PLANE ); 
ogl_window->draw(); 
} 
void UI::cb_planePrim(Fl_Round_Button* o, void* v) { 
  ((UI*)(o->parent()->parent()->user_data()))->cb_planePrim_i(o,v); 
} 
 
inline void UI::cb_cylPrim_i(Fl_Round_Button*, void*) { 
  levelOfDetail->activate(); // the lev of detail slider affects this primitive 
ogl_window->tree.setPrimitiveType( CYLINDER ); 
ogl_window->draw(); 
} 
void UI::cb_cylPrim(Fl_Round_Button* o, void* v) { 
  ((UI*)(o->parent()->parent()->user_data()))->cb_cylPrim_i(o,v); 
} 
 
inline void UI::cb_sphPrim_i(Fl_Round_Button*, void*) { 
  levelOfDetail->activate(); // the lev of detail slider affects this primitive 
ogl_window->tree.setPrimitiveType( SPHERE ); 
ogl_window->draw(); 
} 
void UI::cb_sphPrim(Fl_Round_Button* o, void* v) { 
  ((UI*)(o->parent()->parent()->user_data()))->cb_sphPrim_i(o,v); 
} 
 
inline void UI::cb_spread_i(Fl_Value_Slider* o, void*) { 
  unsigned int spread = (unsigned int)((Fl_Value_Slider *)o)->value(); 
ogl_window->tree.setSpread( spread ); 
ogl_window->draw(); 
} 
void UI::cb_spread(Fl_Value_Slider* o, void* v) { 
  ((UI*)(o->parent()->user_data()))->cb_spread_i(o,v); 
} 
 
inline void UI::cb_twist_i(Fl_Value_Slider* o, void*) { 
  unsigned int twist = (unsigned int)((Fl_Value_Slider *)o)->value(); 
ogl_window->tree.setTwist( twist ); 
ogl_window->draw(); 
} 
void UI::cb_twist(Fl_Value_Slider* o, void* v) { 
  ((UI*)(o->parent()->user_data()))->cb_twist_i(o,v); 
} 
 
inline void UI::cb_branchPerLev_i(Fl_Value_Slider* o, void*) { 
  unsigned int branchesPerLev = (unsigned int)((Fl_Value_Slider *)o)->value(); 
ogl_window->tree.setBranchesPerLevel( branchesPerLev ); 
ogl_window->draw(); 
} 
void UI::cb_branchPerLev(Fl_Value_Slider* o, void* v) { 
  ((UI*)(o->parent()->user_data()))->cb_branchPerLev_i(o,v); 
} 
 
inline void UI::cb_randomizer_i(Fl_Repeat_Button*, void*) { 
  int randSpread = rand() % (int)spread->maximum(); 
spread->value( randSpread ); 
ogl_window->tree.setSpread( randSpread ); 
 
int randTwist = rand() % (int)twist->maximum(); 
twist->value( randTwist ); 
ogl_window->tree.setTwist( randTwist ); 
 
int randBranches = rand() % (int)branchPerLev->maximum(); 
if( randBranches == 0 ) randBranches = 1; 
branchPerLev->value( randBranches ); 
ogl_window->tree.setBranchesPerLevel( randBranches ); 
 
ogl_window->draw(); // show changes; 
} 
void UI::cb_randomizer(Fl_Repeat_Button* o, void* v) { 
  ((UI*)(o->parent()->user_data()))->cb_randomizer_i(o,v); 
} 
 
inline void UI::cb_toggleColors_i(Fl_Repeat_Button*, void*) { 
  static bool state = false; 
 
if( state == false ) 
{ 
  toggleColors->label( "Tree Color" ); 
  ogl_window->tree.setColorScheme( 1 ); 
  state = true; 
} 
else 
{ 
  toggleColors->label( "Pseudocolor" ); 
  ogl_window->tree.setColorScheme( 0 ); 
  state = false; 
} 
ogl_window->draw(); // show changes; 
} 
void UI::cb_toggleColors(Fl_Repeat_Button* o, void* v) { 
  ((UI*)(o->parent()->user_data()))->cb_toggleColors_i(o,v); 
} 
 
inline void UI::cb_toggleLeaves_i(Fl_Light_Button*, void*) { 
  ogl_window->tree.toggleLeaves(); 
ogl_window->draw(); 
} 
void UI::cb_toggleLeaves(Fl_Light_Button* o, void* v) { 
  ((UI*)(o->parent()->user_data()))->cb_toggleLeaves_i(o,v); 
} 
 
inline void UI::cb_toggleTex_i(Fl_Light_Button*, void*) { 
  ogl_window->toggleTextures(); 
} 
void UI::cb_toggleTex(Fl_Light_Button* o, void* v) { 
  ((UI*)(o->parent()->user_data()))->cb_toggleTex_i(o,v); 
} 
 
inline void UI::cb_polyDwgMode_i(Fl_Light_Button*, void*) { 
  ogl_window->togglePolyMode(); 
} 
void UI::cb_polyDwgMode(Fl_Light_Button* o, void* v) { 
  ((UI*)(o->parent()->user_data()))->cb_polyDwgMode_i(o,v); 
} 
 
inline void UI::cb_projMode_i(Fl_Light_Button*, void*) { 
  ogl_window->toggleProjMode(); 
} 
void UI::cb_projMode(Fl_Light_Button* o, void* v) { 
  ((UI*)(o->parent()->user_data()))->cb_projMode_i(o,v); 
} 
 
inline void UI::cb_togDisplayList_i(Fl_Light_Button*, void*) { 
  ogl_window->tree.toggleDisplayList(); 
//ogl_window->draw(); 
} 
void UI::cb_togDisplayList(Fl_Light_Button* o, void* v) { 
  ((UI*)(o->parent()->user_data()))->cb_togDisplayList_i(o,v); 
} 
 
inline void UI::cb_worldAxis_i(Fl_Light_Button*, void*) { 
  ogl_window->toggleWorldAxis(); 
// While this button works, we've just run out of room 
// and this function is very non-essential; 
} 
void UI::cb_worldAxis(Fl_Light_Button* o, void* v) { 
  ((UI*)(o->parent()->user_data()))->cb_worldAxis_i(o,v); 
} 
 
inline void UI::cb_aboutButton_i(Fl_Button*, void*) { 
  aboutWindow->show(); 
} 
void UI::cb_aboutButton(Fl_Button* o, void* v) { 
  ((UI*)(o->parent()->user_data()))->cb_aboutButton_i(o,v); 
} 
 
inline void UI::cb_okButton_i(Fl_Return_Button* o, void*) { 
  ((Fl_Window*)(o->parent()))->hide(); 
} 
void UI::cb_okButton(Fl_Return_Button* o, void* v) { 
  ((UI*)(o->parent()->user_data()))->cb_okButton_i(o,v); 
} 
 
UI::UI() { 
  Fl_Window* w; 
  { Fl_Window* o = mainWindow = new Fl_Window(790, 543, "TreeGen"); 
    w = o; 
    o->box(FL_DOWN_BOX); 
    o->labelcolor(92); 
    o->user_data((void*)(this)); 
    { OGL_Window* o = ogl_window = new OGL_Window(10, 15, 645, 480, "ogl_space"); 
      o->box(FL_EMBOSSED_BOX); 
      o->color(231); 
      o->selection_color(252); 
      o->labelcolor(175); 
      Fl_Group::current()->resizable(o); 
    } 
    { Fl_Button* o = quit = new Fl_Button(10, 505, 70, 20, "Quit"); 
      o->callback((Fl_Callback*)cb_quit); 
    } 
    { Fl_Value_Slider* o = zoom = new Fl_Value_Slider(305, 505, 170, 20, "zoom"); 
      o->type(5); 
      o->selection_color(136); 
      o->minimum(0.1); 
      o->maximum(3); 
      o->value(1); 
      o->callback((Fl_Callback*)cb_zoom); 
    } 
    { Fl_Value_Slider* o = recursion = new Fl_Value_Slider(485, 505, 170, 20, "Rec Depth"); 
      o->type(5); 
      o->selection_color(136); 
      o->minimum(1); 
      o->maximum(10); 
      o->step(1); 
      o->value(5); 
      o->callback((Fl_Callback*)cb_recursion); 
    } 
    { Fl_Repeat_Button* o = toggleTreeBase = new Fl_Repeat_Button(170, 505, 125, 20, "Spiral Tree Base"); 
      o->callback((Fl_Callback*)cb_toggleTreeBase); 
    } 
    { Fl_Button* o = reset = new Fl_Button(665, 15, 115, 20, "Reset"); 
      o->down_box(FL_DOWN_BOX); 
      o->callback((Fl_Callback*)cb_reset); 
    } 
    { Fl_Value_Slider* o = levelOfDetail = new Fl_Value_Slider(665, 60, 115, 20, "Detail"); 
      o->type(5); 
      o->selection_color(136); 
      o->minimum(1); 
      o->maximum(10); 
      o->step(1); 
      o->value(5); 
      o->callback((Fl_Callback*)cb_levelOfDetail); 
      o->align(FL_ALIGN_TOP); 
    } 
    { Fl_Group* o = primitiveShape = new Fl_Group(665, 105, 115, 95, "Tree Primitive"); 
      o->box(FL_DOWN_FRAME); 
      { Fl_Round_Button* o = linePrim = new Fl_Round_Button(675, 110, 60, 25, "Lines"); 
        o->type(102); 
        o->down_box(FL_ROUND_DOWN_BOX); 
        o->selection_color(102); 
        o->callback((Fl_Callback*)cb_linePrim); 
      } 
      { Fl_Round_Button* o = planePrim = new Fl_Round_Button(675, 130, 60, 25, "Planes"); 
        o->type(102); 
        o->down_box(FL_ROUND_DOWN_BOX); 
        o->selection_color(102); 
        o->callback((Fl_Callback*)cb_planePrim); 
      } 
      { Fl_Round_Button* o = cylPrim = new Fl_Round_Button(675, 150, 60, 25, "Cylinders"); 
        o->type(102); 
        o->down_box(FL_ROUND_DOWN_BOX); 
        o->selection_color(102); 
        o->callback((Fl_Callback*)cb_cylPrim); 
      } 
      { Fl_Round_Button* o = sphPrim = new Fl_Round_Button(675, 170, 60, 25, "Spheres"); 
        o->type(102); 
        o->down_box(FL_ROUND_DOWN_BOX); 
        o->selection_color(102); 
        o->callback((Fl_Callback*)cb_sphPrim); 
      } 
      o->end(); 
    } 
    { Fl_Value_Slider* o = spread = new Fl_Value_Slider(665, 220, 115, 20, "Spread"); 
      o->type(5); 
      o->selection_color(136); 
      o->maximum(90); 
      o->step(1); 
      o->value(25); 
      o->callback((Fl_Callback*)cb_spread); 
      o->align(FL_ALIGN_TOP); 
    } 
    { Fl_Value_Slider* o = twist = new Fl_Value_Slider(665, 260, 115, 20, "Twist"); 
      o->type(5); 
      o->selection_color(136); 
      o->maximum(360); 
      o->step(1); 
      o->value(180); 
      o->callback((Fl_Callback*)cb_twist); 
      o->align(FL_ALIGN_TOP); 
    } 
    { Fl_Value_Slider* o = branchPerLev = new Fl_Value_Slider(665, 300, 115, 20, "Branches Per Lev"); 
      o->type(5); 
      o->selection_color(136); 
      o->minimum(1); 
      o->maximum(8); 
      o->step(1); 
      o->value(2); 
      o->callback((Fl_Callback*)cb_branchPerLev); 
      o->align(FL_ALIGN_TOP); 
    } 
    { Fl_Repeat_Button* o = randomizer = new Fl_Repeat_Button(665, 335, 115, 20, "Randomize"); 
      o->callback((Fl_Callback*)cb_randomizer); 
    } 
    { Fl_Repeat_Button* o = toggleColors = new Fl_Repeat_Button(665, 365, 115, 20, "Pseudocolor"); 
      o->callback((Fl_Callback*)cb_toggleColors); 
    } 
    { Fl_Light_Button* o = toggleLeaves = new Fl_Light_Button(665, 395, 115, 20, "Draw Leaves"); 
      o->callback((Fl_Callback*)cb_toggleLeaves); 
      o->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE); 
      o->when(FL_WHEN_CHANGED); 
    } 
    { Fl_Light_Button* o = toggleTex = new Fl_Light_Button(665, 425, 115, 20, "Use Textures  "); 
      o->callback((Fl_Callback*)cb_toggleTex); 
      o->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE); 
      o->when(FL_WHEN_CHANGED); 
    } 
    { Fl_Light_Button* o = polyDwgMode = new Fl_Light_Button(665, 455, 115, 20, "Wireframe"); 
      o->callback((Fl_Callback*)cb_polyDwgMode); 
      o->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE); 
    } 
    { Fl_Light_Button* o = projMode = new Fl_Light_Button(665, 485, 115, 20, "Ortho"); 
      o->callback((Fl_Callback*)cb_projMode); 
      o->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE); 
    } 
    { Fl_Light_Button* o = togDisplayList = new Fl_Light_Button(665, 515, 115, 20, "Display List"); 
      o->callback((Fl_Callback*)cb_togDisplayList); 
      o->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE); 
    } 
    { Fl_Light_Button* o = worldAxis = new Fl_Light_Button(665, 515, 115, 20, "Show Axis"); 
      o->callback((Fl_Callback*)cb_worldAxis); 
      o->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE); 
      o->hide(); 
      o->deactivate(); 
    } 
    { Fl_Button* o = aboutButton = new Fl_Button(90, 505, 70, 20, "About"); 
      o->callback((Fl_Callback*)cb_aboutButton); 
    } 
    o->end(); 
  } 
  { Fl_Window* o = aboutWindow = new Fl_Window(268, 160, "About TreeGen"); 
    w = o; 
    o->user_data((void*)(this)); 
    { Fl_Return_Button* o = okButton = new Fl_Return_Button(155, 123, 100, 25, "OK"); 
      o->callback((Fl_Callback*)cb_okButton); 
    } 
    { Fl_Box* o = new Fl_Box(15, 13, 240, 25, "TreeGen v1.0\n"); 
      o->box(FL_FLAT_BOX); 
      o->selection_color(47); 
      o->labelsize(16); 
    } 
    { Fl_Box* o = new Fl_Box(10, 123, 145, 25, "Released: June 26, 2001"); 
      o->labelsize(12); 
    } 
    { Fl_Output* o = alexEmail = new Fl_Output(49, 61, 195, 25); 
      o->box(FL_FLAT_BOX); 
      o->color(49); 
    } 
    { Fl_Output* o = fusionURL = new Fl_Output(52, 86, 190, 25); 
      o->box(FL_FLAT_BOX); 
      o->color(49); 
    } 
    { Fl_Box* o = new Fl_Box(15, 38, 240, 20, "by Alex\n"); 
      o->box(FL_FLAT_BOX); 
      o->selection_color(47); 
    } 
    o->end(); 
  } 
} 
 
void UI::show() { 
  toggleTex->set();     // select this button 
  polyDwgMode->clear(); // don't select this button 
  projMode->clear();    // don't select this button 
  worldAxis->clear();   // don't select this button 
  togDisplayList->clear(); // don't select this button 
  cylPrim->setonly(); // select only this button in the group 
  mainWindow->show(); // show gui 
  ogl_window->show(); // show ogl window 
 
  // init the about box 
  // (I wish I could make these into links) 
  alexEmail->value("alex@FusionIndustries.com"); 
  fusionURL->value("www.FusionIndustries.com"); 
} 
 
void UI::resetUI() { 
  if( fl_ask( "Are you sure you want to reset the scene?" ) ) 
{ 
  zoom->value(1); 
  recursion->value( 5 ); 
 
  //linePrim->clear(); 
  //planePrim->clear();  
  cylPrim->setonly(); // only select this button in the group 
  //sphPrim->clear(); 
 
  levelOfDetail->value( 5 ); 
  spread->value( 25 ); 
  twist->value( 180 ); 
  branchPerLev->value( 2 ); 
 
  toggleLeaves->clear(); 
 
  toggleTex->set(); 
  polyDwgMode->clear(); 
  projMode->clear(); 
  worldAxis->clear(); 
  togDisplayList->clear(); 
 
  ogl_window->resetScene(); 
} 
}