#include </home/scilab/compilation_chain/sci_checkOut/scilab/modules/renderer/src/cpp/axesDrawing/AxesPositioner.hxx>


Public Member Functions | |
| AxesPositioner (DrawableAxes *axes) | |
| virtual | ~AxesPositioner (void) |
| virtual void | getAxisBounds (double startBound[3], double endBound[3]) |
| virtual void | getTicksDirection (double ticksDir[3]) |
| virtual int | getRelativeTicksPosition (double ticksPos[], int nbTicks) |
Protected Member Functions | |
| bool | isXAxisAligned (void) |
Protected Attributes | |
| DrawableAxes * | m_pAxes |
Definition at line 26 of file AxesPositioner.hxx.
| sciGraphics::AxesPositioner::AxesPositioner | ( | DrawableAxes * | axes | ) |
Definition at line 27 of file AxesPositioner.cpp.
References m_pAxes.
00028 { 00029 m_pAxes = axes; 00030 }
| sciGraphics::AxesPositioner::~AxesPositioner | ( | void | ) | [virtual] |
| void sciGraphics::AxesPositioner::getAxisBounds | ( | double | startBound[3], | |
| double | endBound[3] | |||
| ) | [virtual] |
Get the two bounds of this axis.
Implements sciGraphics::AxisPositioner.
Definition at line 37 of file AxesPositioner.cpp.
References ComputeXIntervals(), destroyGraphicPointer(), sciGraphics::DrawableObject::getDrawedObject(), isXAxisAligned(), m_pAxes, NULL, pAXES_FEATURE, sciAxes::tics, sciAxes::vx, and sciAxes::vy.
Referenced by getRelativeTicksPosition().
00038 { 00039 sciPointObj * pAxes = m_pAxes->getDrawedObject(); 00040 sciAxes * ppAxes = pAXES_FEATURE(pAxes); 00041 double xStart; 00042 double xEnd; 00043 double yStart; 00044 double yEnd; 00045 00046 if (isXAxisAligned()) 00047 { 00048 // axis along X axis 00049 // Y value is constant 00050 yStart = ppAxes->vy[0]; 00051 yEnd = ppAxes->vy[0]; 00052 00053 // compute X ticks 00054 int nbTicks; 00055 double * tempPos = NULL; 00056 ComputeXIntervals(pAxes, ppAxes->tics, &tempPos, &nbTicks, 0); 00057 00058 // get the first and the last one 00059 xStart = tempPos[0]; 00060 xEnd = tempPos[nbTicks - 1]; 00061 00062 destroyGraphicPointer(tempPos); 00063 00064 00065 } 00066 else 00067 { 00068 // axis along Y axis 00069 // X value is constant 00070 xStart = ppAxes->vx[0]; 00071 xEnd = ppAxes->vx[0]; 00072 00073 // compute Y ticks 00074 int nbTicks; 00075 double * tempPos = NULL; 00076 ComputeXIntervals(pAxes, ppAxes->tics, &tempPos, &nbTicks, 0); 00077 00078 // get the first and the last one 00079 yStart = tempPos[0]; 00080 yEnd = tempPos[nbTicks - 1]; 00081 00082 destroyGraphicPointer(tempPos); 00083 00084 } 00085 00086 startBound[0] = xStart; 00087 startBound[1] = yStart; 00088 startBound[2] = 0.0; 00089 00090 endBound[0] = xEnd; 00091 endBound[1] = yEnd; 00092 endBound[2] = 0.0; 00093 00094 }


| void sciGraphics::AxesPositioner::getTicksDirection | ( | double | ticksDir[3] | ) | [virtual] |
Compute the direction and length of ticks
Implements sciGraphics::AxisPositioner.
Definition at line 96 of file AxesPositioner.cpp.
References sciAxes::dir, sciGraphics::DrawableObject::getDrawedObject(), m_pAxes, pAXES_FEATURE, sciGetParentSubwin(), and sciGraphics::AxisPositioner::setTicksDirectionLength().
00097 { 00098 sciAxes * ppAxes = pAXES_FEATURE(m_pAxes->getDrawedObject()); 00099 switch(ppAxes->dir) 00100 { 00101 case 'u': 00102 // axis along X axis 00103 // ticks along Y one 00104 ticksDir[0] = 0.0; 00105 ticksDir[1] = 1.0; 00106 break; 00107 case 'd': 00108 // axis along X axis 00109 // ticks along Y one 00110 ticksDir[0] = 0.0; 00111 ticksDir[1] = -1.0; 00112 break; 00113 case 'l': 00114 // axis along Y axis 00115 // ticks along X one 00116 ticksDir[0] = -1.0; 00117 ticksDir[1] = 0.0; 00118 break; 00119 case 'r': 00120 // axis along Y axis 00121 // ticks along X one 00122 ticksDir[0] = 1.0; 00123 ticksDir[1] = 0.0; 00124 break; 00125 default: 00126 break; 00127 } 00128 00129 ticksDir[2] = 0.0; 00130 00131 // apply the right number of pixels 00132 setTicksDirectionLength(ticksDir, sciGetParentSubwin(m_pAxes->getDrawedObject())); 00133 00134 }

| int sciGraphics::AxesPositioner::getRelativeTicksPosition | ( | double | ticksPos[], | |
| int | nbTicks | |||
| ) | [virtual] |
Convert ticks abscissas, into relative coordinates between the two axis bounds
| ticksPos | abscissas of ticks along their axis as input in output, get the relative coordinates between the axes bounds. 0 stands fot the start bound, 1 for the last one. | |
| nbTicks | number of ticks abascissas as input |
Implements sciGraphics::AxisPositioner.
Definition at line 136 of file AxesPositioner.cpp.
References getAxisBounds(), i, isXAxisAligned(), max, and min.
00137 { 00138 double axisStart[3]; 00139 double axisEnd[3]; 00140 getAxisBounds(axisStart, axisEnd); 00141 00142 double min; 00143 double max; 00144 00145 if (isXAxisAligned()) 00146 { 00147 min = axisStart[0]; 00148 max = axisEnd[0]; 00149 } 00150 else 00151 { 00152 min = axisStart[1]; 00153 max = axisEnd[1]; 00154 } 00155 00156 00157 for (int i = 0; i < nbTicks; i++) 00158 { 00159 ticksPos[i] = (ticksPos[i] - min) / (max - min); 00160 } 00161 return nbTicks; 00162 }

| bool sciGraphics::AxesPositioner::isXAxisAligned | ( | void | ) | [protected] |
To know if the axes is aligned with X axis or with Y axis
Definition at line 164 of file AxesPositioner.cpp.
References sciGraphics::DrawableObject::getDrawedObject(), m_pAxes, sciAxes::nx, sciAxes::ny, and pAXES_FEATURE.
Referenced by getAxisBounds(), and getRelativeTicksPosition().
00165 { 00166 sciAxes * ppAxes = pAXES_FEATURE(m_pAxes->getDrawedObject()); 00167 return (ppAxes->nx > ppAxes->ny); 00168 }


DrawableAxes* sciGraphics::AxesPositioner::m_pAxes [protected] |
Definition at line 63 of file AxesPositioner.hxx.
Referenced by AxesPositioner(), getAxisBounds(), getTicksDirection(), isXAxisAligned(), and ~AxesPositioner().
1.5.5