]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mBarRange.cxx
#3347 creaMaracasVisu Bug New Normal - ViewerMPR2D Reset back position when set...
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / pPlotter / mBarRange.cxx
index fc10c87e1f46234dae366cb8fb8549c6b803659a..42db92071198e13c6a40271af51cb959ae9c1972 100644 (file)
@@ -29,7 +29,6 @@
 
 #include "mBarRange.h"
 
-
 //const wxEventType wxEVT_TSBAR = wxNewEventType();
 
 DEFINE_EVENT_TYPE(wxEVT_TSBAR)
@@ -39,13 +38,12 @@ DEFINE_EVENT_TYPE(wxEVT_TSBAR_END)
 DEFINE_EVENT_TYPE(wxEVT_TSBAR_MOVED)
 DEFINE_EVENT_TYPE(wxEVT_SELECTION_END)
 
-
-
 //----------------------------------------------------------------------------
 //EVENT TABLE
 //----------------------------------------------------------------------------
 
 IMPLEMENT_CLASS(mBarRange, wxScrolledWindow)
+
 BEGIN_EVENT_TABLE(mBarRange, wxScrolledWindow)
        EVT_PAINT (mBarRange::OnPaint)
        EVT_SIZE  (mBarRange::OnSize)
@@ -70,17 +68,17 @@ END_EVENT_TABLE()
 //CONSTRUCTOR
 //----------------------------------------------------------------------------
 
+//wxDefaultSize
 mBarRange::mBarRange(wxWindow *parent, int w, int h)
-:wxScrolledWindow(parent,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL)
+//EED-2019-10-25 :wxScrolledWindow(parent,-1,wxDefaultPosition, wxSize(60,60) ,wxTAB_TRAVERSAL)
+ :wxPanel(parent,-1,wxDefaultPosition, wxSize(60,60) ,wxTAB_TRAVERSAL)
 {
-       acceptedClick           = true;
-       _bitmap_bar                     = NULL;
+       acceptedClick           =       true;
+       _bitmap_bar                     =       NULL;
        SetWidth (w);
        SetHeight(h);
-       _initialPoint           = 0;
-       trianglesHalfWidth      = 5;
-       
-
+       _initialPoint           =       0;
+       trianglesHalfWidth      =       5;
        // Setting the default parts colors
        start_Colour            =       wxColour(1,0,255,254);
        actual_Colour           =       wxColour(255,255,202);
@@ -88,7 +86,6 @@ mBarRange::mBarRange(wxWindow *parent, int w, int h)
        bar_Colour                      =       wxColour(255,0,255);
        backgroundColor     =   parent ->GetBackgroundColour();
        guideLineColor          =   wxColour(255,0,0);
-
        //actual is in _start and end
        //false means that it could be anywhere
        _moveActualWithBar      =       false;
@@ -96,16 +93,13 @@ mBarRange::mBarRange(wxWindow *parent, int w, int h)
        _selectionMoveId        =       -1;
        realX_vertical_line =   -1;
        activeState                     =       false;
-       _actual=0;
-       deviceEndMargin = 0;
-
+       _actual                         =       0;
+       deviceEndMargin         =       0;
        SetOrientation(true);
        setIfWithActualDrawed(true);
-
        b_popmenu.Append (cntID_CHANGE_COLOR, _("Change Color"), _("Changes the color of the selected part"));
        b_popmenu.Append (cntID_ENABLE_ACTUAL, _("Enable actual in range"), _("Enables/Disables the actual triangle to be or not in range"));
        b_popmenu.Append (cntID_MOVABLE_ACTUAL_BAR, _("Move actual-bar simultaneously"), _("Disables the actual triangle to move with the bar"));
-
        SetSize(w,h);
 }
 
@@ -115,7 +109,10 @@ mBarRange::mBarRange(wxWindow *parent, int w, int h)
 
 mBarRange::~mBarRange()
 {
+       DeletePendingEvents ();
+       RemoveEventHandler ( GetEventHandler() );       
 }
+
 //---------------------------------------------------------------------------
 //Draw bar: vertical or Horizontal
 //---------------------------------------------------------------------------
@@ -125,15 +122,12 @@ void mBarRange::DrawBar()
        if(_orientation)
        {
                SetWindowStyle(wxNO_FULL_REPAINT_ON_RESIZE);
-               _bitmap_bar             = new wxBitmap(_w+1280,_h+100);
+               _bitmap_bar                     = new wxBitmap(_w+1280,_h+100);
                //SIL//_bitmap_info     = new wxBitmap(_w+100+1280, _h+100);
-       }
-       //vertical
-       else
-       {
+       } else {
                SetWindowStyle(wxNO_FULL_REPAINT_ON_RESIZE);
-               _bitmap_bar = new wxBitmap(_h+deviceStart_y+100,_w+1280);
-               _bitmap_info = new wxBitmap(_h+deviceStart_y+100, _w+1280);
+               _bitmap_bar             = new wxBitmap(_h+deviceStart_y+100,_w+1280);
+               _bitmap_info            = new wxBitmap(_h+deviceStart_y+100, _w+1280);
        }
 }
 //----------------------------------------------------------------------------
@@ -149,7 +143,7 @@ bool mBarRange::GetInRangeProperty()
 //----------------------------------------------------------------------------
 void mBarRange::SetInRangeProperty(bool in)
 {
-       _in_rangeProperty=in;
+       _in_rangeProperty = in;
 }
 //----------------------------------------------------------------------------
 //the information about the actual triangle in range or not, true if is between start and end
@@ -184,6 +178,7 @@ int mBarRange::GetPixelStart()
 {
        return ((_start - _min)*(_w-deviceEndMargin))/(_max - _min);    
 }
+
 //----------------------------------------------------------------------------
 // param i: value in pixels
 //----------------------------------------------------------------------------
@@ -192,6 +187,7 @@ void mBarRange::SetPixelStart(int i)
        _start = _min+((i - deviceStart_x)*( _max - _min))/(_w-deviceEndMargin);
        
 }
+
 //----------------------------------------------------------------------------
 // _actual of the pixel rectangle
 //----------------------------------------------------------------------------
@@ -199,6 +195,7 @@ int mBarRange::GetPixelActual()
 {
        return ((_actual - _min)*(_w-deviceEndMargin))/(_max - _min);
 }
+
 //----------------------------------------------------------------------------
 // param i: value in pixels
 //----------------------------------------------------------------------------
@@ -206,6 +203,7 @@ void mBarRange::SetPixelActual(int i)
 {
        _actual = _min + (i-deviceStart_x)*(_max-_min)/(_w-deviceEndMargin);
 }
+
 //----------------------------------------------------------------------------
 // _end of the pixel rectangle
 //----------------------------------------------------------------------------
@@ -213,6 +211,7 @@ int mBarRange::GetPixelEnd()
 {
        return ((_end - _min)*(_w-deviceEndMargin))/(_max - _min);
 }
+
 //----------------------------------------------------------------------------
 // param i: value in pixels to be converted to real logical value
 //----------------------------------------------------------------------------
@@ -220,10 +219,10 @@ void mBarRange::SetPixelEnd(int i)
 {
        _end = _min + (i-deviceStart_x)*(_max-_min)/(_w-deviceEndMargin);
 }
+
 //----------------------------------------------------------------------------
 // Logical max of the triangle
 //----------------------------------------------------------------------------
-
 double mBarRange::GetMax()
 {
        return _max;
@@ -387,7 +386,8 @@ void mBarRange::OnSize( wxSizeEvent &WXUNUSED(event) )
 
 void mBarRange::Refresh(bool eraseBackground, const wxRect* rect)
 {
-       wxScrolledWindow::Refresh(false);
+//EED2019-10-25        wxScrolledWindow::Refresh(false);
+       wxPanel::Refresh(false);
 }
 
 
@@ -839,9 +839,9 @@ void mBarRange::OnMouseMove(wxMouseEvent& event )
                        if (barHeight <=_h)
                        {
                                bool in_StartTri = (clickedX>=GetPixelStart()-5+ deviceStart_x) && (clickedX<=GetPixelStart()+5+ deviceStart_x);
-                               bool in_EndTri = (clickedX>=GetPixelEnd()-5+ deviceStart_x) && (clickedX<=GetPixelEnd()+5+ deviceStart_x);
-                               bool in_actualT= withActualDrawed && (clickedX>=GetPixelActual()-5+ deviceStart_x) && (clickedX<=GetPixelActual()+5+ deviceStart_x);
-                               bool in_movingBar = (clickedX>GetPixelStart()+5+ deviceStart_x) && (clickedX<GetPixelEnd()-5+ deviceStart_x);
+                               bool in_EndTri   = (clickedX>=GetPixelEnd()-5+ deviceStart_x) && (clickedX<=GetPixelEnd()+5+ deviceStart_x);
+                               bool in_actualT  = withActualDrawed && (clickedX>=GetPixelActual()-5+ deviceStart_x) && (clickedX<=GetPixelActual()+5+ deviceStart_x);
+                               bool in_movingBar= (clickedX>GetPixelStart()+5+ deviceStart_x) && (clickedX<GetPixelEnd()-5+ deviceStart_x);
 
                                if( in_actualT )
                                        _selectionMoveId = 3;
@@ -852,9 +852,7 @@ void mBarRange::OnMouseMove(wxMouseEvent& event )
                                else if( in_movingBar )
                                        _selectionMoveId = 4;
                        }
-               }
-               else
-               {
+               } else {
                        if(acceptedClick)
                        {
                                //is in start triagle
@@ -1041,10 +1039,10 @@ void mBarRange::OnMouseMove(wxMouseEvent& event )
 */
 void mBarRange :: setRepresentedValues ( double minRealValue, double maxRealValue)
 {
-       _min = minRealValue;
-       _max = maxRealValue;
-       _start=_min;
-       _end=_max;
+       _min    = minRealValue;
+       _max    = maxRealValue;
+       _start  =_min;
+       _end    =_max;
 }
 
 /*
@@ -1081,9 +1079,7 @@ void mBarRange :: setVisibleLabels ( bool setVisibleLB )
                                SetPixelStart(deviceStart_x);
                                SetPixelEnd(_w+deviceStart_x);
                                SetPixelActual(deviceStart_x);
-                       }
-                       else
-                       {
+                       } else {
                                SetPixelStart(deviceStart_x);
                                SetPixelEnd(_h+deviceStart_x);
                                SetPixelActual(deviceStart_x);
@@ -1117,10 +1113,10 @@ void mBarRange :: setVisibleLabels ( bool setVisibleLB )
 
                                if (getClickedX()<=_h)
                                {                                               
-                                       bool in_StartTri = (clickedX>=GetPixelStart()-5+ deviceStart_x) && (clickedX<=GetPixelStart()+5+ deviceStart_x);
-                                       bool in_EndTri = (clickedX>=GetPixelEnd()-5+ deviceStart_x) && (clickedX<=GetPixelEnd()+5+ deviceStart_x);
-                                       bool in_actualT= (clickedX>=GetPixelActual()-5+ deviceStart_x) && (clickedX<=GetPixelActual()+5+ deviceStart_x);
-                                       bool in_movingBar = (clickedX>GetPixelStart()+5+ deviceStart_x) && (clickedX<GetPixelEnd()-5+ deviceStart_x);
+                                       bool in_StartTri        = (clickedX>=GetPixelStart()-5+ deviceStart_x) && (clickedX<=GetPixelStart()+5+ deviceStart_x);
+                                       bool in_EndTri          = (clickedX>=GetPixelEnd()-5+ deviceStart_x) && (clickedX<=GetPixelEnd()+5+ deviceStart_x);
+                                       bool in_actualT         = (clickedX>=GetPixelActual()-5+ deviceStart_x) && (clickedX<=GetPixelActual()+5+ deviceStart_x);
+                                       bool in_movingBar       = (clickedX>GetPixelStart()+5+ deviceStart_x) && (clickedX<GetPixelEnd()-5+ deviceStart_x);
 
                                        if(in_StartTri)
                                                _selectionMoveId = 1;