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 );
440 * Reacts to the cntID_TRIANGLES_UP wxCommandEvent and changes the assigned figure to -triangles up- for the color points of the color bar.
441 * param & anEvent The wxCommandEvent actioned event
443 void pColorBar :: onTrianglesUp_Figure ( wxCommandEvent& anEvent )
445 if( !changesMenu->IsChecked(cntID_TRIANGLES_UP) )
448 changesMenu->Check (cntID_TRIANGLES_UP, true);
449 changesMenu->Check (cntID_TRIANGLES_DOWN, false);
450 changesMenu->Check (cntID_TRIANGLES_LEFT, false);
451 changesMenu->Check (cntID_TRIANGLES_RIGHT, false);
452 changesMenu->Check (cntID_RECTANGLES, false);
456 * Reacts to the cntID_TRIANGLES_DOWN wxCommandEvent and changes the assigned figure to -triangles down- for the color points of the color bar.
457 * param & anEvent The wxCommandEvent actioned event
459 void pColorBar :: onTrianglesDown_Figure ( wxCommandEvent& anEvent )
461 if( !changesMenu->IsChecked(cntID_TRIANGLES_DOWN) )
464 changesMenu->Check (cntID_TRIANGLES_UP, false);
465 changesMenu->Check (cntID_TRIANGLES_DOWN, true);
466 changesMenu->Check (cntID_TRIANGLES_LEFT, false);
467 changesMenu->Check (cntID_TRIANGLES_RIGHT, false);
468 changesMenu->Check (cntID_RECTANGLES, false);
472 * Reacts to the cntID_TRIANGLES_LEFT wxCommandEvent and changes the assigned figure to -triangles left- for the color points of the color bar.
473 * param & anEvent The wxCommandEvent actioned event
475 void pColorBar :: onTrianglesLeft_Figure ( wxCommandEvent& anEvent )
477 if( !changesMenu->IsChecked(cntID_TRIANGLES_LEFT) )
480 changesMenu->Check (cntID_TRIANGLES_UP, false);
481 changesMenu->Check (cntID_TRIANGLES_DOWN, false);
482 changesMenu->Check (cntID_TRIANGLES_LEFT, true);
483 changesMenu->Check (cntID_TRIANGLES_RIGHT, false);
484 changesMenu->Check (cntID_RECTANGLES, false);
488 * Reacts to the cntID_TRIANGLES_RIGHT wxCommandEvent and changes the assigned figure to -triangles right- for the color points of the color bar.
489 * param & anEvent The wxCommandEvent actioned event
491 void pColorBar :: onTrianglesRight_Figure ( wxCommandEvent& anEvent )
493 if( !changesMenu->IsChecked(cntID_TRIANGLES_RIGHT) )
496 changesMenu->Check (cntID_TRIANGLES_UP, false);
497 changesMenu->Check (cntID_TRIANGLES_DOWN, false);
498 changesMenu->Check (cntID_TRIANGLES_LEFT, false);
499 changesMenu->Check (cntID_TRIANGLES_RIGHT, true);
500 changesMenu->Check (cntID_RECTANGLES, false);
504 * Reacts to the cntID_RECTANGLES wxCommandEvent and changes the assigned figure to -rectangles- for the color points of the color bar.
505 * param & anEvent The wxCommandEvent actioned event
507 void pColorBar :: onRectangles_Figure ( wxCommandEvent& anEvent )
509 if( !changesMenu->IsChecked(cntID_TRIANGLES_RIGHT) )
511 changeFigure (RECTANGLE);// RECTANGLE = 4
512 changesMenu->Check (cntID_TRIANGLES_UP, false);
513 changesMenu->Check (cntID_TRIANGLES_DOWN, false);
514 changesMenu->Check (cntID_TRIANGLES_LEFT, false);
515 changesMenu->Check (cntID_TRIANGLES_RIGHT, false);
516 changesMenu->Check (cntID_RECTANGLES, true);
521 * Reacts to the cntID_DEGRADE_CONTROL wxCommandEvent and turns on/off the degrade in the color bar.
522 * param & anEvent The wxCommandEvent actioned event
524 void pColorBar :: onDegradeControl ( wxCommandEvent& anEvent )
526 bool degrade = getDegradeState();
527 wxString nextAction_text;
530 nextAction_text = _T("Turn on degrade");
531 setDegradeState (false);
535 nextAction_text = _T("Turn off degrade");
536 setDegradeState (true);
538 c_popmenu.SetLabel ( cntID_DEGRADE_CONTROL, nextAction_text );
542 * Reacts to the wxEVT_RIGHT_DCLICK wxMouseEvent and adds a color degrade point to the color bar.
543 * Informs the result of the handled event like a wxCommandEvent wxEVT_ADDED_COL_POINT if the point was succesfully inserted.
544 * param & event The wxMouseEvent actioned event
546 void pColorBar :: onLeftButtonDClick (wxMouseEvent& event)
550 bool addedPoint = false;
551 wxPoint point = event.GetPosition();
552 bool posiblePoint = false;
553 if( getOrientation() )
555 posiblePoint = point.x>=deviceStart_x && point.y<= (bar_height + deviceStart_y);
559 posiblePoint = point.x>=deviceStart_y && point.x<= (bar_height+deviceStart_y) && point.y>deviceStart_x;
564 double real_x = getOrientation() ? convertToRealValue( point.x ) : convertToRealValue( point.y );
565 wxColour selectedColor = getSelectedColour();
568 addedPoint = addColorPoint (real_x, selectedColor);
570 // Inform addedPoint event
573 //RefreshForce(); Is all ready refreshed on the adition of the point method
574 createAndSendEvent( wxEVT_ADDED_POINT );
580 void pColorBar ::onLeftClicDown(wxMouseEvent& event )
582 acceptedClick = true;
585 void pColorBar ::onLeftClickUp(wxMouseEvent& event )
587 movingPointIndex = -1;
588 acceptedClick = false;
591 * Shows the popup menu
593 void pColorBar :: onShowPopupMenu (wxMouseEvent &event)
597 if(showedColorPoints.empty())
599 c_popmenu.Enable(cntID_DEL_COLOR_POINT, false);
603 c_popmenu.Enable(cntID_DEL_COLOR_POINT, true);
605 bool setClickedValues = false;
606 if( getOrientation() )
608 setClickedValues = event.GetX()>=deviceStart_x && event.GetY()<= (bar_height + deviceStart_y);
612 setClickedValues = event.GetX()>=deviceStart_y && event.GetX()<= (bar_height+deviceStart_y) && event.GetY()>deviceStart_x;
614 if (setClickedValues)
616 setClickedX ( event.GetX() );
617 setClickedY ( event.GetY() );
619 PopupMenu( &c_popmenu, event.GetX(), event.GetY());
623 //------------------------------------------------------------------------------------------------------------
624 // Other methods implementation
625 //------------------------------------------------------------------------------------------------------------
628 * Method that reinitiates attributes of the color bar to the given points
629 * param minRealValue The minimum represented value (real value)
630 * param maxRealValue The maximum represented value (real value)
632 void pColorBar :: reinitiateColorBar(double minRealValue, double maxRealValue)
635 _logicalBar -> clearPoints();
636 showedColorPoints.clear();
638 movingPointIndex = -1;
639 realX_vertical_line = -1;
641 accumTemporalPoints = 0;
642 viewingRange = false;
643 setDegradeState(true);
644 setRepresentedValues(minRealValue, maxRealValue);
648 * Method that reinitiates attributes of the color bar and set the points given by parameter
649 * param pointsVector The the vector of the new points, the color points must have at least two points.
651 void pColorBar :: reinitiateColorBarTo (std::vector<pColorPoint *> pointsVector)
653 _logicalBar -> clearPoints();
654 _logicalBar -> setColorPoints(pointsVector);
655 showedColorPoints.clear();
657 movingPointIndex = -1;
658 realX_vertical_line = -1;
660 accumTemporalPoints = 0;
661 viewingRange = false;
662 setDegradeState(true);
664 double minRealValue = _logicalBar -> getMinValue();
665 double maxRealvalue = _logicalBar -> getMaxValue();
667 setRepresentedValues(minRealValue, maxRealvalue);
671 * Method that sets a copy of the points of the color bar to the given pointer parameter
672 * param pointsList The list for getting the points
674 void pColorBar :: getPointsListWithTemps (std::vector<pColorPoint*> &pointsVector)
677 for (int a =0; a<showedColorPoints.size() ; a++)
679 cPoint = showedColorPoints[a];
680 pColorPoint* copyPoint = new pColorPoint(cPoint->getRealX(), cPoint->getColor( ), (cPoint->isTemporalColor()));
681 pointsVector.push_back(copyPoint);
686 * 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
687 * includes the teporal points created
688 * param pointsList The list for getting the points
691 void pColorBar :: getAddedColorsPointsList (std::vector<pColorPoint*> &pointsVector)
694 for (int a =0; a<_logicalBar->getCount(); a++)
696 cPoint = _logicalBar ->getPointAtIndex(a);
697 pColorPoint* copyPoint = new pColorPoint(cPoint->getRealX(), cPoint->getColor( ), (cPoint->isTemporalColor()));
698 pointsVector.push_back(copyPoint);
704 * Adds a color degrade point to the color bar.
705 * param xRealValue The real xValue of the point
706 * param theColour The assigned color for the point
707 * param temporalStart Indicates if the inserted point is the temporal startShowing point
708 * param temporalEnd Indicates if the inserted point is the temporal startShowing point
709 * return Returns true if the point was succesfully inserted.
711 bool pColorBar :: addColorPoint (double xRealValue, wxColour theColour/*, bool temporalStart, bool temporalEnd*/)
713 bool addedPoint = false;
714 addedPoint = _logicalBar->addColorPoint(xRealValue,theColour);
722 * Delets a color degrade point to the color bar.
723 * param xRealValue The real xValue of the point to delete
724 * return Returns true if the point was succesfully inserted.
726 bool pColorBar :: deleteColorPoint (double xRealValue)
728 pColorPoint* actualPoint;
729 bool deletedPoint = false;
730 for (int a =0; a<showedColorPoints.size() && !deletedPoint; a++)
732 actualPoint = showedColorPoints[a];
733 int actualX = (int)actualPoint -> getRealX();
734 bool isInsideActual = figure -> isPointInside (convertToPixelValue(actualX), convertToPixelValue(xRealValue));
735 if( actualX == xRealValue || isInsideActual)
738 deletedPoint = _logicalBar->deleteColorPoint(actualPoint -> getRealX());
747 * Changes the color degrade point color value.
748 * Informs the result of the handled event like a wxCommandEvent wxEVT_CHANGED_COLOR_POINT if the point changed its colour.
749 * param clickedValue The x-coord pixel value of the point to which the color change interests
750 * return Returns true if the color point was succesfully updated.
752 bool pColorBar :: changeColor ( int clickedValue )
754 bool colourUpdated = false;
755 double xRealValue = convertToRealValue( clickedValue );
756 pColorPoint* actualPoint;
757 for (int a =0; a<showedColorPoints.size() && !colourUpdated; a++)
759 actualPoint = showedColorPoints[a];
760 int actualX = (int)actualPoint -> getRealX();
761 bool isInsideActual = figure -> isPointInside (convertToPixelValue(actualX), clickedValue);
762 if( actualX == xRealValue || isInsideActual)
764 wxColour newColour = getSelectedColour();
767 actualPoint -> setColor(newColour);
768 colourUpdated = true;
774 return colourUpdated;
778 * Repaints the color bar in horizontal direction mode
780 void pColorBar :: repaintView( )
783 temp_dc.SelectObject( * colorBar_Bitmap );
784 temp_dc.SetBrush(wxBrush( colourParent ,wxSOLID ));
785 temp_dc.SetPen(wxPen( colourParent,1,wxSOLID ));
786 if (getOrientation())
788 temp_dc.DrawRectangle(0, 0, bar_width, bar_height);
789 temp_dc.SetPen(wxPen( wxColour(167,165,191),1,wxSOLID ));
790 temp_dc.DrawRectangle(0, 0, bar_width-deviceEndMargin, bar_height);
794 temp_dc.DrawRectangle(0, 0, bar_height, bar_width);
795 temp_dc.SetPen(wxPen( wxColour(167,165,191),1,wxSOLID ));
796 temp_dc.DrawRectangle(0, 0, bar_height, bar_width-deviceEndMargin);
798 //wxPoint figPoints[4]; // JPRx
800 if( _logicalBar -> getCount() >0)
802 updatePointsToDraw();
804 int numberEdges = figure->getNumberEdges();
806 figure->getVertexPoints(points);
807 figure ->setVertexPoints (points);
809 int maxValue = showedColorPoints.size();
810 pColorPoint * iniPoint;
811 pColorPoint * endPoint;
812 wxColor intialColor, finalColor;
813 for (int a=0; a<maxValue; a++)
815 iniPoint = showedColorPoints[a];
816 int ini_pixelX = convertToPixelValue(iniPoint -> getRealX());
817 intialColor = iniPoint -> getColor();
823 endPoint = showedColorPoints[a+1];
824 int end_pixelX = convertToPixelValue(endPoint -> getRealX());
825 finalColor = endPoint -> getColor();
827 int rectangle_width = end_pixelX - ini_pixelX;
829 //*************************************************************************************
830 int initial_r = intialColor.Red();
831 int final_r = finalColor.Red() ;
832 int initial_g = intialColor.Green();
833 int final_g= finalColor.Green();
834 int initial_b = intialColor.Blue();
835 int final_b= finalColor.Blue();
837 float m_scope_r = (float)(final_r-initial_r)/rectangle_width;
838 float m_scope_g = (float)(final_g-initial_g)/rectangle_width;
839 float m_scope_b = (float)(final_b-initial_b)/rectangle_width;
841 int next_r = initial_r;
842 int next_g = initial_g;
843 int next_b = initial_b;
845 float nxt_r = (float)next_r;
846 float nxt_g = (float)next_g;
847 float nxt_b = (float)next_b;
849 for (int Xi =ini_pixelX; Xi<= end_pixelX; Xi++)
851 temp_dc.SetBrush(wxBrush( wxColour(next_r, next_g, next_b),wxSOLID ));
852 temp_dc.SetPen(wxPen( wxColour(next_r, next_g, next_b),1,wxSOLID ));
853 if( getOrientation() )
854 temp_dc.DrawLine(Xi, 0, Xi, bar_height);
856 temp_dc.DrawLine(0, Xi, bar_height, Xi);
858 nxt_r = (m_scope_r + nxt_r);
859 nxt_g = (m_scope_g + nxt_g);
860 nxt_b = (m_scope_b + nxt_b);
862 next_r = (int)(nxt_r);
863 next_g = (int)(nxt_g);
864 next_b = (int)(nxt_b);
868 if( movingPointIndex!=-1 && movingNodePoint!=NULL )
870 if ( !(movingNodePoint -> isTemporalColor()) )
872 if( movingNodePoint==iniPoint && movingPointIndex!=-1 )
874 temp_dc.SetBrush(wxBrush( wxColour(5,36,180), wxSOLID ));
875 temp_dc.SetPen(wxPen( wxColour(239,239,239), 1, wxSOLID ));
876 if (getOrientation())
877 temp_dc.DrawPolygon(numberEdges, points, ini_pixelX, 0);
879 temp_dc.DrawPolygon(numberEdges, points, 0, ini_pixelX);
883 temp_dc.SetBrush(wxBrush( intialColor, wxSOLID ));
884 if(iniPoint->isTemporalColor())
885 temp_dc.SetPen(wxPen( intialColor, 1, wxSOLID ));
887 temp_dc.SetPen(wxPen( wxColour(0,0,0), 1, wxSOLID ));
888 if (getOrientation())
889 temp_dc.DrawPolygon(numberEdges, points, ini_pixelX, 0);
891 temp_dc.DrawPolygon(numberEdges, points, 0, ini_pixelX);
897 if ( !(iniPoint -> isTemporalColor()) )
899 temp_dc.SetBrush(wxBrush( intialColor, wxSOLID ));
900 temp_dc.SetPen(wxPen( wxColour(0,0,0), 1, wxSOLID ));
901 if (getOrientation())
902 temp_dc.DrawPolygon(numberEdges, points, ini_pixelX, 0);
904 temp_dc.DrawPolygon(numberEdges, points, 0, ini_pixelX);
908 if (realX_vertical_line!=-1)
910 temp_dc.SetPen(wxPen( guideLineColor,1,wxDOT ));
911 int pixelX_guide = convertToPixelValue(realX_vertical_line);
912 if (getOrientation())
913 temp_dc.DrawLine(pixelX_guide, 0, pixelX_guide, bar_height);
915 temp_dc.DrawLine(0, pixelX_guide, bar_height, pixelX_guide);
921 * Forces the refresh view of the color bar
923 void pColorBar :: RefreshForce ()
929 * Draws the color bar with its degrades
930 * param recentlyChangedOrientation indicates if the orientation has been changed before calling this method
932 void pColorBar :: drawColorBar (bool recentlyChangedOrientation)
934 wxRect rectTotal = GetClientRect();
935 if (recentlyChangedOrientation)
937 if ( getOrientation() ) // HORIZONTAL
939 //SetSize(width, height );
940 wxWindow::SetSize( width, height );
941 //SetSize( rectTotal.GetWidth(), rectTotal.GetHeight() );
942 setWidth(GetClientRect().GetWidth()- deviceEndMargin);
943 //setHeight(GetClientRect().GetHeight());
945 colorBar_Bitmap = new wxBitmap( bar_width+1280, bar_height+1280 );
946 //information_Bitmap = new wxBitmap( width-bar_width, height-bar_height );
950 wxWindow::SetSize( height, width );
951 //SetSize( rectTotal.GetHeight(), rectTotal.GetWidth() );
952 setWidth(GetClientRect().GetHeight()- deviceEndMargin);
953 //setHeight(GetClientRect().GetWidth());
955 //SetWindowStyle( wxNO_FULL_REPAINT_ON_RESIZE );
956 colorBar_Bitmap = new wxBitmap( bar_height+1280, bar_width+1280 );
957 //information_Bitmap = new wxBitmap( height-bar_height, width-bar_width );
963 * Changes the figure of the color points according to the parameter
964 * param figureOrientation Is the corresponding number for identifying the figure
965 * RECTANGLE = 4,TRIANGLE LEFT = -4, TRIANGLE RIGHT = -6, TRIANGLE UP = -8, TRIANGLE DOWN = -2
967 void pColorBar :: changeFigure(int figureOrientation)
969 if ( figureOrientation<1 ) //The figure is a a rotated triangle
971 changePointsFigure_Edges(3);
972 figure -> setFigureOrientation ( figureOrientation );
975 else //The figure is a rectangle
977 changePointsFigure_Edges(4);
983 * Changes the figure used for the degreade color points to the indicated one by parameter
984 * param figEdges Is the constant that represents the figure number of edges (TRIANGLE | RECTANGLE)
986 void pColorBar :: changePointsFigure_Edges(int figEdges)
988 figure->setNumberEdges( figEdges);
992 * Gets the constant that represents the figure used for the degreade color points
993 * return figureEdges Is the constant that represents the figure number of edges (TRIANGLE | RECTANGLE)
995 int pColorBar :: getPointsFigure_Edges ()
997 return (figure -> getNumberEdges());
1001 * Sets the height of the drawing bar area
1002 * param _h The height to set
1004 void pColorBar :: setHeight (int _h)
1007 bar_height = height-gapY;
1011 * Sets the height of the drawing bar area
1012 * return _h The height to get
1014 int pColorBar :: getHeight()
1020 * Sets the width of the drawing bar area
1021 * param _w The width to set
1023 void pColorBar :: setWidth (int _w)
1026 bar_width = width-gapX;
1030 * Gets the width of the drawing bar area
1031 * param width The width to get
1033 int pColorBar :: getWidth ()
1039 * Sets the height of the containing rectangle bar
1040 * param _h The height to set
1042 void pColorBar :: setBarHeight (int _h)
1048 * Gets the height of the containing rectangle bar
1049 * return bar_height The height to get
1051 int pColorBar :: getBarHeight()
1057 * Sets the width of the containing rectangle bar
1058 * param _w The width to set
1060 void pColorBar :: setBarWidth (int _w)
1066 * Gets the width of the containing rectangle bar
1067 * return bar_width The width to get
1069 int pColorBar :: getBarWidth ()
1075 * Sets the orientation of the color bar
1076 * param _orientation The orientation to set VERTICAL = false, HORIZONTAL = true
1078 void pColorBar :: setOrientation (bool _orientation)
1080 _logicalBar -> setOrientation(_orientation);
1081 figure -> setBarOrientation (_orientation);
1085 * Gets the orientation of the color bar
1086 * return bar_orientation The bar orientation assigned
1088 bool pColorBar :: getOrientation ()
1090 return _logicalBar->getOrientation();
1094 * Sets the collection of color points
1095 * param _points The new points to set, each one of data type pColorPoint ( xValue, wxColour_assigned)
1097 void pColorBar :: setPoints (std::vector<pColorPoint *> _points)
1099 _logicalBar->clearPoints();
1100 showedColorPoints.clear();
1101 _logicalBar->setColorPoints(_points);
1102 //posible needed to update
1106 * Gets the last clickedX pixel coord inside the bar.
1107 * return clickedX The x-coord pixel value
1109 int pColorBar :: getClickedX()
1115 * Sets the last clickedX pixel coord inside the bar.
1116 * param xCoordPixel The x-coord value to set
1118 void pColorBar :: setClickedX(int xCoordPixel)
1120 clickedX = xCoordPixel;
1124 * Gets the last clickedY pixel coord inside the bar.
1125 * return clickedY The y-coord pixel value
1127 int pColorBar :: getClickedY()
1133 * Sets the last clickedY pixel coord inside the bar.
1134 * param yCoordPixel The y-coord pixel value to set
1136 void pColorBar :: setClickedY(int yCoordPixel)
1138 clickedY = yCoordPixel;
1142 * 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)
1143 * param x_Pixel The pixel value to convert into real value with respect to the x scale
1144 * return realX The real-x value corresponding to the xPixel
1146 double pColorBar :: convertToRealValue ( int x_Pixel )
1149 int newPixel = x_Pixel*(bar_width - deviceEndMargin - deviceStart_x)/(bar_width) ;
1150 return newPixel*(maxX_represented_Tshow - minX_represented_Tshow)/(bar_width);
1152 return minX_represented_Tshow + ((x_Pixel-deviceStart_x) * (maxX_represented_Tshow - minX_represented_Tshow) ) /( bar_width-deviceEndMargin);
1156 * 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)
1157 * param x_Pixel The pixel value to convert into real value with respect to the x scale
1158 * return realX The real-x value corresponding to the xPixel
1160 int pColorBar :: convertToPixelValue (double x_real )
1162 return (int)( ((x_real - minX_represented_Tshow) * (bar_width-deviceEndMargin))/(maxX_represented_Tshow - minX_represented_Tshow) );
1166 * Gets the selected color and updates the state of the okSelectedColor
1167 * return selectedColor Is the selected rbg color
1169 wxColour pColorBar :: getSelectedColour()
1171 okSelectedColor = false;
1174 wxColourDialog dialog( GetParent(), &data);
1176 if ( dialog.ShowModal() == wxID_OK )
1178 col = dialog.GetColourData().GetColour();
1179 okSelectedColor = true;
1185 * Sets the represented minimum and maximunm values
1186 * param minRealValue The minimum represented value (real value)
1187 * param maxRealValue The maximum represented value (real value)
1189 void pColorBar :: setRepresentedValues ( double minRealValue, double maxRealValue )
1191 temporalMinXToShow = (int)minRealValue;
1192 temporalMaxXToShow = (int)maxRealValue;
1194 minX_represented_Tshow = (int)minRealValue;
1195 maxX_represented_Tshow = (int)maxRealValue;
1196 _logicalBar->setMinValue(minX_represented_Tshow);
1197 _logicalBar->setMaxValue(maxX_represented_Tshow);
1201 * Gets the data of the last point moving in a pColorPoint copy
1202 * return pointData Is a pColorPoint with the data of las moved color
1204 pColorPoint * pColorBar :: getLastMovedColorPoint()
1206 pColorPoint * dataPoint = new pColorPoint ( 0, wxColor (0,0,0), false);
1207 if (movingNodePoint)
1209 dataPoint ->setColor(movingNodePoint->getColor());
1210 dataPoint ->setRealX(movingNodePoint->getRealX());
1216 * Sets the gap values for the color bar bitmap
1217 * param gap_x Gap in x
1218 * param gap_y Gap in y
1220 void pColorBar :: setGapValues (int gap_x, int gap_y)
1227 * Sets the degrade state of the color bar
1228 * param newState The degrade stare to set
1230 void pColorBar :: setDegradeState(bool newState)
1232 doingDegrade = newState;
1236 * Gets the degrade state of the color bar
1237 * return doingDegrade is the actual degrade state of the bar
1239 bool pColorBar :: getDegradeState()
1241 return doingDegrade;
1245 * Sets the visible range of the bar and repaints the bar according to it, the min value must be less than the max value.
1246 * param minToShow Is the minimum value to show in the colorbar
1247 * param maxToShow Is the maximum value to show in the colorbar
1249 void pColorBar :: setVisibleRange(int minToShow, int maxToShow)
1251 minX_represented_Tshow = minToShow;
1252 maxX_represented_Tshow = maxToShow;
1253 viewingRange = true;
1258 * Sets the state of static or not for the limit color points
1259 * pamar areStatic Is the state to set for the limits
1261 void pColorBar :: setStaticLimitsTo(bool areStatic)
1263 staticLimits = areStatic;
1267 * Gets the state of static or not for the limit color points
1268 * return staticLimits Is the state for limits
1270 bool pColorBar :: getStaticLimits()
1272 return staticLimits;
1276 * Sets the device start drawing left-superior (pixel) start point and draws automatically the color bar
1277 * param deviceStart_x Pixel start for x-coord
1278 * param deviceStart_y Pixel start for y-coord
1280 void pColorBar :: setDeviceBlitStart ( wxCoord devStart_x, wxCoord devStart_y )
1282 deviceStart_x = devStart_x;
1283 deviceStart_y = devStart_y;
1284 if (getOrientation())
1285 width += deviceStart_x;
1287 height += deviceStart_y;
1292 * Clears the temporal color points of the list
1294 void pColorBar :: clearTemporalColors()
1301 * param activeNow The new state
1303 void pColorBar :: setActiveStateTo (bool activeNow)
1305 activeState = activeNow;
1309 * Gets the active state of the bar
1310 * return isActive The actual state
1312 bool pColorBar :: isActive()
1318 * Gets the real-x value to draw a vertical line
1319 * return realX_vertical_line The real x value for the vertical line
1321 int pColorBar :: getRealX_vertical_line()
1323 return realX_vertical_line;
1327 * Sets the real-x value to draw a vertical line
1328 * param realX_vertical_line The new real x value for the vertical line
1330 void pColorBar :: setRealX_vertical_line(int newReal_x)
1332 realX_vertical_line = newReal_x;
1336 * Sets the new device (deviceEndMargin) value form the end of this panel to the end of the drawing area in the device
1337 * param newDeviceEnd_pixels The new pixel value to asign to the right(horizontal view), underneath(vertical view) margin in pixels
1339 void pColorBar :: setDeviceEndMargin(int newDeviceEnd_pixels)
1341 deviceEndMargin = newDeviceEnd_pixels;
1344 void pColorBar :: createAndSendEvent(WXTYPE theEventType)
1346 wxCommandEvent cevent( theEventType, GetId() );
1347 cevent.SetEventObject( this );
1348 GetEventHandler()->ProcessEvent( cevent );
1353 Returns the number of points that the bar color has
1355 int pColorBar::getColorPointsSize()
1357 return _logicalBar->getCount();
1361 Get the RGB values of the color point that is in the
1362 index given with respecto to the
1364 void pColorBar::getDataAt(int index, double& x,int& red,int& green,int& blue)
1366 //******************************
1367 _logicalBar->getDataAt(index, x, red, green, blue);
1371 * Sets the guide line color
1372 * param theNwGuideLineColor The color to set to the guideLineColor
1374 void pColorBar :: setGuideLineColour(wxColour theNwGuideLineColor)
1376 guideLineColor = theNwGuideLineColor;
1380 * Gets the guide line color
1381 * return guideLineColor The color of the guideLine
1383 wxColour pColorBar :: getGuideLineColour()
1385 return guideLineColor;
1389 * Sets the guide line color
1390 * param theNwGuideLineColor The color to set to the guideLineColor
1392 void pColorBar :: setBackGroundColour(wxColour theNwBackColor)
1394 colourParent = theNwBackColor;
1398 * Gets the guide line color
1399 * return guideLineColor The color of the guideLine
1401 wxColour pColorBar :: getBackGroundColour()
1403 return colourParent;
1407 * Gets the min value of the color bar
1409 double pColorBar :: getMinValue()
1411 return (double)minX_represented_Tshow;
1415 * Gets the max value of the color bar
1417 double pColorBar :: getMaxValue()
1419 return (double)maxX_represented_Tshow;
1423 void pColorBar :: updatePointsToDraw()
1425 accumTemporalPoints = 0;
1426 if (_logicalBar->getCount()>0)
1428 showedColorPoints.clear();
1430 int startIndex, endIndex;
1431 _logicalBar -> getPointersToRangeLimits( showedColorPoints, startIndex, endIndex, minX_represented_Tshow, maxX_represented_Tshow );
1433 int internalCount = _logicalBar->getCount();
1434 std::deque <pColorPoint*>::iterator iterStart = showedColorPoints.begin( );
1435 std::deque <pColorPoint*>::iterator iterEnd = showedColorPoints.end( );
1437 int pixelTmpStart = convertToPixelValue (minX_represented_Tshow);
1438 int pixelTmpEnd = convertToPixelValue (maxX_represented_Tshow);
1439 int initial_r, final_r, initial_g, final_g, initial_b, final_b, rectangle_width;
1440 double realINI, realEND;
1442 bool includeTempStart = false;
1443 bool includeTempEnd = false;
1444 //-----------------Adding the first visible point of the list
1445 if(showedColorPoints.size()>0)
1447 includeTempStart = (int)(showedColorPoints.front()->getRealX())>minX_represented_Tshow ;
1448 includeTempEnd = (int)(showedColorPoints.back()->getRealX())<maxX_represented_Tshow ;
1449 if( startIndex >= 0 )
1451 if( startIndex == 0 )
1453 //The temporal showing point for the start should have the same color of the initial point in range at startIndex
1454 _logicalBar -> getDataAt( startIndex, realINI, initial_r, initial_g, initial_b );
1455 realINI = minX_represented_Tshow;
1456 _logicalBar -> getDataAt( startIndex, realEND, final_r, final_g, final_b );
1458 else if( startIndex > 0 )
1460 _logicalBar -> getDataAt( startIndex-1, realINI, initial_r, initial_g, initial_b );
1461 _logicalBar -> getDataAt( startIndex, realEND, final_r, final_g, final_b );
1464 if( includeTempStart )
1466 int ini_pixelX = convertToPixelValue( realINI );
1467 int end_pixelX = convertToPixelValue( realEND );
1469 rectangle_width = end_pixelX - ini_pixelX;
1471 float m_scope_r = (float)(final_r-initial_r)/rectangle_width;
1472 float m_scope_g = (float)(final_g-initial_g)/rectangle_width;
1473 float m_scope_b = (float)(final_b-initial_b)/rectangle_width;
1476 float bRed = initial_r - m_scope_r*pixelTmpStart;
1477 float bGreen = initial_g - m_scope_g*pixelTmpStart;
1478 float bBlue = initial_b - m_scope_b*pixelTmpStart;
1480 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));
1482 accumTemporalPoints ++;
1485 if( includeTempEnd && minX_represented_Tshow < maxX_represented_Tshow )
1487 if( internalCount>0 )
1489 if( endIndex == internalCount-1 )
1491 _logicalBar -> getDataAt( endIndex, realINI, initial_r, initial_g, initial_b );
1492 _logicalBar -> getDataAt( endIndex, realEND, final_r, final_g, final_b );
1493 realEND = maxX_represented_Tshow;
1497 _logicalBar -> getDataAt( endIndex, realINI, initial_r, initial_g, initial_b );
1498 _logicalBar -> getDataAt( endIndex+1, realEND, final_r, final_g, final_b );
1501 int ini_pixelX = convertToPixelValue( realINI );
1502 int end_pixelX = convertToPixelValue( realEND );
1504 rectangle_width = end_pixelX - ini_pixelX;
1506 float m_scope_r = (float)(final_r-initial_r)/rectangle_width;
1507 float m_scope_g = (float)(final_g-initial_g)/rectangle_width;
1508 float m_scope_b = (float)(final_b-initial_b)/rectangle_width;
1510 float bRed = initial_r - m_scope_r*pixelTmpEnd;
1511 float bGreen = initial_g - m_scope_g*pixelTmpEnd;
1512 float bBlue = initial_b - m_scope_b*pixelTmpEnd;
1513 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));
1514 accumTemporalPoints ++;
1520 if(_logicalBar->getCount()>0)
1522 if ( minX_represented_Tshow > _logicalBar->getMaxAddedValue() )
1524 endIndex = _logicalBar->getCount()-1;
1526 else if ( maxX_represented_Tshow < _logicalBar->getMinAddedValue() )
1531 _logicalBar -> getDataAt( endIndex, realINI, initial_r, initial_g, initial_b );
1532 _logicalBar -> getDataAt( endIndex, realEND, final_r, final_g, final_b );
1534 realINI = minX_represented_Tshow;
1535 realEND = maxX_represented_Tshow;
1537 showedColorPoints.push_back( new pColorPoint ( realINI, wxColour( initial_r, initial_g, initial_b ), true));
1538 accumTemporalPoints ++;
1539 showedColorPoints.push_back( new pColorPoint ( realEND, wxColour( initial_r, initial_g, initial_b ), true));
1540 accumTemporalPoints ++;
1545 if ( !showedColorPoints.empty() )
1547 startNode_show = showedColorPoints.front();
1548 lastNode_show = showedColorPoints.back();