Back to index

salome-gui  6.5.0
Public Member Functions | Static Public Attributes | Protected Member Functions | Private Attributes
Plot2d_AxisScaleDraw Class Reference

#include <Plot2d_ViewFrame.h>

Collaboration diagram for Plot2d_AxisScaleDraw:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Plot2d_AxisScaleDraw (Plot2d_Plot2d *plot)
virtual ~Plot2d_AxisScaleDraw ()
void unactivTicksDrawing (int numcall)
virtual void draw (QPainter *painter, const QPalette &palette) const
virtual QwtText label (double value) const
void setLabelTick (double value, QString label, bool isDevice=false)
void setTicks (const QList< double > aTicks)
void setInterval (double lowerBound, double upperBound)
void applyTicks ()

Static Public Attributes

static const QString DEVICE_FONT = QString("Times")
static const int DEVICE_FONT_SIZE = 12
static const int DEVICE_BY = 40

Protected Member Functions

void drawLabel (QPainter *painter, double value) const
void drawTick (QPainter *painter, double value, int len) const

Private Attributes

bool myActivTicksDrawing
int myNumTicksDrawingCall
QMap< double, QString > myLabelX
QList< double > myTicks
QMap< double, QString > myLabelDevice
Plot2d_Plot2dmyPlot
double myLowerBound
double myUpperBound

Detailed Description

Definition at line 394 of file Plot2d_ViewFrame.h.


Constructor & Destructor Documentation

Definition at line 3887 of file Plot2d_ViewFrame.cxx.

: myPlot(plot)
{
  myLowerBound = -1;
  myUpperBound = -1;
  setLabelAlignment(Qt::AlignRight);
  setLabelRotation(45.);

  applyTicks();

  myActivTicksDrawing   = true;
  myNumTicksDrawingCall = 1;
}

Here is the call graph for this function:

Definition at line 3902 of file Plot2d_ViewFrame.cxx.

{
}

Member Function Documentation

Definition at line 4004 of file Plot2d_ViewFrame.cxx.

{
  //std::cout << "  Plot2d_AxisScaleDraw::applyTicks()" << std::endl;

  QList<double> major_ticks = scaleDiv().ticks(QwtScaleDiv::MajorTick);
  QList<double> medium_ticks = scaleDiv().ticks(QwtScaleDiv::MediumTick);
  QList<double> minor_ticks = scaleDiv().ticks(QwtScaleDiv::MinorTick);

  medium_ticks.clear();
  minor_ticks.clear();

  myPlot->axisScaleDiv(QwtPlot::xBottom)->setTicks(QwtScaleDiv::MajorTick, myTicks);
  myPlot->axisScaleDiv(QwtPlot::xBottom)->setTicks(QwtScaleDiv::MediumTick, medium_ticks);
  myPlot->axisScaleDiv(QwtPlot::xBottom)->setTicks(QwtScaleDiv::MinorTick, minor_ticks);

  QwtScaleDiv* aScaleDiv = (QwtScaleDiv*) &scaleDiv();

  aScaleDiv->setTicks(QwtScaleDiv::MajorTick, myTicks);
  aScaleDiv->setTicks(QwtScaleDiv::MediumTick, medium_ticks);
  aScaleDiv->setTicks(QwtScaleDiv::MinorTick, minor_ticks);

  if (myLowerBound != -1 && myUpperBound != -1)
              aScaleDiv->setInterval(myLowerBound, myUpperBound);
              
  //for (int i = 0; i < myTicks.size(); i++){
  //  QPoint p = labelPosition( i );
  //  qDebug() << i<< ") applyTicks -> LABEL" <<p;
  //}
}

Here is the caller graph for this function:

void Plot2d_AxisScaleDraw::draw ( QPainter *  painter,
const QPalette &  palette 
) const [virtual]

Definition at line 3921 of file Plot2d_ViewFrame.cxx.

{
  //std::cout << "Plot2d_AxisScaleDraw::draw() : activ= " << myActivTicksDrawing
  //                           << "  numcall= " << myNumTicksDrawingCall << std::endl;

  if (!myActivTicksDrawing)  return;

  //std::cout << "Plot2d_AxisScaleDraw::draw()" << std::endl;

  QList<double> major_ticks  = scaleDiv().ticks(QwtScaleDiv::MajorTick);
  QList<double> medium_ticks = scaleDiv().ticks(QwtScaleDiv::MediumTick);
  QList<double> minor_ticks  = scaleDiv().ticks(QwtScaleDiv::MinorTick);

  medium_ticks.clear();
  minor_ticks.clear();
  major_ticks.clear();

  major_ticks.append( myTicks);
  myPlot->axisScaleDiv(QwtPlot::xBottom)->setTicks(QwtScaleDiv::MajorTick,  major_ticks);
  myPlot->axisScaleDiv(QwtPlot::xBottom)->setTicks(QwtScaleDiv::MediumTick, medium_ticks);
  myPlot->axisScaleDiv(QwtPlot::xBottom)->setTicks(QwtScaleDiv::MinorTick,  minor_ticks);
  QwtScaleDraw *scale = myPlot->axisScaleDraw(QwtPlot::xBottom);
  ((Plot2d_AxisScaleDraw*)(scale))->applyTicks();

  QwtScaleDraw::draw( painter, palette);

  for (int i = 0; i < myTicks.size(); i++)
  {
      drawLabel( painter, myTicks[i]);                 
  }      
              
  //std::cout << "Ok for Plot2d_AxisScaleDraw::draw()" << std::endl;
}

Here is the call graph for this function:

void Plot2d_AxisScaleDraw::drawLabel ( QPainter *  painter,
double  value 
) const [protected]

Definition at line 4035 of file Plot2d_ViewFrame.cxx.

{
  //std::cout << "  Plot2d_AxisScaleDraw::drawLabel( " << value << " ) : "; //<< std::endl;

  //qDebug() << "drawLabel  ( " <<value<<" )";
  if ( myLabelDevice.contains(value) )
  {
      QString deviceLabel = myLabelDevice[value];
      //
      std::string std_label = deviceLabel.toStdString();
      //const char *c_label = std_label.c_str();
      //std::cout << "    deviceLabel= |" << c_label << "|" << std::endl;

      QPoint p = labelPosition( value );
      p += QPoint(0, DEVICE_BY);
      QFont  prevf = painter->font();
      //QColor prevc = (painter->pen()).color();
                
      QFont devicef( DEVICE_FONT, DEVICE_FONT_SIZE, QFont::Bold);
      //
      //painter->setPen( QColor("blue") );
      painter->setFont( devicef );
      painter->drawText( p, myLabelDevice[value] );
      //painter->setPen( prevc );
      painter->setFont( prevf );
  }
  if ( myLabelX.contains(value) )
  {
      QString xLabel = myLabelX[value];
      //
      std::string std_label = xLabel.toStdString();
      //const char *c_label = std_label.c_str();
      //std::cout << "    xLabel= |" << c_label << "|" << std::endl;

      QwtScaleDraw::drawLabel( painter, value );
  }
}

Here is the caller graph for this function:

void Plot2d_AxisScaleDraw::drawTick ( QPainter *  painter,
double  value,
int  len 
) const [protected]

Definition at line 4074 of file Plot2d_ViewFrame.cxx.

{
  //qDebug() << "drawTick  ( " <<value<<" , "<<len<<" )  " ;
  //qDebug() << "myLabelX" << myLabelX;
  //
  if ( myLabelX.contains(value) )
  {
      QwtScaleDraw::drawTick( painter, value, len);
  } 
}
QwtText Plot2d_AxisScaleDraw::label ( double  value) const [virtual]

Definition at line 3956 of file Plot2d_ViewFrame.cxx.

{
  if (myLabelX.contains(value))
          return myLabelX[value];

  return QwtText(QString::number(value, 'f', 1));
}

Here is the caller graph for this function:

void Plot2d_AxisScaleDraw::setInterval ( double  lowerBound,
double  upperBound 
)

Definition at line 3994 of file Plot2d_ViewFrame.cxx.

{
  myLowerBound = lowerBound;
  myUpperBound = upperBound;
  myPlot->setAxisScale( QwtPlot::xBottom, myLowerBound, myUpperBound );
}

Here is the caller graph for this function:

void Plot2d_AxisScaleDraw::setLabelTick ( double  value,
QString  label,
bool  isDevice = false 
)

Definition at line 3967 of file Plot2d_ViewFrame.cxx.

{
  //qDebug()<< "setLabelTick ( " << value << ","<< label <<" )";
  if ( isDevice )
  {
      // For systems names under X axis
      myLabelDevice[value] = label;
  }
  else
  {
      // For X axis graduations
      myLabelX[value] = label;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Plot2d_AxisScaleDraw::setTicks ( const QList< double >  aTicks)

Definition at line 3985 of file Plot2d_ViewFrame.cxx.

{
  //std::cout << "  Plot2d_AxisScaleDraw::setTicks()" << std::endl;
  myTicks = aTicks;

  applyTicks();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3909 of file Plot2d_ViewFrame.cxx.

Here is the caller graph for this function:


Member Data Documentation

const int Plot2d_AxisScaleDraw::DEVICE_BY = 40 [static]

Definition at line 399 of file Plot2d_ViewFrame.h.

const QString Plot2d_AxisScaleDraw::DEVICE_FONT = QString("Times") [static]

Definition at line 397 of file Plot2d_ViewFrame.h.

const int Plot2d_AxisScaleDraw::DEVICE_FONT_SIZE = 12 [static]

Definition at line 398 of file Plot2d_ViewFrame.h.

Definition at line 426 of file Plot2d_ViewFrame.h.

QMap<double, QString> Plot2d_AxisScaleDraw::myLabelDevice [private]

Definition at line 435 of file Plot2d_ViewFrame.h.

QMap<double, QString> Plot2d_AxisScaleDraw::myLabelX [private]

Definition at line 430 of file Plot2d_ViewFrame.h.

Definition at line 439 of file Plot2d_ViewFrame.h.

Definition at line 427 of file Plot2d_ViewFrame.h.

Definition at line 437 of file Plot2d_ViewFrame.h.

QList<double> Plot2d_AxisScaleDraw::myTicks [private]

Definition at line 432 of file Plot2d_ViewFrame.h.

Definition at line 440 of file Plot2d_ViewFrame.h.


The documentation for this class was generated from the following files: