Public Slots | Public Member Functions
PSViewer Class Reference

#include <PSViewer.h>

List of all members.

Public Slots

void addPlot ()
AxisWindowaddPlot (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 ModelThreadListmodelList () const
const ColorPalettepalette () const
const InversionThreadparameterList () const
 PSViewer (QWidget *parent=0)
bool saveParameters () const
void unlockDataModels ()
void unlockPlots ()
 ~PSViewer ()

Constructor & Destructor Documentation

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);
}

Member Function Documentation

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 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.

{
  TRACE;
  _saveParameters=true;
  _sheet.fileOpen();
  _saveParameters=false;
}
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.

{
  TRACE;
  _saveParameters=true;
  _sheet.fileSave();
  _saveParameters=false;
}

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();
  }
}

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]
const ColorPalette* PSViewer::palette ( ) const [inline]
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();
}

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();
  }
}

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();
  }
}

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