]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mBarRange.h
#3317 creaMaracasVisu Feature New Normal - plane information inf viewerNV
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / pPlotter / mBarRange.h
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26
27
28 #ifndef __mBAR__RANGE__
29 #define __mBAR__RANGE__
30
31
32 //-----------------------------------------------------------------------------
33 // Includes
34 //-----------------------------------------------------------------------------
35 #include "wx/colordlg.h"
36
37
38 // ----------------------------------------------------------------------------
39 // wx headers inclusion.
40 // For compilers that support precompilation, includes <wx/wx.h>.
41 // ----------------------------------------------------------------------------
42 #include <wx/wxprec.h>
43 #ifdef __BORLANDC__
44 #pragma hdrstop
45 #endif
46 #ifndef WX_PRECOMP
47 #include <wx/wx.h>
48 #endif
49 #include "marTypes.h"
50
51 //----------------------------------------------------------------------------
52 //DECLARING THE NEW EVENT
53 //wxEVT_TSBAR= event of the two side bar
54 //----------------------------------------------------------------------------
55
56 BEGIN_DECLARE_EVENT_TYPES()
57         DECLARE_EVENT_TYPE(wxEVT_TSBAR,-1) 
58         DECLARE_EVENT_TYPE(wxEVT_TSBAR_ACTUAL,-1)
59 //      DECLARE_EXPORTED_EVENT_TYPE(MARACASVISULIB_EXPORTS,wxEVT_TSBAR_ACTUAL,-1)
60 //      extern creaMaracasVisu_EXPORT const wxEventType wxEVT_TSBAR_ACTUAL;
61         DECLARE_EVENT_TYPE(wxEVT_TSBAR_START,-1)
62         DECLARE_EVENT_TYPE(wxEVT_TSBAR_END,-1)
63         DECLARE_EVENT_TYPE(wxEVT_TSBAR_MOVED,-1)
64         DECLARE_EVENT_TYPE(wxEVT_SELECTION_END,-1)
65 END_DECLARE_EVENT_TYPES()
66
67
68
69
70 //-------------------------------------------------------------------------------------------------------------
71 // Enum declarations
72 //-------------------------------------------------------------------------------------------------------------
73 /** Command IDs used by pColorPoint */
74 enum
75 {
76         cntID_CHANGE_COLOR = 7000,
77         cntID_ENABLE_ACTUAL,    
78         cntID_MOVABLE_ACTUAL_BAR,
79 };
80
81
82 class creaMaracasVisu_EXPORT mBarRange :public  wxPanel{
83 //EED-2019-10-25 class creaMaracasVisu_EXPORT mBarRange :public  wxScrolledWindow{
84 public:
85         //------------------------------------
86         //Constructors & Destructors
87         //------------------------------------
88         mBarRange(wxWindow *parent, int w, int h);
89         ~mBarRange();
90         //------------------------------------
91         // Bar Methods
92         //------------------------------------
93         void Refresh(bool eraseBackground = true, const wxRect* rect = NULL);
94         void OnPaint( wxPaintEvent &WXUNUSED(event) );
95         void OnSize( wxSizeEvent &WXUNUSED(event) );
96         void RefreshHorizontalView();
97         void RefreshVerticalView();
98         void RefreshForce();
99         void OnMouseMove(wxMouseEvent& event );
100         void onKey(wxKeyEvent& event);
101
102         void DrawBar();
103         //------------------------------------
104         // Getters & Setters
105         //------------------------------------
106         //Actual triangle
107         int GetPixelActual();
108         void SetPixelActual(int i);
109
110         //Start of the bar
111         int GetPixelStart();
112         void SetPixelStart(int i);
113
114         //End of the bar
115         int GetPixelEnd();
116         void SetPixelEnd(int i);
117
118         //Logical Max
119         double GetMax();
120         void SetMax(double i);
121
122         //Logical Min
123         double GetMin();
124         void SetMin(double i);
125
126         //Rectangule Height
127         int GetHeight();
128         void SetHeight(int h);
129
130         //Width
131         int GetWidth();
132         void SetWidth(int w);
133
134         int filtreValue(int value);
135         
136         //Logical Start
137         int GetStart();
138         void SetStart(int newstart);
139
140         //Logical End
141         int GetEnd();
142         void SetEnd(int newend);
143
144         //logical actual
145         int GetActual();
146         void SetActual(int newactual);
147
148
149         //The triangles half width managment
150         int GetTrianglesHalfWidth();
151         void SetTrianglesHalfWidth(int nwTriHalfWidth);
152         
153
154         //Orientation (false for vertical, true is default for horizontal)
155         bool GetOrientation();
156         void SetOrientation(bool orientation);
157
158         //Manage the property of the actual triangle to be between de start and the end
159         bool GetInRangeProperty();
160         void SetInRangeProperty(bool in);
161
162         //Inform if the actual triangle is between the start and the end triangles
163         bool IsActualInRange();
164
165         /*
166         * Sets the property for viewing or not the bar labels information
167         */
168         void setVisibleLabels (bool setVisible);
169
170         /*
171         * Sets the property for viewing or not the bar labels information
172         * return _visibleLables The state of visible labels or not 
173         */
174         bool getIfVisibleLabels ();
175
176         /*
177         * Sets the represented minimum and maximunm values
178         * param minRealValue The minimum represented value (real value)
179         * param maxRealValue The maximum represented value (real value)
180         */
181         void setRepresentedValues(double minRealValue,double maxRealValue);
182
183         /**
184         * Sets the device start drawing left-superior (pixel) start point 
185         * param deviceStart_x Pixel start for x-coord
186         * param deviceStart_y Pixel start for y-coord
187         */
188         void setDeviceBlitStart ( wxCoord deviceStart_x, wxCoord deviceStart_y );
189
190
191         /*
192         * Set active state 
193         * param activeNow The new state
194         */
195         void setActiveStateTo (bool activeNow);
196         
197         /*
198         * Gets the active state of the bar
199         *  return isActive The actual state
200         */
201         bool isActive();
202
203         /*
204         * Gets the real-x value to draw a vertical line
205         * return realX_vertical_line The real x value for the vertical line
206         */
207         int     getRealX_vertical_line();
208
209         /*
210         * Sets the real-x value to draw a vertical line
211         * param realX_vertical_line The new real x value for the vertical line
212         */
213         void setRealX_vertical_line(int newReal_x);
214
215         //*******************************************************************************************************
216         // Event methods
217         //*******************************************************************************************************
218
219         /**
220         * Shows the popup menu 
221         */
222         void onShowPopupMenu (wxMouseEvent& event);
223         /**
224         * Reacts to the cntID_CHANGE_COLOR wxCommandEvent and adds a color degrade point to the color bar.
225         * param & anEvent The wxCommandEvent actioned event 
226         */
227         void onChangePartColor ( wxCommandEvent& anEvent );
228
229
230         /**
231         * Reacts to the cntID_ENABLE_ACTUAL wxCommandEvent enables the actual to be between the the range.
232         * param & anEvent The wxCommandEvent actioned event 
233         */
234         void onEnableRange_Actual ( wxCommandEvent& anEvent );
235
236         /**
237         * Reacts to the cntID_MOVABLE_ACTUAL_BAR wxCommandEvent by enabling or disabling the property of moving the actual triangle with the bar, just when it is inside of it.
238         * param & anEvent The wxCommandEvent actioned event 
239         */
240         void onMovable_ActualWithBar ( wxCommandEvent& anEvent );
241
242         /*
243         * Gets the device value form the end of this panel to the end of the drawing area in the device in pixels
244         * return deviceEndMargin The value asigned to the right margin
245         */
246         int     getDeviceEndX();
247         
248
249         /*
250         * Sets the new device (deviceEndMargin) value form the end of this panel to the end of the drawing area in the device
251         * param newDeviceEnd_pixels The new pixel value to asign to the right(horizontal view), underneath(vertical view) margin in pixels
252         */
253         void setDeviceEndMargin(int newDeviceEnd_pixels);
254
255         /*
256         * Gets the last clickedX pixel coord inside the bar with respect to the container panel.
257         * return clickedX The x-coord pixel value
258         */
259         int getClickedX();
260
261         /*
262         * Sets the last clickedX pixel coord inside the bar with respect to the container panel.
263         * param nwClickX The x-coord pixel value
264         */
265         void setClickedX(int nwClickX);
266
267         /*
268         * Gets the start porcentage with respect to the represented values of the bar
269         * return The porcentage represented by the start  showing point
270         */
271         float getStartShowPorcentage();
272
273         /*
274         * Gets the end porcentage with respect to the represented values of the bar
275         * return The porcentage represented by the end showing point
276         */
277         float getEndShowPorcentage();
278
279         /*
280         * Gets the actual porcentage with respect to the represented values of the bar
281         * return The porcentage represented by the actual  showing point
282         */
283         float getActualShowPorcentage();
284
285         /*
286         * Gets the logic value of a pixel point that comes in the coords of the container panel.
287     * param thePixel Is the pixel to convert
288         * return Is the correspondig value to the given pixel-value in logic bar coords
289         */
290         int getLogicValueofPixel(int thePixel);
291
292
293         /*
294         * Sets the condition for knowing if the actual triangle is being drawed or not
295         * param drawActual The condition to set for drawing or not the actual control (true for drawing)
296         */
297         void setIfWithActualDrawed(bool drawActual);
298
299         /*
300         * Gets the condition for knowing if the actual triangle is being drawed or not
301         * return withActualDrawed The condition for drawing or not the actual control
302         */
303         bool getIfWithActualDrawed();
304
305         /*
306         * Method that creates and send the given id-event to the event handler
307         * param theEventType Is the event id type identification for generating the event
308         */
309         void createAndSendEvent(WXTYPE theEventType);
310
311         /*
312         * Sets the background color od the bar
313         * theColor The color to set to the backgroundColor
314         */
315         void setBackgroundColor(wxColour theColor);
316
317         /*
318         * Sets the guide line color
319         * param theNwGuideLineColor The color to set to the guideLineColor
320         */
321         void setGuideLineColour(wxColour theNwGuideLineColor);
322
323
324         /*
325         * Gets the guide line color
326         * return guideLineColor The color of the guideLine
327         */
328         wxColour getGuideLineColour();
329
330         void onLeftClicDown(wxMouseEvent& event );
331
332         void onLeftClickUp(wxMouseEvent& event );
333
334
335 private:
336         //Rectangle width
337         int                        _w;
338         //Rectangle Height
339         int                        _h;
340         //Actual value
341         int                        _actual;
342         //Start of the rectangule
343         int                        _start;
344         //End of the rectangule
345         int                        _end;
346         //Logical Max
347         double                    _max;
348         //Logical Min
349         double                     _min;
350         //Initial point when moving the rectangule bar according to bar reference 
351         int                                                _initialPoint;
352         /*
353         * Represents the id of the selected moving part of the bar where:
354         * 1 is for Start triangle, 2 for end triangle, 3 for actual triangle and 4 for the bar
355         */
356         int                                                _selectionMoveId;
357
358         //orientation of the rectangle is true when is horizontal and is the default value
359         bool                                            _orientation;
360
361         /*
362         * The property for identifying if the actual triangle needs to be or not between the limit triangles
363         */
364         bool                                            _in_rangeProperty;
365
366         /*
367         * The property for setting the acutal triangle to move with the bar keeping proportions with the limits
368         */
369         bool                                            _moveActualWithBar;
370
371         /*
372         * The property for setting visible or not the bar labels information
373         */
374         bool                                       _visibleLables;
375         /*
376         * X-Coord for left-superior device visible drawing
377         */
378         wxCoord                                         deviceStart_x;  
379
380         /*
381         * Y-Coord for left-superior device visible drawing
382         */
383         wxCoord                                         deviceStart_y;
384
385         /*
386         * X-Coord for right device margin
387         */
388         wxCoord                                         deviceEndMargin;        
389
390         /*
391         * Represents the active state of the bar
392         */
393         bool activeState;
394
395         /*
396         * Represents the option of activating or not the drawing of the actual triangle, that in default value is true for drawing it
397         * The dafault value is true (use the actual triangle)
398         */
399         bool withActualDrawed;
400
401         /*
402         * The colour of the start triangle
403         */          
404         wxColour start_Colour;
405
406         /*
407         * The colour of the actual triangle
408         */          
409         wxColour actual_Colour;
410
411         /*
412         * The colour of the end triangle
413         */          
414         wxColour end_Colour;
415
416         /*
417         * The colour of the bar
418         */          
419         wxColour bar_Colour;
420         /*
421         * Represents the real-x value to draw a vertical line
422         */
423         int                     realX_vertical_line;
424
425         /*
426         * Represents the last clickedX coord inside the bar.
427         */
428         int                     clickedX;
429
430         /*
431         * Represents the orientation for the numbers view label in the information bitmap.
432         * Where  -4:left, -6:right, -8:up, -2: down respect to the bar
433         */
434         int                     numberOrientation;      
435         /*
436         * Represents the logic initial reference start point used for dragging
437         */
438         int                     logicInitial_start;
439         /*
440         * Represents the logic intial reference end point used for dragging
441         */
442         int                     logicInitial_end;
443         /*
444         * Represents the logic initial reference actual point used for dragging
445         */
446         int                     logicInitial_actual;
447
448         /*
449         * Represents the pixel value assigned to as half of the width of the triangles 
450         */
451         int                     trianglesHalfWidth;
452
453         /*
454         * Represents the background color of the panel (this) where the bar is. The default color is the imediately parent background color
455         */
456         wxColour        backgroundColor;
457         /*
458         * Represents the color of the dot-line use as guides. The default color is RED. 
459         */
460         wxColour        guideLineColor;
461
462
463         bool acceptedClick;
464         
465
466         /*
467         * The color bar pop menu
468         */
469         wxMenu b_popmenu; 
470         //the bar bitmap device
471         wxBitmap        *_bitmap_bar;
472         //the info bitmap device 
473         wxBitmap        *_bitmap_info;
474
475
476         DECLARE_CLASS(BarRange)
477
478         // any class wishing to process wxWindows events must use this macro
479         DECLARE_EVENT_TABLE()
480 };
481
482
483
484 #endif
485
486
487