Main Page | Class Hierarchy | Class List | Directories | File List | Class Members

OptionPanel.cpp

00001 #include <glui.h>
00002 #include <glut.h>
00003 
00004 #include "LifeVariables.h"
00005 #include "OptionPanel.h"
00006 
00007 
00008 using namespace std;
00009 
00010 OptionPanel::OptionPanel(int mainWindowRef, int position) {
00011     this->selectedPlane = XY_PLANE;
00012     this->selectedSlice = 0;
00013     this->interpolationMode = NEAREST_SLICE;
00014     this->volumeInterpolationMode = NEAREST_VOLUME;
00015     this->viewingDirection = FRONT_VIEW;
00016     
00017     this->lightX = 1.0;
00018     this->lightY = 1.0;
00019     this->lightZ = 1.0;
00020    
00021     txFunction = 0;
00022     currLowerThreshold = 600;
00023    
00024     if((mainWindowRef==0)&&(position==0)) {
00025         panel = GLUI_Master.create_glui("Options...", 0,150,200);
00026     }
00027     else {
00028         panel = GLUI_Master.create_glui_subwindow(mainWindowRef, position);
00029         panel->set_main_gfx_window(mainWindowRef);
00030     }   
00031    
00032     slicingPanel = panel->add_panel("Slice Visualisation Options");
00033     slicingPanel->set_alignment(GLUI_ALIGN_LEFT);
00034      
00035     planeSelectorGroup = panel->add_radiogroup_to_panel(slicingPanel,
00036                                                        &selectedPlane,
00037                                                        PLANESELECT_ID,
00038                                                        eventListener);
00039                                                        
00040     panel->add_radiobutton_to_group(planeSelectorGroup, "XY Plane");
00041     panel->add_radiobutton_to_group(planeSelectorGroup, "XZ Plane");
00042     panel->add_radiobutton_to_group(planeSelectorGroup, "YZ Plane");
00043    
00044     panel->add_separator_to_panel(slicingPanel);
00045    
00046     sliceSpinnerPanel = 
00047         panel->add_panel_to_panel(slicingPanel, "", GLUI_PANEL_NONE);
00048    
00049     selectedSliceSpinner = 
00050         panel->add_spinner_to_panel(sliceSpinnerPanel, 
00051                                     "Slice",
00052                                     GLUI_SPINNER_INT,
00053                                     &selectedSlice,
00054                                     SLICESELECT_ID,
00055                                     eventListener);
00056    
00057     selectedSliceSpinner->set_int_limits(0,0,GLUI_LIMIT_WRAP);
00058    
00059     panel->add_separator_to_panel(slicingPanel);   
00060     interpolationSelectorGroup = panel->add_radiogroup_to_panel(slicingPanel,
00061                                                                 &interpolationMode,
00062                                                                 INTERPOLATIONSELECT_ID,
00063                                                                 eventListener);
00064                                                        
00065     panel->add_radiobutton_to_group(interpolationSelectorGroup, "Nearest Neighbour");
00066     panel->add_radiobutton_to_group(interpolationSelectorGroup, "Bilinear");
00067 
00068     switchModeBtn = panel->add_button("Switch Mode", MODESELECT_ID, eventListener);
00069     switchModeBtn->disable();
00070    
00071     volumePanel = panel->add_panel("Volume Visualisation Options");
00072     volumePanel->set_alignment(GLUI_ALIGN_LEFT);
00073    
00074 
00075     txFunctionSelectorGroup = panel->add_radiogroup_to_panel(volumePanel,
00076                                                              &txFunction,
00077                                                              TXFUNCTIONSELECT_ID,
00078                                                              eventListener);
00079 
00080     panel->add_radiobutton_to_group(txFunctionSelectorGroup, "First HIT");
00081     panel->add_radiobutton_to_group(txFunctionSelectorGroup, "X-Ray");
00082     panel->add_radiobutton_to_group(txFunctionSelectorGroup, "MIP");
00083     //panel->add_radiobutton_to_group(txFunctionSelectorGroup, "Compositing");
00084 
00085     thresholdSpinnerPanel = 
00086         panel->add_panel_to_panel(volumePanel, "First Hit Threshold", GLUI_PANEL_NONE);
00087         
00088     lowerThresholdSpinner = 
00089         panel->add_spinner_to_panel(thresholdSpinnerPanel, 
00090                                  "Threshold",
00091                                  GLUI_SPINNER_INT,
00092                                  &currLowerThreshold,
00093                                  SLICESELECT_ID,
00094                                  eventListener);
00095 
00096     volumeInterpolationSelectorGroup = panel->add_radiogroup_to_panel(volumePanel,
00097                                                                     &volumeInterpolationMode,
00098                                                                     VOLUMEINTERPOLATIONSELECT_ID,
00099                                                                     eventListener);
00100 
00101     panel->add_radiobutton_to_group(volumeInterpolationSelectorGroup, "Nearest Neighbour");
00102     panel->add_radiobutton_to_group(volumeInterpolationSelectorGroup, "Triliniear Interpolation");
00103 
00104     
00105     viewpointPanel = panel->add_panel_to_panel(volumePanel,"View...");
00106     viewpointGroup = panel->add_radiogroup_to_panel(viewpointPanel, 
00107                                                     &viewingDirection,
00108                                                     VIEWINGDIRECTION_ID,
00109                                                     eventListener);
00110 
00111    // panel->add_radiobutton_to_group(viewpointGroup, "Front");
00112     panel->add_radiobutton_to_group(viewpointGroup, "Front");
00113     panel->add_radiobutton_to_group(viewpointGroup, "Side");
00114     panel->add_radiobutton_to_group(viewpointGroup, "Top");
00115     panel->add_radiobutton_to_group(viewpointGroup, "A Pose");
00116    
00117     
00118     lightPositionPanel = panel->add_panel_to_panel(volumePanel, "Light Direction");
00119     lightXPosition = panel->add_edittext_to_panel(lightPositionPanel, "x",
00120                                                   GLUI_EDITTEXT_FLOAT,
00121                                                   &lightX);
00122     lightYPosition = panel->add_edittext_to_panel(lightPositionPanel, "y",
00123                                                   GLUI_EDITTEXT_FLOAT,
00124                                                   &lightY);
00125     lightZPosition = panel->add_edittext_to_panel(lightPositionPanel, "z",
00126                                                   GLUI_EDITTEXT_FLOAT,
00127                                                   &lightZ);
00128 
00129     lightXPosition->set_float_limits(-1.0, 1.0, GLUI_LIMIT_CLAMP);
00130     lightYPosition->set_float_limits(-1.0, 1.0, GLUI_LIMIT_CLAMP);
00131     lightZPosition->set_float_limits(-1.0, 1.0, GLUI_LIMIT_CLAMP);
00132 
00133 
00134     refreshBtn = panel->add_button_to_panel(volumePanel, "Refresh", REFRESH_ID, eventListener);
00135 
00136     panel->disable();
00137 }
00138 
00139 
00140 void OptionPanel::enable() {
00141     panel->enable();
00142 }   
00143 
00144 
00145 void OptionPanel::disable() {
00146     panel->disable();
00147 }
00148 
00149 void OptionPanel::enableModeSelection() {
00150     renderMode = SLICE_VISUALISATION;
00151     switchModeBtn->enable();
00152 }
00153 
00154 void OptionPanel::disableModeSelection() {
00155     renderMode = -1;
00156     switchModeBtn->disable();
00157 }
00158 
00159 
00160 void OptionPanel::switchRenderMode(int mode) {
00161     if(mode == SLICE_VISUALISATION) {
00162         volumePanel->disable();
00163         slicingPanel->enable();
00164     }
00165     else if(mode == VOLUME_VISUALISATION) {
00166         slicingPanel->disable();
00167         volumePanel->enable();        
00168     }
00169     else {
00170         slicingPanel->disable();
00171         volumePanel->disable();
00172     }
00173 }
00174 
00175 
00176 void OptionPanel::updateSliceMax(int valX, int valY, int valZ) {
00177     switch(optionPanel->selectedPlane) {
00178         case 0: 
00179             selectedSliceSpinner->set_int_limits(0, valZ, GLUI_LIMIT_WRAP);    
00180             break;
00181         case 1: 
00182             selectedSliceSpinner->set_int_limits(0, valX, GLUI_LIMIT_WRAP);    
00183             break;
00184         case 2:
00185             selectedSliceSpinner->set_int_limits(0, valY, GLUI_LIMIT_WRAP);
00186             break;
00187     }
00188     selectedSliceSpinner->set_int_val(0);
00189 }
00190 
00191 
00192 void OptionPanel::incSlice() {
00193     selectedSlice = selectedSlice + 1;
00194     selectedSliceSpinner->set_int_val(selectedSlice);
00195 }
00196 
00197 
00198 void OptionPanel::decSlice() {
00199     selectedSlice = selectedSlice - 1;
00200     selectedSliceSpinner->set_int_val(selectedSlice);
00201 }
00202 
00203 void OptionPanel::disableMipSpinners() {
00204     thresholdSpinnerPanel->disable();  
00205 }
00206 
00207 void OptionPanel::enableMipSpinners() {
00208     thresholdSpinnerPanel->enable();  
00209 }

Generated on Mon Dec 12 15:20:26 2005 for CCube by  doxygen 1.4.1