1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
28 #ifndef __mBAR__RANGE__
29 #define __mBAR__RANGE__
32 //-----------------------------------------------------------------------------
34 //-----------------------------------------------------------------------------
35 #include "wx/colordlg.h"
38 // ----------------------------------------------------------------------------
39 // wx headers inclusion.
40 // For compilers that support precompilation, includes <wx/wx.h>.
41 // ----------------------------------------------------------------------------
42 #include <wx/wxprec.h>
51 //----------------------------------------------------------------------------
52 //DECLARING THE NEW EVENT
53 //wxEVT_TSBAR= event of the two side bar
54 //----------------------------------------------------------------------------
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()
70 //-------------------------------------------------------------------------------------------------------------
72 //-------------------------------------------------------------------------------------------------------------
73 /** Command IDs used by pColorPoint */
76 cntID_CHANGE_COLOR = 7000,
78 cntID_MOVABLE_ACTUAL_BAR,
82 class creaMaracasVisu_EXPORT mBarRange :public wxPanel{
83 //EED-2019-10-25 class creaMaracasVisu_EXPORT mBarRange :public wxScrolledWindow{
85 //------------------------------------
86 //Constructors & Destructors
87 //------------------------------------
88 mBarRange(wxWindow *parent, int w, int h);
90 //------------------------------------
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();
99 void OnMouseMove(wxMouseEvent& event );
100 void onKey(wxKeyEvent& event);
103 //------------------------------------
105 //------------------------------------
107 int GetPixelActual();
108 void SetPixelActual(int i);
112 void SetPixelStart(int i);
116 void SetPixelEnd(int i);
120 void SetMax(double i);
124 void SetMin(double i);
128 void SetHeight(int h);
132 void SetWidth(int w);
134 int filtreValue(int value);
138 void SetStart(int newstart);
142 void SetEnd(int newend);
146 void SetActual(int newactual);
149 //The triangles half width managment
150 int GetTrianglesHalfWidth();
151 void SetTrianglesHalfWidth(int nwTriHalfWidth);
154 //Orientation (false for vertical, true is default for horizontal)
155 bool GetOrientation();
156 void SetOrientation(bool orientation);
158 //Manage the property of the actual triangle to be between de start and the end
159 bool GetInRangeProperty();
160 void SetInRangeProperty(bool in);
162 //Inform if the actual triangle is between the start and the end triangles
163 bool IsActualInRange();
166 * Sets the property for viewing or not the bar labels information
168 void setVisibleLabels (bool setVisible);
171 * Sets the property for viewing or not the bar labels information
172 * return _visibleLables The state of visible labels or not
174 bool getIfVisibleLabels ();
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)
181 void setRepresentedValues(double minRealValue,double maxRealValue);
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
188 void setDeviceBlitStart ( wxCoord deviceStart_x, wxCoord deviceStart_y );
193 * param activeNow The new state
195 void setActiveStateTo (bool activeNow);
198 * Gets the active state of the bar
199 * return isActive The actual state
204 * Gets the real-x value to draw a vertical line
205 * return realX_vertical_line The real x value for the vertical line
207 int getRealX_vertical_line();
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
213 void setRealX_vertical_line(int newReal_x);
215 //*******************************************************************************************************
217 //*******************************************************************************************************
220 * Shows the popup menu
222 void onShowPopupMenu (wxMouseEvent& event);
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
227 void onChangePartColor ( wxCommandEvent& anEvent );
231 * Reacts to the cntID_ENABLE_ACTUAL wxCommandEvent enables the actual to be between the the range.
232 * param & anEvent The wxCommandEvent actioned event
234 void onEnableRange_Actual ( wxCommandEvent& anEvent );
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
240 void onMovable_ActualWithBar ( wxCommandEvent& anEvent );
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
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
253 void setDeviceEndMargin(int newDeviceEnd_pixels);
256 * Gets the last clickedX pixel coord inside the bar with respect to the container panel.
257 * return clickedX The x-coord pixel value
262 * Sets the last clickedX pixel coord inside the bar with respect to the container panel.
263 * param nwClickX The x-coord pixel value
265 void setClickedX(int nwClickX);
268 * Gets the start porcentage with respect to the represented values of the bar
269 * return The porcentage represented by the start showing point
271 float getStartShowPorcentage();
274 * Gets the end porcentage with respect to the represented values of the bar
275 * return The porcentage represented by the end showing point
277 float getEndShowPorcentage();
280 * Gets the actual porcentage with respect to the represented values of the bar
281 * return The porcentage represented by the actual showing point
283 float getActualShowPorcentage();
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
290 int getLogicValueofPixel(int thePixel);
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)
297 void setIfWithActualDrawed(bool drawActual);
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
303 bool getIfWithActualDrawed();
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
309 void createAndSendEvent(WXTYPE theEventType);
312 * Sets the background color od the bar
313 * theColor The color to set to the backgroundColor
315 void setBackgroundColor(wxColour theColor);
318 * Sets the guide line color
319 * param theNwGuideLineColor The color to set to the guideLineColor
321 void setGuideLineColour(wxColour theNwGuideLineColor);
325 * Gets the guide line color
326 * return guideLineColor The color of the guideLine
328 wxColour getGuideLineColour();
330 void onLeftClicDown(wxMouseEvent& event );
332 void onLeftClickUp(wxMouseEvent& event );
342 //Start of the rectangule
344 //End of the rectangule
350 //Initial point when moving the rectangule bar according to bar reference
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
356 int _selectionMoveId;
358 //orientation of the rectangle is true when is horizontal and is the default value
362 * The property for identifying if the actual triangle needs to be or not between the limit triangles
364 bool _in_rangeProperty;
367 * The property for setting the acutal triangle to move with the bar keeping proportions with the limits
369 bool _moveActualWithBar;
372 * The property for setting visible or not the bar labels information
376 * X-Coord for left-superior device visible drawing
378 wxCoord deviceStart_x;
381 * Y-Coord for left-superior device visible drawing
383 wxCoord deviceStart_y;
386 * X-Coord for right device margin
388 wxCoord deviceEndMargin;
391 * Represents the active state of the bar
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)
399 bool withActualDrawed;
402 * The colour of the start triangle
404 wxColour start_Colour;
407 * The colour of the actual triangle
409 wxColour actual_Colour;
412 * The colour of the end triangle
417 * The colour of the bar
421 * Represents the real-x value to draw a vertical line
423 int realX_vertical_line;
426 * Represents the last clickedX coord inside the bar.
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
434 int numberOrientation;
436 * Represents the logic initial reference start point used for dragging
438 int logicInitial_start;
440 * Represents the logic intial reference end point used for dragging
442 int logicInitial_end;
444 * Represents the logic initial reference actual point used for dragging
446 int logicInitial_actual;
449 * Represents the pixel value assigned to as half of the width of the triangles
451 int trianglesHalfWidth;
454 * Represents the background color of the panel (this) where the bar is. The default color is the imediately parent background color
456 wxColour backgroundColor;
458 * Represents the color of the dot-line use as guides. The default color is RED.
460 wxColour guideLineColor;
467 * The color bar pop menu
470 //the bar bitmap device
471 wxBitmap *_bitmap_bar;
472 //the info bitmap device
473 wxBitmap *_bitmap_info;
476 DECLARE_CLASS(BarRange)
478 // any class wishing to process wxWindows events must use this macro
479 DECLARE_EVENT_TABLE()