add/extend helper classes to savely access document, document objects or view providers
This commit is contained in:
@@ -46,6 +46,11 @@ DocumentT::DocumentT(Document* doc)
|
||||
document = doc->getName();
|
||||
}
|
||||
|
||||
DocumentT::DocumentT(const std::string& name)
|
||||
{
|
||||
document = name;
|
||||
}
|
||||
|
||||
DocumentT::~DocumentT()
|
||||
{
|
||||
}
|
||||
@@ -62,6 +67,11 @@ void DocumentT::operator=(const Document* doc)
|
||||
document = doc->getName();
|
||||
}
|
||||
|
||||
void DocumentT::operator=(const std::string& name)
|
||||
{
|
||||
document = name;
|
||||
}
|
||||
|
||||
Document* DocumentT::getDocument() const
|
||||
{
|
||||
return GetApplication().getDocument(document.c_str());
|
||||
@@ -77,10 +87,10 @@ std::string DocumentT::getDocumentPython() const
|
||||
std::stringstream str;
|
||||
Document* doc = GetApplication().getActiveDocument();
|
||||
if (doc && document == doc->getName()) {
|
||||
str << "FreeCAD.ActiveDocument";
|
||||
str << "App.ActiveDocument";
|
||||
}
|
||||
else {
|
||||
str << "FreeCAD.getDocument(\""
|
||||
str << "App.getDocument(\""
|
||||
<< document
|
||||
<< "\")";
|
||||
}
|
||||
@@ -135,10 +145,10 @@ std::string DocumentObjectT::getDocumentPython() const
|
||||
std::stringstream str;
|
||||
Document* doc = GetApplication().getActiveDocument();
|
||||
if (doc && document == doc->getName()) {
|
||||
str << "FreeCAD.ActiveDocument";
|
||||
str << "App.ActiveDocument";
|
||||
}
|
||||
else {
|
||||
str << "FreeCAD.getDocument(\""
|
||||
str << "App.getDocument(\""
|
||||
<< document
|
||||
<< "\")";
|
||||
}
|
||||
@@ -170,10 +180,10 @@ std::string DocumentObjectT::getObjectPython() const
|
||||
std::stringstream str;
|
||||
Document* doc = GetApplication().getActiveDocument();
|
||||
if (doc && document == doc->getName()) {
|
||||
str << "FreeCAD.ActiveDocument.";
|
||||
str << "App.ActiveDocument.";
|
||||
}
|
||||
else {
|
||||
str << "FreeCAD.getDocument(\""
|
||||
str << "App.getDocument(\""
|
||||
<< document
|
||||
<< "\").";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user