Skip to content

Commit

Permalink
Sketcher: Settings - Allow to set the number of segments per geometry
Browse files Browse the repository at this point in the history
  • Loading branch information
abdullahtahiriyo authored and wwmayer committed Feb 21, 2017
1 parent 00aadc4 commit d92b3fc
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 26 deletions.
2 changes: 2 additions & 0 deletions src/Mod/Sketcher/Gui/SketcherSettings.cpp
Expand Up @@ -122,6 +122,7 @@ void SketcherSettings::saveSettings()

// Sketch editing
ui->EditSketcherFontSize->onSave();
ui->SegmentsPerGeometry->onSave();
ui->dialogOnDistanceConstraint->onSave();
ui->continueMode->onSave();
ui->checkBoxAdvancedSolverTaskBox->onSave();
Expand Down Expand Up @@ -164,6 +165,7 @@ void SketcherSettings::loadSettings()

// Sketch editing
ui->EditSketcherFontSize->onRestore();
ui->SegmentsPerGeometry->onRestore();
ui->dialogOnDistanceConstraint->onRestore();
ui->continueMode->onRestore();
ui->checkBoxAdvancedSolverTaskBox->onRestore();
Expand Down
61 changes: 42 additions & 19 deletions src/Mod/Sketcher/Gui/SketcherSettings.ui
Expand Up @@ -527,6 +527,19 @@
<string>Sketch editing</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="minimumSize">
<size>
<width>182</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Font size</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Gui::PrefSpinBox" name="EditSketcherFontSize">
<property name="suffix">
Expand Down Expand Up @@ -562,27 +575,14 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="minimumSize">
<size>
<width>182</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Font size</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBox">
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<item row="4" column="0" colspan="2">
<widget class="Gui::PrefCheckBox" name="dialogOnDistanceConstraint">
<property name="text">
<string>Ask for value after creating a distance constraint</string>
Expand All @@ -598,17 +598,17 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="EditSketcherMarkerSize"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Grid line pattern</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<item row="1" column="1">
<widget class="QComboBox" name="EditSketcherMarkerSize"/>
</item>
<item row="5" column="0" colspan="2">
<widget class="Gui::PrefCheckBox" name="continueMode">
<property name="text">
<string>Geometry Creation &quot;Continue Mode&quot;</string>
Expand All @@ -624,7 +624,7 @@
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<item row="6" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_3">
<property name="enabled">
<bool>true</bool>
Expand Down Expand Up @@ -771,6 +771,29 @@
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Segments per geometry</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="Gui::PrefSpinBox" name="SegmentsPerGeometry">
<property name="minimum">
<number>50</number>
</property>
<property name="maximum">
<number>1000</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>SegmentsPerGeometry</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
16 changes: 9 additions & 7 deletions src/Mod/Sketcher/Gui/ViewProviderSketch.cpp
Expand Up @@ -3216,6 +3216,8 @@ void ViewProviderSketch::draw(bool temp /*=false*/, bool rebuildinformationlayer
// end information layer

int GeoId = 0;

int stdcountsegments = hGrp->GetInt("SegmentsPerGeometry", 50);

// RootPoint
Points.push_back(Base::Vector3d(0.,0.,0.));
Expand All @@ -3241,7 +3243,7 @@ void ViewProviderSketch::draw(bool temp /*=false*/, bool rebuildinformationlayer
const Part::GeomCircle *circle = static_cast<const Part::GeomCircle *>(*it);
Handle_Geom_Circle curve = Handle_Geom_Circle::DownCast(circle->handle());

int countSegments = 50;
int countSegments = stdcountsegments;
Base::Vector3d center = circle->getCenter();
double segment = (2 * M_PI) / countSegments;
for (int i=0; i < countSegments; i++) {
Expand All @@ -3260,7 +3262,7 @@ void ViewProviderSketch::draw(bool temp /*=false*/, bool rebuildinformationlayer
const Part::GeomEllipse *ellipse = static_cast<const Part::GeomEllipse *>(*it);
Handle_Geom_Ellipse curve = Handle_Geom_Ellipse::DownCast(ellipse->handle());

int countSegments = 50;
int countSegments = stdcountsegments;
Base::Vector3d center = ellipse->getCenter();
double segment = (2 * M_PI) / countSegments;
for (int i=0; i < countSegments; i++) {
Expand All @@ -3285,7 +3287,7 @@ void ViewProviderSketch::draw(bool temp /*=false*/, bool rebuildinformationlayer
std::swap(startangle, endangle);

double range = endangle-startangle;
int countSegments = std::max(6, int(50.0 * range / (2 * M_PI)));
int countSegments = std::max(6, int(stdcountsegments * range / (2 * M_PI)));
double segment = range / countSegments;

Base::Vector3d center = arc->getCenter();
Expand Down Expand Up @@ -3318,7 +3320,7 @@ void ViewProviderSketch::draw(bool temp /*=false*/, bool rebuildinformationlayer
std::swap(startangle, endangle);

double range = endangle-startangle;
int countSegments = std::max(6, int(50.0 * range / (2 * M_PI)));
int countSegments = std::max(6, int(stdcountsegments * range / (2 * M_PI)));
double segment = range / countSegments;

Base::Vector3d center = arc->getCenter();
Expand Down Expand Up @@ -3351,7 +3353,7 @@ void ViewProviderSketch::draw(bool temp /*=false*/, bool rebuildinformationlayer
std::swap(startangle, endangle);

double range = endangle-startangle;
int countSegments = std::max(6, int(50.0 * range / (2 * M_PI)));
int countSegments = std::max(6, int(stdcountsegments * range / (2 * M_PI)));
double segment = range / countSegments;

Base::Vector3d center = aoh->getCenter();
Expand Down Expand Up @@ -3384,7 +3386,7 @@ void ViewProviderSketch::draw(bool temp /*=false*/, bool rebuildinformationlayer
std::swap(startangle, endangle);

double range = endangle-startangle;
int countSegments = std::max(6, int(50.0 * range / (2 * M_PI)));
int countSegments = std::max(6, int(stdcountsegments * range / (2 * M_PI)));
double segment = range / countSegments;

Base::Vector3d center = aop->getCenter();
Expand Down Expand Up @@ -3420,7 +3422,7 @@ void ViewProviderSketch::draw(bool temp /*=false*/, bool rebuildinformationlayer
std::swap(first, last);

double range = last-first;
int countSegments = 50;
int countSegments = stdcountsegments;
double segment = range / countSegments;

for (int i=0; i < countSegments; i++) {
Expand Down

0 comments on commit d92b3fc

Please sign in to comment.