]> Creatis software - creaMaracasVisu.git/commitdiff
#2490 creaMaracasVisu Feature New High - Histogram Interaction
authordavila <eduardo.davila@creatis.insa-lyon.fr>
Tue, 16 Dec 2014 14:00:43 +0000 (15:00 +0100)
committerdavila <eduardo.davila@creatis.insa-lyon.fr>
Tue, 16 Dec 2014 14:00:43 +0000 (15:00 +0100)
20 files changed:
bbtk/bbs/appli/exampleColorLayer.bbg
bbtk/bbs/appli/exampleColorLayer.bbs
bbtk/src/bbmaracasvisuSliderMinMax.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/Histogram.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/Histogram.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramBase.cxx [new file with mode: 0644]
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramBase.h [new file with mode: 0644]
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramWidget.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramWidget.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mBarRange.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mBarRange2.cxx [new file with mode: 0644]
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mBarRange2.h [new file with mode: 0644]
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mathplot.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pColorBar.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotter.cxx

index 79c934c16eb4db804e6a609b264a73eab93ea83d..8bc3371f130f26f88da3eb1464e41d3a74c54aa3 100644 (file)
@@ -9,46 +9,60 @@ DESCRIPTION:Description ??
 AUTHOR:Author ??
 COMPLEXBOX:FALSE
 COMPLEXINPUTS:0
-BOXES:4
+BOXES:6
 BOX
 creaMaracasVisu:ColorLayerImageView:Box00
 ISEXEC:FALSE
-9.331188:14.886552:-900.000000
-80.506188:4.886552:-900.000000
+7.671083:-44.550001:-900.000000
+78.846083:-54.550001:-900.000000
 PORT
 PlainOrGradientColor:"false"
 PORT
-lstBaseColor:"0 1 0 1 1 0 1 0 0"
+lstBaseColor:"1 0 0 0 1 0 0 0 1"
 PORT
-lstGreyLevelBoundaries:"500 1200 1600 3000"
+lstGreyLevelBoundaries:"500 1200 1600 4500"
 FIN_BOX
 BOX
 vtk:LoadHola:Box01
 ISEXEC:FALSE
-56.503805:75.675326:-900.000000
-102.078805:65.675326:-900.000000
+-3.363737:85.532200:-900.000000
+42.211263:75.532200:-900.000000
 FIN_BOX
 BOX
 creaMaracasVisu:ViewerNV:Box02
 ISEXEC:FALSE
--9.147294:53.441356:-900.000000
-51.492706:43.441356:-900.000000
+-67.858344:3.600307:-900.000000
+-7.218344:-6.399693:-900.000000
 FIN_BOX
 BOX
 wx:LayoutSplit:Box03
 ISEXEC:TRUE
--18.080640:-21.963529:-900.000000
-27.494360:-31.963529:-900.000000
+-71.344676:-67.998280:-900.000000
+-25.769676:-77.998280:-900.000000
 PORT
 Orientation:"H"
 FIN_BOX
-CONNECTIONS:7
-CONNECTION
-Box01:Out:Box00:In
-NumberOfControlPoints:0
-CONNECTION
-Box01:Out:Box02:In
-NumberOfControlPoints:0
+BOX
+vtk:vtkImageDataPointerRelay:Box04
+ISEXEC:FALSE
+-18.752005:31.893173:-900.000000
+52.422995:21.893173:-900.000000
+FIN_BOX
+BOX
+vtk:RescaleSlopeIntercept:Box05
+ISEXEC:FALSE
+0.147654:67.034726:-900.000000
+71.322654:57.034726:-900.000000
+PORT
+A:"0"
+PORT
+B:"1"
+PORT
+OutputFormat:"VTK_FLOAT"
+PORT
+Type:"2"
+FIN_BOX
+CONNECTIONS:9
 CONNECTION
 Box02:wxVtkBaseView2:Box00:WxVtkBaseView
 NumberOfControlPoints:0
@@ -64,4 +78,16 @@ NumberOfControlPoints:0
 CONNECTION
 Box02:Widget:Box03:Widget2
 NumberOfControlPoints:0
+CONNECTION
+Box04:Out:Box02:In
+NumberOfControlPoints:0
+CONNECTION
+Box04:Out:Box00:In
+NumberOfControlPoints:0
+CONNECTION
+Box01:Out:Box05:In
+NumberOfControlPoints:0
+CONNECTION
+Box05:Out:Box04:In
+NumberOfControlPoints:0
 APP_END
index 113b44d565fef6ff95471c7790065b84abbe6dd3..2a3fd264486cb1879fee25fbf020c7fa4a86d8cb 100644 (file)
@@ -18,8 +18,8 @@ category "<VOID>"
 
 new ColorLayerImageView Box00
   set Box00.PlainOrGradientColor "false"
-  set Box00.lstBaseColor "0 1 0 1 1 0 1 0 0"
-  set Box00.lstGreyLevelBoundaries "500 1200 1600 3000"
+  set Box00.lstBaseColor "1 0 0 0 1 0 0 0 1"
+  set Box00.lstGreyLevelBoundaries "500 1200 1600 4500"
 
 new LoadHola Box01
 
@@ -28,10 +28,14 @@ new ViewerNV Box02
 new LayoutSplit Box03
   set Box03.Orientation "H"
 
+new vtkImageDataPointerRelay Box04
 
-connect Box01.Out Box00.In
+new RescaleSlopeIntercept Box05
+  set Box05.A "0"
+  set Box05.B "1"
+  set Box05.OutputFormat "VTK_FLOAT"
+  set Box05.Type "2"
 
-connect Box01.Out Box02.In
 
 connect Box02.wxVtkBaseView2 Box00.WxVtkBaseView
 
@@ -43,6 +47,14 @@ connect Box00.Widget Box03.Widget1
 
 connect Box02.Widget Box03.Widget2
 
+connect Box04.Out Box02.In
+
+connect Box04.Out Box00.In
+
+connect Box01.Out Box05.In
+
+connect Box05.Out Box04.In
+
 
 
 # Complex input ports
index d223f5be15261439b98c99f0ed371399fde7a3e8..a10d7e3fcb79d4f01970783607d97b294d5f335d 100644 (file)
@@ -60,7 +60,7 @@ namespace bbcreaMaracasVisu
                void onEndChange_Bar(wxCommandEvent& event);
                void onSelectionEnd(wxCommandEvent& event);
                void onMovedBar(wxCommandEvent& event);
-         void PushEventHandler();
+          void PushEventHandler();
 
 
   private:
index a512a272e1a30804c1a5ebd9c169e706628f1f87..cbba163e24222ba889e5b5523b03627f940770a2 100644 (file)
@@ -45,9 +45,9 @@
 //=========================================================================
 ColorLayerImageView::ColorLayerImageView( )
 {
-  _z2          =       0;
-  _fix_dynamic =       true;
-  _color_type   =       false;
+  _z2                                  =       0;
+  _fix_dynamic         =       true;
+  _color_type          =       false;
 }
 
 //=========================================================================
@@ -216,9 +216,9 @@ void ColorLayerImageView::SetDefaultGreyLevelBoundary()
   // By default, the histogram is split into BaseColorNb areas of equal width.
   double delta = (maxTot - minTot)/GetBaseColorNb();
   for (int i = 1; i <= GetBaseColorNb() ; i ++)
-    {
-      _grey_level_boundary.push_back((double)minTot + i * delta);
-    }
+  {
+               _grey_level_boundary.push_back((double)minTot + i * delta);
+  }
 }
 
 //----------------------------------------------------------------------------
@@ -266,13 +266,11 @@ void ColorLayerImageView::ConfigLookupTable()  // virtual
   // CM
   // Grey level extrema retrieved from the image grey level extrema.
 
-/*
-printf("ERROR: EED ColorLayerImageView::ConfigLookupTable   ------_range----------------\n");
-  _range[0]=0;
-  _range[1]=4000;
-*/
+
   GetImage()->GetScalarRange(_range);
 
+
+
   // ------------------ Setting Default Values
   // Checks the size consistency of vectors _base_color and _grey_level_boundary.
   // In case of inconsistency, an exception should be thrown. Instead, the default values are set.
@@ -301,6 +299,8 @@ printf("ERROR: EED ColorLayerImageView::ConfigLookupTable   ------_range--------
   thresholdTable->SetTableRange(thresholdTable_range); 
   thresholdTable->SetAlphaRange(0, 1);
   thresholdTable->SetValueRange(0, 1);
+
+
   thresholdTable->SetSaturationRange(0, 0); 
   thresholdTable->SetRampToLinear( );
 
@@ -368,8 +368,28 @@ printf("ERROR: EED ColorLayerImageView::ConfigLookupTable   ------_range--------
            }
        }
     } //  End Of if (!_color_type)
+
+
        
+   thresholdTable->SetRange(_range[0], _range[1]); // image intensity range
+   thresholdTable->SetValueRange(0.0, 1.0); // from black to white
+
+
   thresholdTable->Build( );
+
+
+
+/*
+// Create a greyscale lookup table
+   vtkLookupTable* thresholdTable = GetThresholdTable();
+   thresholdTable->SetRange(0.5, 0.75); // image intensity range
+   thresholdTable->SetValueRange(0.0, 1); // from black to white
+   thresholdTable->SetHueRange(0.0, 1.0); // from black to white
+   thresholdTable->SetSaturationRange(0.0, 1.0); // no color saturation
+   thresholdTable->SetRampToLinear();
+   thresholdTable->Build();
+*/ 
+
   // ------------------ End Of Defining the Threshold Table
 
   //EO CM
index eb38e0966c00663226f01f21cfcd55284522aab8..ffabba162bf8ae6dbba8fbfd61921eb36bb1d96b 100644 (file)
@@ -48,7 +48,7 @@ wxDlgTransformByDimensionBySpacingByPixel::~wxDlgTransformByDimensionBySpacingBy
 
 void wxDlgTransformByDimensionBySpacingByPixel::GetTransformType(wxWindow *parent , wxString message,int &typeOfTransformation,bool &dlgWxOK)
 {
-       wxDialog* dial          = new wxDialog (parent,-1,_T("Tools"),wxDefaultPosition, wxSize(590,190));
+       wxDialog* dial                          = new wxDialog (parent,-1,_T("Tools"),wxDefaultPosition, wxSize(590,190));
        wxSizer* buttonsSizer   = dial->CreateSeparatedButtonSizer(wxOK|wxCANCEL);
        wxBoxSizer *dialSizer   = new wxBoxSizer(wxVERTICAL);
 
@@ -88,7 +88,7 @@ void wxDlgTransformByDimensionBySpacingByPixel::GetTransformType(wxWindow *paren
  ** Begin of the threshold panel
  **/
 ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, int max, int type)
-: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
+: wxPanel(parent, -1, wxDefaultPosition, wxSize(600,100), wxBORDER_SUNKEN)
 {
        printf("EED ColorLayerImageViewPanel::ColorLayerImageViewPanel start \n");
 
@@ -112,11 +112,13 @@ ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, in
        _sl_SliceImageX->Enable(false);
        _sl_SliceImageY->Enable(false);
        _sl_SliceImageZ->Enable(false);
-
        _interpolationCheckBox = new wxCheckBox(this, -1, _T("Image Interpolation") );
        _interpolationCheckBox->SetValue(true);
        _opacity = new wxSlider(this, wxID_ANY, 6, 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
 
+       _histogram                                      = new Histogram(  this , -1, wxPoint(0,0), wxSize(400,400), /*wxNO_BORDER*/ wxBORDER_DEFAULT ); 
+       _histogramMinMaxLevel   = new HistogramMinMaxLevel( (HistogramBase*)_histogram );
+
        if (type==0)
        {
        }
@@ -134,44 +136,43 @@ ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, in
 
        Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_THUMBTRACK      , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
        Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_LINEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
-       Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_LINEDOWN        , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+       Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_LINEDOWN                , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
        Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_PAGEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
-       Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_PAGEDOWN        , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+       Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_PAGEDOWN                , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
 
        Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_THUMBTRACK      , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
        Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_LINEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
-       Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_LINEDOWN        , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+       Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_LINEDOWN                , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
        Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_PAGEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
-       Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_PAGEDOWN        , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+       Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_PAGEDOWN                , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
 
        Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_THUMBTRACK      , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
        Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_LINEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
-       Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_LINEDOWN        , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+       Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_LINEDOWN                , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
        Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_PAGEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
-       Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_PAGEDOWN        , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
-
-
+       Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_PAGEDOWN                , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
 
        wxFlexGridSizer * sizer         = new wxFlexGridSizer(1);
        if (type==1)
        {
-               sizer -> Add( new wxStaticText(this,-1,_T("Color Image Layer"))  , 1, wxGROW );
-               sizer -> Add( _btn_ReadImage, 1, wxGROW );
-               sizer -> Add( new wxStaticText(this,-1,_T(" "))  , 1, wxGROW );
+               sizer -> Add( new wxStaticText(this,-1,_T("Color Image Layer"))         , 1, wxGROW );
+               sizer -> Add( _btn_ReadImage                                                                                                    , 1, wxGROW );
+               sizer -> Add( new wxStaticText(this,-1,_T(" "))                                                 , 1, wxGROW );
        }
-       sizer -> Add( new wxStaticText(this,-1,_T("Opacity Level"))  , 1, wxGROW );
-       sizer -> Add( _opacity, 1, wxGROW );
-       sizer -> Add( new wxStaticText(this,-1,_T(" "))  , 1, wxGROW );
-       sizer -> Add( _cb_ShowHide, 1, wxGROW );
-       sizer -> Add( new wxStaticText(this,-1,_T(" "))  , 1, wxGROW );
-       sizer -> Add( _interpolationCheckBox, 1, wxGROW );
-
-       sizer -> Add( new wxStaticText(this,-1,_T(" "))  , 1, wxGROW );
-       sizer -> Add( new wxStaticText(this,-1,_T("Slice "))  , 1, wxGROW );
-       sizer -> Add( _sl_SliceImageX, 1, wxGROW );
-       sizer -> Add( _sl_SliceImageY, 1, wxGROW );
-       sizer -> Add( _sl_SliceImageZ, 1, wxGROW );
-       sizer -> Add( _cb_SliceFixDinamic, 1, wxGROW );
+       sizer -> Add( new wxStaticText(this,-1,_T("Opacity Level"))                     , 1, wxGROW );
+       sizer -> Add( _opacity                                                                                                                          , 1, wxGROW );
+       sizer -> Add( new wxStaticText(this,-1,_T(" "))                                                         , 1, wxGROW );
+       sizer -> Add( _cb_ShowHide                                                                                                                      , 1, wxGROW );
+       sizer -> Add( new wxStaticText(this,-1,_T(" "))                                                         , 1, wxGROW );
+       sizer -> Add( _interpolationCheckBox                                                                                    , 1, wxGROW );
+
+       sizer -> Add( new wxStaticText(this,-1,_T(" "))                                                         , 1, wxGROW );
+       sizer -> Add( new wxStaticText(this,-1,_T("Slice "))                                    , 1, wxGROW );
+       sizer -> Add( _sl_SliceImageX                                                                                                           , 1, wxGROW );
+       sizer -> Add( _sl_SliceImageY                                                                                                           , 1, wxGROW );
+       sizer -> Add( _sl_SliceImageZ                                                                                                           , 1, wxGROW );
+       sizer -> Add( _cb_SliceFixDinamic                                                                                               , 1, wxGROW );
+       sizer -> Add( _histogramMinMaxLevel->GetWindow()                                                        , 1, wxGROW );
 
        this->SetSizer( sizer );
        this->SetAutoLayout( true );
@@ -241,6 +242,7 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
 {
     if (img!=NULL)
     {
+                       _histogramMinMaxLevel->Configure( img );
         _colorLayerImageViewManager->SetImage( img );
 
         double spc[3];
@@ -310,7 +312,7 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
                if (_active==true)
                {
                    _colorLayerImageViewManager->onThreshold();
-                   RefreshView();
+                RefreshView();
                }
 //EED01        }
 
@@ -410,7 +412,7 @@ void ColorLayerImageViewPanel::onThresholdInterpolation(wxCommandEvent& event)
 //EED01        if (_colorLayerImageView!=NULL)
 //EED01        {
 //EED01                _colorLayerImageView->onThresholdInterpolation(_interpolationCheckBox->GetValue());
-               _colorLayerImageViewManager->onThresholdInterpolation(_interpolationCheckBox->GetValue());
+          _colorLayerImageViewManager->onThresholdInterpolation(_interpolationCheckBox->GetValue());
                RefreshView();
 //EED01        }//_colorLayerImageView
 }
index 945c801d2bd86c2673bc5c0d4b85a1abd5f7a355..8853a85f215fb94683e623d93e9c72c267a19bad 100644 (file)
 #include <wx/wx.h>
 #include <wx/button.h>
 #include "ColorLayerImageViewManager.h"
+#include "Histogram.h"
+#include "HistogramBase.h"
 
-
+// Borrame
+// #include "mBarRange2.h"
 
 //-----------------------------------------------------
 
@@ -74,28 +77,31 @@ class ColorLayerImageViewPanel
                        void SetOriginalSpacing(double spc[3]);
                        void SetImage(vtkImageData *img);
                        void SetFittingMode(int fitting_mode);
-                       int GetFittingMode();
+                       int  GetFittingMode();
                        void SetActive(bool active);
 
                private:
                        bool                                                                    _active;
                        int                                                                     _fitting_mode;
-
                        int                                                                     _dimBase[3];
                        double                                                          _spcBase[3];
                        double                                                          _spcOrg[3];
-
                        bool                                                                    _thresholdGo;
                        ColorLayerImageViewManager      *_colorLayerImageViewManager;
-//                     ColorLayerImageView             *_colorLayerImageView;  
-                       wxButton                        *_btn_ReadImage;
-                       wxSlider                        *_opacity;
-                       wxCheckBox                      *_interpolationCheckBox;
-                       wxCheckBox                      *_cb_ShowHide;
-                       wxCheckBox                      *_cb_SliceFixDinamic;
-                       wxSlider                        *_sl_SliceImageX;
-                       wxSlider                        *_sl_SliceImageY;
-                       wxSlider                        *_sl_SliceImageZ;
+                       wxButton                                                                *_btn_ReadImage;
+                       wxSlider                                                                *_opacity;
+                       wxCheckBox                                                      *_interpolationCheckBox;
+                       wxCheckBox                                                      *_cb_ShowHide;
+                       wxCheckBox                                                      *_cb_SliceFixDinamic;
+                       wxSlider                                                                *_sl_SliceImageX;
+                       wxSlider                                                                *_sl_SliceImageY;
+                       wxSlider                                                                *_sl_SliceImageZ;
+
+//Borrame
+//                     mBarRange2                                                      *_barrange2;
+                       Histogram*                                                      _histogram;
+                       HistogramMinMaxLevel*                   _histogramMinMaxLevel;
+
                        void onReadImage(wxCommandEvent& event);
                        void onThresholdChange(wxCommandEvent& event);
                        void onThresholdShow(wxCommandEvent& event);
@@ -103,10 +109,7 @@ class ColorLayerImageViewPanel
                        void onChangeOpacity(wxScrollEvent& event);
                        void onSliceFixDinamic(wxCommandEvent& event);
                        void onSliceImage(wxScrollEvent& event);
-
                        void RefreshView();
-       
-
 };
 
 #endif
index eb70d3e92999533420fa33637be5cb1f2d839d45..15ec30669619dfd9f52651a7c45b3a0f6c699771 100644 (file)
@@ -165,6 +165,20 @@ bool LayerImageBase::GetActorPresent()
 void LayerImageBase::SetImage(vtkImageData* image)
 {
        _image = image;
+       double spc[3];
+       _image->GetSpacing(spc);
+       int ext[6];
+       _image->GetWholeExtent(ext);
+       int sx=ext[1]-ext[0]+1;
+       int sy=ext[3]-ext[2]+1;
+       int sz=ext[5]-ext[4]+1;
+       int ssx=(sx/2)*spc[0];
+       int ssy=(sy/2)*spc[1];
+       int ssz=(sz/2)*spc[2];
+       SetX( ssx );
+       SetY( ssy );
+       SetZ( ssz );
+       _image = image;
 }
 
 //----------------------------------------------------------------------------
@@ -173,10 +187,6 @@ void LayerImageBase::SetwxVtkBaseView(wxVtkBaseView *baseview)
        if (_baseView==NULL)
    {
                _baseView = baseview;
-// Old EED 2014 11 13
-//     vtkInteractorStyleBaseView *isbv    = (vtkInteractorStyleBaseView*)(_baseView->GetInteractorStyleBaseView());
-//     isbv->AddInteractorStyleMaracas( new ColorLayerImageBasevtkInteractor(this) );
-
                ColorLayerObserver *colorlayerobserver = ColorLayerObserver::New();
                _baseView->GetVtkBaseData()->AddObserver( 1, colorlayerobserver );
                colorlayerobserver->SetLayerImageBase(this);
index fec399ca43a180788f551dee20215bc3f69a024f..47a69e97506f79b2f4a73b7c280225bbef565363 100644 (file)
@@ -117,13 +117,13 @@ class LayerImageBase
 
                vtkScalarBarActor               *_scalarbarActor;
 
-               virtual void ConfigLookupTable() = 0;           
-               void CleanXYZ(double &x, double &y, double &z);
+               virtual void                    ConfigLookupTable() = 0;                
+               void                                            CleanXYZ(double &x, double &y, double &z);
 
 
   protected:
-               vtkLookupTableGetThresholdTable();
-               vtkImageDataGetImage();
+               vtkLookupTable                  *GetThresholdTable();
+               vtkImageData                    *GetImage();
  };
 
 
index 8526658a8478c34a4e991edcecb798e204b59d73..459cc18a40b73ffb2f507ab48a7325824642900e 100644 (file)
@@ -95,7 +95,7 @@ END_EVENT_TABLE()
 
        }
 
-    void Histogram::Configure(vtkImageData* imageData)
+   void Histogram::Configure(vtkImageData* imageData)
        {
                histogram= new pHistogram(imageData);
                drawHistogram();
@@ -166,6 +166,7 @@ END_EVENT_TABLE()
                int scrX,scrY;
                GetClientSize(&scrX,&scrY);
                plotter->SetSize(scrX,scrY);
+
                /*
                pGraphicalFunction* actual=plotter->getFunction(idTransferenceFunction);
                actual->setScreens(scrX,scrY);
@@ -192,4 +193,15 @@ END_EVENT_TABLE()
                return histogramSize;
        }
 
+       wxWindow* Histogram::GetWindow()
+       {
+               return this;
+       }
+
+       pPlotterWindow* Histogram::GetPlotterWindow()
+       {
+               return plotter;
+       } 
+
+
 
index 3bd3b081ec785efaf2680abd6461d422f09d3f9d..01071f720b72bd8c0a86993a45a212dfb05e488c 100644 (file)
 #include <wx/wx.h>
 #endif
 
+#include "HistogramBase.h"
 #include "marTypes.h"
 #include "pPlotterWindow.h"
 #include "pFunctionPoint.h"
-#include  "vtkImageData.h"
+#include "vtkImageData.h"
 #include "pHistogram.h"
 #include "pPlotterScaleY.h"
 #include "pPlotterScaleX.h"
@@ -53,7 +54,7 @@
 #define NUM_POINTS 100
 #define WINDOW_SIZE 10
 
-class creaMaracasVisu_EXPORT Histogram:public wxPanel
+class creaMaracasVisu_EXPORT Histogram:public wxPanel, HistogramBase
 {
 public:
        //---------------------
@@ -87,14 +88,16 @@ public:
        */
        int getHistogramPoint(int gValue);
        int getHistogramSize();
-       void Configure(vtkImageData* imageData);
-       
+       pPlotterWindow* GetPlotterWindow(); 
+       virtual void Configure(vtkImageData* imageData);
+       virtual wxWindow* GetWindow();
+
 private:
        
         pHistogram*            histogram;
         pPlotterWindow*        plotter;
-        int                            histogramSize;
-        int                             idHistogram;
+        int                                    histogramSize;
+        int                                    idHistogram;
         
         
         DECLARE_CLASS(Histogram);
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramBase.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramBase.cxx
new file mode 100644 (file)
index 0000000..a57426a
--- /dev/null
@@ -0,0 +1,142 @@
+/*# ---------------------------------------------------------------------
+#
+# 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.
+# ------------------------------------------------------------------------ */
+
+
+#include "HistogramBase.h"
+
+// -- inluces for HistogramMinMaxLevel
+#include "pPlotterWindow.h"
+#include "Histogram.h"
+
+
+
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+       HistogramBase::HistogramBase()
+       {               
+       }
+
+//-----------------------------------------------------------------------------
+       HistogramBase::~HistogramBase()
+       {
+       }
+
+//-----------------------------------------------------------------------------
+       HistogramBase* HistogramBase::GetConcretComponent()
+       {
+               return this;
+       }
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+       HistogramDecorator::HistogramDecorator()
+       {               
+       }
+
+//-----------------------------------------------------------------------------
+       HistogramDecorator::~HistogramDecorator()
+       {
+       }
+
+//-----------------------------------------------------------------------------
+       HistogramBase* HistogramDecorator::GetConcretComponent()
+       {
+               return _histogrambase->GetConcretComponent();
+       }
+
+
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+       HistogramMinMaxLevel::HistogramMinMaxLevel(HistogramBase* histogrambase)
+       {               
+                                                               _histogrambase = histogrambase;
+               wxWindow *histogramebasePanel           =_histogrambase->GetWindow();
+               wxPanel *panel                                          = new wxPanel( histogramebasePanel->GetParent() , -1, wxDefaultPosition, wxSize(600,600) );
+               histogramebasePanel->Reparent(panel);
+                                                               _barrange2              = new mBarRange2(panel, 30, 20); 
+               _barrange2->PushEventHandler((wxEvtHandler*)this);
+               Connect(_barrange2->GetId(), wxEVT_BarRange2_Change ,
+                                       (wxObjectEventFunction) (wxCommandEventFunction) &HistogramMinMaxLevel::onBarRangeChange );
+               wxFlexGridSizer*        sizer                           = new wxFlexGridSizer(1);
+               sizer->Add( histogramebasePanel , 1, wxGROW );
+               sizer->Add( _barrange2                          , 1, wxGROW );
+               panel->SetSizer( sizer );
+               panel->SetAutoLayout( true );
+               panel->Layout();
+               _panel = panel;
+       }
+
+//-----------------------------------------------------------------------------
+       HistogramMinMaxLevel::~HistogramMinMaxLevel()
+       {
+       }
+
+//-----------------------------------------------------------------------------
+       wxWindow* HistogramMinMaxLevel::GetWindow()
+       {
+               return _panel;
+       }
+
+//-----------------------------------------------------------------------------
+       void HistogramMinMaxLevel::Configure(vtkImageData* img)
+       {
+               _histogrambase->Configure(img); 
+               double range[2];
+               img->GetScalarRange(range);
+               _barrange2->SetScalarType( img->GetScalarType() );
+               _barrange2->SetMinMaxValue(range[0],range[1]);
+       }
+
+//-----------------------------------------------------------------------------
+void HistogramMinMaxLevel::onBarRangeChange(wxCommandEvent& event)
+{
+       printf ("EED HistogramMinMaxLevel::onBarrangeChange\n");
+       Histogram*                      histogram               = (Histogram*)GetConcretComponent();
+       pPlotterWindow*         plotterwindow   = histogram->GetPlotterWindow();        
+
+       plotterwindow->setLineGuidesCondition(true);
+       double startvalue = _barrange2->GetStartValue();
+       plotterwindow->setRealGuideX( startvalue*100 );
+       plotterwindow->setRealGuideY( startvalue*100 );
+       
+       if (plotterwindow->drawGuideLines()==true)
+       {
+               printf ("YES \n");
+       } else {
+               printf ("NO \n");
+       }
+
+       plotterwindow->UpdateAll();
+
+}
+
+
+
+
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramBase.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramBase.h
new file mode 100644 (file)
index 0000000..54701d2
--- /dev/null
@@ -0,0 +1,106 @@
+/*# ---------------------------------------------------------------------
+#
+# 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.
+# ------------------------------------------------------------------------ */
+
+#ifndef __HISTOGRAMBASE__
+#define __HISTOGRAMBASE__
+
+
+// ----------------------------------------------------------------------------
+// wx headers inclusion.
+// For compilers that support precompilation, includes <wx/wx.h>.
+// ----------------------------------------------------------------------------
+#include <wx/wxprec.h>
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+#ifndef WX_PRECOMP
+#include <wx/wx.h>
+#endif
+
+#include "marTypes.h"
+#include "vtkImageData.h"
+#include "mBarRange2.h"
+
+
+class creaMaracasVisu_EXPORT HistogramBase
+{
+public:
+       //---------------------
+       // Constructor
+       //----------------------
+       HistogramBase();
+       ~HistogramBase();
+       virtual wxWindow* GetWindow() = 0;
+       virtual void Configure(vtkImageData*) = 0;
+       virtual HistogramBase* GetConcretComponent();
+private:
+protected:
+};
+
+
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+class creaMaracasVisu_EXPORT HistogramDecorator:public HistogramBase
+{
+public:
+       HistogramDecorator();
+       ~HistogramDecorator();
+       virtual wxWindow* GetWindow() = 0;
+       virtual void Configure(vtkImageData*) = 0;
+       virtual HistogramBase* GetConcretComponent();
+private:
+protected:
+       HistogramBase*  _histogrambase;
+};
+
+
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+class creaMaracasVisu_EXPORT HistogramMinMaxLevel:public HistogramDecorator,  wxEvtHandler
+{
+public:
+       //---------------------
+       // Constructor
+       //----------------------
+       HistogramMinMaxLevel(HistogramBase* histogrambase);
+       ~HistogramMinMaxLevel();
+       virtual wxWindow* GetWindow();
+       virtual void Configure(vtkImageData*);
+       void onBarRangeChange(wxCommandEvent& event);
+
+private:
+       wxPanel*                        _panel;
+       mBarRange2*             _barrange2;
+protected:
+};
+
+
+#endif  // __HISTOGRAMBASE__
+
+
index 9d80407174362c6653c4377464ef52e776354922..eb6d6333cde0e8af09cfef6ef48d58f81d539ffe 100644 (file)
@@ -82,11 +82,11 @@ HistogramWidget::HistogramWidget( wxWindow *parent, wxWindowID id, const wxPoint
                plotter->setType(2);
                //setting the popMenu
                plotter->setPopUpMenu(true,true,true,true,true,true,false,false,false,false,false,false,false);
-               histogramSize=0;
-               idTransferenceFunction=-1;
-               idHistogram=-1;
-               transferenceFunctionHasColor=true;
-               transferenceFunctionHasPoints=true;
+               histogramSize                                           = 0;
+               idTransferenceFunction                  = -1;
+               idHistogram                                                     = -1;
+               transferenceFunctionHasColor    = true;
+               transferenceFunctionHasPoints   = true;
                this->type=type;
                
                this->SetAutoLayout(true);
@@ -95,17 +95,14 @@ HistogramWidget::HistogramWidget( wxWindow *parent, wxWindowID id, const wxPoint
                //drawing
                drawHistogram();
                drawTransferenceFunction();
-               
        }
 
        HistogramWidget::HistogramWidget( wxWindow *parent, wxWindowID id)
                : wxPanel(parent,id){
 
-
                        SetBackgroundColour(wxColour(255,255,255));
                        histogram = NULL;       
                        
-                       
                        //plotter
                        plotter=new pPlotter(this, 400,350);
                        
@@ -113,16 +110,14 @@ HistogramWidget::HistogramWidget( wxWindow *parent, wxWindowID id, const wxPoint
                        plotter->setType(2);
                        //setting the popMenu
                        plotter->setPopUpMenu(true,true,true,true,true,true,false,false,false,false,false,false,false);
-                       histogramSize=0;
-                       idTransferenceFunction=-1;
-                       idHistogram=-1;
-                       transferenceFunctionHasColor=true;
-                       transferenceFunctionHasPoints=true;
-                       this->type=type;;
+                       histogramSize                                           = 0;
+                       idTransferenceFunction                  = -1;
+                       idHistogram                                                     = -1;
+                       transferenceFunctionHasColor    = true;
+                       transferenceFunctionHasPoints   = true;
+                       this->type                                                      = type;;
                        this->SetAutoLayout(true);
                        this->Refresh();
-               
-                               
        }
 
        
@@ -205,18 +200,18 @@ HistogramWidget::HistogramWidget( wxWindow *parent, wxWindowID id, const wxPoint
                        double xValues[5],yValues[5];
                        //xValues
                        int maxValueGrey=histogram->getMaximumLevelOfGrey();
-                       xValues[0]=0;
-                       xValues[1]=maxValueGrey/16;
-                       xValues[2]=maxValueGrey/8;
-                       xValues[3]=maxValueGrey/16+(maxValueGrey-maxValueGrey/2)/2;
-                       xValues[4]=maxValueGrey;
+                       xValues[0] = 0;
+                       xValues[1] = maxValueGrey/16;
+                       xValues[2] = maxValueGrey/8;
+                       xValues[3] = maxValueGrey/16+(maxValueGrey-maxValueGrey/2)/2;
+                       xValues[4] = maxValueGrey;
                        
                        //yValues
-                       yValues[0]=0;
-                       yValues[1]=25;
-                       yValues[2]=100;
-                       yValues[3]=25;
-                       yValues[4]=0;
+                       yValues[0] = 0;
+                       yValues[1] = 25;
+                       yValues[2] = 100;
+                       yValues[3] = 25;
+                       yValues[4] = 0;
                        
                        pGraphicalFunction * tf = plotter ->getFunctionForVectors( xValues, 5, yValues, 5 ); 
                        printf("EED %p HistogramWidget::drawTransferenceFunction %p\n", this , tf);             
@@ -311,7 +306,7 @@ HistogramWidget::HistogramWidget( wxWindow *parent, wxWindowID id, const wxPoint
                pGraphicalFunction* histogramFunction   = plotter->getFunction(idHistogram);
                int min                                                                                 = histogramFunction->getMinX();
                float x                                                                                 = porcentageMaxX*(histogramFunction->getMaxX()-min);
-               return min+ x;
+               return min + x;
        }
        /*
         Returns the  minimum value ot the histogram that is show to the user 
@@ -322,7 +317,7 @@ HistogramWidget::HistogramWidget( wxWindow *parent, wxWindowID id, const wxPoint
                pGraphicalFunction* histogramFunction   = plotter->getFunction(idHistogram);
                int min                                                                                 = histogramFunction->getMinX();
                float x                                                                                 = porcentageMinX*(histogramFunction->getMaxX()-min);
-               return min+ x;
+               return min + x;
        }
        /*
         Returns the  minimum value ot the histogram that is show to the user 
index 0e61661d907a46e5ff6d2de900759afbb0332ca7..cd5cc1aad15edd364fcfb17057ad77042f4f82c6 100644 (file)
@@ -183,11 +183,11 @@ public:
        
 private:
        
-        pHistogram* histogram;
-        pPlotter* plotter;
-        int idTransferenceFunction;
-        int histogramSize;
-        int idHistogram;
+        pHistogram*    histogram;
+        pPlotter*              plotter;
+        int                            idTransferenceFunction;
+        int                            histogramSize;
+        int                            idHistogram;
         /*
          if the image has already a transference
          function and color defines to that function
index 72610d7ba3096b40b52cffc12d7509300a7c0ea6..ecff41e1578394b6e1fbe935d798651ee06cbead 100644 (file)
 //----------------------------------------------------------------------------
 
 BEGIN_DECLARE_EVENT_TYPES()
- DECLARE_EVENT_TYPE(wxEVT_TSBAR,-1) 
-DECLARE_EVENT_TYPE(wxEVT_TSBAR_ACTUAL,-1)
-//DECLARE_EXPORTED_EVENT_TYPE(MARACASVISULIB_EXPORTS,wxEVT_TSBAR_ACTUAL,-1)
-//extern creaMaracasVisu_EXPORT const wxEventType wxEVT_TSBAR_ACTUAL;
- DECLARE_EVENT_TYPE(wxEVT_TSBAR_START,-1)
- DECLARE_EVENT_TYPE(wxEVT_TSBAR_END,-1)
- DECLARE_EVENT_TYPE(wxEVT_TSBAR_MOVED,-1)
- DECLARE_EVENT_TYPE(wxEVT_SELECTION_END,-1)
      DECLARE_EVENT_TYPE(wxEVT_TSBAR,-1) 
+       DECLARE_EVENT_TYPE(wxEVT_TSBAR_ACTUAL,-1)
+//     DECLARE_EXPORTED_EVENT_TYPE(MARACASVISULIB_EXPORTS,wxEVT_TSBAR_ACTUAL,-1)
+//     extern creaMaracasVisu_EXPORT const wxEventType wxEVT_TSBAR_ACTUAL;
      DECLARE_EVENT_TYPE(wxEVT_TSBAR_START,-1)
      DECLARE_EVENT_TYPE(wxEVT_TSBAR_END,-1)
      DECLARE_EVENT_TYPE(wxEVT_TSBAR_MOVED,-1)
      DECLARE_EVENT_TYPE(wxEVT_SELECTION_END,-1)
 END_DECLARE_EVENT_TYPES()
 
 
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mBarRange2.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mBarRange2.cxx
new file mode 100644 (file)
index 0000000..c07727b
--- /dev/null
@@ -0,0 +1,197 @@
+ /*# ---------------------------------------------------------------------
+#
+# 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.
+# ------------------------------------------------------------------------ */
+
+/**
+ *  \file 
+ *  \brief ClassThresholdImageViewPanel . 
+ */
+
+#include "mBarRange2.h"
+
+
+DEFINE_EVENT_TYPE(wxEVT_BarRange2_Change)
+
+
+/**
+ ** Begin of the  panel
+ **/
+mBarRange2::mBarRange2(wxWindow* parent,int width, int height)
+: wxPanel(parent, -1, wxDefaultPosition, wxSize(width,height), wxBORDER_SUNKEN)
+{
+       _minValue                       = 0;
+       _maxValue                       = 100;
+       _scalarType                     = 0;
+       _mBarRange                      = new mBarRange(this,width,height);
+       _mBarRange->SetOrientation( true );
+       _mBarRange->setActiveStateTo(true);
+       _mBarRange->setVisibleLabels( false );
+       _mBarRange->setDeviceEndMargin(10);
+       _mBarRange->setDeviceBlitStart(10,10); 
+       _mBarRange->setIfWithActualDrawed( false );
+       _mBarRange->setRepresentedValues( 0, 100 );
+       _mBarRange->SetStart(0);
+       _mBarRange->SetEnd(100);  
+       _textctrlStart  = new wxTextCtrl( this, -1, _T(""),wxDefaultPosition, wxSize(60,20),wxTE_PROCESS_ENTER );
+       _textctrlEnd            = new wxTextCtrl( this, -1, _T(""),wxDefaultPosition, wxSize(60,20),wxTE_PROCESS_ENTER );
+       Connect( _textctrlStart->GetId(), wxEVT_COMMAND_TEXT_ENTER      , (wxObjectEventFunction) &mBarRange2::onTxtCtrl );
+       Connect( _textctrlEnd->GetId(), wxEVT_COMMAND_TEXT_ENTER        , (wxObjectEventFunction) &mBarRange2::onTxtCtrl );
+       wxFlexGridSizer * sizer                                 = new wxFlexGridSizer(1);
+       wxFlexGridSizer * sizerTextCtrl         = new wxFlexGridSizer(2);
+       sizerTextCtrl -> Add( _textctrlStart    , 1, wxGROW );  
+       sizerTextCtrl -> Add( _textctrlEnd              , 1, wxGROW );  
+       sizer -> Add( _mBarRange                                        , 1, wxGROW );  
+       sizer -> Add( sizerTextCtrl                             , 1, wxGROW );  
+       this->SetSizer( sizer );
+       this->SetAutoLayout( true );
+       this->Layout();
+       RefreshTextCntrl();
+}
+
+//----------------------------------------------------------------------------
+mBarRange2::~mBarRange2()
+{
+}
+
+//----------------------------------------------------------------------------
+wxString mBarRange2::CleanNumberStr(wxString string)
+{
+       wxString tmpStr=string;
+       while (tmpStr[tmpStr.Length()-1]=='0') 
+       {
+               tmpStr=tmpStr.SubString (0, tmpStr.Length()-1-1 );
+       } //
+
+       if (tmpStr[tmpStr.Length()-1]=='.')
+       {
+               tmpStr.Append(_T("0"));
+       }
+       return tmpStr;
+}
+
+
+//----------------------------------------------------------------------------
+double mBarRange2::GetStartValue()
+{
+       return _startValue;
+}
+
+//----------------------------------------------------------------------------
+double mBarRange2::GetEndValue()
+{
+       return _endValue;
+}
+
+//----------------------------------------------------------------------------
+void mBarRange2::RefreshTextCntrl()
+{
+   double startPorcentage      = _mBarRange->GetStart();
+       double endPorcentage    = _mBarRange->GetEnd();  
+       _startValue                             = (_maxValue-_minValue)*(startPorcentage/100) + _minValue;
+       _endValue                                       = (_maxValue-_minValue)*(endPorcentage/100) + _minValue;
+
+       wxString startValueStr;
+       wxString endValueStr;
+
+       if ( (_scalarType==10) || (_scalarType==11) )  // 10=VTK_FLOAT   11=VTK_DOUBLE  
+       {
+               startValueStr.Printf(_T("%f"),_startValue);
+               startValueStr=CleanNumberStr( startValueStr );
+               endValueStr.Printf(_T("%f"),_endValue);
+               endValueStr=CleanNumberStr( endValueStr );
+       } else {
+               startValueStr.Printf(_T("%d"),(int)_startValue);        
+               endValueStr.Printf(_T("%d"),(int)_endValue);
+       }
+
+       _textctrlStart->SetValue( startValueStr );
+       _textctrlEnd->SetValue( endValueStr );  
+}
+
+
+//----------------------------------------------------------------------------
+void mBarRange2::createAndSendEvent(WXTYPE theEventType)
+{
+       wxCommandEvent cevent( theEventType, GetId() );
+       cevent.SetEventObject( this );
+       GetEventHandler()->ProcessEvent( cevent );
+}
+
+
+
+//----------------------------------------------------------------------------
+void mBarRange2::onBarRangeChange(wxCommandEvent& event)
+{
+       RefreshTextCntrl();
+       createAndSendEvent( wxEVT_BarRange2_Change );
+}
+
+//----------------------------------------------------------------------------
+void mBarRange2::onTxtCtrl(wxCommandEvent& event)
+{
+       double value;
+       double startPorcentage;
+       double endPorcentage;
+       if (_textctrlStart->GetValue().ToDouble(&value)==true)
+       { 
+               startPorcentage = (value - _minValue)*100/(_maxValue-_minValue);
+               _mBarRange->SetStart( startPorcentage );
+       } 
+
+       if (_textctrlEnd->GetValue().ToDouble(&value)==true)
+       { 
+               endPorcentage = (value - _minValue)*100/(_maxValue-_minValue);
+               _mBarRange->SetEnd( endPorcentage );
+       } 
+
+       RefreshTextCntrl();             
+}
+
+//----------------------------------------------------------------------------
+void mBarRange2::SetMinMaxValue(double min, double max)
+{
+       _minValue = min;
+       _maxValue = max;
+       RefreshTextCntrl();             
+}
+
+
+//----------------------------------------------------------------------------
+void mBarRange2::SetScalarType(int value)
+{
+       _scalarType = value;
+}
+
+
+
+//----------------------------------------------------------------------------
+BEGIN_EVENT_TABLE(mBarRange2, wxPanel)
+  EVT_COMMAND( wxID_ANY, wxEVT_TSBAR_START     , mBarRange2::onBarRangeChange  )
+  EVT_COMMAND( wxID_ANY, wxEVT_TSBAR_END               , mBarRange2::onBarRangeChange  )
+  EVT_COMMAND( wxID_ANY, wxEVT_TSBAR_MOVED     , mBarRange2::onBarRangeChange  )       
+END_EVENT_TABLE()
+
+
+// EOF
+
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mBarRange2.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mBarRange2.h
new file mode 100644 (file)
index 0000000..e883c98
--- /dev/null
@@ -0,0 +1,82 @@
+/*# ---------------------------------------------------------------------
+#
+# 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.
+# ------------------------------------------------------------------------ */
+
+
+
+/**
+ *  \file 
+ *  \brief Class ThresholdImageViewPanel . 
+ */
+
+/**
+ * \class ThresholdImageViewPanel
+ * \brief 
+ */
+#ifndef __ThresholdImageViewPanel_h__
+#define __ThresholdImageViewPanel_h__
+
+
+#include <wx/wx.h>
+#include <wx/textctrl.h>
+#include "mBarRange.h"
+
+
+BEGIN_DECLARE_EVENT_TYPES()
+       DECLARE_EVENT_TYPE(wxEVT_BarRange2_Change,-1) 
+END_DECLARE_EVENT_TYPES()
+
+
+
+       class mBarRange2
+               : public wxPanel
+               {
+               public:
+                       mBarRange2(wxWindow * parent,int width, int height);            
+                       ~mBarRange2();
+                       void            onTxtCtrl(wxCommandEvent& event);
+                       void            SetMinMaxValue(double,double);
+                       void            SetScalarType(int);
+                       double  GetStartValue();
+                       double  GetEndValue();
+               private:
+                       double                          _minValue;
+                       double                          _maxValue;
+                       double                          _startValue;
+                       double                          _endValue;
+                       int                                     _scalarType;   
+                       mBarRange                       *_mBarRange;    
+                       wxTextCtrl                      *_textctrlStart;
+                       wxTextCtrl                      *_textctrlEnd;
+                       void            onBarRangeChange(wxCommandEvent& event);
+                       wxString CleanNumberStr(wxString string);       
+                       void            RefreshTextCntrl();
+                       void            createAndSendEvent(WXTYPE theEventType);
+                       DECLARE_EVENT_TABLE()
+               };
+       
+       
+#endif
+
index bf519013eec252d10a83c4f04e186272c9b6659c..af3e86591c91280d11a42fa6a1869c3fdfb7df18 100644 (file)
@@ -729,14 +729,12 @@ void mpWindow::UpdateAll()
        {
                int cx, cy;
                GetClientSize( &cx, &cy);
-
                const int sx = (int)((m_maxX - m_minX) * GetScaleX()); // JPRx
                const int sy = (int)((m_maxY - m_minY) * GetScaleY()); // JPRx
                const int px = (int)((GetPosX() - m_minX) * GetScaleX() - (cx>>1)); // JPRx
                const int py = (int)((GetPosY() - m_minY) * GetScaleY() - (cy>>1)); // JPRx
                SetScrollbars( 1, 1, sx, sy, px, py);
        }
-
        FitInside();
        Refresh( false );
 }
index be5e98aa1047d60e3e8e1f95bfbf7091461c8661..68874cc645a63a9ae8c92f68008390e21659da1c 100644 (file)
@@ -207,7 +207,7 @@ pColorBar :: ~pColorBar()
                                        bool hasPrevPoint = movingPointIndex > 0;
                                        bool hasNextPoint = movingPointIndex < showedColorPoints.size()-1;
 
-                                       pColorPoint * prevPoint =  hasPrevPoint? showedColorPoints[movingPointIndex-1]: NULL; 
+                                       pColorPoint * prevPoint = hasPrevPoint? showedColorPoints[movingPointIndex-1]: NULL; 
                                        pColorPoint * nextPoint = hasNextPoint ? showedColorPoints[movingPointIndex+1]: NULL;
 
                                        if ( hasPrevPoint && prevPoint!=NULL )
@@ -409,15 +409,15 @@ pColorBar :: ~pColorBar()
        */
        void pColorBar :: onDeleteColorPoint ( wxCommandEvent& anEvent )
        {
-               bool deletedPoint = false;
-               double real_x = getOrientation() ? convertToRealValue( clickedX ) : convertToRealValue( clickedY );
-               deletedPoint = deleteColorPoint(real_x);
+               bool            deletedPoint            = false;
+               double  real_x                          = getOrientation() ? convertToRealValue( clickedX ) : convertToRealValue( clickedY );
+                                       deletedPoint            = deleteColorPoint(real_x);
                // Inform deletedPoint event
                if ( deletedPoint )
                {
                        //RefreshForce();
                        createAndSendEvent( wxEVT_REMOVED_POINT );                      
-               }
+               } //if
        }
 
                /**
@@ -434,8 +434,10 @@ pColorBar :: ~pColorBar()
                {
                        //RefreshForce();
                        createAndSendEvent( wxEVT_CHANGED_POINT );                      
-               }
+               } // if
        }
+
+
        /**
        * Reacts to the cntID_TRIANGLES_UP wxCommandEvent and changes the assigned figure to -triangles up- for the color points of the color bar.
        * param & anEvent The wxCommandEvent actioned event 
index bddea2312257675dda70286dd5bfa5fd0ab74590..1e80597db847ec10a8969e9f9cd9a0de58152e87 100644 (file)
@@ -219,15 +219,13 @@ END_EVENT_TABLE()
 Set the bars according to the actual function 
 */
 
-       void pPlotter::setAll()
+void pPlotter::setAll()
 {
        actualFunction = m_plot->getActualFunction();
-
        if (actualFunction != NULL)
        {
                barrange -> setActiveStateTo(true);
                color_bar -> setActiveStateTo(true);
-
                text.Clear();
                text = _T("minX=");
                double realMin_X = actualFunction->getMinX();
@@ -235,30 +233,25 @@ Set the bars according to the actual function
                text = text + _T(" maxX=");
                double realMax_X = actualFunction->getMaxX();
                text = text + realMax_X;
-
                int minShowed = actualFunction->getMinXShowed();
                int maxShowed = actualFunction->getMaxXShowed();
-
                barrange -> setRepresentedValues (realMin_X, realMax_X);
                barrange->SetStart( minShowed );
                barrange->SetEnd( maxShowed );
-
-
                std::vector<pColorPoint *> actualColorPoints;
-               actualFunction -> getColorPoints(actualColorPoints);
+               actualFunction->getColorPoints(actualColorPoints);
                if(actualColorPoints.empty())
-                       color_bar ->reinitiateColorBar (realMin_X, realMax_X);
-               else
-                       color_bar ->reinitiateColorBarTo(actualColorPoints);
-
-               color_bar -> setVisibleRange (minShowed, maxShowed);
-               
+               {
+                       color_bar->reinitiateColorBar (realMin_X, realMax_X);
+               } else {
+                       color_bar->reinitiateColorBarTo(actualColorPoints);
+               }
+               color_bar->setVisibleRange (minShowed, maxShowed);
                // Refresh
-               color_bar -> RefreshForce();
-               barrange -> RefreshForce();     
-               
+               color_bar->RefreshForce();
+               barrange->RefreshForce();       
                sendTMessage(text);
-       }
+       } // if actualFunction
 }
 
        
@@ -269,11 +262,10 @@ Set the bars according to the actual function
 //-----------------------------------------------------------------------------------------------------
 // Updating methods for occured events in the color bar
 //-----------------------------------------------------------------------------------------------------
-void  pPlotter :: onAdded_ColorPoint(wxCommandEvent& event)
+void  pPlotter::onAdded_ColorPoint(wxCommandEvent& event)
 {
        text.Clear();
        text = _T( "Last event was on color bar: Color point added, total#");
-       
        actualFunction = m_plot->getActualFunction();
        if(actualFunction!=NULL)
        {               
@@ -281,41 +273,38 @@ void  pPlotter :: onAdded_ColorPoint(wxCommandEvent& event)
                color_bar ->getAddedColorsPointsList(actualColorPoints);
                actualFunction -> setColorPoints(actualColorPoints);
                text << actualColorPoints.size();
-
                sendTMessage(text);
        }
 }
+
 void  pPlotter :: onRemoved_ColorPoint(wxCommandEvent& event)
 {      
        text.Clear();
        text = _T( "Last event on color bar: Color point removed total#");
-
        actualFunction = m_plot->getActualFunction();
        std::vector<pColorPoint *> actualColorPoints;
        color_bar ->getAddedColorsPointsList(actualColorPoints);
        actualFunction -> setColorPoints(actualColorPoints);
        text << actualColorPoints.size();
-       
        sendTMessage(text);
 }
+
 void  pPlotter :: onMoved_ColorPoint(wxCommandEvent& event)
 {
        text.Clear();
        text = _T( "Last event was on color bar: Color point moved to: ");
        int lastReal_X = (int)(color_bar->getLastMovedColorPoint())->getRealX();
        text << lastReal_X;
-       
        barrange ->setRealX_vertical_line (lastReal_X);
        barrange -> RefreshForce();
-       
        m_plot->setRealGuideX (lastReal_X);
        m_plot->UpdateAll();
-       
        sendTMessage(text);
 }
+
 void  pPlotter:: onChanged_ColorPoint(wxCommandEvent& event)
 {
-    text.Clear();
+       text.Clear();
        sendTMessage(_T("Last event was on color bar: Color point changed color"));
 }
 
@@ -367,20 +356,21 @@ void pPlotter :: onChangeFunction (wxCommandEvent& event)
                barrange->SetEnd( maxShowed );
                
                std::vector<pColorPoint *> actualColorPoints;
-               actualFunction -> getColorPoints(actualColorPoints);
+               actualFunction->getColorPoints(actualColorPoints);
                if(actualColorPoints.empty())
-                       color_bar ->reinitiateColorBar (realMin_X, realMax_X);
-               else
-                       color_bar ->reinitiateColorBarTo(actualColorPoints);
-
-               color_bar -> setVisibleRange ((int)realMin_X, maxShowed);
+               {
+                       color_bar->reinitiateColorBar (realMin_X, realMax_X);
+               } else {
+                       color_bar->reinitiateColorBarTo(actualColorPoints);
+               }
+               color_bar->setVisibleRange ((int)realMin_X, maxShowed);
                
                // Refresh
-               color_bar -> RefreshForce();
-               barrange -> RefreshForce();     
+               color_bar->RefreshForce();
+               barrange->RefreshForce();       
                
                sendTMessage(text);
-       }
+       } // if actualFunction
 }
 
 
@@ -444,7 +434,7 @@ void  pPlotter::onActualChange_Bar(wxCommandEvent& event)
        color_bar ->setRealX_vertical_line (lastActual_X);
        color_bar -> RefreshForce();    
 
-       m_plot->setRealGuideX (lastActual_X);
+       m_plot->setRealGuideX(lastActual_X);
        m_plot->UpdateAll();
 
        text.Clear();
@@ -472,8 +462,8 @@ void  pPlotter::onStartChange_Bar(wxCommandEvent& event)
        //setting the plotter for draw the functions that
        //it has to move.
        
-       float startP=(float)barrange->getStartShowPorcentage();
-       float endP=(float)barrange->getEndShowPorcentage();
+       float startP    =       (float)barrange->getStartShowPorcentage();
+       float endP              =       (float)barrange->getEndShowPorcentage();
        m_plot->moveFunctions(startP,endP);
        
        //Updating
@@ -486,19 +476,16 @@ void  pPlotter::onEndChange_Bar(wxCommandEvent& event)
 {
        text.Clear();
        text += _T("Last event was on min-max bar: End  triangle moved to: ");
-       int realMax_X = barrange->GetEnd();
+       int realMax_X           = barrange->GetEnd();
        text += wxString::Format(_T("%d"),realMax_X);   
-       double realMin_X = m_plot->getMinScrX();
+       double realMin_X        = m_plot->getMinScrX();
        color_bar -> setVisibleRange ((int)realMin_X, realMax_X);
        m_plot->actualizeViewRange((int)realMin_X,realMax_X);
-       
-       float startP=(float)barrange->getStartShowPorcentage();
-       float endP=(float)barrange->getEndShowPorcentage();
+       float startP            = (float)barrange->getStartShowPorcentage();
+       float endP                      = (float)barrange->getEndShowPorcentage();
        m_plot->moveFunctions(startP,endP);
-       
        color_bar -> RefreshForce();
        m_plot -> UpdateAll();
-
        sendTMessage(text);
 }
 
@@ -670,10 +657,12 @@ void pPlotter :: sendTMessage(wxString theText)
        {
                return barrange->getEndShowPorcentage();
        }
+
        float pPlotter::getMinShowedPorcentage()
        {
                return barrange->getStartShowPorcentage();
        }
+
        float pPlotter::getActualShowedPorcentage()
        {
                return barrange->getActualShowPorcentage();
@@ -747,16 +736,17 @@ void pPlotter :: sendTMessage(wxString theText)
 **/
 void pPlotter::GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& value, int histogramsize)
 {
-       if(actualFunction != NULL){
+       if(actualFunction != NULL)
+       {
                double* xval = actualFunction->getX_RealValues();
                double* yval = actualFunction->getY_RealValues();
-
                actualFunction->getScaleY();
-               for(int i = 0; i < actualFunction->getSizePoints();i++){
+               for(int i = 0; i < actualFunction->getSizePoints();i++)
+               {
                        greylevel.push_back(xval[i]);
                        value.push_back(yval[i]/histogramsize);
-               }
-       }
+               } // for
+       } // if
 }
 
 /**
@@ -768,27 +758,23 @@ void pPlotter::GetValuesColorPointsFunction(std::vector<double>& greylevel,
                                                                std::vector<double>& green,
                                                                std::vector<double>& blue)
 {
-
-       if(color_bar != NULL){
-
+       if(color_bar != NULL)
+       {
                std::vector<pColorPoint*> colors;
-        color_bar->getAddedColorsPointsList(colors);
-
-               for(int i = 0; i < colors.size();i++){
-                       pColorPoint* pcolor = colors[i];
-
+      color_bar->getAddedColorsPointsList(colors);
+               for(int i = 0; i < colors.size();i++)
+               {
+                       pColorPoint* pcolor     = colors[i];
                        greylevel.push_back(pcolor->getRealX());
-                       wxColour colour = pcolor->getColor();
-                       
-                       double _red = (double)(colour.Red())/255.0;
-                       double _green = (double)(colour.Green())/255.0;
-                       double _blue = (double)(colour.Blue())/255.0;
-
+                       wxColour colour                 = pcolor->getColor();
+                       double _red                     = (double)(colour.Red())/255.0;
+                       double _green                   = (double)(colour.Green())/255.0;
+                       double _blue                    = (double)(colour.Blue())/255.0;
                        red.push_back(_red);
                        green.push_back(_green);
                        blue.push_back(_blue);
-               }               
-       }
+               } // for
+       } // if
 }