/****************************************************************************** * This method is called when a new editable object has been assigned to the properties owner this * parameter UI belongs to. The parameter UI should react to this change appropriately and * show the properties value for the new edit object in the UI. ******************************************************************************/ void RefTargetListParameterUI::resetUI() { ParameterUI::resetUI(); if(_viewWidget) { _viewWidget->setEnabled(editObject() != nullptr); _targets.clear(); _targetToRow.clear(); _rowToTarget.clear(); if(editObject()) { // Create a local copy of the list of ref targets. const QVector<RefTarget*>& reflist = editObject()->getVectorReferenceField(referenceField()); Q_FOREACH(RefTarget* t, reflist) { _targetToRow.push_back(_rowToTarget.size()); if(t != nullptr) _rowToTarget.push_back(_targets.size()); _targets.push_back(t); } } _model->resetList(); if(editObject() && _targets.size() > 0) setSelectedObject(_targets.targets().front()); }
SchematicViewer::SchematicViewer(QWidget *parent) : QWidget(parent), m_fullSchematic(true), m_maximizedNode(false), m_sceneHandle(0) { m_viewer = new SchematicSceneViewer(this); m_stageScene = new StageSchematicScene(this); m_fxScene = new FxSchematicScene(this); m_commonToolbar = new QToolBar(m_viewer); m_stageToolbar = new QToolBar(m_viewer); m_fxToolbar = new QToolBar(m_viewer); m_swapToolbar = new QToolBar(m_viewer); m_commonToolbar->setObjectName("ToolBarWithoutBorder"); m_stageToolbar->setObjectName("ToolBarWithoutBorder"); m_fxToolbar->setObjectName("ToolBarWithoutBorder"); m_swapToolbar->setObjectName("ToolBarWithoutBorder"); createToolbars(); createActions(); // layout QVBoxLayout *mainLayout = new QVBoxLayout(); mainLayout->setMargin(1); mainLayout->setSpacing(0); { mainLayout->addWidget(m_viewer, 1); QFrame *bottomFrame = new QFrame(this); bottomFrame->setObjectName("SchematicBottomFrame"); QHBoxLayout *horizontalLayout = new QHBoxLayout(); horizontalLayout->setMargin(0); horizontalLayout->setSpacing(0); { horizontalLayout->addWidget(m_commonToolbar); horizontalLayout->addStretch(); horizontalLayout->addWidget(m_fxToolbar); horizontalLayout->addWidget(m_stageToolbar); horizontalLayout->addWidget(m_swapToolbar); } bottomFrame->setLayout(horizontalLayout); mainLayout->addWidget(bottomFrame, 0); } setLayout(mainLayout); connect(m_fxScene, SIGNAL(showPreview(TFxP)), this, SIGNAL(showPreview(TFxP))); connect(m_fxScene, SIGNAL(doCollapse(const QList<TFxP> &)), this, SIGNAL(doCollapse(const QList<TFxP> &))); connect(m_stageScene, SIGNAL(doCollapse(QList<TStageObjectId>)), this, SIGNAL(doCollapse(QList<TStageObjectId>))); connect(m_fxScene, SIGNAL(doExplodeChild(const QList<TFxP> &)), this, SIGNAL(doExplodeChild(const QList<TFxP> &))); connect(m_stageScene, SIGNAL(doExplodeChild(QList<TStageObjectId>)), this, SIGNAL(doExplodeChild(QList<TStageObjectId>))); connect(m_stageScene, SIGNAL(editObject()), this, SIGNAL(editObject())); connect(m_fxScene, SIGNAL(editObject()), this, SIGNAL(editObject())); m_viewer->setScene(m_stageScene); m_fxToolbar->hide(); setFocusProxy(m_viewer); }
void DesignWidget::editObject(const QModelIndex & current, const QModelIndex & /* previous */) { if (current.isValid()) { Object * o = static_cast<Object*>(current.internalPointer()); editObject(o->sharedPtr()); } else { editObject(program()->scene()); } }
/****************************************************************************** * This method updates the displayed value of the parameter UI. ******************************************************************************/ void FontParameterUI::updateUI() { if(editObject() && fontPicker()) { if(isPropertyFieldUI()) { QVariant currentValue = editObject()->getPropertyFieldValue(*propertyField()); OVITO_ASSERT(currentValue.isValid()); if(currentValue.canConvert<QFont>()) fontPicker()->setText(currentValue.value<QFont>().family()); else fontPicker()->setText(QString()); } } }
void SchematicScenePanel::showEvent(QShowEvent *e) { if (m_schematicViewer->isStageSchematicViewed()) setWindowTitle("Stage Schematic"); else setWindowTitle("Fx Schematic"); TApp *app = TApp::instance(); connect(m_schematicViewer, SIGNAL(showPreview(TFxP)), this, SLOT(onShowPreview(TFxP))); connect(m_schematicViewer, SIGNAL(doCollapse(const QList<TFxP> &)), this, SLOT(onCollapse(const QList<TFxP> &))); connect(m_schematicViewer, SIGNAL(doCollapse(QList<TStageObjectId>)), this, SLOT(onCollapse(QList<TStageObjectId>))); connect(m_schematicViewer, SIGNAL(doExplodeChild(const QList<TFxP> &)), this, SLOT(onExplodeChild(const QList<TFxP> &))); connect(m_schematicViewer, SIGNAL(doExplodeChild(QList<TStageObjectId>)), this, SLOT(onExplodeChild(QList<TStageObjectId>))); connect(m_schematicViewer, SIGNAL(editObject()), this, SLOT(onEditObject())); connect(app->getCurrentLevel(), SIGNAL(xshLevelChanged()), m_schematicViewer, SLOT(updateScenes())); connect(app->getCurrentObject(), SIGNAL(objectSwitched()), m_schematicViewer, SLOT(updateScenes())); connect(app->getCurrentXsheet(), SIGNAL(xsheetSwitched()), m_schematicViewer, SLOT(updateSchematic())); connect(app->getCurrentXsheet(), SIGNAL(xsheetChanged()), m_schematicViewer, SLOT(updateSchematic())); connect(app->getCurrentScene(), SIGNAL(sceneSwitched()), m_schematicViewer, SLOT(onSceneSwitched())); m_schematicViewer->updateSchematic(); }
/****************************************************************************** * Aligns the slicing plane to the viewing direction. ******************************************************************************/ void SliceModifierEditor::onAlignPlaneToView() { TimeInterval interval; Viewport* vp = dataset()->viewportConfig()->activeViewport(); if(!vp) return; // Get the object to world transformation for the currently selected object. ObjectNode* node = dynamic_object_cast<ObjectNode>(dataset()->selection()->front()); if(!node) return; const AffineTransformation& nodeTM = node->getWorldTransform(dataset()->animationSettings()->time(), interval); // Get the base point of the current slicing plane in local coordinates. SliceModifier* mod = static_object_cast<SliceModifier>(editObject()); if(!mod) return; Plane3 oldPlaneLocal = mod->slicingPlane(dataset()->animationSettings()->time(), interval); Point3 basePoint = Point3::Origin() + oldPlaneLocal.normal * oldPlaneLocal.dist; // Get the orientation of the projection plane of the current viewport. Vector3 dirWorld = -vp->cameraDirection(); Plane3 newPlaneLocal(basePoint, nodeTM.inverse() * dirWorld); if(std::abs(newPlaneLocal.normal.x()) < FLOATTYPE_EPSILON) newPlaneLocal.normal.x() = 0; if(std::abs(newPlaneLocal.normal.y()) < FLOATTYPE_EPSILON) newPlaneLocal.normal.y() = 0; if(std::abs(newPlaneLocal.normal.z()) < FLOATTYPE_EPSILON) newPlaneLocal.normal.z() = 0; undoableTransaction(tr("Align plane to view"), [mod, &newPlaneLocal]() { mod->setNormal(newPlaneLocal.normal.normalized()); mod->setDistance(newPlaneLocal.dist); }); }
void SchematicScenePanel::hideEvent(QHideEvent *e) { TApp *app = TApp::instance(); disconnect(m_schematicViewer, SIGNAL(showPreview(TFxP)), this, SLOT(onShowPreview(TFxP))); disconnect(m_schematicViewer, SIGNAL(doCollapse(const QList<TFxP> &)), this, SLOT(onCollapse(const QList<TFxP> &))); disconnect(m_schematicViewer, SIGNAL(doCollapse(QList<TStageObjectId>)), this, SLOT(onCollapse(QList<TStageObjectId>))); disconnect(m_schematicViewer, SIGNAL(doExplodeChild(const QList<TFxP> &)), this, SLOT(onExplodeChild(const QList<TFxP> &))); disconnect(m_schematicViewer, SIGNAL(doExplodeChild(QList<TStageObjectId>)), this, SLOT(onExplodeChild(QList<TStageObjectId>))); disconnect(m_schematicViewer, SIGNAL(editObject()), this, SLOT(onEditObject())); disconnect(app->getCurrentLevel(), SIGNAL(xshLevelChanged()), m_schematicViewer, SLOT(updateScenes())); disconnect(app->getCurrentObject(), SIGNAL(objectSwitched()), m_schematicViewer, SLOT(updateScenes())); disconnect(app->getCurrentXsheet(), SIGNAL(xsheetSwitched()), m_schematicViewer, SLOT(updateSchematic())); disconnect(app->getCurrentXsheet(), SIGNAL(xsheetChanged()), m_schematicViewer, SLOT(updateSchematic())); disconnect(app->getCurrentScene(), SIGNAL(sceneSwitched()), m_schematicViewer, SLOT(onSceneSwitched())); }
/****************************************************************************** * Is called when the user presses the "Open Inspector" button. ******************************************************************************/ void DislocationNetworkEditor::onOpenInspector() { DislocationNetwork* dislocationsObj = static_object_cast<DislocationNetwork>(editObject()); if(!dislocationsObj) return; QMainWindow* inspectorWindow = new QMainWindow(container()->window(), (Qt::WindowFlags)(Qt::Tool | Qt::CustomizeWindowHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint)); inspectorWindow->setWindowTitle(tr("Dislocation Inspector")); PropertiesPanel* propertiesPanel = new PropertiesPanel(inspectorWindow); propertiesPanel->hide(); QWidget* mainPanel = new QWidget(inspectorWindow); QVBoxLayout* mainPanelLayout = new QVBoxLayout(mainPanel); mainPanelLayout->setStretch(0,1); mainPanelLayout->setContentsMargins(0,0,0,0); inspectorWindow->setCentralWidget(mainPanel); ObjectNode* node = dynamic_object_cast<ObjectNode>(dataset()->selection()->front()); DislocationInspector* inspector = new DislocationInspector(node); connect(inspector, &QObject::destroyed, inspectorWindow, &QMainWindow::close); inspector->setParent(propertiesPanel); inspector->initialize(propertiesPanel, mainWindow(), RolloutInsertionParameters().insertInto(mainPanel)); inspector->setEditObject(dislocationsObj); inspectorWindow->setAttribute(Qt::WA_DeleteOnClose); inspectorWindow->resize(1000, 350); inspectorWindow->show(); }
/****************************************************************************** * This is called when the user has clicked the "Save Data" button. ******************************************************************************/ void ScatterPlotModifierEditor::onSaveData() { ScatterPlotModifier* modifier = static_object_cast<ScatterPlotModifier>(editObject()); if(!modifier) return; if(modifier->numberOfParticleTypeIds() == 0) return; QString fileName = QFileDialog::getSaveFileName(mainWindow(), tr("Save Scatter Plot"), QString(), tr("Text files (*.txt);;All files (*)")); if(fileName.isEmpty()) return; try { QFile file(fileName); if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) throw Exception(tr("Could not open file for writing: %1").arg(file.errorString())); QTextStream stream(&file); stream << "# " << modifier->xAxisProperty().name() << " " << modifier->yAxisProperty().name() << endl; for(int typeId = 0; typeId < modifier->numberOfParticleTypeIds(); typeId++) { stream << "# Data for particle type id " << typeId << " follow." << endl; for(int i = 0; i < modifier->xData(typeId).size(); i++) { stream << modifier->xData(typeId)[i] << " " << modifier->yData(typeId)[i] << endl; } } } catch(const Exception& ex) { ex.showError(); } }
/****************************************************************************** * Is called when the user has selected a certain frame in the frame list box. ******************************************************************************/ void FileSourceEditor::onFrameSelected(int index) { FileSource* obj = static_object_cast<FileSource>(editObject()); if(!obj) return; dataset()->animationSettings()->setTime(obj->inputFrameToAnimationTime(index)); }
/****************************************************************************** * This method is called when a reference target changes. ******************************************************************************/ bool FileSourceEditor::referenceEvent(RefTarget* source, ReferenceEvent* event) { if(source == editObject()) { if(event->type() == ReferenceEvent::ObjectStatusChanged || event->type() == ReferenceEvent::TitleChanged) { updateInformationLabel(); } #if 0 else if(event->type() == ReferenceEvent::ReferenceAdded || event->type() == ReferenceEvent::ReferenceRemoved) { ReferenceFieldEvent* refEvent = static_cast<ReferenceFieldEvent*>(event); if(refEvent->field() == PROPERTY_FIELD(FileSource::_dataObjects)) { DataObject* dataObj = dynamic_object_cast<DataObject>(event->type() == ReferenceEvent::ReferenceAdded ? refEvent->newTarget() : refEvent->oldTarget()); if(dataObj) { if(event->type() == ReferenceEvent::ReferenceAdded) { // Open a new sub-editor. OORef<PropertiesEditor> subEditor = dataObj->createPropertiesEditor(); if(subEditor) { subEditor->initialize(container(), mainWindow(), _subEditorRolloutParams); subEditor->setEditObject(dataObj); _subEditors.push_back(subEditor); } } else { // Close sub-editor. for(int i = (int)_subEditors.size() - 1; i >= 0; i--) { if(_subEditors[i]->editObject() == dataObj) _subEditors.erase(_subEditors.begin() + i); } } } } } #endif } return PropertiesEditor::referenceEvent(source, event); }
/****************************************************************************** * This method is called when a reference target changes. ******************************************************************************/ bool ScatterPlotModifierEditor::referenceEvent(RefTarget* source, ReferenceEvent* event) { if(event->sender() == editObject() && event->type() == ReferenceEvent::ObjectStatusChanged) { plotScatterPlot(); } return ParticleModifierEditor::referenceEvent(source, event); }
/****************************************************************************** * Sets the enabled state of the UI. ******************************************************************************/ void SubObjectParameterUI::setEnabled(bool enabled) { if(enabled != isEnabled()) { PropertyParameterUI::setEnabled(enabled); if(editObject()) resetUI(); } }
/****************************************************************************** * Is called when the user presses the Reload frame button. ******************************************************************************/ void FileSourceEditor::onReloadFrame() { FileSource* obj = static_object_cast<FileSource>(editObject()); if(obj) { obj->refreshFromSource(obj->loadedFrameIndex()); obj->notifyDependents(ReferenceEvent::TargetChanged); } }
/* ============================================================================= =============================================================================== */ void C3DModel::unloadMaterials(bool bClearMaterial) { for (int i = 0; i < getMaterialCnt(); i++) { if (getMaterial(i).getShared()) continue; deleteTexture(getMaterial(i).getTextureId()); editMaterial(i).setTextureId(-1); } for (int i = 0; i < getObjectCnt(); i++) { editObject(i).unloadGLArrays(); if (bClearMaterial) editObject(i).setMaterial(NULL); editObject(i).setDirty(true); } }
/****************************************************************************** * Is called when the user has pressed the font picker button. ******************************************************************************/ void FontParameterUI::onButtonClicked() { if(fontPicker() && editObject() && isPropertyFieldUI()) { QVariant currentValue = editObject()->getPropertyFieldValue(*propertyField()); OVITO_ASSERT(currentValue.isValid()); QFont currentFont; if(currentValue.canConvert<QFont>()) currentFont = currentValue.value<QFont>(); bool ok; QFont font = QFontDialog::getFont(&ok, currentFont, fontPicker()->window()); if(ok && font != currentFont) { undoableTransaction(tr("Change font"), [this, &font]() { editObject()->setPropertyFieldValue(*propertyField(), qVariantFromValue(font)); Q_EMIT valueEntered(); }); } } }
/****************************************************************************** * Enable/disable the editor for number of y-bins and the first derivative * button ******************************************************************************/ void BinAndReduceModifierEditor::updateWidgets() { BinAndReduceModifier* modifier = static_object_cast<BinAndReduceModifier>(editObject()); if(!modifier) return; _numBinsYPUI->setEnabled(!modifier->is1D()); _firstDerivativePUI->setEnabled(modifier->is1D()); }
/****************************************************************************** * Sets the enabled state of the UI. ******************************************************************************/ void FontParameterUI::setEnabled(bool enabled) { if(enabled == isEnabled()) return; PropertyParameterUI::setEnabled(enabled); if(fontPicker()) { if(isReferenceFieldUI()) fontPicker()->setEnabled(parameterObject() != NULL && isEnabled()); else fontPicker()->setEnabled(editObject() != NULL && isEnabled()); } }
/****************************************************************************** * Keep y-axis range updated ******************************************************************************/ void ScatterPlotModifierEditor::updateYAxisRange(const QCPRange &newRange) { if (_rangeUpdate) { ScatterPlotModifier* modifier = static_object_cast<ScatterPlotModifier>(editObject()); if(!modifier) return; // Fix range if user modifies the range by a mouse action in QCustomPlot modifier->setFixYAxisRange(true); modifier->setYAxisRange(newRange.lower, newRange.upper); } }
/****************************************************************************** * Is called when the user presses the Reload animation button. ******************************************************************************/ void FileSourceEditor::onReloadAnimation() { FileSource* obj = static_object_cast<FileSource>(editObject()); OVITO_CHECK_OBJECT_POINTER(obj); try { obj->updateFrames(); } catch(const Exception& ex) { ex.showError(); } // Adjust the animation length number to match the number of frames in the input data source. obj->adjustAnimationInterval(); }
/****************************************************************************** * Keep y-axis range updated ******************************************************************************/ void BinAndReduceModifierEditor::updatePropertyAxisRange(const QCPRange &newRange) { if (_rangeUpdate) { BinAndReduceModifier* modifier = static_object_cast<BinAndReduceModifier>(editObject()); if(!modifier) return; if (!modifier->is1D()) return; // Fix range if user modifies the range by a mouse action in QCustomPlot modifier->setFixPropertyAxisRange(true); modifier->setPropertyAxisRange(newRange.lower, newRange.upper); } }
/****************************************************************************** * This method is called when a new editable object has been assigned to the properties owner this * parameter UI belongs to. ******************************************************************************/ void FontParameterUI::resetUI() { PropertyParameterUI::resetUI(); if(fontPicker()) { if(editObject() && (!isReferenceFieldUI() || parameterObject())) { fontPicker()->setEnabled(isEnabled()); } else { fontPicker()->setEnabled(false); fontPicker()->setText(QString()); } } }
/****************************************************************************** * Aligns the normal of the slicing plane with the X, Y, or Z axis. ******************************************************************************/ void SliceModifierEditor::onXYZNormal(const QString& link) { SliceModifier* mod = static_object_cast<SliceModifier>(editObject()); if(!mod) return; undoableTransaction(tr("Set plane normal"), [mod, &link]() { if(link == "0") mod->setNormal(Vector3(1,0,0)); else if(link == "1") mod->setNormal(Vector3(0,1,0)); else if(link == "2") mod->setNormal(Vector3(0,0,1)); }); }
ObjectTree::ObjectTree(QWidget *parent) : QVBox(parent) { copying = false; cutting = false; referencing = false; list = new ObjectListView(this); list->addColumn("Objects"); list->addColumn("Value"); list->addColumn("Def"); list->setRootIsDecorated(true); list->setItemMargin(3); list->setTreeStepSize(15); list->setAcceptDrops(true); menu = new QMenu(list); menu->addAction(QIcon(QPixmap("icons/add.png")), "Add", this, SLOT(addAttribute())); menu->addAction(QIcon(QPixmap("icons/remove.png")), "Delete", this, SLOT(deleteObject())); menu->addAction(QIcon(QPixmap("icons/object.png")), "View", this, SLOT(viewObject())); menu->addAction(QIcon(QPixmap("icons/filesaveobj.png")), "Save...", this, SLOT(saveObject())); menu->addSeparator(); menu->addAction(QIcon(QPixmap("icons/editcut.png")), "Cut", this, SLOT(objcut())); menu->addAction(QIcon(QPixmap("icons/editcopy.png")), "Copy", this, SLOT(objcopy())); menu->addAction(QIcon(QPixmap("icons/definition.png")), "Reference", this, SLOT(objref())); menu->addSeparator(); menu->addAction(QIcon(QPixmap("icons/trace.png")), "Trace", this, SLOT(traceObject())); menu->addAction(QIcon(QPixmap("icons/monitor.png")), "Monitor"); menu->addAction(QIcon(QPixmap("icons/edit.png")), "Edit", this, SLOT(editObject())); icon_array = new QPixmap[NUM_OBJTYPES]; for (int i=0; i<NUM_OBJTYPES; i++) { icon_array[i] = QPixmap(icon_files[i]); } icon_def = new QPixmap(icon_deffile); new ObjectItem(list, Null, Null, core::root, "root", false); //new ObjectItem(list, Null, Null, doste::Current, "current", false); //aname = new AttribNameDialog(); connect(list, SIGNAL(expanded(QTreeWidgetItem*)), this, SLOT(expanded(QTreeWidgetItem*))); connect(list, SIGNAL(collapsed(QTreeWidgetItem*)), this, SLOT(collapsed(QTreeWidgetItem*))); connect(list, SIGNAL(itemRenamed(QTreeWidgetItem *, int, const QString&)), this, SLOT(itemRenamed(QTreeWidgetItem*, int, const QString&))); connect(list, SIGNAL(rightButtonClicked(QTreeWidgetItem *, const QPoint&, int)), this, SLOT(rightButtonClicked(QTreeWidgetItem*, const QPoint&, int))); connect(list, SIGNAL(onItem(QTreeWidgetItem*)), this, SLOT(onItem(QTreeWidgetItem*))); connect(list, SIGNAL(clicked(QTreeWidgetItem*)), this, SLOT(itemClicked(QTreeWidgetItem*))); }
FunctionViewerPanel::FunctionViewerPanel(QWidget *parent) : TPanel(parent), m_functionViewer(new FunctionViewer(this)) { setWidget(m_functionViewer); attachHandles(); bool ret = connect(m_functionViewer, SIGNAL(curveIo(int, TDoubleParam *, const std::string &)), this, SLOT(onIoCurve(int, TDoubleParam *, const std::string &))); ret &&connect(m_functionViewer, SIGNAL(editObject()), this, SLOT(onEditObject())); assert(ret); }
/****************************************************************************** * This is called when the user has clicked the "Save Data" button. ******************************************************************************/ void BinAndReduceModifierEditor::onSaveData() { BinAndReduceModifier* modifier = static_object_cast<BinAndReduceModifier>(editObject()); if(!modifier) return; if(modifier->binData().empty()) return; QString fileName = QFileDialog::getSaveFileName(mainWindow(), tr("Save Data"), QString(), tr("Text files (*.txt);;All files (*)")); if(fileName.isEmpty()) return; try { QFile file(fileName); if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) throw Exception(tr("Could not open file for writing: %1").arg(file.errorString())); int binDataSizeX = std::max(1, modifier->numberOfBinsX()); int binDataSizeY = std::max(1, modifier->numberOfBinsY()); if (modifier->is1D()) binDataSizeY = 1; FloatType binSizeX = (modifier->xAxisRangeEnd() - modifier->xAxisRangeStart()) / binDataSizeX; FloatType binSizeY = (modifier->yAxisRangeEnd() - modifier->yAxisRangeStart()) / binDataSizeY; QTextStream stream(&file); if (binDataSizeY == 1) { stream << "# " << modifier->sourceProperty().name() << " bin size: " << binSizeX << endl; for(size_t i = 0; i < modifier->binData().size(); i++) { stream << (binSizeX * (FloatType(i) + 0.5f) + modifier->xAxisRangeStart()) << " " << modifier->binData()[i] << endl; } } else { stream << "# " << modifier->sourceProperty().name() << " bin size X: " << binDataSizeX << ", bin size Y: " << binDataSizeY << endl; for(int i = 0; i < binDataSizeY; i++) { for(int j = 0; j < binDataSizeX; j++) { stream << modifier->binData()[i*binDataSizeX+j] << " "; } stream << endl; } } } catch(const Exception& ex) { ex.showError(); } }
/****************************************************************************** * Moves the plane to the center of the simulation box. ******************************************************************************/ void SliceModifierEditor::onCenterOfBox() { SliceModifier* mod = static_object_cast<SliceModifier>(editObject()); if(!mod) return; // Get the simulation cell from the input object to center the slicing plane in // the center of the simulation cell. PipelineFlowState input = mod->getModifierInput(); SimulationCellObject* cell = input.findObject<SimulationCellObject>(); if(!cell) return; Point3 centerPoint = cell->cellMatrix() * Point3(0.5, 0.5, 0.5); FloatType centerDistance = mod->normal().dot(centerPoint - Point3::Origin()); undoableTransaction(tr("Set plane position"), [mod, centerDistance]() { mod->setDistance(centerDistance); }); }
void RKWorkplace::restoreWorkplaceItem (const QString &desc) { RK_TRACE (APP); QString type = desc.section (QChar (':'), 0, 0); QString specification = desc.section (QChar (':'), 1); if (type == "data") { RObject *object = RObjectList::getObjectList ()->findObject (specification); if (object) editObject (object, false); } else if (type == "script") { openScriptEditor (specification); } else if (type == "output") { openOutputWindow (specification); } else if (type == "help") { openHelpWindow (specification, true); } else { RK_ASSERT (false); } }
/****************************************************************************** * Updates the contents of the pair-wise cutoff table. ******************************************************************************/ void CreateBondsModifierEditor::updatePairCutoffList() { CreateBondsModifier* mod = static_object_cast<CreateBondsModifier>(editObject()); if(!mod) return; // Obtain the list of particle types in the modifier's input. PairCutoffTableModel::ContentType pairCutoffs; PipelineFlowState inputState = mod->getModifierInput(); ParticleTypeProperty* typeProperty = dynamic_object_cast<ParticleTypeProperty>( ParticlePropertyObject::findInState(inputState, ParticleProperty::ParticleTypeProperty)); if(typeProperty) { for(auto ptype1 = typeProperty->particleTypes().constBegin(); ptype1 != typeProperty->particleTypes().constEnd(); ++ptype1) { for(auto ptype2 = ptype1; ptype2 != typeProperty->particleTypes().constEnd(); ++ptype2) { pairCutoffs.push_back(qMakePair((*ptype1)->name(), (*ptype2)->name())); } } } _pairCutoffTableModel->setContent(mod, pairCutoffs); }
void DesignWidget::setProgram(std::tr1::shared_ptr<Program> program) { program_ = program; // Remove previous widget scrollArea_->takeWidget(); currentDialog_.reset(); // Set new scene / model SceneModel * sm = new SceneModel(program->scene()); treeView_->setModel(sm); sceneModel_ = std::tr1::shared_ptr<SceneModel>(sm); treeView_->setColumnWidth(0, 192); treeView_->setColumnWidth(1, 48); treeView_->setColumnWidth(2, 48); // treeView_->resizeColumnToContents(0); // treeView_->resizeColumnToContents(1); QItemSelectionModel * selection = treeView_->selectionModel(); connect(selection, SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(editObject(const QModelIndex &, const QModelIndex &))); editObject(program->scene()); }