Sketcher: TV: preferences UI

* 4 checkboxes for setting defaults for visibility automation
* "Apply to existing sketches" button
This commit is contained in:
DeepSOIC 2016-06-19 23:59:42 +03:00
parent d9376eb487
commit 95f70b0b9d
3 changed files with 274 additions and 63 deletions

View File

@ -26,14 +26,18 @@
#ifndef _PreComp_
# include <QPainter>
# include <QPixmap>
# include <QMessageBox>
#endif
#include "SketcherSettings.h"
#include "ui_SketcherSettings.h"
#include "TaskSketcherGeneral.h"
#include <Base/Console.h>
#include <Base/Interpreter.h>
#include <App/Application.h>
#include <Gui/PrefWidgets.h>
#include <Gui/Inventor/MarkerBitmaps.h>
#include <Gui/Command.h>
using namespace SketcherGui;
@ -82,6 +86,8 @@ SketcherSettings::SketcherSettings(QWidget* parent)
ui->comboBox->addItem(QIcon(px), QString(), QVariant(it->second));
}
connect(ui->btnTVApply, SIGNAL(clicked(bool)), this, SLOT(onBtnTVApplyClicked(bool)));
}
/**
@ -119,6 +125,10 @@ void SketcherSettings::saveSettings()
ui->dialogOnDistanceConstraint->onSave();
ui->continueMode->onSave();
ui->checkBoxAdvancedSolverTaskBox->onSave();
ui->checkBoxTVHideDependent->onSave();
ui->checkBoxTVShowLinks->onSave();
ui->checkBoxTVShowSupport->onSave();
ui->checkBoxTVRestoreCamera->onSave();
form->saveSettings();
ParameterGrp::handle hViewGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
@ -157,6 +167,10 @@ void SketcherSettings::loadSettings()
ui->dialogOnDistanceConstraint->onRestore();
ui->continueMode->onRestore();
ui->checkBoxAdvancedSolverTaskBox->onRestore();
ui->checkBoxTVHideDependent->onRestore();
ui->checkBoxTVShowLinks->onRestore();
ui->checkBoxTVShowSupport->onRestore();
ui->checkBoxTVRestoreCamera->onRestore();
form->loadSettings();
std::list<int> sizes = Gui::Inventor::MarkerBitmaps::getSupportedSizes("CIRCLE_FILLED");
@ -189,5 +203,32 @@ void SketcherSettings::changeEvent(QEvent *e)
}
}
void SketcherSettings::onBtnTVApplyClicked(bool)
{
QString errMsg;
try{
Gui::Command::doCommand(Gui::Command::Gui,
"for name,doc in App.listDocuments().items():\n"
" for sketch in doc.findObjects('Sketcher::SketchObject'):\n"
" sketch.ViewObject.HideDependent = %s\n"
" sketch.ViewObject.ShowLinks = %s\n"
" sketch.ViewObject.ShowSupport = %s\n"
" sketch.ViewObject.RestoreCamera = %s\n",
this->ui->checkBoxTVHideDependent->isChecked() ? "True": "False",
this->ui->checkBoxTVShowLinks->isChecked() ? "True": "False",
this->ui->checkBoxTVShowSupport->isChecked() ? "True": "False",
this->ui->checkBoxTVRestoreCamera->isChecked() ? "True": "False");
} catch (Base::PyException &e){
Base::Console().Error("SketcherSettings::onBtnTVApplyClicked:\n");
e.ReportException();
errMsg = QString::fromLatin1(e.what());
} catch (...) {
errMsg = tr("Unexpected C++ exception");
}
if(errMsg.length()>0){
QMessageBox::warning(this, tr("Sketcher"),errMsg);
}
}
#include "moc_SketcherSettings.cpp"

View File

@ -47,6 +47,9 @@ public:
protected:
void changeEvent(QEvent *e);
private Q_SLOTS:
void onBtnTVApplyClicked(bool);
private:
Ui_SketcherSettings* ui;
SketcherGeneralWidget* form;

View File

@ -6,14 +6,49 @@
<rect>
<x>0</x>
<y>0</y>
<width>404</width>
<height>744</height>
<width>427</width>
<height>1253</height>
</rect>
</property>
<property name="windowTitle">
<string>Sketcher</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="7" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Sketch Solver</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="Gui::PrefCheckBox" name="checkBoxAdvancedSolverTaskBox">
<property name="text">
<string>Show Advanced Solver Control in the Task bar</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>ShowSolverAdvancedWidget</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="groupBoxSketcherColor">
<property name="title">
@ -40,7 +75,7 @@
<property name="toolTip">
<string>The color of edges being edited</string>
</property>
<property name="color">
<property name="color" stdset="0">
<color>
<red>255</red>
<green>255</green>
@ -73,7 +108,7 @@
<property name="toolTip">
<string>The color of vertices being edited</string>
</property>
<property name="color">
<property name="color" stdset="0">
<color>
<red>255</red>
<green>255</green>
@ -106,7 +141,7 @@
<property name="toolTip">
<string>The color of edges being edited</string>
</property>
<property name="color">
<property name="color" stdset="0">
<color>
<red>255</red>
<green>255</green>
@ -139,7 +174,7 @@
<property name="toolTip">
<string>The color of vertices being edited</string>
</property>
<property name="color">
<property name="color" stdset="0">
<color>
<red>255</red>
<green>38</green>
@ -172,7 +207,7 @@
<property name="toolTip">
<string>The color of fully constrained geometry in edit mode</string>
</property>
<property name="color">
<property name="color" stdset="0">
<color>
<red>255</red>
<green>38</green>
@ -192,7 +227,7 @@
<property name="toolTip">
<string>The color of construction geometry in edit mode</string>
</property>
<property name="color">
<property name="color" stdset="0">
<color>
<red>0</red>
<green>0</green>
@ -225,7 +260,7 @@
<property name="toolTip">
<string>The color of external geometry in edit mode</string>
</property>
<property name="color">
<property name="color" stdset="0">
<color>
<red>204</red>
<green>51</green>
@ -271,7 +306,7 @@
<property name="toolTip">
<string>The color of fully constrained geometry in edit mode</string>
</property>
<property name="color">
<property name="color" stdset="0">
<color>
<red>0</red>
<green>255</green>
@ -397,7 +432,7 @@
</item>
<item row="13" column="1">
<widget class="Gui::PrefColorButton" name="CursorTextColor">
<property name="color">
<property name="color" stdset="0">
<color>
<red>0</red>
<green>0</green>
@ -446,7 +481,7 @@
<property name="toolTip">
<string>The color of driving constraints in edit mode</string>
</property>
<property name="color">
<property name="color" stdset="0">
<color>
<red>255</red>
<green>38</green>
@ -466,7 +501,7 @@
<property name="toolTip">
<string>The color of non-driving constrains or dimensions in edit mode</string>
</property>
<property name="color">
<property name="color" stdset="0">
<color>
<red>0</red>
<green>38</green>
@ -492,19 +527,6 @@
<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">
@ -540,13 +562,16 @@
</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">
<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>Grid line pattern</string>
<string>Font size</string>
</property>
</widget>
</item>
@ -573,6 +598,16 @@
</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">
<widget class="Gui::PrefCheckBox" name="continueMode">
<property name="text">
@ -589,44 +624,156 @@
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Sketch Solver</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="Gui::PrefCheckBox" name="checkBoxAdvancedSolverTaskBox">
<property name="text">
<string>Show Advanced Solver Control in the Task bar</string>
<item row="5" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_3">
<property name="enabled">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>ShowSolverAdvancedWidget</cstring>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher</cstring>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="title">
<string>Visibility automation</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="Gui::PrefCheckBox" name="checkBoxTVHideDependent">
<property name="toolTip">
<string>When opening sketch, hide all features that depend on it.</string>
</property>
<property name="text">
<string>Hide all objects that depend on the sketch</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>HideDependent</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher/General</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="checkBoxTVShowLinks">
<property name="toolTip">
<string>When opening sketch, show sources for external geometry links.</string>
</property>
<property name="text">
<string>Show objects used for external geometry</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>ShowLinks</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher/General</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="checkBoxTVShowSupport">
<property name="toolTip">
<string>When opening sketch, show objects the sketch is attached to.</string>
</property>
<property name="text">
<string>Show object(s) sketch is attached to</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>ShowSupport</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher/General</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="checkBoxTVRestoreCamera">
<property name="toolTip">
<string>When closing sketch, move camera back to where it was before sketch was opened.</string>
</property>
<property name="text">
<string>Restore camera position after editing</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>RestoreCamera</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher/General</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_9">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Note: these settings are defaults applied to new sketches. The behavior is remembered for each sketch individually as properties on View tab.</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnTVApply">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Apply current smart visibility to all sketches in open documents (update properties to match).</string>
</property>
<property name="text">
<string>Apply to existing sketches</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="0">
<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>
@ -652,11 +799,31 @@
</customwidget>
</customwidgets>
<tabstops>
<tabstop>CursorTextColor</tabstop>
<tabstop>SketchEdgeColor</tabstop>
<tabstop>SketchVertexColor</tabstop>
<tabstop>EditedEdgeColor</tabstop>
<tabstop>EditedVertexColor</tabstop>
<tabstop>ConstructionColor</tabstop>
<tabstop>ExternalColor</tabstop>
<tabstop>FullyConstrainedColor</tabstop>
<tabstop>ConstrainedColor</tabstop>
<tabstop>NonDrivingConstraintColor</tabstop>
<tabstop>DatumColor</tabstop>
<tabstop>SketcherDatumWidth</tabstop>
<tabstop>DefaultSketcherVertexWidth</tabstop>
<tabstop>DefaultSketcherLineWidth</tabstop>
<tabstop>CursorTextColor</tabstop>
<tabstop>EditSketcherFontSize</tabstop>
<tabstop>EditSketcherMarkerSize</tabstop>
<tabstop>comboBox</tabstop>
<tabstop>dialogOnDistanceConstraint</tabstop>
<tabstop>continueMode</tabstop>
<tabstop>checkBoxTVHideDependent</tabstop>
<tabstop>checkBoxTVShowLinks</tabstop>
<tabstop>checkBoxTVShowSupport</tabstop>
<tabstop>checkBoxTVRestoreCamera</tabstop>
<tabstop>btnTVApply</tabstop>
<tabstop>checkBoxAdvancedSolverTaskBox</tabstop>
</tabstops>
<resources/>
<connections/>