//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- bool RicImportSummaryCasesFeature::createAndAddSummaryCasesFromFiles(const QStringList& fileNames, std::vector<RimSummaryCase*>* newCases) { RiaApplication* app = RiaApplication::instance(); std::vector<RimSummaryCase*> temp; std::vector<RimSummaryCase*>* cases = newCases ? newCases : &temp; if (createSummaryCasesFromFiles(fileNames, cases)) { addSummaryCases(*cases); if (!cases->empty()) { createNewPlot(cases->back()); } RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); if (mainPlotWindow && !cases->empty()) { mainPlotWindow->selectAsCurrentItem(cases->back()); mainPlotWindow->updateSummaryPlotToolBar(); // Close main window if there are no eclipse cases imported std::vector<RimCase*> allCases; app->project()->allCases(allCases); if (allCases.size() == 0) { RiuMainWindow::instance()->close(); } } return true; } return false; }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreator::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { if (changedField == &m_applyButtonField || changedField == &m_okButtonField) { if (m_targetPlot == nullptr) { createNewPlot(); } updateTargetPlot(); if (changedField == &m_okButtonField) { m_closeButtonField = true; RiuPlotMainWindowTools::showPlotMainWindow(); RiuPlotMainWindowTools::selectAsCurrentItem(m_targetPlot); RiuPlotMainWindowTools::setExpanded(m_targetPlot); } m_applyButtonField = false; m_okButtonField = false; caf::PdmField<bool>* field = dynamic_cast<caf::PdmField<bool>*>(m_targetPlot->uiCapability()->objectToggleField()); field->setValueWithFieldChanged(true); } else if (changedField == &m_useAutoAppearanceAssignment && m_useAutoAppearanceAssignment) { updateAppearanceEditor(); } else if (changedField == &m_appearanceApplyButton) { applyAppearanceToAllPreviewCurves(); m_previewPlot->loadDataAndUpdate(); m_appearanceApplyButton = false; } else if (changedField == &m_useAutoPlotTitleProxy) { m_previewPlot->updatePlotTitle(); m_previewPlot->summaryCurveCollection()->updateConnectedEditors(); } }
DataBrokerPlotter::DataBrokerPlotter(DataBrokerPlotterLib *_mainLib, mars::data_broker::DataBrokerInterface *_dataBroker, mars::cfg_manager::CFGManagerInterface *cfg, std::string _name, QWidget *parent) : mars::main_gui::BaseWidget(parent, cfg, _name), dataBroker(_dataBroker), mainLib(_mainLib), name(_name), nextPlotId(1) { setStyleSheet("background-color:#eeeeee;"); colors[0] = QColor(255, 0, 0); colors[1] = QColor(0, 255, 0); colors[2] = QColor(0, 0, 255); colors[3] = QColor(255, 155, 0); colors[4] = QColor(0, 255, 255); colors[5] = QColor(255, 0, 255); colors[6] = QColor(127, 0, 255); colors[7] = QColor(255, 0, 127); qcPlot = new QCustomPlot; qcPlot->xAxis2->setVisible(true); qcPlot->xAxis2->setTickLabels(false); qcPlot->yAxis2->setVisible(true); qcPlot->yAxis2->setTickLabels(false); connect(qcPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), qcPlot->xAxis2, SLOT(setRange(QCPRange))); connect(qcPlot->yAxis, SIGNAL(rangeChanged(QCPRange)), qcPlot->yAxis2, SLOT(setRange(QCPRange))); //qcPlot->setInteraction(QCustomPlot::iSelectPlottables); QVBoxLayout *vLayout = new QVBoxLayout(); vLayout->addWidget(qcPlot); setLayout(vLayout); createNewPlot(); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicImportSummaryCasesFeature::onActionTriggered(bool isChecked) { RiaApplication* app = RiaApplication::instance(); QString pathCacheName = "INPUT_FILES"; QStringList fileNames = runRecursiveSummaryCaseFileSearchDialog("Import Summary Cases", pathCacheName); std::vector<RimSummaryCase*> cases; if (!fileNames.isEmpty()) createSummaryCasesFromFiles(fileNames, &cases); addSummaryCases(cases); if (!cases.empty()) { createNewPlot(cases.front()); } addCasesToGroupIfRelevant(cases); for (const auto& rimCase : cases) RiaApplication::instance()->addToRecentFiles(rimCase->summaryHeaderFilename()); RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); if (mainPlotWindow && !cases.empty()) { mainPlotWindow->selectAsCurrentItem(cases.back()); mainPlotWindow->updateSummaryPlotToolBar(); } std::vector<RimCase*> allCases; app->project()->allCases(allCases); if (allCases.size() == 0) { RiuMainWindow::instance()->close(); } }
void DataBrokerPlotter::update() { std::vector<Plot*>::iterator it; Plot *p; double x; int ix; double xmin; double sTime, xRange; // first handle panding dataPackages dataLock.lock(); while(!packageList.empty()) { mars::data_broker::DataPackage &dataPackage = packageList.front().dp; int callbackParam = packageList.front().callbackParam; for(it=plots.begin(); it!=plots.end(); ++it) { if((*it)->dpId == callbackParam/10) { p = *it; if(dataPackage[0].type == mars::data_broker::DOUBLE_TYPE) dataPackage.get(0, &x); else if(dataPackage[0].type == mars::data_broker::INT_TYPE) { dataPackage.get(0, &ix); x = (double)ix; } if(callbackParam % 10) { x = x*p->yScale.dValue+p->yOffset.dValue; p->yValues.push_back(x); p->gotNewData |= 1; } else { p->xValues.push_back(x); if((xRange = fabs(p->xRange.dValue)) < 0.000001) xRange = fabs(plots[0]->xRange.dValue); if(xRange > 0.0000001) { xmin = x-xRange; while(!p->xValues.empty() && p->xValues.front() < xmin) { p->xValues.pop_front(); p->yValues.pop_front(); } } p->gotNewData |= 2; } /* if((sTime = fabs(p->sTime.dValue)) < 0.000001) { sTime = fabs(plots[0]->sTime.dValue); } if(sTime > 0.00000001) { if(x-p->xValues.back() < sTime) { dataLock.unlock(); return; } } */ if(!p->gotData) { p->gotData = true; createNewPlot(); } break; } } packageList.pop_front(); } bool onlyEnlarge = false; for(it=plots.begin(); it!=plots.end(); ++it) { if((*it)->gotNewData == 3) { (*it)->curve->setData((*it)->xValues, (*it)->yValues); (*it)->curve->rescaleAxes(onlyEnlarge); onlyEnlarge = true; (*it)->gotNewData = 0; } } qcPlot->replot(); dataLock.unlock(); }