]> Creatis software - creaContours.git/blobdiff - lib/Interface_ManagerContour_NDimensions/wxConceptControl.cxx
#3320creaContours Bug NewNormal - Segmentation PolyData Cells
[creaContours.git] / lib / Interface_ManagerContour_NDimensions / wxConceptControl.cxx
index 833c04731c50577106b7ddc1d11d81ab61a1cb10..a205f95a1bccf7d77466cdbc0c30a273bd8b8597 100644 (file)
@@ -1,3 +1,28 @@
+/*# ---------------------------------------------------------------------
+#
+# 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.
+# ------------------------------------------------------------------------ */
+
 
 //----------------------------------------------------------------------------------------------------------------
 // Class definition include
@@ -20,37 +45,35 @@ DEFINE_EVENT_TYPE( wxEVT_CONCEPT_RELEASE )
        // Constructors & Destructors
        //------------------------------------------------------------------------------------------------------------
        
-       wxConceptControl :: wxConceptControl(wxWindow *parent, bool orientation, int minV, int maxV,  int actualV, std::string &aConceptName, std::string elementsDef )
+       wxConceptControl::wxConceptControl(wxWindow *parent, bool orientation, int minV, int maxV,  int actualV, std::string &aConceptName, std::string elementsDef )
        :wxPanel(parent, -1, wxDefaultPosition, parent->GetSize(), wxTAB_TRAVERSAL)
        {
-
-               minValue = minV;
-               maxValue = maxV;
-               
-               showLabels = true;
-
-               wxFlexGridSizer* sizer = new wxFlexGridSizer (1, 3, 15, 15);
-
+               minValue                = minV;
+               maxValue                = maxV;
+               _numCheckBox    = 0;    
+               showLabels              = true;
+
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
+               wxFlexGridSizer* sizer = new wxFlexGridSizer(1, 3, 15, 15);
+#else
+               wxFlexGridSizer* sizer = new wxFlexGridSizer(3);
+#endif
                conceptName = new wxStaticText(this, -1, wxString(aConceptName.c_str(),wxConvUTF8), wxDefaultPosition, wxSize(90,20), wxALIGN_CENTRE );         
                sizer->Add( conceptName, 0, wxALIGN_CENTRE |wxALIGN_CENTER_HORIZONTAL);
-               
                if(orientation)
                {
                        sizer->AddGrowableCol(1);
                        conceptSlider = new wxSlider(this, -1, actualV, minV, maxV, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL| wxSL_AUTOTICKS | wxSL_LABELS, wxDefaultValidator, wxString(aConceptName.c_str(),wxConvUTF8));                    
-               }
-               else
-               {                       
-                       sizer->AddGrowableRow(1);
+               } else {                        
+//                     sizer->AddGrowableRow(1);
                        conceptSlider = new wxSlider(this, -1, actualV, minV, maxV, wxDefaultPosition, wxDefaultSize, wxSL_LEFT| wxSL_AUTOTICKS | wxSL_LABELS, wxDefaultValidator, wxString(aConceptName.c_str(),wxConvUTF8) );                 
                }
                sizer->Add(conceptSlider, 0, wxGROW |wxALL );           
                createElements( sizer, elementsDef );
                SetSizer( sizer );
-
                Connect( conceptSlider->GetId(), wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler(wxConceptControl::onSliderTrack));//(wxObjectEventFunction) &wxConceptControl :: onSliderRelease ); 
                Connect( conceptSlider->GetId(),  wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler(wxConceptControl::onSliderRelease));//(wxObjectEventFunction) &wxConceptControl :: onSliderTrack );     
-
                this->SetAutoLayout( true );
                this->Layout(); 
        }
@@ -206,36 +229,64 @@ DEFINE_EVENT_TYPE( wxEVT_CONCEPT_RELEASE )
        //------------------------------------------------------------------------------------------------------------
        // Creational and initialization methods
        //------------------------------------------------------------------------------------------------------------
-       void wxConceptControl :: createElements(wxSizer *sizer , std::string elementsDef )
+       void wxConceptControl::createElements(wxSizer *sizer , std::string elementsDef )
        {
                const char * elements = elementsDef.c_str();
                int elementsNum = elementsDef.size();
-               wxFlexGridSizer* checkSizer = new wxFlexGridSizer (1, elementsNum, 5, 5);
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
+               wxFlexGridSizer* checkSizer = new wxFlexGridSizer(1, elementsNum, 5, 5);
+#else
+               wxFlexGridSizer* checkSizer = new wxFlexGridSizer(elementsNum);
+#endif
                int i,ckecks = 0;
                for( i = 0;*elements!= 0; elements++)
                {                       
                        char a = *elements;     
                        if( a == 67 || a == 99 )// Including C:67 or c:99 as a checkBox (ASCII)
                        {
-                               createCheckBoxAndAddToSizer( checkSizer, "", -1, ckecks);
+                               /*if(ckecks==0){
+                                       createCheckBoxAndAddToSizer( checkSizer, "X", -1, ckecks);
+                               }else{
+                                       createCheckBoxAndAddToSizer( checkSizer, "Y", -1, ckecks);
+                               }*/
+                               createCheckBoxAndAddToSizer( checkSizer, "X", -1, ckecks);
                                ckecks++;
-                       }
-                       else if ( a == 84 || a==116 )// Including T:84 or t t:116 as textCtrl (ASCII)
+                       } else if ( a == 84 || a==116 )// Including T:84 or t t:116 as textCtrl (ASCII)
                        {
 
                        }
                        i++;
                }
+               _numCheckBox = ckecks;
                sizer->Add(checkSizer, 0, wxGROW |wxALL );      
        }
 
+       int wxConceptControl :: getNumCheckBox(){
+               return _numCheckBox;
+       }
+
        //------------------------------------------------------------------------------------------------------------
        wxCheckBox * wxConceptControl :: createCheckBoxAndAddToSizer(wxSizer *sizer, std::string label, wxWindowID id,int groupID)
        {
-               char buffer[33];
-               //itoa( groupID, buffer, 10); // No ANSI C!
-               sprintf(buffer, "%d", groupID);
-               wxCheckBox *checkbox = new wxCheckBox( this, -1, wxString(  label.c_str(), wxConvUTF8), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxString( buffer, wxConvUTF8) );
+               //char buffer[33];
+               //itoa( groupID, buffer, 10);
+
+               std::string buffer;
+               
+               if(groupID == 0){
+                       buffer = "0";
+               }else{
+                       int k=groupID;
+                       while (k > 0){
+                               char temp = k % 10 + 48;
+                               k = k / 10;
+                               buffer = temp + buffer; 
+                       }
+               }
+
+               //wxCheckBox *checkbox = new wxCheckBox( this, -1, wxString(  label.c_str(), wxConvUTF8), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxString( buffer, wxConvUTF8) );
+               wxCheckBox *checkbox = new wxCheckBox( this, -1, wxString(  label.c_str(), wxConvUTF8), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxString( buffer.c_str(), wxConvUTF8) );
                sizer->Add(checkbox, 0, wxLEFT | wxRIGHT, 5);
                sizer->Add(0, 2, 0, wxGROW); 
                checkBoxes.push_back( checkbox );