NIREP
|
00001 // For compilers that support precompilation, includes "wx/wx.h". 00002 #include "wx/wxprec.h" 00003 00004 #ifdef __BORLANDC__ 00005 #pragma hdrstop 00006 #endif 00007 00008 #ifndef WX_PRECOMP 00009 #include "wx/wx.h" 00010 #endif 00011 00012 00013 #include "ObjectmapForm.h" 00014 #include "Panel.h" 00015 00016 00017 00022 IMPLEMENT_CLASS( ObjectmapForm, wxFrame ) 00023 00024 00025 00029 BEGIN_EVENT_TABLE( ObjectmapForm, wxFrame ) 00030 00031 EVT_CHOICE(ID_OBJECT_CHOICE, ObjectmapForm::ChangeChoice) 00032 EVT_RADIOBOX(ID_RADIOBOX, ObjectmapForm::EnableOrDisableObjectMapFromRadioButton) 00033 00034 00035 END_EVENT_TABLE() 00036 00037 00042 ObjectmapForm::ObjectmapForm() 00043 { 00044 Init(); 00045 } 00046 00047 ObjectmapForm::ObjectmapForm( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) 00048 { 00049 Init(); 00050 Create( parent, id, caption, pos, size, style ); 00051 } 00052 00053 00058 bool ObjectmapForm::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) 00059 { 00060 wxFrame::Create( parent, id, caption, pos, size, style ); 00061 panel = (Panel*)parent; 00062 CreateControls(); 00063 Centre(); 00064 return true; 00065 } 00066 00067 00072 ObjectmapForm::~ObjectmapForm() 00073 { 00074 } 00075 00076 00081 void ObjectmapForm::Init() 00082 { 00083 } 00084 00085 00089 //The main function that actually creates this window. 00090 //This will add in the sizers, the buttons, the drop down 00091 //lists, the radio buttons, and static text. 00092 00093 void ObjectmapForm::CreateControls() 00094 { 00095 ObjectmapForm* window = this; 00096 00097 wxFlexGridSizer* windowFlexGridSizer = new wxFlexGridSizer(1, 2, 0, 0); 00098 windowFlexGridSizer->AddGrowableRow(0); 00099 windowFlexGridSizer->AddGrowableCol(0); 00100 window->SetSizer(windowFlexGridSizer); 00101 00102 wxNotebook* notebook = new wxNotebook( window, ID_NOTEBOOK, wxDefaultPosition, wxDefaultSize, wxBK_DEFAULT ); 00103 00104 wxPanel* objectPanel = new wxPanel( notebook, ID_Object, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL ); 00105 wxFlexGridSizer* objectSizer = new wxFlexGridSizer(2); 00106 objectPanel->SetSizer(objectSizer); 00107 00108 wxStaticText* objectTitleStaticText = new wxStaticText( objectPanel, wxID_STATIC, _("Object:"), wxDefaultPosition, wxDefaultSize, 0 ); 00109 objectSizer->Add(objectTitleStaticText, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); 00110 00111 00112 for(int i=0; i < panel->GetObjectEntries()->size(); i++) 00113 { 00114 std::string objectEntryName = panel->GetObjectEntries()->at(i)->GetName(); 00115 Objects.Add(wxString(objectEntryName.c_str(), wxConvUTF8)); 00116 } 00117 ObjectChoice = new wxChoice( objectPanel, ID_OBJECT_CHOICE, wxDefaultPosition, wxDefaultSize, Objects, 0 ); 00118 ObjectChoice->SetSelection(0); 00119 objectSizer->Add(ObjectChoice, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); 00120 00121 wxStaticText* displayTitleStaticText = new wxStaticText( objectPanel, wxID_STATIC, _("Display"), wxDefaultPosition, wxDefaultSize, 0 ); 00122 objectSizer->Add(displayTitleStaticText, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); 00123 00124 wxArrayString displayRadioBoxStrings; 00125 displayRadioBoxStrings.Add(_("&Off")); 00126 displayRadioBoxStrings.Add(_("&On")); 00127 ObjectChoiceRadioBox = new wxRadioBox( objectPanel, ID_RADIOBOX, _T(""), wxDefaultPosition, wxDefaultSize, displayRadioBoxStrings, 1, wxRA_SPECIFY_ROWS ); 00128 ObjectChoiceRadioBox->SetSelection(panel->GetObjectEntries()->at(0)->GetDisplayFlag()); 00129 00130 objectSizer->Add(ObjectChoiceRadioBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); 00131 00132 00133 wxStaticText* nameStaticText = new wxStaticText( objectPanel, wxID_STATIC, _("Name"), wxDefaultPosition, wxDefaultSize, 0 ); 00134 objectSizer->Add(nameStaticText, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); 00135 00136 ObjectName = new wxTextCtrl( objectPanel, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); 00137 std::string name = panel->GetObjectEntries()->at(0)->GetName(); 00138 ObjectName->SetValue(wxString(name.c_str(), wxConvUTF8)); 00139 objectSizer->Add(ObjectName, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); 00140 00141 wxStaticText* colorStaticText = new wxStaticText( objectPanel, wxID_STATIC, _("Color"), wxDefaultPosition, wxDefaultSize, 0 ); 00142 objectSizer->Add(colorStaticText, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); 00143 00144 ObjectColor = new wxColourPickerCtrl( objectPanel, ID_COLOURCTRL, wxColour(), wxDefaultPosition, wxDefaultSize, wxCLRP_DEFAULT_STYLE ); 00145 wxColour *objectEntryColor = new wxColour(); 00146 objectEntryColor->Set(panel->GetObjectEntries()->at(0)->GetEndRed(),panel->GetObjectEntries()->at(0)->GetEndGreen(),panel->GetObjectEntries()->at(0)->GetEndBlue(),panel->GetObjectEntries()->at(0)->GetOpacity()); 00147 ObjectColor->SetColour(*objectEntryColor); 00148 objectSizer->Add(ObjectColor, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); 00149 00150 wxStaticText* itemStaticText14 = new wxStaticText( objectPanel, wxID_STATIC, _("Shades"), wxDefaultPosition, wxDefaultSize, 0 ); 00151 objectSizer->Add(itemStaticText14, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); 00152 00153 ObjectShade = new wxTextCtrl( objectPanel, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); 00154 std::stringstream shadeValue; 00155 shadeValue << panel->GetObjectEntries()->at(0)->GetShades(); 00156 ObjectShade->SetValue(wxString( shadeValue.str().c_str(), wxConvUTF8 )); 00157 objectSizer->Add(ObjectShade, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); 00158 00159 notebook->AddPage(objectPanel, _("Object")); 00160 00161 wxChoicebook* itemChoicebook16 = new wxChoicebook( notebook, ID_Attribute, wxDefaultPosition, wxDefaultSize, wxBK_DEFAULT ); 00162 00163 //This is going to be the fun part. Have to call the panel, and get the object map entries and display 00164 //the information. I am also going to have to do dynamic event handling because the 00165 //number of entries is not constant. 00166 00167 //Will need to do something like: 00168 //this->Connect( id, event, wxCommandEventHandler(ObjectmapForm::someFunction) ); 00169 //for the dynamic event handleing 00170 wxScrolledWindow* itemScrolledWindow17 = new wxScrolledWindow( itemChoicebook16, ID_Display, wxDefaultPosition, wxSize(100, 100), wxSUNKEN_BORDER|wxHSCROLL|wxVSCROLL ); 00171 itemScrolledWindow17->SetScrollbars(1, 1, 0, 0); 00172 wxFlexGridSizer* itemFlexGridSizer18 = new wxFlexGridSizer(2); 00173 wxFlexGridSizer* itemFlexGridSizer32 = new wxFlexGridSizer(2); 00174 wxFlexGridSizer* itemFlexGridSizer44 = new wxFlexGridSizer(2); 00175 wxFlexGridSizer* itemFlexGridSizer56 = new wxFlexGridSizer(2); 00176 for(int i=0; i<panel->GetObjectEntries()->size();i++) 00177 { 00178 itemFlexGridSizer18->AddGrowableRow(i); 00179 itemFlexGridSizer32->AddGrowableRow(i); 00180 itemFlexGridSizer44->AddGrowableRow(i); 00181 itemFlexGridSizer56->AddGrowableRow(i); 00182 } 00183 itemFlexGridSizer18->AddGrowableCol(0); 00184 itemFlexGridSizer18->AddGrowableCol(1); 00185 itemScrolledWindow17->SetSizer(itemFlexGridSizer18); 00186 00187 for(int i=0; i<panel->GetObjectEntries()->size();i++) 00188 { 00189 std::string name = panel->GetObjectEntries()->at(i)->GetName(); 00190 wxStaticText* itemStaticText19 = new wxStaticText( itemScrolledWindow17, wxID_ANY, wxString(name.c_str(), wxConvUTF8), wxDefaultPosition, wxDefaultSize, 0 ); 00191 itemFlexGridSizer18->Add(itemStaticText19, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); 00192 00193 wxArrayString itemRadioBox20Strings; 00194 itemRadioBox20Strings.Add(_("&Off")); 00195 itemRadioBox20Strings.Add(_("&On")); 00196 wxRadioBox* itemRadioBox20 = new wxRadioBox( itemScrolledWindow17, wxID_ANY, _T(""), wxDefaultPosition, wxDefaultSize, itemRadioBox20Strings, 1, wxRA_SPECIFY_ROWS ); 00197 this->Connect( itemRadioBox20->GetId(), wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler(ObjectmapForm::EnableOrDisableObjectMap) ); 00198 IDToName.insert(make_pair(itemRadioBox20->GetId(), name)); 00199 itemRadioBox20->SetSelection(panel->GetObjectEntries()->at(i)->GetDisplayFlag()); 00200 itemFlexGridSizer18->Add(itemRadioBox20, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); 00201 } 00202 00203 itemScrolledWindow17->FitInside(); 00204 itemChoicebook16->AddPage(itemScrolledWindow17, _("Display")); 00205 00206 wxScrolledWindow* itemScrolledWindow31 = new wxScrolledWindow( itemChoicebook16, ID_Name, wxDefaultPosition, wxSize(100, 100), wxSUNKEN_BORDER|wxHSCROLL|wxVSCROLL ); 00207 itemScrolledWindow31->SetScrollbars(1, 1, 0, 0); 00208 00209 itemFlexGridSizer32->AddGrowableCol(0); 00210 itemFlexGridSizer32->AddGrowableCol(1); 00211 itemScrolledWindow31->SetSizer(itemFlexGridSizer32); 00212 00213 for(int i=0; i<panel->GetObjectEntries()->size();i++) 00214 { 00215 std::string number = "#"; 00216 std::stringstream out; 00217 out << i; 00218 number = number.append(out.str()); 00219 00220 00221 wxStaticText* itemStaticText33 = new wxStaticText( itemScrolledWindow31, wxID_ANY, wxString(number.c_str(), wxConvUTF8), wxDefaultPosition, wxDefaultSize, 0 ); 00222 itemFlexGridSizer32->Add(itemStaticText33, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); 00223 00224 std::string name = panel->GetObjectEntries()->at(i)->GetName(); 00225 wxTextCtrl* itemTextCtrl34 = new wxTextCtrl( itemScrolledWindow31, wxID_ANY, wxString(name.c_str(), wxConvUTF8), wxDefaultPosition, wxDefaultSize, 0 ); 00226 itemFlexGridSizer32->Add(itemTextCtrl34, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); 00227 } 00228 00229 itemScrolledWindow31->FitInside(); 00230 itemChoicebook16->AddPage(itemScrolledWindow31, _("Name")); 00231 00232 wxScrolledWindow* itemScrolledWindow43 = new wxScrolledWindow( itemChoicebook16, ID_Color, wxDefaultPosition, wxSize(100, 100), wxSUNKEN_BORDER|wxHSCROLL|wxVSCROLL ); 00233 itemScrolledWindow43->SetScrollbars(1, 1, 0, 0); 00234 00235 itemFlexGridSizer44->AddGrowableCol(0); 00236 itemFlexGridSizer44->AddGrowableCol(1); 00237 itemScrolledWindow43->SetSizer(itemFlexGridSizer44); 00238 00239 for(int i=0; i<panel->GetObjectEntries()->size();i++) 00240 { 00241 std::string name = panel->GetObjectEntries()->at(i)->GetName(); 00242 wxStaticText* itemStaticText45 = new wxStaticText( itemScrolledWindow43, wxID_STATIC, wxString(name.c_str(), wxConvUTF8), wxDefaultPosition, wxDefaultSize, 0 ); 00243 itemFlexGridSizer44->Add(itemStaticText45, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); 00244 00245 wxColourPickerCtrl* itemColourPickerCtrl46 = new wxColourPickerCtrl( itemScrolledWindow43, wxID_ANY, wxColour(), wxDefaultPosition, wxSize(500, 500), wxCLRP_DEFAULT_STYLE ); 00246 wxColour *objectEntryColor = new wxColour(); 00247 objectEntryColor->Set(panel->GetObjectEntries()->at(i)->GetEndRed(),panel->GetObjectEntries()->at(i)->GetEndGreen(),panel->GetObjectEntries()->at(i)->GetEndBlue(),panel->GetObjectEntries()->at(i)->GetOpacity()); 00248 itemColourPickerCtrl46->SetColour(*objectEntryColor); 00249 itemFlexGridSizer44->Add(itemColourPickerCtrl46, 1, wxGROW|wxGROW|wxALL, 5); 00250 } 00251 00252 itemScrolledWindow43->FitInside(); 00253 itemChoicebook16->AddPage(itemScrolledWindow43, _("Color")); 00254 00255 wxScrolledWindow* itemScrolledWindow55 = new wxScrolledWindow( itemChoicebook16, ID_Shades, wxDefaultPosition, wxSize(100, 100), wxSUNKEN_BORDER|wxHSCROLL|wxVSCROLL ); 00256 itemScrolledWindow55->SetScrollbars(1, 1, 0, 0); 00257 00258 itemFlexGridSizer56->AddGrowableCol(0); 00259 itemFlexGridSizer56->AddGrowableCol(1); 00260 itemScrolledWindow55->SetSizer(itemFlexGridSizer56); 00261 00262 for(int i=0; i<panel->GetObjectEntries()->size();i++) 00263 { 00264 std::string name = panel->GetObjectEntries()->at(i)->GetName(); 00265 wxStaticText* itemStaticText57 = new wxStaticText( itemScrolledWindow55, wxID_ANY, wxString(name.c_str(), wxConvUTF8), wxDefaultPosition, wxDefaultSize, 0 ); 00266 itemFlexGridSizer56->Add(itemStaticText57, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); 00267 00268 std::string s; 00269 std::stringstream out; 00270 out << panel->GetObjectEntries()->at(i)->GetShades(); 00271 s = out.str(); 00272 00273 wxTextCtrl* itemTextCtrl58 = new wxTextCtrl( itemScrolledWindow55, wxID_ANY, wxString(s.c_str(), wxConvUTF8), wxDefaultPosition, wxDefaultSize, 0 ); 00274 itemFlexGridSizer56->Add(itemTextCtrl58, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); 00275 } 00276 00277 00278 itemScrolledWindow55->FitInside(); 00279 itemChoicebook16->AddPage(itemScrolledWindow55, _("Shades")); 00280 00281 notebook->AddPage(itemChoicebook16, _("Attribute")); 00282 00283 windowFlexGridSizer->Add(notebook, 0, wxGROW|wxGROW|wxLEFT, 0); 00284 00285 } 00286 00287 00292 bool ObjectmapForm::ShowToolTips() 00293 { 00294 return true; 00295 } 00296 00301 wxBitmap ObjectmapForm::GetBitmapResource( const wxString& name ) 00302 { 00303 // Bitmap retrieval 00304 wxUnusedVar(name); 00305 return wxNullBitmap; 00306 } 00307 00312 wxIcon ObjectmapForm::GetIconResource( const wxString& name ) 00313 { 00314 // Icon retrieval 00315 wxUnusedVar(name); 00316 return wxNullIcon; 00317 } 00318 00319 //This is the choice from the drop down list when the user is in the mode of objects and 00320 //not attributes. So the user can change the object and this function will 00321 //update the form to reflect the properties of that object. 00322 void ObjectmapForm::ChangeChoice(wxCommandEvent &event) 00323 { 00324 int selection = event.GetSelection(); 00325 //Call the panel, get the object entry that is being 00326 //asked for and fill in the respective fields with 00327 //the information from the object entry. 00328 00329 ObjectChoiceRadioBox->SetSelection(panel->GetObjectEntries()->at(selection)->GetDisplayFlag()); 00330 00331 std::string name = panel->GetObjectEntries()->at(selection)->GetName(); 00332 ObjectName->SetValue(wxString(name.c_str(), wxConvUTF8)); 00333 00334 wxColour *objectEntryColor = new wxColour(); 00335 objectEntryColor->Set(panel->GetObjectEntries()->at(selection)->GetEndRed(),panel->GetObjectEntries()->at(selection)->GetEndGreen(),panel->GetObjectEntries()->at(selection)->GetEndBlue(),panel->GetObjectEntries()->at(selection)->GetOpacity()); 00336 ObjectColor->SetColour(*objectEntryColor); 00337 00338 std::string s; 00339 std::stringstream out; 00340 out << panel->GetObjectEntries()->at(selection)->GetShades(); 00341 s = out.str(); 00342 ObjectShade->SetValue(wxString(s.c_str(), wxConvUTF8)); 00343 } 00344 00345 //This is the choice from the radio button when the user is in the mode of objects and 00346 //not attributes. 00347 void ObjectmapForm::EnableOrDisableObjectMapFromRadioButton( wxCommandEvent& event ) 00348 { 00349 00350 int choice = ObjectChoice->GetSelection(); 00351 vtkLookupTable *pop= panel->GetLookUpTable(); 00352 double *rgbs = pop->GetTableValue(choice); 00353 if(ObjectChoiceRadioBox->GetSelection()) 00354 { 00355 pop->SetTableValue(choice,rgbs[0],rgbs[1], rgbs[2],1); 00356 panel->GetObjectEntries()->at(choice)->SetDisplayFlag(1); 00357 } 00358 else 00359 { 00360 pop->SetTableValue(choice,rgbs[0],rgbs[1], rgbs[2],0); 00361 panel->GetObjectEntries()->at(choice)->SetDisplayFlag(0); 00362 } 00363 panel->SetLookUpTable(pop); 00364 panel->BlendImages(); 00365 panel->Render(); 00366 } 00367 00368 00369 //This is the choice from the radio button when the user is in the mode of attributes and 00370 //not objects. This will be dynamically added to the event table. 00371 void ObjectmapForm::EnableOrDisableObjectMap( wxCommandEvent& event ) 00372 { 00373 00374 std::string choice = IDToName.find(event.GetId())->second; 00375 vtkLookupTable *pop= panel->GetLookUpTable(); 00376 for(int i=0;i<panel->GetObjectEntries()->size();i++) 00377 { 00378 if(!choice.compare(panel->GetObjectEntries()->at(i)->GetName())) 00379 { 00380 double *rgbs = pop->GetTableValue(i); 00381 if(event.IsChecked()) 00382 { 00383 pop->SetTableValue(i,rgbs[0],rgbs[1], rgbs[2],1); 00384 panel->GetObjectEntries()->at(i)->SetDisplayFlag(1); 00385 } 00386 else 00387 { 00388 pop->SetTableValue(i,rgbs[0],rgbs[1], rgbs[2],0); 00389 panel->GetObjectEntries()->at(i)->SetDisplayFlag(0); 00390 } 00391 00392 panel->BlendImages(); 00393 panel->Render(); 00394 return; 00395 } 00396 } 00397 00398 00399 }