]> Creatis software - creaContours.git/blob - lib/Interface_Icons_NDimensions/interfToolsMenu.cxx
Compiling under windows and linux
[creaContours.git] / lib / Interface_Icons_NDimensions / interfToolsMenu.cxx
1 #include "interfToolsMenu.h"
2 #include "interfMainPanel.h"
3
4 interfToolsMenu::interfToolsMenu(wxWindow * parent, int sizex, int sizey,wxEvtHandler* evtHandler, std::string datdir)
5         : interfMenuBar(parent, sizex, sizey)
6 {
7         this->datadir = datdir;
8         contourevent = (wxContourEventHandler*)evtHandler;
9         infoWin = NULL;
10         configPanel = NULL;
11         segmentPanel = NULL;
12         spreadPanel = NULL;
13         segmentPanelITK = NULL;
14         
15         eventHandler = evtHandler;
16
17         initButtons(this);
18 }
19
20 void interfToolsMenu::initButtons(wxEvtHandler* evtHandler) {
21
22         std::vector<std::string> path, nom;
23         std::vector<wxObjectEventFunction> funct;
24
25         path.push_back(datadir + "/Spread.png");
26         nom.push_back("The selected contour will spread through all slides");
27         funct.push_back((wxObjectEventFunction) &interfMenuBar:: onActionButtonPressed);
28
29         path.push_back(datadir + "/Spread1.png");
30         nom.push_back("Select more than one contour and find the contours between them");
31         funct.push_back((wxObjectEventFunction) &interfToolsMenu:: onSpreadPressed);
32
33         
34         path.push_back(datadir + "/info.png");
35         nom.push_back("Information of the contours in the scene");
36         funct.push_back((wxObjectEventFunction) &interfToolsMenu:: onInformationPressed);
37
38         path.push_back(datadir + "/pignon.png");
39         nom.push_back("Configuration of the window");
40         funct.push_back((wxObjectEventFunction) &interfToolsMenu:: onConfigurationPressed);
41
42         this->addButtons(path, nom);    
43         this->setVectorFunction(funct);
44
45         this->setButtonName(0, wxContour_ActionCommandsID::CHANGE_TOOL);
46
47         this->connectEvents(evtHandler);
48            
49
50 }
51
52 interfToolsMenu::~interfToolsMenu()
53 {
54 }
55
56 /**
57         **      Responds to the events of the buttons, when the same panel is responsible for it. It gets the name
58         **      of the button corresponding to the method that has to be executed,
59         **      it uses attribute eventHandler to call the methods define by the application.
60         **      see setEventHandler(wxEventHandler*)
61         **/
62 void interfToolsMenu::onRigidPressed(wxCommandEvent& event){
63         
64 }
65
66 void  interfToolsMenu::onSpreadPressed(wxCommandEvent& event){
67
68
69         if(spreadPanel==NULL){
70
71                 spreadPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
72                 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);    
73                 spreadPanel->SetSizer(flexsizer, true);
74                 spreadPanel->SetAutoLayout( true );     
75                 spreadPanel->SetEventHandler(this->contourevent);
76                 
77                 wxPanel* panel = contourevent->getSpreadPanel(spreadPanel);
78         
79
80                 wxStaticText* stattext = new wxStaticText(spreadPanel, -1, wxString(_T("   Automatic Spread   ")), wxDefaultPosition,
81                         wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
82
83                 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
84                 flexsizer->Add(panel, wxEXPAND);
85                 spreadPanel->Layout();
86         }       
87         interfMainPanel::getInstance()->showPanel(spreadPanel);
88         hideAxis();
89 }
90
91
92 void  interfToolsMenu::onInformationPressed(wxCommandEvent& event){
93
94         if(infoWin ==NULL){
95                 infoWin                                         = new wxFrame (interfMainPanel::getInstance()->getInfoPanel(), -1,_T("  Spread  "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION |  wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER  );
96                 infoWin->SetSize( wxSize(500,450) );
97                 
98                 wxSize sizepanel(200,300);
99                 wxPanel *panel                                                                  = contourevent->getInformationPanel(infoWin);
100
101                 wxBoxSizer * sizerPanel         = new wxBoxSizer(wxHORIZONTAL);
102                 sizerPanel -> Add( panel->GetSizer()            , 1, wxEXPAND ,0);
103
104                 infoWin->SetSizer( sizerPanel );
105                 infoWin->SetAutoLayout( true );
106                 infoWin->Layout();
107
108                 infoWin->Show();                
109
110         }else {
111
112                 if (infoWin->IsShown()==true)
113                 {
114                         infoWin->Show(false);
115                 } else  {
116                         contourevent->FillGridWithContoursInformation();
117                         infoWin->Show(true);
118                 }
119         }       
120 }
121
122 void  interfToolsMenu::onConfigurationPressed(wxCommandEvent& event){
123
124         if(configPanel == NULL){
125                 configPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
126                 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);    
127                 configPanel->SetSizer(flexsizer, true);
128                 configPanel->SetAutoLayout( true );     
129                 configPanel->SetEventHandler(this->contourevent);
130                 
131                 wxPanel* panel = contourevent->getConfigurationPanel(configPanel);
132
133                 wxStaticText* stattext = new wxStaticText(configPanel, -1, wxString(_T("   Interface Configuration   ")), wxDefaultPosition,
134                         wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
135
136                 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
137
138                 flexsizer->Add(panel, wxEXPAND);
139                 configPanel->Layout();
140
141         }
142         interfMainPanel::getInstance()->showPanel(configPanel);
143
144         hideAxis();
145 }
146
147 void interfToolsMenu::hideAxis(){
148         if(axisshown){
149                 axisshown = false;
150                 contourevent->showAxis(axisshown);
151         }
152 }