13 #include "msdevstudio/MSconfig.h" 127 vector <double> temp_x;
128 vector <double> temp_y;
129 vector <Line::Style> temp_s;
141 while (!
m_x.empty()){
144 temp_x.push_back(
m_x[0]);
145 temp_x.push_back(
m_x[1]);
146 temp_y.push_back(
m_y[0]);
147 temp_y.push_back(
m_y[1]);
158 while(curX!=temp_x[0] || curY!=temp_y[0]){
159 for (
unsigned int i=0; i<
m_x.size(); i++) {
167 temp_x.push_back(curX);
168 temp_y.push_back(curY);
169 m_x.erase(
m_x.begin()+i,
m_x.begin()+i+2);
170 m_y.erase(
m_y.begin()+i,
m_y.begin()+i+2);
175 temp_x.push_back(curX);
176 temp_y.push_back(curY);
177 m_x.erase(
m_x.begin()+i-1,
m_x.begin()+i+1);
178 m_y.erase(
m_y.begin()+i-1,
m_y.begin()+i+1);
185 if (found) {found=
false;
continue;}
238 vector <double> temp_x;
239 vector <double> temp_y;
240 vector <Color> temp_c;
251 while (!
m_x.empty()){
254 temp_x.push_back(
m_x[0]);
255 temp_x.push_back(
m_x[1]);
256 temp_y.push_back(
m_y[0]);
257 temp_y.push_back(
m_y[1]);
268 while(curX!=temp_x[0] || curY!=temp_y[0]){
269 for (
unsigned int i=0; i<
m_x.size(); i++) {
277 temp_x.push_back(curX);
278 temp_y.push_back(curY);
279 m_x.erase(
m_x.begin()+i,
m_x.begin()+i+2);
280 m_y.erase(
m_y.begin()+i,
m_y.begin()+i+2);
285 temp_x.push_back(curX);
286 temp_y.push_back(curY);
287 m_x.erase(
m_x.begin()+i-1,
m_x.begin()+i+1);
288 m_y.erase(
m_y.begin()+i-1,
m_y.begin()+i+1);
295 if (found) {found=
false;
continue;}
326 const std::vector < double > & values )
331 unsigned int size = values.size ();
343 double tick_length = 6.0;
344 double y_base = view_rect.
getY() - 15.0;
347 for (
unsigned int i = 0; i < values.size(); i++ ) {
349 double user_z = values[i];
351 if ( range.excludes ( user_z ) )
continue;
357 xv.push_back ( view_x );
358 yv.push_back ( y_base );
359 xv.push_back ( view_x );
360 yv.push_back ( y_base + tick_length );
377 if ( ntuple -> rows () == 0 )
return;
396 int im[4] = {0,1,1,0};
397 int jm[4] = {0,0,1,1};
406 int castab [3][3][3] =
409 {0,0,8},{0,2,5},{7,6,9}
412 {0,3,4},{1,0,1},{4,3,0}
415 {9,6,7},{5,2,0},{8,0,0}
418 const vector < unsigned int > &
shape = ntuple -> getShape ();
419 unsigned int i_size = shape[0];
420 unsigned int j_size = shape[1];
421 vector < unsigned int > index ( 3 );
423 for ( i = 0; i < i_size - 1; i++ ) {
425 for ( j = 0; j < j_size - 1; j++ ) {
433 double tempij = ntuple -> operator [] ( index );
436 double tempij1 = ntuple -> operator [] ( index );
438 temp1 = min ( tempij, tempij1 );
442 double tempi1j = ntuple -> operator[] ( index );
445 double tempi1j1 = ntuple -> operator [] ( index );
446 temp2 = min ( tempi1j, tempi1j1 );
448 dmin = min ( temp1, temp2 );
450 temp1 = max ( tempij, tempij1 );
451 temp2 = max ( tempi1j, tempi1j1 );
452 dmax = max ( temp1, temp2 );
461 if ( curContour >= dmin &&
462 curContour <= dmax ) {
466 for ( m = 4; m >= 0; m--) {
470 index[0] = i + im[m-1];
471 index[1] = j + jm[m-1];
473 h[m] = ntuple -> operator [] ( index ) - curContour;
476 xh[m] = ntuple -> operator [] ( index );
479 yh[m] = ntuple -> operator [] ( index );
485 h[0] = 0.25 * ( h[1] + h[2] + h[3] + h[4] );
489 double xij = ntuple -> operator [] ( index );
492 double xi1j = ntuple -> operator [] ( index );
497 double yij = ntuple -> operator [] ( index );
500 double yij1 = ntuple -> operator [] ( index );
502 xh[0] = 0.50 * ( xij + xi1j );
503 yh[0] = 0.50 * ( yij + yij1 );
510 else if ( h[m] < 0.0 ) {
555 case_value = castab[sh[m1]+1][sh[m2]+1][sh[m3]+1];
558 switch (case_value) {
618 double val = curContour;
622 bt -> transformZ ( val );
626 m_x.push_back ( x1 );
627 m_x.push_back ( x2 );
628 m_y.push_back ( y1 );
629 m_y.push_back ( y2 );
645 unsigned int style = ( m_numContours - 1 - k ) % 3;
674 double width = high - low;
675 low = low + 0.05 * width;
676 high = high - 0.05 * width;
683 t -> transformZ ( high );
684 t -> transformZ ( low );
686 double value = low + (
692 t -> inverseTransformZ ( value );
700 return (h[p2]*xh[p1]-h[p1]*xh[p2])/(h[
p2]-h[
p1]);
739 vector < double > :: iterator iter = values.begin ();
740 for ( ; iter != values.end (); iter++ ) {
770 double high = range.high();
771 double low = range.low();
773 bt -> transformZ ( high );
774 bt -> transformZ ( low );
776 Range newrange ( low, high );
784 unsigned int size = ntuple -> rows () * ntuple -> columns ();
785 m_x.reserve ( size );
786 m_y.reserve ( size );
810 gamma = pbt -> yOffset ();
811 beta = pbt -> xOffset();
812 max_x = pbt -> limitX().high();
816 unsigned int rowsize = newntuple -> rows();
817 unsigned int columnsize = newntuple -> columns();
819 for (
unsigned int i = 0; i < rowsize; i++) {
820 const vector < double > & row = newntuple -> getRow (i);
821 vector <double> newrow;
822 vector <double> rowdata(columnsize);
824 for (
unsigned int j=0; j<columnsize; j++) {
828 rotate ( rowdata[0], rowdata[1], 0.0, beta, gamma, (max_x==180));
830 for (
unsigned int j=0; j<columnsize; j++) {
831 newrow.push_back(rowdata[j]);
834 newntuple -> replaceRow ( i, newrow );
844 const vector < unsigned int > &
shape = newntuple -> getShape ();
845 unsigned int ynum = shape [ 1 ];
846 unsigned int xnum = shape [ 0 ];
848 for (
unsigned int i=0; i<xnum; i++){
850 tempntuple -> clear();
852 for (
unsigned int j=0; j<ynum; j++){
854 const vector < double > & row = newntuple -> getRow (i*ynum+j);
855 tempntuple -> insertRow ( j, row );
860 ysorter -> setSorting(1);
863 for (
unsigned int j=0; j<ynum; j++){
865 const vector < double > & row2 = tempntuple -> getRow (j);
866 newntuple -> replaceRow(i*ynum+j, row2);
937 const vector < double > & values = ntuple -> getColumn (
dp::Z );
938 Range range ( values );
953 double alpha,
double beta,
double gamma,
bool negative )
955 if (!negative) lat-=180.0;
958 lat = M_PI * lat / 180.0;
959 lon = M_PI * lon / 180.0;
960 alpha = M_PI * alpha / 180.0;
961 beta = M_PI * beta / 180.0;
962 gamma = M_PI * gamma / 180.0;
966 double x = cos( lat ) * cos( lon );
967 double y = sin( lat ) * cos( lon );
968 double z = sin( lon );
972 double ry = y * cos( alpha ) + z * sin( alpha );
973 double rz = - y * sin( alpha ) + z * cos( alpha );
975 x = rx; y = ry; z = rz;
978 rx = x * cos( beta ) - z * sin( beta );
980 rz = x * sin( beta ) + z * cos( beta );
982 x = rx; y = ry; z = rz;
985 rx = x * cos( gamma ) + y * sin( gamma );
986 ry = - x * sin( gamma ) + y * cos( gamma );
989 x = rx; y = ry; z = rz;
992 lon = ( 180.0 / M_PI ) * asin( z );
993 lat = ( 180.0 / M_PI ) * atan2( y, x );
995 if (!negative) lat+=180.0;
hippodraw::ContourPointRep class interface
A namespace to set the standard for indexing into 2 dimension data point tuple.
virtual void transform(double &x, double &y) const =0
Transform the coordinates on the X and Y axes.
virtual bool isLinearInZ() const
Returns true if the transform would be one to one on Z axes.
bool m_desel
A flag to indicate the representation is de-selected.
Class representing a rectangle.
std::vector< double > m_values
The vector of contour values.
A PointRep class that draws a contour lines.
const std::string & name() const
Returns the name of the representation.
hippodraw::NTupleProjector class interface
Style convert(unsigned int style)
static const Color s_desel_color
The color of the representation when it is de-selected.
void sort()
Sorts the NTuple.
~ContourPointRep()
The destructor.
hippodraw::Line::Style m_line_style
The style currently used.
void drawContourTicks(const TransformBase &, ViewBase &, const std::vector< double > &)
hippodraw::AxisModelBase class interface
std::vector< Color > m_colorvec
The vector of colors used for drawing the lines.
virtual AxisModelBase * getAxisModel(Axes::Type axis) const
Get the AxisModel for axis axis.
hippodraw::DataView class interface
hippodraw::BinToColor class interface
NTupleSorter class interface.
virtual const BinToColor * getValueTransform() const
Returns the value transform.
void setContourVector(const TransformBase *transform)
Prepare the vector of contour values.
ContourPointRep()
The default constructor.
A transform that transforms coordinates from one 2D coordinate system to another. ...
virtual void drawPolyLine(const std::vector< double > &xpoints, const std::vector< double > &ypoints, Line::Style style, const Color &color, float size)=0
Draws a polyline.
bool m_usingUserValues
A boolean which is true if we are using user input contour values.
double m_minValue
The min Z value of the data.
int getNumContours() const
Returns the number of contours.
static BinToColorFactory * instance()
Returns a pointer to the singleton instance.
double high() const
Returns the maximum of the range object.
void setContourValues(std::vector< double > &values, ProjectorBase *proj)
Set user defined contour values.
virtual void drawViewLines(const std::vector< double > &x, const std::vector< double > &y, Line::Style style, bool color, float size)=0
Draws multiple line segments.
void setMinMax(const DataSource *)
Set the min and max Z values of the data being plotted.
double getY() const
A shortcut to get origin.Y.
std::vector< double > m_x
A cache of the points along the X axis to be drawn.
bool excludes(double value) const
Returns true if the argument value is outside the range.
virtual void drawValuesWithStyle(const TransformBase &, ViewBase &vb)
Does the actual drawing using different line styles.
hippodraw::NTuple class interface.
Base class for DataSource.
const std::string & name() const
Returns the name of the value to color transform.
const Rect & getUserRect() const
Is called by the AxisRepBase object (or one of its derived objects), and returns the rectangle where ...
std::vector< Line::Style > m_stylevec
The vector of line style used for drawing the lines.
Range getRange() const
Get the Range of expected values.
A Periodic transform that transforms coordinates from one 2D coordinate system to another...
intp size(numeric::array arr)
The base class for the point representation hierarchy.
void setRange(const Range &r)
Sets the range of the values passed.
Color m_color
The color of the representation.
double m_maxValue
The max Z value of the data.
double low() const
Returns the minimum of the range object.
A Color class for creating the color object following the standard RGB color space.
bool isPeriodic() const
Sets whether this transform is periodic.
virtual void drawValues(const TransformBase &, ViewBase &vb)
Does the actual drawing of the contour and the contour ticks.
BinToColorFactory class interface.
A DataSource class implemented with std::vector<double> to store the column data. ...
hippodraw::PeriodicBinaryTransform class interface
virtual RepBase * clone()
The clone function returns an object of its own kind which is a copy of this object at this moment...
float size() const
Returns the size of the representation.
void transformZ(double &z) const
Transforms the z coordinate.
Expresses a range of values.
virtual float userToDrawColor(double c) const =0
Converts a coordinate in user space to drawing space along the color (X) axis.
virtual void setValueTransform(BinToColor *)
Sets the value transform.
The base class for the Projector hierarchy.
A factory for creation of objects whose class is derived from BinToColor.
static void rotate(double &lat, double &lon, double alpha, double beta, double gamma, bool negative=true)
A transform that transforms coordinates from one coordinate system to another.
const Range & getRange(Axes::Type axis) const
Returns the range of the data space on specified axis.
void setNumContours(int i)
Set number of contours.
virtual const Color & color() const
Returns the representation's color.
The abstract base class for views.
void createContours(const DataSource *ntuple, const TransformBase *transform)
The method that actually calculates the contour lines.
double intersect(int p1, int p2, double *h, double *xh)
Returns the intersection of the segment given by h[p1] and h[p2] with the segment given by xh[p1] and...
hippodraw::DataPointTuple namespace interface
bool getUsingUserValues() const
Get the m_usingUserValues boolean.
double getScaleFactor() const
Returns the scale factor.
void setUsingUserValues(bool flag)
Set the m_usingUserValues boolean.
double m_minPos
The min positive Z value of the data.
A namespace to set the standard for indexing into 3 dimension data point tuple.
A PointRep class that draws a column to represent the value.
A helper class to sort and keep sorted an NTuple.
void makeInBounds(double &x, double &y) const
Changes the coordinates so that they are inside or on the boundary of the rectangle.
std::vector< double > m_y
A cache of the points along the Y axis to be drawn.
float m_size
The size of the representation.
void init()
Initialization member function used by constructors.
double getContour(int i, const TransformBase *transform)
Returns the z value where the i-th level contour is to be drawn.
double pos() const
Returns the first positive element in range.
int m_numContours
The number of contours to be drawn.
BinToColor * m_bin_to_color
The color scale generator.
virtual void drawProjectedValues(const DataSource *ntuple, TransformBase *transform, ViewBase *view)
Draws the projected values.
The base class for the value to the color transformation.
std::string m_name
The name of the representation.
The AxisModelBase class maintains the Range and scaling of an axis.
The abstract base class for views that have a region for drawing data points with area around it for ...
const Rect & getMarginRect() const
Returns the rectangle area in which data points are drawn.
std::vector< intptr_t > shape(numeric::array arr)
virtual void drawColorLines(const std::vector< double > &x, const std::vector< double > &y, Line::Style style, const std::vector< Color > &color, float size)=0
Draws multiple line segments, each with a different color - that is, a line between x0...
Style
Line style constants.