#include <LogicalColorBar.h>
Public Member Functions | |
LogicalColorBar () | |
~LogicalColorBar () | |
pColorPoint * | getFirstPoint () |
pColorPoint * | getLastPoint () |
double | getMinValue () |
void | setMinValue (double valueMin) |
double | getMaxValue () |
void | setMaxValue (double valueMax) |
bool | getOrientation () |
void | setOrientation (bool orientation) |
bool | addColorPoint (double xRealValue, wxColour theColour) |
bool | deleteColorPoint (double valErase) |
void | getPointersToRangeLimits (std::deque< pColorPoint * > &theInputQueue, int &startIndex, int &endIndex, int startSearched, int endSearched) |
pColorPoint * | getLastAddedPoint () |
pColorPoint * | getPointAtIndex (int anIndex) |
int | getCount () |
void | getDataAt (int index, double &x, int &red, int &green, int &blue) |
void | clearPoints () |
double | getMinAddedValue () |
double | getMaxAddedValue () |
void | changeColor (double pointValue, wxColour theNewColor) |
bool | setColorPoints (std::vector< pColorPoint * > pointsVector) |
Public Attributes | |
bool | bar_orientation |
std::vector< pColorPoint * > | logicColorPoints |
pColorPoint * | lastAddedPoint |
double | minValue |
double | maxValue |
file LogicalColorBar.h
Definition at line 31 of file LogicalColorBar.h.
LogicalColorBar::LogicalColorBar | ( | ) |
file LogicalColorBar.cxx
Definition at line 17 of file LogicalColorBar.cxx.
References bar_orientation, maxValue, and minValue.
00018 { 00019 minValue = 0; 00020 maxValue = 0; 00021 bar_orientation = true; 00022 }
LogicalColorBar::~LogicalColorBar | ( | ) |
Definition at line 24 of file LogicalColorBar.cxx.
bool LogicalColorBar::addColorPoint | ( | double | xRealValue, | |
wxColour | theColour | |||
) |
Definition at line 95 of file LogicalColorBar.cxx.
References pColorPoint::getRealX(), lastAddedPoint, logicColorPoints, maxValue, and minValue.
Referenced by pColorBar::addColorPoint(), and setColorPoints().
00096 { 00097 bool addedPoint = false; 00098 00099 if(xRealValue>=minValue && xRealValue<=maxValue) 00100 { 00101 // bool ifContinue = true; // JPRx 00102 //pColorPoint * colorPoint, nextColorPoint; 00103 int maxIndex= logicColorPoints.size()-1; 00104 // int nextIndex = 0; // JPRx 00105 //int nextX = 0; // JPRx 00106 int i = 0; 00107 00108 std::vector <pColorPoint*>::iterator iter; 00109 std::vector <pColorPoint*>::iterator nextIter; 00110 pColorPoint * newColorPoint = new pColorPoint ( xRealValue, theColour, false ); 00111 if(logicColorPoints.empty()) 00112 { 00113 logicColorPoints.push_back(newColorPoint); 00114 addedPoint = true; 00115 }else{ 00116 iter = logicColorPoints.begin(); 00117 for (i=0; i<=maxIndex && !addedPoint; i++) 00118 { 00119 nextIter = iter; 00120 int before = (*iter)->getRealX() ; 00121 if(before>xRealValue && i==0) 00122 { 00123 //Is the first point 00124 logicColorPoints.insert( iter, newColorPoint ); 00125 addedPoint =true; 00126 lastAddedPoint = newColorPoint; 00127 } 00128 else if(before<xRealValue && i==maxIndex) 00129 { 00130 //Is the last point 00131 logicColorPoints.push_back(newColorPoint ); 00132 addedPoint =true; 00133 lastAddedPoint = newColorPoint; 00134 } 00135 else if(i<maxIndex) 00136 { 00137 // 00138 nextIter++; 00139 int after = (*nextIter)->getRealX(); 00140 if( before < xRealValue && after> xRealValue) 00141 { 00142 logicColorPoints.insert( nextIter, newColorPoint ); 00143 addedPoint =true; 00144 lastAddedPoint = newColorPoint; 00145 } 00146 } 00147 //std::cout<<"JCPaddColorPoint iterator "<<*iter<<std::endl; 00148 if(!addedPoint) 00149 ++iter; 00150 } 00151 } 00152 } 00153 return addedPoint; 00154 }
void LogicalColorBar::changeColor | ( | double | pointValue, | |
wxColour | theNewColor | |||
) |
Definition at line 279 of file LogicalColorBar.cxx.
References pColorPoint::getRealX(), logicColorPoints, and pColorPoint::setColor().
00280 { 00281 bool changedCol = false; 00282 for(int i=0; i<logicColorPoints.size() && !changedCol; i++) 00283 { 00284 pColorPoint * aPoint = logicColorPoints[i]; 00285 if(aPoint->getRealX() == pointValue) 00286 { 00287 aPoint->setColor( theNewColor ); 00288 changedCol = true; 00289 } 00290 } 00291 }
void LogicalColorBar::clearPoints | ( | ) |
Definition at line 264 of file LogicalColorBar.cxx.
References logicColorPoints.
Referenced by pColorBar::setPoints().
00265 { 00266 logicColorPoints.clear(); 00267 }
bool LogicalColorBar::deleteColorPoint | ( | double | valErase | ) |
Definition at line 156 of file LogicalColorBar.cxx.
References pColorPoint::getRealX(), and logicColorPoints.
Referenced by pColorBar::deleteColorPoint().
00157 { 00158 bool deletedPoint = false; 00159 std::vector <pColorPoint*>::iterator pointIterator = logicColorPoints.begin(); 00160 for(int i=0; i<logicColorPoints.size() && !deletedPoint; i++) 00161 { 00162 pColorPoint aPoint =**pointIterator; 00163 if(aPoint.getRealX() == valErase) 00164 { 00165 logicColorPoints.erase(pointIterator); 00166 deletedPoint = true; 00167 } 00168 pointIterator++; 00169 } 00170 return deletedPoint; 00171 }
int LogicalColorBar::getCount | ( | ) |
Definition at line 249 of file LogicalColorBar.cxx.
References logicColorPoints.
Referenced by pColorBar::getAddedColorsPointsList(), pColorBar::getColorPointsSize(), pColorBar::onMouseMove(), and pColorBar::updatePointsToDraw().
00250 { 00251 return logicColorPoints.size(); 00252 }
void LogicalColorBar::getDataAt | ( | int | index, | |
double & | x, | |||
int & | red, | |||
int & | green, | |||
int & | blue | |||
) |
Definition at line 254 of file LogicalColorBar.cxx.
References pColorPoint::getColor(), pColorPoint::getRealX(), and logicColorPoints.
Referenced by pColorBar::getDataAt().
00255 { 00256 pColorPoint * colorPoint = logicColorPoints[index]; 00257 wxColour color = colorPoint->getColor(); 00258 red = color.Red(); 00259 blue = color.Blue(); 00260 green = color.Green(); 00261 x = colorPoint->getRealX(); 00262 }
pColorPoint * LogicalColorBar::getFirstPoint | ( | ) |
Definition at line 38 of file LogicalColorBar.cxx.
References logicColorPoints.
00039 { 00040 return logicColorPoints.front(); 00041 }
pColorPoint * LogicalColorBar::getLastAddedPoint | ( | ) |
Definition at line 235 of file LogicalColorBar.cxx.
References lastAddedPoint.
00236 { 00237 return lastAddedPoint; 00238 }
pColorPoint * LogicalColorBar::getLastPoint | ( | ) |
Definition at line 47 of file LogicalColorBar.cxx.
References logicColorPoints.
00048 { 00049 return logicColorPoints.back(); 00050 }
double LogicalColorBar::getMaxAddedValue | ( | ) |
Definition at line 274 of file LogicalColorBar.cxx.
References logicColorPoints.
Referenced by setColorPoints(), and pColorBar::updatePointsToDraw().
00275 { 00276 return logicColorPoints.back()->getRealX(); 00277 }
double LogicalColorBar::getMaxValue | ( | ) |
Definition at line 65 of file LogicalColorBar.cxx.
References maxValue.
00066 { 00067 return maxValue; 00068 }
double LogicalColorBar::getMinAddedValue | ( | ) |
Definition at line 269 of file LogicalColorBar.cxx.
References logicColorPoints.
Referenced by setColorPoints().
00270 { 00271 return logicColorPoints.front()->getRealX(); 00272 }
double LogicalColorBar::getMinValue | ( | ) |
Definition at line 53 of file LogicalColorBar.cxx.
References minValue.
00054 { 00055 return minValue; 00056 }
bool LogicalColorBar::getOrientation | ( | ) |
Definition at line 77 of file LogicalColorBar.cxx.
References bar_orientation.
Referenced by pColorBar::getOrientation().
00078 { 00079 return bar_orientation; 00080 }
pColorPoint * LogicalColorBar::getPointAtIndex | ( | int | anIndex | ) |
Definition at line 240 of file LogicalColorBar.cxx.
References logicColorPoints.
Referenced by pColorBar::getAddedColorsPointsList().
00241 { 00242 if(anIndex>=0 && logicColorPoints.size()>anIndex) 00243 return logicColorPoints[anIndex]; 00244 else 00245 return NULL; 00246 }
void LogicalColorBar::getPointersToRangeLimits | ( | std::deque< pColorPoint * > & | theInputQueue, | |
int & | startIndex, | |||
int & | endIndex, | |||
int | startSearched, | |||
int | endSearched | |||
) |
Definition at line 173 of file LogicalColorBar.cxx.
References pColorPoint::getRealX(), and logicColorPoints.
00175 { 00176 bool foundedStart = false; 00177 bool foundedEnd = false; 00178 00179 /*for (int i=0; i<logicColorPoints.size()&&(!foundedStart || !foundedEnd);i++) 00180 { 00181 pColorPoint colorPoint = logicColorPoints[i]; 00182 double actualValue = colorPoint->getRealX(); 00183 if(!foundedStart) 00184 { 00185 if((startSearched <= actualValue) ) 00186 { 00187 startIndex = i; 00188 if((startSearched == actualValue) ) 00189 foundedStart = true; 00190 } 00191 } 00192 if(!foundedEnd) 00193 { 00194 if((actualValue <= endSearched) ) 00195 { 00196 endIndex = i; 00197 if((endSearched == actualValue)) 00198 foundedEnd = true; 00199 } 00200 } 00201 } */ 00202 00203 for (int i=0; i<logicColorPoints.size()&& !foundedEnd;i++) 00204 { 00205 pColorPoint * colorPoint = logicColorPoints[i]; 00206 double actualValue = colorPoint->getRealX(); 00207 if(!foundedStart) 00208 { 00209 if((startSearched <= actualValue) ) 00210 { 00211 startIndex = i; 00212 //if((startSearched == actualValue) ) 00213 foundedStart = true; 00214 } 00215 } 00216 if(!foundedEnd) 00217 { 00218 if((actualValue <= endSearched) ) 00219 { 00220 endIndex = i; 00221 if((endSearched == actualValue)) 00222 { 00223 foundedEnd = true; 00224 } 00225 } 00226 } 00227 if(actualValue>=startSearched && actualValue<=endSearched) 00228 { 00229 if(startSearched<endSearched) 00230 theInputQueue.push_back(colorPoint); 00231 } 00232 } 00233 }
bool LogicalColorBar::setColorPoints | ( | std::vector< pColorPoint * > | pointsVector | ) |
Definition at line 293 of file LogicalColorBar.cxx.
References addColorPoint(), pColorPoint::getColor(), getMaxAddedValue(), getMinAddedValue(), pColorPoint::getRealX(), logicColorPoints, maxValue, and minValue.
Referenced by pColorBar::setPoints().
00294 { 00295 bool addedAll = true; 00296 for(int i=0; i<pointsVector.size() && addedAll; i++) 00297 { 00298 pColorPoint * aPoint = pointsVector[i]; 00299 addedAll &= addColorPoint(aPoint->getRealX(), aPoint->getColor()); 00300 } 00301 if(addedAll) 00302 { 00303 minValue = getMinAddedValue(); 00304 maxValue = getMaxAddedValue(); 00305 } 00306 else 00307 logicColorPoints.clear(); 00308 00309 return addedAll; 00310 }
void LogicalColorBar::setMaxValue | ( | double | valueMax | ) |
Definition at line 71 of file LogicalColorBar.cxx.
References maxValue.
Referenced by pColorBar::setRepresentedValues().
00072 { 00073 maxValue = valueMax; 00074 }
void LogicalColorBar::setMinValue | ( | double | valueMin | ) |
Definition at line 59 of file LogicalColorBar.cxx.
References minValue.
Referenced by pColorBar::setRepresentedValues().
00060 { 00061 minValue = valueMin; 00062 }
void LogicalColorBar::setOrientation | ( | bool | orientation | ) |
Definition at line 82 of file LogicalColorBar.cxx.
References bar_orientation.
00083 { 00084 bar_orientation = orientation; 00085 }
Definition at line 97 of file LogicalColorBar.h.
Referenced by getOrientation(), LogicalColorBar(), and setOrientation().
Definition at line 102 of file LogicalColorBar.h.
Referenced by addColorPoint(), and getLastAddedPoint().
std::vector<pColorPoint * > LogicalColorBar::logicColorPoints |
Definition at line 100 of file LogicalColorBar.h.
Referenced by addColorPoint(), changeColor(), clearPoints(), deleteColorPoint(), getCount(), getDataAt(), getFirstPoint(), getLastPoint(), getMaxAddedValue(), getMinAddedValue(), getPointAtIndex(), getPointersToRangeLimits(), and setColorPoints().
double LogicalColorBar::maxValue |
Definition at line 106 of file LogicalColorBar.h.
Referenced by addColorPoint(), getMaxValue(), LogicalColorBar(), setColorPoints(), and setMaxValue().
double LogicalColorBar::minValue |
Definition at line 104 of file LogicalColorBar.h.
Referenced by addColorPoint(), getMinValue(), LogicalColorBar(), setColorPoints(), and setMinValue().