[TD]add alignment grid to page

This commit is contained in:
Wanderer Fan
2022-02-27 14:34:35 -05:00
committed by WandererFan
parent 6a606783d6
commit eb4a5384c0
12 changed files with 501 additions and 274 deletions
+9 -7
View File
@@ -28,6 +28,8 @@
#ifndef TECHDRAW_EDGEWALKER_H #ifndef TECHDRAW_EDGEWALKER_H
#define TECHDRAW_EDGEWALKER_H #define TECHDRAW_EDGEWALKER_H
#include <Mod/TechDraw/TechDrawGlobal.h>
#include <vector> #include <vector>
#include <boost_graph_adjacency_list.hpp> #include <boost_graph_adjacency_list.hpp>
#include <boost/graph/properties.hpp> #include <boost/graph/properties.hpp>
@@ -72,7 +74,7 @@ typedef
> >
planar_embedding_t; planar_embedding_t;
class WalkerEdge class TechDrawExport WalkerEdge
{ {
public: public:
static bool weCompare(WalkerEdge i, WalkerEdge j); static bool weCompare(WalkerEdge i, WalkerEdge j);
@@ -85,7 +87,7 @@ public:
int idx; int idx;
}; };
class ewWire class TechDrawExport ewWire
{ {
public: public:
bool isEqual(ewWire w); bool isEqual(ewWire w);
@@ -96,7 +98,7 @@ public:
int size(void); int size(void);
}; };
class ewWireList class TechDrawExport ewWireList
{ {
public: public:
ewWireList removeDuplicateWires(); ewWireList removeDuplicateWires();
@@ -108,7 +110,7 @@ public:
class edgeVisitor : public boost::planar_face_traversal_visitor class TechDrawExport edgeVisitor : public boost::planar_face_traversal_visitor
{ {
public: public:
template <typename Edge> template <typename Edge>
@@ -124,7 +126,7 @@ private:
TechDraw::graph m_g; TechDraw::graph m_g;
}; };
class incidenceItem class TechDrawExport incidenceItem
{ {
public: public:
incidenceItem() {iEdge = 0; angle = 0.0;} incidenceItem() {iEdge = 0; angle = 0.0;}
@@ -137,7 +139,7 @@ public:
edge_t eDesc; edge_t eDesc;
}; };
class embedItem class TechDrawExport embedItem
{ {
public: public:
embedItem(); embedItem();
@@ -152,7 +154,7 @@ public:
}; };
class EdgeWalker class TechDrawExport EdgeWalker
{ {
public: public:
EdgeWalker(void); EdgeWalker(void);
+265 -241
View File
@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>440</width> <width>440</width>
<height>342</height> <height>368</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@@ -49,115 +49,6 @@
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="lbl_Normal">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Normal</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Gui::PrefColorButton" name="pcb_Normal">
<property name="toolTip">
<string>Normal line color</string>
</property>
<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="2">
<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="0" column="3">
<widget class="QLabel" name="lbl_Hidden">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Hidden Line</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="Gui::PrefColorButton" name="pcb_Hidden">
<property name="toolTip">
<string>Hidden line color</string>
</property>
<property name="color">
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
<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="0">
<widget class="QLabel" name="lbl_PreSelect">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Preselected</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::PrefColorButton" name="pcb_PreSelect">
<property name="toolTip">
<string>Preselection color</string>
</property>
<property name="color">
<color>
<red>255</red>
<green>255</green>
<blue>0</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="3"> <item row="1" column="3">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="font"> <property name="font">
@@ -170,38 +61,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="4">
<widget class="Gui::PrefColorButton" name="pcb_Surface">
<property name="toolTip">
<string>Section face color</string>
</property>
<property name="color">
<color>
<red>211</red>
<green>211</green>
<blue>211</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>CutSurfaceColor</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_Select">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Selected</string>
</property>
</widget>
</item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="Gui::PrefColorButton" name="pcb_Select"> <widget class="Gui::PrefColorButton" name="pcb_Select">
<property name="toolTip"> <property name="toolTip">
@@ -222,62 +81,10 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="3"> <item row="5" column="3">
<widget class="QLabel" name="label_14"> <widget class="QLabel" name="label_16">
<property name="text"> <property name="text">
<string>Section Line</string> <string>Vertex</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="Gui::PrefColorButton" name="pcbSectionLine">
<property name="toolTip">
<string>Section line color</string>
</property>
<property name="color">
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>SectionColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw/Decorations</cstring>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Background</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="Gui::PrefColorButton" name="pcb_Background">
<property name="toolTip">
<string>Background color around pages</string>
</property>
<property name="color">
<color>
<red>211</red>
<green>211</green>
<blue>211</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>Background</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw/Colors</cstring>
</property> </property>
</widget> </widget>
</item> </item>
@@ -313,13 +120,58 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item row="2" column="4">
<widget class="QLabel" name="label_13"> <widget class="Gui::PrefColorButton" name="pcbSectionLine">
<property name="text"> <property name="toolTip">
<string>Dimension</string> <string>Section line color</string>
</property>
<property name="color">
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>SectionColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw/Decorations</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="3">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Section Line</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lbl_Normal">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Normal</string>
</property>
</widget>
</item>
<item row="0" column="2">
<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="4" column="1"> <item row="4" column="1">
<widget class="Gui::PrefColorButton" name="pcbDimColor"> <widget class="Gui::PrefColorButton" name="pcbDimColor">
<property name="toolTip"> <property name="toolTip">
@@ -340,22 +192,22 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="3"> <item row="3" column="0">
<widget class="QLabel" name="label_7"> <widget class="QLabel" name="label_4">
<property name="font"> <property name="font">
<font> <font>
<italic>true</italic> <italic>true</italic>
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string>Geometric Hatch</string> <string>Background</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="4"> <item row="0" column="1">
<widget class="Gui::PrefColorButton" name="pcb_GeomHatch"> <widget class="Gui::PrefColorButton" name="pcb_Normal">
<property name="toolTip"> <property name="toolTip">
<string>Geometric hatch pattern color</string> <string>Normal line color</string>
</property> </property>
<property name="color"> <property name="color">
<color> <color>
@@ -365,17 +217,82 @@
</color> </color>
</property> </property>
<property name="prefEntry" stdset="0"> <property name="prefEntry" stdset="0">
<cstring>GeomHatch</cstring> <cstring>NormalColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Colors</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::PrefColorButton" name="pcb_PreSelect">
<property name="toolTip">
<string>Preselection color</string>
</property>
<property name="color">
<color>
<red>255</red>
<green>255</green>
<blue>0</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="3" column="1">
<widget class="Gui::PrefColorButton" name="pcb_Background">
<property name="toolTip">
<string>Background color around pages</string>
</property>
<property name="color">
<color>
<red>211</red>
<green>211</green>
<blue>211</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>Background</cstring>
</property> </property>
<property name="prefPath" stdset="0"> <property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw/Colors</cstring> <cstring>/Mod/TechDraw/Colors</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_15"> <widget class="QLabel" name="lbl_PreSelect">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text"> <property name="text">
<string>Centerline</string> <string>Preselected</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="Gui::PrefColorButton" name="pcb_Hidden">
<property name="toolTip">
<string>Hidden line color</string>
</property>
<property name="color">
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>HiddenColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Colors</cstring>
</property> </property>
</widget> </widget>
</item> </item>
@@ -399,17 +316,42 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="3"> <item row="2" column="0">
<widget class="QLabel" name="label_16"> <widget class="QLabel" name="lbl_Select">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text"> <property name="text">
<string>Vertex</string> <string>Selected</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="4"> <item row="8" column="1">
<widget class="Gui::PrefColorButton" name="pcbVertexColor"> <widget class="Gui::PrefColorButton" name="pcb_Face">
<property name="toolTip"> <property name="toolTip">
<string>Color of vertices in views</string> <string>Face color (if not transparent)</string>
</property>
<property name="color">
<color>
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>FaceColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw/Colors</cstring>
</property>
</widget>
</item>
<item row="4" column="4">
<widget class="Gui::PrefColorButton" name="pcb_GeomHatch">
<property name="toolTip">
<string>Geometric hatch pattern color</string>
</property> </property>
<property name="color"> <property name="color">
<color> <color>
@@ -419,14 +361,26 @@
</color> </color>
</property> </property>
<property name="prefEntry" stdset="0"> <property name="prefEntry" stdset="0">
<cstring>VertexColor</cstring> <cstring>GeomHatch</cstring>
</property> </property>
<property name="prefPath" stdset="0"> <property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Decorations</cstring> <cstring>/Mod/TechDraw/Colors</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="0"> <item row="0" column="3">
<widget class="QLabel" name="lbl_Hidden">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Hidden Line</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="Gui::PrefCheckBox" name="pcb_PaintFaces"> <widget class="Gui::PrefCheckBox" name="pcb_PaintFaces">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
@@ -453,23 +407,37 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="1"> <item row="5" column="4">
<widget class="Gui::PrefColorButton" name="pcb_Face"> <widget class="Gui::PrefColorButton" name="pcbVertexColor">
<property name="toolTip"> <property name="toolTip">
<string>Face color (if not transparent)</string> <string>Color of vertices in views</string>
</property> </property>
<property name="color"> <property name="color">
<color> <color>
<red>255</red> <red>0</red>
<green>255</green> <green>0</green>
<blue>255</blue> <blue>0</blue>
</color> </color>
</property> </property>
<property name="prefEntry" stdset="0"> <property name="prefEntry" stdset="0">
<cstring>FaceColor</cstring> <cstring>VertexColor</cstring>
</property> </property>
<property name="prefPath" stdset="0"> <property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw/Colors</cstring> <cstring>Mod/TechDraw/Decorations</cstring>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Dimension</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Centerline</string>
</property> </property>
</widget> </widget>
</item> </item>
@@ -485,18 +453,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="3">
<widget class="QLabel" name="label_17">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Leaderline</string>
</property>
</widget>
</item>
<item row="6" column="4"> <item row="6" column="4">
<widget class="Gui::PrefColorButton" name="pcbMarkup"> <widget class="Gui::PrefColorButton" name="pcbMarkup">
<property name="toolTip"> <property name="toolTip">
@@ -517,6 +473,50 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="4">
<widget class="Gui::PrefColorButton" name="pcb_Surface">
<property name="toolTip">
<string>Section face color</string>
</property>
<property name="color">
<color>
<red>211</red>
<green>211</green>
<blue>211</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>CutSurfaceColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Colors</cstring>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QLabel" name="label_7">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Geometric Hatch</string>
</property>
</widget>
</item>
<item row="6" column="3">
<widget class="QLabel" name="label_17">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Leaderline</string>
</property>
</widget>
</item>
<item row="6" column="1"> <item row="6" column="1">
<widget class="Gui::PrefColorButton" name="pcbHighlight"> <widget class="Gui::PrefColorButton" name="pcbHighlight">
<property name="color"> <property name="color">
@@ -534,6 +534,30 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Grid Color</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="Gui::PrefColorButton" name="pcb_Grid">
<property name="color">
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>gridColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw/Colors</cstring>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>
@@ -548,7 +572,7 @@
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=" font-weight:600;"&gt;Note:&lt;/span&gt; Items in &lt;span style=" font-style:italic;"&gt;italics&lt;/span&gt; are default values for new objects. They have no effect on existing objects.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Note:&lt;/span&gt; Items in &lt;span style=&quot; font-style:italic;&quot;&gt;italics&lt;/span&gt; are default values for new objects. They have no effect on existing objects.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="wordWrap"> <property name="wordWrap">
<bool>true</bool> <bool>true</bool>
@@ -61,6 +61,7 @@ void DlgPrefsTechDrawColorsImp::saveSettings()
ui->pcbVertexColor->onSave(); ui->pcbVertexColor->onSave();
ui->pcbMarkup->onSave(); ui->pcbMarkup->onSave();
ui->pcbHighlight->onSave(); ui->pcbHighlight->onSave();
ui->pcb_Grid->onSave();
} }
void DlgPrefsTechDrawColorsImp::loadSettings() void DlgPrefsTechDrawColorsImp::loadSettings()
@@ -81,6 +82,7 @@ void DlgPrefsTechDrawColorsImp::loadSettings()
ui->pcbVertexColor->onRestore(); ui->pcbVertexColor->onRestore();
ui->pcbMarkup->onRestore(); ui->pcbMarkup->onRestore();
ui->pcbHighlight->onRestore(); ui->pcbHighlight->onRestore();
ui->pcb_Grid->onRestore();
} }
/** /**
+79 -19
View File
@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>440</width> <width>499</width>
<height>581</height> <height>776</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@@ -275,9 +275,7 @@ for ProjectionGroups</string>
<string>Font for labels</string> <string>Font for labels</string>
</property> </property>
<property name="currentFont"> <property name="currentFont">
<font> <font/>
<pointsize>10</pointsize>
</font>
</property> </property>
<property name="prefEntry" stdset="0"> <property name="prefEntry" stdset="0">
<cstring>LabelFont</cstring> <cstring>LabelFont</cstring>
@@ -788,6 +786,76 @@ for ProjectionGroups</string>
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="gbGrid">
<property name="title">
<string>Grid</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QGridLayout" name="gridLayout" columnstretch="1,0,1">
<item row="1" column="2">
<widget class="Gui::PrefSpinBox" name="psb_GridSpacing">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="value">
<number>10</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>gridSpacing</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw/General</cstring>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="Gui::PrefCheckBox" name="cb_ShowGrid">
<property name="text">
<string>Show Grid</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>showGrid</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw/General</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Grid Spacing</string>
</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>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QLabel" name="label_12"> <widget class="QLabel" name="label_12">
<property name="font"> <property name="font">
@@ -797,26 +865,13 @@ for ProjectionGroups</string>
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=" font-weight:600;"&gt;Note:&lt;/span&gt; Items in &lt;span style=" font-style:italic;"&gt;italics&lt;/span&gt; are default values for new objects. They have no effect on existing objects.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Note:&lt;/span&gt; Items in &lt;span style=&quot; font-style:italic;&quot;&gt;italics&lt;/span&gt; are default values for new objects. They have no effect on existing objects.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="wordWrap"> <property name="wordWrap">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>19</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>
@@ -835,6 +890,11 @@ for ProjectionGroups</string>
<extends>Gui::FileChooser</extends> <extends>Gui::FileChooser</extends>
<header>Gui/PrefWidgets.h</header> <header>Gui/PrefWidgets.h</header>
</customwidget> </customwidget>
<customwidget>
<class>Gui::PrefSpinBox</class>
<extends>QSpinBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget> <customwidget>
<class>Gui::PrefCheckBox</class> <class>Gui::PrefCheckBox</class>
<extends>QCheckBox</extends> <extends>QCheckBox</extends>
@@ -71,6 +71,8 @@ void DlgPrefsTechDrawGeneralImp::saveSettings()
ui->pfc_Welding->onSave(); ui->pfc_Welding->onSave();
ui->pfc_FilePattern->onSave(); ui->pfc_FilePattern->onSave();
ui->le_NamePattern->onSave(); ui->le_NamePattern->onSave();
ui->cb_ShowGrid->onSave();
ui->psb_GridSpacing->onSave();
} }
void DlgPrefsTechDrawGeneralImp::loadSettings() void DlgPrefsTechDrawGeneralImp::loadSettings()
@@ -106,6 +108,8 @@ void DlgPrefsTechDrawGeneralImp::loadSettings()
ui->pfc_Welding->onRestore(); ui->pfc_Welding->onRestore();
ui->pfc_FilePattern->onRestore(); ui->pfc_FilePattern->onRestore();
ui->le_NamePattern->onRestore(); ui->le_NamePattern->onRestore();
ui->cb_ShowGrid->onRestore();
ui->psb_GridSpacing->onRestore();
} }
/** /**
+33
View File
@@ -211,3 +211,36 @@ QString PreferencesGui::weldingDirectory()
return qSymbolDir; return qSymbolDir;
} }
App::Color PreferencesGui::gridColor()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->
GetGroup("Mod/TechDraw/Colors");
App::Color result;
result.setPackedValue(hGrp->GetUnsigned("gridColor", 0x000000FF)); //#000000 black
return result;
}
QColor PreferencesGui::gridQColor()
{
return PreferencesGui::gridColor().asValue<QColor>();
}
int PreferencesGui::gridSpacing()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->
GetGroup("Mod/TechDraw/General");
int spacing = hGrp->GetInt("gridSpacing", 10);
return spacing;
}
bool PreferencesGui::showGrid()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->
GetGroup("Mod/TechDraw/General");
bool show = hGrp->GetInt("showGrid", true);
return show;
}
+5
View File
@@ -63,6 +63,11 @@ static int mattingStyle();
static QString weldingDirectory(); static QString weldingDirectory();
static bool showGrid();
static App::Color gridColor();
static QColor gridQColor();
static int gridSpacing();
}; };
} //end namespace TechDrawGui } //end namespace TechDrawGui
+45 -1
View File
@@ -90,6 +90,7 @@
#include <Mod/TechDraw/App/DrawUtil.h> #include <Mod/TechDraw/App/DrawUtil.h>
#include "Rez.h" #include "Rez.h"
#include "PreferencesGui.h"
#include "QGIDrawingTemplate.h" #include "QGIDrawingTemplate.h"
#include "QGITemplate.h" #include "QGITemplate.h"
#include "QGISVGTemplate.h" #include "QGISVGTemplate.h"
@@ -134,7 +135,8 @@ QGVPage::QGVPage(ViewProviderPage *vp, QGraphicsScene* s, QWidget *parent)
drawBkg(true), drawBkg(true),
m_vpPage(0), m_vpPage(0),
balloonPlacing(false), balloonPlacing(false),
panningActive(false) panningActive(false),
m_showGrid(false)
{ {
assert(vp); assert(vp);
m_vpPage = vp; m_vpPage = vp;
@@ -1306,5 +1308,47 @@ void QGVPage::resetCursor() {
viewport()->setCursor(Qt::ArrowCursor); viewport()->setCursor(Qt::ArrowCursor);
} }
void QGVPage::drawForeground(QPainter *painter, const QRectF &rect)
{
Q_UNUSED(rect);
if (m_showGrid) {
QPen gridPen(PreferencesGui::gridQColor());
QPen savePen = painter->pen();
painter->setPen(gridPen);
painter->drawPath(m_gridPath);
painter->setPen(savePen);
}
}
void QGVPage::makeGrid(int gridWidth, int gridHeight, int gridStep)
{
QPainterPath grid;
int width = Rez::guiX(gridWidth);
int height = Rez::guiX(gridHeight);
int step = Rez::guiX(gridStep);
int horizStart = 0;
int vPos = 0;
int rows = (height / step) + 1;
//draw horizontal lines
for (int i = 0; i < rows; i++) {
vPos = i * step;
QPoint start (horizStart, -vPos);
QPoint end (width, -vPos);
grid.moveTo(start);
grid.lineTo(end);
}
//draw vertical lines
int vertStart = 0;
int cols = (width / step) + 1;
int hPos = 0;
for (int i = 0; i < cols; i++) {
hPos = i * step;
QPoint start(hPos, -vertStart);
QPoint end(hPos, -height);
grid.moveTo(start);
grid.lineTo(end);
}
m_gridPath = grid;
}
#include <Mod/TechDraw/Gui/moc_QGVPage.cpp> #include <Mod/TechDraw/Gui/moc_QGVPage.cpp>
+13
View File
@@ -23,12 +23,18 @@
#ifndef TECHDRAWGUI_QGVIEW_H #ifndef TECHDRAWGUI_QGVIEW_H
#define TECHDRAWGUI_QGVIEW_H #define TECHDRAWGUI_QGVIEW_H
#include <Mod/TechDraw/TechDrawGlobal.h>
#include <QGraphicsView> #include <QGraphicsView>
#include <QGraphicsScene> #include <QGraphicsScene>
#include <QLabel> #include <QLabel>
class QTemporaryFile; class QTemporaryFile;
namespace App {
class DocumentObject;
}
namespace TechDraw { namespace TechDraw {
class DrawView; class DrawView;
class DrawViewPart; class DrawViewPart;
@@ -122,6 +128,9 @@ public:
void saveSvg(QString filename); void saveSvg(QString filename);
void postProcessXml(QTemporaryFile& tempFile, QString filename, QString pagename); void postProcessXml(QTemporaryFile& tempFile, QString filename, QString pagename);
void makeGrid(int width, int height, int step);
void showGrid(bool state) {m_showGrid = state;}
void updateViewport(void) {viewport()->repaint();}
public Q_SLOTS: public Q_SLOTS:
void setHighQualityAntialiasing(bool highQualityAntialiasing); void setHighQualityAntialiasing(bool highQualityAntialiasing);
@@ -150,6 +159,7 @@ protected:
void activateCursor(QCursor cursor); void activateCursor(QCursor cursor);
void resetCursor(); void resetCursor();
virtual void drawForeground(QPainter *painter, const QRectF &rect) override;
private: private:
RendererType m_renderer; RendererType m_renderer;
@@ -172,6 +182,9 @@ private:
QPoint panOrigin; QPoint panOrigin;
bool panningActive; bool panningActive;
bool m_showGrid;
QPainterPath m_gridPath;
}; };
} // namespace } // namespace
@@ -25,6 +25,8 @@
#ifndef TECHDRAWGUI_VIEWPROVIDERVIEW_H #ifndef TECHDRAWGUI_VIEWPROVIDERVIEW_H
#define TECHDRAWGUI_VIEWPROVIDERVIEW_H #define TECHDRAWGUI_VIEWPROVIDERVIEW_H
#include <Mod/TechDraw/TechDrawGlobal.h>
#include <boost_signals2.hpp> #include <boost_signals2.hpp>
#include <Gui/ViewProviderFeature.h> #include <Gui/ViewProviderFeature.h>
+36 -6
View File
@@ -82,9 +82,12 @@ ViewProviderPage::ViewProviderPage()
m_graphicsView(nullptr) m_graphicsView(nullptr)
{ {
sPixmap = "TechDraw_TreePage"; sPixmap = "TechDraw_TreePage";
static const char *group = "Base"; static const char *group = "Grid";
ADD_PROPERTY_TYPE(ShowFrames ,(true),group,App::Prop_None,"NonGui! Show or hide View frames and Labels on this Page"); ADD_PROPERTY_TYPE(ShowFrames ,(true),group,App::Prop_None,"NonGui! Show or hide View frames and Labels on this Page");
ADD_PROPERTY_TYPE(ShowGrid ,(PreferencesGui::showGrid()),group,App::Prop_None,"Show or hide a grid on this Page");
ADD_PROPERTY_TYPE(GridSpacing, (PreferencesGui::gridSpacing()), group, (App::PropertyType)(App::Prop_None),
"Grid line spacing in mm");
ShowFrames.setStatus(App::Property::Hidden,true); ShowFrames.setStatus(App::Property::Hidden,true);
Visibility.setStatus(App::Property::Hidden,true); Visibility.setStatus(App::Property::Hidden,true);
@@ -300,6 +303,8 @@ bool ViewProviderPage::showMDIViewPage()
m_mdiView->redrawAllViews(); m_mdiView->redrawAllViews();
m_mdiView->fixOrphans(true); m_mdiView->fixOrphans(true);
} }
setGrid();
return true; return true;
} }
@@ -382,11 +387,11 @@ MDIViewPage* ViewProviderPage::getMDIViewPage() const
void ViewProviderPage::onChanged(const App::Property *prop) void ViewProviderPage::onChanged(const App::Property *prop)
{ {
// if (prop == &(getDrawPage()->Template)) { if (prop == &(ShowGrid)) {
// if (m_mdiView) { setGrid();
// m_mdiView->updateTemplate(); } else if (prop == &(GridSpacing)) {
// } setGrid();
// } }
Gui::ViewProviderDocumentObject::onChanged(prop); Gui::ViewProviderDocumentObject::onChanged(prop);
} }
@@ -492,3 +497,28 @@ Gui::MDIView *ViewProviderPage::getMDIView() const
const_cast<ViewProviderPage*>(this)->showMDIViewPage(); const_cast<ViewProviderPage*>(this)->showMDIViewPage();
return m_mdiView.data(); return m_mdiView.data();
} }
void ViewProviderPage::setGrid(void)
{
TechDraw::DrawPage* dp = getDrawPage();
if (!dp) {
return;
}
int pageWidth = 298;
int pageHeight = 215;
int gridStep = GridSpacing.getValue() > 0 ? GridSpacing.getValue() : 10;
if (dp) {
pageWidth = dp->getPageWidth();
pageHeight = dp->getPageHeight();
}
QGVPage* widget = getGraphicsView();
if (widget) {
if (ShowGrid.getValue()) {
widget->showGrid(true);
widget->makeGrid(pageWidth, pageHeight, gridStep);
} else {
widget->showGrid(false);
}
widget->updateViewport();
}
}
+8
View File
@@ -25,6 +25,8 @@
#ifndef DRAWINGGUI_VIEWPROVIDERPAGE_H #ifndef DRAWINGGUI_VIEWPROVIDERPAGE_H
#define DRAWINGGUI_VIEWPROVIDERPAGE_H #define DRAWINGGUI_VIEWPROVIDERPAGE_H
#include <Mod/TechDraw/TechDrawGlobal.h>
#include <QPointer> #include <QPointer>
#include <Gui/ViewProviderDocumentObject.h> #include <Gui/ViewProviderDocumentObject.h>
@@ -50,6 +52,8 @@ public:
virtual ~ViewProviderPage(); virtual ~ViewProviderPage();
App::PropertyBool ShowFrames; App::PropertyBool ShowFrames;
App::PropertyBool ShowGrid;
App::PropertyInteger GridSpacing;
virtual void attach(App::DocumentObject *) override; virtual void attach(App::DocumentObject *) override;
virtual void setDisplayMode(const char* ModeName) override; virtual void setDisplayMode(const char* ModeName) override;
@@ -94,6 +98,7 @@ public:
QGVPage *getGraphicsView() { return m_graphicsView; } QGVPage *getGraphicsView() { return m_graphicsView; }
void setGraphicsView(QGVPage* gv); void setGraphicsView(QGVPage* gv);
virtual bool canDelete(App::DocumentObject* obj) const override; virtual bool canDelete(App::DocumentObject* obj) const override;
void setGrid(void);
protected: protected:
bool setEdit(int ModNum) override; bool setEdit(int ModNum) override;
@@ -103,6 +108,9 @@ private:
bool m_docReady; bool m_docReady;
std::string m_pageName; std::string m_pageName;
QGVPage* m_graphicsView; QGVPage* m_graphicsView;
bool m_showGrid;
int m_gridStep;
}; };
} // namespace TechDrawGui } // namespace TechDrawGui