All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Signals | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Properties
SciFigs::ParallelBands Class Reference

A ParallelBands is a layer to plot infinite parallel bands (along X or Y) More...

#include <ParallelBands.h>

Inheritance diagram for SciFigs::ParallelBands:
SciFigs::GraphContentLayer QGpGuiTools::PropertyItem QGpCoreTools::XMLClass

List of all members.

Signals

void bandPicked (double min, double max)

Public Member Functions

void addBand (const Brush &b, const Pen &p=Qt::NoPen)
void addBand (double value, const Pen &p=Qt::SolidLine)
void addBand (double min, double max, const Brush &b=Qt::SolidPattern, const Pen &p=Qt::NoPen)
void addBand (const ParallelBand &b)
AxisType axisType () const
QString axisTypeString () const
ParallelBandband (int index)
const ParallelBandband (int index) const
virtual Rect boundingRect () const
void clear ()
int count () const
void operator= (ParallelBands &o)
 ParallelBands (AxisWindow *parent=0)
void removeBand (int index)
void setAxisType (AxisType a)
void setAxisType (QString t)
virtual bool trackRectangle (int, double rx1, double ry1, double rx2, double ry2, Qt::KeyboardModifiers)
virtual const QString & xml_tagName () const
 ~ParallelBands ()

Static Public Attributes

static const QString xmlParallelBandsTag = "ParallelBands"

Protected Member Functions

virtual void paintData (const LayerPainterRequest &lp, QPainter &p, double dotpercm) const
virtual XMLMember xml_member (XML_MEMBER_ARGS)
virtual void xml_writeChildren (XML_WRITECHILDREN_ARGS) const

Protected Attributes

AxisType _axisType
QVector< ParallelBand_bands

Properties

QString axisType

Detailed Description

A ParallelBands is a layer to plot infinite parallel bands (along X or Y)


Constructor & Destructor Documentation

References TRACE.

{
  TRACE;

}

Member Function Documentation

void SciFigs::ParallelBands::addBand ( const Brush b,
const Pen p = Qt::NoPen 
)
void SciFigs::ParallelBands::addBand ( double  value,
const Pen p = Qt::SolidLine 
)

References _bands, and TRACE.

{
  TRACE;
  LayerLocker ll(this);
  _bands.append(ParallelBand(value, p));
}
void SciFigs::ParallelBands::addBand ( double  min,
double  max,
const Brush b = Qt::SolidPattern,
const Pen p = Qt::NoPen 
)

References _bands, and TRACE.

{
  TRACE;
  LayerLocker ll(this);
  _bands.append(ParallelBand(min, max, b, p));
}
void SciFigs::ParallelBands::addBand ( const ParallelBand b) [inline]
{_bands.append(b);}
{return _axisType;}
QString SciFigs::ParallelBands::axisTypeString ( ) const [inline]

References QGpCoreTools::XAxis.

{return _axisType==XAxis ?"X":"Y";}
ParallelBand& SciFigs::ParallelBands::band ( int  index) [inline]
const ParallelBand& SciFigs::ParallelBands::band ( int  index) const [inline]
{return _bands[index];}
void SciFigs::ParallelBands::bandPicked ( double  min,
double  max 
) [signal]

Referenced by trackRectangle().

Implements SciFigs::GraphContentLayer.

References _axisType, _bands, SciFigs::ParallelBand::maximum(), SciFigs::ParallelBand::minimum(), TRACE, and QGpCoreTools::XAxis.

{
  TRACE;
  if(_bands.isEmpty()) return Rect( -1e99, -1e99, 1e99, 1e99);
  double min=1e99, max=-1e99;
  QVector<ParallelBand>::const_iterator it=_bands.begin();
  for(;it!=_bands.end();++it) {
    const ParallelBand& b=*it;
    if(b.minimum()<min) min=b.minimum();
    if(b.maximum()<min) min=b.maximum();
    if(b.minimum()>max) max=b.minimum();
    if(b.maximum()>max) max=b.maximum();
  }
  if(_axisType==XAxis) {
    return Rect(min, -1e99, max, 1e99);
  } else {
    return Rect(-1e99, min, 1e99, max);
  }
}
int SciFigs::ParallelBands::count ( ) const [inline]
void SciFigs::ParallelBands::operator= ( ParallelBands o)

References _axisType, _bands, and TRACE.

{
  TRACE;
  LayerLocker ll(this);
  _axisType=o._axisType;
  _bands=o._bands;
}
void SciFigs::ParallelBands::paintData ( const LayerPainterRequest lp,
QPainter &  p,
double  dotpercm 
) const [protected, virtual]

Implements SciFigs::GraphContentLayer.

References _axisType, _bands, SciFigs::ParallelBand::brush(), SciFigs::ParallelBand::maximum(), SciFigs::ParallelBand::minimum(), SciFigs::LayerPainterRequest::options(), SciFigs::ParallelBand::pen(), SciFigs::Brush::qbrush(), SciFigs::Pen::qpen(), SciFigs::LayerPainterRequest::size(), SciFigs::LayerPainterRequest::terminated(), TRACE, w, QGpCoreTools::XAxis, SciFigs::GraphContentOptions::xr2s(), SciFigs::GraphContentOptions::xVisMax(), SciFigs::GraphContentOptions::xVisMin(), SciFigs::GraphContentOptions::yr2s(), SciFigs::GraphContentOptions::yVisMax(), and SciFigs::GraphContentOptions::yVisMin().

{
  TRACE;
  const GraphContentOptions& gc=lp.options();
  QVector<ParallelBand>::const_iterator it=_bands.begin();
  if(_axisType==XAxis) {
    int h=lp.size().height();
    for(;it!=_bands.end();++it) {
      if(lp.terminated()) return;
      const ParallelBand& b=*it;
      double min=b.minimum();
      double max=b.maximum();
      if(max<=gc.xVisMin()) continue;
      if(min>=gc.xVisMax()) continue;
      if(min<gc.xVisMin()) min=gc.xVisMin();
      if(max>gc.xVisMax()) max=gc.xVisMax();
      p.setPen(b.pen().qpen(dotpercm));
      p.setBrush(b.brush().qbrush(dotpercm));
      int bleft=gc.xr2s(min);
      int bwidth=gc.xr2s(max)-bleft;
      if(bwidth==0) {
        p.drawLine(bleft, 0, bleft, h);
      } else {
        p.drawRect(bleft, 0, bwidth, h);
      }
    }
  } else {
    int w=lp.size().width();
    for(;it!=_bands.end();++it) {
      if(lp.terminated()) return;
      const ParallelBand& b=*it;
      double min=b.minimum();
      double max=b.maximum();
      if(max<=gc.yVisMin()) continue;
      if(min>=gc.yVisMax()) continue;
      if(min<gc.yVisMin()) min=gc.yVisMin();
      if(max>gc.yVisMax()) max=gc.yVisMax();
      p.setPen(b.pen().qpen(dotpercm));
      p.setBrush(b.brush().qbrush(dotpercm));
      int btop=gc.yr2s(min);
      int bheight=gc.yr2s(max)-btop;
      if(bheight==0) {
        p.drawLine(0, btop, w, btop);
      } else {
        p.drawRect(0, btop, w, bheight);
      }
    }
  }
}

References _bands, and TRACE.

Referenced by MonoStation::StationResults::removePeak().

{
  TRACE;
  LayerLocker ll(this);
  _bands.remove(index);
}

References _axisType, and TRACE.

Referenced by createBands().

{
  TRACE;
  LayerLocker ll(this);
  _axisType=a;
}
void SciFigs::ParallelBands::setAxisType ( QString  t) [inline]

References setAxisType(), QGpCoreTools::XAxis, and QGpCoreTools::YAxis.

Referenced by setAxisType().

{if(t.contains("X")) setAxisType(XAxis); else setAxisType(YAxis);}
bool SciFigs::ParallelBands::trackRectangle ( int  ,
double  rx1,
double  ry1,
double  rx2,
double  ry2,
Qt::KeyboardModifiers   
) [virtual]

Reimplemented from SciFigs::GraphContentLayer.

References _axisType, bandPicked(), TRACE, and QGpCoreTools::XAxis.

{
  TRACE;
  if(_axisType==XAxis) {
    emit bandPicked(rx1, rx2);
  } else {
    emit bandPicked(ry1, ry2);
  }
  return true;
}

Re-implement this function to offer XML restore (children and properties) support to your class.

From tag and map (with contains the attibute value) return a unique identifier under the format of a XMLMember. XMLMember is initialized with 3 types of contructors:

  • An integer: id number of a property
  • A XMLClass * : a child of this object identified by tag
  • Default constructor: error, unknow child or property

Map of attributes can be inspected in this way (can be achived also in xml_setProperty()):

    static const QString tmp("childrenName");
    XMLRestoreAttributeIterator it=map.find(tmp);
    if(it!=map.end()) {
      // found attribute "childrenName"
    }

If the map of attributes is not used:

    Q_UNUSED(attributes);
    if(tag=="x1") return XMLMember(0);
    else if(tag=="y1") return XMLMember(1);
    else if(tag=="x2") return XMLMember(2);
    else if(tag=="y2") return XMLMember(3);
    else return XMLMember(XMLMember::Unknown);

Arithmetic operations + and - apply to XMLMember to avoid confusion of property id numbers between inherited objects. Offset 3 corresponds to the number of properties defined in this object.

    if(tag=="anInteger") return XMLMember(0);
    else if(tag=="aString") return XMLMember(1);
    else if(tag=="aDouble") return XMLMember(2);
    return AbstractLine::xml_member(tag, attributes, context)+3;

For the arguments of this function use Macro XML_MEMBER_ARGS.

Reimplemented from SciFigs::GraphContentLayer.

References _bands, SciFigs::XMLSciFigs::data(), and TRACE.

{
  TRACE;
  XMLSciFigs * scifigsContext=static_cast<XMLSciFigs *>(context);
  if(scifigsContext->data()) {
    if(tag=="ParallelBand") {
      _bands.resize(_bands.size()+1);
      return XMLMember(&_bands.back());
    }
  }
  return GraphContentLayer::xml_member(tag, attributes, context);
}
virtual const QString& SciFigs::ParallelBands::xml_tagName ( ) const [inline, virtual]

Reimplemented from SciFigs::GraphContentLayer.

Reimplemented from QGpCoreTools::XMLClass.

References _bands, SciFigs::XMLSciFigs::data(), and TRACE.

{
  TRACE;
  XMLSciFigs * scifigsContext=static_cast<XMLSciFigs *>(context);
  if(scifigsContext->data()) {
    QVector<ParallelBand>::const_iterator it=_bands.begin();
    for(;it!=_bands.end();++it) (*it).xml_save(s, context);
  }
}

Member Data Documentation

const QString SciFigs::ParallelBands::xmlParallelBandsTag = "ParallelBands" [static]

Property Documentation

QString SciFigs::ParallelBands::axisType [read, write]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines