Initial task panel for filling function
This commit is contained in:
@@ -40,7 +40,7 @@
|
||||
|
||||
using namespace Surface;
|
||||
|
||||
PROPERTY_SOURCE(Surface::Filling, Part::Feature)
|
||||
PROPERTY_SOURCE(Surface::Filling, Part::Spline)
|
||||
|
||||
//Initial values
|
||||
|
||||
|
||||
@@ -26,13 +26,14 @@
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <App/PropertyUnits.h>
|
||||
#include <App/PropertyLinks.h>
|
||||
#include "Mod/Part/App/PartFeature.h"
|
||||
#include <Mod/Part/App/FeaturePartSpline.h>
|
||||
|
||||
class BRepFill_Filling;
|
||||
|
||||
namespace Surface
|
||||
{
|
||||
|
||||
class SurfaceExport Filling : public Part::Feature
|
||||
class SurfaceExport Filling : public Part::Spline
|
||||
{
|
||||
PROPERTY_HEADER(Surface::Filling);
|
||||
|
||||
@@ -66,6 +67,10 @@ public:
|
||||
// recalculate the feature
|
||||
App::DocumentObjectExecReturn *execute(void);
|
||||
short mustExecute() const;
|
||||
/// returns the type name of the view provider
|
||||
const char* getViewProviderName(void) const {
|
||||
return "SurfaceGui::ViewProviderFilling";
|
||||
}
|
||||
|
||||
private:
|
||||
void addConstraints(BRepFill_Filling& builder,
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
|
||||
#include "Workbench.h"
|
||||
#include "TaskGeomFillSurface.h"
|
||||
#include "TaskFilling.h"
|
||||
|
||||
// use a different name to CreateCommand()
|
||||
void CreateSurfaceCommands(void);
|
||||
@@ -76,7 +77,8 @@ PyMOD_INIT_FUNC(SurfaceGui)
|
||||
CreateSurfaceCommands();
|
||||
|
||||
SurfaceGui::Workbench::init();
|
||||
SurfaceGui::ViewProviderGeomFillSurface::init();
|
||||
SurfaceGui::ViewProviderGeomFillSurface ::init();
|
||||
SurfaceGui::ViewProviderFilling ::init();
|
||||
|
||||
// SurfaceGui::ViewProviderCut::init();
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ set(SurfaceGui_LIBS
|
||||
)
|
||||
|
||||
set(SurfaceGui_MOC_HDRS
|
||||
TaskFilling.h
|
||||
TaskGeomFillSurface.h
|
||||
)
|
||||
fc_wrap_cpp(SurfaceGui_MOC_SRCS ${SurfaceGui_MOC_HDRS})
|
||||
@@ -36,6 +37,7 @@ else()
|
||||
endif()
|
||||
|
||||
SET(SurfaceGui_UIC_SRCS
|
||||
TaskFilling.ui
|
||||
TaskGeomFillSurface.ui
|
||||
)
|
||||
|
||||
@@ -48,6 +50,8 @@ endif()
|
||||
SET(SurfaceGui_SRCS
|
||||
${SurfaceGui_QRC_SRCS}
|
||||
${SurfaceGui_UIC_HDRS}
|
||||
TaskFilling.cpp
|
||||
TaskFilling.h
|
||||
TaskGeomFillSurface.cpp
|
||||
TaskGeomFillSurface.h
|
||||
AppSurfaceGui.cpp
|
||||
|
||||
@@ -63,29 +63,6 @@
|
||||
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
//===========================================================================
|
||||
// CmdSurfaceFILLING THIS IS THE SURFACE FILLING COMMAND
|
||||
//===========================================================================
|
||||
DEF_STD_CMD(CmdSurfaceFilling);
|
||||
|
||||
CmdSurfaceFilling::CmdSurfaceFilling()
|
||||
:Command("Surface_Filling")
|
||||
{
|
||||
sAppModule = "Surface";
|
||||
sGroup = QT_TR_NOOP("Surface");
|
||||
sMenuText = QT_TR_NOOP("Surface Filling function");
|
||||
sToolTipText = QT_TR_NOOP("Fills a series of boundary curves, constraint curves and verticies with a surface.");
|
||||
sWhatsThis = QT_TR_NOOP("Surface Filling function");
|
||||
sStatusTip = QT_TR_NOOP("Surface Filling function");
|
||||
sPixmap = "Filling.svg";
|
||||
}
|
||||
|
||||
void CmdSurfaceFilling::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
Base::Console().Message("Hello, World!\n");
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// CmdSurfaceCut THIS IS THE SURFACE CUT COMMAND
|
||||
//===========================================================================
|
||||
@@ -147,6 +124,35 @@ void CmdSurfaceCut::activated(int iMsg)
|
||||
}
|
||||
|
||||
|
||||
DEF_STD_CMD_A(CmdSurfaceFilling)
|
||||
|
||||
CmdSurfaceFilling::CmdSurfaceFilling()
|
||||
:Command("Surface_Filling")
|
||||
{
|
||||
sAppModule = "Surface";
|
||||
sGroup = QT_TR_NOOP("Surface");
|
||||
sMenuText = QT_TR_NOOP("Filling...");
|
||||
sToolTipText = QT_TR_NOOP("Fills a series of boundary curves, constraint curves and vertexes with a surface");
|
||||
sStatusTip = QT_TR_NOOP("Fills a series of boundary curves, constraint curves and vertexes with a surface");
|
||||
sWhatsThis = QT_TR_NOOP("Surface_Filling");
|
||||
sPixmap = "Filling.svg";
|
||||
}
|
||||
|
||||
void CmdSurfaceFilling::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
std::string FeatName = getUniqueObjectName("Surface");
|
||||
|
||||
openCommand("Create surface");
|
||||
doCommand(Doc, "App.ActiveDocument.addObject(\"Surface::Filling\",\"%s\")", FeatName.c_str());
|
||||
doCommand(Doc, "Gui.ActiveDocument.setEdit('%s',0)", FeatName.c_str());
|
||||
}
|
||||
|
||||
bool CmdSurfaceFilling::isActive(void)
|
||||
{
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// Bezier and BSpline surfaces
|
||||
//===========================================================================
|
||||
@@ -218,6 +224,7 @@ void CreateSurfaceCommands(void)
|
||||
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
|
||||
/* rcCmdMgr.addCommand(new CmdSurfaceFilling());
|
||||
rcCmdMgr.addCommand(new CmdSurfaceCut());*/
|
||||
rcCmdMgr.addCommand(new CmdSurfaceFilling());
|
||||
rcCmdMgr.addCommand(new CmdSurfaceGeomFillSurface());
|
||||
rcCmdMgr.addCommand(new CmdSurfaceCurveOnMesh());
|
||||
}
|
||||
|
||||
532
src/Mod/Surface/Gui/TaskFilling.cpp
Normal file
532
src/Mod/Surface/Gui/TaskFilling.cpp
Normal file
@@ -0,0 +1,532 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2015 Balázs Bámer *
|
||||
* Werner Mayer <wmayer[at]users.sourceforge.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"
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QTimer>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
|
||||
#include <Gui/ViewProvider.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/SelectionObject.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Mod/Part/Gui/ViewProvider.h>
|
||||
|
||||
#include "TaskFilling.h"
|
||||
#include "ui_TaskFilling.h"
|
||||
|
||||
|
||||
using namespace SurfaceGui;
|
||||
|
||||
PROPERTY_SOURCE(SurfaceGui::ViewProviderFilling, PartGui::ViewProviderSpline)
|
||||
|
||||
namespace SurfaceGui {
|
||||
|
||||
void ViewProviderFilling::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
|
||||
{
|
||||
QAction* act;
|
||||
act = menu->addAction(QObject::tr("Edit filling"), receiver, member);
|
||||
act->setData(QVariant((int)ViewProvider::Default));
|
||||
PartGui::ViewProviderSpline::setupContextMenu(menu, receiver, member);
|
||||
}
|
||||
|
||||
bool ViewProviderFilling::setEdit(int ModNum)
|
||||
{
|
||||
if (ModNum == ViewProvider::Default ) {
|
||||
// When double-clicking on the item for this sketch the
|
||||
// object unsets and sets its edit mode without closing
|
||||
// the task panel
|
||||
|
||||
Surface::Filling* obj = static_cast<Surface::Filling*>(this->getObject());
|
||||
|
||||
Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog();
|
||||
|
||||
// start the edit dialog
|
||||
if (dlg) {
|
||||
TaskFilling* tDlg = qobject_cast<TaskFilling*>(dlg);
|
||||
if (tDlg)
|
||||
tDlg->setEditedObject(obj);
|
||||
Gui::Control().showDialog(dlg);
|
||||
}
|
||||
else {
|
||||
Gui::Control().showDialog(new TaskFilling(this, obj));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return ViewProviderSpline::setEdit(ModNum);
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderFilling::unsetEdit(int ModNum)
|
||||
{
|
||||
if (ModNum == ViewProvider::Default) {
|
||||
// when pressing ESC make sure to close the dialog
|
||||
QTimer::singleShot(0, &Gui::Control(), SLOT(closeDialog()));
|
||||
}
|
||||
else {
|
||||
PartGui::ViewProviderSpline::unsetEdit(ModNum);
|
||||
}
|
||||
}
|
||||
|
||||
QIcon ViewProviderFilling::getIcon(void) const
|
||||
{
|
||||
return Gui::BitmapFactory().pixmap("BSplineSurf");
|
||||
}
|
||||
|
||||
void ViewProviderFilling::highlightReferences(bool on)
|
||||
{
|
||||
#if 0
|
||||
Surface::Filling* surface = static_cast<Surface::Filling*>(getObject());
|
||||
auto bounds = surface->BoundaryList.getSubListValues();
|
||||
for (auto it : bounds) {
|
||||
Part::Feature* base = dynamic_cast<Part::Feature*>(it.first);
|
||||
if (base) {
|
||||
PartGui::ViewProviderPartExt* svp = dynamic_cast<PartGui::ViewProviderPartExt*>(
|
||||
Gui::Application::Instance->getViewProvider(base));
|
||||
if (svp) {
|
||||
if (on) {
|
||||
std::vector<App::Color> colors;
|
||||
TopTools_IndexedMapOfShape eMap;
|
||||
TopExp::MapShapes(base->Shape.getValue(), TopAbs_EDGE, eMap);
|
||||
colors.resize(eMap.Extent(), svp->LineColor.getValue());
|
||||
|
||||
for (auto jt : it.second) {
|
||||
std::size_t idx = static_cast<std::size_t>(std::stoi(jt.substr(4)) - 1);
|
||||
assert (idx < colors.size());
|
||||
colors[idx] = App::Color(1.0,0.0,1.0); // magenta
|
||||
}
|
||||
|
||||
svp->setHighlightedEdges(colors);
|
||||
}
|
||||
else {
|
||||
svp->unsetHighlightedEdges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class FillingPanel::ShapeSelection : public Gui::SelectionFilterGate
|
||||
{
|
||||
public:
|
||||
ShapeSelection(bool appendEdges, Surface::Filling* editedObject)
|
||||
: Gui::SelectionFilterGate(static_cast<Gui::SelectionFilter*>(nullptr))
|
||||
, appendEdges(appendEdges)
|
||||
, editedObject(editedObject)
|
||||
{
|
||||
}
|
||||
/**
|
||||
* Allow the user to pick only edges.
|
||||
*/
|
||||
bool allow(App::Document* pDoc, App::DocumentObject* pObj, const char* sSubName);
|
||||
|
||||
private:
|
||||
bool appendEdges;
|
||||
Surface::Filling* editedObject;
|
||||
};
|
||||
|
||||
bool FillingPanel::ShapeSelection::allow(App::Document* , App::DocumentObject* pObj, const char* sSubName)
|
||||
{
|
||||
// don't allow references to itself
|
||||
if (pObj == editedObject)
|
||||
return false;
|
||||
if (!pObj->isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
return false;
|
||||
|
||||
if (!sSubName || sSubName[0] == '\0')
|
||||
return false;
|
||||
|
||||
std::string element(sSubName);
|
||||
if (element.substr(0,4) != "Edge")
|
||||
return false;
|
||||
#if 0
|
||||
auto links = editedObject->BoundaryList.getSubListValues();
|
||||
for (auto it : links) {
|
||||
if (it.first == pObj) {
|
||||
for (auto jt : it.second) {
|
||||
if (jt == sSubName)
|
||||
return !appendEdges;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return appendEdges;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
FillingPanel::FillingPanel(ViewProviderFilling* vp, Surface::Filling* obj)
|
||||
{
|
||||
ui = new Ui_TaskFilling();
|
||||
ui->setupUi(this);
|
||||
selectionMode = None;
|
||||
this->vp = vp;
|
||||
checkCommand = true;
|
||||
setEditedObject(obj);
|
||||
|
||||
// Create context menu
|
||||
QAction* action = new QAction(tr("Remove"), this);
|
||||
action->setShortcut(QString::fromLatin1("Del"));
|
||||
ui->listWidget->addAction(action);
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(onDeleteEdge()));
|
||||
ui->listWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
}
|
||||
|
||||
/*
|
||||
* Destroys the object and frees any allocated resources
|
||||
*/
|
||||
FillingPanel::~FillingPanel()
|
||||
{
|
||||
// no need to delete child widgets, Qt does it all for us
|
||||
delete ui;
|
||||
}
|
||||
|
||||
// stores object pointer, its old fill type and adjusts radio buttons according to it.
|
||||
void FillingPanel::setEditedObject(Surface::Filling* obj)
|
||||
{
|
||||
editedObject = obj;
|
||||
#if 0
|
||||
GeomFill_FillingStyle curtype = static_cast<GeomFill_FillingStyle>(editedObject->FillType.getValue());
|
||||
switch(curtype)
|
||||
{
|
||||
case GeomFill_StretchStyle:
|
||||
ui->fillType_stretch->setChecked(true);
|
||||
break;
|
||||
case GeomFill_CoonsStyle:
|
||||
ui->fillType_coons->setChecked(true);
|
||||
break;
|
||||
case GeomFill_CurvedStyle:
|
||||
ui->fillType_curved->setChecked(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
auto objects = editedObject->BoundaryList.getValues();
|
||||
auto element = editedObject->BoundaryList.getSubValues();
|
||||
auto it = objects.begin();
|
||||
auto jt = element.begin();
|
||||
|
||||
App::Document* doc = editedObject->getDocument();
|
||||
for (; it != objects.end() && jt != element.end(); ++it, ++jt) {
|
||||
QListWidgetItem* item = new QListWidgetItem(ui->listWidget);
|
||||
ui->listWidget->addItem(item);
|
||||
|
||||
QString text = QString::fromLatin1("%1.%2")
|
||||
.arg(QString::fromUtf8((*it)->Label.getValue()))
|
||||
.arg(QString::fromStdString(*jt));
|
||||
item->setText(text);
|
||||
|
||||
QList<QVariant> data;
|
||||
data << QByteArray(doc->getName());
|
||||
data << QByteArray((*it)->getNameInDocument());
|
||||
data << QByteArray(jt->c_str());
|
||||
item->setData(Qt::UserRole, data);
|
||||
}
|
||||
attachDocument(Gui::Application::Instance->getDocument(doc));
|
||||
#endif
|
||||
}
|
||||
|
||||
void FillingPanel::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
else {
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
void FillingPanel::open()
|
||||
{
|
||||
checkOpenCommand();
|
||||
this->vp->highlightReferences(true);
|
||||
Gui::Selection().clearSelection();
|
||||
}
|
||||
|
||||
void FillingPanel::clearSelection()
|
||||
{
|
||||
Gui::Selection().clearSelection();
|
||||
}
|
||||
|
||||
void FillingPanel::checkOpenCommand()
|
||||
{
|
||||
if (checkCommand && !Gui::Command::hasPendingCommand()) {
|
||||
std::string Msg("Edit ");
|
||||
Msg += editedObject->Label.getValue();
|
||||
Gui::Command::openCommand(Msg.c_str());
|
||||
checkCommand = false;
|
||||
}
|
||||
}
|
||||
|
||||
void FillingPanel::slotUndoDocument(const Gui::Document&)
|
||||
{
|
||||
checkCommand = true;
|
||||
}
|
||||
|
||||
void FillingPanel::slotRedoDocument(const Gui::Document&)
|
||||
{
|
||||
checkCommand = true;
|
||||
}
|
||||
|
||||
bool FillingPanel::accept()
|
||||
{
|
||||
this->vp->highlightReferences(false);
|
||||
selectionMode = None;
|
||||
Gui::Selection().rmvSelectionGate();
|
||||
|
||||
int count = ui->listWidget->count();
|
||||
if (count > 4) {
|
||||
QMessageBox::warning(this,
|
||||
tr("Too many edges"),
|
||||
tr("The tool requires two, three or four edges"));
|
||||
return false;
|
||||
}
|
||||
else if (count < 2) {
|
||||
QMessageBox::warning(this,
|
||||
tr("Too less edges"),
|
||||
tr("The tool requires two, three or four edges"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (editedObject->mustExecute())
|
||||
editedObject->recomputeFeature();
|
||||
if (!editedObject->isValid()) {
|
||||
QMessageBox::warning(this, tr("Invalid object"),
|
||||
QString::fromLatin1(editedObject->getStatusString()));
|
||||
return false;
|
||||
}
|
||||
|
||||
Gui::Command::commitCommand();
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
|
||||
Gui::Command::updateActive();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FillingPanel::reject()
|
||||
{
|
||||
this->vp->highlightReferences(false);
|
||||
selectionMode = None;
|
||||
Gui::Selection().rmvSelectionGate();
|
||||
|
||||
Gui::Command::abortCommand();
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
|
||||
Gui::Command::updateActive();
|
||||
return true;
|
||||
}
|
||||
|
||||
void FillingPanel::on_fillType_stretch_clicked()
|
||||
{
|
||||
changeFillType(GeomFill_StretchStyle);
|
||||
}
|
||||
|
||||
void FillingPanel::on_fillType_coons_clicked()
|
||||
{
|
||||
changeFillType(GeomFill_CoonsStyle);
|
||||
}
|
||||
|
||||
void FillingPanel::on_fillType_curved_clicked()
|
||||
{
|
||||
changeFillType(GeomFill_CurvedStyle);
|
||||
}
|
||||
|
||||
void FillingPanel::changeFillType(GeomFill_FillingStyle fillType)
|
||||
{
|
||||
#if 0
|
||||
GeomFill_FillingStyle curtype = static_cast<GeomFill_FillingStyle>(editedObject->FillType.getValue());
|
||||
if (curtype != fillType) {
|
||||
checkOpenCommand();
|
||||
editedObject->FillType.setValue(static_cast<long>(fillType));
|
||||
editedObject->recomputeFeature();
|
||||
if (!editedObject->isValid()) {
|
||||
Base::Console().Error("Surface filling: %s", editedObject->getStatusString());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void FillingPanel::on_buttonEdgeAdd_clicked()
|
||||
{
|
||||
selectionMode = Append;
|
||||
Gui::Selection().addSelectionGate(new ShapeSelection(true, editedObject));
|
||||
}
|
||||
|
||||
void FillingPanel::on_buttonEdgeRemove_clicked()
|
||||
{
|
||||
selectionMode = Remove;
|
||||
Gui::Selection().addSelectionGate(new ShapeSelection(false, editedObject));
|
||||
}
|
||||
|
||||
void FillingPanel::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
{
|
||||
if (selectionMode == None)
|
||||
return;
|
||||
#if 0
|
||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
checkOpenCommand();
|
||||
if (selectionMode == Append) {
|
||||
QListWidgetItem* item = new QListWidgetItem(ui->listWidget);
|
||||
ui->listWidget->addItem(item);
|
||||
|
||||
Gui::SelectionObject sel(msg);
|
||||
QString text = QString::fromLatin1("%1.%2")
|
||||
.arg(QString::fromUtf8(sel.getObject()->Label.getValue()))
|
||||
.arg(QString::fromLatin1(msg.pSubName));
|
||||
item->setText(text);
|
||||
|
||||
QList<QVariant> data;
|
||||
data << QByteArray(msg.pDocName);
|
||||
data << QByteArray(msg.pObjectName);
|
||||
data << QByteArray(msg.pSubName);
|
||||
item->setData(Qt::UserRole, data);
|
||||
|
||||
auto objects = editedObject->BoundaryList.getValues();
|
||||
objects.push_back(sel.getObject());
|
||||
auto element = editedObject->BoundaryList.getSubValues();
|
||||
element.push_back(msg.pSubName);
|
||||
editedObject->BoundaryList.setValues(objects, element);
|
||||
this->vp->highlightReferences(true);
|
||||
}
|
||||
else {
|
||||
Gui::SelectionObject sel(msg);
|
||||
QList<QVariant> data;
|
||||
data << QByteArray(msg.pDocName);
|
||||
data << QByteArray(msg.pObjectName);
|
||||
data << QByteArray(msg.pSubName);
|
||||
for (int i=0; i<ui->listWidget->count(); i++) {
|
||||
QListWidgetItem* item = ui->listWidget->item(i);
|
||||
if (item && item->data(Qt::UserRole) == data) {
|
||||
ui->listWidget->takeItem(i);
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
|
||||
this->vp->highlightReferences(false);
|
||||
App::DocumentObject* obj = sel.getObject();
|
||||
std::string sub = msg.pSubName;
|
||||
auto objects = editedObject->BoundaryList.getValues();
|
||||
auto element = editedObject->BoundaryList.getSubValues();
|
||||
auto it = objects.begin();
|
||||
auto jt = element.begin();
|
||||
for (; it != objects.end() && jt != element.end(); ++it, ++jt) {
|
||||
if (*it == obj && *jt == sub) {
|
||||
objects.erase(it);
|
||||
element.erase(jt);
|
||||
editedObject->BoundaryList.setValues(objects, element);
|
||||
break;
|
||||
}
|
||||
}
|
||||
this->vp->highlightReferences(true);
|
||||
}
|
||||
|
||||
editedObject->recomputeFeature();
|
||||
QTimer::singleShot(50, this, SLOT(clearSelection()));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void FillingPanel::onDeleteEdge()
|
||||
{
|
||||
#if 0
|
||||
int row = ui->listWidget->currentRow();
|
||||
QListWidgetItem* item = ui->listWidget->item(row);
|
||||
if (item) {
|
||||
checkOpenCommand();
|
||||
QList<QVariant> data;
|
||||
data = item->data(Qt::UserRole).toList();
|
||||
ui->listWidget->takeItem(row);
|
||||
delete item;
|
||||
|
||||
App::Document* doc = App::GetApplication().getDocument(data[0].toByteArray());
|
||||
App::DocumentObject* obj = doc ? doc->getObject(data[1].toByteArray()) : nullptr;
|
||||
std::string sub = data[2].toByteArray().constData();
|
||||
auto objects = editedObject->BoundaryList.getValues();
|
||||
auto element = editedObject->BoundaryList.getSubValues();
|
||||
auto it = objects.begin();
|
||||
auto jt = element.begin();
|
||||
this->vp->highlightReferences(false);
|
||||
for (; it != objects.end() && jt != element.end(); ++it, ++jt) {
|
||||
if (*it == obj && *jt == sub) {
|
||||
objects.erase(it);
|
||||
element.erase(jt);
|
||||
editedObject->BoundaryList.setValues(objects, element);
|
||||
break;
|
||||
}
|
||||
}
|
||||
this->vp->highlightReferences(true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
TaskFilling::TaskFilling(ViewProviderFilling* vp, Surface::Filling* obj)
|
||||
{
|
||||
widget = new FillingPanel(vp, obj);
|
||||
widget->setWindowTitle(QObject::tr("Surface"));
|
||||
taskbox = new Gui::TaskView::TaskBox(
|
||||
Gui::BitmapFactory().pixmap("BezSurf"),
|
||||
widget->windowTitle(), true, 0);
|
||||
taskbox->groupLayout()->addWidget(widget);
|
||||
Content.push_back(taskbox);
|
||||
}
|
||||
|
||||
TaskFilling::~TaskFilling()
|
||||
{
|
||||
// automatically deleted in the sub-class
|
||||
}
|
||||
|
||||
void TaskFilling::setEditedObject(Surface::Filling* obj)
|
||||
{
|
||||
widget->setEditedObject(obj);
|
||||
}
|
||||
|
||||
void TaskFilling::open()
|
||||
{
|
||||
widget->open();
|
||||
}
|
||||
|
||||
bool TaskFilling::accept()
|
||||
{
|
||||
return widget->accept();
|
||||
}
|
||||
|
||||
bool TaskFilling::reject()
|
||||
{
|
||||
return widget->reject();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#include "moc_TaskFilling.cpp"
|
||||
121
src/Mod/Surface/Gui/TaskFilling.h
Normal file
121
src/Mod/Surface/Gui/TaskFilling.h
Normal file
@@ -0,0 +1,121 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2015 Balázs Bámer *
|
||||
* *
|
||||
* 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 SURFACEGUI_TASKFILLING_H
|
||||
#define SURFACEGUI_TASKFILLING_H
|
||||
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
#include <Gui/SelectionFilter.h>
|
||||
#include <Gui/DocumentObserver.h>
|
||||
#include <Base/BoundBox.h>
|
||||
#include <Mod/Part/Gui/ViewProviderSpline.h>
|
||||
#include <Mod/Surface/App/FeatureFilling.h>
|
||||
#include <GeomFill_FillingStyle.hxx>
|
||||
|
||||
namespace SurfaceGui
|
||||
{
|
||||
|
||||
class Ui_TaskFilling;
|
||||
|
||||
class ViewProviderFilling : public PartGui::ViewProviderSpline
|
||||
{
|
||||
PROPERTY_HEADER(SurfaceGui::ViewProviderFilling);
|
||||
public:
|
||||
virtual void setupContextMenu(QMenu*, QObject*, const char*);
|
||||
virtual bool setEdit(int ModNum);
|
||||
virtual void unsetEdit(int ModNum);
|
||||
QIcon getIcon(void) const;
|
||||
void highlightReferences(bool on);
|
||||
};
|
||||
|
||||
class FillingPanel : public QWidget,
|
||||
public Gui::SelectionObserver,
|
||||
public Gui::DocumentObserver
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
protected:
|
||||
class ShapeSelection;
|
||||
enum SelectionMode { None, Append, Remove };
|
||||
SelectionMode selectionMode;
|
||||
Surface::Filling* editedObject;
|
||||
bool checkCommand;
|
||||
|
||||
private:
|
||||
Ui_TaskFilling* ui;
|
||||
ViewProviderFilling* vp;
|
||||
|
||||
public:
|
||||
FillingPanel(ViewProviderFilling* vp, Surface::Filling* obj);
|
||||
~FillingPanel();
|
||||
|
||||
void open();
|
||||
void checkOpenCommand();
|
||||
bool accept();
|
||||
bool reject();
|
||||
void setEditedObject(Surface::Filling* obj);
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
virtual void onSelectionChanged(const Gui::SelectionChanges& msg);
|
||||
/** Notifies on undo */
|
||||
virtual void slotUndoDocument(const Gui::Document& Doc);
|
||||
/** Notifies on redo */
|
||||
virtual void slotRedoDocument(const Gui::Document& Doc);
|
||||
void changeFillType(GeomFill_FillingStyle);
|
||||
|
||||
private Q_SLOTS:
|
||||
void on_fillType_stretch_clicked();
|
||||
void on_fillType_coons_clicked();
|
||||
void on_fillType_curved_clicked();
|
||||
void on_buttonEdgeAdd_clicked();
|
||||
void on_buttonEdgeRemove_clicked();
|
||||
void onDeleteEdge(void);
|
||||
void clearSelection();
|
||||
};
|
||||
|
||||
class TaskFilling : public Gui::TaskView::TaskDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskFilling(ViewProviderFilling* vp, Surface::Filling* obj);
|
||||
~TaskFilling();
|
||||
void setEditedObject(Surface::Filling* obj);
|
||||
|
||||
public:
|
||||
void open();
|
||||
bool accept();
|
||||
bool reject();
|
||||
|
||||
virtual QDialogButtonBox::StandardButtons getStandardButtons() const
|
||||
{ return QDialogButtonBox::Ok | QDialogButtonBox::Cancel; }
|
||||
|
||||
private:
|
||||
FillingPanel* widget;
|
||||
Gui::TaskView::TaskBox* taskbox;
|
||||
};
|
||||
|
||||
} //namespace SurfaceGui
|
||||
|
||||
#endif // SURFACEGUI_TASKFILLING_H
|
||||
106
src/Mod/Surface/Gui/TaskFilling.ui
Normal file
106
src/Mod/Surface/Gui/TaskFilling.ui
Normal file
@@ -0,0 +1,106 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SurfaceGui::TaskFilling</class>
|
||||
<widget class="QWidget" name="SurfaceGui::TaskFilling">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>277</width>
|
||||
<height>467</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Filling</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonEdgeAdd">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add Edge</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonEdgeRemove">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove Edge</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QListWidget" name="listWidget"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="fillTypes">
|
||||
<property name="title">
|
||||
<string>Fill type:</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="2" column="0">
|
||||
<widget class="QRadioButton" name="fillType_coons">
|
||||
<property name="text">
|
||||
<string>Coons</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="fillType_stretch">
|
||||
<property name="text">
|
||||
<string>Stretch</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QRadioButton" name="fillType_curved">
|
||||
<property name="text">
|
||||
<string>Curved</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -53,6 +53,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
|
||||
root->insertItem( item, surface );
|
||||
surface->setCommand("Surface");
|
||||
*surface << "Surface_CurveOnMesh"
|
||||
<< "Surface_Filling"
|
||||
<< "Surface_GeomFillSurface";
|
||||
/* *surface << "Surface_Filling";
|
||||
*surface << "Surface_Cut";*/
|
||||
@@ -66,9 +67,9 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
||||
|
||||
Gui::ToolBarItem* surface = new Gui::ToolBarItem(root);
|
||||
surface->setCommand( "Surface" );
|
||||
*surface << "Surface_GeomFillSurface";
|
||||
/* *surface << "Surface_Filling";
|
||||
*surface << "Surface_Cut"; */
|
||||
*surface << "Surface_Filling"
|
||||
<< "Surface_GeomFillSurface";
|
||||
/* *surface << "Surface_Cut"; */
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user