//------------------------------------------------------------------------------------------------------------ // Class definition include //------------------------------------------------------------------------------------------------------------ #include "LogicalColorBar.h" //------------------------------------------------------------------------------------------------------------ // Class implementation //------------------------------------------------------------------------------------------------------------ /** file LogicalColorBar.cxx */ //------------------------------------------------------------------------------------------------------------ // Constructors & Destructors //------------------------------------------------------------------------------------------------------------ LogicalColorBar :: LogicalColorBar () { minValue = 0; maxValue = 0; bar_orientation = true; } LogicalColorBar :: ~ LogicalColorBar () { //logicColorPoints.clear(); } //------------------------------------------------------------------------------------------------------------ // Methods Implementation //------------------------------------------------------------------------------------------------------------ // // Gets the first point // pColorPoint * LogicalColorBar :: getFirstPoint() { return logicColorPoints.front(); } // // Gets the last point // pColorPoint * LogicalColorBar :: getLastPoint() { return logicColorPoints.back(); } double LogicalColorBar :: getMinValue() { return minValue; } void LogicalColorBar :: setMinValue(double valueMin) { minValue = valueMin; } double LogicalColorBar :: getMaxValue() { return maxValue; } void LogicalColorBar :: setMaxValue(double valueMax) { maxValue = valueMax; } bool LogicalColorBar :: getOrientation() { return bar_orientation; } void LogicalColorBar :: setOrientation(bool orientation) { bar_orientation = orientation; } // // Adds a color degrade point to the color bar. // param xRealValue The real xValue of the point // param theColour The assigned color for the point // param temporalStart Indicates if the inserted point is the temporal startShowing point // param temporalEnd Indicates if the inserted point is the temporal startShowing point // return Returns true if the point was succesfully inserted. //// bool LogicalColorBar :: addColorPoint (double xRealValue, wxColour theColour ) { bool addedPoint = false; if(xRealValue>=minValue && xRealValue<=maxValue) { bool ifContinue = true; //pColorPoint * colorPoint, nextColorPoint; int maxIndex= logicColorPoints.size()-1; int nextIndex = 0; int nextX = 0; int i = 0; std::vector ::iterator iter; std::vector ::iterator nextIter; pColorPoint * newColorPoint = new pColorPoint ( xRealValue, theColour, false ); if(logicColorPoints.empty()) { logicColorPoints.push_back(newColorPoint); addedPoint = true; } for ( iter = logicColorPoints.begin(); i<=maxIndex && !addedPoint; iter++ ) { nextIter = iter; int before = (*iter)->getRealX() ; if(before>xRealValue && i==0) { //Is the first point logicColorPoints.insert( iter, newColorPoint ); addedPoint =true; lastAddedPoint = newColorPoint; } else if(beforegetRealX(); if( before < xRealValue && after> xRealValue) { logicColorPoints.insert( nextIter, newColorPoint ); addedPoint =true; lastAddedPoint = newColorPoint; } } i++; } } return addedPoint; } bool LogicalColorBar :: deleteColorPoint ( double valErase ) { bool deletedPoint = false; std::vector ::iterator pointIterator = logicColorPoints.begin(); for(int i=0; i &theInputQueue, int &startIndex, int &endIndex, int startSearched, int endSearched ) //void LogicalColorBar :: getListIndexRangeLimits( std::vector &theVector, bool &startFOUND, bool &endFOUND, int startSearched, int endSearched ); { bool foundedStart = false; bool foundedEnd = false; /*for (int i=0; igetRealX(); if(!foundedStart) { if((startSearched <= actualValue) ) { startIndex = i; if((startSearched == actualValue) ) foundedStart = true; } } if(!foundedEnd) { if((actualValue <= endSearched) ) { endIndex = i; if((endSearched == actualValue)) foundedEnd = true; } } } */ for (int i=0; igetRealX(); if(!foundedStart) { if((startSearched <= actualValue) ) { startIndex = i; //if((startSearched == actualValue) ) foundedStart = true; } } if(!foundedEnd) { if((actualValue <= endSearched) ) { endIndex = i; if((endSearched == actualValue)) { foundedEnd = true; } } } if(actualValue>=startSearched && actualValue<=endSearched) { if(startSearched=0 && logicColorPoints.size()>anIndex) return logicColorPoints[anIndex]; else return NULL; } int LogicalColorBar :: getCount() { return logicColorPoints.size(); } void LogicalColorBar :: getDataAt(int index, double &x,int &red,int &green,int &blue) { pColorPoint * colorPoint = logicColorPoints[index]; wxColour color = colorPoint->getColor(); red = color.Red(); blue = color.Blue(); green = color.Green(); x = colorPoint->getRealX(); } void LogicalColorBar :: clearPoints() { logicColorPoints.clear(); } double LogicalColorBar :: getMinAddedValue() { return logicColorPoints.front()->getRealX(); } double LogicalColorBar :: getMaxAddedValue() { return logicColorPoints.back()->getRealX(); } void LogicalColorBar :: changeColor(double pointValue, wxColour theNewColor) { bool changedCol = false; for(int i=0; igetRealX() == pointValue) { aPoint->setColor( theNewColor ); changedCol = true; } } } bool LogicalColorBar :: setColorPoints (std::vector pointsVector) { bool addedAll = true; for(int i=0; igetRealX(), aPoint->getColor()); } if(addedAll) { minValue = getMinAddedValue(); maxValue = getMaxAddedValue(); } else logicColorPoints.clear(); return addedAll; }