TechDraw: Extended Draft View

This commit is contained in:
Yorik van Havre
2016-09-14 12:38:34 -03:00
parent 70be035caf
commit 6775227589
7 changed files with 130 additions and 50 deletions

View File

@@ -52,8 +52,12 @@ DrawViewDraft::DrawViewDraft(void)
static const char *group = "Draft view";
ADD_PROPERTY_TYPE(Source ,(0),group,App::Prop_None,"Draft object for this view");
ADD_PROPERTY_TYPE(LineScale,(1.0),group,App::Prop_None,"Line width adjustment factor for this view");
ADD_PROPERTY_TYPE(LineWidth,(0.35),group,App::Prop_None,"Line width of this view");
ADD_PROPERTY_TYPE(FontSize,(12.0),group,App::Prop_None,"Text size for this view");
ADD_PROPERTY_TYPE(Direction ,(0,0,1.0),group,App::Prop_None,"Projection direction. The direction you are looking from.");
ADD_PROPERTY_TYPE(Color,(0.0f,0.0f,0.0f),group,App::Prop_None,"The default color of text and lines");
ADD_PROPERTY_TYPE(LineStyle,("Solid") ,group,App::Prop_None,"A line style to use for this view. Can be Solid, Dashed, Dashdot, Dot or a SVG pattern like 0.20,0.20");
ADD_PROPERTY_TYPE(LineSpacing,(1.0f),group,App::Prop_None,"The spacing between lines to use for multiline texts");
ScaleType.setValue("Custom");
}
@@ -65,8 +69,12 @@ void DrawViewDraft::onChanged(const App::Property* prop)
{
if (!isRestoring()) {
if (prop == &Source ||
prop == &LineScale ||
prop == &FontSize) {
prop == &LineWidth ||
prop == &FontSize ||
prop == &Direction ||
prop == &Color ||
prop == &LineStyle ||
prop == &LineSpacing) {
try {
App::DocumentObjectExecReturn *ret = recompute();
delete ret;
@@ -87,9 +95,20 @@ App::DocumentObjectExecReturn *DrawViewDraft::execute(void)
std::string svgTail = getSVGTail();
std::string FeatName = getNameInDocument();
std::string SourceName = sourceObj->getNameInDocument();
// Draft.getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direction=None,linestyle=None,color=None,linespacing=None,techdraw=False)
std::stringstream paramStr;
paramStr << ",scale=" << LineScale.getValue() << ",fontsize=" << FontSize.getValue();
App::Color col = Color.getValue();
paramStr << ",scale=" << Scale.getValue()
<< ",linewidth=" << LineWidth.getValue()
<< ",fontsize=" << FontSize.getValue()
// TODO treat fillstyle here
<< ",direction=FreeCAD.Vector(" << Direction.getValue().x << "," << Direction.getValue().y << "," << Direction.getValue().z << ")"
<< ",linestyle=\"" << LineStyle.getValue() << "\""
<< ",color=\"" << col.asCSSString() << "\""
<< ",linespacing=" << LineSpacing.getValue()
// We must set techdraw to "true" becausea couple of things behave differently than in Drawing
<< ",techdraw=True";
// this is ok for a starting point, but should eventually make dedicated Draft functions that build the svg for all the special cases
// (Arch section, etc)
@@ -124,7 +143,7 @@ namespace App {
/// @cond DOXERR
PROPERTY_SOURCE_TEMPLATE(TechDraw::DrawViewDraftPython, TechDraw::DrawViewDraft)
template<> const char* TechDraw::DrawViewDraftPython::getViewProviderName(void) const {
return "TechDrawGui::ViewProviderSymbol";
return "TechDrawGui::ViewProviderDraft";
}
/// @endcond