[TD]add alignment grid to page

This commit is contained in:
Wanderer Fan
2022-02-27 09:42:08 -05:00
committed by WandererFan
parent 6a606783d6
commit eb4a5384c0
12 changed files with 501 additions and 274 deletions

View File

@@ -28,6 +28,8 @@
#ifndef TECHDRAW_EDGEWALKER_H
#define TECHDRAW_EDGEWALKER_H
#include <Mod/TechDraw/TechDrawGlobal.h>
#include <vector>
#include <boost_graph_adjacency_list.hpp>
#include <boost/graph/properties.hpp>
@@ -72,7 +74,7 @@ typedef
>
planar_embedding_t;
class WalkerEdge
class TechDrawExport WalkerEdge
{
public:
static bool weCompare(WalkerEdge i, WalkerEdge j);
@@ -85,7 +87,7 @@ public:
int idx;
};
class ewWire
class TechDrawExport ewWire
{
public:
bool isEqual(ewWire w);
@@ -96,7 +98,7 @@ public:
int size(void);
};
class ewWireList
class TechDrawExport ewWireList
{
public:
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:
template <typename Edge>
@@ -124,7 +126,7 @@ private:
TechDraw::graph m_g;
};
class incidenceItem
class TechDrawExport incidenceItem
{
public:
incidenceItem() {iEdge = 0; angle = 0.0;}
@@ -137,7 +139,7 @@ public:
edge_t eDesc;
};
class embedItem
class TechDrawExport embedItem
{
public:
embedItem();
@@ -152,7 +154,7 @@ public:
};
class EdgeWalker
class TechDrawExport EdgeWalker
{
public:
EdgeWalker(void);

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>440</width>
<height>342</height>
<height>368</height>
</rect>
</property>
<property name="sizePolicy">
@@ -49,115 +49,6 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<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">
<widget class="QLabel" name="label_3">
<property name="font">
@@ -170,38 +61,6 @@
</property>
</widget>
</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">
<widget class="Gui::PrefColorButton" name="pcb_Select">
<property name="toolTip">
@@ -222,62 +81,10 @@
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLabel" name="label_14">
<item row="5" column="3">
<widget class="QLabel" name="label_16">
<property name="text">
<string>Section Line</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>
<string>Vertex</string>
</property>
</widget>
</item>
@@ -313,13 +120,58 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Dimension</string>
<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="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">
<widget class="Gui::PrefColorButton" name="pcbDimColor">
<property name="toolTip">
@@ -340,22 +192,22 @@
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QLabel" name="label_7">
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Geometric Hatch</string>
<string>Background</string>
</property>
</widget>
</item>
<item row="4" column="4">
<widget class="Gui::PrefColorButton" name="pcb_GeomHatch">
<item row="0" column="1">
<widget class="Gui::PrefColorButton" name="pcb_Normal">
<property name="toolTip">
<string>Geometric hatch pattern color</string>
<string>Normal line color</string>
</property>
<property name="color">
<color>
@@ -365,17 +217,82 @@
</color>
</property>
<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 name="prefPath" stdset="0">
<cstring>/Mod/TechDraw/Colors</cstring>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_15">
<item row="1" column="0">
<widget class="QLabel" name="lbl_PreSelect">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<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>
</widget>
</item>
@@ -399,17 +316,42 @@
</property>
</widget>
</item>
<item row="5" column="3">
<widget class="QLabel" name="label_16">
<item row="2" column="0">
<widget class="QLabel" name="lbl_Select">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Vertex</string>
<string>Selected</string>
</property>
</widget>
</item>
<item row="5" column="4">
<widget class="Gui::PrefColorButton" name="pcbVertexColor">
<item row="8" column="1">
<widget class="Gui::PrefColorButton" name="pcb_Face">
<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 name="color">
<color>
@@ -419,14 +361,26 @@
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>VertexColor</cstring>
<cstring>GeomHatch</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Decorations</cstring>
<cstring>/Mod/TechDraw/Colors</cstring>
</property>
</widget>
</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">
<property name="minimumSize">
<size>
@@ -453,23 +407,37 @@
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="Gui::PrefColorButton" name="pcb_Face">
<item row="5" column="4">
<widget class="Gui::PrefColorButton" name="pcbVertexColor">
<property name="toolTip">
<string>Face color (if not transparent)</string>
<string>Color of vertices in views</string>
</property>
<property name="color">
<color>
<red>255</red>
<green>255</green>
<blue>255</blue>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>FaceColor</cstring>
<cstring>VertexColor</cstring>
</property>
<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>
</widget>
</item>
@@ -485,18 +453,6 @@
</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="4">
<widget class="Gui::PrefColorButton" name="pcbMarkup">
<property name="toolTip">
@@ -517,6 +473,50 @@
</property>
</widget>
</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">
<widget class="Gui::PrefColorButton" name="pcbHighlight">
<property name="color">
@@ -534,6 +534,30 @@
</property>
</widget>
</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>
</item>
</layout>
@@ -548,7 +572,7 @@
</font>
</property>
<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 name="wordWrap">
<bool>true</bool>

View File

@@ -61,6 +61,7 @@ void DlgPrefsTechDrawColorsImp::saveSettings()
ui->pcbVertexColor->onSave();
ui->pcbMarkup->onSave();
ui->pcbHighlight->onSave();
ui->pcb_Grid->onSave();
}
void DlgPrefsTechDrawColorsImp::loadSettings()
@@ -81,6 +82,7 @@ void DlgPrefsTechDrawColorsImp::loadSettings()
ui->pcbVertexColor->onRestore();
ui->pcbMarkup->onRestore();
ui->pcbHighlight->onRestore();
ui->pcb_Grid->onRestore();
}
/**

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>440</width>
<height>581</height>
<width>499</width>
<height>776</height>
</rect>
</property>
<property name="sizePolicy">
@@ -275,9 +275,7 @@ for ProjectionGroups</string>
<string>Font for labels</string>
</property>
<property name="currentFont">
<font>
<pointsize>10</pointsize>
</font>
<font/>
</property>
<property name="prefEntry" stdset="0">
<cstring>LabelFont</cstring>
@@ -788,6 +786,76 @@ for ProjectionGroups</string>
</layout>
</widget>
</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>
<widget class="QLabel" name="label_12">
<property name="font">
@@ -797,26 +865,13 @@ for ProjectionGroups</string>
</font>
</property>
<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 name="wordWrap">
<bool>true</bool>
</property>
</widget>
</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>
</widget>
<customwidgets>
@@ -835,6 +890,11 @@ for ProjectionGroups</string>
<extends>Gui::FileChooser</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefSpinBox</class>
<extends>QSpinBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefCheckBox</class>
<extends>QCheckBox</extends>

View File

@@ -71,6 +71,8 @@ void DlgPrefsTechDrawGeneralImp::saveSettings()
ui->pfc_Welding->onSave();
ui->pfc_FilePattern->onSave();
ui->le_NamePattern->onSave();
ui->cb_ShowGrid->onSave();
ui->psb_GridSpacing->onSave();
}
void DlgPrefsTechDrawGeneralImp::loadSettings()
@@ -106,6 +108,8 @@ void DlgPrefsTechDrawGeneralImp::loadSettings()
ui->pfc_Welding->onRestore();
ui->pfc_FilePattern->onRestore();
ui->le_NamePattern->onRestore();
ui->cb_ShowGrid->onRestore();
ui->psb_GridSpacing->onRestore();
}
/**

View File

@@ -211,3 +211,36 @@ QString PreferencesGui::weldingDirectory()
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;
}

View File

@@ -63,6 +63,11 @@ static int mattingStyle();
static QString weldingDirectory();
static bool showGrid();
static App::Color gridColor();
static QColor gridQColor();
static int gridSpacing();
};
} //end namespace TechDrawGui

View File

@@ -90,6 +90,7 @@
#include <Mod/TechDraw/App/DrawUtil.h>
#include "Rez.h"
#include "PreferencesGui.h"
#include "QGIDrawingTemplate.h"
#include "QGITemplate.h"
#include "QGISVGTemplate.h"
@@ -134,7 +135,8 @@ QGVPage::QGVPage(ViewProviderPage *vp, QGraphicsScene* s, QWidget *parent)
drawBkg(true),
m_vpPage(0),
balloonPlacing(false),
panningActive(false)
panningActive(false),
m_showGrid(false)
{
assert(vp);
m_vpPage = vp;
@@ -1306,5 +1308,47 @@ void QGVPage::resetCursor() {
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>

View File

@@ -23,12 +23,18 @@
#ifndef TECHDRAWGUI_QGVIEW_H
#define TECHDRAWGUI_QGVIEW_H
#include <Mod/TechDraw/TechDrawGlobal.h>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QLabel>
class QTemporaryFile;
namespace App {
class DocumentObject;
}
namespace TechDraw {
class DrawView;
class DrawViewPart;
@@ -122,6 +128,9 @@ public:
void saveSvg(QString filename);
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:
void setHighQualityAntialiasing(bool highQualityAntialiasing);
@@ -150,6 +159,7 @@ protected:
void activateCursor(QCursor cursor);
void resetCursor();
virtual void drawForeground(QPainter *painter, const QRectF &rect) override;
private:
RendererType m_renderer;
@@ -172,6 +182,9 @@ private:
QPoint panOrigin;
bool panningActive;
bool m_showGrid;
QPainterPath m_gridPath;
};
} // namespace

View File

@@ -25,6 +25,8 @@
#ifndef TECHDRAWGUI_VIEWPROVIDERVIEW_H
#define TECHDRAWGUI_VIEWPROVIDERVIEW_H
#include <Mod/TechDraw/TechDrawGlobal.h>
#include <boost_signals2.hpp>
#include <Gui/ViewProviderFeature.h>

View File

@@ -82,9 +82,12 @@ ViewProviderPage::ViewProviderPage()
m_graphicsView(nullptr)
{
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(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);
Visibility.setStatus(App::Property::Hidden,true);
@@ -300,6 +303,8 @@ bool ViewProviderPage::showMDIViewPage()
m_mdiView->redrawAllViews();
m_mdiView->fixOrphans(true);
}
setGrid();
return true;
}
@@ -382,11 +387,11 @@ MDIViewPage* ViewProviderPage::getMDIViewPage() const
void ViewProviderPage::onChanged(const App::Property *prop)
{
// if (prop == &(getDrawPage()->Template)) {
// if (m_mdiView) {
// m_mdiView->updateTemplate();
// }
// }
if (prop == &(ShowGrid)) {
setGrid();
} else if (prop == &(GridSpacing)) {
setGrid();
}
Gui::ViewProviderDocumentObject::onChanged(prop);
}
@@ -492,3 +497,28 @@ Gui::MDIView *ViewProviderPage::getMDIView() const
const_cast<ViewProviderPage*>(this)->showMDIViewPage();
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();
}
}

View File

@@ -25,6 +25,8 @@
#ifndef DRAWINGGUI_VIEWPROVIDERPAGE_H
#define DRAWINGGUI_VIEWPROVIDERPAGE_H
#include <Mod/TechDraw/TechDrawGlobal.h>
#include <QPointer>
#include <Gui/ViewProviderDocumentObject.h>
@@ -50,6 +52,8 @@ public:
virtual ~ViewProviderPage();
App::PropertyBool ShowFrames;
App::PropertyBool ShowGrid;
App::PropertyInteger GridSpacing;
virtual void attach(App::DocumentObject *) override;
virtual void setDisplayMode(const char* ModeName) override;
@@ -94,6 +98,7 @@ public:
QGVPage *getGraphicsView() { return m_graphicsView; }
void setGraphicsView(QGVPage* gv);
virtual bool canDelete(App::DocumentObject* obj) const override;
void setGrid(void);
protected:
bool setEdit(int ModNum) override;
@@ -103,6 +108,9 @@ private:
bool m_docReady;
std::string m_pageName;
QGVPage* m_graphicsView;
bool m_showGrid;
int m_gridStep;
};
} // namespace TechDrawGui