VPart/VSection Graphic Properties to Gui side

This commit is contained in:
WandererFan
2018-02-14 09:06:36 -05:00
parent 78f4d91b95
commit 99fcba4992
11 changed files with 141 additions and 96 deletions

View File

@@ -57,6 +57,7 @@
#include "DrawViewPartPy.h"
#include "GeometryObject.h"
#include "EdgeWalker.h"
#include "DrawUtil.h"
namespace TechDraw {
@@ -380,7 +381,8 @@ private:
TechDrawGeometry::GeometryObject* go = dvp->getGeometryObject();
//visible group begin "<g ... >"
ss << grpHead1;
double thick = dvp->LineWidth.getValue();
// double thick = dvp->LineWidth.getValue();
double thick = DrawUtil::getDefaultLineWeight("Thick");
ss << thick;
ss << grpHead2;
TopoDS_Shape s = go->getVisHard();
@@ -403,7 +405,8 @@ private:
dvp->SeamHidden.getValue() ) {
//hidden group begin
ss << grpHead1;
thick = dvp->HiddenWidth.getValue();
// thick = dvp->HiddenWidth.getValue();
thick = DrawUtil::getDefaultLineWeight("Thin");
ss << thick;
ss << grpHead2;
if (dvp->HardHidden.getValue()) {

View File

@@ -425,6 +425,17 @@ double DrawUtil::sensibleScale(double working_scale)
return result;
}
double DrawUtil::getDefaultLineWeight(std::string lineType)
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
std::string lgName = hGrp->GetASCII("LineGroup","FC 0.70mm");
auto lg = LineGroup::lineGroupFactory(lgName);
double weight = lg->getWeight(lineType);
return weight;
}
//============================
// various debugging routines.
void DrawUtil::dumpVertexes(const char* text, const TopoDS_Shape& s)

View File

@@ -40,6 +40,8 @@
#include <Base/Vector3D.h>
#include <Base/Matrix.h>
#include "LineGroup.h"
#define VERTEXTOLERANCE (2.0 * Precision::Confusion())
namespace TechDraw
@@ -72,6 +74,7 @@ class TechDrawExport DrawUtil {
Base::Vector3d axis,
Base::Vector3d org = Base::Vector3d(0.0,0.0,0.0));
static Base::Vector3d closestBasis(Base::Vector3d v);
static double getDefaultLineWeight(std::string s);

View File

@@ -71,8 +71,7 @@ DrawView::DrawView(void)
: autoPos(true),
mouseMove(false)
{
static const char *group = "BaseView";
static const char *fgroup = "Format";
static const char *group = "Base";
ADD_PROPERTY_TYPE(X ,(0),group,App::Prop_None,"X position of the view on the page in modelling units (mm)");
ADD_PROPERTY_TYPE(Y ,(0),group,App::Prop_None,"Y position of the view on the page in modelling units (mm)");
@@ -84,7 +83,7 @@ DrawView::DrawView(void)
ADD_PROPERTY_TYPE(Scale ,(1.0),group,App::Prop_None,"Scale factor of the view");
Scale.setConstraints(&scaleRange);
ADD_PROPERTY_TYPE(Caption ,(""),fgroup,App::Prop_None,"Short text about the view");
ADD_PROPERTY_TYPE(Caption ,(""),group,App::Prop_None,"Short text about the view");
}
DrawView::~DrawView()

View File

@@ -118,14 +118,12 @@ PROPERTY_SOURCE(TechDraw::DrawViewPart, TechDraw::DrawView)
DrawViewPart::DrawViewPart(void) : geometryObject(0)
{
static const char *group = "Projection";
static const char *fgroup = "Format";
static const char *lgroup = "Lines";
static const char *sgroup = "Show";
static const char *sgroup = "HLR Parameters";
nowUnsetting = false;
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
double defDist = hGrp->GetFloat("FocusDistance",100.0);
bool coarseView = hGrp->GetBool("CoarseView", false);
//properties that affect Geometry
ADD_PROPERTY_TYPE(Source ,(0),group,App::Prop_None,"3D Shape to view");
@@ -134,7 +132,8 @@ DrawViewPart::DrawViewPart(void) : geometryObject(0)
ADD_PROPERTY_TYPE(Perspective ,(false),group,App::Prop_None,"Perspective(true) or Orthographic(false) projection");
ADD_PROPERTY_TYPE(Focus,(defDist),group,App::Prop_None,"Perspective view focus distance");
//properties that affect Appearance
//properties that control HLR algoaffect Appearance
bool coarseView = hGrp->GetBool("CoarseView", false);
ADD_PROPERTY_TYPE(CoarseView, (coarseView), sgroup, App::Prop_None, "Coarse View on/off");
//visible outline
ADD_PROPERTY_TYPE(SmoothVisible ,(false),sgroup,App::Prop_None,"Visible Smooth lines on/off");
@@ -145,33 +144,9 @@ DrawViewPart::DrawViewPart(void) : geometryObject(0)
ADD_PROPERTY_TYPE(SeamHidden ,(false),sgroup,App::Prop_None,"Hidden Seam lines on/off");
ADD_PROPERTY_TYPE(IsoHidden ,(false),sgroup,App::Prop_None,"Hidden Iso u,v lines on/off");
ADD_PROPERTY_TYPE(IsoCount ,(0),sgroup,App::Prop_None,"Number of isoparameters");
//default line weights
hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
std::string lgName = hGrp->GetASCII("LineGroup","FC 0.70mm");
auto lg = LineGroup::lineGroupFactory(lgName);
double weight = lg->getWeight("Thick");
ADD_PROPERTY_TYPE(LineWidth,(weight),lgroup,App::Prop_None,"The thickness of visible lines");
weight = lg->getWeight("Thin");
ADD_PROPERTY_TYPE(HiddenWidth,(weight),lgroup,App::Prop_None,"The thickness of hidden lines, if enabled");
weight = lg->getWeight("Graphic");
ADD_PROPERTY_TYPE(IsoWidth,(weight),lgroup,App::Prop_None,"The thickness of isoparameter/center/section lines, if enabled");
weight = lg->getWeight("Extra");
ADD_PROPERTY_TYPE(ExtraWidth,(weight),lgroup,App::Prop_None,"The thickness of LineGroup Extra lines, if enabled");
ADD_PROPERTY_TYPE(HorizCenterLine ,(false),lgroup,App::Prop_None,"Show a horizontal centerline through view");
ADD_PROPERTY_TYPE(VertCenterLine ,(false),lgroup,App::Prop_None,"Show a vertical centerline through view");
ADD_PROPERTY_TYPE(ArcCenterMarks ,(true),sgroup,App::Prop_None,"Center marks on/off");
ADD_PROPERTY_TYPE(CenterScale,(2.0),fgroup,App::Prop_None,"Center mark size adjustment, if enabled");
//properties that affect Section Line
ADD_PROPERTY_TYPE(ShowSectionLine ,(true) ,sgroup,App::Prop_None,"Show/hide section line if applicable");
geometryObject = nullptr;
getRunControl();
delete lg;
}
DrawViewPart::~DrawViewPart()
@@ -306,7 +281,18 @@ short DrawViewPart::mustExecute() const
result = (Direction.isTouched() ||
Source.isTouched() ||
Scale.isTouched() ||
ScaleType.isTouched());
ScaleType.isTouched() ||
Perspective.isTouched() ||
Focus.isTouched() ||
SmoothVisible.isTouched() ||
SeamVisible.isTouched() ||
IsoVisible.isTouched() ||
HardHidden.isTouched() ||
SmoothHidden.isTouched() ||
SeamHidden.isTouched() ||
IsoHidden.isTouched() ||
IsoCount.isTouched() ||
CoarseView.isTouched());
}
if (result) {

View File

@@ -100,17 +100,6 @@ public:
App::PropertyBool IsoHidden;
App::PropertyInteger IsoCount;
App::PropertyFloat LineWidth;
App::PropertyFloat HiddenWidth;
App::PropertyFloat IsoWidth;
App::PropertyFloat ExtraWidth;
App::PropertyBool ArcCenterMarks;
App::PropertyFloat CenterScale;
App::PropertyBool HorizCenterLine;
App::PropertyBool VertCenterLine;
App::PropertyBool ShowSectionLine;
std::vector<TechDraw::DrawHatch*> getHatches(void) const;
std::vector<TechDraw::DrawGeomHatch*> getGeomHatches(void) const;
std::vector<TechDraw::DrawViewDimension*> getDimensions() const;

View File

@@ -104,8 +104,7 @@ PROPERTY_SOURCE(TechDraw::DrawViewSection, TechDraw::DrawViewPart)
DrawViewSection::DrawViewSection()
{
static const char *sgroup = "Section";
static const char *fgroup = "Format";
//static const char *lgroup = "Line";
static const char *fgroup = "Cut Surface Format";
ADD_PROPERTY_TYPE(SectionSymbol ,("A"),sgroup,App::Prop_None,"The identifier for this section");
@@ -119,14 +118,6 @@ DrawViewSection::DrawViewSection()
ADD_PROPERTY_TYPE(NameGeomPattern ,(""),fgroup,App::Prop_None,"The pattern name for geometric hatching");
ADD_PROPERTY_TYPE(HatchScale,(1.0),fgroup,App::Prop_None,"Hatch pattern size adjustment");
// ADD_PROPERTY_TYPE(ShowCutSurface ,(true),fgroup,App::Prop_None,"Show/hide the cut surface");
// ADD_PROPERTY_TYPE(CutSurfaceColor,(0.0,0.0,0.0),fgroup,App::Prop_None,"The color to shade the cut surface");
// ADD_PROPERTY_TYPE(HatchCutSurface ,(false),fgroup,App::Prop_None,"Hatch the cut surface");
// ADD_PROPERTY_TYPE(FileHatchPattern ,(""),fgroup,App::Prop_None,"The hatch pattern file for the cut surface");
// ADD_PROPERTY_TYPE(NameGeomPattern ,(""),fgroup,App::Prop_None,"The pattern name for geometric hatching");
// ADD_PROPERTY_TYPE(HatchColor,(0.0,0.0,0.0),fgroup,App::Prop_None,"The color of the hatch pattern");
getParameters();
}

View File

@@ -71,6 +71,7 @@
#include "QGIViewPart.h"
#include "ViewProviderGeomHatch.h"
#include "ViewProviderHatch.h"
#include "ViewProviderViewPart.h"
using namespace TechDrawGui;
using namespace TechDrawGeometry;
@@ -308,10 +309,13 @@ void QGIViewPart::updateView(bool update)
if( viewPart == nullptr ) {
return;
}
auto vp = static_cast<ViewProviderViewPart*>(getViewProvider(getViewObject()));
if ( vp == nullptr ) {
return;
}
QGIView::updateView(update);
if (update ||
viewPart->isTouched() ||
viewPart->Source.isTouched() ||
@@ -325,21 +329,18 @@ void QGIViewPart::updateView(bool update)
viewPart->SmoothHidden.isTouched() ||
viewPart->SeamHidden.isTouched() ||
viewPart->IsoHidden.isTouched() ||
viewPart->IsoCount.isTouched() ||
viewPart->ShowSectionLine.isTouched() ||
viewPart->HorizCenterLine.isTouched() ||
viewPart->VertCenterLine.isTouched() ) {
viewPart->IsoCount.isTouched() ) {
draw();
} else if (update ||
viewPart->LineWidth.isTouched() ||
viewPart->HiddenWidth.isTouched()) {
vp->LineWidth.isTouched() ||
vp->HiddenWidth.isTouched()) {
QList<QGraphicsItem*> items = childItems();
for(QList<QGraphicsItem*>::iterator it = items.begin(); it != items.end(); ++it) {
QGIEdge *edge = dynamic_cast<QGIEdge *>(*it);
if(edge && edge->getHiddenEdge()) {
edge->setWidth(viewPart->HiddenWidth.getValue() * lineScaleFactor);
edge->setWidth(vp->HiddenWidth.getValue() * lineScaleFactor);
} else if (edge){
edge->setWidth(viewPart->LineWidth.getValue() * lineScaleFactor);
edge->setWidth(vp->LineWidth.getValue() * lineScaleFactor);
}
}
draw();
@@ -363,10 +364,16 @@ void QGIViewPart::drawViewPart()
if (!viewPart->hasGeometry()) {
return;
}
auto vp = static_cast<ViewProviderViewPart*>(getViewProvider(getViewObject()));
if ( vp == nullptr ) {
return;
}
float lineWidth = viewPart->LineWidth.getValue() * lineScaleFactor;
float lineWidthHid = viewPart->HiddenWidth.getValue() * lineScaleFactor;
float lineWidthIso = viewPart->IsoWidth.getValue() * lineScaleFactor;
float lineWidth = vp->LineWidth.getValue() * lineScaleFactor;
float lineWidthHid = vp->HiddenWidth.getValue() * lineScaleFactor;
float lineWidthIso = vp->IsoWidth.getValue() * lineScaleFactor;
// float lineWidthExtra = viewPart->ExtraWidth.getValue() * lineScaleFactor;
prepareGeometryChange();
@@ -485,8 +492,8 @@ void QGIViewPart::drawViewPart()
bool usePolygonHLR = viewPart->CoarseView.getValue();
const std::vector<TechDrawGeometry::Vertex *> &verts = viewPart->getVertexGeometry();
std::vector<TechDrawGeometry::Vertex *>::const_iterator vert = verts.begin();
bool showCenters = viewPart->ArcCenterMarks.getValue();
double cAdjust = viewPart->CenterScale.getValue();
bool showCenters = vp->ArcCenterMarks.getValue();
double cAdjust = vp->CenterScale.getValue();
for(int i = 0 ; vert != verts.end(); ++vert, i++) {
if ((*vert)->isCenter) {
if (showCenters) {
@@ -506,7 +513,7 @@ void QGIViewPart::drawViewPart()
}
}
//draw section line
if (viewPart->ShowSectionLine.getValue()) {
if (vp->ShowSectionLine.getValue()) {
auto refs = viewPart->getSectionRefs();
for (auto& r:refs) {
drawSectionLine(r, true);
@@ -601,7 +608,12 @@ void QGIViewPart::drawSectionLine(TechDraw::DrawViewSection* viewSection, bool b
if (!viewSection->hasGeometry()) {
return;
}
auto vp = static_cast<ViewProviderViewPart*>(getViewProvider(getViewObject()));
if ( vp == nullptr ) {
return;
}
if (b) {
QGISectionLine* sectionLine = new QGISectionLine();
addToGroup(sectionLine);
@@ -652,7 +664,7 @@ void QGIViewPart::drawSectionLine(TechDraw::DrawViewSection* viewSection, bool b
yVal = sectionSpan / 2.0;
}
sectionLine->setBounds(-xVal,-yVal,xVal,yVal);
sectionLine->setWidth(Rez::guiX(viewPart->IsoWidth.getValue()));
sectionLine->setWidth(Rez::guiX(vp->IsoWidth.getValue()));
sectionLine->setFont(m_font,Rez::guiX(6.0));
sectionLine->setZValue(ZVALUE::SECTIONLINE);
sectionLine->setRotation(viewPart->Rotation.getValue());
@@ -665,11 +677,16 @@ void QGIViewPart::drawCenterLines(bool b)
TechDraw::DrawViewPart *viewPart = dynamic_cast<TechDraw::DrawViewPart *>(getViewObject());
if (!viewPart) {
return;
}
auto vp = static_cast<ViewProviderViewPart*>(getViewProvider(getViewObject()));
if ( vp == nullptr ) {
return;
}
if (b) {
bool horiz = viewPart->HorizCenterLine.getValue();
bool vert = viewPart->VertCenterLine.getValue();
bool horiz = vp->HorizCenterLine.getValue();
bool vert = vp->VertCenterLine.getValue();
QGICenterLine* centerLine;
double sectionSpan;
@@ -683,7 +700,7 @@ void QGIViewPart::drawCenterLines(bool b)
xVal = sectionSpan / 2.0;
yVal = 0.0;
centerLine->setBounds(-xVal,-yVal,xVal,yVal);
centerLine->setWidth(Rez::guiX(viewPart->IsoWidth.getValue()));
centerLine->setWidth(Rez::guiX(vp->IsoWidth.getValue()));
centerLine->setZValue(ZVALUE::SECTIONLINE);
centerLine->setRotation(viewPart->Rotation.getValue());
centerLine->draw();
@@ -696,7 +713,7 @@ void QGIViewPart::drawCenterLines(bool b)
xVal = 0.0;
yVal = sectionSpan / 2.0;
centerLine->setBounds(-xVal,-yVal,xVal,yVal);
centerLine->setWidth(Rez::guiX(viewPart->IsoWidth.getValue()));
centerLine->setWidth(Rez::guiX(vp->IsoWidth.getValue()));
centerLine->setZValue(ZVALUE::SECTIONLINE);
centerLine->setRotation(viewPart->Rotation.getValue());
centerLine->draw();
@@ -716,6 +733,11 @@ void QGIViewPart::drawHighlight(TechDraw::DrawViewDetail* viewDetail, bool b)
return;
}
auto vp = static_cast<ViewProviderViewPart*>(getViewProvider(getViewObject()));
if ( vp == nullptr ) {
return;
}
if (b) {
QGIHighlight* highlight = new QGIHighlight();
addToGroup(highlight);
@@ -724,7 +746,7 @@ void QGIViewPart::drawHighlight(TechDraw::DrawViewDetail* viewDetail, bool b)
Base::Vector3d center = viewDetail->AnchorPoint.getValue() * viewPart->getScale();
double radius = viewDetail->Radius.getValue() * viewPart->getScale();
highlight->setBounds(center.x - radius, center.y + radius,center.x + radius, center.y - radius);
highlight->setWidth(Rez::guiX(viewPart->IsoWidth.getValue()));
highlight->setWidth(Rez::guiX(vp->IsoWidth.getValue()));
highlight->setFont(m_font,Rez::guiX(6.0));
highlight->setZValue(ZVALUE::HIGHLIGHT);
highlight->draw();

View File

@@ -40,6 +40,7 @@
#include <Mod/TechDraw/App/DrawViewMulti.h>
#include <Mod/TechDraw/App/DrawHatch.h>
#include <Mod/TechDraw/App/DrawGeomHatch.h>
#include <Mod/TechDraw/App/LineGroup.h>
#include<Mod/TechDraw/App/DrawPage.h>
#include "ViewProviderViewPart.h"
@@ -54,6 +55,32 @@ PROPERTY_SOURCE(TechDrawGui::ViewProviderViewPart, TechDrawGui::ViewProviderDraw
ViewProviderViewPart::ViewProviderViewPart()
{
sPixmap = "TechDraw_Tree_View";
static const char *group = "Lines";
static const char *dgroup = "Decoration";
//default line weights
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
std::string lgName = hGrp->GetASCII("LineGroup","FC 0.70mm");
auto lg = TechDraw::LineGroup::lineGroupFactory(lgName);
double weight = lg->getWeight("Thick");
ADD_PROPERTY_TYPE(LineWidth,(weight),group,App::Prop_None,"The thickness of visible lines");
weight = lg->getWeight("Thin");
ADD_PROPERTY_TYPE(HiddenWidth,(weight),group,App::Prop_None,"The thickness of hidden lines, if enabled");
weight = lg->getWeight("Graphic");
ADD_PROPERTY_TYPE(IsoWidth,(weight),group,App::Prop_None,"The thickness of isoparameter/center/section lines, if enabled");
weight = lg->getWeight("Extra");
ADD_PROPERTY_TYPE(ExtraWidth,(weight),group,App::Prop_None,"The thickness of LineGroup Extra lines, if enabled");
//decorations
ADD_PROPERTY_TYPE(HorizCenterLine ,(false),dgroup,App::Prop_None,"Show a horizontal centerline through view");
ADD_PROPERTY_TYPE(VertCenterLine ,(false),dgroup,App::Prop_None,"Show a vertical centerline through view");
ADD_PROPERTY_TYPE(ArcCenterMarks ,(true),dgroup,App::Prop_None,"Center marks on/off");
ADD_PROPERTY_TYPE(CenterScale,(2.0),dgroup,App::Prop_None,"Center mark size adjustment, if enabled");
//properties that affect Section Line
ADD_PROPERTY_TYPE(ShowSectionLine ,(true) ,dgroup,App::Prop_None,"Show/hide section line if applicable");
}
ViewProviderViewPart::~ViewProviderViewPart()
@@ -63,13 +90,21 @@ ViewProviderViewPart::~ViewProviderViewPart()
void ViewProviderViewPart::updateData(const App::Property* prop)
{
if (prop == &(getViewObject()->LineWidth) ||
prop == &(getViewObject()->HiddenWidth) ||
prop == &(getViewObject()->ArcCenterMarks) ||
prop == &(getViewObject()->CenterScale) ||
prop == &(getViewObject()->ShowSectionLine) ||
prop == &(getViewObject()->HorizCenterLine) ||
prop == &(getViewObject()->VertCenterLine) ) {
ViewProviderDrawingView::updateData(prop);
}
void ViewProviderViewPart::onChanged(const App::Property* prop)
{
if (prop == &(LineWidth) ||
prop == &(HiddenWidth) ||
prop == &(IsoWidth) ||
prop == &(ExtraWidth) ||
prop == &(ArcCenterMarks) ||
prop == &(CenterScale) ||
prop == &(ShowSectionLine) ||
prop == &(HorizCenterLine) ||
prop == &(VertCenterLine) ) {
// redraw QGIVP
QGIView* qgiv = getQView();
if (qgiv) {
@@ -77,12 +112,6 @@ void ViewProviderViewPart::updateData(const App::Property* prop)
}
}
ViewProviderDrawingView::updateData(prop);
}
void ViewProviderViewPart::onChanged(const App::Property* prop)
{
ViewProviderDrawingView::onChanged(prop);
}
@@ -94,8 +123,6 @@ void ViewProviderViewPart::attach(App::DocumentObject *pcFeat)
sPixmap = "TechDraw_Tree_Multi";
}
// call parent attach method
// ViewProviderDocumentObject::attach(pcFeat);
ViewProviderDrawingView::attach(pcFeat);
}

View File

@@ -24,6 +24,10 @@
#ifndef DRAWINGGUI_VIEWPROVIDERVIEWPART_H
#define DRAWINGGUI_VIEWPROVIDERVIEWPART_H
#include <App/PropertyLinks.h>
#include <App/PropertyStandard.h>
#include <App/PropertyUnits.h>
#include "ViewProviderDrawingView.h"
#include <Mod/TechDraw/App/DrawView.h>
#include <Mod/TechDraw/App/DrawViewPart.h>
@@ -40,6 +44,16 @@ public:
/// destructor
virtual ~ViewProviderViewPart();
App::PropertyFloat LineWidth;
App::PropertyFloat HiddenWidth;
App::PropertyFloat IsoWidth;
App::PropertyFloat ExtraWidth;
App::PropertyBool ArcCenterMarks;
App::PropertyFloat CenterScale;
App::PropertyBool HorizCenterLine;
App::PropertyBool VertCenterLine;
App::PropertyBool ShowSectionLine;
virtual void attach(App::DocumentObject *);
virtual void setDisplayMode(const char* ModeName);
virtual bool useNewSelectionModel(void) const {return false;}

View File

@@ -48,8 +48,8 @@ PROPERTY_SOURCE(TechDrawGui::ViewProviderViewSection, TechDrawGui::ViewProviderV
ViewProviderViewSection::ViewProviderViewSection()
{
static const char *sgroup = "Surface";
static const char *hgroup = "Hatch";
static const char *sgroup = "Cut Surface";
static const char *hgroup = "Surface Hatch";
sPixmap = "TechDraw_Tree_Section";
ADD_PROPERTY_TYPE(ShowCutSurface ,(true),sgroup,App::Prop_None,"Show/hide the cut surface");
ADD_PROPERTY_TYPE(CutSurfaceColor,(0.0,0.0,0.0),sgroup,App::Prop_None,"The color to shade the cut surface");