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

Brief description of class still missing. More...

#include <ColorPaletteLayer.h>

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

List of all members.

Public Member Functions

AxisType axisType () const
QString axisTypeString () const
virtual Rect boundingRect () const
 ColorPaletteLayer (AxisWindow *parent=0)
const ColorPalettepalette () const
void setAxisType (AxisType a)
void setAxisType (QString t)
void setPalette (const ColorPalette &pal)
virtual const QString & xml_tagName () const

Static Public Attributes

static const QString xmlColorPaletteLayerTag = "ColorPaletteLayer"

Protected Member Functions

virtual QString coordinateTipInfo (const Point2D &p) const
virtual void paintData (const LayerPainterRequest &lp, QPainter &p, double dotpercm) const

Properties

QString axisType

Detailed Description

Brief description of class still missing.

Full description of class still missing


Constructor & Destructor Documentation

Description of constructor still missing

References TRACE, and QGpCoreTools::XAxis.

    : GraphContentLayer(parent)
{
  TRACE;
  _axisType=XAxis;
}

Member Function Documentation

{return _axisType;}
QString SciFigs::ColorPaletteLayer::axisTypeString ( ) const [inline]

References QGpCoreTools::XAxis.

{return _axisType==XAxis ? "X":"Y";}

Implements SciFigs::GraphContentLayer.

References QGpGuiTools::ColorPalette::count(), TRACE, QGpGuiTools::ColorPalette::upperValue(), and QGpCoreTools::XAxis.

Referenced by SciFigs::ColorPaletteWidget::setPalette().

{
  TRACE;
  if(_pal.count()<2) {
    return Rect(-1e99, -1e99, 1e99, 1e99);
  }
  if(_axisType==XAxis) {
    if(_pal.count()==2) {
      return Rect(_pal.upperValue(0)-1.0, -1e99, _pal.upperValue(0)+1.0, 1e99);
    } else {
      return Rect(1.5*_pal.upperValue(0)-0.5*_pal.upperValue(1), -1e99,
                  1.5*_pal.upperValue(_pal.count()-2)-0.5*_pal.upperValue(_pal.count()-3), 1e99);
    }
  } else {
    if(_pal.count()==2) {
      return Rect( -1e99, _pal.upperValue(0)-1.0, 1e99, _pal.upperValue(0)+1.0);
    } else {
      return Rect(-1e99, 1.5*_pal.upperValue(0)-0.5*_pal.upperValue(1),
                  1e99, 1.5*_pal.upperValue(_pal.count()-2)-0.5*_pal.upperValue(_pal.count()-3));
    }
  }
}
QString SciFigs::ColorPaletteLayer::coordinateTipInfo ( const Point2D p) const [protected, virtual]

Reimplemented from SciFigs::GraphContentLayer.

References QGpGuiTools::ColorPalette::color(), QGpGuiTools::ColorPalette::count(), SciFigs::GraphContentLayer::graph(), SciFigs::GraphContentLayer::name, SciFigs::Axis::numberPrecision, SciFigs::Axis::numberType, TRACE, QGpCoreTools::Point2D::x(), and SciFigs::AxisWindow::xAxis().

{
  TRACE;
  Axis * xAxis=graph()->xAxis();
  if(_pal.count()<2)
    return QString::null;
  else
    return QString("%1 ; %2").arg(Number::toString(p.x(), xAxis->numberType(), xAxis->numberPrecision()+2) ).arg(_pal.color(p.x()).name());
}
void SciFigs::ColorPaletteLayer::paintData ( const LayerPainterRequest lp,
QPainter &  p,
double  dotpercm 
) const [protected, virtual]

Implements SciFigs::GraphContentLayer.

References QGpGuiTools::ColorPalette::color(), QGpGuiTools::ColorPalette::count(), QGpGuiTools::ColorPalette::index(), QGpGuiTools::ColorPalette::lowerValue(), SciFigs::LayerPainterRequest::options(), SciFigs::LayerPainterRequest::size(), TRACE, QGpGuiTools::ColorPalette::upperValue(), QGpCoreTools::XAxis, SciFigs::GraphContentOptions::xs2r(), and SciFigs::GraphContentOptions::ys2r().

{
  TRACE;
  const GraphContentOptions& gc=lp.options();
  ColorPalette pal=_pal; // A copy to avoid distrubances from changes to palette during painting
  int n=pal.count()-1;
  if(n<0) return;
  int w=lp.size().width();
  int h=lp.size().height();
  if(n==0) {
    p.fillRect(0, 0, w, h, pal.color(0));
    return;
  }
  if(_axisType==XAxis) {
    double vmin=gc.xs2r(0);
    double vmax=gc.xs2r(w);
    if(vmin>vmax) qSwap(vmin, vmax);
    int minIndex=pal.index(vmin);
    int maxIndex=pal.index(vmax);
    if(minIndex==0) {
      paintX(vmin, pal.upperValue(0), w, h, pal.color(0), gc, p);
      minIndex++;
    }
    if(maxIndex==n) {
      paintX(pal.lowerValue(n), vmax, w, h, pal.color(n), gc, p);
      maxIndex--;
    }
    for(int i=minIndex; i<=maxIndex; i++) {
      paintX(pal.lowerValue(i), pal.upperValue(i), w, h, pal.color(i), gc, p);
    }
  } else {
    double vmin=gc.ys2r(0);
    double vmax=gc.ys2r(h);
    if(vmin>vmax) qSwap(vmin, vmax);
    int minIndex=pal.index(vmin);
    int maxIndex=pal.index(vmax);
    if(minIndex==0) {
      paintY(vmin, pal.upperValue(0), w, h, pal.color(0), gc, p);
      minIndex++;
    }
    if(maxIndex==n) {
      paintY(pal.lowerValue(n), vmax, w, h, pal.color(n), gc, p);
      maxIndex--;
    }
    for(int i=minIndex; i<=maxIndex; i++) {
      paintY(pal.lowerValue(i), pal.upperValue(i), w, h, pal.color(i), gc, p);
    }
  }
}

References TRACE.

Referenced by SciFigs::ColorPaletteWidget::operator=().

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

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

Referenced by setAxisType().

{if(t.contains("X")) setAxisType(XAxis); else setAxisType(YAxis);}
void SciFigs::ColorPaletteLayer::setPalette ( const ColorPalette pal) [inline]
virtual const QString& SciFigs::ColorPaletteLayer::xml_tagName ( ) const [inline, virtual]

Reimplemented from SciFigs::GraphContentLayer.


Member Data Documentation

const QString SciFigs::ColorPaletteLayer::xmlColorPaletteLayerTag = "ColorPaletteLayer" [static]

Property Documentation

QString SciFigs::ColorPaletteLayer::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