The QbtGraphContent is the plot area of a AxisWindow. More...
#include <GraphContent.h>
Public Slots | |
void | addLayers (QString fileName=QString::null) |
void | browse () |
void | copyLayers () |
void | deepUpdate (int fromLayer=0) |
void | pasteLayers () |
void | saveLayers (QString fileName=QString::null) |
void | unzoom () |
void | zoom () |
void | zoomIn () |
Signals | |
void | browse (QRect &r) |
void | mouseInside (bool) |
void | mouseMoved (QPoint, Qt::MouseButtons, Qt::KeyboardModifiers) |
void | mouseTrackingBegin () |
void | mouseTrackingEnd () |
void | zoomIn (double, double, double, double) |
void | zoomOut () |
Public Member Functions | |
QAction * | action (QString actionName) |
QAction * | addAction (QString actionName) |
void | addLayer (GraphContentLayer *layer) |
void | addProperties (PropertyProxy *pp) |
void | addProperties (GraphContentLayer *layer) |
Rect | boundingRect () const |
const Scale & | constScaleX () const |
const Scale & | constScaleY () const |
double | contourWeight () const |
QString | coordinateTipText (const QPoint &mousePos) |
void | delayPainting () |
GraphContentLayer * | findLayer (QString tagName, QString layerName=QString::null, int startIndex=0) |
AxisWindow * | graph () const |
GraphContent (AxisWindow *parent) | |
const QColor & | gridLineColor () const |
bool | gridLines () const |
double | gridLineWeight () const |
int | layerCount () |
void | moveLayerDown (GraphContentLayer *layer) |
void | moveLayerUp (GraphContentLayer *layer) |
const GraphContentOptions & | options () const |
void | paintMask (QPainter &p) |
QImage * | pixmap () |
virtual void | polish () |
void | print (QPainter &p, double dotpercm, int w, int h, bool mask) |
bool | printBitmap () const |
virtual void | properties (PropertyWidget *w) const |
void | removeLayer (GraphContentLayer *layer) |
void | removeProperties (PropertyProxy *pp) |
Scale & | scaleX () |
Scale & | scaleY () |
void | setContourWeight (double lw) |
void | setGridLineColor (const QColor &c) |
void | setGridLines (bool gl) |
void | setGridLineWeight (double lw) |
void | setLineWeights (double lw) |
void | setPrintBitmap (bool sbmp) |
void | setProgressEnd () |
void | setProgressMaximum (int value) |
void | setProgressValue (int value) |
virtual void | setProperty (uint wid, int pid, QVariant val) |
void | setTransparentMask (bool tm) |
void | swapAxes () |
bool | transparentMask () const |
virtual const QString & | xml_tagName () const |
void | zoomIn (const QPoint &c) |
~GraphContent () | |
Static Public Member Functions | |
static void | clear () |
static void | init () |
Static Public Attributes | |
static const QString | xmlGraphContentTag = "GraphContent" |
Protected Member Functions | |
virtual XMLMember | xml_member (XML_MEMBER_ARGS) |
virtual void | xml_polish (XML_POLISH_ARGS) |
virtual void | xml_polishChild (XML_POLISHCHILD_ARGS) |
virtual bool | xml_setProperty (XML_SETPROPERTY_ARGS) |
virtual void | xml_writeChildren (XML_WRITECHILDREN_ARGS) const |
virtual void | xml_writeProperties (XML_WRITEPROPERTIES_ARGS) const |
Properties | |
double | contourWeight |
DUMMY_PROPERTIES | |
QColor | gridLineColor |
bool | gridLines |
double | gridLineWeight |
QString | name |
QString | objectName |
bool | printBitmap |
double | printLineWeight |
bool | transparentMask |
Friends | |
class | CoordTip |
class | GraphContentLayer |
class | LayerPropertiesItem |
The QbtGraphContent is the plot area of a AxisWindow.
GraphContent manages the X and Y scales to transform double precision coordinates into integer screen coordinates. The graph content is redrawn by the children which must be of type QbtGraphContentLayer. It is done only when strictly necessary (forced by deepUpdate() or resizeEvent()). The resulting bitmap is saved and transfered to the screen on all refresh events.
The following types of layers are implemented in SciFigs (there are all deriving GraphContentLayer):
SciFigs::GraphContent::GraphContent | ( | AxisWindow * | parent | ) |
References QGpGuiTools::setWidgetColor(), and TRACE.
: QWidget(parent) { TRACE; ::setWidgetColor(this, Qt::white); /* Avoid erase before painting */ setAttribute(Qt::WA_OpaquePaintEvent); addActions(); setContextMenuPolicy (Qt::ActionsContextMenu); _paintDepth=0; _mouseTracking=0; setFocusPolicy(Qt::ClickFocus); connect(this,SIGNAL(destroyed()), _coordTip,SLOT(hideTip())); setDefaultCursor(); _mouseMoveDelay.setSingleShot(true); _mouseMoveDelay.setInterval(50); connect(&_mouseMoveDelay, SIGNAL(timeout()), this, SLOT(delayedMouseMoveEvent())); _d=new GraphContentOptions; _progress=new PaintProgress(this); connect(_progress, SIGNAL(repaint()), this, SLOT(paintProgress()), Qt::QueuedConnection); _paintEventTiming.start(); connect(&_paintEventDelay, SIGNAL(timeout()), this, SLOT(update())); _paintEventDelay.setInterval(200); _paintEventDelay.setSingleShot(true); }
References SciFigs::LayerPainter::clear(), SciFigs::LayerPainter::terminate(), and TRACE.
QAction * SciFigs::GraphContent::action | ( | QString | actionName | ) |
Return action named actionName
References TRACE.
Referenced by addAction(), browse(), MagnifierSignal::MagnifierSignal(), GeopsyGui::PickLayer::setPick(), zoom(), SciFigs::AxisWindow::zoomIn(), and SciFigs::AxisWindow::zoomOut().
{ TRACE; QList<QAction *> aList=actions(); QList<QAction *>::iterator it; for(it=aList.begin();it!=aList.end(); ++it) { if((*it)->objectName()==actionName) return *it; } return 0; }
QAction * SciFigs::GraphContent::addAction | ( | QString | actionName | ) |
Check that action actionName is not already added (by objectName). If action a is already added, it returns action named actionName. Else, a new action is created and added.
References action(), and TRACE.
{ TRACE; QAction * a=action(actionName); if(!a) { a=new QAction(this); a->setObjectName(actionName); QWidget::addAction(a); } return a; }
void SciFigs::GraphContent::addLayer | ( | GraphContentLayer * | newlayer | ) |
Called from GraphContentLayer's constructor
References SciFigs::GraphContentLayer::setParent(), and TRACE.
Referenced by SciFigs::GraphContentLayer::GraphContentLayer(), and xml_member().
{ TRACE; newlayer->setParent(this); QList<GraphContentLayer *>::iterator it; for(it=_layers.begin();it!=_layers.end();++it) ASSERT(*it!=newlayer); QString layerName("layer%1"); newlayer->setObjectName(layerName.arg(_layers.count())); _layers.append(newlayer); // We can add layers while painting because painter caches the list of layers _paintDepth=0; }
void SciFigs::GraphContent::addLayers | ( | QString | fileName = QString::null | ) | [slot] |
References deepUpdate(), QGpCoreTools::XMLErrorReport::exec(), SciFigs::XMLSciFigs::Layer, SciFigs::XMLSciFigs::restoreFile(), QGpCoreTools::XMLErrorReport::setFileName(), QGpCoreTools::XMLErrorReport::setTitle(), QGpCoreTools::tr(), and TRACE.
Referenced by addPlot(), and createPlot().
{ TRACE; static QString title=tr("Add layers"); if(fileName.isEmpty()) { fileName=Message::getOpenFileName(title, tr("Graph layers (*.layer)")); } if(fileName.length()>0) { XMLErrorReport xmler(XMLErrorReport::Read); xmler.setTitle(title); xmler.setFileName(fileName); XMLSciFigs s; xmler.exec(s.restoreFile(fileName, this, XMLSciFigs::Layer)); deepUpdate(); } }
void SciFigs::GraphContent::addProperties | ( | PropertyProxy * | pp | ) |
Setup property editor
References QGpGuiTools::PropertyProxy::addCategory(), SciFigs::GraphContentLayerProperties::addGraph(), SciFigs::GraphContentLayer::addProperties(), QGpGuiTools::PropertyProxy::addReference(), QGpGuiTools::PropertyProxy::addTab(), QGpGuiTools::PropertyProxy::currentTabWidget(), SciFigs::GraphContentLayer::hasProperties(), SciFigs::GraphContentLayer::isEditable(), QGpGuiTools::PropertyProxy::setCurrentCategory(), QGpGuiTools::PropertyProxy::setCurrentTab(), QGpCoreTools::tr(), TRACE, and w.
Referenced by SciFigs::AxisWindow::addProperties(), and xml_polishChild().
{ TRACE; if( !pp->setCurrentCategory(_categoryGraphic) ) { pp->addCategory(_categoryGraphic, tr("Graphic"), QIcon( ":/images/GraphContent.png")); } if(pp->setCurrentTab(_tabGraphicFormat)) { pp->addReference(this); } else { GraphContentFormatProperties * w=new GraphContentFormatProperties; pp->addTab(_tabGraphicFormat, tr("Format"), w, this); } if(pp->setCurrentTab(_tabGraphicLayers)) { pp->addReference(this); GraphContentLayerProperties * w=static_cast<GraphContentLayerProperties *>(pp->currentTabWidget()); w->addGraph(this); } else { GraphContentLayerProperties * w=new GraphContentLayerProperties; w->addGraph(this); pp->addTab(_tabGraphicLayers, tr("Layer stack"), w, this); } // First check if there are layers with properties bool hasLayerProperties=false; QList<GraphContentLayer *>::iterator it; for(it=_layers.begin();it!=_layers.end();++it) { GraphContentLayer * l=*it; if(l->hasProperties() && l->isEditable()) { hasLayerProperties=true; break; } } if(hasLayerProperties) { if( !pp->setCurrentCategory(_categoryLayers) ) { pp->addCategory(_categoryLayers, tr("Layers"), QIcon( ":/images/GraphContentLayer.png")); } QList<GraphContentLayer *>::iterator it; for(it=_layers.begin();it!=_layers.end();++it) { GraphContentLayer * l=*it; if(l->isEditable()) l->addProperties(pp); } } }
void SciFigs::GraphContent::addProperties | ( | GraphContentLayer * | layer | ) |
Dynamically add properties of layer to property editor. Cannot be integrated in addLayer() directly because addLayer() is called from contructor of layer object (use of virtual functions).
References QGpGuiTools::PropertyProxy::addCategory(), SciFigs::GraphContentLayer::addProperties(), QGpGuiTools::PropertyProxy::currentTabWidget(), graph(), SciFigs::GraphContentLayer::hasProperties(), SciFigs::GraphContentLayer::isEditable(), SciFigs::GraphicObject::isSelected(), SciFigs::GraphicObject::proxy(), SciFigs::GraphContentLayerProperties::reset(), QGpGuiTools::PropertyProxy::restoreStates(), QGpGuiTools::PropertyProxy::saveStates(), QGpGuiTools::PropertyProxy::setCurrentCategory(), QGpGuiTools::PropertyProxy::setValues(), QGpCoreTools::tr(), and w.
{ AxisWindow * w=graph(); PropertyProxy * pp=w->proxy(); if(pp) { if(layer->hasProperties() && w->isSelected() && layer->isEditable()) { pp->saveStates(); if( !pp->setCurrentCategory(_categoryLayers) ) { pp->addCategory(_categoryLayers, tr("Layers"), QIcon( ":/images/GraphContentLayer.png")); } layer->addProperties(pp); pp->restoreStates(); pp->setValues(); } if(pp->setCurrentCategory(_categoryGraphic) ) { if(pp->setCurrentCategory(_tabGraphicLayers) ) { GraphContentLayerProperties * w=static_cast<GraphContentLayerProperties *>(pp->currentTabWidget()); w->reset(); } } } }
Rect SciFigs::GraphContent::boundingRect | ( | ) | const |
References QGpCoreTools::Rect::add(), SciFigs::GraphContentLayer::boundingRect(), QGpCoreTools::Rect::isNull(), SciFigs::GraphContentLayer::opacity, and TRACE.
Referenced by PSViewer::addPlot(), addPlot(), SciFigs::Axis::boundingRect(), DampingResults::compute(), RefractionTargetWidget::setLimits(), SciFigs::CurveBrowser::setLimits(), Seismic1DThread::setModelLimits(), and MagnetoTelluricThread::setModelLimits().
{ TRACE; Rect r; QList<GraphContentLayer *>::const_iterator it=_layers.begin(); while(it!=_layers.end() && !(*it)->opacity()>0.0) it++; if(it!=_layers.end()) { r=(*it)->boundingRect(); for(it++;it!=_layers.end();++it) { GraphContentLayer * layer=*it; if(layer->opacity()>0.0) { Rect lr=layer->boundingRect(); if(!lr.isNull()) { r.add(lr); } } } } return r; }
void SciFigs::GraphContent::browse | ( | ) | [slot] |
References action(), graph(), SciFigs::LayerMouseTracking::setActionCursor(), SciFigs::LayerMouseTracking::setId(), SciFigs::LayerMouseTracking::setIdleCursor(), SciFigs::LayerMouseTracking::setRectangle(), and TRACE.
Referenced by SciFigs::AxisWindow::zoomOut().
{ TRACE; if(graph()->isActive()) { QAction * a=action("Browse"); if(a) { if(isMouseTracking(0, Browse) || !graph()->isZoomed()) { a->setChecked(false); endMouseTracking(0, Browse); } else { a->setChecked(true); LayerMouseTracking mt(0); mt.setId(Browse); mt.setIdleCursor(Qt::OpenHandCursor); mt.setActionCursor(Qt::ClosedHandCursor); mt.setRectangle(true); beginMouseTracking(mt); } } } }
void SciFigs::GraphContent::browse | ( | QRect & | r | ) | [signal] |
void SciFigs::GraphContent::clear | ( | ) | [static] |
References TRACE.
Referenced by SciFigs::SciFigsGlobal::~SciFigsGlobal().
{ TRACE; delete _coordTip; _coordTip=0; delete _defaultCursor; _defaultCursor=0; delete _layerPainter; _layerPainter=0; }
const Scale& SciFigs::GraphContent::constScaleX | ( | ) | const [inline] |
Referenced by SciFigs::AxisWindow::print().
{return _d->scaleX();}
const Scale& SciFigs::GraphContent::constScaleY | ( | ) | const [inline] |
Referenced by SciFigs::AxisWindow::print().
{return _d->scaleY();}
double SciFigs::GraphContent::contourWeight | ( | ) | const [inline] |
Referenced by print(), and properties().
{return _d->contourWeight();}
QString SciFigs::GraphContent::coordinateTipText | ( | const QPoint & | mousePos | ) |
References graph(), SciFigs::Scale::Inversed, SciFigs::Axis::scaleType, QGpCoreTools::Point2D::setX(), QGpCoreTools::Point2D::setY(), TRACE, SciFigs::Axis::unitFactor, w, QGpCoreTools::Point2D::x(), SciFigs::AxisWindow::xAxis(), QGpCoreTools::Point2D::y(), and SciFigs::AxisWindow::yAxis().
Referenced by SciFigs::CoordTip::fallAsleep().
{ TRACE; Point2D p=_d->s2r(mousePos); AxisWindow * w=graph(); if(w->xAxis()->scaleType()==Scale::Inversed) p.setX(1.0/p.x()); if(w->yAxis()->scaleType()==Scale::Inversed) p.setY(1.0/p.y()); p*=Point2D(w->xAxis()->unitFactor(), w->yAxis()->unitFactor()); // Set info from the visible top most layer for(int i=_layers.count()-1; i >= 0; i--) { if(_layers.at(i)->opacity()>0.0) { return _layers.at(i)->coordinateTipInfo(p); } } return QString::null; }
void SciFigs::GraphContent::copyLayers | ( | ) | [slot] |
Copy all layers to the clipboard
References SciFigs::XMLSciFigs::Layer, SciFigs::XMLSciFigs::saveByteArray(), and TRACE.
{ TRACE; QClipboard * cb=QApplication::clipboard(); XMLSciFigs s; QByteArray layers=s.saveByteArray(this, XMLSciFigs::Layer); QMimeData * mime=new QMimeData; mime->setData("XMLSciFigs::Layers", layers); cb->setMimeData(mime, QClipboard::Clipboard); }
void SciFigs::GraphContent::deepUpdate | ( | int | fromLayer = 0 | ) | [slot] |
fromLayer can vary from 0 to the index of the last layer. 0 to force a complete redraw.
References TRACE.
Referenced by addLayers(), SciFigs::AxisWindow::deepUpdate(), SciFigs::GraphContentLayer::deepUpdate(), delayPainting(), SciFigs::ImageLayer::grayFilter(), SciFigs::ImageLayer::highPassFilter(), SpacSelector::inverseAt(), SciFigs::ImageLayer::loadImage(), SciFigs::ImageLayer::lowPassFilter(), moveLayerDown(), moveLayerUp(), pasteLayers(), SciFigs::ImageLayer::redPassFilter(), removeLayer(), SpacSelector::selectSamples(), SpacSelector::setK(), SciFigs::XYValueLines::setLinearPalette(), SciFigs::XYValuePlot::setPalette(), SciFigs::XYValueLines::setPalette(), SciFigs::GridPlot::setPalette(), SciFigs::GridPlot::setProperty(), SciFigs::NameLineLayer::setProperty(), GeopsyGui::ChronogramLayer::setProperty(), NAModelsPlot::setProperty(), SciFigs::XUniqueYColorLines::setProperty(), SciFigs::XYPlot::setProperty(), SciFigs::ColorPaletteWidget::setProperty(), SciFigs::XYColorLines::setProperty(), SciFigs::ImageLayer::setProperty(), GeopsyGui::SignalLayer::setProperty(), GeopsyGui::SignalLayer::signalsUpdate(), SciFigs::XYPlot::swapXY(), SciFigs::IrregularGrid2DPlot::trackRectangle(), SciFigs::GridViewer::trackRectangle(), SciFigs::LineLayer::trackRectangle(), SciFigs::AxisWindow::zoomIn(), and SciFigs::AxisWindow::zoomOut().
{ TRACE; if(fromLayer<_layers.count() && fromLayer>=0) { if(fromLayer<_paintDepth) _paintDepth=fromLayer; } update(); }
void SciFigs::GraphContent::delayPainting | ( | ) |
Terminate all painting requests about this plot and generate a new painting request with the same depth. This is used internally by GraphContentLayer::lockDelayPainting().
References deepUpdate(), and SciFigs::LayerPainter::terminate().
Referenced by SciFigs::GraphContentLayer::lockDelayPainting(), and SciFigs::AxisWindow::xml_member().
{ int depth=_layerPainter->terminate(this); // Post a new paint request if something terminated if(depth>=0) deepUpdate(depth); }
GraphContentLayer * SciFigs::GraphContent::findLayer | ( | QString | tagName, |
QString | layerName = QString::null , |
||
int | startIndex = 0 |
||
) |
Returns the first layer of type tagName and named layerName. If layerName is empty the layer name is ignored. Search is started at startIndex.
References SciFigs::GraphContentLayer::objectName, TRACE, and SciFigs::GraphContentLayer::xml_tagName().
Referenced by GeopsyGui::TimeWindowLayer::xml_layerPolish(), and xml_member().
{ TRACE; int nLayers=_layers.count(); for(int i=startIndex; i<nLayers; i++) { GraphContentLayer * layer=_layers.at(i); if(layer->xml_tagName()==tagName && (layerName.isEmpty() || layer->objectName()==layerName)) { return layer; } } return 0; }
AxisWindow* SciFigs::GraphContent::graph | ( | ) | const [inline] |
Referenced by addProperties(), browse(), DampingResults::compute(), coordinateTipText(), MagnifierSignal::MagnifierSignal(), properties(), removeLayer(), HistogramWidget::setHistogram(), NAModelsPlot::setParamX(), NAModelsPlot::setParamY(), NAModelsPlot::setParent(), setProperty(), unzoom(), and zoom().
{return reinterpret_cast<AxisWindow *>(parent());}
const QColor& SciFigs::GraphContent::gridLineColor | ( | ) | const [inline] |
Referenced by properties().
{return _d->gridLineColor();}
bool SciFigs::GraphContent::gridLines | ( | ) | const [inline] |
Referenced by print(), and properties().
{return _d->gridLines();}
double SciFigs::GraphContent::gridLineWeight | ( | ) | const [inline] |
Referenced by properties().
{return _d->gridLineWeight();}
void SciFigs::GraphContent::init | ( | ) | [static] |
References CoordTip, and TRACE.
Referenced by SciFigs::SciFigsGlobal::SciFigsGlobal().
int SciFigs::GraphContent::layerCount | ( | ) | [inline] |
Referenced by SciFigs::LayerPropertiesItem::data(), SciFigs::LayerPropertiesItem::headerData(), SciFigs::LayerPropertiesItem::moveLayersDown(), SciFigs::LayerPropertiesItem::moveLayersUp(), moveLayerUp(), SciFigs::LayerPropertiesItem::removeLayers(), SciFigs::LayerPropertiesItem::rowCount(), SciFigs::LayerPropertiesItem::selectAllLayers(), SciFigs::LayerPropertiesItem::selectLayers(), and SciFigs::LayerPropertiesItem::setData().
{return _layers.count();}
void SciFigs::GraphContent::mouseInside | ( | bool | ) | [signal] |
void SciFigs::GraphContent::mouseMoved | ( | QPoint | , |
Qt::MouseButtons | , | ||
Qt::KeyboardModifiers | |||
) | [signal] |
void SciFigs::GraphContent::mouseTrackingBegin | ( | ) | [signal] |
void SciFigs::GraphContent::mouseTrackingEnd | ( | ) | [signal] |
void SciFigs::GraphContent::moveLayerDown | ( | GraphContentLayer * | layer | ) |
References deepUpdate(), SciFigs::GraphContentLayer::lockDelayPainting(), TRACE, and SciFigs::GraphContentLayer::unlock().
Referenced by SciFigs::LayerPropertiesItem::moveLayersDown().
{ TRACE; int i=indexOf(layer); if(i>0) { layer->lockDelayPainting(); // Force termination of all paint requests and wait for layer unlock _layers.swap(i-1, i); layer->unlock(); deepUpdate(); } }
void SciFigs::GraphContent::moveLayerUp | ( | GraphContentLayer * | layer | ) |
References deepUpdate(), layerCount(), SciFigs::GraphContentLayer::lockDelayPainting(), TRACE, and SciFigs::GraphContentLayer::unlock().
Referenced by SciFigs::LayerPropertiesItem::moveLayersUp().
{ TRACE; int i=indexOf(layer); ASSERT(i>-1); if(i<layerCount()-1) { layer->lockDelayPainting(); // Force termination of all paint requests and wait for layer unlock _layers.swap(i, i+1); layer->unlock(); deepUpdate(); } }
const GraphContentOptions& SciFigs::GraphContent::options | ( | ) | const [inline] |
Referenced by SciFigs::AxisWindow::alignHScales(), SciFigs::AxisWindow::alignVScales(), GeopsyGui::ChronogramLayer::exportGaps(), GeopsyGui::PickLayer::keyPressEvent(), SciFigs::LineEditor::mouseMoveEvent(), GeopsyGui::PickLayer::mouseMoveEvent(), SciFigs::PolarGridPlot::mouseReleaseEvent(), SciFigs::GridViewer::mouseReleaseEvent(), SciFigs::IrregularGrid2DPlot::mouseReleaseEvent(), SciFigs::LineLayer::mouseReleaseEvent(), GraphicWindow::setMagnifySignal(), GeopsyGui::SignalLayer::signalAt(), and MonoStation::AbstractTool::signalMouseReleased().
{return *_d;}
void SciFigs::GraphContent::paintMask | ( | QPainter & | p | ) |
References TRACE, and transparentMask().
{ TRACE; if(transparentMask()) #ifdef GRAPHCONTENT_PIXMAP p.drawPixmap(x(), y(), _pixmap.createHeuristicMask()); #else p.drawImage(x(), y(), _pixmap.createHeuristicMask()); #endif else p.fillRect(x(),y(),width(), height(), Qt::color1); }
void SciFigs::GraphContent::pasteLayers | ( | ) | [slot] |
Paste layers from the clipboard if there are any
References deepUpdate(), QGpCoreTools::XMLErrorReport::exec(), SciFigs::XMLSciFigs::Layer, SciFigs::XMLSciFigs::restoreByteArray(), QGpCoreTools::XMLErrorReport::setTitle(), QGpCoreTools::tr(), and TRACE.
{ TRACE; static QString title=tr("Paste layers"); QClipboard * cb=QApplication::clipboard(); const QMimeData * mime=cb->mimeData(QClipboard::Clipboard); if(mime->hasFormat("XMLSciFigs::Layers")) { QByteArray layers=mime->data("XMLSciFigs::Layers"); XMLErrorReport xmler(XMLErrorReport::Read); xmler.setTitle(title); XMLSciFigs s; xmler.exec(s.restoreByteArray(layers, this, XMLSciFigs::Layer)); deepUpdate(); } }
QImage* SciFigs::GraphContent::pixmap | ( | ) | [inline] |
{if(_pixmap.isNull()) return 0; else return &_pixmap;}
void SciFigs::GraphContent::polish | ( | ) | [virtual] |
void SciFigs::GraphContent::print | ( | QPainter & | p, |
double | dotpercm, | ||
int | w, | ||
int | h, | ||
bool | mask | ||
) |
References contourWeight(), gridLines(), printBitmap(), SciFigs::LayerPainterRequest::setGraphContent(), SciFigs::LayerPainterRequest::setOptions(), SciFigs::LayerPainterRequest::setSize(), TRACE, and transparentMask().
Referenced by SciFigs::AxisWindow::print().
{ TRACE; if(w<=0 || h<=0) { return; } if(mask && !transparentMask()) { p.fillRect(0, 0, w, h, Qt::color1); return; } p.save(); LayerPainterRequest lp; lp.setGraphContent(this); lp.setSize(w, h); lp.setOptions(_d); int nLayers=_layers.count(); for(int i=0;i<nLayers;i++) { _layers.at(i)->paintText(lp, dotpercm); } if(printBitmap()) { // Depends upon media support: for bitmap, printBitmap is force to true // in scaleFonts(). QImage * printerImage=new QImage(w,h,QImage::Format_ARGB32_Premultiplied); QPainter ppx; ppx.begin(printerImage); ppx.fillRect(0,0,w,h,Qt::white); if (gridLines()) { _d->paintGridLines(ppx, dotpercm, w, h); } for (int i=0;i<nLayers;i++) { _layers.at(i)->paint(lp, ppx, dotpercm); } ppx.end(); p.drawImage(0,0,*printerImage); delete printerImage; } else { p.fillRect(0,0,w,h,Qt::white); if(gridLines()) { _d->paintGridLines(p, dotpercm, w, h); } for (int i=0;i<nLayers;i++) { _layers.at(i)->paint(lp, p, dotpercm); } } if(contourWeight()>0) _d->paintContour(p, dotpercm, w, h); p.restore(); }
bool SciFigs::GraphContent::printBitmap | ( | ) | const [inline] |
Referenced by print(), and properties().
{return _d->printBitmap();}
void SciFigs::GraphContent::properties | ( | PropertyWidget * | w | ) | const [virtual] |
Implements QGpGuiTools::PropertyItem.
References SciFigs::GraphContentFormatProperties::ContourWeight, contourWeight(), graph(), SciFigs::GraphContentFormatProperties::GridLineColor, gridLineColor(), SciFigs::GraphContentFormatProperties::GridLines, gridLines(), SciFigs::GraphContentFormatProperties::GridLineWeight, gridLineWeight(), SciFigs::GraphContentFormatProperties::HorizontalAxis, QGpGuiTools::PropertyWidget::id(), SciFigs::GraphContentFormatProperties::PrintBitmap, printBitmap(), QGpGuiTools::PropertyWidget::setValue(), TRACE, SciFigs::GraphContentFormatProperties::TransparentMask, transparentMask(), SciFigs::GraphContentFormatProperties::VerticalAxis, SciFigs::AxisWindow::xAxis(), and SciFigs::AxisWindow::yAxis().
{ TRACE; if(w->id()==_tabGraphicFormat) { AxisWindow * g=graph(); w->setValue(GraphContentFormatProperties::HorizontalAxis, g->xAxis()->isEnabled()); w->setValue(GraphContentFormatProperties::VerticalAxis, g->yAxis()->isEnabled()); w->setValue(GraphContentFormatProperties::GridLines, gridLines()); w->setValue(GraphContentFormatProperties::GridLineColor, gridLineColor()); w->setValue(GraphContentFormatProperties::TransparentMask, transparentMask()); w->setValue(GraphContentFormatProperties::PrintBitmap, printBitmap()); w->setValue(GraphContentFormatProperties::ContourWeight, contourWeight()); w->setValue(GraphContentFormatProperties::GridLineWeight, gridLineWeight()); } }
void SciFigs::GraphContent::removeLayer | ( | GraphContentLayer * | layer | ) |
Remove layer from layer stack and delete it.
References deepUpdate(), graph(), SciFigs::GraphContentLayer::isRemovable(), SciFigs::GraphContentLayer::lockDelayPainting(), SciFigs::GraphicObject::proxy(), SciFigs::GraphContentLayer::removeProperties(), QGpGuiTools::PropertyProxy::setCurrentCategory(), TRACE, and SciFigs::GraphContentLayer::unlock().
Referenced by SciFigs::LayerPropertiesItem::removeLayers().
{ TRACE; ASSERT(layer->isRemovable()); layer->lockDelayPainting(); // Force termination of all paint requests and wait for layer unlock _layers.removeAt(indexOf(layer)); _layerImages.remove(layer); layer->unlock(); PropertyProxy * pp=graph()->proxy(); if(pp) { if(pp->setCurrentCategory(_categoryLayers)) { layer->removeProperties(pp); } } delete layer; if(_layers.isEmpty()) { #ifdef GRAPHCONTENT_PIXMAP _pixmap=QPixmap(); #else _pixmap=QImage(); #endif update(); } else { deepUpdate(); } }
void SciFigs::GraphContent::removeProperties | ( | PropertyProxy * | pp | ) |
Cleanup property editor
References QGpGuiTools::PropertyProxy::currentTabWidget(), SciFigs::GraphContentLayerProperties::removeGraph(), QGpGuiTools::PropertyProxy::removeTab(), QGpGuiTools::PropertyProxy::setCurrentCategory(), QGpGuiTools::PropertyProxy::setCurrentTab(), TRACE, and w.
Referenced by SciFigs::AxisWindow::removeProperties().
{ TRACE; if(pp->setCurrentCategory(_categoryGraphic) ) { pp->removeTab(_tabGraphicFormat, this); if(pp->setCurrentTab(_tabGraphicLayers)) { GraphContentLayerProperties * w=static_cast<GraphContentLayerProperties *>(pp->currentTabWidget()); w->removeGraph(this); pp->removeTab(_tabGraphicLayers, this); } } if(pp->setCurrentCategory(_categoryLayers) ) { QList<GraphContentLayer *>::iterator it; for(it=_layers.begin();it!=_layers.end();++it) { (*it)->removeProperties(pp); } } }
void SciFigs::GraphContent::saveLayers | ( | QString | fileName = QString::null | ) | [slot] |
References SciFigs::XMLSciFigs::Layer, SciFigs::XMLSciFigs::saveFile(), QGpCoreTools::tr(), and TRACE.
Scale& SciFigs::GraphContent::scaleX | ( | ) | [inline] |
Referenced by addPlot(), SciFigs::AxisWindow::print(), and HistogramWidget::setHistogram().
{return _d->scaleX();}
Scale& SciFigs::GraphContent::scaleY | ( | ) | [inline] |
Referenced by addPlot(), SciFigs::AxisWindow::print(), and HistogramWidget::setHistogram().
{return _d->scaleY();}
void SciFigs::GraphContent::setContourWeight | ( | double | lw | ) | [inline] |
Referenced by setLineWeights(), and setProperty().
{_d->setContourWeight(lw);}
void SciFigs::GraphContent::setGridLineColor | ( | const QColor & | c | ) | [inline] |
Referenced by setProperty().
{_d->setGridLineColor(c);}
SciFigs::GraphContent::setGridLines | ( | bool | gl | ) | [inline] |
Show or hide grid lines
Referenced by SciFigs::ActivityMonitor::ActivityMonitor(), SciFigs::ColorPaletteWidget::ColorPaletteWidget(), FKTimeWindows::FKTimeWindows(), and setProperty().
{_d->setGridLines(gl);}
void SciFigs::GraphContent::setGridLineWeight | ( | double | lw | ) | [inline] |
Referenced by setLineWeights(), and setProperty().
{_d->setGridLineWeight(lw);}
void SciFigs::GraphContent::setLineWeights | ( | double | lw | ) |
Set the line weight for contour and for grid lines. Mainly used for compatibility with old files. Grid line weight is set to one half of contour weight.
References setContourWeight(), and setGridLineWeight().
{ setContourWeight(lw); setGridLineWeight(lw * 0.5); }
SciFigs::GraphContent::setPrintBitmap | ( | bool | p | ) | [inline] |
True to print in a bitmap rather than directly. Effective only for vectorial ouptut (ps, pdf,..)
Referenced by SciFigs::AxisWindow::restoreScaleFonts(), SciFigs::AxisWindow::scaleFonts(), and setProperty().
{_d->setPrintBitmap(sbmp);}
References SciFigs::PaintProgress::boundingRect(), and SciFigs::PaintProgress::setActive().
Referenced by SciFigs::AxisWindow::print().
{ _progress->setActive(false); update(_progress->boundingRect()); }
void SciFigs::GraphContent::setProgressMaximum | ( | int | value | ) | [inline] |
References QGpCoreTools::AbstractProgress::setMaximum().
Referenced by SciFigs::GridPlot::drawGrid2DBlock(), SciFigs::GridPlot::drawGrid2DSmooth(), SciFigs::XYValueLines::paintData(), and GeopsyGui::SignalLayer::paintData().
{ _progress->setMaximum(value); }
void SciFigs::GraphContent::setProgressValue | ( | int | value | ) | [inline] |
References QGpCoreTools::AbstractProgress::setValue().
Referenced by SciFigs::GridPlot::drawGrid2DBlock(), SciFigs::GridPlot::drawGrid2DSmooth(), SciFigs::XYValueLines::paintData(), and GeopsyGui::SignalLayer::paintData().
{ _progress->setValue(value); }
void SciFigs::GraphContent::setProperty | ( | uint | wid, |
int | pid, | ||
QVariant | val | ||
) | [virtual] |
Set value val to property id, after a user action in property editor
Implements QGpGuiTools::PropertyItem.
References SciFigs::GraphContentFormatProperties::ContourWeight, SciFigs::AxisWindow::deepUpdate(), graph(), SciFigs::GraphContentFormatProperties::GridLineColor, SciFigs::GraphContentFormatProperties::GridLines, SciFigs::GraphContentFormatProperties::GridLineWeight, SciFigs::GraphContentFormatProperties::HorizontalAxis, SciFigs::GraphContentFormatProperties::PrintBitmap, setContourWeight(), setGridLineColor(), setGridLines(), setGridLineWeight(), setPrintBitmap(), setTransparentMask(), TRACE, SciFigs::GraphContentFormatProperties::TransparentMask, SciFigs::AxisWindow::updateExternalGeometry(), SciFigs::GraphContentFormatProperties::VerticalAxis, SciFigs::AxisWindow::xAxis(), and SciFigs::AxisWindow::yAxis().
{ TRACE; if(wid==_tabGraphicFormat) { AxisWindow * p=graph(); switch(pid) { case GraphContentFormatProperties::HorizontalAxis: p->xAxis()->setEnabled(val.toBool()); if(p->xAxis()->isEnabled()) p->xAxis()->show(); else p->xAxis()->hide(); p->updateExternalGeometry(); p->deepUpdate(); break; case GraphContentFormatProperties::VerticalAxis: p->yAxis()->setEnabled(val.toBool()); if(p->yAxis()->isEnabled()) p->yAxis()->show(); else p->yAxis()->hide(); p->updateExternalGeometry(); p->deepUpdate(); break; case GraphContentFormatProperties::GridLines: setGridLines(val.toBool()); p->deepUpdate(); break; case GraphContentFormatProperties::GridLineColor: setGridLineColor(val.value<QColor>()); p->deepUpdate(); break; case GraphContentFormatProperties::TransparentMask: setTransparentMask(val.toBool()); break; case GraphContentFormatProperties::PrintBitmap: setPrintBitmap(val.toBool()); break; case GraphContentFormatProperties::ContourWeight: setContourWeight(val.toDouble()); p->deepUpdate(); break; case GraphContentFormatProperties::GridLineWeight: setGridLineWeight(val.toDouble()); p->deepUpdate(); break; default: break; } } }
SciFigs::GraphContent::setTransparentMask | ( | bool | tm | ) | [inline] |
Use a mask when printing an image made of non blank pixels
Referenced by setProperty().
{_d->setTransparentMask(tm);}
void SciFigs::GraphContent::swapAxes | ( | ) | [inline] |
Referenced by SciFigs::AxisWindow::swapAxes().
{_d->swapAxes();}
bool SciFigs::GraphContent::transparentMask | ( | ) | const [inline] |
Referenced by paintMask(), print(), and properties().
{return _d->transparentMask();}
void SciFigs::GraphContent::unzoom | ( | ) | [slot] |
XMLMember SciFigs::GraphContent::xml_member | ( | XML_MEMBER_ARGS | ) | [protected, virtual] |
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:
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 QGpCoreTools::XMLClass.
References addLayer(), SciFigs::GraphContentLayerFactory::create(), SciFigs::XMLSciFigs::data(), QGpCoreTools::endl(), findLayer(), SciFigs::GraphContentLayerFactory::instance(), SciFigs::XMLSciFigs::makeUp(), MSG_ID, SciFigs::GraphContentLayer::objectName, QGpCoreTools::XMLClass::qobject_member(), SciFigs::GraphContentLayer::removeReference(), QGpCoreTools::tr(), and TRACE.
{ TRACE; static const QString tmp("layer"); XMLSciFigs * scifigsContext=static_cast<XMLSciFigs *>(context); XMLRestoreAttributeIterator it=attributes.find(tmp); if(it!=attributes.end()) { GraphContentLayer * layer; if(scifigsContext->data()) { GraphContentLayer * layer=GraphContentLayerFactory::instance()->create(tag.toString()); if(layer) { addLayer(layer); layer->setObjectName(it.value().toString()); // In pure data XML, objectName is not set properly layer->removeReference(); // By default layers are not removable except when loaded from page and layer files return XMLMember(layer); } else { App::stream() << tr("Unknown layer type %1").arg(tag.toString()) << endl; return XMLMember(XMLMember::Unknown); } } else { layer=findLayer(tag.toString(), it.value().toString()); if(layer) return XMLMember(layer); else { layer=findLayer(tag.toString(), QString::null); if(layer) { if(Message::warning(MSG_ID,tr("Restore"), tr("Cannot find a layer of type '%1' and named '%2', " "but a layer of type '%3' and named '%4' has been found. " "Do you want restore properties to this layer?"). arg(tag.toString()).arg(it.value().toString()). arg(tag.toString()).arg(layer->objectName()), Message::yes(),Message::no(), true)==Message::Answer0) { return XMLMember(layer); } else return XMLMember(XMLMember::Unknown); } else { App::stream() << tr("Cannot find a layer of type %1").arg(tag.toString()) << endl; return XMLMember(XMLMember::Unknown); } } } } else if(scifigsContext->makeUp()) { return qobject_member(this, tag, attributes, context); } return XMLMember(XMLMember::Unknown); }
void SciFigs::GraphContent::xml_polish | ( | XML_POLISH_ARGS | ) | [protected, virtual] |
Reimplemented from QGpCoreTools::XMLClass.
{ int n=_layers.count(); for(int i=0; i<n; i++) { _layers.at(i)->xml_layerPolish(context); } }
void SciFigs::GraphContent::xml_polishChild | ( | XML_POLISHCHILD_ARGS | ) | [protected, virtual] |
Reimplemented from QGpCoreTools::XMLClass.
References addProperties(), and SciFigs::XMLSciFigs::data().
{ XMLSciFigs * scifigsContext=static_cast<XMLSciFigs *>(context); if(scifigsContext->data()) { GraphContentLayer * layer=static_cast<GraphContentLayer *>(child); // Add layer dynamically to property editor if necessary addProperties(layer); } }
virtual bool SciFigs::GraphContent::xml_setProperty | ( | XML_SETPROPERTY_ARGS | ) | [inline, protected, virtual] |
Re-implement this function to offer XML restore properties support to your class.
From memberID set the corresponding property with value content. The map of attributes is given as a supplementary information (not useful in all cases).
For a general case:
Q_UNUSED(attributes); double val=content.toDouble(); switch (memberID) { case 0: _x1=val; return true; case 1: _y1=val; return true; case 2: _x2=val; return true; case 3: _y2=val; return true; default: return false; }
For classes inheriting other classes (see also xml_member())
switch (memberID) { case 0: _anInteger=content.toString(); return true; case 1: _aString=content.toInt(); return true; case 2: _aDouble=content.toDouble(); return true; default: return AbstractLine::xml_setProperty(memberID-3, map, content);
For the arguments of this function use Macro XML_SETPROPERTY_ARGS.
Reimplemented from QGpCoreTools::XMLClass.
{return qobject_setProperty(this, memberID, tag, attributes, content, context);}
virtual const QString& SciFigs::GraphContent::xml_tagName | ( | ) | const [inline, virtual] |
Implements QGpCoreTools::XMLClass.
{return xmlGraphContentTag;}
void SciFigs::GraphContent::xml_writeChildren | ( | XML_WRITECHILDREN_ARGS | ) | const [protected, virtual] |
Reimplemented from QGpCoreTools::XMLClass.
References QGpCoreTools::XMLSaveAttributes::add(), SciFigs::GraphContentLayer::isSelected(), SciFigs::GraphContentLayer::objectName, TRACE, and QGpCoreTools::XMLClass::xml_save().
{ TRACE; QList<GraphContentLayer *>::const_iterator it; static const QString key("layer"); XMLSaveAttributes att; QString& value=att.add(key); for(it=_layers.begin();it!=_layers.end();++it) { GraphContentLayer * layer=*it; if(layer->isSelected()) { value=layer->objectName(); layer->xml_save(s, context, att); } } }
void SciFigs::GraphContent::xml_writeProperties | ( | XML_WRITEPROPERTIES_ARGS | ) | const [protected, virtual] |
Reimplemented from QGpCoreTools::XMLClass.
References SciFigs::XMLSciFigs::makeUp(), QGpCoreTools::XMLClass::qobject_writeProperties(), and TRACE.
{ TRACE; XMLSciFigs * scifigsContext=static_cast<XMLSciFigs *>(context); if(scifigsContext->makeUp()) { qobject_writeProperties(this, this, s, context); } }
void SciFigs::GraphContent::zoom | ( | ) | [slot] |
References action(), graph(), SciFigs::LayerMouseTracking::setId(), SciFigs::LayerMouseTracking::setIdleCursor(), SciFigs::LayerMouseTracking::setRectangle(), SciFigs::LayerMouseTracking::showRectangle(), and TRACE.
{ TRACE; if(graph()->isActive()) { QAction * a=action("Zoom"); if(a) { if(isMouseTracking(0, Zoom)) { a->setChecked(false); endMouseTracking(0, Zoom); } else { a->setChecked(true); LayerMouseTracking mt(0); mt.setId(Zoom); mt.setIdleCursor(QPixmap(":/images/zoomcursor.png"), 4, 4); mt.setRectangle(true); mt.showRectangle(); beginMouseTracking(mt); } } } }
void SciFigs::GraphContent::zoomIn | ( | const QPoint & | c | ) |
Zoom from center c.
References TRACE, w, and zoomIn().
{ TRACE; int w=width()/4; int h=height()/4; int x1=c.x()-w; int y1=c.y()-h; int x2=c.x()+w; int y2=c.y()+h; if(x1<0) { x2-=x1; x1=0; } else if(x2>width()) { x1-=x2-width(); x2=width(); } if(y1<0) { y2-=y1; y1=0; } else if(y2>height()) { y1-=y2-height(); y2=height(); } emit(zoomIn(_d->xs2r(x1), _d->ys2r(y1), _d->xs2r(x2), _d->ys2r(y2))); }
void SciFigs::GraphContent::zoomIn | ( | ) | [slot] |
void SciFigs::GraphContent::zoomIn | ( | double | , |
double | , | ||
double | , | ||
double | |||
) | [signal] |
void SciFigs::GraphContent::zoomOut | ( | ) | [signal] |
Referenced by unzoom().
friend class GraphContentLayer [friend] |
friend class LayerPropertiesItem [friend] |
const QString SciFigs::GraphContent::xmlGraphContentTag = "GraphContent" [static] |
double SciFigs::GraphContent::contourWeight [read, write] |
QColor SciFigs::GraphContent::gridLineColor [read, write] |
bool SciFigs::GraphContent::gridLines [read, write] |
double SciFigs::GraphContent::gridLineWeight [read, write] |
QString SciFigs::GraphContent::name [read, write] |
QString SciFigs::GraphContent::objectName [read, write] |
bool SciFigs::GraphContent::printBitmap [read, write] |
Referenced by SciFigs::AxisWindow::scaleFonts().
double SciFigs::GraphContent::printLineWeight [read, write] |
bool SciFigs::GraphContent::transparentMask [read, write] |