Allow selecting and removing fillet and chamfer references in the dialog

This commit is contained in:
jrheinlaender 2013-10-02 21:35:40 +02:00 committed by Stefan Tröger
parent 8b19d2cf16
commit ee7f50a554
13 changed files with 441 additions and 330 deletions

View File

@ -50,8 +50,8 @@ using namespace Gui;
/* TRANSLATOR PartDesignGui::TaskChamferParameters */
TaskChamferParameters::TaskChamferParameters(ViewProviderChamfer *ChamferView,QWidget *parent)
: TaskBox(Gui::BitmapFactory().pixmap("Part_Chamfer"),tr("Chamfer parameters"),true, parent),ChamferView(ChamferView)
TaskChamferParameters::TaskChamferParameters(ViewProviderDressUp *DressUpView,QWidget *parent)
: TaskDressUpParameters(DressUpView, parent)
{
// we need a separate container widget to add all controls to
proxy = new QWidget(this);
@ -61,10 +61,14 @@ TaskChamferParameters::TaskChamferParameters(ViewProviderChamfer *ChamferView,QW
connect(ui->chamferDistance, SIGNAL(valueChanged(double)),
this, SLOT(onLengthChanged(double)));
connect(ui->buttonRefAdd, SIGNAL(toggled(bool)),
this, SLOT(onButtonRefAdd(bool)));
connect(ui->buttonRefRemove, SIGNAL(toggled(bool)),
this, SLOT(onButtonRefRemove(bool)));
this->groupLayout()->addWidget(proxy);
PartDesign::Chamfer* pcChamfer = static_cast<PartDesign::Chamfer*>(ChamferView->getObject());
PartDesign::Chamfer* pcChamfer = static_cast<PartDesign::Chamfer*>(DressUpView->getObject());
double r = pcChamfer->Size.getValue();
ui->chamferDistance->setUnit(Base::Unit::Length);
@ -73,11 +77,55 @@ TaskChamferParameters::TaskChamferParameters(ViewProviderChamfer *ChamferView,QW
ui->chamferDistance->selectNumber();
ui->chamferDistance->bind(pcChamfer->Size);
QMetaObject::invokeMethod(ui->chamferDistance, "setFocus", Qt::QueuedConnection);
std::vector<std::string> strings = pcChamfer->Base.getSubValues();
for (std::vector<std::string>::const_iterator i = strings.begin(); i != strings.end(); i++)
{
ui->listWidgetReferences->insertItem(0, QString::fromStdString(*i));
}
// Create context menu
QAction* action = new QAction(tr("Remove"), this);
ui->listWidgetReferences->addAction(action);
connect(action, SIGNAL(triggered()), this, SLOT(onRefDeleted()));
ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu);
}
void TaskChamferParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
{
if (selectionMode == none)
return;
if (msg.Type == Gui::SelectionChanges::AddSelection) {
if (referenceSelected(msg)) {
if (selectionMode == refAdd)
ui->listWidgetReferences->insertItem(0, QString::fromStdString(msg.pSubName));
else
removeItemFromListWidget(ui->listWidgetReferences, msg.pSubName);
clearButtons(none);
exitSelectionMode();
}
}
}
void TaskChamferParameters::clearButtons(const selectionModes notThis)
{
if (notThis != refAdd) ui->buttonRefAdd->setChecked(false);
if (notThis != refRemove) ui->buttonRefRemove->setChecked(false);
}
void TaskChamferParameters::onRefDeleted(void)
{
PartDesign::Chamfer* pcChamfer = static_cast<PartDesign::Chamfer*>(DressUpView->getObject());
App::DocumentObject* base = pcChamfer->Base.getValue();
std::vector<std::string> refs = pcChamfer->Base.getSubValues();
refs.erase(refs.begin() + ui->listWidgetReferences->currentRow());
pcChamfer->Base.setValue(base, refs);
ui->listWidgetReferences->model()->removeRow(ui->listWidgetReferences->currentRow());
pcChamfer->getDocument()->recomputeFeature(pcChamfer);
}
void TaskChamferParameters::onLengthChanged(double len)
{
PartDesign::Chamfer* pcChamfer = static_cast<PartDesign::Chamfer*>(ChamferView->getObject());
PartDesign::Chamfer* pcChamfer = static_cast<PartDesign::Chamfer*>(DressUpView->getObject());
pcChamfer->Size.setValue(len);
pcChamfer->getDocument()->recomputeFeature(pcChamfer);
}
@ -89,6 +137,7 @@ double TaskChamferParameters::getLength(void) const
TaskChamferParameters::~TaskChamferParameters()
{
Gui::Selection().rmvSelectionGate();
delete ui;
}
@ -102,12 +151,13 @@ void TaskChamferParameters::changeEvent(QEvent *e)
void TaskChamferParameters::apply()
{
std::string name = ChamferView->getObject()->getNameInDocument();
std::string name = DressUpView->getObject()->getNameInDocument();
//Gui::Command::openCommand("Chamfer changed");
ui->chamferDistance->apply();
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
Gui::Command::commitCommand();
}
@ -116,11 +166,10 @@ void TaskChamferParameters::apply()
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskDlgChamferParameters::TaskDlgChamferParameters(ViewProviderChamfer *ChamferView)
: TaskDialog(),ChamferView(ChamferView)
TaskDlgChamferParameters::TaskDlgChamferParameters(ViewProviderChamfer *DressUpView)
: TaskDlgDressUpParameters(DressUpView)
{
assert(ChamferView);
parameter = new TaskChamferParameters(ChamferView);
parameter = new TaskChamferParameters(DressUpView);
Content.push_back(parameter);
}
@ -133,48 +182,20 @@ TaskDlgChamferParameters::~TaskDlgChamferParameters()
//==== calls from the TaskView ===============================================================
void TaskDlgChamferParameters::open()
{
// a transaction is already open at creation time of the chamfer
if (!Gui::Command::hasPendingCommand()) {
QString msg = tr("Edit chamfer");
Gui::Command::openCommand((const char*)msg.toUtf8());
}
}
void TaskDlgChamferParameters::clicked(int)
{
}
//void TaskDlgChamferParameters::open()
//{
// // a transaction is already open at creation time of the chamfer
// if (!Gui::Command::hasPendingCommand()) {
// QString msg = tr("Edit chamfer");
// Gui::Command::openCommand((const char*)msg.toUtf8());
// }
//}
bool TaskDlgChamferParameters::accept()
{
parameter->showObject();
parameter->apply();
return true;
return TaskDlgDressUpParameters::accept();
}
bool TaskDlgChamferParameters::reject()
{
// role back the done things
Gui::Command::abortCommand();
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
// Body housekeeping
if (ActivePartObject != NULL) {
// Make the new Tip and the previous solid feature visible again
App::DocumentObject* tip = ActivePartObject->Tip.getValue();
App::DocumentObject* prev = ActivePartObject->getPrevSolidFeature();
if (tip != NULL) {
Gui::Application::Instance->getViewProvider(tip)->show();
if ((tip != prev) && (prev != NULL))
Gui::Application::Instance->getViewProvider(prev)->show();
}
}
return true;
}
#include "moc_TaskChamferParameters.cpp"

View File

@ -24,83 +24,49 @@
#ifndef GUI_TASKVIEW_TaskChamferParameters_H
#define GUI_TASKVIEW_TaskChamferParameters_H
#include <Gui/TaskView/TaskView.h>
#include <Gui/Selection.h>
#include <Gui/TaskView/TaskDialog.h>
#include "TaskDressUpParameters.h"
#include "ViewProviderChamfer.h"
class Ui_TaskChamferParameters;
namespace App {
class Property;
}
namespace Gui {
class ViewProvider;
}
namespace PartDesignGui {
class TaskChamferParameters : public Gui::TaskView::TaskBox
class TaskChamferParameters : public TaskDressUpParameters
{
Q_OBJECT
public:
TaskChamferParameters(ViewProviderChamfer *ChamferView, QWidget *parent=0);
TaskChamferParameters(ViewProviderDressUp *DressUpView, QWidget *parent=0);
~TaskChamferParameters();
void apply();
virtual void apply();
private Q_SLOTS:
void onLengthChanged(double);
void onRefDeleted(void);
protected:
virtual void clearButtons(const selectionModes notThis);
void changeEvent(QEvent *e);
virtual void onSelectionChanged(const Gui::SelectionChanges& msg);
double getLength(void) const;
private:
private:
QWidget* proxy;
Ui_TaskChamferParameters* ui;
ViewProviderChamfer *ChamferView;
};
/// simulation dialog for the TaskView
class TaskDlgChamferParameters : public Gui::TaskView::TaskDialog
class TaskDlgChamferParameters : public TaskDlgDressUpParameters
{
Q_OBJECT
public:
TaskDlgChamferParameters(ViewProviderChamfer *ChamferView);
TaskDlgChamferParameters(ViewProviderChamfer *DressUpView);
~TaskDlgChamferParameters();
ViewProviderChamfer* getChamferView() const
{ return ChamferView; }
public:
/// is called the TaskView when the dialog is opened
virtual void open();
/// is called by the framework if an button is clicked which has no accept or reject role
virtual void clicked(int);
/// 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)
virtual bool reject();
virtual bool isAllowedAlterDocument(void) const
{ return false; }
/// returns for Close and Help button
virtual QDialogButtonBox::StandardButtons getStandardButtons(void) const
{ return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; }
protected:
ViewProviderChamfer *ChamferView;
TaskChamferParameters *parameter;
};
} //namespace PartDesignGui

View File

@ -0,0 +1,90 @@
/***************************************************************************
* Copyright (c) 2011 Juergen Riegel <FreeCAD@juergen-riegel.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_TaskChamferParameters_H
#define GUI_TASKVIEW_TaskChamferParameters_H
#include "TaskDressUpParameters.h"
#include "ViewProviderChamfer.h"
class Ui_TaskChamferParameters;
namespace PartDesignGui {
class TaskChamferParameters : public TaskDressUpParameters
{
Q_OBJECT
public:
TaskChamferParameters(ViewProviderDressUp *DressUpView, QWidget *parent=0);
~TaskChamferParameters();
virtual void apply();
private Q_SLOTS:
void onLengthChanged(double);
void onRefDeleted(void);
protected:
virtual void clearButtons(const selectionModes notThis);
void changeEvent(QEvent *e);
virtual void onSelectionChanged(const Gui::SelectionChanges& msg);
double getLength(void) const;
private:
Ui_TaskChamferParameters* ui;
};
/// simulation dialog for the TaskView
class TaskDlgChamferParameters : public TaskDlgDressUpParameters
{
Q_OBJECT
public:
TaskDlgChamferParameters(ViewProviderChamfer *DressUpView);
~TaskDlgChamferParameters();
public:
/// is called by the framework if the dialog is accepted (Ok)
virtual bool accept();
<<<<<<< 61d7568d0ff2d3e87f1abb738517f4294c5a6d2e
/// is called by the framework if the dialog is rejected (Cancel)
virtual bool reject();
virtual bool isAllowedAlterDocument(void) const
{ return false; }
/// returns for Close and Help button
virtual QDialogButtonBox::StandardButtons getStandardButtons(void) const
{ return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; }
protected:
ViewProviderChamfer *ChamferView;
TaskChamferParameters *parameter;
=======
>>>>>>> Allow selecting and removing fillet and chamfer references in the dialog
};
} //namespace PartDesignGui
#endif // GUI_TASKVIEW_TaskChamferParameters_H

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>135</width>
<height>40</height>
<width>182</width>
<height>185</height>
</rect>
</property>
<property name="windowTitle">
@ -15,19 +15,42 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<widget class="QToolButton" name="buttonRefAdd">
<property name="text">
<string>Size:</string>
<string>Add ref</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="Gui::QuantitySpinBox" name="chamferDistance"/>
<widget class="QToolButton" name="buttonRefRemove">
<property name="text">
<string>Remove ref</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidgetReferences"/>
</item>
<item>
<widget class="Gui::QuantitySpinBox" name="chamferDistance"/>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Size:</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>

View File

@ -48,6 +48,9 @@ public:
void hideObject();
void showObject();
/// Apply the changes made to the object to it
virtual void apply() {};
protected Q_SLOTS:
void onButtonRefAdd(const bool checked);
void onButtonRefRemove(const bool checked);
@ -63,11 +66,13 @@ protected:
virtual void changeEvent(QEvent *e) = 0;
static void removeItemFromListWidget(QListWidget* widget, const char* itemstr);
ViewProviderDressUp* getDressUpView() const
{ return DressUpView; }
protected:
QWidget* proxy;
ViewProviderDressUp *DressUpView;
selectionModes selectionMode;
};

View File

@ -50,8 +50,8 @@ using namespace Gui;
/* TRANSLATOR PartDesignGui::TaskFilletParameters */
TaskFilletParameters::TaskFilletParameters(ViewProviderFillet *FilletView,QWidget *parent)
: TaskBox(Gui::BitmapFactory().pixmap("Part_Fillet"),tr("Fillet parameters"),true, parent),FilletView(FilletView)
TaskFilletParameters::TaskFilletParameters(ViewProviderDressUp *DressUpView,QWidget *parent)
: TaskDressUpParameters(DressUpView, parent)
{
// we need a separate container widget to add all controls to
proxy = new QWidget(this);
@ -61,10 +61,14 @@ TaskFilletParameters::TaskFilletParameters(ViewProviderFillet *FilletView,QWidge
connect(ui->filletRadius, SIGNAL(valueChanged(double)),
this, SLOT(onLengthChanged(double)));
connect(ui->buttonRefAdd, SIGNAL(toggled(bool)),
this, SLOT(onButtonRefAdd(bool)));
connect(ui->buttonRefRemove, SIGNAL(toggled(bool)),
this, SLOT(onButtonRefRemove(bool)));
this->groupLayout()->addWidget(proxy);
PartDesign::Fillet* pcFillet = static_cast<PartDesign::Fillet*>(FilletView->getObject());
PartDesign::Fillet* pcFillet = static_cast<PartDesign::Fillet*>(DressUpView->getObject());
double r = pcFillet->Radius.getValue();
ui->filletRadius->setUnit(Base::Unit::Length);
@ -73,11 +77,56 @@ TaskFilletParameters::TaskFilletParameters(ViewProviderFillet *FilletView,QWidge
ui->filletRadius->selectNumber();
ui->filletRadius->bind(pcFillet->Radius);
QMetaObject::invokeMethod(ui->filletRadius, "setFocus", Qt::QueuedConnection);
std::vector<std::string> strings = pcFillet->Base.getSubValues();
for (std::vector<std::string>::const_iterator i = strings.begin(); i != strings.end(); i++)
{
ui->listWidgetReferences->insertItem(0, QString::fromStdString(*i));
}
// Create context menu
QAction* action = new QAction(tr("Remove"), this);
ui->listWidgetReferences->addAction(action);
connect(action, SIGNAL(triggered()), this, SLOT(onRefDeleted()));
ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu);
}
void TaskFilletParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
{
if (selectionMode == none)
return;
if (msg.Type == Gui::SelectionChanges::AddSelection) {
if (referenceSelected(msg)) {
if (selectionMode == refAdd)
ui->listWidgetReferences->insertItem(0, QString::fromStdString(msg.pSubName));
else
removeItemFromListWidget(ui->listWidgetReferences, msg.pSubName);
clearButtons(none);
exitSelectionMode();
}
}
}
void TaskFilletParameters::clearButtons(const selectionModes notThis)
{
if (notThis != refAdd) ui->buttonRefAdd->setChecked(false);
if (notThis != refRemove) ui->buttonRefRemove->setChecked(false);
}
void TaskFilletParameters::onRefDeleted(void)
{
PartDesign::Fillet* pcFillet = static_cast<PartDesign::Fillet*>(DressUpView->getObject());
App::DocumentObject* base = pcFillet->Base.getValue();
std::vector<std::string> refs = pcFillet->Base.getSubValues();
refs.erase(refs.begin() + ui->listWidgetReferences->currentRow());
pcFillet->Base.setValue(base, refs);
ui->listWidgetReferences->model()->removeRow(ui->listWidgetReferences->currentRow());
pcFillet->getDocument()->recomputeFeature(pcFillet);
}
void TaskFilletParameters::onLengthChanged(double len)
{
PartDesign::Fillet* pcFillet = static_cast<PartDesign::Fillet*>(FilletView->getObject());
clearButtons(none);
PartDesign::Fillet* pcFillet = static_cast<PartDesign::Fillet*>(DressUpView->getObject());
pcFillet->Radius.setValue(len);
pcFillet->getDocument()->recomputeFeature(pcFillet);
}
@ -89,6 +138,7 @@ double TaskFilletParameters::getLength(void) const
TaskFilletParameters::~TaskFilletParameters()
{
Gui::Selection().rmvSelectionGate();
delete ui;
}
@ -102,7 +152,7 @@ void TaskFilletParameters::changeEvent(QEvent *e)
void TaskFilletParameters::apply()
{
std::string name = FilletView->getObject()->getNameInDocument();
std::string name = getDressUpView()->getObject()->getNameInDocument();
//Gui::Command::openCommand("Fillet changed");
ui->filletRadius->apply();
@ -116,11 +166,10 @@ void TaskFilletParameters::apply()
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskDlgFilletParameters::TaskDlgFilletParameters(ViewProviderFillet *FilletView)
: TaskDialog(),FilletView(FilletView)
TaskDlgFilletParameters::TaskDlgFilletParameters(ViewProviderFillet *DressUpView)
: TaskDlgDressUpParameters(DressUpView)
{
assert(FilletView);
parameter = new TaskFilletParameters(FilletView);
parameter = new TaskFilletParameters(DressUpView);
Content.push_back(parameter);
}
@ -133,48 +182,20 @@ TaskDlgFilletParameters::~TaskDlgFilletParameters()
//==== calls from the TaskView ===============================================================
void TaskDlgFilletParameters::open()
{
// a transaction is already open at creation time of the fillet
if (!Gui::Command::hasPendingCommand()) {
QString msg = tr("Edit fillet");
Gui::Command::openCommand((const char*)msg.toUtf8());
}
}
void TaskDlgFilletParameters::clicked(int)
{
}
//void TaskDlgFilletParameters::open()
//{
// // a transaction is already open at creation time of the fillet
// if (!Gui::Command::hasPendingCommand()) {
// QString msg = tr("Edit fillet");
// Gui::Command::openCommand((const char*)msg.toUtf8());
// }
//}
bool TaskDlgFilletParameters::accept()
{
parameter->showObject();
parameter->apply();
return true;
return TaskDlgDressUpParameters::accept();
}
bool TaskDlgFilletParameters::reject()
{
// role back the done things
Gui::Command::abortCommand();
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
// Body housekeeping
if (ActivePartObject != NULL) {
// Make the new Tip and the previous solid feature visible again
App::DocumentObject* tip = ActivePartObject->Tip.getValue();
App::DocumentObject* prev = ActivePartObject->getPrevSolidFeature();
if (tip != NULL) {
Gui::Application::Instance->getViewProvider(tip)->show();
if ((tip != prev) && (prev != NULL))
Gui::Application::Instance->getViewProvider(prev)->show();
}
}
return true;
}
#include "moc_TaskFilletParameters.cpp"

View File

@ -24,85 +24,51 @@
#ifndef GUI_TASKVIEW_TaskFilletParameters_H
#define GUI_TASKVIEW_TaskFilletParameters_H
#include <Gui/TaskView/TaskView.h>
#include <Gui/Selection.h>
#include <Gui/TaskView/TaskDialog.h>
#include "TaskDressUpParameters.h"
#include "ViewProviderFillet.h"
class Ui_TaskFilletParameters;
namespace App {
class Property;
}
namespace Gui {
class ViewProvider;
}
namespace PartDesignGui {
class TaskFilletParameters : public Gui::TaskView::TaskBox
class TaskFilletParameters : public TaskDressUpParameters
{
Q_OBJECT
public:
TaskFilletParameters(ViewProviderFillet *FilletView, QWidget *parent=0);
TaskFilletParameters(ViewProviderDressUp *DressUpView, QWidget *parent=0);
~TaskFilletParameters();
void apply();
virtual void apply();
private Q_SLOTS:
void onLengthChanged(double);
void onRefDeleted(void);
protected:
double getLength(void) const;
virtual void clearButtons(const selectionModes notThis);
void changeEvent(QEvent *e);
virtual void onSelectionChanged(const Gui::SelectionChanges& msg);
private:
private:
QWidget* proxy;
Ui_TaskFilletParameters* ui;
ViewProviderFillet *FilletView;
};
/// simulation dialog for the TaskView
class TaskDlgFilletParameters : public Gui::TaskView::TaskDialog
class TaskDlgFilletParameters : public TaskDlgDressUpParameters
{
Q_OBJECT
public:
TaskDlgFilletParameters(ViewProviderFillet *FilletView);
TaskDlgFilletParameters(ViewProviderFillet *DressUpView);
~TaskDlgFilletParameters();
ViewProviderFillet* getFilletView() const
{ return FilletView; }
public:
/// is called the TaskView when the dialog is opened
virtual void open();
/// is called by the framework if an button is clicked which has no accept or reject role
virtual void clicked(int);
/// 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)
virtual bool reject();
virtual bool isAllowedAlterDocument(void) const
{ return false; }
/// returns for Close and Help button
virtual QDialogButtonBox::StandardButtons getStandardButtons(void) const
{ return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; }
protected:
ViewProviderFillet *FilletView;
TaskFilletParameters *parameter;
};
} //namespace PartDesignGui
#endif // GUI_TASKVIEW_TASKAPPERANCE_H
#endif // GUI_TASKVIEW_TaskFilletParameters_H

View File

@ -0,0 +1,90 @@
/***************************************************************************
* Copyright (c) 2011 Juergen Riegel <FreeCAD@juergen-riegel.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_TaskFilletParameters_H
#define GUI_TASKVIEW_TaskFilletParameters_H
#include "TaskDressUpParameters.h"
#include "ViewProviderFillet.h"
class Ui_TaskFilletParameters;
namespace PartDesignGui {
class TaskFilletParameters : public TaskDressUpParameters
{
Q_OBJECT
public:
TaskFilletParameters(ViewProviderDressUp *DressUpView, QWidget *parent=0);
~TaskFilletParameters();
virtual void apply();
private Q_SLOTS:
void onLengthChanged(double);
void onRefDeleted(void);
protected:
double getLength(void) const;
virtual void clearButtons(const selectionModes notThis);
void changeEvent(QEvent *e);
virtual void onSelectionChanged(const Gui::SelectionChanges& msg);
private:
Ui_TaskFilletParameters* ui;
};
/// simulation dialog for the TaskView
class TaskDlgFilletParameters : public TaskDlgDressUpParameters
{
Q_OBJECT
public:
TaskDlgFilletParameters(ViewProviderFillet *DressUpView);
~TaskDlgFilletParameters();
public:
/// is called by the framework if the dialog is accepted (Ok)
virtual bool accept();
<<<<<<< 61d7568d0ff2d3e87f1abb738517f4294c5a6d2e
/// is called by the framework if the dialog is rejected (Cancel)
virtual bool reject();
virtual bool isAllowedAlterDocument(void) const
{ return false; }
/// returns for Close and Help button
virtual QDialogButtonBox::StandardButtons getStandardButtons(void) const
{ return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; }
protected:
ViewProviderFillet *FilletView;
TaskFilletParameters *parameter;
=======
>>>>>>> Allow selecting and removing fillet and chamfer references in the dialog
};
} //namespace PartDesignGui
#endif // GUI_TASKVIEW_TaskFilletParameters_H

View File

@ -6,14 +6,41 @@
<rect>
<x>0</x>
<y>0</y>
<width>135</width>
<height>40</height>
<width>208</width>
<height>164</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="buttonRefAdd">
<property name="text">
<string>Add ref</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonRefRemove">
<property name="text">
<string>Remove ref</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidgetReferences"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>

View File

@ -31,8 +31,6 @@
#include "ViewProviderChamfer.h"
#include "TaskChamferParameters.h"
#include <Mod/PartDesign/App/FeatureChamfer.h>
#include <Mod/Sketcher/App/SketchObject.h>
#include <Gui/Control.h>
#include <Gui/Command.h>
#include <Gui/Application.h>
@ -40,73 +38,32 @@
using namespace PartDesignGui;
PROPERTY_SOURCE(PartDesignGui::ViewProviderChamfer,PartDesignGui::ViewProvider)
ViewProviderChamfer::ViewProviderChamfer()
{
sPixmap = "PartDesign_Chamfer.svg";
}
ViewProviderChamfer::~ViewProviderChamfer()
{
}
void ViewProviderChamfer::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
{
QAction* act;
act = menu->addAction(QObject::tr("Edit chamfer"), receiver, member);
act->setData(QVariant((int)ViewProvider::Default));
PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member);
}
PROPERTY_SOURCE(PartDesignGui::ViewProviderChamfer,PartDesignGui::ViewProviderDressUp)
bool ViewProviderChamfer::setEdit(int ModNum)
{
if (ModNum == ViewProvider::Default ) {
// When double-clicking on the item for this chamfer the
// object unsets and sets its edit mode without closing
// the task panel
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
TaskDlgChamferParameters *padDlg = qobject_cast<TaskDlgChamferParameters *>(dlg);
if (padDlg && padDlg->getChamferView() != this)
padDlg = 0; // another pad left open its task panel
if (dlg && !padDlg) {
QMessageBox msgBox;
msgBox.setText(QObject::tr("A dialog is already open in the task panel"));
msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Yes);
int ret = msgBox.exec();
if (ret == QMessageBox::Yes)
Gui::Control().reject();
TaskDlgDressUpParameters *dressUpDlg = NULL;
if (checkDlgOpen(dressUpDlg)) {
// always change to PartDesign WB, remember where we come from
oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench");
// start the edit dialog
if (dressUpDlg)
Gui::Control().showDialog(dressUpDlg);
else
return false;
Gui::Control().showDialog(new TaskDlgChamferParameters(this));
return true;
} else {
return false;
}
// clear the selection (convenience)
Gui::Selection().clearSelection();
// always change to PartDesign WB, remember where we come from
oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench");
// start the edit dialog
if (padDlg)
Gui::Control().showDialog(padDlg);
else
Gui::Control().showDialog(new TaskDlgChamferParameters(this));
return true;
}
else {
return PartGui::ViewProviderPart::setEdit(ModNum);
return ViewProviderDressUp::setEdit(ModNum);
}
}
bool ViewProviderChamfer::onDelete(const std::vector<std::string> &s)
{
return ViewProvider::onDelete(s);
}

View File

@ -24,25 +24,20 @@
#ifndef PARTGUI_ViewProviderChamfer_H
#define PARTGUI_ViewProviderChamfer_H
#include "ViewProvider.h"
#include "ViewProviderDressUp.h"
namespace PartDesignGui {
class PartDesignGuiExport ViewProviderChamfer : public ViewProvider
class PartDesignGuiExport ViewProviderChamfer : public ViewProviderDressUp
{
PROPERTY_HEADER(PartDesignGui::ViewProviderChamfer);
public:
/// constructor
ViewProviderChamfer();
/// destructor
virtual ~ViewProviderChamfer();
/// grouping handling
void setupContextMenu(QMenu*, QObject*, const char*);
virtual bool onDelete(const std::vector<std::string> &);
ViewProviderChamfer()
{ featureName = std::string("Chamfer");
sPixmap = "PartDesign_Chamfer.svg"; }
protected:
virtual bool setEdit(int ModNum);

View File

@ -31,8 +31,6 @@
#include "ViewProviderFillet.h"
#include "TaskFilletParameters.h"
#include <Mod/PartDesign/App/FeatureFillet.h>
#include <Mod/Sketcher/App/SketchObject.h>
#include <Gui/Control.h>
#include <Gui/Command.h>
#include <Gui/Application.h>
@ -40,71 +38,31 @@
using namespace PartDesignGui;
PROPERTY_SOURCE(PartDesignGui::ViewProviderFillet,PartDesignGui::ViewProvider)
ViewProviderFillet::ViewProviderFillet()
{
sPixmap = "PartDesign_Fillet.svg";
}
ViewProviderFillet::~ViewProviderFillet()
{
}
void ViewProviderFillet::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
{
QAction* act;
act = menu->addAction(QObject::tr("Edit fillet"), receiver, member);
act->setData(QVariant((int)ViewProvider::Default));
PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member);
}
PROPERTY_SOURCE(PartDesignGui::ViewProviderFillet,PartDesignGui::ViewProviderDressUp)
bool ViewProviderFillet::setEdit(int ModNum)
{
if (ModNum == ViewProvider::Default ) {
// When double-clicking on the item for this fillet the
// object unsets and sets its edit mode without closing
// the task panel
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
TaskDlgFilletParameters *padDlg = qobject_cast<TaskDlgFilletParameters *>(dlg);
if (padDlg && padDlg->getFilletView() != this)
padDlg = 0; // another pad left open its task panel
if (dlg && !padDlg) {
QMessageBox msgBox;
msgBox.setText(QObject::tr("A dialog is already open in the task panel"));
msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Yes);
int ret = msgBox.exec();
if (ret == QMessageBox::Yes)
Gui::Control().reject();
TaskDlgDressUpParameters *dressUpDlg = NULL;
if (checkDlgOpen(dressUpDlg)) {
// always change to PartDesign WB, remember where we come from
oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench");
// start the edit dialog
if (dressUpDlg)
Gui::Control().showDialog(dressUpDlg);
else
return false;
Gui::Control().showDialog(new TaskDlgFilletParameters(this));
return true;
} else {
return false;
}
// clear the selection (convenience)
Gui::Selection().clearSelection();
// always change to PartDesign WB, remember where we come from
oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench");
// start the edit dialog
if (padDlg)
Gui::Control().showDialog(padDlg);
else
Gui::Control().showDialog(new TaskDlgFilletParameters(this));
return true;
}
else {
return PartGui::ViewProviderPart::setEdit(ModNum);
return ViewProviderDressUp::setEdit(ModNum);
}
}
bool ViewProviderFillet::onDelete(const std::vector<std::string> &s)
{
return ViewProvider::onDelete(s);
}

View File

@ -24,33 +24,25 @@
#ifndef PARTGUI_ViewProviderFillet_H
#define PARTGUI_ViewProviderFillet_H
#include "ViewProvider.h"
#include "ViewProviderDressUp.h"
namespace PartDesignGui {
class PartDesignGuiExport ViewProviderFillet : public ViewProvider
class PartDesignGuiExport ViewProviderFillet : public ViewProviderDressUp
{
PROPERTY_HEADER(PartDesignGui::ViewProviderFillet);
public:
/// constructor
ViewProviderFillet();
/// destructor
virtual ~ViewProviderFillet();
/// grouping handling
void setupContextMenu(QMenu*, QObject*, const char*);
virtual bool onDelete(const std::vector<std::string> &);
ViewProviderFillet()
{ featureName = std::string("Fillet");
sPixmap = "PartDesign_Fillet.svg"; }
protected:
virtual bool setEdit(int ModNum);
};
} // namespace PartDesignGui