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 wxScrolledWindow{
84 //------------------------------------
85 //Constructors & Destructors
86 //------------------------------------
87 mBarRange(wxWindow *parent, int w, int h);
89 //------------------------------------
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();
98 void OnMouseMove(wxMouseEvent& event );
99 void onKey(wxKeyEvent& event);
102 //------------------------------------
104 //------------------------------------
106 int GetPixelActual();
107 void SetPixelActual(int i);
111 void SetPixelStart(int i);
115 void SetPixelEnd(int i);
119 void SetMax(double i);
123 void SetMin(double i);
127 void SetHeight(int h);
131 void SetWidth(int w);
133 int filtreValue(int value);
137 void SetStart(int newstart);
141 void SetEnd(int newend);
145 void SetActual(int newactual);
148 //The triangles half width managment
149 int GetTrianglesHalfWidth();
150 void SetTrianglesHalfWidth(int nwTriHalfWidth);
153 //Orientation (false for vertical, true is default for horizontal)
154 bool GetOrientation();
155 void SetOrientation(bool orientation);
157 //Manage the property of the actual triangle to be between de start and the end
158 bool GetInRangeProperty();
159 void SetInRangeProperty(bool in);
161 //Inform if the actual triangle is between the start and the end triangles
162 bool IsActualInRange();
165 * Sets the property for viewing or not the bar labels information
167 void setVisibleLabels (bool setVisible);
170 * Sets the property for viewing or not the bar labels information
171 * return _visibleLables The state of visible labels or not
173 bool getIfVisibleLabels ();
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)
180 void setRepresentedValues(double minRealValue,double maxRealValue);
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
187 void setDeviceBlitStart ( wxCoord deviceStart_x, wxCoord deviceStart_y );
192 * param activeNow The new state
194 void setActiveStateTo (bool activeNow);
197 * Gets the active state of the bar
198 * return isActive The actual state
203 * Gets the real-x value to draw a vertical line
204 * return realX_vertical_line The real x value for the vertical line
206 int getRealX_vertical_line();
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
212 void setRealX_vertical_line(int newReal_x);
214 //*******************************************************************************************************
216 //*******************************************************************************************************
219 * Shows the popup menu
221 void onShowPopupMenu (wxMouseEvent& event);
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
226 void onChangePartColor ( wxCommandEvent& anEvent );
230 * Reacts to the cntID_ENABLE_ACTUAL wxCommandEvent enables the actual to be between the the range.
231 * param & anEvent The wxCommandEvent actioned event
233 void onEnableRange_Actual ( wxCommandEvent& anEvent );
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
239 void onMovable_ActualWithBar ( wxCommandEvent& anEvent );
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
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
252 void setDeviceEndMargin(int newDeviceEnd_pixels);
255 * Gets the last clickedX pixel coord inside the bar with respect to the container panel.
256 * return clickedX The x-coord pixel value
261 * Sets the last clickedX pixel coord inside the bar with respect to the container panel.
262 * param nwClickX The x-coord pixel value
264 void setClickedX(int nwClickX);
267 * Gets the start porcentage with respect to the represented values of the bar
268 * return The porcentage represented by the start showing point
270 float getStartShowPorcentage();
273 * Gets the end porcentage with respect to the represented values of the bar
274 * return The porcentage represented by the end showing point
276 float getEndShowPorcentage();
279 * Gets the actual porcentage with respect to the represented values of the bar
280 * return The porcentage represented by the actual showing point
282 float getActualShowPorcentage();
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
289 int getLogicValueofPixel(int thePixel);
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)
296 void setIfWithActualDrawed(bool drawActual);
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
302 bool getIfWithActualDrawed();
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
308 void createAndSendEvent(WXTYPE theEventType);
311 * Sets the background color od the bar
312 * theColor The color to set to the backgroundColor
314 void setBackgroundColor(wxColour theColor);
317 * Sets the guide line color
318 * param theNwGuideLineColor The color to set to the guideLineColor
320 void setGuideLineColour(wxColour theNwGuideLineColor);
324 * Gets the guide line color
325 * return guideLineColor The color of the guideLine
327 wxColour getGuideLineColour();
329 void onLeftClicDown(wxMouseEvent& event );
331 void onLeftClickUp(wxMouseEvent& event );
341 //Start of the rectangule
343 //End of the rectangule
349 //Initial point when moving the rectangule bar according to bar reference
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
355 int _selectionMoveId;
357 //orientation of the rectangle is true when is horizontal and is the default value
361 * The property for identifying if the actual triangle needs to be or not between the limit triangles
363 bool _in_rangeProperty;
366 * The property for setting the acutal triangle to move with the bar keeping proportions with the limits
368 bool _moveActualWithBar;
371 * The property for setting visible or not the bar labels information
375 * X-Coord for left-superior device visible drawing
377 wxCoord deviceStart_x;
380 * Y-Coord for left-superior device visible drawing
382 wxCoord deviceStart_y;
385 * X-Coord for right device margin
387 wxCoord deviceEndMargin;
390 * Represents the active state of the bar
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)
398 bool withActualDrawed;
401 * The colour of the start triangle
403 wxColour start_Colour;
406 * The colour of the actual triangle
408 wxColour actual_Colour;
411 * The colour of the end triangle
416 * The colour of the bar
420 * Represents the real-x value to draw a vertical line
422 int realX_vertical_line;
425 * Represents the last clickedX coord inside the bar.
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
433 int numberOrientation;
435 * Represents the logic initial reference start point used for dragging
437 int logicInitial_start;
439 * Represents the logic intial reference end point used for dragging
441 int logicInitial_end;
443 * Represents the logic initial reference actual point used for dragging
445 int logicInitial_actual;
448 * Represents the pixel value assigned to as half of the width of the triangles
450 int trianglesHalfWidth;
453 * Represents the background color of the panel (this) where the bar is. The default color is the imediately parent background color
455 wxColour backgroundColor;
457 * Represents the color of the dot-line use as guides. The default color is RED.
459 wxColour guideLineColor;
466 * The color bar pop menu
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()