VPart/VSection Graphic Properties to Gui side

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

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");