Skip to content

Commit

Permalink
Merge pull request #4387 from mlampert/feature/add-experimental-featu…
Browse files Browse the repository at this point in the history
…res-to-preferences

[Path]: Expose experimental feature flag in preferences - with warning.
  • Loading branch information
sliptonic committed Feb 15, 2021
2 parents ab186aa + ff01e4f commit 48dc406
Show file tree
Hide file tree
Showing 8 changed files with 265 additions and 81 deletions.
1 change: 1 addition & 0 deletions src/Mod/Path/CMakeLists.txt
Expand Up @@ -84,6 +84,7 @@ SET(PathScripts_SRCS
PathScripts/PathPost.py
PathScripts/PathPostProcessor.py
PathScripts/PathPreferences.py
PathScripts/PathPreferencesAdvanced.py
PathScripts/PathPreferencesPathDressup.py
PathScripts/PathPreferencesPathJob.py
PathScripts/PathProbe.py
Expand Down
6 changes: 0 additions & 6 deletions src/Mod/Path/Gui/DlgSettingsPathColor.cpp
Expand Up @@ -67,9 +67,6 @@ void DlgSettingsPathColor::saveSettings()
ui->DefaultBBoxNormalColor->onSave();
ui->DefaultSelectionStyle->onSave();
ui->DefaultTaskPanelLayout->onSave();
ui->WarningSuppressAllSpeeds->onSave();
ui->WarningSuppressRapidSpeeds->onSave();
ui->WarningSuppressSelectionMode->onSave();
}

void DlgSettingsPathColor::loadSettings()
Expand All @@ -86,9 +83,6 @@ void DlgSettingsPathColor::loadSettings()
ui->DefaultBBoxNormalColor->onRestore();
ui->DefaultSelectionStyle->onRestore();
ui->DefaultTaskPanelLayout->onRestore();
ui->WarningSuppressAllSpeeds->onRestore();
ui->WarningSuppressRapidSpeeds->onRestore();
ui->WarningSuppressSelectionMode->onRestore();
}

/**
Expand Down
75 changes: 2 additions & 73 deletions src/Mod/Path/Gui/DlgSettingsPathColor.ui
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>512</width>
<height>691</height>
<height>573</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -436,7 +436,7 @@
</layout>
</widget>
</item>
<item row="3" column="0" colspan="2">
<item row="2" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
Expand All @@ -449,72 +449,6 @@
</property>
</spacer>
</item>
<item row="2" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Warnings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="Gui::PrefCheckBox" name="WarningSuppressAllSpeeds">
<property name="toolTip">
<string>Suppress all warnings about setting speed rates for accurate cycle time calculation</string>
</property>
<property name="text">
<string>Suppress all missing speeds warning</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>WarningSuppressAllSpeeds</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Path</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="WarningSuppressRapidSpeeds">
<property name="toolTip">
<string>Suppress warning about setting the rapid speed rates for accurate cycle time calculation. Ignored if all speed warnings are already suppressed.</string>
</property>
<property name="text">
<string>Suppress missing rapid speeds warning</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>WarningSuppressRapidSpeeds</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Path</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="WarningSuppressSelectionMode">
<property name="toolTip">
<string>Suppress warning whenever a Path selection mode is activated</string>
</property>
<property name="text">
<string>Suppress selection mode warning</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>WarningSuppressSelectionMode</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Path</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
Expand All @@ -538,11 +472,6 @@
<extends>QComboBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefCheckBox</class>
<extends>QCheckBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>DefaultNormalPathColor</tabstop>
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Path/Gui/Resources/Path.qrc
Expand Up @@ -132,6 +132,7 @@
<file>panels/ToolLibraryEditor.ui</file>
<file>panels/TaskPathSimulator.ui</file>
<file>panels/ZCorrectEdit.ui</file>
<file>preferences/Advanced.ui</file>
<file>preferences/PathDressupHoldingTags.ui</file>
<file>preferences/PathJob.ui</file>
<file>translations/Path_af.qm</file>
Expand Down
184 changes: 184 additions & 0 deletions src/Mod/Path/Gui/Resources/preferences/Advanced.ui
@@ -0,0 +1,184 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PathGui::DlgSettingsPathColor</class>
<widget class="QWidget" name="PathGui::DlgSettingsPathColor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>512</width>
<height>691</height>
</rect>
</property>
<property name="windowTitle">
<string>Advanced</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Warnings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="Gui::PrefCheckBox" name="WarningSuppressAllSpeeds">
<property name="toolTip">
<string>Suppress all warnings about setting speed rates for accurate cycle time calculation</string>
</property>
<property name="text">
<string>Suppress all missing speeds warning</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>WarningSuppressAllSpeeds</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Path</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="WarningSuppressRapidSpeeds">
<property name="toolTip">
<string>Suppress warning about setting the rapid speed rates for accurate cycle time calculation. Ignored if all speed warnings are already suppressed.</string>
</property>
<property name="text">
<string>Suppress missing rapid speeds warning</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>WarningSuppressRapidSpeeds</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Path</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="WarningSuppressSelectionMode">
<property name="toolTip">
<string>Suppress warning whenever a Path selection mode is activated</string>
</property>
<property name="text">
<string>Suppress selection mode warning</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>WarningSuppressSelectionMode</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Path</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Open CAMlib</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTextEdit" name="textEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans'; font-size:16pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;If openCAMlib is installed with its python interface it can be used by some additional 3d operations.&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Changing this value requires a restart of FreeCAD to take effect.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="EnableAdvancedOCLFeatures">
<property name="text">
<string>Enable OCL dependent features</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>EnableAdvancedOCLFeatures</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Path</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="WarningSuppressOpenCamLib">
<property name="toolTip">
<string>Suppress warning if openCAMlib cannot be found</string>
</property>
<property name="text">
<string>Suppress openCAMlib warning</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>WarningSuppressOpenCamLib</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Path</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>217</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::PrefCheckBox</class>
<extends>QCheckBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
4 changes: 4 additions & 0 deletions src/Mod/Path/InitGui.py
Expand Up @@ -121,6 +121,7 @@ def Initialize(self):
extracmdlist.extend(["Path_Area", "Path_Area_Workplane"])
specialcmdlist.append('Path_Thread_Milling')

if PathPreferences.advancedOCLFeaturesEnabled():
try:
import ocl # pylint: disable=unused-variable
from PathScripts import PathSurfaceGui
Expand Down Expand Up @@ -164,6 +165,9 @@ def Initialize(self):
if curveAccuracy:
Path.Area.setDefaultParams(Accuracy=curveAccuracy)

# keep this one the last entry in the preferences
import PathScripts.PathPreferencesAdvanced as PathPreferencesAdvanced
FreeCADGui.addPreferencePage(PathPreferencesAdvanced.AdvancedPreferencesPage, "Path")
Log('Loading Path workbench... done\n')

def GetClassName(self):
Expand Down
15 changes: 13 additions & 2 deletions src/Mod/Path/PathScripts/PathPreferences.py
Expand Up @@ -62,6 +62,7 @@
WarningSuppressSelectionMode = "WarningSuppressSelectionMode"
WarningSuppressOpenCamLib = "WarningSuppressOpenCamLib"
EnableExperimentalFeatures = "EnableExperimentalFeatures"
EnableAdvancedOCLFeatures = "EnableAdvancedOCLFeatures"


def preferences():
Expand Down Expand Up @@ -243,6 +244,10 @@ def setDefaultTaskPanelLayout(style):
preferences().SetInt(DefaultTaskPanelLayout, style)


def advancedOCLFeaturesEnabled():
return preferences().GetBool(EnableAdvancedOCLFeatures, False)


def experimentalFeaturesEnabled():
return preferences().GetBool(EnableExperimentalFeatures, False)

Expand All @@ -251,8 +256,8 @@ def suppressAllSpeedsWarning():
return preferences().GetBool(WarningSuppressAllSpeeds, True)


def suppressRapidSpeedsWarning():
return suppressAllSpeedsWarning() or preferences().GetBool(WarningSuppressRapidSpeeds, True)
def suppressRapidSpeedsWarning(user=True):
return (user and suppressAllSpeedsWarning()) or preferences().GetBool(WarningSuppressRapidSpeeds, True)


def suppressSelectionModeWarning():
Expand All @@ -262,6 +267,12 @@ def suppressSelectionModeWarning():
def suppressOpenCamLibWarning():
return preferences().GetBool(WarningSuppressOpenCamLib, True)

def setPreferencesAdvanced(ocl, warnSpeeds, warnRapids, warnModes, warnOCL):
preferences().SetBool(EnableAdvancedOCLFeatures, ocl)
preferences().SetBool(WarningSuppressAllSpeeds, warnSpeeds)
preferences().SetBool(WarningSuppressRapidSpeeds, warnRapids)
preferences().SetBool(WarningSuppressSelectionMode, warnModes)
preferences().SetBool(WarningSuppressOpenCamLib, warnOCL)

def lastFileToolLibrary():
filename = preferences().GetString(LastFileToolLibrary)
Expand Down

0 comments on commit 48dc406

Please sign in to comment.