本文整理汇总了C++中techdraw::DrawPage::getNameInDocument方法的典型用法代码示例。如果您正苦于以下问题:C++ DrawPage::getNameInDocument方法的具体用法?C++ DrawPage::getNameInDocument怎么用?C++ DrawPage::getNameInDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类techdraw::DrawPage
的用法示例。
在下文中一共展示了DrawPage::getNameInDocument方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: activated
void CmdTechDrawNewView::activated(int iMsg)
{
Q_UNUSED(iMsg);
TechDraw::DrawPage* page = DrawGuiUtil::findPage(this);
if (!page) {
return;
}
std::vector<App::DocumentObject*> shapes = getSelection().getObjectsOfType(Part::Feature::getClassTypeId());
if (shapes.empty()) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Select at least 1 Part object."));
return;
}
std::string PageName = page->getNameInDocument();
Gui::WaitCursor wc;
const auto selectedProjections( getSelection().getObjectsOfType(TechDraw::DrawView::getClassTypeId()) );
float newScale = 1.0;
float newRotation = 0.0;
Base::Vector3d newDirection(0.0, 0.0, 1.0);
if (!selectedProjections.empty()) {
const auto myView( static_cast<TechDraw::DrawView*>(selectedProjections.front()) );
newScale = myView->Scale.getValue();
newRotation = myView->Rotation.getValue();
// The "Direction" property does not belong to TechDraw::DrawView, but to one of the
// many child classes that are projecting objects into the drawing. Therefore, we get the
// property by name.
const App::PropertyVector* const propDirection = dynamic_cast<App::PropertyVector*>(myView->getPropertyByName("Direction"));
if (propDirection) {
newDirection = propDirection->getValue();
}
}
openCommand("Create view");
for (std::vector<App::DocumentObject*>::iterator it = shapes.begin(); it != shapes.end(); ++it) {
std::string FeatName = getUniqueObjectName("View");
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewPart','%s')",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Source = App.activeDocument().%s",FeatName.c_str(),(*it)->getNameInDocument());
doCommand(Doc,"App.activeDocument().%s.Direction = (%e,%e,%e)",FeatName.c_str(), newDirection.x, newDirection.y, newDirection.z);
doCommand(Doc,"App.activeDocument().%s.Scale = %e",FeatName.c_str(), newScale);
doCommand(Doc,"App.activeDocument().%s.Rotation = %e",FeatName.c_str(), newRotation);
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
}
updateActive();
commitCommand();
}
示例2: activated
void CmdTechDrawLinkDimension::activated(int iMsg)
{
Q_UNUSED(iMsg);
TechDraw::DrawPage* page = DrawGuiUtil::findPage(this);
if (!page) {
return;
}
std::string PageName = page->getNameInDocument();
bool result = _checkSelection(this,2);
if (!result)
return;
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
App::DocumentObject* obj3D = 0;
std::vector<App::DocumentObject*> parts;
std::vector<std::string> subs;
std::vector<Gui::SelectionObject>::iterator itSel = selection.begin();
for (; itSel != selection.end(); itSel++) {
if ((*itSel).getObject()->isDerivedFrom(Part::Feature::getClassTypeId())) {
obj3D = ((*itSel).getObject());
std::vector<std::string> subList = (*itSel).getSubNames();
for (auto& s:subList) {
parts.push_back(obj3D);
subs.push_back(s);
}
}
}
if (!obj3D) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect Selection"),
QObject::tr("There is no 3D object in your selection"));
return;
}
if (subs.empty()) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect Selection"),
QObject::tr("There are no 3D Edges or Vertices in your selection"));
return;
}
// dialog to select the Dimension to link
Gui::Control().showDialog(new TaskDlgLinkDim(parts,subs,page));
page->getDocument()->recompute(); //still need to recompute in Gui. why?
}
示例3: activated
void CmdTechDrawAnnotation::activated(int iMsg)
{
Q_UNUSED(iMsg);
TechDraw::DrawPage* page = _findPage(this);
if (!page) {
return;
}
std::string PageName = page->getNameInDocument();
std::string FeatName = getUniqueObjectName("Annotation");
openCommand("Create Annotation");
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewAnnotation','%s')",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
updateActive();
commitCommand();
}
示例4: activated
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;
}
}
示例5: activated
void CmdTechDrawNewHatch::activated(int iMsg)
{
Q_UNUSED(iMsg);
if (!_checkSelectionHatch(this)) {
return;
}
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
auto objFeat( dynamic_cast<TechDraw::DrawViewPart *>(selection[0].getObject()) );
if( objFeat == nullptr ) {
return;
}
const std::vector<std::string> &subNames = selection[0].getSubNames();
TechDraw::DrawPage* page = objFeat->findParentPage();
std::string PageName = page->getNameInDocument();
std::string FeatName = getUniqueObjectName("Hatch");
std::stringstream featLabel;
featLabel << FeatName << "F" << TechDraw::DrawUtil::getIndexFromName(subNames.at(0));
openCommand("Create Hatch");
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawHatch','%s')",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Label = '%s'",FeatName.c_str(),featLabel.str().c_str());
auto hatch( static_cast<TechDraw::DrawHatch *>(getDocument()->getObject(FeatName.c_str())) );
hatch->Source.setValue(objFeat, subNames);
//should this be: doCommand(Doc,"App..Feat..Source = [(App...%s,%s),(App..%s,%s),...]",objs[0]->getNameInDocument(),subs[0],...);
//seems very unwieldy
commitCommand();
//Horrible hack to force Tree update ??still required??
double x = objFeat->X.getValue();
objFeat->X.setValue(x);
getDocument()->recompute();
}
示例6: Exception
void CmdTechDrawNewAngle3PtDimension::activated(int iMsg)
{
Q_UNUSED(iMsg);
bool result = _checkSelection(this,3);
if (!result)
return;
result = _checkDrawViewPart(this);
if (!result)
return;
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
TechDraw::DrawViewPart * objFeat = 0;
std::vector<std::string> SubNames;
std::vector<Gui::SelectionObject>::iterator itSel = selection.begin();
for (; itSel != selection.end(); itSel++) {
if ((*itSel).getObject()->isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) {
objFeat = static_cast<TechDraw::DrawViewPart*> ((*itSel).getObject());
SubNames = (*itSel).getSubNames();
}
}
TechDraw::DrawPage* page = objFeat->findParentPage();
std::string PageName = page->getNameInDocument();
TechDraw::DrawViewDimension *dim = 0;
std::string FeatName = getUniqueObjectName("Dimension");
std::vector<App::DocumentObject *> objs;
std::vector<std::string> subs;
if (_isValidVertexes(this, 3)) {
objs.push_back(objFeat);
objs.push_back(objFeat);
objs.push_back(objFeat);
subs.push_back(SubNames[0]);
subs.push_back(SubNames[1]);
subs.push_back(SubNames[2]);
} else {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect Selection"),
QObject::tr("Need three points to make an 3 point Angle Dimension"));
return;
}
openCommand("Create Dimension");
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewDimension','%s')",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Type = '%s'",FeatName.c_str()
,"Angle3Pt");
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
if (!dim) {
throw Base::Exception("CmdTechDrawNewAngle3PtDimension - dim not found\n");
}
dim->References2D.setValues(objs, subs);
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
commitCommand();
dim->recomputeFeature();
//Horrible hack to force Tree update
double x = objFeat->X.getValue();
objFeat->X.setValue(x);
}