]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mBarRange.h
#2490 creaMaracasVisu Feature New High - Histogram Interaction
[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  wxScrolledWindow{
83 public:
84         //------------------------------------
85         //Constructors & Destructors
86         //------------------------------------
87         mBarRange(wxWindow *parent, int w, int h);
88         ~mBarRange();
89         //------------------------------------
90         // Bar Methods
91         //------------------------------------
92         void Refresh(bool eraseBackground = true, const wxRect* rect = NULL);
93         void OnPaint( wxPaintEvent &WXUNUSED(event) );
94         void OnSize( wxSizeEvent &WXUNUSED(event) );
95         void RefreshHorizontalView();
96         void RefreshVerticalView();
97         void RefreshForce();
98         void OnMouseMove(wxMouseEvent& event );
99         void onKey(wxKeyEvent& event);
100
101         void DrawBar();
102         //------------------------------------
103         // Getters & Setters
104         //------------------------------------
105         //Actual triangle
106         int GetPixelActual();
107         void SetPixelActual(int i);
108
109         //Start of the bar
110         int GetPixelStart();
111         void SetPixelStart(int i);
112
113         //End of the bar
114         int GetPixelEnd();
115         void SetPixelEnd(int i);
116
117         //Logical Max
118         double GetMax();
119         void SetMax(double i);
120
121         //Logical Min
122         double GetMin();
123         void SetMin(double i);
124
125         //Rectangule Height
126         int GetHeight();
127         void SetHeight(int h);
128
129         //Width
130         int GetWidth();
131         void SetWidth(int w);
132
133         int filtreValue(int value);
134         
135         //Logical Start
136         int GetStart();
137         void SetStart(int newstart);
138
139         //Logical End
140         int GetEnd();
141         void SetEnd(int newend);
142
143         //logical actual
144         int GetActual();
145         void SetActual(int newactual);
146
147
148         //The triangles half width managment
149         int GetTrianglesHalfWidth();
150         void SetTrianglesHalfWidth(int nwTriHalfWidth);
151         
152
153         //Orientation (false for vertical, true is default for horizontal)
154         bool GetOrientation();
155         void SetOrientation(bool orientation);
156
157         //Manage the property of the actual triangle to be between de start and the end
158         bool GetInRangeProperty();
159         void SetInRangeProperty(bool in);
160
161         //Inform if the actual triangle is between the start and the end triangles
162         bool IsActualInRange();
163
164         /*
165         * Sets the property for viewing or not the bar labels information
166         */
167         void setVisibleLabels (bool setVisible);
168
169         /*
170         * Sets the property for viewing or not the bar labels information
171         * return _visibleLables The state of visible labels or not 
172         */
173         bool getIfVisibleLabels ();
174
175         /*
176         * Sets the represented minimum and maximunm values
177         * param minRealValue The minimum represented value (real value)
178         * param maxRealValue The maximum represented value (real value)
179         */
180         void setRepresentedValues(double minRealValue,double maxRealValue);
181
182         /**
183         * Sets the device start drawing left-superior (pixel) start point 
184         * param deviceStart_x Pixel start for x-coord
185         * param deviceStart_y Pixel start for y-coord
186         */
187         void setDeviceBlitStart ( wxCoord deviceStart_x, wxCoord deviceStart_y );
188
189
190         /*
191         * Set active state 
192         * param activeNow The new state
193         */
194         void setActiveStateTo (bool activeNow);
195         
196         /*
197         * Gets the active state of the bar
198         *  return isActive The actual state
199         */
200         bool isActive();
201
202         /*
203         * Gets the real-x value to draw a vertical line
204         * return realX_vertical_line The real x value for the vertical line
205         */
206         int     getRealX_vertical_line();
207
208         /*
209         * Sets the real-x value to draw a vertical line
210         * param realX_vertical_line The new real x value for the vertical line
211         */
212         void setRealX_vertical_line(int newReal_x);
213
214         //*******************************************************************************************************
215         // Event methods
216         //*******************************************************************************************************
217
218         /**
219         * Shows the popup menu 
220         */
221         void onShowPopupMenu (wxMouseEvent& event);
222         /**
223         * Reacts to the cntID_CHANGE_COLOR wxCommandEvent and adds a color degrade point to the color bar.
224         * param & anEvent The wxCommandEvent actioned event 
225         */
226         void onChangePartColor ( wxCommandEvent& anEvent );
227
228
229         /**
230         * Reacts to the cntID_ENABLE_ACTUAL wxCommandEvent enables the actual to be between the the range.
231         * param & anEvent The wxCommandEvent actioned event 
232         */
233         void onEnableRange_Actual ( wxCommandEvent& anEvent );
234
235         /**
236         * 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.
237         * param & anEvent The wxCommandEvent actioned event 
238         */
239         void onMovable_ActualWithBar ( wxCommandEvent& anEvent );
240
241         /*
242         * Gets the device value form the end of this panel to the end of the drawing area in the device in pixels
243         * return deviceEndMargin The value asigned to the right margin
244         */
245         int     getDeviceEndX();
246         
247
248         /*
249         * Sets the new device (deviceEndMargin) value form the end of this panel to the end of the drawing area in the device
250         * param newDeviceEnd_pixels The new pixel value to asign to the right(horizontal view), underneath(vertical view) margin in pixels
251         */
252         void setDeviceEndMargin(int newDeviceEnd_pixels);
253
254         /*
255         * Gets the last clickedX pixel coord inside the bar with respect to the container panel.
256         * return clickedX The x-coord pixel value
257         */
258         int getClickedX();
259
260         /*
261         * Sets the last clickedX pixel coord inside the bar with respect to the container panel.
262         * param nwClickX The x-coord pixel value
263         */
264         void setClickedX(int nwClickX);
265
266         /*
267         * Gets the start porcentage with respect to the represented values of the bar
268         * return The porcentage represented by the start  showing point
269         */
270         float getStartShowPorcentage();
271
272         /*
273         * Gets the end porcentage with respect to the represented values of the bar
274         * return The porcentage represented by the end showing point
275         */
276         float getEndShowPorcentage();
277
278         /*
279         * Gets the actual porcentage with respect to the represented values of the bar
280         * return The porcentage represented by the actual  showing point
281         */
282         float getActualShowPorcentage();
283
284         /*
285         * Gets the logic value of a pixel point that comes in the coords of the container panel.
286     * param thePixel Is the pixel to convert
287         * return Is the correspondig value to the given pixel-value in logic bar coords
288         */
289         int getLogicValueofPixel(int thePixel);
290
291
292         /*
293         * Sets the condition for knowing if the actual triangle is being drawed or not
294         * param drawActual The condition to set for drawing or not the actual control (true for drawing)
295         */
296         void setIfWithActualDrawed(bool drawActual);
297
298         /*
299         * Gets the condition for knowing if the actual triangle is being drawed or not
300         * return withActualDrawed The condition for drawing or not the actual control
301         */
302         bool getIfWithActualDrawed();
303
304         /*
305         * Method that creates and send the given id-event to the event handler
306         * param theEventType Is the event id type identification for generating the event
307         */
308         void createAndSendEvent(WXTYPE theEventType);
309
310         /*
311         * Sets the background color od the bar
312         * theColor The color to set to the backgroundColor
313         */
314         void setBackgroundColor(wxColour theColor);
315
316         /*
317         * Sets the guide line color
318         * param theNwGuideLineColor The color to set to the guideLineColor
319         */
320         void setGuideLineColour(wxColour theNwGuideLineColor);
321
322
323         /*
324         * Gets the guide line color
325         * return guideLineColor The color of the guideLine
326         */
327         wxColour getGuideLineColour();
328
329         void onLeftClicDown(wxMouseEvent& event );
330
331         void onLeftClickUp(wxMouseEvent& event );
332
333
334 private:
335         //Rectangle width
336         int                        _w;
337         //Rectangle Height
338         int                        _h;
339         //Actual value
340         int                        _actual;
341         //Start of the rectangule
342         int                        _start;
343         //End of the rectangule
344         int                        _end;
345         //Logical Max
346         double                    _max;
347         //Logical Min
348         double                     _min;
349         //Initial point when moving the rectangule bar according to bar reference 
350         int                                                _initialPoint;
351         /*
352         * Represents the id of the selected moving part of the bar where:
353         * 1 is for Start triangle, 2 for end triangle, 3 for actual triangle and 4 for the bar
354         */
355         int                                                _selectionMoveId;
356
357         //orientation of the rectangle is true when is horizontal and is the default value
358         bool                                            _orientation;
359
360         /*
361         * The property for identifying if the actual triangle needs to be or not between the limit triangles
362         */
363         bool                                            _in_rangeProperty;
364
365         /*
366         * The property for setting the acutal triangle to move with the bar keeping proportions with the limits
367         */
368         bool                                            _moveActualWithBar;
369
370         /*
371         * The property for setting visible or not the bar labels information
372         */
373         bool                                       _visibleLables;
374         /*
375         * X-Coord for left-superior device visible drawing
376         */
377         wxCoord                                         deviceStart_x;  
378
379         /*
380         * Y-Coord for left-superior device visible drawing
381         */
382         wxCoord                                         deviceStart_y;
383
384         /*
385         * X-Coord for right device margin
386         */
387         wxCoord                                         deviceEndMargin;        
388
389         /*
390         * Represents the active state of the bar
391         */
392         bool activeState;
393
394         /*
395         * Represents the option of activating or not the drawing of the actual triangle, that in default value is true for drawing it
396         * The dafault value is true (use the actual triangle)
397         */
398         bool withActualDrawed;
399
400         /*
401         * The colour of the start triangle
402         */          
403         wxColour start_Colour;
404
405         /*
406         * The colour of the actual triangle
407         */          
408         wxColour actual_Colour;
409
410         /*
411         * The colour of the end triangle
412         */          
413         wxColour end_Colour;
414
415         /*
416         * The colour of the bar
417         */          
418         wxColour bar_Colour;
419         /*
420         * Represents the real-x value to draw a vertical line
421         */
422         int                     realX_vertical_line;
423
424         /*
425         * Represents the last clickedX coord inside the bar.
426         */
427         int                     clickedX;
428
429         /*
430         * Represents the orientation for the numbers view label in the information bitmap.
431         * Where  -4:left, -6:right, -8:up, -2: down respect to the bar
432         */
433         int                     numberOrientation;      
434         /*
435         * Represents the logic initial reference start point used for dragging
436         */
437         int                     logicInitial_start;
438         /*
439         * Represents the logic intial reference end point used for dragging
440         */
441         int                     logicInitial_end;
442         /*
443         * Represents the logic initial reference actual point used for dragging
444         */
445         int                     logicInitial_actual;
446
447         /*
448         * Represents the pixel value assigned to as half of the width of the triangles 
449         */
450         int                     trianglesHalfWidth;
451
452         /*
453         * Represents the background color of the panel (this) where the bar is. The default color is the imediately parent background color
454         */
455         wxColour        backgroundColor;
456         /*
457         * Represents the color of the dot-line use as guides. The default color is RED. 
458         */
459         wxColour        guideLineColor;
460
461
462         bool acceptedClick;
463         
464
465         /*
466         * The color bar pop menu
467         */
468         wxMenu b_popmenu; 
469         //the bar bitmap device
470         wxBitmap        *_bitmap_bar;
471         //the info bitmap device 
472         wxBitmap        *_bitmap_info;
473         DECLARE_CLASS(BarRange)
474         // any class wishing to process wxWindows events must use this macro
475         DECLARE_EVENT_TABLE()
476 };
477
478
479
480 #endif
481
482
483