void QGVPage::toggleMarkers(bool enable) { QList<QGraphicsItem*> list = scene()->items(); for (QList<QGraphicsItem*>::iterator it = list.begin(); it != list.end(); ++it) { QGIView *itemView = dynamic_cast<QGIView *>(*it); if(itemView) { itemView->setSelected(false); itemView->toggleBorder(enable); QGIViewPart *viewPart = dynamic_cast<QGIViewPart *>(*it); if(viewPart) { viewPart->toggleVertices(enable); } } QGISVGTemplate* itemTemplate = dynamic_cast<QGISVGTemplate*> (*it); if (itemTemplate) { std::vector<TemplateTextField *> textFields = itemTemplate->getTextFields(); for (auto& t:textFields) { if (enable) { t->show(); } else { t->hide(); } } } } }
int QGVPage::addQView(QGIView *view) { auto ourScene( scene() ); assert(ourScene); ourScene->addItem(view); // Find if it belongs to a parent QGIView *parent = 0; parent = findParent(view); QPointF viewPos(Rez::guiX(view->getViewObject()->X.getValue()), Rez::guiX(view->getViewObject()->Y.getValue() * -1)); if(parent) { // move child view to center of parent QPointF posRef(0.,0.); QPointF mapPos = view->mapToItem(parent, posRef); view->moveBy(-mapPos.x(), -mapPos.y()); parent->addToGroup(view); } view->setPos(viewPos); return 0; }
void ViewProviderDrawingView::updateData(const App::Property* prop) { if (prop == &(getViewObject()->Rotation) ) { // redraw QGIVP QGIView* qgiv = getQView(); if (qgiv) { qgiv->updateView(true); } } Gui::ViewProviderDocumentObject::updateData(prop); }
void ViewProviderDimension::onChanged(const App::Property* p) { if ((p == &Font) || (p == &Fontsize) || (p == &LineWidth) ) { QGIView* qgiv = getQView(); if (qgiv) { qgiv->updateView(true); } } Gui::ViewProviderDocumentObject::onChanged(p); }
void MDIViewPage::clearSelection() { blockSelection(true); std::vector<QGIView *> views = m_view->getViews(); // Iterate through all views and unselect all for (std::vector<QGIView *>::iterator it = views.begin(); it != views.end(); ++it) { QGIView *item = *it; item->setSelected(false); item->updateView(); } blockSelection(false); }
void ViewProviderDrawingView::onGuiRepaint(const TechDraw::DrawView* dv) { if (dv == getViewObject()) { QGIView* qgiv = getQView(); if (qgiv) { qgiv->updateView(true); } else { //we are not part of the Gui page yet. ask page to add us. auto page = dv->findParentPage(); if (page != nullptr) { page->requestPaint(); } } } }
void ViewProviderViewSection::updateData(const App::Property* prop) { Base::Console().Log("ViewProviderViewSection::updateData - Update View: %s\n",prop->getName()); if (prop == &(getViewObject()->ShowCutSurface) || prop == &(getViewObject()->CutSurfaceColor) ) { // redraw QGIVP QGIView* qgiv = getQView(); if (qgiv) { qgiv->updateView(true); } } ViewProviderViewPart::updateData(prop); }
//! find the graphic for DocumentObject with name QGIView* QGVPage::getQGIVByName(std::string name) { QList<QGraphicsItem*> qgItems = scene()->items(); QList<QGraphicsItem*>::iterator it = qgItems.begin(); for (; it != qgItems.end(); it++) { QGIView* qv = dynamic_cast<QGIView*>((*it)); if (qv) { const char* qvName = qv->getViewName(); if(name.compare(qvName) == 0) { return (qv); } } } return nullptr; }
//!Update QGVPage's selection based on Selection made outside Drawing Interface //invoked from VPP void MDIViewPage::selectFeature(App::DocumentObject *obj, const bool isSelected) { App::DocumentObject* objCopy = obj; TechDraw::DrawHatch* hatchObj = dynamic_cast<TechDraw::DrawHatch*>(objCopy); if (hatchObj) { //Hatch does not have a QGIV of it's own. mark parent as selected. objCopy = hatchObj->getSourceView(); //possible to highlight subObject? } QGIView *view = m_view->findQViewForDocObj(objCopy); blockSelection(true); if(view) { view->setSelected(isSelected); view->updateView(); } blockSelection(false); }
void ViewProviderViewClip::updateData(const App::Property* prop) { //Base::Console().Log("ViewProviderViewClip::updateData - Update View: %s\n",prop->getName()); if (prop == &(getViewObject()->Height) || prop == &(getViewObject()->Width) || prop == &(getViewObject()->ShowFrame) || prop == &(getViewObject()->ShowLabels) || prop == &(getViewObject()->Views) ) { // redraw QGIVP QGIView* qgiv = getQView(); if (qgiv) { qgiv->updateView(true); } } ViewProviderDrawingView::updateData(prop); }
void ViewProviderProjGroup::updateData(const App::Property* prop) { ViewProviderDrawingView::updateData(prop); if(prop == &(getObject()->Scale) || prop == &(getObject()->ScaleType) || prop == &(getObject()->Views) || prop == &(getObject()->ProjectionType) || prop == &(getObject()->LockPosition) ) { QGIView* qgiv = getQView(); if (qgiv) { qgiv->updateView(true); } } }
void ViewProviderDrawingView::hide(void) { TechDraw::DrawView* obj = getViewObject(); if (!obj || obj->isRestoring()) return; if (obj->getTypeId().isDerivedFrom(TechDraw::DrawView::getClassTypeId())) { QGIView* qView = getQView(); if (qView) { qView->isVisible(false); qView->draw(); qView->hide(); } } ViewProviderDocumentObject::hide(); }
void ViewProviderViewPart::updateData(const App::Property* prop) { if (prop == &(getViewObject()->LineWidth) || prop == &(getViewObject()->HiddenWidth) || prop == &(getViewObject()->ArcCenterMarks) || prop == &(getViewObject()->CenterScale) || prop == &(getViewObject()->ShowSectionLine) || prop == &(getViewObject()->HorizCenterLine) || prop == &(getViewObject()->VertCenterLine) ) { // redraw QGIVP QGIView* qgiv = getQView(); if (qgiv) { qgiv->updateView(true); } } ViewProviderDrawingView::updateData(prop); }
QColor QGCustomText::getNormalColor() { QColor result; QGIView *parent; QGraphicsItem* qparent = parentItem(); if (qparent == nullptr) { parent = nullptr; } else { parent = dynamic_cast<QGIView *> (qparent); } if (parent != nullptr) { result = parent->getNormalColor(); } else { Base::Reference<ParameterGrp> hGrp = getParmGroup(); App::Color fcColor; fcColor.setPackedValue(hGrp->GetUnsigned("NormalColor", 0x00000000)); result = fcColor.asValue<QColor>(); } return result; }
void ViewProviderDrawingView::onChanged(const App::Property *prop) { App::DocumentObject* obj = getObject(); if (!obj || obj->isRestoring()) { Gui::ViewProviderDocumentObject::onChanged(prop); return; } if (prop == &Visibility) { if(Visibility.getValue()) { show(); } else { hide(); } } else if (prop == &KeepLabel) { QGIView* qgiv = getQView(); if (qgiv) { qgiv->updateView(true); } } Gui::ViewProviderDocumentObject::onChanged(prop); }
bool MDIViewPage::compareSelections(std::vector<Gui::SelectionObject> treeSel, QList<QGraphicsItem*> sceneSel) { bool result = true; if (treeSel.empty() && sceneSel.empty()) { return true; } else if (treeSel.empty() && !sceneSel.empty()) { return false; } else if (!treeSel.empty() && sceneSel.empty()) { return false; } int treeCount = 0; int sceneCount = 0; int subCount = 0; int ppCount = 0; std::vector<std::string> treeNames; std::vector<std::string> sceneNames; for (auto tn: treeSel) { if (tn.getObject()->isDerivedFrom(TechDraw::DrawView::getClassTypeId())) { int treeSubs = tn.getSubNames().size(); subCount += treeSubs; std::string s = tn.getObject()->getNameInDocument(); treeNames.push_back(s); } } std::sort(treeNames.begin(),treeNames.end()); treeCount = treeNames.size(); for (auto sn:sceneSel){ QGIView *itemView = dynamic_cast<QGIView *>(sn); //<<<<< if(itemView == 0) { QGIPrimPath* pp = dynamic_cast<QGIPrimPath*>(sn); //count Vertex/Edge/Face if (pp != nullptr) { ppCount++; } } else { std::string s = itemView->getViewNameAsString(); sceneNames.push_back(s); } } std::sort(sceneNames.begin(),sceneNames.end()); sceneCount = sceneNames.size(); //different # of DrawView* vs QGIV* if (sceneCount != treeCount) { return false; } // even of counts match, have to check that names in scene == names in tree auto treePtr = treeNames.begin(); for (auto& s: sceneNames){ if (s == (*treePtr)) { treePtr++; continue; } else { return false; } } //Objects all match, check subs if (treeCount != ppCount) { return false; } return result; }
//! update FC Selection from QGraphicsScene selection //trigged by m_view->scene() signal void MDIViewPage::selectionChanged() { if(isSelectionBlocked) { return; } QList<QGraphicsItem*> selection = m_view->scene()->selectedItems(); bool saveBlock = blockConnection(true); // avoid to be notified by itself blockSelection(true); Gui::Selection().clearSelection(); for (QList<QGraphicsItem*>::iterator it = selection.begin(); it != selection.end(); ++it) { QGIView *itemView = dynamic_cast<QGIView *>(*it); if(itemView == 0) { QGIEdge *edge = dynamic_cast<QGIEdge *>(*it); if(edge) { QGraphicsItem*parent = edge->parentItem(); if(!parent) continue; QGIView *viewItem = dynamic_cast<QGIView *>(parent); if(!viewItem) continue; TechDraw::DrawView *viewObj = viewItem->getViewObject(); std::stringstream ss; ss << "Edge" << edge->getProjIndex(); //bool accepted = static_cast<void> (Gui::Selection().addSelection(viewObj->getDocument()->getName(), viewObj->getNameInDocument(), ss.str().c_str())); showStatusMsg(viewObj->getDocument()->getName(), viewObj->getNameInDocument(), ss.str().c_str()); continue; } QGIVertex *vert = dynamic_cast<QGIVertex *>(*it); if(vert) { QGraphicsItem*parent = vert->parentItem(); if(!parent) continue; QGIView *viewItem = dynamic_cast<QGIView *>(parent); if(!viewItem) continue; TechDraw::DrawView *viewObj = viewItem->getViewObject(); std::stringstream ss; ss << "Vertex" << vert->getProjIndex(); //bool accepted = static_cast<void> (Gui::Selection().addSelection(viewObj->getDocument()->getName(), viewObj->getNameInDocument(), ss.str().c_str())); showStatusMsg(viewObj->getDocument()->getName(), viewObj->getNameInDocument(), ss.str().c_str()); continue; } QGIFace *face = dynamic_cast<QGIFace *>(*it); if(face) { QGraphicsItem*parent = face->parentItem(); if(!parent) continue; QGIView *viewItem = dynamic_cast<QGIView *>(parent); if(!viewItem) continue; TechDraw::DrawView *viewObj = viewItem->getViewObject(); std::stringstream ss; ss << "Face" << face->getProjIndex(); //bool accepted = static_cast<void> (Gui::Selection().addSelection(viewObj->getDocument()->getName(), viewObj->getNameInDocument(), ss.str().c_str())); showStatusMsg(viewObj->getDocument()->getName(), viewObj->getNameInDocument(), ss.str().c_str()); continue; } QGIDatumLabel *dimLabel = dynamic_cast<QGIDatumLabel*>(*it); if(dimLabel) { QGraphicsItem*dimParent = dimLabel->parentItem(); if(!dimParent) continue; QGIView *dimItem = dynamic_cast<QGIView *>(dimParent); if(!dimItem) continue; TechDraw::DrawView *dimObj = dimItem->getViewObject(); if (!dimObj) { continue; } const char* name = dimObj->getNameInDocument(); if (!name) { //can happen during undo/redo if Dim is selected??? //Base::Console().Log("INFO - MDIVP::selectionChanged - dimObj name is null!\n"); continue; } //bool accepted = static_cast<void> (Gui::Selection().addSelection(dimObj->getDocument()->getName(),dimObj->getNameInDocument())); } } else { TechDraw::DrawView *viewObj = itemView->getViewObject(); if (viewObj && !viewObj->isRemoving()) { std::string doc_name = viewObj->getDocument()->getName(); std::string obj_name = viewObj->getNameInDocument(); Gui::Selection().addSelection(doc_name.c_str(), obj_name.c_str()); showStatusMsg(doc_name.c_str(), obj_name.c_str(), ""); } } } blockConnection(saveBlock); blockSelection(false); } // end MDIViewPage::selectionChanged()