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 # ------------------------------------------------------------------------ */
26 //------------------------------------------------------------------------------------------------------------
27 // Class definition include
28 //------------------------------------------------------------------------------------------------------------
29 #include "pColorBar.h"
32 //------------------------------------------------------------------------------------------------------------
33 // Generated events declaration and definition
34 //------------------------------------------------------------------------------------------------------------
36 * How to catch generated event: EVT_COMMAND(ID_CONTAINER_WINDOW_LISTENER, wxEVT_TYPE_EVENT, ContainerClass :: determinedEventFor)
38 BEGIN_DECLARE_EVENT_TYPES()
39 DECLARE_EVENT_TYPE( wxEVT_ADDED_POINT, -1 )
40 DECLARE_EVENT_TYPE( wxEVT_REMOVED_POINT, -1 )
41 DECLARE_EVENT_TYPE( wxEVT_MOVED_POINT, -1 )
42 DECLARE_EVENT_TYPE( wxEVT_CHANGED_POINT, -1 )
43 DECLARE_EVENT_TYPE( wxEVT_ON_COLOR_BAR, -1 )
44 END_DECLARE_EVENT_TYPES()
47 DEFINE_EVENT_TYPE( wxEVT_ADDED_POINT )
48 DEFINE_EVENT_TYPE( wxEVT_REMOVED_POINT )
49 DEFINE_EVENT_TYPE( wxEVT_MOVED_POINT )
50 DEFINE_EVENT_TYPE( wxEVT_CHANGED_POINT )
51 DEFINE_EVENT_TYPE( wxEVT_ON_COLOR_BAR )
53 //------------------------------------------------------------------------------------------------------------
54 // Class implementation
55 //------------------------------------------------------------------------------------------------------------
56 /** file pColorBar.cxx */
57 IMPLEMENT_CLASS(pColorBar, wxScrolledWindow)
59 //------------------------------------------------------------------------------------------------------------
60 // Handled events table
61 //------------------------------------------------------------------------------------------------------------
62 BEGIN_EVENT_TABLE(pColorBar, wxScrolledWindow)
63 EVT_PAINT( pColorBar :: onPaint)
64 EVT_SIZE ( pColorBar :: OnSize )
65 EVT_MOTION ( pColorBar :: onMouseMove)
66 EVT_RIGHT_DOWN( pColorBar :: onShowPopupMenu)
67 EVT_LEFT_DCLICK( pColorBar :: onLeftButtonDClick)
68 EVT_LEFT_DOWN( pColorBar :: onLeftClicDown)
69 EVT_LEFT_UP( pColorBar :: onLeftClickUp)
70 EVT_MENU( cntID_DEL_COLOR_POINT, pColorBar :: onDeleteColorPoint)
71 EVT_MENU( cntID_ADD_COLOR_POINT, pColorBar :: onAddColorPoint)
72 EVT_MENU( cntID_CHANGE_COLOR_POINT, pColorBar :: onChangeColourSelectedPoint)
73 EVT_MENU( cntID_TRIANGLES_UP, pColorBar :: onTrianglesUp_Figure)
74 EVT_MENU( cntID_TRIANGLES_DOWN, pColorBar :: onTrianglesDown_Figure)
75 EVT_MENU( cntID_TRIANGLES_LEFT, pColorBar :: onTrianglesLeft_Figure)
76 EVT_MENU( cntID_TRIANGLES_RIGHT, pColorBar :: onTrianglesRight_Figure)
77 EVT_MENU( cntID_RECTANGLES, pColorBar :: onRectangles_Figure)
78 EVT_MENU( cntID_DEGRADE_CONTROL, pColorBar :: onDegradeControl)
79 EVT_MIDDLE_UP( pColorBar :: onShowPopupMenu )
80 EVT_RIGHT_UP ( pColorBar :: onShowPopupMenu )
83 //------------------------------------------------------------------------------------------------------------
84 // Constructors & Destructors
85 //------------------------------------------------------------------------------------------------------------
88 * Creates a colorBar instance
89 * param *parent Container event listener window
90 * param _w Width of the color bar drawing area
91 * param _h Height of the color bar drawing area
92 * param _bar_orientation VERTICAL (false) or HORIZONTAL (true) direction to set
94 pColorBar :: pColorBar (wxWindow *parent, int _w, int _h, bool _bar_orientation)
95 :wxScrolledWindow(parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
97 _logicalBar = new LogicalColorBar();
98 colourParent = GetParent()->GetBackgroundColour();
100 acceptedClick = true;
105 // Setting the default represented values
106 setDegradeState(true);
107 setStaticLimitsTo(false);
108 viewingRange = false;
109 accumTemporalPoints = 0;
112 avaliablePointToMove = -1;
114 movingPointIndex = -1;
115 movingNodePoint = NULL;
116 realX_vertical_line = -1;
117 guideLineColor = wxColour(255,0,0);
120 figure = new pFigure( RECTANGLE, FIGURE_WIDTH, bar_height, -2, _bar_orientation );
121 setOrientation ( _bar_orientation );
123 // Appending menu items to the pop-menu
124 c_popmenu.Append( cntID_ADD_COLOR_POINT, _T("Add color point"), _T("Adds a color point in the clicked point"));
125 c_popmenu.Append( cntID_DEL_COLOR_POINT, _T("Delete color point"), _T("Deletes the color point at the clicked point"));
126 c_popmenu.Append( cntID_CHANGE_COLOR_POINT, _T("Change color"), _T("Changes the color at the clicked point"));
127 c_popmenu.Append ( cntID_DEGRADE_CONTROL, _T("Turn off degrade"), _T("Turns on/off the degrade"),wxITEM_SEPARATOR);
129 changesMenu = new wxMenu;
130 changesMenu->AppendCheckItem ( cntID_TRIANGLES_UP, _T("Triangles up"),_T("Sets triangles up figure"));
131 changesMenu->AppendCheckItem ( cntID_TRIANGLES_DOWN, _T("Triangles down"),_T("Sets triangles down figure"));
132 changesMenu->AppendCheckItem ( cntID_TRIANGLES_LEFT, _T("Triangles left"),_T("Sets triangles left figure"));
133 changesMenu->AppendCheckItem ( cntID_TRIANGLES_RIGHT, _T("Triangles right"),_T("Sets triangles right figure"));
134 changesMenu->AppendCheckItem ( cntID_RECTANGLES, _T("Rectangles"),_T("Sets rectangle figure"));
135 c_popmenu.Append(cntID_CHANGE_FIGURE, _T("Change figure"),changesMenu, _T("Changes the figure of the color points"));
136 changesMenu->Check (cntID_TRIANGLES_UP, true);
139 pColorBar :: ~pColorBar()
143 //------------------------------------------------------------------------------------------------------------
144 // Color bar proccessed events methods implementation
145 //------------------------------------------------------------------------------------------------------------
147 void pColorBar :: OnSize ( wxSizeEvent &WXUNUSED(event) )
149 wxRect rectTotal = GetClientRect();
152 setWidth( rectTotal.GetWidth() - deviceEndMargin );
156 setWidth( rectTotal.GetHeight() - deviceEndMargin);
161 * Reacts to the mouse movement inside the color bar for moving the clicked color point in the x-axis.
162 * Informs the result of the handled event like a wxCommandEvent wxEVT_MOVED_COL_POINT if a point was moved.
163 * param event The mouse actioned event
165 void pColorBar :: onMouseMove ( wxMouseEvent& event )
167 if(!event.LeftIsDown())
168 avaliablePointToMove = -1;
170 if (acceptedClick && activeState && _logicalBar->getCount()>0)
172 bool movedPoint = false;
173 wxPoint point = event.GetPosition();
174 double realClicked = getOrientation() ? convertToRealValue(point.x) : convertToRealValue(point.y);
175 bool rangeToMove = realClicked<=maxX_represented_Tshow && realClicked>=minX_represented_Tshow;//getOrientation() ? (point.x >=deviceStart_x && point.x<=bar_width+deviceStart_x-deviceEndMargin ) : ( point.y>=deviceStart_y && point.y<=bar_width+deviceStart_x-deviceEndMargin);
176 if ( rangeToMove && acceptedClick && showedColorPoints.size()>0 )
178 if ( movingPointIndex == -1 )
180 startNode_show = showedColorPoints.front();
181 lastNode_show = showedColorPoints.back();
183 //int numberEdges = figure->getNumberEdges(); // JPRx
184 //wxPoint points [4]; // JPRx
187 for (a=0; a<showedColorPoints.size() && movingPointIndex==-1 ; a++ )
189 pColorPoint * nodePoint = showedColorPoints[a];
190 int point_pixelX = convertToPixelValue(nodePoint -> getRealX());
191 point_pixelX+= deviceStart_x;
192 if ( getOrientation() )
193 movingPointIndex = (figure ->isPointInside (point_pixelX,point.x))? a : -1;
195 movingPointIndex = (figure ->isPointInside (point_pixelX,point.y))? a : -1;
197 if(movingPointIndex != -1)
199 movingNodePoint = nodePoint;
200 if(avaliablePointToMove ==-1)
201 avaliablePointToMove = movingPointIndex;
205 if (event.LeftIsDown() && movingNodePoint && movingPointIndex!=-1 && avaliablePointToMove==movingPointIndex)
207 bool hasPrevPoint = movingPointIndex > 0;
208 bool hasNextPoint = movingPointIndex < showedColorPoints.size()-1;
210 pColorPoint * prevPoint = hasPrevPoint? showedColorPoints[movingPointIndex-1]: NULL;
211 pColorPoint * nextPoint = hasNextPoint ? showedColorPoints[movingPointIndex+1]: NULL;
213 if ( hasPrevPoint && prevPoint!=NULL )
215 if ( hasNextPoint && nextPoint!=NULL )
217 double previousValue = prevPoint->getRealX();
218 double nextValue = nextPoint->getRealX();
219 movedPoint = prevPoint->isTemporalColor() ?
220 ( nextPoint->isTemporalColor() ? (realClicked>=previousValue)&&(realClicked<=nextValue) : (realClicked>=previousValue)&&(realClicked<nextValue))
221 :(realClicked>previousValue)&&(realClicked<nextValue);
223 avaliablePointToMove = movingPointIndex;
224 if(!movedPoint && realClicked<previousValue)
226 realClicked = previousValue+1;
229 else if(!movedPoint && realClicked>nextValue)
231 realClicked = nextValue-1;
240 double previousValue = prevPoint->getRealX();
241 movedPoint = prevPoint->isTemporalColor() ?
242 ( realClicked>=previousValue ) && ( realClicked<= maxX_represented_Tshow )
243 : ( realClicked>previousValue ) && ( realClicked<= maxX_represented_Tshow );
245 avaliablePointToMove = movingPointIndex;
246 if(!movedPoint && realClicked<previousValue)
248 realClicked = prevPoint->isTemporalColor()? previousValue: previousValue+1;
251 else if (!movedPoint && realClicked>=maxX_represented_Tshow)
253 realClicked = maxX_represented_Tshow;
261 if ( hasNextPoint && nextPoint!=NULL )
265 // Is the first point
266 double nextValue = nextPoint->getRealX();
267 movedPoint = ( nextPoint->isTemporalColor() ? (realClicked<=nextValue) && ( realClicked>= minX_represented_Tshow )
268 :( realClicked<nextValue ) && ( realClicked>= minX_represented_Tshow ));
271 avaliablePointToMove = movingPointIndex;
272 if(!movedPoint && realClicked>nextValue)
274 realClicked = nextPoint->isTemporalColor() ? nextValue : nextValue-1;
277 else if (!movedPoint && realClicked<=minX_represented_Tshow)
279 realClicked = minX_represented_Tshow;
286 //Is the only point in the color bar
287 movedPoint = ( realClicked<= maxX_represented_Tshow ) && ( realClicked>= minX_represented_Tshow );
289 avaliablePointToMove = movingPointIndex;
290 if (!movedPoint && realClicked<=minX_represented_Tshow)
292 realClicked = minX_represented_Tshow;
295 else if(!movedPoint && realClicked>=maxX_represented_Tshow)
297 realClicked = maxX_represented_Tshow;
304 bool movingTempStart = movingNodePoint->getRealX() == startNode_show->getRealX() && movingNodePoint->isTemporalColor();
305 bool movingTempEnd = movingNodePoint->getRealX()== lastNode_show->getRealX() && movingNodePoint->isTemporalColor();
306 if( movingTempStart || movingTempEnd )
310 // Inform movedPoint event
313 movingNodePoint->setRealX ( realClicked );
314 RefreshForce();//Refresh to show the point is moved
315 createAndSendEvent(wxEVT_MOVED_POINT);
319 movingPointIndex = -1;
320 //Creating a general event of mouse move to actualize views
321 createAndSendEvent( wxEVT_ON_COLOR_BAR );
326 movingPointIndex = -1;
327 //Creating a general event of mouse move to actualize views
328 createAndSendEvent( wxEVT_ON_COLOR_BAR );
330 if ( movingPointIndex ==-1 )
332 RefreshForce();//Refresh to show the point is not selected anymore
337 void pColorBar :: Refresh(bool eraseBackground , const wxRect* rect )
339 wxScrolledWindow::Refresh(false);
344 * Reacts to the event of drawing the bar and draws it
345 * param &WXUNUSED(event) The correspondig wxPaintEvent actioned event
347 void pColorBar :: onPaint ( wxPaintEvent &WXUNUSED(event) )
350 if ( getOrientation() ) // HORIZONTAL
353 temp_dc.SelectObject( * colorBar_Bitmap );
354 wxPaintDC dc( this );
356 // dc.Blit(deviceStart_x, deviceStart_y, bar_width+deviceStart_x, bar_height+deviceStart_y, &temp_dc, deviceStart_x, deviceStart_y);
358 dc.Blit(deviceStart_x, deviceStart_y, bar_width/*-deviceEndMargin*/, bar_height, &temp_dc, 0, 0);
360 // Bitmap for posible needed information to be shown
362 temp_dc.SelectObject( * information_Bitmap );
363 dc.Blit(0,bar_height, width, height, &temp_dc, 0, height);
369 temp_dc.SelectObject( * colorBar_Bitmap );
370 wxPaintDC dc( this );
371 // dc.Blit(deviceStart_y,deviceStart_x, bar_height+deviceStart_y, bar_width+deviceStart_x, &temp_dc, deviceStart_y, deviceStart_x);
373 dc.Blit(deviceStart_y,deviceStart_x, bar_height, bar_width-deviceEndMargin, &temp_dc, 0, 0);
374 // Bitmap for posible needed information to be shown
376 temp_dc.SelectObject( * information_Bitmap );
377 dc.Blit(0,bar_width, height, width, &temp_dc, 0, width );
379 temp_dc.SelectObject(wxNullBitmap);
384 * Reacts to the cntID_ADD_COLOR_POINT wxCommandEvent and adds a color degrade point to the color bar.
385 * Informs the result of the handled event like a wxCommandEvent wxEVT_ADDED_COL_POINT if the point was inserted succesfully.
386 * param & anEvent The wxCommandEvent actioned event
388 void pColorBar :: onAddColorPoint ( wxCommandEvent& anEvent )
390 bool addedPoint = false;
391 double real_x = getOrientation() ? convertToRealValue( clickedX ) : convertToRealValue( clickedY );
392 wxColour selectedColor = getSelectedColour();
395 addedPoint = addColorPoint (real_x, selectedColor);
397 // Inform addedPoint event
401 createAndSendEvent( wxEVT_ADDED_POINT );
406 * Reacts to the cntID_DEL_COLOR_POINT wxCommandEvent and deletes a color degrade point of the color bar.
407 * Informs the result of the handled event like a wxCommandEvent wxEVT_REMOVED_COL_POINT if the point was succesfully removed.
408 * param & anEvent The wxCommandEvent actioned event
410 void pColorBar :: onDeleteColorPoint ( wxCommandEvent& anEvent )
412 bool deletedPoint = false;
413 double real_x = getOrientation() ? convertToRealValue( clickedX ) : convertToRealValue( clickedY );
414 deletedPoint = deleteColorPoint(real_x);
415 // Inform deletedPoint event
419 createAndSendEvent( wxEVT_REMOVED_POINT );
424 * Reacts to the cntID_CHANGE_COLOR_POINT wxCommandEvent and changes the assigned color to the selected color degrade point of the color bar.
425 * Informs the result of the handled event like a wxCommandEvent wxEVT_CHANGED_POINT if the point was succesfully removed.
426 * param & anEvent The wxCommandEvent actioned event
428 void pColorBar :: onChangeColourSelectedPoint ( wxCommandEvent& anEvent )
430 bool changedColour = false;
431 changedColour = getOrientation() ? changeColor( clickedX ) : changeColor( clickedY );
432 // Inform deletedPoint event
436 createAndSendEvent( wxEVT_CHANGED_POINT );
442 * Reacts to the cntID_TRIANGLES_UP wxCommandEvent and changes the assigned figure to -triangles up- for the color points of the color bar.
443 * param & anEvent The wxCommandEvent actioned event
445 void pColorBar :: onTrianglesUp_Figure ( wxCommandEvent& anEvent )
447 if( !changesMenu->IsChecked(cntID_TRIANGLES_UP) )
450 changesMenu->Check (cntID_TRIANGLES_UP, true);
451 changesMenu->Check (cntID_TRIANGLES_DOWN, false);
452 changesMenu->Check (cntID_TRIANGLES_LEFT, false);
453 changesMenu->Check (cntID_TRIANGLES_RIGHT, false);
454 changesMenu->Check (cntID_RECTANGLES, false);
458 * Reacts to the cntID_TRIANGLES_DOWN wxCommandEvent and changes the assigned figure to -triangles down- for the color points of the color bar.
459 * param & anEvent The wxCommandEvent actioned event
461 void pColorBar :: onTrianglesDown_Figure ( wxCommandEvent& anEvent )
463 if( !changesMenu->IsChecked(cntID_TRIANGLES_DOWN) )
466 changesMenu->Check (cntID_TRIANGLES_UP, false);
467 changesMenu->Check (cntID_TRIANGLES_DOWN, true);
468 changesMenu->Check (cntID_TRIANGLES_LEFT, false);
469 changesMenu->Check (cntID_TRIANGLES_RIGHT, false);
470 changesMenu->Check (cntID_RECTANGLES, false);
474 * Reacts to the cntID_TRIANGLES_LEFT wxCommandEvent and changes the assigned figure to -triangles left- for the color points of the color bar.
475 * param & anEvent The wxCommandEvent actioned event
477 void pColorBar :: onTrianglesLeft_Figure ( wxCommandEvent& anEvent )
479 if( !changesMenu->IsChecked(cntID_TRIANGLES_LEFT) )
482 changesMenu->Check (cntID_TRIANGLES_UP, false);
483 changesMenu->Check (cntID_TRIANGLES_DOWN, false);
484 changesMenu->Check (cntID_TRIANGLES_LEFT, true);
485 changesMenu->Check (cntID_TRIANGLES_RIGHT, false);
486 changesMenu->Check (cntID_RECTANGLES, false);
490 * Reacts to the cntID_TRIANGLES_RIGHT wxCommandEvent and changes the assigned figure to -triangles right- for the color points of the color bar.
491 * param & anEvent The wxCommandEvent actioned event
493 void pColorBar :: onTrianglesRight_Figure ( wxCommandEvent& anEvent )
495 if( !changesMenu->IsChecked(cntID_TRIANGLES_RIGHT) )
498 changesMenu->Check (cntID_TRIANGLES_UP, false);
499 changesMenu->Check (cntID_TRIANGLES_DOWN, false);
500 changesMenu->Check (cntID_TRIANGLES_LEFT, false);
501 changesMenu->Check (cntID_TRIANGLES_RIGHT, true);
502 changesMenu->Check (cntID_RECTANGLES, false);
506 * Reacts to the cntID_RECTANGLES wxCommandEvent and changes the assigned figure to -rectangles- for the color points of the color bar.
507 * param & anEvent The wxCommandEvent actioned event
509 void pColorBar :: onRectangles_Figure ( wxCommandEvent& anEvent )
511 if( !changesMenu->IsChecked(cntID_TRIANGLES_RIGHT) )
513 changeFigure (RECTANGLE);// RECTANGLE = 4
514 changesMenu->Check (cntID_TRIANGLES_UP, false);
515 changesMenu->Check (cntID_TRIANGLES_DOWN, false);
516 changesMenu->Check (cntID_TRIANGLES_LEFT, false);
517 changesMenu->Check (cntID_TRIANGLES_RIGHT, false);
518 changesMenu->Check (cntID_RECTANGLES, true);
523 * Reacts to the cntID_DEGRADE_CONTROL wxCommandEvent and turns on/off the degrade in the color bar.
524 * param & anEvent The wxCommandEvent actioned event
526 void pColorBar :: onDegradeControl ( wxCommandEvent& anEvent )
528 bool degrade = getDegradeState();
529 wxString nextAction_text;
532 nextAction_text = _T("Turn on degrade");
533 setDegradeState (false);
537 nextAction_text = _T("Turn off degrade");
538 setDegradeState (true);
540 c_popmenu.SetLabel ( cntID_DEGRADE_CONTROL, nextAction_text );
544 * Reacts to the wxEVT_RIGHT_DCLICK wxMouseEvent and adds a color degrade point to the color bar.
545 * Informs the result of the handled event like a wxCommandEvent wxEVT_ADDED_COL_POINT if the point was succesfully inserted.
546 * param & event The wxMouseEvent actioned event
548 void pColorBar :: onLeftButtonDClick (wxMouseEvent& event)
552 bool addedPoint = false;
553 wxPoint point = event.GetPosition();
554 bool posiblePoint = false;
555 if( getOrientation() )
557 posiblePoint = point.x>=deviceStart_x && point.y<= (bar_height + deviceStart_y);
561 posiblePoint = point.x>=deviceStart_y && point.x<= (bar_height+deviceStart_y) && point.y>deviceStart_x;
566 double real_x = getOrientation() ? convertToRealValue( point.x ) : convertToRealValue( point.y );
567 wxColour selectedColor = getSelectedColour();
570 addedPoint = addColorPoint (real_x, selectedColor);
572 // Inform addedPoint event
575 //RefreshForce(); Is all ready refreshed on the adition of the point method
576 createAndSendEvent( wxEVT_ADDED_POINT );
582 void pColorBar ::onLeftClicDown(wxMouseEvent& event )
584 acceptedClick = true;
587 void pColorBar ::onLeftClickUp(wxMouseEvent& event )
589 movingPointIndex = -1;
590 acceptedClick = false;
593 * Shows the popup menu
595 void pColorBar :: onShowPopupMenu (wxMouseEvent &event)
599 if(showedColorPoints.empty())
601 c_popmenu.Enable(cntID_DEL_COLOR_POINT, false);
605 c_popmenu.Enable(cntID_DEL_COLOR_POINT, true);
607 bool setClickedValues = false;
608 if( getOrientation() )
610 setClickedValues = event.GetX()>=deviceStart_x && event.GetY()<= (bar_height + deviceStart_y);
614 setClickedValues = event.GetX()>=deviceStart_y && event.GetX()<= (bar_height+deviceStart_y) && event.GetY()>deviceStart_x;
616 if (setClickedValues)
618 setClickedX ( event.GetX() );
619 setClickedY ( event.GetY() );
621 PopupMenu( &c_popmenu, event.GetX(), event.GetY());
625 //------------------------------------------------------------------------------------------------------------
626 // Other methods implementation
627 //------------------------------------------------------------------------------------------------------------
630 * Method that reinitiates attributes of the color bar to the given points
631 * param minRealValue The minimum represented value (real value)
632 * param maxRealValue The maximum represented value (real value)
634 void pColorBar :: reinitiateColorBar(double minRealValue, double maxRealValue)
637 _logicalBar -> clearPoints();
638 showedColorPoints.clear();
640 movingPointIndex = -1;
641 realX_vertical_line = -1;
643 accumTemporalPoints = 0;
644 viewingRange = false;
645 setDegradeState(true);
646 setRepresentedValues(minRealValue, maxRealValue);
650 * Method that reinitiates attributes of the color bar and set the points given by parameter
651 * param pointsVector The the vector of the new points, the color points must have at least two points.
653 void pColorBar :: reinitiateColorBarTo (std::vector<pColorPoint *> pointsVector)
655 _logicalBar -> clearPoints();
656 _logicalBar -> setColorPoints(pointsVector);
657 showedColorPoints.clear();
659 movingPointIndex = -1;
660 realX_vertical_line = -1;
662 accumTemporalPoints = 0;
663 viewingRange = false;
664 setDegradeState(true);
666 double minRealValue = _logicalBar -> getMinValue();
667 double maxRealvalue = _logicalBar -> getMaxValue();
669 setRepresentedValues(minRealValue, maxRealvalue);
673 * Method that sets a copy of the points of the color bar to the given pointer parameter
674 * param pointsList The list for getting the points
676 void pColorBar :: getPointsListWithTemps (std::vector<pColorPoint*> &pointsVector)
679 for (int a =0; a<showedColorPoints.size() ; a++)
681 cPoint = showedColorPoints[a];
682 pColorPoint* copyPoint = new pColorPoint(cPoint->getRealX(), cPoint->getColor( ), (cPoint->isTemporalColor()));
683 pointsVector.push_back(copyPoint);
688 * Method that sets a copy of the points of the color bar to the given pointer parameter, and sets the default values to the needeed attributes, it doesn't
689 * includes the teporal points created
690 * param pointsList The list for getting the points
693 void pColorBar :: getAddedColorsPointsList (std::vector<pColorPoint*> &pointsVector)
696 for (int a =0; a<_logicalBar->getCount(); a++)
698 cPoint = _logicalBar ->getPointAtIndex(a);
699 pColorPoint* copyPoint = new pColorPoint(cPoint->getRealX(), cPoint->getColor( ), (cPoint->isTemporalColor()));
700 pointsVector.push_back(copyPoint);
706 * Adds a color degrade point to the color bar.
707 * param xRealValue The real xValue of the point
708 * param theColour The assigned color for the point
709 * param temporalStart Indicates if the inserted point is the temporal startShowing point
710 * param temporalEnd Indicates if the inserted point is the temporal startShowing point
711 * return Returns true if the point was succesfully inserted.
713 bool pColorBar :: addColorPoint (double xRealValue, wxColour theColour/*, bool temporalStart, bool temporalEnd*/)
715 bool addedPoint = false;
716 addedPoint = _logicalBar->addColorPoint(xRealValue,theColour);
724 * Delets a color degrade point to the color bar.
725 * param xRealValue The real xValue of the point to delete
726 * return Returns true if the point was succesfully inserted.
728 bool pColorBar :: deleteColorPoint (double xRealValue)
730 pColorPoint* actualPoint;
731 bool deletedPoint = false;
732 for (int a =0; a<showedColorPoints.size() && !deletedPoint; a++)
734 actualPoint = showedColorPoints[a];
735 int actualX = (int)actualPoint -> getRealX();
736 bool isInsideActual = figure -> isPointInside (convertToPixelValue(actualX), convertToPixelValue(xRealValue));
737 if( actualX == xRealValue || isInsideActual)
740 deletedPoint = _logicalBar->deleteColorPoint(actualPoint -> getRealX());
749 * Changes the color degrade point color value.
750 * Informs the result of the handled event like a wxCommandEvent wxEVT_CHANGED_COLOR_POINT if the point changed its colour.
751 * param clickedValue The x-coord pixel value of the point to which the color change interests
752 * return Returns true if the color point was succesfully updated.
754 bool pColorBar :: changeColor ( int clickedValue )
756 bool colourUpdated = false;
757 double xRealValue = convertToRealValue( clickedValue );
758 pColorPoint* actualPoint;
759 for (int a =0; a<showedColorPoints.size() && !colourUpdated; a++)
761 actualPoint = showedColorPoints[a];
762 int actualX = (int)actualPoint -> getRealX();
763 bool isInsideActual = figure -> isPointInside (convertToPixelValue(actualX), clickedValue);
764 if( actualX == xRealValue || isInsideActual)
766 wxColour newColour = getSelectedColour();
769 actualPoint -> setColor(newColour);
770 colourUpdated = true;
776 return colourUpdated;
780 * Repaints the color bar in horizontal direction mode
782 void pColorBar :: repaintView( )
785 temp_dc.SelectObject( * colorBar_Bitmap );
786 temp_dc.SetBrush(wxBrush( colourParent ,wxSOLID ));
787 temp_dc.SetPen(wxPen( colourParent,1,wxSOLID ));
788 if (getOrientation())
790 temp_dc.DrawRectangle(0, 0, bar_width, bar_height);
791 temp_dc.SetPen(wxPen( wxColour(167,165,191),1,wxSOLID ));
792 temp_dc.DrawRectangle(0, 0, bar_width-deviceEndMargin, bar_height);
796 temp_dc.DrawRectangle(0, 0, bar_height, bar_width);
797 temp_dc.SetPen(wxPen( wxColour(167,165,191),1,wxSOLID ));
798 temp_dc.DrawRectangle(0, 0, bar_height, bar_width-deviceEndMargin);
800 //wxPoint figPoints[4]; // JPRx
802 if( _logicalBar -> getCount() >0)
804 updatePointsToDraw();
806 int numberEdges = figure->getNumberEdges();
808 figure->getVertexPoints(points);
809 figure ->setVertexPoints (points);
811 int maxValue = showedColorPoints.size();
812 pColorPoint * iniPoint;
813 pColorPoint * endPoint;
814 wxColor intialColor, finalColor;
815 for (int a=0; a<maxValue; a++)
817 iniPoint = showedColorPoints[a];
818 int ini_pixelX = convertToPixelValue(iniPoint -> getRealX());
819 intialColor = iniPoint -> getColor();
825 endPoint = showedColorPoints[a+1];
826 int end_pixelX = convertToPixelValue(endPoint -> getRealX());
827 finalColor = endPoint -> getColor();
829 int rectangle_width = end_pixelX - ini_pixelX;
831 //*************************************************************************************
832 int initial_r = intialColor.Red();
833 int final_r = finalColor.Red() ;
834 int initial_g = intialColor.Green();
835 int final_g= finalColor.Green();
836 int initial_b = intialColor.Blue();
837 int final_b= finalColor.Blue();
839 float m_scope_r = (float)(final_r-initial_r)/rectangle_width;
840 float m_scope_g = (float)(final_g-initial_g)/rectangle_width;
841 float m_scope_b = (float)(final_b-initial_b)/rectangle_width;
843 int next_r = initial_r;
844 int next_g = initial_g;
845 int next_b = initial_b;
847 float nxt_r = (float)next_r;
848 float nxt_g = (float)next_g;
849 float nxt_b = (float)next_b;
851 for (int Xi =ini_pixelX; Xi<= end_pixelX; Xi++)
853 temp_dc.SetBrush(wxBrush( wxColour(next_r, next_g, next_b),wxSOLID ));
854 temp_dc.SetPen(wxPen( wxColour(next_r, next_g, next_b),1,wxSOLID ));
855 if( getOrientation() )
856 temp_dc.DrawLine(Xi, 0, Xi, bar_height);
858 temp_dc.DrawLine(0, Xi, bar_height, Xi);
860 nxt_r = (m_scope_r + nxt_r);
861 nxt_g = (m_scope_g + nxt_g);
862 nxt_b = (m_scope_b + nxt_b);
864 next_r = (int)(nxt_r);
865 next_g = (int)(nxt_g);
866 next_b = (int)(nxt_b);
870 if( movingPointIndex!=-1 && movingNodePoint!=NULL )
872 if ( !(movingNodePoint -> isTemporalColor()) )
874 if( movingNodePoint==iniPoint && movingPointIndex!=-1 )
876 temp_dc.SetBrush(wxBrush( wxColour(5,36,180), wxSOLID ));
877 temp_dc.SetPen(wxPen( wxColour(239,239,239), 1, wxSOLID ));
878 if (getOrientation())
879 temp_dc.DrawPolygon(numberEdges, points, ini_pixelX, 0);
881 temp_dc.DrawPolygon(numberEdges, points, 0, ini_pixelX);
885 temp_dc.SetBrush(wxBrush( intialColor, wxSOLID ));
886 if(iniPoint->isTemporalColor())
887 temp_dc.SetPen(wxPen( intialColor, 1, wxSOLID ));
889 temp_dc.SetPen(wxPen( wxColour(0,0,0), 1, wxSOLID ));
890 if (getOrientation())
891 temp_dc.DrawPolygon(numberEdges, points, ini_pixelX, 0);
893 temp_dc.DrawPolygon(numberEdges, points, 0, ini_pixelX);
899 if ( !(iniPoint -> isTemporalColor()) )
901 temp_dc.SetBrush(wxBrush( intialColor, wxSOLID ));
902 temp_dc.SetPen(wxPen( wxColour(0,0,0), 1, wxSOLID ));
903 if (getOrientation())
904 temp_dc.DrawPolygon(numberEdges, points, ini_pixelX, 0);
906 temp_dc.DrawPolygon(numberEdges, points, 0, ini_pixelX);
910 if (realX_vertical_line!=-1)
912 temp_dc.SetPen(wxPen( guideLineColor,1,wxDOT ));
913 int pixelX_guide = convertToPixelValue(realX_vertical_line);
914 if (getOrientation())
915 temp_dc.DrawLine(pixelX_guide, 0, pixelX_guide, bar_height);
917 temp_dc.DrawLine(0, pixelX_guide, bar_height, pixelX_guide);
923 * Forces the refresh view of the color bar
925 void pColorBar :: RefreshForce ()
931 * Draws the color bar with its degrades
932 * param recentlyChangedOrientation indicates if the orientation has been changed before calling this method
934 void pColorBar :: drawColorBar (bool recentlyChangedOrientation)
936 wxRect rectTotal = GetClientRect();
937 if (recentlyChangedOrientation)
939 if ( getOrientation() ) // HORIZONTAL
941 //SetSize(width, height );
942 wxWindow::SetSize( width, height );
943 //SetSize( rectTotal.GetWidth(), rectTotal.GetHeight() );
944 setWidth(GetClientRect().GetWidth()- deviceEndMargin);
945 //setHeight(GetClientRect().GetHeight());
947 colorBar_Bitmap = new wxBitmap( bar_width+1280, bar_height+1280 );
948 //information_Bitmap = new wxBitmap( width-bar_width, height-bar_height );
952 wxWindow::SetSize( height, width );
953 //SetSize( rectTotal.GetHeight(), rectTotal.GetWidth() );
954 setWidth(GetClientRect().GetHeight()- deviceEndMargin);
955 //setHeight(GetClientRect().GetWidth());
957 //SetWindowStyle( wxNO_FULL_REPAINT_ON_RESIZE );
958 colorBar_Bitmap = new wxBitmap( bar_height+1280, bar_width+1280 );
959 //information_Bitmap = new wxBitmap( height-bar_height, width-bar_width );
965 * Changes the figure of the color points according to the parameter
966 * param figureOrientation Is the corresponding number for identifying the figure
967 * RECTANGLE = 4,TRIANGLE LEFT = -4, TRIANGLE RIGHT = -6, TRIANGLE UP = -8, TRIANGLE DOWN = -2
969 void pColorBar :: changeFigure(int figureOrientation)
971 if ( figureOrientation<1 ) //The figure is a a rotated triangle
973 changePointsFigure_Edges(3);
974 figure -> setFigureOrientation ( figureOrientation );
977 else //The figure is a rectangle
979 changePointsFigure_Edges(4);
985 * Changes the figure used for the degreade color points to the indicated one by parameter
986 * param figEdges Is the constant that represents the figure number of edges (TRIANGLE | RECTANGLE)
988 void pColorBar :: changePointsFigure_Edges(int figEdges)
990 figure->setNumberEdges( figEdges);
994 * Gets the constant that represents the figure used for the degreade color points
995 * return figureEdges Is the constant that represents the figure number of edges (TRIANGLE | RECTANGLE)
997 int pColorBar :: getPointsFigure_Edges ()
999 return (figure -> getNumberEdges());
1003 * Sets the height of the drawing bar area
1004 * param _h The height to set
1006 void pColorBar :: setHeight (int _h)
1009 bar_height = height-gapY;
1013 * Sets the height of the drawing bar area
1014 * return _h The height to get
1016 int pColorBar :: getHeight()
1022 * Sets the width of the drawing bar area
1023 * param _w The width to set
1025 void pColorBar :: setWidth (int _w)
1028 bar_width = width-gapX;
1032 * Gets the width of the drawing bar area
1033 * param width The width to get
1035 int pColorBar :: getWidth ()
1041 * Sets the height of the containing rectangle bar
1042 * param _h The height to set
1044 void pColorBar :: setBarHeight (int _h)
1050 * Gets the height of the containing rectangle bar
1051 * return bar_height The height to get
1053 int pColorBar :: getBarHeight()
1059 * Sets the width of the containing rectangle bar
1060 * param _w The width to set
1062 void pColorBar :: setBarWidth (int _w)
1068 * Gets the width of the containing rectangle bar
1069 * return bar_width The width to get
1071 int pColorBar :: getBarWidth ()
1077 * Sets the orientation of the color bar
1078 * param _orientation The orientation to set VERTICAL = false, HORIZONTAL = true
1080 void pColorBar :: setOrientation (bool _orientation)
1082 _logicalBar -> setOrientation(_orientation);
1083 figure -> setBarOrientation (_orientation);
1087 * Gets the orientation of the color bar
1088 * return bar_orientation The bar orientation assigned
1090 bool pColorBar :: getOrientation ()
1092 return _logicalBar->getOrientation();
1096 * Sets the collection of color points
1097 * param _points The new points to set, each one of data type pColorPoint ( xValue, wxColour_assigned)
1099 void pColorBar :: setPoints (std::vector<pColorPoint *> _points)
1101 _logicalBar->clearPoints();
1102 showedColorPoints.clear();
1103 _logicalBar->setColorPoints(_points);
1104 //posible needed to update
1108 * Gets the last clickedX pixel coord inside the bar.
1109 * return clickedX The x-coord pixel value
1111 int pColorBar :: getClickedX()
1117 * Sets the last clickedX pixel coord inside the bar.
1118 * param xCoordPixel The x-coord value to set
1120 void pColorBar :: setClickedX(int xCoordPixel)
1122 clickedX = xCoordPixel;
1126 * Gets the last clickedY pixel coord inside the bar.
1127 * return clickedY The y-coord pixel value
1129 int pColorBar :: getClickedY()
1135 * Sets the last clickedY pixel coord inside the bar.
1136 * param yCoordPixel The y-coord pixel value to set
1138 void pColorBar :: setClickedY(int yCoordPixel)
1140 clickedY = yCoordPixel;
1144 * Gets the real x value for a given x-pixel value using the rule real_x = minX_represented_Tshow + ((x_Pixel * (maxX_represented_Tshow - minX_represented_Tshow) ) / bar_width)
1145 * param x_Pixel The pixel value to convert into real value with respect to the x scale
1146 * return realX The real-x value corresponding to the xPixel
1148 double pColorBar :: convertToRealValue ( int x_Pixel )
1151 int newPixel = x_Pixel*(bar_width - deviceEndMargin - deviceStart_x)/(bar_width) ;
1152 return newPixel*(maxX_represented_Tshow - minX_represented_Tshow)/(bar_width);
1154 return minX_represented_Tshow + ((x_Pixel-deviceStart_x) * (maxX_represented_Tshow - minX_represented_Tshow) ) /( bar_width-deviceEndMargin);
1158 * Gets the x-pixel value for a given x_real value using the rule x_pixel = ((x_real - minX_represented_Tshow) * bar_width)/(maxX_represented_Tshow - minX_represented_Tshow)
1159 * param x_Pixel The pixel value to convert into real value with respect to the x scale
1160 * return realX The real-x value corresponding to the xPixel
1162 int pColorBar :: convertToPixelValue (double x_real )
1164 return (int)( ((x_real - minX_represented_Tshow) * (bar_width-deviceEndMargin))/(maxX_represented_Tshow - minX_represented_Tshow) );
1168 * Gets the selected color and updates the state of the okSelectedColor
1169 * return selectedColor Is the selected rbg color
1171 wxColour pColorBar :: getSelectedColour()
1173 okSelectedColor = false;
1176 wxColourDialog dialog( GetParent(), &data);
1178 if ( dialog.ShowModal() == wxID_OK )
1180 col = dialog.GetColourData().GetColour();
1181 okSelectedColor = true;
1187 * Sets the represented minimum and maximunm values
1188 * param minRealValue The minimum represented value (real value)
1189 * param maxRealValue The maximum represented value (real value)
1191 void pColorBar :: setRepresentedValues ( double minRealValue, double maxRealValue )
1193 temporalMinXToShow = (int)minRealValue;
1194 temporalMaxXToShow = (int)maxRealValue;
1196 minX_represented_Tshow = (int)minRealValue;
1197 maxX_represented_Tshow = (int)maxRealValue;
1198 _logicalBar->setMinValue(minX_represented_Tshow);
1199 _logicalBar->setMaxValue(maxX_represented_Tshow);
1203 * Gets the data of the last point moving in a pColorPoint copy
1204 * return pointData Is a pColorPoint with the data of las moved color
1206 pColorPoint * pColorBar :: getLastMovedColorPoint()
1208 pColorPoint * dataPoint = new pColorPoint ( 0, wxColor (0,0,0), false);
1209 if (movingNodePoint)
1211 dataPoint ->setColor(movingNodePoint->getColor());
1212 dataPoint ->setRealX(movingNodePoint->getRealX());
1218 * Sets the gap values for the color bar bitmap
1219 * param gap_x Gap in x
1220 * param gap_y Gap in y
1222 void pColorBar :: setGapValues (int gap_x, int gap_y)
1229 * Sets the degrade state of the color bar
1230 * param newState The degrade stare to set
1232 void pColorBar :: setDegradeState(bool newState)
1234 doingDegrade = newState;
1238 * Gets the degrade state of the color bar
1239 * return doingDegrade is the actual degrade state of the bar
1241 bool pColorBar :: getDegradeState()
1243 return doingDegrade;
1247 * Sets the visible range of the bar and repaints the bar according to it, the min value must be less than the max value.
1248 * param minToShow Is the minimum value to show in the colorbar
1249 * param maxToShow Is the maximum value to show in the colorbar
1251 void pColorBar :: setVisibleRange(int minToShow, int maxToShow)
1253 minX_represented_Tshow = minToShow;
1254 maxX_represented_Tshow = maxToShow;
1255 viewingRange = true;
1260 * Sets the state of static or not for the limit color points
1261 * pamar areStatic Is the state to set for the limits
1263 void pColorBar :: setStaticLimitsTo(bool areStatic)
1265 staticLimits = areStatic;
1269 * Gets the state of static or not for the limit color points
1270 * return staticLimits Is the state for limits
1272 bool pColorBar :: getStaticLimits()
1274 return staticLimits;
1278 * Sets the device start drawing left-superior (pixel) start point and draws automatically the color bar
1279 * param deviceStart_x Pixel start for x-coord
1280 * param deviceStart_y Pixel start for y-coord
1282 void pColorBar :: setDeviceBlitStart ( wxCoord devStart_x, wxCoord devStart_y )
1284 deviceStart_x = devStart_x;
1285 deviceStart_y = devStart_y;
1286 if (getOrientation())
1287 width += deviceStart_x;
1289 height += deviceStart_y;
1294 * Clears the temporal color points of the list
1296 void pColorBar :: clearTemporalColors()
1303 * param activeNow The new state
1305 void pColorBar :: setActiveStateTo (bool activeNow)
1307 activeState = activeNow;
1311 * Gets the active state of the bar
1312 * return isActive The actual state
1314 bool pColorBar :: isActive()
1320 * Gets the real-x value to draw a vertical line
1321 * return realX_vertical_line The real x value for the vertical line
1323 int pColorBar :: getRealX_vertical_line()
1325 return realX_vertical_line;
1329 * Sets the real-x value to draw a vertical line
1330 * param realX_vertical_line The new real x value for the vertical line
1332 void pColorBar :: setRealX_vertical_line(int newReal_x)
1334 realX_vertical_line = newReal_x;
1338 * Sets the new device (deviceEndMargin) value form the end of this panel to the end of the drawing area in the device
1339 * param newDeviceEnd_pixels The new pixel value to asign to the right(horizontal view), underneath(vertical view) margin in pixels
1341 void pColorBar :: setDeviceEndMargin(int newDeviceEnd_pixels)
1343 deviceEndMargin = newDeviceEnd_pixels;
1346 void pColorBar :: createAndSendEvent(WXTYPE theEventType)
1348 wxCommandEvent cevent( theEventType, GetId() );
1349 cevent.SetEventObject( this );
1350 GetEventHandler()->ProcessEvent( cevent );
1355 Returns the number of points that the bar color has
1357 int pColorBar::getColorPointsSize()
1359 return _logicalBar->getCount();
1363 Get the RGB values of the color point that is in the
1364 index given with respecto to the
1366 void pColorBar::getDataAt(int index, double& x,int& red,int& green,int& blue)
1368 //******************************
1369 _logicalBar->getDataAt(index, x, red, green, blue);
1373 * Sets the guide line color
1374 * param theNwGuideLineColor The color to set to the guideLineColor
1376 void pColorBar :: setGuideLineColour(wxColour theNwGuideLineColor)
1378 guideLineColor = theNwGuideLineColor;
1382 * Gets the guide line color
1383 * return guideLineColor The color of the guideLine
1385 wxColour pColorBar :: getGuideLineColour()
1387 return guideLineColor;
1391 * Sets the guide line color
1392 * param theNwGuideLineColor The color to set to the guideLineColor
1394 void pColorBar :: setBackGroundColour(wxColour theNwBackColor)
1396 colourParent = theNwBackColor;
1400 * Gets the guide line color
1401 * return guideLineColor The color of the guideLine
1403 wxColour pColorBar :: getBackGroundColour()
1405 return colourParent;
1409 * Gets the min value of the color bar
1411 double pColorBar :: getMinValue()
1413 return (double)minX_represented_Tshow;
1417 * Gets the max value of the color bar
1419 double pColorBar :: getMaxValue()
1421 return (double)maxX_represented_Tshow;
1425 void pColorBar :: updatePointsToDraw()
1427 accumTemporalPoints = 0;
1428 if (_logicalBar->getCount()>0)
1430 showedColorPoints.clear();
1432 int startIndex, endIndex;
1433 _logicalBar -> getPointersToRangeLimits( showedColorPoints, startIndex, endIndex, minX_represented_Tshow, maxX_represented_Tshow );
1435 int internalCount = _logicalBar->getCount();
1436 std::deque <pColorPoint*>::iterator iterStart = showedColorPoints.begin( );
1437 std::deque <pColorPoint*>::iterator iterEnd = showedColorPoints.end( );
1439 int pixelTmpStart = convertToPixelValue (minX_represented_Tshow);
1440 int pixelTmpEnd = convertToPixelValue (maxX_represented_Tshow);
1441 int initial_r, final_r, initial_g, final_g, initial_b, final_b, rectangle_width;
1442 double realINI, realEND;
1444 bool includeTempStart = false;
1445 bool includeTempEnd = false;
1446 //-----------------Adding the first visible point of the list
1447 if(showedColorPoints.size()>0)
1449 includeTempStart = (int)(showedColorPoints.front()->getRealX())>minX_represented_Tshow ;
1450 includeTempEnd = (int)(showedColorPoints.back()->getRealX())<maxX_represented_Tshow ;
1451 if( startIndex >= 0 )
1453 if( startIndex == 0 )
1455 //The temporal showing point for the start should have the same color of the initial point in range at startIndex
1456 _logicalBar -> getDataAt( startIndex, realINI, initial_r, initial_g, initial_b );
1457 realINI = minX_represented_Tshow;
1458 _logicalBar -> getDataAt( startIndex, realEND, final_r, final_g, final_b );
1460 else if( startIndex > 0 )
1462 _logicalBar -> getDataAt( startIndex-1, realINI, initial_r, initial_g, initial_b );
1463 _logicalBar -> getDataAt( startIndex, realEND, final_r, final_g, final_b );
1466 if( includeTempStart )
1468 int ini_pixelX = convertToPixelValue( realINI );
1469 int end_pixelX = convertToPixelValue( realEND );
1471 rectangle_width = end_pixelX - ini_pixelX;
1473 float m_scope_r = (float)(final_r-initial_r)/rectangle_width;
1474 float m_scope_g = (float)(final_g-initial_g)/rectangle_width;
1475 float m_scope_b = (float)(final_b-initial_b)/rectangle_width;
1478 float bRed = initial_r - m_scope_r*pixelTmpStart;
1479 float bGreen = initial_g - m_scope_g*pixelTmpStart;
1480 float bBlue = initial_b - m_scope_b*pixelTmpStart;
1482 showedColorPoints.push_front( new pColorPoint ( minX_represented_Tshow, wxColour( (m_scope_r*pixelTmpStart)+bRed, (m_scope_g*pixelTmpStart)+bGreen, (m_scope_b*pixelTmpStart)+bBlue ), true));
1484 accumTemporalPoints ++;
1487 if( includeTempEnd && minX_represented_Tshow < maxX_represented_Tshow )
1489 if( internalCount>0 )
1491 if( endIndex == internalCount-1 )
1493 _logicalBar -> getDataAt( endIndex, realINI, initial_r, initial_g, initial_b );
1494 _logicalBar -> getDataAt( endIndex, realEND, final_r, final_g, final_b );
1495 realEND = maxX_represented_Tshow;
1499 _logicalBar -> getDataAt( endIndex, realINI, initial_r, initial_g, initial_b );
1500 _logicalBar -> getDataAt( endIndex+1, realEND, final_r, final_g, final_b );
1503 int ini_pixelX = convertToPixelValue( realINI );
1504 int end_pixelX = convertToPixelValue( realEND );
1506 rectangle_width = end_pixelX - ini_pixelX;
1508 float m_scope_r = (float)(final_r-initial_r)/rectangle_width;
1509 float m_scope_g = (float)(final_g-initial_g)/rectangle_width;
1510 float m_scope_b = (float)(final_b-initial_b)/rectangle_width;
1512 float bRed = initial_r - m_scope_r*pixelTmpEnd;
1513 float bGreen = initial_g - m_scope_g*pixelTmpEnd;
1514 float bBlue = initial_b - m_scope_b*pixelTmpEnd;
1515 showedColorPoints.push_back( new pColorPoint ( maxX_represented_Tshow, wxColour( ( m_scope_r*pixelTmpEnd)+bRed, (m_scope_g*pixelTmpEnd)+bGreen, (m_scope_b*pixelTmpEnd)+bBlue ), true));
1516 accumTemporalPoints ++;
1522 if(_logicalBar->getCount()>0)
1524 if ( minX_represented_Tshow > _logicalBar->getMaxAddedValue() )
1526 endIndex = _logicalBar->getCount()-1;
1528 else if ( maxX_represented_Tshow < _logicalBar->getMinAddedValue() )
1533 _logicalBar -> getDataAt( endIndex, realINI, initial_r, initial_g, initial_b );
1534 _logicalBar -> getDataAt( endIndex, realEND, final_r, final_g, final_b );
1536 realINI = minX_represented_Tshow;
1537 realEND = maxX_represented_Tshow;
1539 showedColorPoints.push_back( new pColorPoint ( realINI, wxColour( initial_r, initial_g, initial_b ), true));
1540 accumTemporalPoints ++;
1541 showedColorPoints.push_back( new pColorPoint ( realEND, wxColour( initial_r, initial_g, initial_b ), true));
1542 accumTemporalPoints ++;
1547 if ( !showedColorPoints.empty() )
1549 startNode_show = showedColorPoints.front();
1550 lastNode_show = showedColorPoints.back();