Implement ShowCutSurface

This commit is contained in:
WandererFan 2016-07-09 11:37:55 -04:00 committed by wmayer
parent fc9c4d2bf5
commit 8edfa147da
5 changed files with 417 additions and 379 deletions

View File

@ -77,10 +77,13 @@
#include <boost/concept_check.hpp> #include <boost/concept_check.hpp>
#include <App/Application.h>
#include <App/Material.h>
#include <Base/BoundBox.h> #include <Base/BoundBox.h>
#include <Base/Exception.h> #include <Base/Exception.h>
#include <Base/FileInfo.h> //#include <Base/FileInfo.h>
#include <Base/Console.h> #include <Base/Console.h>
#include <Base/Parameter.h>
#include <Mod/Part/App/PartFeature.h> #include <Mod/Part/App/PartFeature.h>
#include <Mod/Part/App/Geometry.h> #include <Mod/Part/App/Geometry.h>
@ -99,11 +102,17 @@ PROPERTY_SOURCE(TechDraw::DrawViewSection, TechDraw::DrawViewPart)
DrawViewSection::DrawViewSection() DrawViewSection::DrawViewSection()
{ {
static const char *group = "Shape view"; static const char *group = "Section";
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");
App::Color fcColor = App::Color((uint32_t) hGrp->GetUnsigned("CutSurfaceColor", 0xC8C8C800));
ADD_PROPERTY_TYPE(SectionNormal ,(0,0,1.0) ,group,App::Prop_None,"Section Plane normal direction"); ADD_PROPERTY_TYPE(SectionNormal ,(0,0,1.0) ,group,App::Prop_None,"Section Plane normal direction");
ADD_PROPERTY_TYPE(SectionOrigin ,(0,0,0) ,group,App::Prop_None,"Section Plane Origin"); ADD_PROPERTY_TYPE(SectionOrigin ,(0,0,0) ,group,App::Prop_None,"Section Plane Origin");
ADD_PROPERTY_TYPE(ShowCutSurface ,(true),group,App::Prop_None,"Show the cut surface"); ADD_PROPERTY_TYPE(ShowCutSurface ,(true),group,App::Prop_None,"Show the cut surface");
ADD_PROPERTY_TYPE(CutSurfaceColor,(fcColor),group,App::Prop_None,"The color to shade the cut surface");
geometryObject = new TechDrawGeometry::GeometryObject(); geometryObject = new TechDrawGeometry::GeometryObject();
} }
@ -117,7 +126,8 @@ short DrawViewSection::mustExecute() const
// If Tolerance Property is touched // If Tolerance Property is touched
if(SectionNormal.isTouched() || if(SectionNormal.isTouched() ||
SectionOrigin.isTouched() || SectionOrigin.isTouched() ||
ShowCutSurface.isTouched()) ShowCutSurface.isTouched() ||
CutSurfaceColor.isTouched() )
return 1; return 1;
return TechDraw::DrawViewPart::mustExecute(); return TechDraw::DrawViewPart::mustExecute();

View File

@ -54,6 +54,7 @@ public:
App::PropertyVector SectionNormal; App::PropertyVector SectionNormal;
App::PropertyVector SectionOrigin; App::PropertyVector SectionOrigin;
App::PropertyBool ShowCutSurface; App::PropertyBool ShowCutSurface;
App::PropertyColor CutSurfaceColor;
short mustExecute() const; short mustExecute() const;
bool isReallyInBox (const Base::Vector3d v, const Base::BoundBox3d bb) const; bool isReallyInBox (const Base::Vector3d v, const Base::BoundBox3d bb) const;

View File

@ -6,213 +6,20 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>601</width> <width>566</width>
<height>600</height> <height>538</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>TechDraw</string> <string>TechDraw</string>
</property> </property>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>20</x>
<y>30</y>
<width>561</width>
<height>551</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="gb_Colors">
<property name="title">
<string>Colors</string>
</property>
<widget class="QWidget" name="gridLayoutWidget">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>191</width>
<height>128</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="2">
<widget class="Gui::PrefColorButton" name="pcb_Select">
<property name="color">
<color>
<red>28</red>
<green>173</green>
<blue>28</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>SelectColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Colors</cstring>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="Gui::PrefColorButton" name="pcb_Hidden">
<property name="prefEntry" stdset="0">
<cstring>HiddenColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Colors</cstring>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="Gui::PrefColorButton" name="pcb_Normal">
<property name="color">
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>NormalColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Colors</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lbl_PreSelect">
<property name="text">
<string>PreSelected</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_Normal">
<property name="text">
<string>Normal</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="lbl_Hidden">
<property name="text">
<string>Hidden</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lbl_Select">
<property name="text">
<string>Selected</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="Gui::PrefColorButton" name="pcb_PreSelect">
<property name="color">
<color>
<red>255</red>
<green>255</green>
<blue>20</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>PreSelectColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Colors</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QGroupBox" name="gb_Font">
<property name="geometry">
<rect>
<x>0</x>
<y>160</y>
<width>559</width>
<height>91</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Font</string>
</property>
<widget class="QWidget" name="gridLayoutWidget_2">
<property name="geometry">
<rect>
<x>20</x>
<y>30</y>
<width>451</width>
<height>41</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="lbl_LabelFont">
<property name="text">
<string>Label Font</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="Gui::PrefLineEdit" name="le_LabelFont">
<property name="prefEntry" stdset="0">
<cstring>LabelFont</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
<widget class="QGroupBox" name="gb_Templates"> <widget class="QGroupBox" name="gb_Templates">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>20</x>
<y>240</y> <y>250</y>
<width>559</width> <width>531</width>
<height>121</height> <height>108</height>
</rect> </rect>
</property> </property>
<property name="title"> <property name="title">
@ -221,9 +28,9 @@
<widget class="QWidget" name="gridLayoutWidget_3"> <widget class="QWidget" name="gridLayoutWidget_3">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>20</x> <x>10</x>
<y>20</y> <y>30</y>
<width>451</width> <width>501</width>
<height>71</height> <height>71</height>
</rect> </rect>
</property> </property>
@ -268,13 +75,77 @@
</layout> </layout>
</widget> </widget>
</widget> </widget>
<widget class="QGroupBox" name="gb_Font">
<property name="geometry">
<rect>
<x>20</x>
<y>160</y>
<width>541</width>
<height>91</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Font</string>
</property>
<widget class="QWidget" name="gridLayoutWidget_2">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>501</width>
<height>41</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="lbl_LabelFont">
<property name="text">
<string>Label Font</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="Gui::PrefLineEdit" name="le_LabelFont">
<property name="prefEntry" stdset="0">
<cstring>LabelFont</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
<widget class="QGroupBox" name="gbMisc"> <widget class="QGroupBox" name="gbMisc">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>20</x>
<y>350</y> <y>380</y>
<width>551</width> <width>531</width>
<height>181</height> <height>141</height>
</rect> </rect>
</property> </property>
<property name="title"> <property name="title">
@ -283,17 +154,17 @@
<widget class="QWidget" name="gridLayoutWidget_4"> <widget class="QWidget" name="gridLayoutWidget_4">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>20</x> <x>10</x>
<y>30</y> <y>30</y>
<width>531</width> <width>501</width>
<height>103</height> <height>95</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout_4"> <layout class="QFormLayout" name="formLayout">
<item row="1" column="0"> <item row="0" column="0">
<widget class="QLabel" name="lbl_HidLine"> <widget class="QLabel" name="lbl_Angle">
<property name="text"> <property name="text">
<string>Hidden Line</string> <string>Projection Angle</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -317,6 +188,13 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_HidLine">
<property name="text">
<string>Hidden Line</string>
</property>
</widget>
</item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="Gui::PrefComboBox" name="cb_HidLine"> <widget class="Gui::PrefComboBox" name="cb_HidLine">
<property name="prefEntry" stdset="0"> <property name="prefEntry" stdset="0">
@ -352,28 +230,14 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="0" column="0"> <item row="2" column="0">
<widget class="QLabel" name="lbl_Angle"> <widget class="QLabel" name="lbl_Hatch">
<property name="text"> <property name="text">
<string>Projection Angle</string> <string>Default Pattern File</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> <item row="2" column="1">
</widget>
<widget class="QWidget" name="gridLayoutWidget_5">
<property name="geometry">
<rect>
<x>20</x>
<y>130</y>
<width>531</width>
<height>54</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="1">
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="1">
<widget class="Gui::PrefFileChooser" name="pfc_HatchFile"> <widget class="Gui::PrefFileChooser" name="pfc_HatchFile">
<property name="prefEntry" stdset="0"> <property name="prefEntry" stdset="0">
<cstring>PatternFile</cstring> <cstring>PatternFile</cstring>
@ -383,10 +247,173 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0"> </layout>
<widget class="QLabel" name="lbl_Hatch"> </widget>
</widget>
<widget class="QGroupBox" name="gb_Colors">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>531</width>
<height>141</height>
</rect>
</property>
<property name="title">
<string>Colors</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QLabel" name="lbl_Select">
<property name="text"> <property name="text">
<string>Default Pattern File</string> <string>Selected</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="Gui::PrefColorButton" name="pcb_PreSelect">
<property name="color">
<color>
<red>255</red>
<green>255</green>
<blue>20</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>PreSelectColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Colors</cstring>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lbl_Normal">
<property name="text">
<string>Normal</string>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="Gui::PrefColorButton" name="pcb_Hidden">
<property name="prefEntry" stdset="0">
<cstring>HiddenColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Colors</cstring>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="Gui::PrefColorButton" name="pcb_Select">
<property name="color">
<color>
<red>28</red>
<green>173</green>
<blue>28</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>SelectColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Colors</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="5">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="4">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Section Face</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="Gui::PrefColorButton" name="pcb_Normal">
<property name="color">
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>NormalColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Colors</cstring>
</property>
</widget>
</item>
<item row="0" column="3">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_PreSelect">
<property name="text">
<string>PreSelected</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="lbl_Hidden">
<property name="text">
<string>Hidden</string>
</property>
</widget>
</item>
<item row="1" column="6">
<widget class="Gui::PrefColorButton" name="pcb_Surface">
<property name="color">
<color>
<red>225</red>
<green>225</green>
<blue>225</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>CutSurfaceColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Colors</cstring>
</property> </property>
</widget> </widget>
</item> </item>
@ -395,11 +422,6 @@
</layout> </layout>
</widget> </widget>
</widget> </widget>
</widget>
</item>
</layout>
</widget>
</widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>
<class>Gui::FileChooser</class> <class>Gui::FileChooser</class>

View File

@ -47,6 +47,7 @@ void DlgPrefsTechDrawImp::saveSettings()
pcb_Select->onSave(); pcb_Select->onSave();
pcb_PreSelect->onSave(); pcb_PreSelect->onSave();
pcb_Hidden->onSave(); pcb_Hidden->onSave();
pcb_Surface->onSave();
le_LabelFont->onSave(); le_LabelFont->onSave();
pfc_DefTemp->onSave(); pfc_DefTemp->onSave();
pfc_DefDir->onSave(); pfc_DefDir->onSave();
@ -62,6 +63,7 @@ void DlgPrefsTechDrawImp::loadSettings()
pcb_Select->onRestore(); pcb_Select->onRestore();
pcb_PreSelect->onRestore(); pcb_PreSelect->onRestore();
pcb_Hidden->onRestore(); pcb_Hidden->onRestore();
pcb_Surface->onRestore();
le_LabelFont->onRestore(); le_LabelFont->onRestore();
pfc_DefTemp->onRestore(); pfc_DefTemp->onRestore();
pfc_DefDir->onRestore(); pfc_DefDir->onRestore();

View File

@ -67,6 +67,10 @@ void QGIViewSection::drawSectionFace()
return; return;
} }
if (!section->ShowCutSurface.getValue()) {
return;
}
std::vector<TechDrawGeometry::Face*> sectionFaces; std::vector<TechDrawGeometry::Face*> sectionFaces;
sectionFaces = section->getFaceGeometry(); sectionFaces = section->getFaceGeometry();
if (sectionFaces.empty()) { if (sectionFaces.empty()) {
@ -74,8 +78,7 @@ void QGIViewSection::drawSectionFace()
return; return;
} }
std::vector<TechDrawGeometry::Face *>::iterator fit = sectionFaces.begin(); std::vector<TechDrawGeometry::Face *>::iterator fit = sectionFaces.begin();
QColor faceColor(0,0,255,40); //temp. sb preference or property. transparency allows bleed through/colour mix. QColor faceColor = section->CutSurfaceColor.getValue().asValue<QColor>();
//QColor faceColor(170,170,255); //temp. sb preference or property.
for(; fit != sectionFaces.end(); fit++) { for(; fit != sectionFaces.end(); fit++) {
QGIFace* newFace = drawFace(*fit,-1); //TODO: do we need to know which sectionFace this QGIFace came from? QGIFace* newFace = drawFace(*fit,-1); //TODO: do we need to know which sectionFace this QGIFace came from?
newFace->setZValue(ZVALUE::SECTIONFACE); newFace->setZValue(ZVALUE::SECTIONFACE);