#include <PSViewer.h>
Public Slots | |
void | addPlot () |
AxisWindow * | addPlot (int paramX, int paramY) |
void | fileOpenPS () |
void | fileSaveAsPS () |
void | fileSavePS () |
void | setLimits () |
void | synchronize () |
Public Member Functions | |
void | addThreadData (InversionThread *models) |
void | lockDataModels () |
void | lockPlots () |
const ModelThreadList & | modelList () const |
const ColorPalette * | palette () const |
const InversionThread * | parameterList () const |
PSViewer (QWidget *parent=0) | |
bool | saveParameters () const |
void | unlockDataModels () |
void | unlockPlots () |
~PSViewer () |
PSViewer::PSViewer | ( | QWidget * | parent = 0 | ) |
References SciFigs::GraphicSheet::addObject(), SciFigs::ColorPaletteWidget::defaultHSVColors(), SciFigs::ColorPaletteWidget::setNumberPrecision(), SciFigs::GraphicObject::setObjectName(), SciFigs::GraphicObject::setPrintHeight(), SciFigs::GraphicObject::setPrintWidth(), SciFigs::GraphicObject::setPrintXAnchor(), SciFigs::GraphicObject::setPrintYAnchor(), SciFigs::ColorPaletteWidget::setTitle(), SciFigs::ColorPaletteWidget::setVLinear(), and TRACE.
: QWidget(parent) { TRACE; setAttribute(Qt::WA_DeleteOnClose, true); _childLayout=new QVBoxLayout(this); _childLayout->setMargin(0); _childLayout->setSpacing(0); #ifndef Q_WS_MAC _menuBar=new QMenuBar(this); _childLayout->addWidget(_menuBar); #endif _childLayout->addWidget(&_sheet); resize(700, 500); Settings::getSize(this, "PSViewer" ); _palette=new ColorPaletteWidget(0); _palette->setObjectName( "Palette" ); _palette->defaultHSVColors(255, 230, 128); _palette->setNumberPrecision(2); _palette->setTitle( "Misfit value" ); _palette->setVLinear(0, 1); _palette->setPrintXAnchor(6); _palette->setPrintYAnchor(20); _palette->setPrintWidth(15); _palette->setPrintHeight(2); _sheet.addObject(_palette); _saveParameters=false; addActions(); }
References DinverCore::dinverCore, lockPlots(), DinverCore::DinverCoreObject::removeWindow(), TRACE, and unlockPlots().
{ TRACE; Settings::setSize(this, "PSViewer" ); lockPlots(); ViewerThreadMap::iterator it; for(it=_threads.begin();it!=_threads.end();++it) delete *it; unlockPlots(); dinverCore->removeWindow(this); }
void PSViewer::addPlot | ( | ) | [slot] |
References SciFigs::GraphContent::boundingRect(), SciFigs::AxisWindow::graphContent(), parameterList(), SciFigs::Axis::setRange(), TRACE, SciFigs::AxisWindow::updateGeometry(), w, SciFigs::AxisWindow::xAxis(), and SciFigs::AxisWindow::yAxis().
Referenced by addThreadData().
{ TRACE; AddPlotParam * d=new AddPlotParam (this); d->param->setParameterList(parameterList()); Settings::getWidget(d); if(d->exec()==QDialog::Accepted) { Settings::setWidget(d); AxisWindow * w=addPlot(d->param->paramX(), d->param->paramY()); Rect r=w->graphContent()->boundingRect(); w->xAxis()->setRange(r.x1(), r.x2()); w->yAxis()->setRange(r.y1(), r.y2()); w->updateGeometry(); } }
AxisWindow * PSViewer::addPlot | ( | int | paramX, |
int | paramY | ||
) | [slot] |
References SciFigs::GraphicSheet::addObject(), SciFigs::GraphicSheet::currentOrigin(), SciFigs::AxisWindow::graphContent(), SciFigs::GraphicObject::setObjectName(), NAModelsPlot::setParamX(), NAModelsPlot::setParamY(), SciFigs::GraphicObject::setPrintAnchor(), SciFigs::GraphicObject::setPrintHeight(), SciFigs::GraphicObject::setPrintWidth(), SciFigs::GraphicObject::setRemovable(), SciFigs::GraphicSheet::showObject(), TRACE, and w.
{ TRACE; AxisWindow * w=new AxisWindow; w->setObjectName( "graph" ); _sheet.addObject(w); NAModelsPlot * plot=new NAModelsPlot(w); connect(_palette, SIGNAL(changed(ColorPalette)), w->graphContent(), SLOT(deepUpdate())); plot->setParamX(paramX); plot->setParamY(paramY); w->setRemovable(true); w->setPrintAnchor(_sheet.currentOrigin() + Point2D(1.0, 1.0) ); w->setPrintWidth(6.0); w->setPrintHeight(6.0); _sheet.showObject(w); return w; }
void PSViewer::addThreadData | ( | InversionThread * | models | ) |
References addPlot(), lockPlots(), models, parameterList(), SciFigs::GraphicObject::setPrintAnchor(), TRACE, unlockPlots(), SciFigs::AxisWindow::updateGeometry(), InversionThread::variableParameterCount(), and w.
Referenced by DinverGui::viewPS().
{ TRACE; // Look if this set of models is already in if(_threads.contains(models) ) return ; // Test if parameter space are compatible with current models if( !_threads.isEmpty() && *parameterList()!=*models) return ; lockPlots(); _threads.insert(models, new ViewerThreadInfo); unlockPlots(); if(_threads.count()==1) { int nd=models->variableParameterCount(); double y=0.5; for(int i=0;i < nd;i++ ) { AxisWindow * w=addPlot( -1, i); w->setPrintAnchor(Point2D( 0.5, y) ); w->updateGeometry(); y += 6.0; } } }
void PSViewer::fileOpenPS | ( | ) | [slot] |
References SciFigs::GraphicSheet::fileOpen(), and TRACE.
void PSViewer::fileSaveAsPS | ( | ) | [slot] |
References SciFigs::GraphicSheet::fileSaveAs(), and TRACE.
{ TRACE; _saveParameters=true; _sheet.fileSaveAs(); _saveParameters=false; }
void PSViewer::fileSavePS | ( | ) | [slot] |
References SciFigs::GraphicSheet::fileSave(), and TRACE.
void PSViewer::lockDataModels | ( | ) |
References TRACE.
Referenced by NAModelsPlot::boundingRect(), NAModelsPlot::paintData(), setLimits(), synchronize(), and NAModelsPlot::xml_writeBinaryData().
{ TRACE; ViewerThreadMap::iterator it; for(it=_threads.begin();it!=_threads.end();++it) { it.key()->lock(); } }
void PSViewer::lockPlots | ( | ) |
References SciFigs::GraphContentLayer::lockDelayPainting(), and TRACE.
Referenced by addThreadData(), synchronize(), and ~PSViewer().
{ TRACE; QList<NAModelsPlot *> plotList=_sheet.findChildren<NAModelsPlot *>(); for(QList<NAModelsPlot *>::iterator it=plotList.begin(); it!=plotList.end(); ++it) { (*it)->lockDelayPainting(); } }
const ModelThreadList& PSViewer::modelList | ( | ) | const [inline] |
Referenced by NAModelsPlot::boundingRect(), NAModelsPlot::paintData(), setLimits(), and NAModelsPlot::xml_writeBinaryData().
{return _models;}
const ColorPalette* PSViewer::palette | ( | ) | const [inline] |
References SciFigs::ColorPaletteWidget::palette().
Referenced by NAModelsPlot::paintData(), and NAModelsPlot::xml_writeChildren().
{return &_palette->palette();}
const InversionThread* PSViewer::parameterList | ( | ) | const [inline] |
Referenced by addPlot(), NAModelsPlot::addProperties(), addThreadData(), NAModelsPlot::setParamX(), and NAModelsPlot::setParamY().
{ if(_threads.isEmpty()) return 0; else return _threads.begin().key(); }
PSViewer::saveParameters | ( | ) | const [inline] |
If it return true, the NAModelsPlot contained in the sheet will export themselves as NAModelsPlot and not as XYValuePlot. The first one are used to save "canvas" for viewing particular parameter spaces while the last one is for viewing in figue. Set by slots PSViewer::fileSavePS() and PSViewer::fileSaveAsPS().
Referenced by NAModelsPlot::saveParameters().
{return _saveParameters;}
void PSViewer::setLimits | ( | ) | [slot] |
References NAModelsPlot::boundingRect(), SciFigs::AxisWindow::deepUpdate(), SciFigs::GraphicSheet::deepUpdate(), SciFigs::GraphContentLayer::graph(), ModelThreadInfo::index(), lockDataModels(), InversionThread::misfit(), modelList(), SAFE_UNINITIALIZED, SciFigs::Axis::setRange(), SciFigs::ColorPaletteWidget::setVLinear(), SciFigs::ColorPaletteWidget::setVLog(), ModelThreadInfo::thread(), TRACE, unlockDataModels(), w, QGpCoreTools::Rect::x1(), QGpCoreTools::Rect::x2(), SciFigs::AxisWindow::xAxis(), QGpCoreTools::Rect::y1(), QGpCoreTools::Rect::y2(), and SciFigs::AxisWindow::yAxis().
Referenced by DinverGui::viewPS().
{ TRACE; QList<NAModelsPlot *> plotList=_sheet.findChildren<NAModelsPlot *>(); for(QList<NAModelsPlot *>::iterator it=plotList.begin(); it!=plotList.end(); ++it) { NAModelsPlot * plot=*it; Rect r=plot->boundingRect(); AxisWindow * w=plot->graph(); w->xAxis()->setRange(r.x1(), r.x2()); w->yAxis()->setRange(r.y1(), r.y2()); w->deepUpdate(); } if(modelList().size() > 0) { lockDataModels(); ModelThreadList::const_iterator it=modelList().begin(); if(it!=modelList().end()) { double minM=1e99, maxM=-1e99; double misfitValue; SAFE_UNINITIALIZED(misfitValue, 0); for(; it!=modelList().end(); ++it) { const ModelThreadInfo& modelInfo=*it; misfitValue=it->thread()->misfit(modelInfo.index()); if(misfitValue>maxM) maxM=misfitValue; if(misfitValue<minM) minM=misfitValue; } if(misfitValue>0) { _palette->setVLog(minM, maxM); } else { _palette->setVLinear(minM, maxM); } _sheet.deepUpdate(); } unlockDataModels(); } }
void PSViewer::synchronize | ( | ) | [slot] |
References SciFigs::GraphicSheet::deepUpdate(), iModel, InversionThread::lock(), lockDataModels(), lockPlots(), InversionThread::misfit(), TRACE, InversionThread::unlock(), unlockDataModels(), unlockPlots(), and InversionThread::visitedModelCount().
Referenced by DinverGui::viewPS().
{ TRACE; //App::stream() << "Synchronize now" << endl; lockPlots(); ViewerThreadMap::iterator it; for(it=_threads.begin();it!=_threads.end();++it) { const InversionThread * t=static_cast<const InversionThread *>(it.key()); t->lock(); int nModels=t->visitedModelCount(); int& iModel=it.value()->alreadyLoaded; //App::stream() << tr("Already loaded %1, max %2").arg(iModel).arg(nModels) << endl; if(iModel > nModels) { // Less models than in view (probably a clear) _models.clear(); iModel=0; } if(iModel < nModels) { for( ;iModel < nModels;iModel++ ) { if(t->misfit(iModel)!=1e99) { _models.append(ModelThreadInfo( t, iModel) ); } } } t->unlock(); } lockDataModels(); qSort(_models); unlockDataModels(); unlockPlots(); _sheet.deepUpdate(); }
void PSViewer::unlockDataModels | ( | ) |
References TRACE.
Referenced by NAModelsPlot::boundingRect(), NAModelsPlot::paintData(), setLimits(), synchronize(), and NAModelsPlot::xml_writeBinaryData().
{ TRACE; ViewerThreadMap::iterator it; for(it=_threads.begin();it!=_threads.end();++it) { it.key()->unlock(); } }
void PSViewer::unlockPlots | ( | ) |
References TRACE, and SciFigs::GraphContentLayer::unlock().
Referenced by addThreadData(), synchronize(), and ~PSViewer().
{ TRACE; QList<NAModelsPlot *> plotList=_sheet.findChildren<NAModelsPlot *>(); for(QList<NAModelsPlot *>::iterator it=plotList.begin(); it!=plotList.end(); ++it) { (*it)->unlock(); } }