本文整理汇总了C++中app::DocumentObject::getNameInDocument方法的典型用法代码示例。如果您正苦于以下问题:C++ DocumentObject::getNameInDocument方法的具体用法?C++ DocumentObject::getNameInDocument怎么用?C++ DocumentObject::getNameInDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app::DocumentObject
的用法示例。
在下文中一共展示了DocumentObject::getNameInDocument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onSelectReference
void TaskSketchBasedParameters::onSelectReference(const bool pressed, const bool edge, const bool face, const bool planar) {
// Note: Even if there is no solid, App::Plane and Part::Datum can still be selected
PartDesign::ProfileBased* pcSketchBased = static_cast<PartDesign::ProfileBased*>(vp->getObject());
// The solid this feature will be fused to
App::DocumentObject* prevSolid = pcSketchBased->getBaseObject( /* silent =*/ true );
if (pressed) {
Gui::Document* doc = Gui::Application::Instance->activeDocument();
if (doc) {
if (pcSketchBased)
doc->setHide(pcSketchBased->getNameInDocument());
if (prevSolid)
doc->setShow(prevSolid->getNameInDocument());
}
Gui::Selection().clearSelection();
Gui::Selection().addSelectionGate
(new ReferenceSelection(prevSolid, edge, face, planar));
} else {
Gui::Selection().rmvSelectionGate();
Gui::Document* doc = Gui::Application::Instance->activeDocument();
if (doc) {
if (pcSketchBased)
doc->setShow(pcSketchBased->getNameInDocument());
if (prevSolid)
doc->setHide(prevSolid->getNameInDocument());
}
}
}
示例2: onAddSelection
const QString TaskSketchBasedParameters::onAddSelection(const Gui::SelectionChanges& msg)
{
// Note: The validity checking has already been done in ReferenceSelection.cpp
PartDesign::ProfileBased* pcSketchBased = static_cast<PartDesign::ProfileBased*>(vp->getObject());
App::DocumentObject* selObj = pcSketchBased->getDocument()->getObject(msg.pObjectName);
if (selObj == pcSketchBased)
return QString::fromLatin1("");
std::string subname = msg.pSubName;
QString refStr;
// Remove subname for planes and datum features
if (PartDesign::Feature::isDatum(selObj)) {
subname = "";
refStr = QString::fromLatin1(selObj->getNameInDocument());
} else {
int faceId = std::atoi(&subname[4]);
refStr = QString::fromLatin1(selObj->getNameInDocument()) + QString::fromLatin1(":") + QObject::tr("Face") + QString::number(faceId);
}
std::vector<std::string> upToFaces(1,subname);
pcSketchBased->UpToFace.setValue(selObj, upToFaces);
recomputeFeature();
return refStr;
}
示例3: slotChangedObject
void Document::slotChangedObject(const App::DocumentObject& Obj, const App::Property& Prop)
{
//Base::Console().Log("Document::slotChangedObject() called\n");
ViewProvider* viewProvider = getViewProvider(&Obj);
if (viewProvider) {
try {
viewProvider->update(&Prop);
}
catch(const Base::MemoryException& e) {
Base::Console().Error("Memory exception in '%s' thrown: %s\n",Obj.getNameInDocument(),e.what());
}
catch(Base::Exception& e){
e.ReportException();
}
catch(const std::exception& e){
Base::Console().Error("C++ exception in '%s' thrown: %s\n",Obj.getNameInDocument(),e.what());
}
catch (...) {
Base::Console().Error("Cannot update representation for '%s'.\n", Obj.getNameInDocument());
}
// check for children
if(viewProvider->getChildRoot()) {
std::vector<App::DocumentObject*> children = viewProvider->claimChildren3D();
SoGroup* childGroup = viewProvider->getChildRoot();
// size not the same -> build up the list new
if(childGroup->getNumChildren() != children.size()){
childGroup->removeAllChildren();
for(std::vector<App::DocumentObject*>::iterator it=children.begin();it!=children.end();++it){
ViewProvider* ChildViewProvider = getViewProvider(*it);
if(ChildViewProvider) {
SoSeparator* childRootNode = ChildViewProvider->getRoot();
childGroup->addChild(childRootNode);
// cycling to all views of the document to remove the viewprovider from the viewer itself
for (std::list<Gui::BaseView*>::iterator vIt = d->baseViews.begin();vIt != d->baseViews.end();++vIt) {
View3DInventor *activeView = dynamic_cast<View3DInventor *>(*vIt);
if (activeView && viewProvider) {
if (d->_pcInEdit == ChildViewProvider)
resetEdit();
activeView->getViewer()->removeViewProvider(ChildViewProvider);
}
}
}
}
}
}
if (viewProvider->isDerivedFrom(ViewProviderDocumentObject::getClassTypeId()))
signalChangedObject(static_cast<ViewProviderDocumentObject&>(*viewProvider), Prop);
}
// a property of an object has changed
setModified(true);
}
示例4: activated
void CmdPartDesignMoveTip::activated(int iMsg)
{
Q_UNUSED(iMsg);
std::vector<App::DocumentObject*> features = getSelection().getObjectsOfType(
Part::Feature::getClassTypeId() );
App::DocumentObject* selFeature;
PartDesign::Body* body= nullptr;
if ( features.size() == 1 ) {
selFeature = features.front();
if ( selFeature->getTypeId().isDerivedFrom ( PartDesign::Body::getClassTypeId() ) ) {
body = static_cast<PartDesign::Body *> ( selFeature );
} else {
body = PartDesignGui::getBodyFor ( selFeature, /* messageIfNot =*/ false );
}
} else {
selFeature = nullptr;
}
if (!selFeature) {
QMessageBox::warning (0, QObject::tr( "Selection error" ),
QObject::tr( "Select exactly one PartDesign feature or a body." ) );
return;
} else if (!body) {
QMessageBox::warning (0, QObject::tr( "Selection error" ),
QObject::tr( "Couldn't determine a body for the selected feature '%s'.", selFeature->Label.getValue() ) );
return;
} else if ( !selFeature->isDerivedFrom(PartDesign::Feature::getClassTypeId () ) &&
selFeature != body && body->BaseFeature.getValue() != selFeature ) {
QMessageBox::warning (0, QObject::tr( "Selection error" ),
QObject::tr( "Only a solid feature can be the tip of a body." ) );
return;
}
App::DocumentObject* oldTip = body->Tip.getValue();
if (oldTip == selFeature) { // it's not generally an error, so print only a console message
Base::Console().Message ("%s is already the tip of the body", selFeature->getNameInDocument () );
return;
}
openCommand("Move tip to selected feature");
if (selFeature == body) {
doCommand(Doc,"App.activeDocument().%s.Tip = None", body->getNameInDocument());
} else {
doCommand(Doc,"App.activeDocument().%s.Tip = App.activeDocument().%s",body->getNameInDocument(),
selFeature->getNameInDocument());
// Adjust visibility to show only the Tip feature
doCommand(Gui,"Gui.activeDocument().show(\"%s\")", selFeature->getNameInDocument());
}
// TOOD: Hide all datum features after the Tip feature? But the user might have already hidden some and wants to see
// others, so we would have to remember their state somehow
updateActive();
}
示例5: activated
void CmdPartDesignPad::activated(int iMsg)
{
unsigned int n = getSelection().countObjectsOfType(Part::Part2DObject::getClassTypeId());
if (n != 1) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Select a sketch or 2D object."));
return;
}
std::string FeatName = getUniqueObjectName("Pad");
std::vector<App::DocumentObject*> Sel = getSelection().getObjectsOfType(Part::Part2DObject::getClassTypeId());
Part::Part2DObject* sketch = static_cast<Part::Part2DObject*>(Sel.front());
const TopoDS_Shape& shape = sketch->Shape.getValue();
if (shape.IsNull()) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("The shape of the selected object is empty."));
return;
}
// count free wires
int ctWires=0;
TopExp_Explorer ex;
for (ex.Init(shape, TopAbs_WIRE); ex.More(); ex.Next()) {
ctWires++;
}
if (ctWires == 0) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("The shape of the selected object is not a wire."));
return;
}
App::DocumentObject* support = sketch->Support.getValue();
openCommand("Make Pad");
doCommand(Doc,"App.activeDocument().addObject(\"PartDesign::Pad\",\"%s\")",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Sketch = App.activeDocument().%s",FeatName.c_str(),sketch->getNameInDocument());
doCommand(Doc,"App.activeDocument().%s.Length = 10.0",FeatName.c_str());
updateActive();
if (isActiveObjectValid()) {
doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",sketch->getNameInDocument());
if (support)
doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",support->getNameInDocument());
}
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
//commitCommand();
adjustCameraPosition();
if (support) {
copyVisual(FeatName.c_str(), "ShapeColor", support->getNameInDocument());
copyVisual(FeatName.c_str(), "LineColor", support->getNameInDocument());
copyVisual(FeatName.c_str(), "PointColor", support->getNameInDocument());
}
}
示例6: list
PyObject *SelectionSingleton::sAddSelection(PyObject * /*self*/, PyObject *args, PyObject * /*kwd*/)
{
PyObject *object;
char* subname=0;
float x=0,y=0,z=0;
if (PyArg_ParseTuple(args, "O!|sfff", &(App::DocumentObjectPy::Type),&object,&subname,&x,&y,&z)) {
App::DocumentObjectPy* docObjPy = static_cast<App::DocumentObjectPy*>(object);
App::DocumentObject* docObj = docObjPy->getDocumentObjectPtr();
if (!docObj || !docObj->getNameInDocument()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot check invalid object");
return NULL;
}
Selection().addSelection(docObj->getDocument()->getName(),
docObj->getNameInDocument(),
subname,x,y,z);
Py_Return;
}
PyErr_Clear();
PyObject *sequence;
if (PyArg_ParseTuple(args, "O!O", &(App::DocumentObjectPy::Type),&object,&sequence)) {
App::DocumentObjectPy* docObjPy = static_cast<App::DocumentObjectPy*>(object);
App::DocumentObject* docObj = docObjPy->getDocumentObjectPtr();
if (!docObj || !docObj->getNameInDocument()) {
PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot check invalid object");
return NULL;
}
try {
if (PyTuple_Check(sequence) || PyList_Check(sequence)) {
Py::Sequence list(sequence);
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
std::string subname = static_cast<std::string>(Py::String(*it));
Selection().addSelection(docObj->getDocument()->getName(),
docObj->getNameInDocument(),
subname.c_str());
}
Py_Return;
}
}
catch (const Py::Exception&) {
// do nothing here
}
}
PyErr_SetString(PyExc_ValueError, "type must be 'DocumentObject[,subname[,x,y,z]]' or 'DocumentObject, list or tuple of subnames'");
return 0;
}
示例7: onDeleteObject
void MDIViewPage::onDeleteObject(const App::DocumentObject& obj)
{
//if this page has a QView for this obj, delete it.
if (obj.isDerivedFrom(TechDraw::DrawView::getClassTypeId())) {
(void) m_view->removeQViewByName(obj.getNameInDocument());
}
}
示例8: getPyReprString
const string PropertyLinkSubList::getPyReprString()
{
assert(this->_lValueList.size() == this->_lSubList.size());
if (this->_lValueList.size() == 0)
return std::string("None");
std::stringstream strm;
strm << "[";
for (std::size_t i = 0; i < this->_lSubList.size(); i++) {
if (i>0)
strm << ",(";
else
strm << "(";
App::DocumentObject* obj = this->_lValueList[i];
if (obj) {
strm << "App.getDocument('" << obj->getDocument()->getName() << "')." << obj->getNameInDocument();
} else {
strm << "None";
}
strm << ",";
strm << "'" << this->_lSubList[i] << "'";
strm << ")";
}
strm << "]";
return strm.str();
}
示例9: onDeleteObject
void DlgFilletEdges::onDeleteObject(const App::DocumentObject& obj)
{
if (d->fillet == &obj) {
d->fillet = 0;
}
else if (d->fillet && d->fillet->Base.getValue() == &obj) {
d->fillet = 0;
d->object = 0;
ui->shapeObject->setCurrentIndex(0);
on_shapeObject_activated(0);
}
else if (d->object == &obj) {
d->object = 0;
ui->shapeObject->removeItem(ui->shapeObject->currentIndex());
ui->shapeObject->setCurrentIndex(0);
on_shapeObject_activated(0);
}
else {
QString shape = QString::fromAscii(obj.getNameInDocument());
// start from the second item
for (int i=1; i<ui->shapeObject->count(); i++) {
if (ui->shapeObject->itemData(i).toString() == shape) {
ui->shapeObject->removeItem(i);
break;
}
}
}
}
示例10: execute
App::DocumentObjectExecReturn *DrawViewArch::execute(void)
{
if (!keepUpdated()) {
return App::DocumentObject::StdReturn;
}
App::DocumentObject* sourceObj = Source.getValue();
if (sourceObj) {
std::string svgFrag;
std::string svgHead = getSVGHead();
std::string svgTail = getSVGTail();
std::string FeatName = getNameInDocument();
std::string SourceName = sourceObj->getNameInDocument();
// ArchSectionPlane.getSVG(section,allOn=False,renderMode="Wireframe",showHidden=False,showFill=False,scale=1,linewidth=1,fontsize=1):
std::stringstream paramStr;
paramStr << ",allOn=" << (AllOn.getValue() ? "True" : "False")
<< ",renderMode=" << RenderMode.getValue()
<< ",showHidden=" << (ShowHidden.getValue() ? "True" : "False")
<< ",showFill=" << (ShowFill.getValue() ? "True" : "False")
<< ",scale=" << getScale()
<< ",linewidth=" << LineWidth.getValue()
<< ",fontsize=" << FontSize.getValue()
<< ",techdraw=True"
<< ",rotation=" << Rotation.getValue();
Base::Interpreter().runString("import ArchSectionPlane");
Base::Interpreter().runStringArg("svgBody = ArchSectionPlane.getSVG(App.activeDocument().%s %s)",
SourceName.c_str(),paramStr.str().c_str());
Base::Interpreter().runStringArg("App.activeDocument().%s.Symbol = '%s' + svgBody + '%s'",
FeatName.c_str(),svgHead.c_str(),svgTail.c_str());
}
requestPaint();
return DrawView::execute();
}
示例11: apply
void TaskLinearPatternParameters::apply()
{
std::string name = TransformedView->getObject()->getNameInDocument();
std::string direction = getDirection();
if (!direction.empty()) {
App::DocumentObject* sketch = 0;
if (direction == "H_Axis" || direction == "V_Axis" ||
(direction.size() > 4 && direction.substr(0,4) == "Axis"))
sketch = getSketchObject();
else
sketch = getSupportObject();
if (sketch) {
QString buf = QString::fromLatin1("(App.ActiveDocument.%1,[\"%2\"])");
buf = buf.arg(QString::fromLatin1(sketch->getNameInDocument()));
buf = buf.arg(QString::fromLatin1(direction.c_str()));
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Direction = %s", name.c_str(), buf.toStdString().c_str());
}
} else
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Direction = None", name.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %u",name.c_str(),getReverse());
ui->spinLength->apply();
ui->spinOccurrences->apply();
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
if (!TransformedView->getObject()->isValid())
throw Base::Exception(TransformedView->getObject()->getStatusString());
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
Gui::Command::commitCommand();
}
示例12: apply
void TaskGrooveParameters::apply()
{
App::DocumentObject* groove = GrooveView->getObject();
std::string name = groove->getNameInDocument();
// retrieve sketch and its support object
App::DocumentObject* sketch = 0;
App::DocumentObject* support = 0;
if (groove->getTypeId().isDerivedFrom(PartDesign::Groove::getClassTypeId())) {
sketch = static_cast<PartDesign::Groove*>(groove)->Sketch.getValue<Sketcher::SketchObject*>();
if (sketch) {
support = static_cast<Sketcher::SketchObject*>(sketch)->Support.getValue();
}
}
//Gui::Command::openCommand("Groove changed");
ui->grooveAngle->apply();
std::string axis = getReferenceAxis().toStdString();
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.ReferenceAxis = %s",name.c_str(),axis.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Midplane = %i",name.c_str(), getMidplane() ? 1 : 0);
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %i",name.c_str(), getReversed() ? 1 : 0);
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
if (groove->isValid()) {
if (sketch)
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().hide(\"%s\")",sketch->getNameInDocument());
if (support)
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().hide(\"%s\")",support->getNameInDocument());
}
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
Gui::Command::commitCommand();
}
示例13: unsetupObject
void OriginGroup::unsetupObject () {
App::DocumentObject *origin = Origin.getValue ();
if (origin && !origin->isDeleting ()) {
origin->getDocument ()->remObject (origin->getNameInDocument());
}
GeoFeatureGroup::unsetupObject ();
}
示例14: showObject
void TaskDressUpParameters::showObject()
{
Gui::Document* doc = Gui::Application::Instance->activeDocument();
App::DocumentObject* base = getBase();
if (doc != NULL && base != NULL) {
doc->setShow(DressUpView->getObject()->getNameInDocument());
doc->setHide(base->getNameInDocument());
}
}
示例15: unsetupObject
void Body::unsetupObject () {
App::DocumentObject *origin = Origin.getValue ();
if (origin && !origin->isDeleting ()) {
origin->getDocument ()->remObject (origin->getNameInDocument());
}
Part::BodyBase::unsetupObject ();
}