VectorXf param_sensitivity_widget::readResponseValues( QStringList realizations,QString response) { // Sort the realizations stringlist realizations.sort(); SmartPtr<Named_interface> ni = Root::instance()->interface( metricData_manager + "/metricRegistrar"); MetricDataManager* mRegistrar = dynamic_cast<MetricDataManager*>(ni.raw_ptr()); // Grab the grid name std::string gridName = mdsObject_->getGridName(0); // Obtain pointer to metricToProperties map MetricDataToProperties propFromMetricRegistrar = mRegistrar->get_properties_for_metric(response.toStdString()); // Determine what kind of metricData we are looking at std::string response_type = propFromMetricRegistrar. data_type().toStdString(); // Response values VectorXf responseValue(realizations.size()); if (response_type == "MetricTimeSeriesData") { for (unsigned int i = 0; i < realizations.size(); ++i ) { MetricData* mdata = mRegistrar->getMetricData(gridName, realizations.at(i). toStdString(), response.toStdString()); // Should be a safe cast as this function is only called for data that // has form "TimeSeries" MetricTimeSeriesData *mDataTS = static_cast<MetricTimeSeriesData*>(mdata); // Get number of data points in this response for particular property // We assume that the data/time have same number of points int numDataPoints = mDataTS->data().size(); responseValue[i] = (mDataTS->data().at(numDataPoints -1)); } } return responseValue; }
bool ChartDataFromPropertyMdiSubWindow::initialize(QString metricName, QStringList props ){ SmartPtr<Named_interface> ni = Root::instance()->interface( metricData_manager + "/metricRegistrar"); //return dynamic_cast<MetricDataManager*>(ni.raw_ptr()); MetricDataManager* mRegistrar = dynamic_cast<MetricDataManager*>(ni.raw_ptr()); metricName_ = metricName; this->setWindowTitle("Metric name: "+metricName_); // table_->SetName(metricName.toStdString()); //vtkSmartPointer<vtkStringArray> arrX = vtkSmartPointer<vtkStringArray>::New(); arrX_ = vtkSmartPointer<vtkStringArray>::New(); arrX_->SetName("Metrics"); table_->AddColumn(arrX_); arrY_ = vtkSmartPointer<vtkFloatArray>::New(); arrY_->SetName("Value"); table_->AddColumn(arrY_); table_->SetNumberOfRows(props.size()); std::string metricName_str = metricName_.toStdString(); for( int i=0; i<props.size(); ++i ) { QStringList path = props.at(i).split("/"); MetricData* mdata = mRegistrar->getMetricData(path.at(0).toStdString(), path.at(1).toStdString(), metricName_str); if( mdata==0 ) return false; // QString valStr = arrX_->InsertValue(i,props.value(i).toStdString().c_str()); arrY_->SetValue(i,mdata->data(0)); } // table_->Update(); vtkPlot *bar = chart_->AddPlot(vtkChart::BAR); bar->SetInputData(table_, 0, 1); tableView_->SetSplitMultiComponentColumns(true); tableView_->AddRepresentationFromInput(table_); tableView_->Update(); return true; }