FreeCAD

Форк
0
/
TaskDlgEditSketch.cpp 
148 строк · 5.5 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2009 Jürgen Riegel <juergen.riegel@web.de>              *
3
 *                                                                         *
4
 *   This file is part of the FreeCAD CAx development system.              *
5
 *                                                                         *
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.      *
10
 *                                                                         *
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.                  *
15
 *                                                                         *
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                                *
20
 *                                                                         *
21
 ***************************************************************************/
22

23
#include "PreCompiled.h"
24

25
#include <Gui/Command.h>
26

27
#include "TaskDlgEditSketch.h"
28
#include "ViewProviderSketch.h"
29

30

31
using namespace SketcherGui;
32

33
namespace sp = std::placeholders;
34

35
//**************************************************************************
36
//**************************************************************************
37
// TaskDialog
38
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
39

40
TaskDlgEditSketch::TaskDlgEditSketch(ViewProviderSketch* sketchView)
41
    : TaskDialog()
42
    , sketchView(sketchView)
43
{
44
    assert(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);
50

51
    ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
52
        "User parameter:BaseApp/Preferences/Mod/Sketcher");
53
    setEscapeButtonEnabled(hGrp->GetBool("LeaveSketchWithEscape", true));
54

55
    Content.push_back(ToolSettings);
56
    Content.push_back(Messages);
57

58
    if (hGrp->GetBool("ShowSolverAdvancedWidget", false)) {
59
        Content.push_back(SolverAdvanced);
60
    }
61

62
    Content.push_back(Constraints);
63
    Content.push_back(Elements);
64

65
    if (!hGrp->GetBool("ExpandedMessagesWidget", true)) {
66
        Messages->hideGroupBox();
67
    }
68
    if (!hGrp->GetBool("ExpandedSolverAdvancedWidget", false)) {
69
        SolverAdvanced->hideGroupBox();
70
    }
71
    if (!hGrp->GetBool("ExpandedConstraintsWidget", true)) {
72
        Constraints->hideGroupBox();
73
    }
74
    if (!hGrp->GetBool("ExpandedElementsWidget", true)) {
75
        Elements->hideGroupBox();
76
    }
77

78
    connectionToolSettings = sketchView->registerToolChanged(
79
        std::bind(&SketcherGui::TaskDlgEditSketch::slotToolChanged, this, sp::_1));
80

81
    ToolSettings->setHidden(true);
82
}
83

84
TaskDlgEditSketch::~TaskDlgEditSketch()
85
{
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);
91
    }
92

93
    connectionToolSettings.disconnect();
94
}
95

96
void TaskDlgEditSketch::slotToolChanged(const std::string& toolname)
97
{
98
    bool widgetvisible = false;
99

100
    if (toolname != "DSH_None") {
101
        widgetvisible = sketchView->toolManager.isWidgetVisible();
102

103
        ToolSettings->toolChanged(toolname);
104
    }
105

106
    ToolSettings->setHidden(!widgetvisible);
107
}
108

109
//==== calls from the TaskView ===============================================================
110

111

112
void TaskDlgEditSketch::open()
113
{}
114

115
void TaskDlgEditSketch::clicked(int)
116
{}
117

118
bool TaskDlgEditSketch::accept()
119
{
120
    return true;
121
}
122

123
bool TaskDlgEditSketch::reject()
124
{
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());
131

132
    if (sketchView && sketchView->getSketchMode() != ViewProviderSketch::STATUS_NONE) {
133
        sketchView->purgeHandler();
134
    }
135

136
    std::string document = getDocumentName();  // needed because resetEdit() deletes this instance
137
    Gui::Command::doCommand(Gui::Command::Gui,
138
                            "Gui.getDocument('%s').resetEdit()",
139
                            document.c_str());
140
    Gui::Command::doCommand(Gui::Command::Doc,
141
                            "App.getDocument('%s').recompute()",
142
                            document.c_str());
143

144
    return true;
145
}
146

147

148
#include "moc_TaskDlgEditSketch.cpp"
149

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.