void AnalysisDialog::createNetworkAnalysis() { QVBoxLayout* netAnalysisLayout = new QVBoxLayout(); QGridLayout* netTopLayout = new QGridLayout(); QGridLayout* netBottomLayout = new QGridLayout(); nodeCountEdit = new QLineEdit(this); edgeCountEdit = new QLineEdit(this); meanDegreeEdit = new QLineEdit(this); componentCountEdit = new QLineEdit(this); maxComponentSizeEdit = new QLineEdit(this); transitivityEdit = new QLineEdit(this); diameterEdit = new QLineEdit(this); meanDistanceEdit = new QLineEdit(this); makeReadonly(nodeCountEdit); makeReadonly(edgeCountEdit); makeReadonly(meanDegreeEdit); makeReadonly(componentCountEdit); makeReadonly(maxComponentSizeEdit); makeReadonly(transitivityEdit); makeReadonly(diameterEdit); makeReadonly(meanDistanceEdit); componentButton1 = new QPushButton("Calculate", this); componentButton2 = new QPushButton("Calculate", this); transitivityButton = new QPushButton("Calculate", this); diameterButton = new QPushButton("Calculate", this); meanDistanceButton = new QPushButton("Calculate", this); connect(componentButton1, SIGNAL(clicked()), this, SLOT(generate_comp_thread())); connect(componentButton2, SIGNAL(clicked()), this, SLOT(generate_comp_thread())); connect(transitivityButton, SIGNAL(clicked()), this, SLOT(generate_trans_thread())); connect(diameterButton, SIGNAL(clicked()), this, SLOT(generate_dist_thread())); connect(meanDistanceButton, SIGNAL(clicked()), this, SLOT(generate_dist_thread())); _addNetAnalysisRow(netTopLayout, "Node count:", nodeCountEdit); _addNetAnalysisRow(netTopLayout, "Edge count:", edgeCountEdit); _addNetAnalysisRow(netTopLayout, "Mean degree:", meanDegreeEdit); _addNetAnalysisRow(netTopLayout, "Largest component:", maxComponentSizeEdit, componentButton1); _addNetAnalysisRow(netTopLayout, "Component count:", componentCountEdit, componentButton2 ); _addNetAnalysisRow(netTopLayout, "Transitivity:", transitivityEdit, transitivityButton); _addNetAnalysisRow(netTopLayout, "Diameter:", diameterEdit, diameterButton); _addNetAnalysisRow(netTopLayout, "Mean shortest path:", meanDistanceEdit, meanDistanceButton); QGroupBox* netAnalysisTop = new QGroupBox(); netAnalysisTop->setLayout(netTopLayout); QLabel* nbins = new QLabel("Number of bins", this); QLabel* minRange = new QLabel("Range minimum", this); QLabel* maxRange = new QLabel("Range maximum", this); netBottomLayout->addWidget(nbins, 1, 0); netBottomLayout->addWidget(minRange, 1, 1); netBottomLayout->addWidget(maxRange, 1, 2); QLineEdit* nbinsLineEdit = new QLineEdit(this); QLineEdit* minRangeLineEdit = new QLineEdit(this); QLineEdit* maxRangeLineEdit = new QLineEdit(this); netBottomLayout->addWidget(nbinsLineEdit, 2, 0); netBottomLayout->addWidget(minRangeLineEdit, 2, 1); netBottomLayout->addWidget(maxRangeLineEdit, 2, 2); QGroupBox* netAnalysisBottom = new QGroupBox(); netAnalysisBottom->setLayout(netBottomLayout); degDistPlot = new PlotView(this, "Degree distribution", "Degree", "Frequency"); degDistPlot->setPlotType(PlotView::DEGPLOT); connect(nbinsLineEdit, SIGNAL(textChanged(QString)), degDistPlot, SLOT(setNBins(QString))); connect(minRangeLineEdit, SIGNAL(textChanged(QString)), degDistPlot, SLOT(setRangeMin(QString))); connect(maxRangeLineEdit, SIGNAL(textChanged(QString)), degDistPlot, SLOT(setRangeMax(QString))); // add a close window button QPushButton* closeButton = new QPushButton("Close analysis", this); connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); QHBoxLayout* buttonBoxLayout = new QHBoxLayout(); QWidget* buttonBox = new QWidget(); buttonBoxLayout->addStretch(1); buttonBoxLayout->addWidget(closeButton); buttonBox->setLayout(buttonBoxLayout); netAnalysisLayout->addWidget(netAnalysisTop); netAnalysisLayout->addWidget(degDistPlot); netAnalysisLayout->addWidget((netAnalysisBottom)); netAnalysisLayout->addWidget(buttonBox); this->setLayout(netAnalysisLayout); }
//-------------------------------------------------------------- bool ofxMuiNumberData::setNormalizedRangeMax(float _max, int index) { return setRangeMax(bounds[index].denormalize(_max),index); }
void AnalysisDialog::createResultsAnalysis() { QVBoxLayout* resultsAnalysisLayout = new QVBoxLayout(); QGridLayout* resultsTopLayout = new QGridLayout(); QGridLayout* resultsBottomLayout = new QGridLayout(); thresholdEdit = new QLineEdit(this); thresholdEdit ->setText(QString::number( 0 )); thresholdEdit->setValidator( new QDoubleValidator(thresholdEdit) ); connect(thresholdEdit, SIGNAL(textChanged(QString)), this, SLOT(updateResultsAnalysis())); QPushButton* defaultThresholdButton = new QPushButton("Default"); connect(defaultThresholdButton, SIGNAL(clicked()), this, SLOT(reset_epi_threshold())); allNEdit = new QLineEdit(this); allMinEdit = new QLineEdit(this); allMaxEdit = new QLineEdit(this); allMeanEdit = new QLineEdit(this); allSDEdit = new QLineEdit(this); outNEdit = new QLineEdit(this); outMinEdit = new QLineEdit(this); outMaxEdit = new QLineEdit(this); outMeanEdit = new QLineEdit(this); outSDEdit = new QLineEdit(this); epiNEdit = new QLineEdit(this); epiMinEdit = new QLineEdit(this); epiMaxEdit = new QLineEdit(this); epiMeanEdit = new QLineEdit(this); epiSDEdit = new QLineEdit(this); QLabel* thresholdLabel = new QLabel("Outbreak/epidemic threshold:", this); resultsTopLayout->addWidget(thresholdLabel, 1, 0, 1, 2); resultsTopLayout->addWidget(thresholdEdit, 1, 2); resultsTopLayout->addWidget(defaultThresholdButton, 1, 3); QLabel* allLabel = new QLabel("All simulations", this); QLabel* outLabel = new QLabel("Outbreaks only", this); QLabel* epiLabel = new QLabel("Epidemics only", this); resultsTopLayout->addWidget(allLabel, 2, 1); resultsTopLayout->addWidget(outLabel, 2, 2); resultsTopLayout->addWidget(epiLabel, 2, 3); _addResultsAnalysisRow(resultsTopLayout, "N", allNEdit, outNEdit, epiNEdit); _addResultsAnalysisRow(resultsTopLayout, "Min" , allMinEdit, outMinEdit, epiMinEdit); _addResultsAnalysisRow(resultsTopLayout, "Max" , allMaxEdit, outMaxEdit, epiMaxEdit); _addResultsAnalysisRow(resultsTopLayout, "Mean" , allMeanEdit, outMeanEdit, epiMeanEdit); _addResultsAnalysisRow(resultsTopLayout, "SD" , allSDEdit, outSDEdit, epiSDEdit); QGroupBox* resultsAnalysisTop = new QGroupBox(); resultsAnalysisTop->setLayout(resultsTopLayout); QLabel* nbins = new QLabel("Number of bins", this); QLabel* minRange = new QLabel("Range minimum", this); QLabel* maxRange = new QLabel("Range maximum", this); resultsBottomLayout->addWidget(nbins, 1, 0); resultsBottomLayout->addWidget(minRange, 1, 1); resultsBottomLayout->addWidget(maxRange, 1, 2); QLineEdit* nbinsLineEdit = new QLineEdit(this); QLineEdit* minRangeLineEdit = new QLineEdit(this); QLineEdit* maxRangeLineEdit = new QLineEdit(this); resultsBottomLayout->addWidget(nbinsLineEdit, 2, 0); resultsBottomLayout->addWidget(minRangeLineEdit, 2, 1); resultsBottomLayout->addWidget(maxRangeLineEdit, 2, 2); QGroupBox* resultsAnalysisBottom = new QGroupBox(); resultsAnalysisBottom->setLayout(resultsBottomLayout); resultsHistPlot = new PlotView(this, "Epidemic size distribution", "Epidemic size", "Frequency"); resultsHistPlot->setPlotType(PlotView::RESULTS_HISTPLOT); connect(thresholdEdit, SIGNAL(textChanged(QString)), resultsHistPlot, SLOT(setCutoff(QString))); connect(thresholdEdit, SIGNAL(textEdited(QString)), this, SLOT(setThresholdEdited())); connect(nbinsLineEdit, SIGNAL(textChanged(QString)), resultsHistPlot, SLOT(setNBins(QString))); connect(minRangeLineEdit, SIGNAL(textChanged(QString)), resultsHistPlot, SLOT(setRangeMin(QString))); connect(maxRangeLineEdit, SIGNAL(textChanged(QString)), resultsHistPlot, SLOT(setRangeMax(QString))); // add a close window button QPushButton* closeButton = new QPushButton("Close analysis", this); connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); QHBoxLayout* buttonBoxLayout = new QHBoxLayout(); QWidget* buttonBox = new QWidget(); buttonBoxLayout->addStretch(1); buttonBoxLayout->addWidget(closeButton); buttonBox->setLayout(buttonBoxLayout); resultsAnalysisLayout->addWidget(resultsAnalysisTop); resultsAnalysisLayout->addWidget(resultsHistPlot); resultsAnalysisLayout->addWidget(resultsAnalysisBottom); resultsAnalysisLayout->addWidget(buttonBox); this->setLayout(resultsAnalysisLayout); }
extern shapeop_err shapeop_editConstraint(ShapeOpSolver *op, const char *constraintType, int constraint_id, const ShapeOpScalar *scalars, int nb_scl) { if (strcmp(constraintType, "EdgeStrain") == 0) { auto c = std::dynamic_pointer_cast<ShapeOp::EdgeStrainConstraint>(op->s->getConstraint(constraint_id)); if (!c) { return SO_UNMATCHING_CONSTRAINT_ID; } if (nb_scl != 3) { return SO_INVALID_ARGUMENT_LENGTH; } c->setEdgeLength(scalars[0]); c->setRangeMin(scalars[1]); c->setRangeMax(scalars[2]); return SO_SUCCESS; } if (strcmp(constraintType, "TriangleStrain") == 0) { auto c = std::dynamic_pointer_cast<ShapeOp::TriangleStrainConstraint>(op->s->getConstraint(constraint_id)); if (!c) { return SO_UNMATCHING_CONSTRAINT_ID; } if (nb_scl != 2) { return SO_INVALID_ARGUMENT_LENGTH; } c->setRangeMin(scalars[0]); c->setRangeMax(scalars[1]); return SO_SUCCESS; } if (strcmp(constraintType, "TetrahedronStrain") == 0) { auto c = std::dynamic_pointer_cast<ShapeOp::TetrahedronStrainConstraint>(op->s->getConstraint(constraint_id)); if (!c) { return SO_UNMATCHING_CONSTRAINT_ID; } if (nb_scl != 2) { return SO_INVALID_ARGUMENT_LENGTH; } c->setRangeMin(scalars[0]); c->setRangeMax(scalars[1]); return SO_SUCCESS; } if (strcmp(constraintType, "Area") == 0) { auto c = std::dynamic_pointer_cast<ShapeOp::AreaConstraint>(op->s->getConstraint(constraint_id)); if (!c) { return SO_UNMATCHING_CONSTRAINT_ID; } if (nb_scl != 2) { return SO_INVALID_ARGUMENT_LENGTH; } c->setRangeMin(scalars[0]); c->setRangeMax(scalars[1]); return SO_SUCCESS; } if (strcmp(constraintType, "Volume") == 0) { auto c = std::dynamic_pointer_cast<ShapeOp::VolumeConstraint>(op->s->getConstraint(constraint_id)); if (!c) { return SO_UNMATCHING_CONSTRAINT_ID; } if (nb_scl != 2) { return SO_INVALID_ARGUMENT_LENGTH; } c->setRangeMin(scalars[0]); c->setRangeMax(scalars[1]); return SO_SUCCESS; } if (strcmp(constraintType, "Bending") == 0) { auto c = std::dynamic_pointer_cast<ShapeOp::BendingConstraint>(op->s->getConstraint(constraint_id)); if (!c) { return SO_UNMATCHING_CONSTRAINT_ID; } if (nb_scl != 2) { return SO_INVALID_ARGUMENT_LENGTH; } c->setRangeMin(scalars[0]); c->setRangeMax(scalars[1]); return SO_SUCCESS; } if (strcmp(constraintType, "Closeness") == 0) { auto c = std::dynamic_pointer_cast<ShapeOp::ClosenessConstraint>(op->s->getConstraint(constraint_id)); if (!c) { return SO_UNMATCHING_CONSTRAINT_ID; } if (nb_scl != 3) { return SO_INVALID_ARGUMENT_LENGTH; } Eigen::Map<const ShapeOp::Vector3> p(scalars, 3, 1); c->setPosition(p); return SO_SUCCESS; } if (strcmp(constraintType, "Similarity") == 0 || strcmp(constraintType, "Rigid") == 0) { auto c = std::dynamic_pointer_cast<ShapeOp::SimilarityConstraint>(op->s->getConstraint(constraint_id)); if (!c) { return SO_UNMATCHING_CONSTRAINT_ID; } int nI = static_cast<int>(c->nIndices()); if ((nb_scl % (nI * 3)) != 0) { return SO_INVALID_ARGUMENT_LENGTH; } std::vector<ShapeOp::Matrix3X> shapes; int nShapes = nb_scl / (nI * 3); for (int i = 0; i < nShapes; ++i) { Eigen::Map<const ShapeOp::Matrix3X> s(scalars + i * nI * 3, 3, nI); shapes.push_back(s); } c->setShapes(shapes); return SO_SUCCESS; } if (strcmp(constraintType, "Angle") == 0) { auto c = std::dynamic_pointer_cast<ShapeOp::AngleConstraint>(op->s->getConstraint(constraint_id)); if (!c) { return SO_UNMATCHING_CONSTRAINT_ID; } if (nb_scl != 2) { return SO_INVALID_ARGUMENT_LENGTH; } c->setMinAngle(scalars[0]); c->setMaxAngle(scalars[1]); return SO_SUCCESS; } return SO_INVALID_CONSTRAINT_TYPE; }