]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/CutModule/interface/CutModelMainPanel.cxx
Code cleaning done
[creaMaracasVisu.git] / lib / maracasVisuLib / src / CutModule / interface / CutModelMainPanel.cxx
index a0622b4176268099f622771cdc72a894a57e2964..c1a3dfd8e8aa83747bc67e0b76d5f8854a22ea96 100644 (file)
@@ -1,10 +1,35 @@
+/*# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+#                        pour la Sant�)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+# Previous Authors : Laurent Guigues, Jean-Pierre Roux
+# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+#
+#  This software is governed by the CeCILL-B license under French law and
+#  abiding by the rules of distribution of free software. You can  use,
+#  modify and/ or redistribute the software under the terms of the CeCILL-B
+#  license as circulated by CEA, CNRS and INRIA at the following URL
+#  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+#  or in the file LICENSE.txt.
+#
+#  As a counterpart to the access to the source code and  rights to copy,
+#  modify and redistribute granted by the license, users are provided only
+#  with a limited warranty  and the software's author,  the holder of the
+#  economic rights,  and the successive licensors  have only  limited
+#  liability.
+#
+#  The fact that you are presently reading this means that you have had
+#  knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------ */
+
 /*=========================================================================
 
 Program:   wxMaracas
 Module:    $RCSfile: CutModelMainPanel.cxx,v $
 Language:  C++
-Date:      $Date: 2010/02/24 13:56:06 $
-Version:   $Revision: 1.6 $
+Date:      $Date: 2012/11/15 14:16:20 $
+Version:   $Revision: 1.14 $
 
 Copyright: (c) 2002, 2003
 License:
@@ -26,10 +51,10 @@ PURPOSE.  See the above copyright notice for more information.
 #include <wx/colordlg.h>
 #include <wx/bmpbuttn.h>
 
-#include <Add.xpm>
-#include <Undo.xpm>
-#include <Redo.xpm>
-#include <OkAll.xpm>
+#include "Add.xpm"
+#include "Undo.xpm"
+#include "Redo.xpm"
+#include "OkAll.xpm"
 
 
 
@@ -44,7 +69,7 @@ CutModelMainPanel::CutModelMainPanel( wxWindow* parent, std::string path)
        initialize(path);
 
 }
-CutModelMainPanel::~CutModelMainPanel( ){      
+CutModelMainPanel::~CutModelMainPanel( ){
        viewpanels.clear();
        delete cutmanager;
 }
@@ -52,16 +77,16 @@ CutModelMainPanel::~CutModelMainPanel( ){
 void CutModelMainPanel::initialize(std::string path){
        cutmanager = new CutModelManager(path);
        _panelid = 0;
-       _wxauimanager = new wxAuiManager(this); 
+       _wxauimanager = new wxAuiManager(this);
 
        wxAuiPaneInfo paneinfo;
 
        //RaC 5-02-2010 Add tabs
        _notebook = new wxAuiNotebook(this,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxAUI_NB_TOP |wxAUI_NB_TAB_MOVE | wxAUI_NB_SCROLL_BUTTONS);
 
-       _notebook->AddPage(new ToolBarCutModel(_notebook),"Cutter",true);
-       //_wxauimanager->AddPane(new ToolBarCutModel(this),paneinfo.ToolbarPane().Top());       
-       _wxauimanager->AddPane(_notebook,paneinfo.Center());
+       _notebook->AddPage(new ToolBarCutModel(_notebook),_T("Cutter"),true);
+       //_wxauimanager->AddPane(new ToolBarCutModel(this),paneinfo.ToolbarPane().Top());
+       _wxauimanager->AddPane(_notebook,paneinfo.Center().CloseButton(false));
        addPolygonCutterTab();
        _notebook->Update();
 
@@ -113,10 +138,10 @@ void CutModelMainPanel::setRenderer(vtkRenderer* renderer){
 void CutModelMainPanel::checkInvariant()throw (CutModelException){
        if(cutmanager==NULL){
                throw CutModelException("The manager is not initialize");
-       }       
+       }
 }
 
-void CutModelMainPanel::showErrorDialog(std::string str){      
+void CutModelMainPanel::showErrorDialog(std::string str){
        wxMessageDialog* diag = new wxMessageDialog(this, wxString(str.c_str(),wxConvUTF8 ), wxString(str.c_str(),wxConvUTF8 ), wxICON_ERROR);
        diag->ShowModal();
 }
@@ -126,10 +151,11 @@ void CutModelMainPanel::RemoveActor(int id){
                checkInvariant();
 
                if(!this->IsBeingDeleted()){
-                       for(int i = 0; i < viewpanels.size()-1;i++){
+                       int i,j;
+                       for(i = 0; i < (int)viewpanels.size()-1;i++){
                                CutModelView* view = viewpanels[i];
                                if(view->getId()==id){
-                                       for(int j = i; j < viewpanels.size()-1;j++){
+                                       for(j = i; j < (int)viewpanels.size()-1;j++){
                                                viewpanels[j]=viewpanels[j+1];
                                        }
                                        i = viewpanels.size();
@@ -137,7 +163,7 @@ void CutModelMainPanel::RemoveActor(int id){
                        }
                        viewpanels.pop_back();
                        cutmanager->RemoveActor(id);
-               }       
+               }
 
        }catch(CutModelException e){
                showErrorDialog(e.getCause());
@@ -153,7 +179,7 @@ void CutModelMainPanel::onCheckChanged(){
        }
 
        if(_isCheck==false)
-       {       
+       {
                _isCheck=true;
                //Draw Polygon
 
@@ -161,10 +187,10 @@ void CutModelMainPanel::onCheckChanged(){
                btnExecutePolygonCut->Enable(false);
                _notebook->GetPage(0)->Enable(false);
                _radioinsideout->Enable(false);
-               lblMessagePolygon->SetLabel("Drawing polygon...");
+               lblMessagePolygon->SetLabel(_T("Drawing polygon..."));
        }
        else
-       {       
+       {
                _isCheck=false;
                //Finish Drawing
                cout<<"Finish Drawing"<<endl;
@@ -172,7 +198,7 @@ void CutModelMainPanel::onCheckChanged(){
                btnExecutePolygonCut->Enable(true);
                _notebook->GetPage(0)->Enable(true);
                _radioinsideout->Enable(true);
-               lblMessagePolygon->SetLabel("Contour saved! Click on Execute Cut");
+               lblMessagePolygon->SetLabel(_T("Contour saved! Click on Execute Cut"));
        }
 
        cutmanager->UpdatePolygon(_isCheck);
@@ -181,11 +207,11 @@ void CutModelMainPanel::onCheckChanged(){
 
 
 //RaC
-void CutModelMainPanel::onExecuteCutPolygon(){
+void CutModelMainPanel::onExecuteCutPolygon()
+{
        //Cuts Polygon
        cutmanager->ExecuteCutPolygon(_radioinsideout->GetSelection());
-       lblMessagePolygon->SetLabel("No contour drawed");
-
+       lblMessagePolygon->SetLabel(_T("No contour drawed"));
 }
 
 
@@ -193,7 +219,7 @@ void CutModelMainPanel::onAddCutModel(){
        try{
                checkInvariant();
 
-               int id = addNewViewPanel();             
+               int id = addNewViewPanel();
                cutmanager->onAddCutModel(id, getModelView(id));
 
                _panelid++;
@@ -204,8 +230,11 @@ void CutModelMainPanel::onAddCutModel(){
                showErrorDialog(e.getCause());
        }
 }
-void CutModelMainPanel::ShowCurrentPanel(int id){
-       for(int i = 0; i < viewpanels.size();i++){              
+
+void CutModelMainPanel::ShowCurrentPanel(int id)
+{
+        int i;
+       for(i = 0; i < (int) viewpanels.size();i++){
                if(viewpanels[i]->getId()==id){
                        _wxauimanager->GetPane(viewpanels[i]).Show(true);
                        cutmanager->RefreshActor(id);
@@ -220,55 +249,58 @@ int CutModelMainPanel::addNewViewPanel()throw( CutModelException){
        CutModelView* viewpanel = new CutModelView(this,cutmanager->getImageRange());
 
        wxAuiPaneInfo paneinfo0;
-       _wxauimanager->AddPane(viewpanel, paneinfo0.DefaultPane().DestroyOnClose().Centre());   
+       _wxauimanager->AddPane(viewpanel, paneinfo0.DefaultPane().DestroyOnClose().Centre().Bottom());
 
        viewpanel->setId(_panelid);
-       viewpanels.push_back(viewpanel);        
+       viewpanels.push_back(viewpanel);
 
        return viewpanel->getId();
 
 
 }
-CutModelView* CutModelMainPanel::getModelView(int id)throw( CutModelException){
-
+CutModelView* CutModelMainPanel::getModelView(int id)throw( CutModelException)
+{
        CutModelView* current = NULL;
-       for(int i = 0; i < viewpanels.size();i++){
-               if(viewpanels[i]->getId()==id){
+       int i;
+       for(i = 0; i < (int)viewpanels.size();i++)
+       {
+               if(viewpanels[i]->getId()==id)
+               {
                        current = viewpanels[i];
                }
        }
-       if(current == NULL){
+       if(current == NULL)
+       {
                std::string s = "Id not found";
                throw CutModelException(s);
        }
        return current;
 }
-void CutModelMainPanel::onUndo(){
+
+void CutModelMainPanel::onUndo()
+       {
        try{
-               checkInvariant();               
-               int result = cutmanager->Undo();
+               checkInvariant();
+               /*int result = */ cutmanager->Undo(); // result unused// JPR
 
        }catch(CutModelException e){
                showErrorDialog(e.getCause());
        }
-
 }
 
 void CutModelMainPanel::onRedo(){
-
        try{
-               checkInvariant();               
-               int result = cutmanager->Redo();
+               checkInvariant();
+               /*int result = */ cutmanager->Redo();
 
        }catch(CutModelException e){
                showErrorDialog(e.getCause());
        }
-
 }
 
 void CutModelMainPanel::changeOpacity(int id,int opacity){
        try{
-               checkInvariant();               
+               checkInvariant();
                cutmanager->changeOpacity(id, opacity);
 
        }catch(CutModelException e){
@@ -278,27 +310,29 @@ void CutModelMainPanel::changeOpacity(int id,int opacity){
 
 void CutModelMainPanel::ShowViewBox(int id,bool check){
        try{
-               checkInvariant();               
+               checkInvariant();
                cutmanager->ShowViewBox(id, check);
 
        }catch(CutModelException e){
                showErrorDialog(e.getCause());
        }
 }
+
 void CutModelMainPanel::ShowPopUpMenu(int id){
        showErrorDialog("test");
 }
+
 void CutModelMainPanel::changeColor(int id,double r,double g,double b){
 
        try{
-               checkInvariant();               
+               checkInvariant();
                cutmanager->changeColor(id, r, g, b);
 
        }catch(CutModelException e){
                showErrorDialog(e.getCause());
        }
-
 }
+
 void CutModelMainPanel::ChangeShape(int id,int selection){
        try{
                checkInvariant();
@@ -322,7 +356,7 @@ void CutModelMainPanel::updateActorDirection(int id){
 
 void CutModelMainPanel::ExecuteCut(int id, double* range, bool isinside){
        try{
-               checkInvariant();               
+               checkInvariant();
 
                cutmanager->ExecuteCut(id, range, isinside);
        }catch(CutModelException e){
@@ -331,11 +365,12 @@ void CutModelMainPanel::ExecuteCut(int id, double* range, bool isinside){
 }
 
 void CutModelMainPanel::ExecuteAll(){
-       for(int i = 0; i < viewpanels.size(); i++){
+       int i;
+       for(i = 0; i < (int)viewpanels.size(); i++){
                viewpanels[i]->ExecuteCut();
        }
-
 }
+
 vtkImageData* CutModelMainPanel::GetResultImage(){
        try{
                checkInvariant();
@@ -377,16 +412,16 @@ int CutModelMainPanel::GetType(){
 void CutModelMainPanel::addPolygonCutterTab(){
        wxPanel *panel = new wxPanel(_notebook);
        panel->SetAutoLayout(true);
-       wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); 
+       wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
        panel->SetSizer(sizer);
        sizer->AddSpacer(20);
 
-       wxCheckBox *item = new wxCheckBox(panel,10,"Draw Polygon",wxDefaultPosition,wxDefaultSize,0,wxDefaultValidator,"");
+       wxCheckBox *item = new wxCheckBox(panel,10,_T("Draw Polygon"),wxDefaultPosition,wxDefaultSize,0,wxDefaultValidator,_T("") );
        item->SetValue(false);
        Connect(item->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)(&PolygonCutterEventHandlerCutModel::onCheckChanged));
        sizer->Add(item, 0, wxALIGN_LEFT);
 
-       lblMessagePolygon = new wxStaticText(panel,30,"No contour drawed",wxDefaultPosition,wxDefaultSize,0,"");
+       lblMessagePolygon = new wxStaticText(panel,30,_T("No contour drawed"),wxDefaultPosition,wxDefaultSize,0,_T("") );
        sizer->Add(lblMessagePolygon, 0, wxALIGN_LEFT);
 
        wxString choices0[2];
@@ -395,16 +430,13 @@ void CutModelMainPanel::addPolygonCutterTab(){
        _radioinsideout = new  wxRadioBox(panel,-1,_T(""), wxDefaultPosition, wxDefaultSize,2,choices0);
        sizer->Add(_radioinsideout, wxALIGN_LEFT);
 
-       btnExecutePolygonCut = new wxButton(panel,20,"Execute Cut",wxDefaultPosition,wxDefaultSize,0,wxDefaultValidator,"");
-       Connect(btnExecutePolygonCut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)(&PolygonCutterEventHandlerCutModel::onExecuteCutPolygon));  
+       btnExecutePolygonCut = new wxButton(panel,20,_T("Execute Cut"),wxDefaultPosition,wxDefaultSize,0,wxDefaultValidator,_T("") );
+       Connect(btnExecutePolygonCut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)(&PolygonCutterEventHandlerCutModel::onExecuteCutPolygon));
        sizer->Add(btnExecutePolygonCut, 0, wxALIGN_LEFT);
 
-
-       _notebook->AddPage(panel, "Polygon Cutter", false);
-
+       _notebook->AddPage(panel, _T("Polygon Cutter"), false);
 }
 
-
 void PolygonCutterEventHandlerCutModel::onCheckChanged(wxCommandEvent& event){
        CutModelMainPanel::getInstance()->onCheckChanged();
 }
@@ -413,8 +445,6 @@ void PolygonCutterEventHandlerCutModel::onExecuteCutPolygon(wxCommandEvent& even
        CutModelMainPanel::getInstance()->onExecuteCutPolygon();
 }
 
-
-
 /**
 **
 **/
@@ -430,18 +460,17 @@ ToolBarCutModel::ToolBarCutModel(wxWindow * parent)
        this->AddTool(20, wxString(_T("Undo")),bitmap20);
 
        wxBitmap bitmap30(Redo_xpm);
-       this->AddTool(30, wxString(_T("Redo")),bitmap30);       
+       this->AddTool(30, wxString(_T("Redo")),bitmap30);
 
        this->AddSeparator();
 
        wxBitmap bitmap40(OkAll_xpm);
-       this->AddTool(40, wxString(_T("Ok All")),bitmap40);     
+       this->AddTool(40, wxString(_T("Ok All")),bitmap40);
 
        this->Realize();
 
        _evthand = new ToolBarEventHandlerCutModel();
        this->SetEventHandler(_evthand);
-
 }
 
 ToolBarCutModel::~ToolBarCutModel(void){
@@ -458,7 +487,7 @@ void ToolBarEventHandlerCutModel::onAdd(wxCommandEvent& event){
 }
 
 void ToolBarEventHandlerCutModel::onUndo(wxCommandEvent& event){
-       CutModelMainPanel::getInstance()->onUndo();     
+       CutModelMainPanel::getInstance()->onUndo();
 }
 
 void ToolBarEventHandlerCutModel::onRedo(wxCommandEvent& event){
@@ -469,11 +498,9 @@ void ToolBarEventHandlerCutModel::onExecuteAll(wxCommandEvent& event){
        CutModelMainPanel::getInstance()->ExecuteAll();
 }
 
-
 BEGIN_EVENT_TABLE(ToolBarEventHandlerCutModel, wxEvtHandler)
        EVT_MENU(10, ToolBarEventHandlerCutModel::onAdd)
        EVT_MENU(20, ToolBarEventHandlerCutModel::onUndo)
        EVT_MENU(30, ToolBarEventHandlerCutModel::onRedo)
        EVT_MENU(40, ToolBarEventHandlerCutModel::onExecuteAll)
 END_EVENT_TABLE()
-