void Gui::ActiveObjectList::setObject(App::DocumentObject* obj, const char* name, const Gui::HighlightMode& mode) { ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/TreeView"); bool autoExpand = hGrp->GetBool("TreeActiveAutoExpand", true); if (hasObject(name)) { App::DocumentObject* act = getObject<App::DocumentObject*>(name); Gui::Document* doc = Application::Instance->getDocument(act->getDocument()); Gui::ViewProviderDocumentObject* viewProvider = static_cast <Gui::ViewProviderDocumentObject*>(doc->getViewProvider(act)); doc->signalHighlightObject(*viewProvider, mode, false); if (autoExpand) doc->signalExpandObject(*viewProvider, Gui::Collapse); } if (obj) { Gui::Document* doc = Application::Instance->getDocument(obj->getDocument()); Gui::ViewProviderDocumentObject* viewProvider = static_cast <Gui::ViewProviderDocumentObject*>(doc->getViewProvider(obj)); doc->signalHighlightObject(*viewProvider, mode, true); if (autoExpand) doc->signalExpandObject(*viewProvider, Gui::Expand); _ObjectMap[name] = obj; } else { if (hasObject(name)) _ObjectMap.erase(name); } }
void TransformStrategy::acceptDataTransform(const Base::Matrix4D& mat, App::DocumentObject* obj) { Gui::Document* doc = Gui::Application::Instance->getDocument(obj->getDocument()); std::map<std::string,App::Property*> props; obj->getPropertyMap(props); // search for the placement property std::map<std::string,App::Property*>::iterator jt; jt = std::find_if(props.begin(), props.end(), find_transform()); if (jt != props.end()) { Base::Placement local = static_cast<App::PropertyPlacement*>(jt->second)->getValue(); Gui::ViewProvider* vp = doc->getViewProvider(obj); if (vp) vp->setTransformation(local.toMatrix()); } else { // No placement found Gui::ViewProvider* vp = doc->getViewProvider(obj); if (vp) vp->setTransformation(Base::Matrix4D()); } // Apply the transformation jt = std::find_if(props.begin(), props.end(), find_geometry_data()); if (jt != props.end()) { static_cast<App::PropertyGeometry*>(jt->second)->transformGeometry(mat); } }
void StdCmdDuplicateSelection::activated(int iMsg) { App::Document* act = App::GetApplication().getActiveDocument(); if (!act) return; // no active document found Gui::Document* doc = Gui::Application::Instance->getDocument(act); std::vector<Gui::SelectionSingleton::SelObj> sel = Gui::Selection().getCompleteSelection(); for (std::vector<SelectionSingleton::SelObj>::iterator it = sel.begin(); it != sel.end(); ++it) { if (!it->pObject) continue; // should actually not happen // create a copy of the object App::DocumentObject* copy = act->copyObject(it->pObject, false); if (!copy) // continue if no copy could be created continue; // mark all properties of the copy as "touched" which are touched in the original object std::map<std::string,App::Property*> props; it->pObject->getPropertyMap(props); std::map<std::string,App::Property*> copy_props; copy->getPropertyMap(copy_props); for (std::map<std::string,App::Property*>::iterator jt = props.begin(); jt != props.end(); ++jt) { if (jt->second->isTouched()) { std::map<std::string,App::Property*>::iterator kt; kt = copy_props.find(jt->first); if (kt != copy_props.end()) { kt->second->touch(); } } } Gui::Document* parent = Gui::Application::Instance->getDocument(it->pObject->getDocument()); if (!parent || !doc) continue; // should not happen // copy the properties of the associated view providers Gui::ViewProvider* view = parent->getViewProvider(it->pObject); Gui::ViewProvider* copy_view = doc->getViewProvider(copy); copy_view->addDynamicProperties(view); if (!view || !copy_view) continue; // should not happen // get the properties of the view provider props.clear(); view->getPropertyMap(props); copy_props.clear(); copy_view->getPropertyMap(copy_props); for (std::map<std::string,App::Property*>::iterator jt = props.begin(); jt != props.end(); ++jt) { std::map<std::string,App::Property*>::iterator kt; kt = copy_props.find(jt->first); if (kt != copy_props.end()) { std::auto_ptr<App::Property> data(jt->second->Copy()); if (data.get()) { kt->second->Paste(*data); } } } } }
void Mirroring::findShapes() { App::Document* activeDoc = App::GetApplication().getActiveDocument(); if (!activeDoc) return; Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc); if (!activeGui) return; this->document = QString::fromLatin1(activeDoc->getName()); std::vector<App::DocumentObject*> objs = activeDoc->getObjectsOfType (Part::Feature::getClassTypeId()); for (std::vector<App::DocumentObject*>::iterator it = objs.begin(); it!=objs.end(); ++it) { const TopoDS_Shape& shape = static_cast<Part::Feature*>(*it)->Shape.getValue(); if (!shape.IsNull()) { QString label = QString::fromUtf8((*it)->Label.getValue()); QString name = QString::fromLatin1((*it)->getNameInDocument()); QTreeWidgetItem* child = new QTreeWidgetItem(); child->setText(0, label); child->setToolTip(0, label); child->setData(0, Qt::UserRole, name); Gui::ViewProvider* vp = activeGui->getViewProvider(*it); if (vp) child->setIcon(0, vp->getIcon()); ui->shapes->addTopLevelItem(child); } } }
void DlgRevolution::findShapes() { App::Document* activeDoc = App::GetApplication().getActiveDocument(); if (!activeDoc) return; Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc); std::vector<App::DocumentObject*> objs = activeDoc->getObjectsOfType (Part::Feature::getClassTypeId()); for (std::vector<App::DocumentObject*>::iterator it = objs.begin(); it!=objs.end(); ++it) { const TopoDS_Shape& shape = static_cast<Part::Feature*>(*it)->Shape.getValue(); if (shape.IsNull()) continue; TopExp_Explorer xp; xp.Init(shape,TopAbs_SOLID); if (xp.More()) continue; // solids not allowed xp.Init(shape,TopAbs_COMPSOLID); if (xp.More()) continue; // compound solids not allowed // So allowed are: vertex, edge, wire, face, shell and compound QTreeWidgetItem* item = new QTreeWidgetItem(ui->treeWidget); item->setText(0, QString::fromUtf8((*it)->Label.getValue())); item->setData(0, Qt::UserRole, QString::fromAscii((*it)->getNameInDocument())); Gui::ViewProvider* vp = activeGui->getViewProvider(*it); if (vp) item->setIcon(0, vp->getIcon()); } }
void Tessellation::findShapes() { App::Document* activeDoc = App::GetApplication().getActiveDocument(); if (!activeDoc) return; Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc); if (!activeGui) return; this->document = QString::fromAscii(activeDoc->getName()); std::vector<Part::Feature*> objs = activeDoc->getObjectsOfType<Part::Feature>(); for (std::vector<Part::Feature*>::iterator it = objs.begin(); it!=objs.end(); ++it) { const TopoDS_Shape& shape = (*it)->Shape.getValue(); if (shape.IsNull()) continue; bool hasfaces = false; TopExp_Explorer xp(shape,TopAbs_FACE); while (xp.More()) { hasfaces = true; break; } if (hasfaces) { QString label = QString::fromUtf8((*it)->Label.getValue()); QString name = QString::fromAscii((*it)->getNameInDocument()); QTreeWidgetItem* child = new QTreeWidgetItem(); child->setText(0, label); child->setToolTip(0, label); child->setData(0, Qt::UserRole, name); Gui::ViewProvider* vp = activeGui->getViewProvider(*it); if (vp) child->setIcon(0, vp->getIcon()); ui->treeWidget->addTopLevelItem(child); } } }
void Placement::applyPlacement(const Base::Placement& p, bool incremental) { Gui::Document* document = Application::Instance->activeDocument(); if (!document) return; std::vector<App::DocumentObject*> sel = Gui::Selection().getObjectsOfType (App::DocumentObject::getClassTypeId(), document->getDocument()->getName()); if (!sel.empty()) { // apply transformation only on view matrix not on placement property for (std::vector<App::DocumentObject*>::iterator it=sel.begin();it!=sel.end();++it) { std::map<std::string,App::Property*> props; (*it)->getPropertyMap(props); // search for the placement property std::map<std::string,App::Property*>::iterator jt; jt = std::find_if(props.begin(), props.end(), find_placement(this->propertyName)); if (jt != props.end()) { Base::Placement cur = static_cast<App::PropertyPlacement*>(jt->second)->getValue(); if (incremental) cur = p * cur; else cur = p; Gui::ViewProvider* vp = document->getViewProvider(*it); if (vp) vp->setTransformation(cur.toMatrix()); } } } else { Base::Console().Warning("No object selected.\n"); } }
SoNode* ViewProviderDocumentObject::findFrontRootOfType(const SoType& type) const { // first get the document this object is part of and get its GUI counterpart App::Document* pAppDoc = pcObject->getDocument(); Gui::Document* pGuiDoc = Gui::Application::Instance->getDocument(pAppDoc); SoSearchAction searchAction; searchAction.setType(type); searchAction.setInterest(SoSearchAction::FIRST); // search in all view providers for the node type std::vector<App::DocumentObject*> obj = pAppDoc->getObjects(); for (std::vector<App::DocumentObject*>::iterator it = obj.begin(); it != obj.end(); ++it) { const ViewProvider* vp = pGuiDoc->getViewProvider(*it); // Ignore 'this' view provider. It could also happen that vp is 0, e.g. when // several objects have been added to the App::Document before notifying the // Gui::Document if (!vp || vp == this) continue; SoSeparator* front = vp->getFrontRoot(); //if (front && front->getTypeId() == type) // return front; if (front) { searchAction.apply(front); SoPath* path = searchAction.getPath(); if (path) return path->getTail(); } } return 0; }
void SweepWidget::findShapes() { App::Document* activeDoc = App::GetApplication().getActiveDocument(); Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc); if (!activeGui) return; d->document = activeDoc->getName(); std::vector<Part::Feature*> objs = activeDoc->getObjectsOfType<Part::Feature>(); for (std::vector<Part::Feature*>::iterator it = objs.begin(); it!=objs.end(); ++it) { const TopoDS_Shape& shape = (*it)->Shape.getValue(); if (shape.IsNull()) continue; if (shape.ShapeType() == TopAbs_FACE || shape.ShapeType() == TopAbs_WIRE || shape.ShapeType() == TopAbs_EDGE || shape.ShapeType() == TopAbs_VERTEX) { QString label = QString::fromUtf8((*it)->Label.getValue()); QString name = QString::fromAscii((*it)->getNameInDocument()); QTreeWidgetItem* child = new QTreeWidgetItem(); child->setText(0, label); child->setToolTip(0, label); child->setData(0, Qt::UserRole, name); Gui::ViewProvider* vp = activeGui->getViewProvider(*it); if (vp) child->setIcon(0, vp->getIcon()); d->ui.selector->availableTreeWidget()->addTopLevelItem(child); } } }
/** * Constructs a VisualInspection as a child of 'parent', with the * name 'name' and widget flags set to 'f'. */ VisualInspection::VisualInspection(QWidget* parent, Qt::WFlags fl) : QDialog(parent, fl), ui(new Ui_VisualInspection) { ui->setupUi(this); connect(ui->treeWidgetActual, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(onActivateItem(QTreeWidgetItem*))); connect(ui->treeWidgetNominal, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(onActivateItem(QTreeWidgetItem*))); connect(ui->buttonBox, SIGNAL(helpRequested()), Gui::getMainWindow(), SLOT(whatsThis())); //FIXME: Not used yet ui->textLabel2->hide(); ui->prefFloatSpinBox2->hide(); ui->prefFloatSpinBox1->setDecimals(Base::UnitsApi::getDecimals()); ui->prefFloatSpinBox2->setDecimals(Base::UnitsApi::getDecimals()); App::Document* doc = App::GetApplication().getActiveDocument(); // disable Ok button and enable of at least one item in each view is on buttonOk = ui->buttonBox->button(QDialogButtonBox::Ok); buttonOk->setDisabled(true); if (!doc) { ui->treeWidgetActual->setDisabled(true); ui->treeWidgetNominal->setDisabled(true); return; } Gui::Document* gui = Gui::Application::Instance->getDocument(doc); std::vector<App::DocumentObject*> obj = doc->getObjects(); Base::Type point = Base::Type::fromName("Points::Feature"); Base::Type mesh = Base::Type::fromName("Mesh::Feature"); Base::Type shape = Base::Type::fromName("Part::Feature"); for (std::vector<App::DocumentObject*>::iterator it = obj.begin(); it != obj.end(); ++it) { if ((*it)->getTypeId().isDerivedFrom(point) || (*it)->getTypeId().isDerivedFrom(mesh) || (*it)->getTypeId().isDerivedFrom(shape)) { Gui::ViewProvider* view = gui->getViewProvider(*it); QIcon px = view->getIcon(); SingleSelectionItem* item1 = new SingleSelectionItem(ui->treeWidgetActual); item1->setText(0, QString::fromUtf8((*it)->Label.getValue())); item1->setData(0, Qt::UserRole, QString::fromAscii((*it)->getNameInDocument())); item1->setCheckState(0, Qt::Unchecked); item1->setIcon(0, px); SingleSelectionItem* item2 = new SingleSelectionItem(ui->treeWidgetNominal); item2->setText(0, QString::fromUtf8((*it)->Label.getValue())); item2->setData(0, Qt::UserRole, QString::fromAscii((*it)->getNameInDocument())); item2->setCheckState(0, Qt::Unchecked); item2->setIcon(0, px); item1->setCompetitiveItem(item2); item2->setCompetitiveItem(item1); } } loadSettings(); }
/* static */ Gui::ViewProvider* QGIView::getViewProvider(App::DocumentObject* obj) { Gui::ViewProvider* result = nullptr; if (obj != nullptr) { Gui::Document* guiDoc = Gui::Application::Instance->getDocument(obj->getDocument()); result = guiDoc->getViewProvider(obj); } return result; }
void AlignmentGroup::addView(App::DocumentObject* pView) { if (pView) { App::Document* rDoc = pView->getDocument(); Gui::Document* pDoc = Gui::Application::Instance->getDocument(rDoc); Gui::ViewProviderDocumentObject* pProvider = static_cast<Gui::ViewProviderDocumentObject*> (pDoc->getViewProvider(pView)); this->_views.push_back(pProvider); } }
void TransformStrategy::applyViewTransform(const Base::Placement& plm, App::DocumentObject* obj) { Gui::Document* doc = Gui::Application::Instance->getDocument(obj->getDocument()); std::map<std::string,App::Property*> props; obj->getPropertyMap(props); // search for the placement property std::map<std::string,App::Property*>::iterator jt; jt = std::find_if(props.begin(), props.end(), find_transform()); if (jt != props.end()) { Base::Placement local = static_cast<App::PropertyPlacement*>(jt->second)->getValue(); local *= plm; // in case a placement is already set Gui::ViewProvider* vp = doc->getViewProvider(obj); if (vp) vp->setTransformation(local.toMatrix()); } else { // No placement found, so apply the transformation directly Gui::ViewProvider* vp = doc->getViewProvider(obj); if (vp) vp->setTransformation(plm.toMatrix()); } }
MDIViewPage* ViewProviderDrawingView::getMDIViewPage() const { MDIViewPage* result = nullptr; Gui::Document* guiDoc = Gui::Application::Instance->getDocument(getViewObject()->getDocument()); Gui::ViewProvider* vp = guiDoc->getViewProvider(getViewObject()->findParentPage()); ViewProviderPage* dvp = dynamic_cast<ViewProviderPage*>(vp); if (dvp) { result = dvp->getMDIViewPage(); } return result; }
TaskPipeOrientation::TaskPipeOrientation(ViewProviderPipe* PipeView, bool /*newObj*/, QWidget* parent) : TaskSketchBasedParameters(PipeView, parent, "PartDesign_Additive_Pipe", tr("Section orientation")) { // we need a separate container widget to add all controls to proxy = new QWidget(this); ui = new Ui_TaskPipeOrientation(); ui->setupUi(proxy); QMetaObject::connectSlotsByName(this); connect(ui->comboBoxMode, SIGNAL(currentIndexChanged(int)), this, SLOT(onOrientationChanged(int))); connect(ui->buttonRefAdd, SIGNAL(toggled(bool)), this, SLOT(onButtonRefAdd(bool))); connect(ui->buttonRefRemove, SIGNAL(toggled(bool)), this, SLOT(onButtonRefRemove(bool))); connect(ui->buttonProfileBase, SIGNAL(toggled(bool)), this, SLOT(onBaseButton(bool))); connect(ui->stackedWidget, SIGNAL(currentChanged(int)), this, SLOT(updateUI(int))); connect(ui->curvelinear, SIGNAL(toggled(bool)), this, SLOT(onCurvelinearChanged(bool))); connect(ui->doubleSpinBoxX, SIGNAL(valueChanged(double)), this, SLOT(onBinormalChanged(double))); connect(ui->doubleSpinBoxY, SIGNAL(valueChanged(double)), this, SLOT(onBinormalChanged(double))); connect(ui->doubleSpinBoxZ, SIGNAL(valueChanged(double)), this, SLOT(onBinormalChanged(double))); this->groupLayout()->addWidget(proxy); PartDesign::Pipe* pipe = static_cast<PartDesign::Pipe*>(PipeView->getObject()); Gui::Document* doc = Gui::Application::Instance->activeDocument(); //make sure th euser sees al important things: the base feature to select edges and the //spine/auxillery spine he already selected if(pipe->AuxillerySpine.getValue()) { auto* svp = doc->getViewProvider(pipe->AuxillerySpine.getValue()); auxSpineShow = svp->isShow(); svp->show(); } //add initial values if(pipe->AuxillerySpine.getValue()) ui->profileBaseEdit->setText(QString::fromUtf8(pipe->AuxillerySpine.getValue()->getNameInDocument())); std::vector<std::string> strings = pipe->AuxillerySpine.getSubValues(); for (std::vector<std::string>::const_iterator i = strings.begin(); i != strings.end(); i++) ui->listWidgetReferences->addItem(QString::fromStdString(*i)); ui->comboBoxMode->setCurrentIndex(pipe->Mode.getValue()); ui->curvelinear->setChecked(pipe->AuxilleryCurvelinear.getValue()); updateUI(pipe->Mode.getValue()); }
/** * Extracts the associated view providers of the objects of the associated object group group. */ void ViewProviderDocumentObjectGroup::getViewProviders(std::vector<ViewProviderDocumentObject*>& vp) const { App::DocumentObject* doc = getObject(); if (doc->getTypeId().isDerivedFrom(App::DocumentObjectGroup::getClassTypeId())) { Gui::Document* gd = Application::Instance->getDocument(doc->getDocument()); App::DocumentObjectGroup* grp = (App::DocumentObjectGroup*)doc; std::vector<App::DocumentObject*> obj = grp->getObjects(); for (std::vector<App::DocumentObject*>::iterator it = obj.begin(); it != obj.end(); ++it) { ViewProvider* v = gd->getViewProvider(*it); if (v && v->getTypeId().isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) vp.push_back((ViewProviderDocumentObject*)v); } } }
void ViewProviderBody::setVisualBodyMode(bool bodymode) { Gui::Document *gdoc = Gui::Application::Instance->getDocument ( pcObject->getDocument() ) ; PartDesign::Body *body = static_cast<PartDesign::Body *> ( getObject() ); auto features = body->Model.getValues(); for(auto feature : features) { if(!feature->isDerivedFrom(PartDesign::Feature::getClassTypeId())) continue; static_cast<PartDesignGui::ViewProvider*>(gdoc->getViewProvider(feature))->setBodyMode(bodymode); } }
TaskProjGroup::TaskProjGroup(TechDraw::DrawProjGroup* featView, bool mode) : ui(new Ui_TaskProjGroup), multiView(featView), m_createMode(mode) { ui->setupUi(this); blockUpdate = true; ui->projection->setCurrentIndex(multiView->ProjectionType.getValue()); setFractionalScale(multiView->Scale.getValue()); ui->cmbScaleType->setCurrentIndex(multiView->ScaleType.getValue()); // Initially toggle view checkboxes if needed setupViewCheckboxes(true); blockUpdate = false; // Rotation buttons // Note we don't do the custom one here, as it's handled by [a different function that's held up in customs] connect(ui->butTopRotate, SIGNAL(clicked()), this, SLOT(rotateButtonClicked(void))); connect(ui->butCWRotate, SIGNAL(clicked()), this, SLOT(rotateButtonClicked(void))); connect(ui->butRightRotate, SIGNAL(clicked()), this, SLOT(rotateButtonClicked(void))); connect(ui->butDownRotate, SIGNAL(clicked()), this, SLOT(rotateButtonClicked(void))); connect(ui->butLeftRotate, SIGNAL(clicked()), this, SLOT(rotateButtonClicked(void))); connect(ui->butCCWRotate, SIGNAL(clicked()), this, SLOT(rotateButtonClicked(void))); //3D button connect(ui->but3D, SIGNAL(clicked()), this, SLOT(on3DClicked(void))); //Reset button connect(ui->butReset, SIGNAL(clicked()), this, SLOT(onResetClicked(void))); // Slot for Scale Type connect(ui->cmbScaleType, SIGNAL(currentIndexChanged(int)), this, SLOT(scaleTypeChanged(int))); connect(ui->sbScaleNum, SIGNAL(valueChanged(int)), this, SLOT(scaleManuallyChanged(int))); connect(ui->sbScaleDen, SIGNAL(valueChanged(int)), this, SLOT(scaleManuallyChanged(int))); // Slot for Projection Type (layout) connect(ui->projection, SIGNAL(currentIndexChanged(int)), this, SLOT(projectionTypeChanged(int))); m_page = multiView->findParentPage(); Gui::Document* activeGui = Gui::Application::Instance->getDocument(m_page->getDocument()); Gui::ViewProvider* vp = activeGui->getViewProvider(m_page); ViewProviderPage* dvp = static_cast<ViewProviderPage*>(vp); m_mdi = dvp->getMDIViewPage(); setUiPrimary(); }
TaskPipeOrientation::~TaskPipeOrientation() { PartDesign::Pipe* pipe = static_cast<PartDesign::Pipe*>(vp->getObject()); Gui::Document* doc = Gui::Application::Instance->activeDocument(); //make sure th euser sees al important things: the base feature to select edges and the //spine/auxillery spine he already selected if(pipe->AuxillerySpine.getValue()) { auto* svp = doc->getViewProvider(pipe->AuxillerySpine.getValue()); svp->setVisible(auxSpineShow); auxSpineShow = false; } static_cast<ViewProviderPipe*>(vp)->highlightReferences(false, true); }
void Tessellation::findShapes() { App::Document* activeDoc = App::GetApplication().getActiveDocument(); if (!activeDoc) return; Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc); if (!activeGui) return; this->document = QString::fromAscii(activeDoc->getName()); std::vector<Part::Feature*> objs = activeDoc->getObjectsOfType<Part::Feature>(); double edgeLen = 0; bool foundSelection = false; for (std::vector<Part::Feature*>::iterator it = objs.begin(); it!=objs.end(); ++it) { const TopoDS_Shape& shape = (*it)->Shape.getValue(); if (shape.IsNull()) continue; bool hasfaces = false; TopExp_Explorer xp(shape,TopAbs_FACE); while (xp.More()) { hasfaces = true; break; } if (hasfaces) { Base::BoundBox3d bbox = (*it)->Shape.getBoundingBox(); edgeLen = std::max<double>(edgeLen, bbox.LengthX()); edgeLen = std::max<double>(edgeLen, bbox.LengthY()); edgeLen = std::max<double>(edgeLen, bbox.LengthZ()); QString label = QString::fromUtf8((*it)->Label.getValue()); QString name = QString::fromAscii((*it)->getNameInDocument()); QTreeWidgetItem* child = new QTreeWidgetItem(); child->setText(0, label); child->setToolTip(0, label); child->setData(0, Qt::UserRole, name); Gui::ViewProvider* vp = activeGui->getViewProvider(*it); if (vp) child->setIcon(0, vp->getIcon()); ui->treeWidget->addTopLevelItem(child); if (Gui::Selection().isSelected(*it)) { child->setSelected(true); foundSelection = true; } } } ui->spinMaximumEdgeLength->setValue(edgeLen/10); if (foundSelection) ui->treeWidget->hide(); }
QIcon ViewProviderInspection::getIcon() const { // Get the icon of the view provider to the associated feature QIcon px = inherited::getIcon(); App::Property* pActual = pcObject->getPropertyByName("Actual"); if (pActual && pActual->getTypeId().isDerivedFrom( App::PropertyLink::getClassTypeId())) { App::DocumentObject* docobj = ((App::PropertyLink*)pActual)->getValue(); if (docobj) { Gui::Document* doc = Gui::Application::Instance->getDocument(docobj->getDocument()); Gui::ViewProvider* view = doc->getViewProvider(docobj); px = view->getIcon(); } } return px; }
TaskPipeParameters::~TaskPipeParameters() { PartDesign::Pipe* pipe = static_cast<PartDesign::Pipe*>(vp->getObject()); Gui::Document* doc = Gui::Application::Instance->activeDocument(); //make sure th euser sees al important things: the //spine/auxillery spine he already selected if(pipe->Spine.getValue()) { auto* svp = doc->getViewProvider(pipe->Spine.getValue()); svp->setVisible(spineShow); spineShow = false; } static_cast<ViewProviderPipe*>(vp)->highlightReferences(false, false); delete ui; }
QGIView* ViewProviderDrawingView::getQView(void) { QGIView *qView = nullptr; if (m_docReady){ Gui::Document* guiDoc = Gui::Application::Instance->getDocument(getViewObject()->getDocument()); Gui::ViewProvider* vp = guiDoc->getViewProvider(getViewObject()->findParentPage()); ViewProviderPage* dvp = dynamic_cast<ViewProviderPage*>(vp); if (dvp) { if (dvp->getMDIViewPage()) { if (dvp->getMDIViewPage()->getQGVPage()) { qView = dynamic_cast<QGIView *>(dvp->getMDIViewPage()->getQGVPage()->findView(getViewObject())); } } } } return qView; }
void SweepWidget::findShapes() { App::Document* activeDoc = App::GetApplication().getActiveDocument(); Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc); if (!activeGui) return; d->document = activeDoc->getName(); std::vector<Part::Feature*> objs = activeDoc->getObjectsOfType<Part::Feature>(); for (std::vector<Part::Feature*>::iterator it = objs.begin(); it!=objs.end(); ++it) { TopoDS_Shape shape = (*it)->Shape.getValue(); if (shape.IsNull()) continue; // also allow compounds with a single face, wire, edge or vertex if (shape.ShapeType() == TopAbs_COMPOUND) { TopoDS_Iterator it(shape); int numChilds=0; TopoDS_Shape child; for (; it.More(); it.Next(), numChilds++) { if (!it.Value().IsNull()) child = it.Value(); } if (numChilds == 1) shape = child; } if (shape.ShapeType() == TopAbs_FACE || shape.ShapeType() == TopAbs_WIRE || shape.ShapeType() == TopAbs_EDGE || shape.ShapeType() == TopAbs_VERTEX) { QString label = QString::fromUtf8((*it)->Label.getValue()); QString name = QString::fromLatin1((*it)->getNameInDocument()); QTreeWidgetItem* child = new QTreeWidgetItem(); child->setText(0, label); child->setToolTip(0, label); child->setData(0, Qt::UserRole, name); Gui::ViewProvider* vp = activeGui->getViewProvider(*it); if (vp) child->setIcon(0, vp->getIcon()); d->ui.selector->availableTreeWidget()->addTopLevelItem(child); } } }
void ViewProviderDocumentObjectGroup::updateData(const App::Property* prop) { #if 0 if (prop->getTypeId() == App::PropertyLinkList::getClassTypeId()) { std::vector<App::DocumentObject*> obj = static_cast<const App::PropertyLinkList*>(prop)->getValues(); Gui::Document* doc = Gui::Application::Instance->getDocument (&this->getObject()->getDocument()); MDIView* mdi = doc->getActiveView(); if (mdi && mdi->isDerivedFrom(View3DInventor::getClassTypeId())) { View3DInventorViewer* view = static_cast<View3DInventor*>(mdi)->getViewer(); SoSeparator* scene_graph = static_cast<SoSeparator*>(view->getSceneGraph()); std::vector<ViewProvider*> current_nodes; for (std::vector<App::DocumentObject*>::iterator it = obj.begin(); it != obj.end(); ++it) current_nodes.push_back(doc->getViewProvider(*it)); std::sort(current_nodes.begin(), current_nodes.end()); std::sort(this->nodes.begin(), this->nodes.end()); // get the removed views std::vector<ViewProvider*> diff_1, diff_2; std::back_insert_iterator<std::vector<ViewProvider*> > biit(diff_2); std::set_difference(this->nodes.begin(), this->nodes.end(), current_nodes.begin(), current_nodes.end(), biit); diff_1 = diff_2; diff_2.clear(); // get the added views std::set_difference(current_nodes.begin(), current_nodes.end(), this->nodes.begin(), this->nodes.end(), biit); this->nodes = current_nodes; // move from root node to switch for (std::vector<ViewProvider*>::iterator it = diff_1.begin(); it != diff_1.end(); ++it) { view->addViewProviderToGroup(*it, scene_graph); view->removeViewProviderFromGroup(*it, this->pcModeSwitch); } // move from switch node to root node for (std::vector<ViewProvider*>::iterator it = diff_2.begin(); it != diff_2.end(); ++it) { view->addViewProviderToGroup(*it, this->pcModeSwitch); view->removeViewProviderFromGroup(*it, scene_graph); } } } #else Q_UNUSED(prop); #endif }
void ViewProviderGroupExtension::extensionShow(void) { // when reading the Visibility property from file then do not hide the // objects of this group because they have stored their visibility status, too if (!getExtendedViewProvider()->isRestoring() && !this->visible) { auto* group = getExtendedViewProvider()->getObject()->getExtensionByType<App::GroupExtension>(); const std::vector<App::DocumentObject*> & links = group->Group.getValues(); Gui::Document* doc = Application::Instance->getDocument(group->getExtendedObject()->getDocument()); for (std::vector<App::DocumentObject*>::const_iterator it = links.begin(); it != links.end(); ++it) { ViewProvider* view = doc->getViewProvider(*it); if (view) view->show(); } } ViewProviderExtension::extensionShow(); this->visible = true; }
void CmdTechDrawToggleFrame::activated(int iMsg) { TechDraw::DrawPage* page = _findPageCD(this); if (!page) { return; } std::string PageName = page->getNameInDocument(); Gui::Document* activeGui = Gui::Application::Instance->getDocument(page->getDocument()); Gui::ViewProvider* vp = activeGui->getViewProvider(page); ViewProviderPage* dvp = dynamic_cast<ViewProviderPage*>(vp); if (dvp && dvp->getMDIViewPage()) { dvp->getMDIViewPage()->setFrameState(!dvp->getMDIViewPage()->getFrameState()); } else { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No TechDraw Page"), QObject::tr("Need a TechDraw Page for this command")); return; } }
void ViewProviderDocumentObjectGroup::show(void) { // when reading the Visibility property from file then do not hide the // objects of this group because they have stored their visibility status, too if (!Visibility.testStatus(App::Property::User1) && !this->visible) { App::DocumentObject * group = getObject(); if (group && group->getTypeId().isDerivedFrom(App::DocumentObjectGroup::getClassTypeId())) { const std::vector<App::DocumentObject*> & links = static_cast<App::DocumentObjectGroup*> (group)->Group.getValues(); Gui::Document* doc = Application::Instance->getDocument(group->getDocument()); for (std::vector<App::DocumentObject*>::const_iterator it = links.begin(); it != links.end(); ++it) { ViewProvider* view = doc->getViewProvider(*it); if (view) view->show(); } } } ViewProviderDocumentObject::show(); this->visible = true; }
void ViewProviderBody::unifyVisualProperty(const App::Property* prop) { if(prop == &Visibility || prop == &Selectable || prop == &DisplayModeBody) return; Gui::Document *gdoc = Gui::Application::Instance->getDocument ( pcObject->getDocument() ) ; PartDesign::Body *body = static_cast<PartDesign::Body *> ( getObject() ); auto features = body->Model.getValues(); for(auto feature : features) { if(!feature->isDerivedFrom(PartDesign::Feature::getClassTypeId())) continue; //copy over the properties data auto p = gdoc->getViewProvider(feature)->getPropertyByName(prop->getName()); p->Paste(*prop); } }
void CmdTechDrawExportPage::activated(int iMsg) { Q_UNUSED(iMsg); TechDraw::DrawPage* page = _findPage(this); if (!page) { return; } std::string PageName = page->getNameInDocument(); Gui::Document* activeGui = Gui::Application::Instance->getDocument(page->getDocument()); Gui::ViewProvider* vp = activeGui->getViewProvider(page); ViewProviderPage* dvp = dynamic_cast<ViewProviderPage*>(vp); if (dvp && dvp->getMDIViewPage()) { dvp->getMDIViewPage()->saveSVG(); } else { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No Drawing View"), QObject::tr("Open Drawing View before attempting export to SVG.")); return; } }