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
***************************************************************************/
22
//this file originally part of TechDraw workbench
23
//migrated to TechDraw workbench 2022-01-26 by Wandererfan
25
#include "PreCompiled.h"
27
# include <QMessageBox>
30
#include <Gui/Application.h>
31
#include <Gui/BitmapFactory.h>
32
#include <Gui/Command.h>
33
#include <Gui/Document.h>
34
#include <Gui/MainWindow.h>
35
#include <Gui/Selection.h>
36
#include <Gui/View3DInventor.h>
37
#include <Gui/View3DInventorViewer.h>
38
#include <Mod/Part/App/PartFeature.h>
40
#include "TaskProjection.h"
41
#include "ui_TaskProjection.h"
44
using namespace TechDrawGui;
46
/* TRANSLATOR TechDrawGui::TaskProjection */
48
TaskProjection::TaskProjection() :
49
ui(new Ui_TaskProjection)
55
TaskProjection::~TaskProjection()
57
// automatically deleted in the sub-class
60
bool TaskProjection::accept()
62
Gui::Document* document = Gui::Application::Instance->activeDocument();
64
QMessageBox::warning(Gui::getMainWindow(), tr("No active document"),
65
tr("There is currently no active document to complete the operation"));
68
std::list<Gui::MDIView*> mdis = document->getMDIViewsOfType(Gui::View3DInventor::getClassTypeId());
70
QMessageBox::warning(Gui::getMainWindow(), tr("No active view"),
71
tr("There is currently no active view to complete the operation"));
75
Gui::View3DInventorViewer* viewer = static_cast<Gui::View3DInventor*>(mdis.front())->getViewer();
77
viewer->getNearPlane(pnt, dir);
81
std::vector<Part::Feature*> shapes = Gui::Selection().getObjectsOfType<Part::Feature>();
82
Gui::Command::openCommand("Project shape");
83
Gui::Command::addModule(Gui::Command::Doc, "TechDraw");
84
for (std::vector<Part::Feature*>::iterator it = shapes.begin(); it != shapes.end(); ++it) {
85
const char* object = (*it)->getNameInDocument();
86
Gui::Command::doCommand(Gui::Command::Doc,
87
"FreeCAD.ActiveDocument.addObject('TechDraw::FeatureProjection', '%s_proj')", object);
88
Gui::Command::doCommand(Gui::Command::Doc,
89
"FreeCAD.ActiveDocument.ActiveObject.Direction=FreeCAD.Vector(%f, %f, %f)", x, y,z);
90
Gui::Command::doCommand(Gui::Command::Doc,
91
"FreeCAD.ActiveDocument.ActiveObject.Source=FreeCAD.ActiveDocument.%s", object);
92
Gui::Command::doCommand(Gui::Command::Doc,
93
"FreeCAD.ActiveDocument.ActiveObject.VCompound=%s", (ui->cbVisSharp->isChecked() ? "True" : "False"));
94
Gui::Command::doCommand(Gui::Command::Doc,
95
"FreeCAD.ActiveDocument.ActiveObject.Rg1LineVCompound=%s", (ui->cbVisSmooth->isChecked() ? "True" : "False"));
96
Gui::Command::doCommand(Gui::Command::Doc,
97
"FreeCAD.ActiveDocument.ActiveObject.RgNLineVCompound=%s", (ui->cbVisSewn->isChecked() ? "True" : "False"));
98
Gui::Command::doCommand(Gui::Command::Doc,
99
"FreeCAD.ActiveDocument.ActiveObject.OutLineVCompound=%s", (ui->cbVisOutline->isChecked() ? "True" : "False"));
100
Gui::Command::doCommand(Gui::Command::Doc,
101
"FreeCAD.ActiveDocument.ActiveObject.IsoLineVCompound=%s", (ui->cbVisIso->isChecked() ? "True" : "False"));
102
Gui::Command::doCommand(Gui::Command::Doc,
103
"FreeCAD.ActiveDocument.ActiveObject.HCompound=%s", (ui->cbHidSharp->isChecked() ? "True" : "False"));
104
Gui::Command::doCommand(Gui::Command::Doc,
105
"FreeCAD.ActiveDocument.ActiveObject.Rg1LineHCompound=%s", (ui->cbHidSmooth->isChecked() ? "True" : "False"));
106
Gui::Command::doCommand(Gui::Command::Doc,
107
"FreeCAD.ActiveDocument.ActiveObject.RgNLineHCompound=%s", (ui->cbHidSewn->isChecked() ? "True" : "False"));
108
Gui::Command::doCommand(Gui::Command::Doc,
109
"FreeCAD.ActiveDocument.ActiveObject.OutLineHCompound=%s", (ui->cbHidOutline->isChecked() ? "True" : "False"));
110
Gui::Command::doCommand(Gui::Command::Doc,
111
"FreeCAD.ActiveDocument.ActiveObject.IsoLineHCompound=%s", (ui->cbHidIso->isChecked() ? "True" : "False"));
113
Gui::Command::updateActive();
114
Gui::Command::commitCommand();
118
bool TaskProjection::reject()
124
///////////////////////////////////////////////////////////////////////////
126
TaskDlgProjection::TaskDlgProjection() :
129
widget = new TaskProjection();
130
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/TechDraw_ProjectShape"), widget->windowTitle(), true, nullptr);
131
taskbox->groupLayout()->addWidget(widget);
132
Content.push_back(taskbox);
133
setAutoCloseOnTransactionChange(true);
136
TaskDlgProjection::~TaskDlgProjection()
140
void TaskDlgProjection::update()
144
//==== calls from the TaskView ===============================================================
145
void TaskDlgProjection::open()
149
void TaskDlgProjection::clicked(int i)
154
bool TaskDlgProjection::accept()
160
bool TaskDlgProjection::reject()
166
#include "moc_TaskProjection.cpp"