1
/***************************************************************************
2
* Copyright (c) 2009 Jürgen Riegel <juergen.riegel@web.de> *
4
* This file is part of the FreeCAD CAx development system. *
6
* This library is free software; you can redistribute it and/or *
7
* modify it under the terms of the GNU Library General Public *
8
* License as published by the Free Software Foundation; either *
9
* version 2 of the License, or (at your option) any later version. *
11
* This library is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU Library General Public License for more details. *
16
* You should have received a copy of the GNU Library General Public *
17
* License along with this library; see the file COPYING.LIB. If not, *
18
* write to the Free Software Foundation, Inc., 59 Temple Place, *
19
* Suite 330, Boston, MA 02111-1307, USA *
21
***************************************************************************/
23
#include "PreCompiled.h"
25
#include <Gui/Command.h>
27
#include "TaskDlgEditSketch.h"
28
#include "ViewProviderSketch.h"
31
using namespace SketcherGui;
33
namespace sp = std::placeholders;
35
//**************************************************************************
36
//**************************************************************************
38
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
40
TaskDlgEditSketch::TaskDlgEditSketch(ViewProviderSketch* sketchView)
42
, sketchView(sketchView)
45
ToolSettings = new TaskSketcherTool(sketchView);
46
Constraints = new TaskSketcherConstraints(sketchView);
47
Elements = new TaskSketcherElements(sketchView);
48
Messages = new TaskSketcherMessages(sketchView);
49
SolverAdvanced = new TaskSketcherSolverAdvanced(sketchView);
51
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
52
"User parameter:BaseApp/Preferences/Mod/Sketcher");
53
setEscapeButtonEnabled(hGrp->GetBool("LeaveSketchWithEscape", true));
55
Content.push_back(ToolSettings);
56
Content.push_back(Messages);
58
if (hGrp->GetBool("ShowSolverAdvancedWidget", false)) {
59
Content.push_back(SolverAdvanced);
62
Content.push_back(Constraints);
63
Content.push_back(Elements);
65
if (!hGrp->GetBool("ExpandedMessagesWidget", true)) {
66
Messages->hideGroupBox();
68
if (!hGrp->GetBool("ExpandedSolverAdvancedWidget", false)) {
69
SolverAdvanced->hideGroupBox();
71
if (!hGrp->GetBool("ExpandedConstraintsWidget", true)) {
72
Constraints->hideGroupBox();
74
if (!hGrp->GetBool("ExpandedElementsWidget", true)) {
75
Elements->hideGroupBox();
78
connectionToolSettings = sketchView->registerToolChanged(
79
std::bind(&SketcherGui::TaskDlgEditSketch::slotToolChanged, this, sp::_1));
81
ToolSettings->setHidden(true);
84
TaskDlgEditSketch::~TaskDlgEditSketch()
86
// to make sure to delete the advanced solver panel
87
// it must be part to the 'Content' array
88
std::vector<QWidget*>::iterator it = std::find(Content.begin(), Content.end(), SolverAdvanced);
89
if (it == Content.end()) {
90
Content.push_back(SolverAdvanced);
93
connectionToolSettings.disconnect();
96
void TaskDlgEditSketch::slotToolChanged(const std::string& toolname)
98
bool widgetvisible = false;
100
if (toolname != "DSH_None") {
101
widgetvisible = sketchView->toolManager.isWidgetVisible();
103
ToolSettings->toolChanged(toolname);
106
ToolSettings->setHidden(!widgetvisible);
109
//==== calls from the TaskView ===============================================================
112
void TaskDlgEditSketch::open()
115
void TaskDlgEditSketch::clicked(int)
118
bool TaskDlgEditSketch::accept()
123
bool TaskDlgEditSketch::reject()
125
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
126
"User parameter:BaseApp/Preferences/Mod/Sketcher");
127
hGrp->SetBool("ExpandedMessagesWidget", Messages->isGroupVisible());
128
hGrp->SetBool("ExpandedSolverAdvancedWidget", SolverAdvanced->isGroupVisible());
129
hGrp->SetBool("ExpandedConstraintsWidget", Constraints->isGroupVisible());
130
hGrp->SetBool("ExpandedElementsWidget", Elements->isGroupVisible());
132
if (sketchView && sketchView->getSketchMode() != ViewProviderSketch::STATUS_NONE) {
133
sketchView->purgeHandler();
136
std::string document = getDocumentName(); // needed because resetEdit() deletes this instance
137
Gui::Command::doCommand(Gui::Command::Gui,
138
"Gui.getDocument('%s').resetEdit()",
140
Gui::Command::doCommand(Gui::Command::Doc,
141
"App.getDocument('%s').recompute()",
148
#include "moc_TaskDlgEditSketch.cpp"