Skip to content

Commit

Permalink
Split OCL and experimental features to allow enabling independently.
Browse files Browse the repository at this point in the history
  • Loading branch information
mlampert committed Feb 14, 2021
1 parent 63cd587 commit da85fde
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
17 changes: 8 additions & 9 deletions src/Mod/Path/Gui/Resources/preferences/Advanced.ui
Expand Up @@ -89,7 +89,7 @@
</sizepolicy>
</property>
<property name="title">
<string>Experimental Features</string>
<string>Open CAMlib</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
Expand Down Expand Up @@ -117,26 +117,25 @@
&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;This will enable some operations and commands which are not fully tested or are otherwise not deemed to be ready for prime time.&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;Some of these features require additional libraries to be installed in order to function correctly:&lt;br /&gt; * opencamlib&lt;br /&gt; * asciidoctor&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;While enabling these features has no impact on the functionality of other features and operations but might have an impact on the stability of FreeCAD itself.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
&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="EnableExperimentalFeatures">
<widget class="Gui::PrefCheckBox" name="EnableAdvancedOCLFeatures">
<property name="text">
<string>Enable Experimental Features</string>
<string>Enable OCL dependent features</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>EnableExperimentalFeatures</cstring>
<cstring>EnableAdvancedOCLFeatures</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Path</cstring>
</property>
</widget>
</item>
<item>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="WarningSuppressOpenCamLib">
<property name="toolTip">
<string>Suppress warning if openCAMlib cannot be found</string>
Expand Down
1 change: 1 addition & 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
9 changes: 7 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 @@ -262,8 +267,8 @@ def suppressSelectionModeWarning():
def suppressOpenCamLibWarning():
return preferences().GetBool(WarningSuppressOpenCamLib, True)

def setPreferencesAdvanced(experimental, warnSpeeds, warnRapids, warnModes, warnOCL):
preferences().SetBool(EnableExperimentalFeatures, experimental)
def setPreferencesAdvanced(ocl, warnSpeeds, warnRapids, warnModes, warnOCL):
preferences().SetBool(EnableAdvancedOCLFeatures, ocl)
preferences().SetBool(WarningSuppressAllSpeeds, warnSpeeds)
preferences().SetBool(WarningSuppressRapidSpeeds, warnRapids)
preferences().SetBool(WarningSuppressSelectionMode, warnModes)
Expand Down
8 changes: 4 additions & 4 deletions src/Mod/Path/PathScripts/PathPreferencesAdvanced.py
Expand Up @@ -32,11 +32,11 @@ class AdvancedPreferencesPage:
def __init__(self, parent=None):
self.form = FreeCADGui.PySideUic.loadUi(':preferences/Advanced.ui')
self.form.WarningSuppressAllSpeeds.stateChanged.connect(self.updateSelection)
self.form.EnableExperimentalFeatures.stateChanged.connect(self.updateSelection)
self.form.EnableAdvancedOCLFeatures.stateChanged.connect(self.updateSelection)

def saveSettings(self):
PathPreferences.setPreferencesAdvanced(
self.form.EnableExperimentalFeatures.isChecked(),
self.form.EnableAdvancedOCLFeatures.isChecked(),
self.form.WarningSuppressAllSpeeds.isChecked(),
self.form.WarningSuppressRapidSpeeds.isChecked(),
self.form.WarningSuppressSelectionMode.isChecked(),
Expand All @@ -46,12 +46,12 @@ def loadSettings(self):
self.form.WarningSuppressAllSpeeds.setChecked(PathPreferences.suppressAllSpeedsWarning())
self.form.WarningSuppressRapidSpeeds.setChecked(PathPreferences.suppressRapidSpeedsWarning(False))
self.form.WarningSuppressSelectionMode.setChecked(PathPreferences.suppressSelectionModeWarning())
self.form.EnableExperimentalFeatures.setChecked(PathPreferences.experimentalFeaturesEnabled())
self.form.EnableAdvancedOCLFeatures.setChecked(PathPreferences.advancedOCLFeaturesEnabled())
self.form.WarningSuppressOpenCamLib.setChecked(PathPreferences.suppressOpenCamLibWarning())
self.updateSelection()

def updateSelection(self, state=None):
self.form.WarningSuppressOpenCamLib.setEnabled(self.form.EnableExperimentalFeatures.isChecked())
self.form.WarningSuppressOpenCamLib.setEnabled(self.form.EnableAdvancedOCLFeatures.isChecked())
if self.form.WarningSuppressAllSpeeds.isChecked():
self.form.WarningSuppressRapidSpeeds.setChecked(True)
self.form.WarningSuppressRapidSpeeds.setEnabled(False)
Expand Down

0 comments on commit da85fde

Please sign in to comment.