#include <pFigure.h>
Public Types | |
enum | { LEFT = -4, RIGHT = -6, UP = -8, DOWN = -2 } |
Public Member Functions | |
pFigure (int edges_n, int _w, int _h, int _orientation, bool bar_orientation) | |
~pFigure () | |
int | getNumberEdges () |
void | setNumberEdges (int n_edges) |
void | getVertexPoints (wxPoint thePoints[]) |
void | setVertexPoints (wxPoint *n_points) |
void | setHeigth (int _h) |
int | getHeigth () |
void | setWidth (int _w) |
int | getWidth () |
bool | isPointInside (int xFig_PixelPoint, int xPixel) |
void | setBarOrientation (bool bar_orientation) |
void | setFigureOrientation (int fig_orientation) |
Private Attributes | |
int | heigth |
int | width |
int | edges |
int | orientation |
bool | barOrientation |
wxPoint * | v_points |
Definition at line 17 of file pFigure.h.
anonymous enum |
pFigure::pFigure | ( | int | edges_n, | |
int | _w, | |||
int | _h, | |||
int | _orientation, | |||
bool | bar_orientation | |||
) |
Create a figure with edges_n edges
edges_n | The number of edges of the new figure | |
_w | The width to set | |
_h | The height to set | |
_orientation | The figure orientation to set | |
bar_orientation | The figure orientation to set |
Create a figure with edges_n edges
edges_n | The number of edges of the new figure | |
_w | The width to set | |
_h | The height to set | |
_orientation | The orientation to set |
Definition at line 32 of file pFigure.cxx.
00033 { 00034 edges = edges_n; 00035 orientation = _orientation; 00036 width = _w; 00037 heigth = _h; 00038 setBarOrientation( bar_orientation ); 00039 }
pFigure::~pFigure | ( | ) |
Definition at line 41 of file pFigure.cxx.
int pFigure::getHeigth | ( | ) |
int pFigure::getNumberEdges | ( | ) |
Gets the number of edges of the figure
edges | Number of edges in the figure |
Definition at line 54 of file pFigure.cxx.
References edges.
Referenced by pColorBar::repaintView().
00055 { 00056 return edges; 00057 }
void pFigure::getVertexPoints | ( | wxPoint | thePoints[] | ) |
Gets the vertex points of the figure
wxPoint | The vector to get the points |
points | Vertex points distribution in the figure |
Definition at line 73 of file pFigure.cxx.
References barOrientation, DOWN, edges, heigth, LEFT, orientation, RECTANGLE, RIGHT, TRIANGLE, UP, and width.
Referenced by pColorBar::repaintView().
00074 { 00075 if (edges == TRIANGLE) 00076 { 00077 int halfWidth = 0; 00078 int halfHeigth = 0; 00079 if ( barOrientation ) // HORIZONTAL 00080 { 00081 halfWidth = (int)(width/2); 00082 halfHeigth = (int)(heigth/2); 00083 switch ( orientation ) 00084 { 00085 case UP : 00086 thePoints[0].x = halfWidth; 00087 thePoints[0].y = 0; 00088 thePoints[1].x = width; 00089 thePoints[1].y = heigth; 00090 thePoints[2].x = -halfWidth; 00091 thePoints[2].y = heigth; 00092 break; 00093 00094 case DOWN : 00095 thePoints[0].x = halfWidth; 00096 thePoints[0].y = heigth; 00097 thePoints[1].x = width; 00098 thePoints[1].y = 0; 00099 thePoints[2].x = -halfWidth; 00100 thePoints[2].y = 0; 00101 break; 00102 00103 case LEFT : 00104 thePoints[0].x = 0; 00105 thePoints[0].y = halfHeigth; 00106 thePoints[1].x = width; 00107 thePoints[1].y = 0; 00108 thePoints[2].x = width; 00109 thePoints[2].y = heigth; 00110 break; 00111 00112 case RIGHT : 00113 thePoints[0].x = width; 00114 thePoints[0].y = halfHeigth; 00115 thePoints[1].x = 0; 00116 thePoints[1].y = 0; 00117 thePoints[2].x = 0; 00118 thePoints[2].y = heigth; 00119 break; 00120 } 00121 } 00122 else // VERTICAL 00123 { 00124 halfWidth = (int)(heigth/2); 00125 halfHeigth = (int)(width/2); 00126 switch ( orientation ) 00127 { 00128 case UP : 00129 thePoints[0].x = halfWidth; 00130 thePoints[0].y = 0; 00131 thePoints[1].x = heigth; 00132 thePoints[1].y = width; 00133 thePoints[2].x = -halfWidth; 00134 thePoints[2].y = width; 00135 break; 00136 00137 case DOWN : 00138 thePoints[0].x = halfWidth; 00139 thePoints[0].y = width; 00140 thePoints[1].x = heigth; 00141 thePoints[1].y = 0; 00142 thePoints[2].x = -halfWidth; 00143 thePoints[2].y = 0; 00144 break; 00145 00146 case LEFT : 00147 thePoints[0].x = 0; 00148 thePoints[0].y = halfHeigth; 00149 thePoints[1].x = heigth; 00150 thePoints[1].y = -halfHeigth; 00151 thePoints[2].x = heigth; 00152 thePoints[2].y = width; 00153 break; 00154 00155 case RIGHT : 00156 thePoints[0].x = heigth; 00157 thePoints[0].y = halfHeigth; 00158 thePoints[1].x = 0; 00159 thePoints[1].y = -halfHeigth; 00160 thePoints[2].x = 0; 00161 thePoints[2].y = width; 00162 break; 00163 } 00164 } 00165 } 00166 else if (edges == RECTANGLE) 00167 { 00168 if ( barOrientation ) // HORIZONTAL 00169 { 00170 thePoints[0].x = 0; 00171 thePoints[0].y = 0; 00172 thePoints[1].x = width; 00173 thePoints[1].y = 0; 00174 thePoints[2].x = width; 00175 thePoints[2].y = heigth; 00176 thePoints[3].x = 0; 00177 thePoints[3].y = heigth; 00178 } 00179 else // VERTICAL 00180 { 00181 thePoints[0].x = 0; 00182 thePoints[0].y = 0; 00183 thePoints[1].x = heigth; 00184 thePoints[1].y = 0; 00185 thePoints[2].x = heigth; 00186 thePoints[2].y = width; 00187 thePoints[3].x = 0; 00188 thePoints[3].y = width; 00189 } 00190 } 00191 }
int pFigure::getWidth | ( | ) |
bool pFigure::isPointInside | ( | int | xFig_PixelPoint, | |
int | xPixel | |||
) |
Definition at line 244 of file pFigure.cxx.
References DOWN, edges, heigth, LEFT, orientation, RECTANGLE, RIGHT, TRIANGLE, UP, and width.
Referenced by pColorBar::onMouseMove().
00245 { 00246 bool isInside = false; 00247 00248 if (edges == TRIANGLE) 00249 { 00250 int halfWidth = (int)(width/2)+1; 00251 int halfHeigth = (int)(heigth/2)+1; 00252 if ( orientation == UP || orientation == DOWN ) 00253 { 00254 isInside = (xPixel>=xFig_PixelPoint-halfWidth) && (xPixel<=xFig_PixelPoint+halfWidth); 00255 } 00256 else if( orientation == LEFT || orientation == RIGHT ) 00257 { 00258 isInside = (xPixel>=xFig_PixelPoint-halfHeigth) && (xPixel<=xFig_PixelPoint+halfHeigth); 00259 } 00260 } 00261 else if (edges == RECTANGLE) 00262 { 00263 isInside = (xPixel >= xFig_PixelPoint) && (xPixel<=xFig_PixelPoint+width); 00264 } 00265 return isInside; 00266 }
void pFigure::setBarOrientation | ( | bool | bar_orientation | ) |
Definition at line 272 of file pFigure.cxx.
References barOrientation.
00273 { 00274 barOrientation = bar_orientation; 00275 }
void pFigure::setFigureOrientation | ( | int | fig_orientation | ) |
Definition at line 281 of file pFigure.cxx.
References orientation.
00282 { 00283 orientation = fig_orientation; 00284 }
void pFigure::setHeigth | ( | int | _h | ) |
void pFigure::setNumberEdges | ( | int | n_edges | ) |
Sets the vertex points of the figure
edges | Number of edges in the figure to set |
Definition at line 63 of file pFigure.cxx.
References edges.
Referenced by pColorBar::changePointsFigure_Edges().
00064 { 00065 edges = n_edges; 00066 }
void pFigure::setVertexPoints | ( | wxPoint * | n_points | ) |
Sets the vertex points of the figure
edges | Vertex points distribution in the figure to set |
Definition at line 197 of file pFigure.cxx.
References v_points.
Referenced by pColorBar::repaintView().
00198 { 00199 v_points = n_points; 00200 }
void pFigure::setWidth | ( | int | _w | ) |
bool pFigure::barOrientation [private] |
Definition at line 151 of file pFigure.h.
Referenced by getVertexPoints(), and setBarOrientation().
int pFigure::edges [private] |
Definition at line 141 of file pFigure.h.
Referenced by getNumberEdges(), getVertexPoints(), isPointInside(), and setNumberEdges().
int pFigure::heigth [private] |
Definition at line 131 of file pFigure.h.
Referenced by getHeigth(), getVertexPoints(), isPointInside(), and setHeigth().
int pFigure::orientation [private] |
Represents the orientation UP, DOWN, LEFT, RIGTH of the figure
Definition at line 146 of file pFigure.h.
Referenced by getVertexPoints(), isPointInside(), and setFigureOrientation().
wxPoint* pFigure::v_points [private] |
Definition at line 156 of file pFigure.h.
Referenced by setVertexPoints().
int pFigure::width [private] |
Definition at line 136 of file pFigure.h.
Referenced by getVertexPoints(), getWidth(), isPointInside(), and setWidth().