make part design loft functional

This commit is contained in:
Stefan Tröger 2015-06-04 17:46:31 +02:00
parent 987880fffa
commit d435e15a97
10 changed files with 768 additions and 23 deletions

View File

@ -104,25 +104,28 @@ App::DocumentObjectExecReturn *Loft::execute(void)
//build up multisections //build up multisections
auto multisections = Sections.getValues(); auto multisections = Sections.getValues();
if(multisections.empty())
return new App::DocumentObjectExecReturn("Loft: At least one section is needed");
std::vector<std::vector<TopoDS_Wire>> wiresections; std::vector<std::vector<TopoDS_Wire>> wiresections;
for(TopoDS_Wire& wire : wires) for(TopoDS_Wire& wire : wires)
wiresections.push_back(std::vector<TopoDS_Wire>(1, wire)); wiresections.push_back(std::vector<TopoDS_Wire>(1, wire));
for(App::DocumentObject* obj : multisections) { for(App::DocumentObject* obj : multisections) {
if(!obj->isDerivedFrom(Part::Feature::getClassTypeId())) if(!obj->isDerivedFrom(Part::Feature::getClassTypeId()))
return new App::DocumentObjectExecReturn("All sections need to be part features"); return new App::DocumentObjectExecReturn("Loft: All sections need to be part features");
TopExp_Explorer ex; TopExp_Explorer ex;
int i=0; int i=0;
for (ex.Init(static_cast<Part::Feature*>(obj)->Shape.getValue(), TopAbs_WIRE); ex.More(); ex.Next()) { for (ex.Init(static_cast<Part::Feature*>(obj)->Shape.getValue(), TopAbs_WIRE); ex.More(); ex.Next()) {
wiresections[i].push_back(TopoDS::Wire(ex.Current())); wiresections[i].push_back(TopoDS::Wire(ex.Current()));
if(i>=wiresections.size()) if(i>=wiresections.size())
return new App::DocumentObjectExecReturn("Sections need to have the same amount of inner wires as the base section"); return new App::DocumentObjectExecReturn("Loft: Sections need to have the same amount of inner wires as the base section");
++i; ++i;
} }
if(i<wiresections.size()) if(i<wiresections.size())
return new App::DocumentObjectExecReturn("Sections need to have the same amount of inner wires as the base section"); return new App::DocumentObjectExecReturn("Loft: Sections need to have the same amount of inner wires as the base section");
} }
@ -135,6 +138,7 @@ App::DocumentObjectExecReturn *Loft::execute(void)
for(TopoDS_Wire& wire : wires) for(TopoDS_Wire& wire : wires)
mkTS.AddWire(wire); mkTS.AddWire(wire);
mkTS.Build();
if (!mkTS.IsDone()) if (!mkTS.IsDone())
return new App::DocumentObjectExecReturn("Loft could not be build"); return new App::DocumentObjectExecReturn("Loft could not be build");
@ -163,7 +167,7 @@ App::DocumentObjectExecReturn *Loft::execute(void)
BRepBuilderAPI_MakeSolid mkSolid; BRepBuilderAPI_MakeSolid mkSolid;
mkSolid.Add(TopoDS::Shell(sewer.SewedShape())); mkSolid.Add(TopoDS::Shell(sewer.SewedShape()));
if(!mkSolid.IsDone()) if(!mkSolid.IsDone())
return new App::DocumentObjectExecReturn("Result is not a solid"); return new App::DocumentObjectExecReturn("Loft: Result is not a solid");
TopoDS_Shape result = mkSolid.Shape(); TopoDS_Shape result = mkSolid.Shape();
BRepClass3d_SolidClassifier SC(result); BRepClass3d_SolidClassifier SC(result);
@ -184,12 +188,12 @@ App::DocumentObjectExecReturn *Loft::execute(void)
BRepAlgoAPI_Fuse mkFuse(base, result); BRepAlgoAPI_Fuse mkFuse(base, result);
if (!mkFuse.IsDone()) if (!mkFuse.IsDone())
return new App::DocumentObjectExecReturn("Adding the loft failed"); return new App::DocumentObjectExecReturn("Loft: Adding the loft failed");
// we have to get the solids (fuse sometimes creates compounds) // we have to get the solids (fuse sometimes creates compounds)
TopoDS_Shape boolOp = this->getSolid(mkFuse.Shape()); TopoDS_Shape boolOp = this->getSolid(mkFuse.Shape());
// lets check if the result is a solid // lets check if the result is a solid
if (boolOp.IsNull()) if (boolOp.IsNull())
return new App::DocumentObjectExecReturn("Resulting shape is not a solid"); return new App::DocumentObjectExecReturn("Loft: Resulting shape is not a solid");
boolOp = refineShapeIfActive(boolOp); boolOp = refineShapeIfActive(boolOp);
Shape.setValue(boolOp); Shape.setValue(boolOp);
@ -198,12 +202,12 @@ App::DocumentObjectExecReturn *Loft::execute(void)
BRepAlgoAPI_Cut mkCut(base, result); BRepAlgoAPI_Cut mkCut(base, result);
if (!mkCut.IsDone()) if (!mkCut.IsDone())
return new App::DocumentObjectExecReturn("Subtracting the loft failed"); return new App::DocumentObjectExecReturn("Loft: Subtracting the loft failed");
// we have to get the solids (fuse sometimes creates compounds) // we have to get the solids (fuse sometimes creates compounds)
TopoDS_Shape boolOp = this->getSolid(mkCut.Shape()); TopoDS_Shape boolOp = this->getSolid(mkCut.Shape());
// lets check if the result is a solid // lets check if the result is a solid
if (boolOp.IsNull()) if (boolOp.IsNull())
return new App::DocumentObjectExecReturn("Resulting shape is not a solid"); return new App::DocumentObjectExecReturn("Loft: Resulting shape is not a solid");
boolOp = refineShapeIfActive(boolOp); boolOp = refineShapeIfActive(boolOp);
Shape.setValue(boolOp); Shape.setValue(boolOp);
@ -218,7 +222,7 @@ App::DocumentObjectExecReturn *Loft::execute(void)
return new App::DocumentObjectExecReturn(e->GetMessageString()); return new App::DocumentObjectExecReturn(e->GetMessageString());
} }
catch (...) { catch (...) {
return new App::DocumentObjectExecReturn("A fatal error occurred when making the loft"); return new App::DocumentObjectExecReturn("Loft: A fatal error occurred when making the loft");
} }
} }

View File

@ -51,6 +51,7 @@ set(PartDesignGui_MOC_HDRS
TaskBooleanParameters.h TaskBooleanParameters.h
TaskPrimitiveParameters.h TaskPrimitiveParameters.h
TaskPipeParameters.h TaskPipeParameters.h
TaskLoftParameters.h
) )
fc_wrap_cpp(PartDesignGui_MOC_SRCS ${PartDesignGui_MOC_HDRS}) fc_wrap_cpp(PartDesignGui_MOC_SRCS ${PartDesignGui_MOC_HDRS})
SOURCE_GROUP("Moc" FILES ${PartDesignGui_MOC_SRCS}) SOURCE_GROUP("Moc" FILES ${PartDesignGui_MOC_SRCS})
@ -80,6 +81,7 @@ set(PartDesignGui_UIC_SRCS
TaskPipeParameters.ui TaskPipeParameters.ui
TaskPipeOrientation.ui TaskPipeOrientation.ui
TaskPipeScaling.ui TaskPipeScaling.ui
TaskLoftParameters.ui
) )
qt4_wrap_ui(PartDesignGui_UIC_HDRS ${PartDesignGui_UIC_SRCS}) qt4_wrap_ui(PartDesignGui_UIC_HDRS ${PartDesignGui_UIC_SRCS})
@ -213,6 +215,9 @@ SET(PartDesignGuiTaskDlgs_SRCS
TaskPipeScaling.ui TaskPipeScaling.ui
TaskPipeParameters.h TaskPipeParameters.h
TaskPipeParameters.cpp TaskPipeParameters.cpp
TaskLoftParameters.ui
TaskLoftParameters.h
TaskLoftParameters.cpp
) )
SOURCE_GROUP("TaskDialogs" FILES ${PartDesignGuiTaskDlgs_SRCS}) SOURCE_GROUP("TaskDialogs" FILES ${PartDesignGuiTaskDlgs_SRCS})

View File

@ -1363,6 +1363,86 @@ bool CmdPartDesignSubtractivePipe::isActive(void)
return hasActiveDocument(); return hasActiveDocument();
} }
//===========================================================================
// PartDesign_Additive_Loft
//===========================================================================
DEF_STD_CMD_A(CmdPartDesignAdditiveLoft);
CmdPartDesignAdditiveLoft::CmdPartDesignAdditiveLoft()
: Command("PartDesign_AdditiveLoft")
{
sAppModule = "PartDesign";
sGroup = QT_TR_NOOP("PartDesign");
sMenuText = QT_TR_NOOP("Additive pipe");
sToolTipText = QT_TR_NOOP("Sweep a selected sketch along a path or to other profiles");
sWhatsThis = "PartDesign_Additive_Loft";
sStatusTip = sToolTipText;
sPixmap = "PartDesign_Additive_Loft";
}
void CmdPartDesignAdditiveLoft::activated(int iMsg)
{
Gui::Command* cmd = this;
auto worker = [cmd](Part::Part2DObject* sketch, std::string FeatName) {
if (FeatName.empty()) return;
// specific parameters for pipe
Gui::Command::updateActive();
finishSketchBased(cmd, sketch, FeatName);
cmd->adjustCameraPosition();
};
prepareSketchBased(this, "AdditiveLoft", worker);
}
bool CmdPartDesignAdditiveLoft::isActive(void)
{
return hasActiveDocument();
}
//===========================================================================
// PartDesign_Subtractive_Loft
//===========================================================================
DEF_STD_CMD_A(CmdPartDesignSubtractiveLoft);
CmdPartDesignSubtractiveLoft::CmdPartDesignSubtractiveLoft()
: Command("PartDesign_SubtractiveLoft")
{
sAppModule = "PartDesign";
sGroup = QT_TR_NOOP("PartDesign");
sMenuText = QT_TR_NOOP("Subtractive pipe");
sToolTipText = QT_TR_NOOP("Sweep a selected sketch along a path or to other profiles and remove it from the body");
sWhatsThis = "PartDesign_Subtractive_Loft";
sStatusTip = sToolTipText;
sPixmap = "PartDesign_Subtractive_Loft";
}
void CmdPartDesignSubtractiveLoft::activated(int iMsg)
{
Gui::Command* cmd = this;
auto worker = [cmd](Part::Part2DObject* sketch, std::string FeatName) {
if (FeatName.empty()) return;
// specific parameters for pipe
Gui::Command::updateActive();
finishSketchBased(cmd, sketch, FeatName);
cmd->adjustCameraPosition();
};
prepareSketchBased(this, "SubtractiveLoft", worker);
}
bool CmdPartDesignSubtractiveLoft::isActive(void)
{
return hasActiveDocument();
}
//=========================================================================== //===========================================================================
// Common utility functions for Dressup features // Common utility functions for Dressup features
//=========================================================================== //===========================================================================
@ -2157,6 +2237,10 @@ void CreatePartDesignCommands(void)
rcCmdMgr.addCommand(new CmdPartDesignPocket()); rcCmdMgr.addCommand(new CmdPartDesignPocket());
rcCmdMgr.addCommand(new CmdPartDesignRevolution()); rcCmdMgr.addCommand(new CmdPartDesignRevolution());
rcCmdMgr.addCommand(new CmdPartDesignGroove()); rcCmdMgr.addCommand(new CmdPartDesignGroove());
rcCmdMgr.addCommand(new CmdPartDesignAdditivePipe);
rcCmdMgr.addCommand(new CmdPartDesignSubtractivePipe);
rcCmdMgr.addCommand(new CmdPartDesignAdditiveLoft);
rcCmdMgr.addCommand(new CmdPartDesignSubtractiveLoft);
rcCmdMgr.addCommand(new CmdPartDesignFillet()); rcCmdMgr.addCommand(new CmdPartDesignFillet());
rcCmdMgr.addCommand(new CmdPartDesignDraft()); rcCmdMgr.addCommand(new CmdPartDesignDraft());
@ -2170,6 +2254,4 @@ void CreatePartDesignCommands(void)
rcCmdMgr.addCommand(new CmdPartDesignMultiTransform()); rcCmdMgr.addCommand(new CmdPartDesignMultiTransform());
rcCmdMgr.addCommand(new CmdPartDesignBoolean()); rcCmdMgr.addCommand(new CmdPartDesignBoolean());
rcCmdMgr.addCommand(new CmdPartDesignAdditivePipe);
rcCmdMgr.addCommand(new CmdPartDesignSubtractivePipe);
} }

View File

@ -0,0 +1,331 @@
/***************************************************************************
* Copyright (c) 2015 Stefan Tröger <stefantroeger@gmx.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <sstream>
# include <QRegExp>
# include <QTextStream>
# include <QMessageBox>
# include <Precision.hxx>
#endif
#include "ui_TaskLoftParameters.h"
#include "TaskLoftParameters.h"
#include <App/Application.h>
#include <App/Document.h>
#include <Gui/Application.h>
#include <Gui/Document.h>
#include <Gui/BitmapFactory.h>
#include <Gui/ViewProvider.h>
#include <Gui/WaitCursor.h>
#include <Base/Console.h>
#include <Gui/Selection.h>
#include <Gui/Command.h>
#include <Mod/PartDesign/App/FeatureLoft.h>
#include <Mod/Sketcher/App/SketchObject.h>
#include <Mod/PartDesign/App/Body.h>
#include "TaskSketchBasedParameters.h"
#include "ReferenceSelection.h"
#include "Workbench.h"
using namespace PartDesignGui;
using namespace Gui;
/* TRANSLATOR PartDesignGui::TaskLoftParameters */
TaskLoftParameters::TaskLoftParameters(ViewProviderLoft *LoftView,bool newObj, QWidget *parent)
: TaskSketchBasedParameters(LoftView, parent, "PartDesign_Additive_Loft",tr("Loft parameters"))
{
// we need a separate container widget to add all controls to
proxy = new QWidget(this);
ui = new Ui_TaskLoftParameters();
ui->setupUi(proxy);
QMetaObject::connectSlotsByName(this);
connect(ui->buttonRefAdd, SIGNAL(toggled(bool)),
this, SLOT(onRefButtonAdd(bool)));
connect(ui->buttonRefRemove, SIGNAL(toggled(bool)),
this, SLOT(onRefButtonRemvove(bool)));
connect(ui->checkBoxRuled, SIGNAL(toggled(bool)),
this, SLOT(onRuled(bool)));
connect(ui->checkBoxClosed, SIGNAL(toggled(bool)),
this, SLOT(onClosed(bool)));
this->groupLayout()->addWidget(proxy);
// Temporarily prevent unnecessary feature recomputes
for(QWidget* child : proxy->findChildren<QWidget*>())
child->blockSignals(true);
// activate and de-activate dialog elements as appropriate
for(QWidget* child : proxy->findChildren<QWidget*>())
child->blockSignals(false);
updateUI(0);
}
void TaskLoftParameters::updateUI(int index)
{
}
void TaskLoftParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
{
if (selectionMode == none)
return;
if (msg.Type == Gui::SelectionChanges::AddSelection) {
if (referenceSelected(msg)) {
if (selectionMode == refAdd) {
QString objn = QString::fromStdString(msg.pObjectName);
if(!objn.isEmpty())
ui->listWidgetReferences->addItem(objn);
}
else if (selectionMode == refRemove) {
QString objn = QString::fromStdString(msg.pObjectName);
if(!objn.isEmpty())
removeFromListWidget(ui->listWidgetReferences, objn);
}
clearButtons();
//static_cast<ViewProviderLoft*>(vp)->highlightReferences(false, true);
recomputeFeature();
}
clearButtons();
exitSelectionMode();
}
}
bool TaskLoftParameters::referenceSelected(const Gui::SelectionChanges& msg) const {
if ((msg.Type == Gui::SelectionChanges::AddSelection) && (
(selectionMode == refAdd) || (selectionMode == refRemove))) {
if (strcmp(msg.pDocName, vp->getObject()->getDocument()->getName()) != 0)
return false;
// not allowed to reference ourself
const char* fname = vp->getObject()->getNameInDocument();
if (strcmp(msg.pObjectName, fname) == 0)
return false;
//every selection needs to be a profile in itself, hence currently only full objects are
//supported, not individual edges of a part
//change the references
std::vector<App::DocumentObject*> refs = static_cast<PartDesign::Loft*>(vp->getObject())->Sections.getValues();
App::DocumentObject* obj = vp->getObject()->getDocument()->getObject(msg.pObjectName);
std::vector<App::DocumentObject*>::iterator f = std::find(refs.begin(), refs.end(), obj);
if (selectionMode == refAdd) {
if (f == refs.end())
refs.push_back(obj);
else
return false; // duplicate selection
} else {
if (f != refs.end())
refs.erase(f);
else
return false;
}
static_cast<PartDesign::Loft*>(vp->getObject())->Sections.setValues(refs);
return true;
}
return false;
}
void TaskLoftParameters::removeFromListWidget(QListWidget* widget, QString name) {
QList<QListWidgetItem*> items = widget->findItems(name, Qt::MatchExactly);
if (!items.empty()) {
for (QList<QListWidgetItem*>::const_iterator i = items.begin(); i != items.end(); i++) {
QListWidgetItem* it = widget->takeItem(widget->row(*i));
delete it;
}
}
}
void TaskLoftParameters::clearButtons() {
ui->buttonRefAdd->setChecked(false);
ui->buttonRefRemove->setChecked(false);
}
void TaskLoftParameters::exitSelectionMode() {
selectionMode = none;
Gui::Selection().clearSelection();
}
TaskLoftParameters::~TaskLoftParameters()
{
delete ui;
}
void TaskLoftParameters::changeEvent(QEvent *e)
{/*
TaskBox::changeEvent(e);
if (e->type() == QEvent::LanguageChange) {
ui->spinOffset->blockSignals(true);
ui->lengthEdit->blockSignals(true);
ui->lengthEdit2->blockSignals(true);
ui->lineFaceName->blockSignals(true);
ui->changeMode->blockSignals(true);
int index = ui->changeMode->currentIndex();
ui->retranslateUi(proxy);
ui->changeMode->clear();
ui->changeMode->addItem(tr("Dimension"));
ui->changeMode->addItem(tr("To last"));
ui->changeMode->addItem(tr("To first"));
ui->changeMode->addItem(tr("Up to face"));
ui->changeMode->addItem(tr("Two dimensions"));
ui->changeMode->setCurrentIndex(index);
QStringList parts = ui->lineFaceName->text().split(QChar::fromAscii(':'));
QByteArray upToFace = ui->lineFaceName->property("FaceName").toByteArray();
int faceId = -1;
bool ok = false;
if (upToFace.indexOf("Face") == 0) {
faceId = upToFace.remove(0,4).toInt(&ok);
}
#if QT_VERSION >= 0x040700
ui->lineFaceName->setPlaceholderText(tr("No face selected"));
#endif
ui->lineFaceName->setText(ok ?
parts[0] + QString::fromAscii(":") + tr("Face") + QString::number(faceId) :
tr("No face selected"));
ui->spinOffset->blockSignals(false);
ui->lengthEdit->blockSignals(false);
ui->lengthEdit2->blockSignals(false);
ui->lineFaceName->blockSignals(false);
ui->changeMode->blockSignals(false);
}*/
}
void TaskLoftParameters::onClosed(bool val) {
static_cast<PartDesign::Loft*>(vp->getObject())->Closed.setValue(val);
recomputeFeature();
}
void TaskLoftParameters::onRuled(bool val) {
static_cast<PartDesign::Loft*>(vp->getObject())->Ruled.setValue(val);
recomputeFeature();
}
void TaskLoftParameters::onRefButtonAdd(bool checked) {
if (checked) {
Gui::Selection().clearSelection();
selectionMode = refAdd;
//static_cast<ViewProviderLoft*>(vp)->highlightReferences(true, true);
}
}
void TaskLoftParameters::onRefButtonRemvove(bool checked) {
if (checked) {
Gui::Selection().clearSelection();
selectionMode = refRemove;
//static_cast<ViewProviderLoft*>(vp)->highlightReferences(true, true);
}
}
//**************************************************************************
//**************************************************************************
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskDlgLoftParameters::TaskDlgLoftParameters(ViewProviderLoft *LoftView,bool newObj)
: TaskDlgSketchBasedParameters(LoftView)
{
assert(LoftView);
parameter = new TaskLoftParameters(LoftView,newObj);
Content.push_back(parameter);
}
TaskDlgLoftParameters::~TaskDlgLoftParameters()
{
}
//==== calls from the TaskView ===============================================================
bool TaskDlgLoftParameters::accept()
{
std::string name = vp->getObject()->getNameInDocument();
try {
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
if (!vp->getObject()->isValid())
throw Base::Exception(vp->getObject()->getStatusString());
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
Gui::Command::commitCommand();
}
catch (const Base::Exception& e) {
QMessageBox::warning(parameter, tr("Input error"), QString::fromUtf8(e.what()));
return false;
}
return true;
}
//bool TaskDlgLoftParameters::reject()
//{
// // get the support and Sketch
// PartDesign::Loft* pcLoft = static_cast<PartDesign::Loft*>(LoftView->getObject());
// Sketcher::SketchObject *pcSketch = 0;
// App::DocumentObject *pcSupport = 0;
// if (pcLoft->Sketch.getValue()) {
// pcSketch = static_cast<Sketcher::SketchObject*>(pcLoft->Sketch.getValue());
// pcSupport = pcSketch->Support.getValue();
// }
//
// // roll back the done things
// Gui::Command::abortCommand();
// Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
//
// // if abort command deleted the object the support is visible again
// if (!Gui::Application::Instance->getViewProvider(pcLoft)) {
// if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch))
// Gui::Application::Instance->getViewProvider(pcSketch)->show();
// if (pcSupport && Gui::Application::Instance->getViewProvider(pcSupport))
// Gui::Application::Instance->getViewProvider(pcSupport)->show();
// }
//
// //Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
// //Gui::Command::commitCommand();
//
// return true;
//}
#include "moc_TaskLoftParameters.cpp"

View File

@ -0,0 +1,106 @@
/***************************************************************************
* Copyright (c) 2015 Stefan Tröger <stefantroeger@gmx.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef GUI_TASKVIEW_TaskLoftParameters_H
#define GUI_TASKVIEW_TaskLoftParameters_H
#include <Gui/TaskView/TaskView.h>
#include <Gui/Selection.h>
#include <Gui/TaskView/TaskDialog.h>
#include "TaskSketchBasedParameters.h"
#include "ViewProviderLoft.h"
class Ui_TaskLoftParameters;
class QListWidget;
namespace App {
class Property;
}
namespace Gui {
class ViewProvider;
}
namespace PartDesignGui {
class TaskLoftParameters : public TaskSketchBasedParameters
{
Q_OBJECT
public:
TaskLoftParameters(ViewProviderLoft *LoftView,bool newObj=false,QWidget *parent = 0);
~TaskLoftParameters();
private Q_SLOTS:
void onRefButtonAdd(bool);
void onRefButtonRemvove(bool);
void onClosed(bool);
void onRuled(bool);
protected:
void changeEvent(QEvent *e);
private:
void onSelectionChanged(const Gui::SelectionChanges& msg);
void updateUI(int index);
bool referenceSelected(const Gui::SelectionChanges& msg) const;
void removeFromListWidget(QListWidget*w, QString name);
void clearButtons();
void exitSelectionMode();
private:
QWidget* proxy;
Ui_TaskLoftParameters* ui;
enum selectionModes { none, refAdd, refRemove };
selectionModes selectionMode = none;
};
/// simulation dialog for the TaskView
class TaskDlgLoftParameters : public TaskDlgSketchBasedParameters
{
Q_OBJECT
public:
TaskDlgLoftParameters(ViewProviderLoft *LoftView,bool newObj=false);
~TaskDlgLoftParameters();
ViewProviderLoft* getLoftView() const
{ return static_cast<ViewProviderLoft*>(vp); }
public:
/// is called by the framework if the dialog is accepted (Ok)
virtual bool accept();
/// is called by the framework if the dialog is rejected (Cancel)
protected:
TaskLoftParameters *parameter;
};
} //namespace PartDesignGui
#endif // GUI_TASKVIEW_TASKAPPERANCE_H

View File

@ -0,0 +1,204 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PartDesignGui::TaskLoftParameters</class>
<widget class="QWidget" name="PartDesignGui::TaskLoftParameters">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>285</width>
<height>305</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="constant"/>
<widget class="QWidget" name="multisection">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="checkBoxClosed">
<property name="text">
<string>Closed</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxRuled">
<property name="text">
<string>Ruled surface</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QToolButton" name="buttonRefAdd">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Add Section</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonRefRemove">
<property name="text">
<string>Remove Section</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidgetReferences"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="linear">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Final scaling factor</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="linearSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>99999.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="sshape">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Scaling factor</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="sshapeSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<double>-9999.000000000000000</double>
</property>
<property name="maximum">
<double>9999.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Derivative at start</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="sshapeStartDeriSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<double>-99.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Derivative at end</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="sshapeEndDeriSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<double>-99.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -500,8 +500,15 @@ bool TaskPipeOrientation::referenceSelected(const SelectionChanges& msg) const {
return false; return false;
} }
void TaskPipeOrientation::removeFromListWidget(QListWidget* w, QString name) { void TaskPipeOrientation::removeFromListWidget(QListWidget* widget, QString name) {
QList<QListWidgetItem*> items = widget->findItems(name, Qt::MatchExactly);
if (!items.empty()) {
for (QList<QListWidgetItem*>::const_iterator i = items.begin(); i != items.end(); i++) {
QListWidgetItem* it = widget->takeItem(widget->row(*i));
delete it;
}
}
} }
void TaskPipeOrientation::updateUI(int idx) { void TaskPipeOrientation::updateUI(int idx) {
@ -664,8 +671,15 @@ bool TaskPipeScaling::referenceSelected(const SelectionChanges& msg) const {
return false; return false;
} }
void TaskPipeScaling::removeFromListWidget(QListWidget* w, QString name) { void TaskPipeScaling::removeFromListWidget(QListWidget* widget, QString name) {
QList<QListWidgetItem*> items = widget->findItems(name, Qt::MatchExactly);
if (!items.empty()) {
for (QList<QListWidgetItem*>::const_iterator i = items.begin(); i != items.end(); i++) {
QListWidgetItem* it = widget->takeItem(widget->row(*i));
delete it;
}
}
} }
void TaskPipeScaling::updateUI(int idx) { void TaskPipeScaling::updateUI(int idx) {

View File

@ -58,18 +58,11 @@
<item> <item>
<widget class="QStackedWidget" name="stackedWidget"> <widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="constant"/> <widget class="QWidget" name="constant"/>
<widget class="QWidget" name="multisection"> <widget class="QWidget" name="multisection">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Automaticly build profile from sections</string>
</property>
</widget>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<item> <item>

View File

@ -82,7 +82,7 @@ bool ViewProviderLoft::setEdit(int ModNum)
if (ModNum == ViewProvider::Default || ModNum == 1 ) { if (ModNum == ViewProvider::Default || ModNum == 1 ) {
setPreviewDisplayMode(true); setPreviewDisplayMode(true);
/*
// When double-clicking on the item for this pad the // When double-clicking on the item for this pad the
// object unsets and sets its edit mode without closing // object unsets and sets its edit mode without closing
// the task panel // the task panel
@ -114,7 +114,7 @@ bool ViewProviderLoft::setEdit(int ModNum)
Gui::Control().showDialog(padDlg); Gui::Control().showDialog(padDlg);
else else
Gui::Control().showDialog(new TaskDlgLoftParameters(this,ModNum == 1)); Gui::Control().showDialog(new TaskDlgLoftParameters(this,ModNum == 1));
*/
return true; return true;
} }
else { else {

View File

@ -654,6 +654,8 @@ void Workbench::activated()
"PartDesign_Groove", "PartDesign_Groove",
"PartDesign_AdditivePipe", "PartDesign_AdditivePipe",
"PartDesign_SubtractivePipe", "PartDesign_SubtractivePipe",
"PartDesign_AdditiveLoft",
"PartDesign_SubtractiveLoft",
0}; 0};
Watcher.push_back(new Gui::TaskView::TaskWatcherCommands( Watcher.push_back(new Gui::TaskView::TaskWatcherCommands(
"SELECT Sketcher::SketchObject COUNT 1", "SELECT Sketcher::SketchObject COUNT 1",
@ -751,6 +753,8 @@ Gui::MenuItem* Workbench::setupMenuBar() const
<< "PartDesign_Groove" << "PartDesign_Groove"
<< "PartDesign_AdditivePipe" << "PartDesign_AdditivePipe"
<< "PartDesign_SubtractivePipe" << "PartDesign_SubtractivePipe"
<< "PartDesign_AdditiveLoft"
<< "PartDesign_SubtractiveLoft"
<< "PartDesign_Fillet" << "PartDesign_Fillet"
<< "PartDesign_Chamfer" << "PartDesign_Chamfer"
<< "PartDesign_Draft" << "PartDesign_Draft"
@ -809,6 +813,8 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
<< "PartDesign_Groove" << "PartDesign_Groove"
<< "PartDesign_AdditivePipe" << "PartDesign_AdditivePipe"
<< "PartDesign_SubtractivePipe" << "PartDesign_SubtractivePipe"
<< "PartDesign_AdditiveLoft"
<< "PartDesign_SubtractiveLoft"
<< "PartDesign_Fillet" << "PartDesign_Fillet"
<< "PartDesign_Chamfer" << "PartDesign_Chamfer"
<< "PartDesign_Draft" << "PartDesign_Draft"