MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / execute

Method execute

src/Mod/TechDraw/App/DrawViewDraft.cpp:78–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76
77
78App::DocumentObjectExecReturn *DrawViewDraft::execute()
79{
80// Base::Console().message("DVDr::execute() \n");
81 if (!keepUpdated()) {
82 return App::DocumentObject::StdReturn;
83 }
84
85 App::DocumentObject* sourceObj = Source.getValue();
86 if (sourceObj) {
87 std::string svgFrag;
88 std::string svgHead = getSVGHead();
89 std::string svgTail = getSVGTail();
90 std::string FeatName = getNameInDocument();
91 std::string SourceName = sourceObj->getNameInDocument();
92 // Draft.get_svg(obj, scale=1, linewidth=0.35, fontsize=12, fillstyle="shape color", direction=None, linestyle=None, color=None, linespacing=None, techdraw=False)
93
94 std::stringstream paramStr;
95 Base::Color col = Color.getValue();
96 paramStr << ", scale=" << getScale()
97 << ", linewidth=" << LineWidth.getValue()
98 << ", fontsize=" << FontSize.getValue()
99 // TODO treat fillstyle here
100 << ", direction=FreeCAD.Vector(" << Direction.getValue().x << ", " << Direction.getValue().y << ", " << Direction.getValue().z << ")"
101 << ", linestyle=\"" << LineStyle.getValue() << "\""
102 << ", color=\"" << col.asHexString() << "\""
103 << ", linespacing=" << LineSpacing.getValue()
104 // We must set techdraw to "true" becausea couple of things behave differently than in Drawing
105 << ", techdraw=True"
106 << ", override=" << (OverrideStyle.getValue() ? "True" : "False");
107
108// this is ok for a starting point, but should eventually make dedicated Draft functions that build the svg for all the special cases
109// (Arch section, etc)
110// like Draft.makeDrawingView, but we don't need to create the actual document objects in Draft, just the svg.
111 Base::Interpreter().runString("import Draft");
112 Base::Interpreter().runStringArg("svgBody = Draft.get_svg(App.activeDocument().%s %s)",
113 SourceName.c_str(), paramStr.str().c_str());
114// Base::Interpreter().runString("print svgBody");
115 Base::Interpreter().runStringArg("App.activeDocument().%s.Symbol = '%s' + svgBody + '%s'",
116 FeatName.c_str(), svgHead.c_str(), svgTail.c_str());
117 }
118
119 overrideKeepUpdated(false);
120 return DrawView::execute();
121}
122
123std::string DrawViewDraft::getSVGHead()
124{

Callers

nothing calls this directly

Calls 10

overrideKeepUpdatedFunction · 0.85
asHexStringMethod · 0.80
runStringMethod · 0.80
runStringArgMethod · 0.80
getScaleFunction · 0.50
executeFunction · 0.50
getValueMethod · 0.45
getNameInDocumentMethod · 0.45
c_strMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected