1
/***************************************************************************
2
* Copyright (c) 2009 Werner Mayer <wmayer[at]users.sourceforge.net> *
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"
29
#include <Gui/Application.h>
30
#include <Gui/Command.h>
31
#include <Gui/Document.h>
32
#include <Gui/Selection.h>
33
#include <Gui/View3DInventor.h>
34
#include <Gui/View3DInventorViewer.h>
35
#include <Mod/Part/App/PartFeature.h>
37
#include "TaskDialog.h"
40
using namespace DrawingGui;
42
/* TRANSLATOR DrawingGui::TaskProjection */
44
TaskProjection::TaskProjection()
46
QString texts[10] = {tr("Visible sharp edges"),
47
tr("Visible smooth edges"),
48
tr("Visible sewn edges"),
49
tr("Visible outline edges"),
50
tr("Visible isoparameters"),
51
tr("Hidden sharp edges"),
52
tr("Hidden smooth edges"),
53
tr("Hidden sewn edges"),
54
tr("Hidden outline edges"),
55
tr("Hidden isoparameters")};
56
widget = new QWidget();
57
QVBoxLayout* mainLayout = new QVBoxLayout;
59
for (int i = 0; i < 10; i++) {
60
QCheckBox* cb = new QCheckBox();
64
cb->setText(texts[i]);
65
mainLayout->addWidget(cb);
69
widget->setLayout(mainLayout);
70
widget->setWindowTitle(tr("Project shapes"));
72
addTaskBox(widget, false);
75
TaskProjection::~TaskProjection()
77
// automatically deleted in the sub-class
80
bool TaskProjection::accept()
82
Gui::Document* document = Gui::Application::Instance->activeDocument();
84
QMessageBox::warning(widget,
85
tr("No active document"),
86
tr("There is currently no active document to complete the operation"));
89
std::list<Gui::MDIView*> mdis =
90
document->getMDIViewsOfType(Gui::View3DInventor::getClassTypeId());
92
QMessageBox::warning(widget,
94
tr("There is currently no active view to complete the operation"));
98
Gui::View3DInventorViewer* viewer =
99
static_cast<Gui::View3DInventor*>(mdis.front())->getViewer();
101
viewer->getNearPlane(pnt, dir);
102
float x = 0, y = 1, z = 1;
103
dir.getValue(x, y, z);
105
std::vector<Part::Feature*> shapes = Gui::Selection().getObjectsOfType<Part::Feature>();
106
Gui::Command::openCommand("Project shape");
107
Gui::Command::addModule(Gui::Command::Doc, "Drawing");
108
for (std::vector<Part::Feature*>::iterator it = shapes.begin(); it != shapes.end(); ++it) {
109
const char* object = (*it)->getNameInDocument();
110
Gui::Command::doCommand(
112
"FreeCAD.ActiveDocument.addObject('Drawing::FeatureProjection','%s_proj')",
114
Gui::Command::doCommand(
116
"FreeCAD.ActiveDocument.ActiveObject.Direction=FreeCAD.Vector(%f,%f,%f)",
120
Gui::Command::doCommand(
122
"FreeCAD.ActiveDocument.ActiveObject.Source=FreeCAD.ActiveDocument.%s",
124
Gui::Command::doCommand(Gui::Command::Doc,
125
"FreeCAD.ActiveDocument.ActiveObject.VCompound=%s",
126
(boxes[0]->isChecked() ? "True" : "False"));
127
Gui::Command::doCommand(Gui::Command::Doc,
128
"FreeCAD.ActiveDocument.ActiveObject.Rg1LineVCompound=%s",
129
(boxes[1]->isChecked() ? "True" : "False"));
130
Gui::Command::doCommand(Gui::Command::Doc,
131
"FreeCAD.ActiveDocument.ActiveObject.RgNLineVCompound=%s",
132
(boxes[2]->isChecked() ? "True" : "False"));
133
Gui::Command::doCommand(Gui::Command::Doc,
134
"FreeCAD.ActiveDocument.ActiveObject.OutLineVCompound=%s",
135
(boxes[3]->isChecked() ? "True" : "False"));
136
Gui::Command::doCommand(Gui::Command::Doc,
137
"FreeCAD.ActiveDocument.ActiveObject.IsoLineVCompound=%s",
138
(boxes[4]->isChecked() ? "True" : "False"));
139
Gui::Command::doCommand(Gui::Command::Doc,
140
"FreeCAD.ActiveDocument.ActiveObject.HCompound=%s",
141
(boxes[5]->isChecked() ? "True" : "False"));
142
Gui::Command::doCommand(Gui::Command::Doc,
143
"FreeCAD.ActiveDocument.ActiveObject.Rg1LineHCompound=%s",
144
(boxes[6]->isChecked() ? "True" : "False"));
145
Gui::Command::doCommand(Gui::Command::Doc,
146
"FreeCAD.ActiveDocument.ActiveObject.RgNLineHCompound=%s",
147
(boxes[7]->isChecked() ? "True" : "False"));
148
Gui::Command::doCommand(Gui::Command::Doc,
149
"FreeCAD.ActiveDocument.ActiveObject.OutLineHCompound=%s",
150
(boxes[8]->isChecked() ? "True" : "False"));
151
Gui::Command::doCommand(Gui::Command::Doc,
152
"FreeCAD.ActiveDocument.ActiveObject.IsoLineHCompound=%s",
153
(boxes[9]->isChecked() ? "True" : "False"));
155
Gui::Command::updateActive();
156
Gui::Command::commitCommand();
160
#include "moc_TaskDialog.cpp"