+ Add fillet dialog
+ fix undo/redo bug in edit PartDesign features + partially clean up module dependency in ViewProvider base class git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5108 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
parent
11008812de
commit
72bfc3c74b
|
@ -185,12 +185,14 @@ public:
|
|||
Transform,
|
||||
Cutting,
|
||||
Color,
|
||||
Mirror,
|
||||
Mirror
|
||||
//FIXME: Never do such stuff in the base system
|
||||
/*,
|
||||
Fillet,
|
||||
Sketch,
|
||||
Pad,
|
||||
Pocket,
|
||||
Revolve
|
||||
Revolve*/
|
||||
};
|
||||
protected:
|
||||
/// is called by the document when the provider goes in edit mode
|
||||
|
|
|
@ -205,13 +205,13 @@ void ViewProviderFillet::setupContextMenu(QMenu* menu, QObject* receiver, const
|
|||
{
|
||||
QAction* act;
|
||||
act = menu->addAction(QObject::tr("Edit fillet edges"), receiver, member);
|
||||
act->setData(QVariant((int)ViewProvider::Fillet));
|
||||
act->setData(QVariant((int)ViewProvider::Default));
|
||||
PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member);
|
||||
}
|
||||
|
||||
bool ViewProviderFillet::setEdit(int ModNum)
|
||||
{
|
||||
if (ModNum == ViewProvider::Default || ModNum == ViewProvider::Fillet) {
|
||||
if (ModNum == ViewProvider::Default ) {
|
||||
if (Gui::Control().activeDialog())
|
||||
return false;
|
||||
Part::Fillet* fillet = static_cast<Part::Fillet*>(getObject());
|
||||
|
@ -226,7 +226,7 @@ bool ViewProviderFillet::setEdit(int ModNum)
|
|||
|
||||
void ViewProviderFillet::unsetEdit(int ModNum)
|
||||
{
|
||||
if (ModNum == ViewProvider::Default || ModNum == ViewProvider::Fillet) {
|
||||
if (ModNum == ViewProvider::Default) {
|
||||
Gui::Control().closeDialog();
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -45,10 +45,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 "PartGui::ViewProviderFillet";
|
||||
//}
|
||||
// returns the type name of the view provider
|
||||
const char* getViewProviderName(void) const {
|
||||
return "PartDesignGui::ViewProviderFillet";
|
||||
}
|
||||
//@}
|
||||
};
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "Workbench.h"
|
||||
#include "ViewProviderPocket.h"
|
||||
#include "ViewProviderPad.h"
|
||||
#include "ViewProviderFillet.h"
|
||||
#include "ViewProviderRevolution.h"
|
||||
#include "TaskChamfer.h"
|
||||
|
||||
|
@ -78,10 +79,12 @@ void PartDesignGuiExport initPartDesignGui()
|
|||
CreatePartDesignCommands();
|
||||
|
||||
PartDesignGui::Workbench ::init();
|
||||
PartDesignGui::ViewProvider ::init();
|
||||
PartDesignGui::ViewProviderPocket ::init();
|
||||
PartDesignGui::ViewProviderPad ::init();
|
||||
PartDesignGui::ViewProviderRevolution::init();
|
||||
PartDesignGui::ViewProviderChamfer ::init();
|
||||
PartDesignGui::ViewProviderFillet ::init();
|
||||
|
||||
// add resources and reloads the translators
|
||||
loadPartDesignResource();
|
||||
|
|
|
@ -29,6 +29,7 @@ set(PartDesignGui_MOC_HDRS
|
|||
TaskPadParameters.h
|
||||
TaskPatternRectangularParameters.h
|
||||
TaskPocketParameters.h
|
||||
TaskFilletParameters.h
|
||||
TaskHoleParameters.h
|
||||
TaskRevolutionParameters.h
|
||||
)
|
||||
|
@ -42,6 +43,7 @@ set(PartDesignGui_UIC_SRCS
|
|||
TaskPadParameters.ui
|
||||
TaskPatternRectangularParameters.ui
|
||||
TaskPocketParameters.ui
|
||||
TaskFilletParameters.ui
|
||||
TaskHoleParameters.ui
|
||||
TaskRevolutionParameters.ui
|
||||
)
|
||||
|
@ -56,6 +58,8 @@ SET(PartDesignGuiViewProvider_SRCS
|
|||
ViewProviderHole.h
|
||||
ViewProviderPocket.cpp
|
||||
ViewProviderPocket.h
|
||||
ViewProviderFillet.cpp
|
||||
ViewProviderFillet.h
|
||||
ViewProviderRevolution.cpp
|
||||
ViewProviderRevolution.h
|
||||
ViewProviderPatternRectangular.cpp
|
||||
|
@ -76,6 +80,9 @@ SET(PartDesignGuiTaskDlgs_SRCS
|
|||
TaskPocketParameters.ui
|
||||
TaskPocketParameters.cpp
|
||||
TaskPocketParameters.h
|
||||
TaskFilletParameters.ui
|
||||
TaskFilletParameters.cpp
|
||||
TaskFilletParameters.h
|
||||
TaskRevolutionParameters.ui
|
||||
TaskRevolutionParameters.cpp
|
||||
TaskRevolutionParameters.h
|
||||
|
|
|
@ -354,8 +354,7 @@ void CmdPartDesignFillet::activated(int iMsg)
|
|||
doCommand(Doc,"App.activeDocument().addObject(\"PartDesign::Fillet\",\"%s\")",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Base = %s",FeatName.c_str(),SelString.c_str());
|
||||
doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",selection[0].getFeatName());
|
||||
updateActive();
|
||||
commitCommand();
|
||||
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
|
||||
|
||||
copyVisual(FeatName.c_str(), "ShapeColor", selection[0].getFeatName());
|
||||
copyVisual(FeatName.c_str(), "LineColor", selection[0].getFeatName());
|
||||
|
|
|
@ -7,12 +7,14 @@ BUILT_SOURCES=\
|
|||
moc_TaskPadParameters.cpp \
|
||||
moc_TaskPatternRectangularParameters.cpp \
|
||||
moc_TaskPocketParameters.cpp \
|
||||
moc_TaskFilletParameters.cpp \
|
||||
moc_TaskHoleParameters.cpp \
|
||||
moc_TaskRevolutionParameters.cpp \
|
||||
ui_TaskChamfer.h \
|
||||
ui_TaskPadParameters.h \
|
||||
ui_TaskPatternRectangularParameters.h \
|
||||
ui_TaskPocketParameters.h \
|
||||
ui_TaskFilletParameters.h \
|
||||
ui_TaskHoleParameters.h \
|
||||
ui_TaskRevolutionParameters.h
|
||||
|
||||
|
@ -21,6 +23,7 @@ libPartDesignGui_la_UI=\
|
|||
TaskPadParameters.ui \
|
||||
TaskPatternRectangularParameters.ui \
|
||||
TaskPocketParameters.ui \
|
||||
TaskFilletParameters.ui \
|
||||
TaskHoleParameters.ui \
|
||||
TaskRevolutionParameters.ui
|
||||
|
||||
|
@ -37,6 +40,8 @@ libPartDesignGui_la_SOURCES=\
|
|||
TaskPatternRectangularParameters.h \
|
||||
TaskPocketParameters.cpp \
|
||||
TaskPocketParameters.h \
|
||||
TaskFilletParameters.cpp \
|
||||
TaskFilletParameters.h \
|
||||
TaskRevolutionParameters.cpp \
|
||||
TaskRevolutionParameters.h \
|
||||
TaskHoleParameters.cpp \
|
||||
|
@ -49,6 +54,8 @@ libPartDesignGui_la_SOURCES=\
|
|||
ViewProviderPad.h \
|
||||
ViewProviderPocket.cpp \
|
||||
ViewProviderPocket.h \
|
||||
ViewProviderFillet.cpp \
|
||||
ViewProviderFillet.h \
|
||||
ViewProviderRevolution.cpp \
|
||||
ViewProviderRevolution.h \
|
||||
ViewProviderPatternRectangular.cpp \
|
||||
|
|
168
src/Mod/PartDesign/Gui/TaskFilletParameters.cpp
Normal file
168
src/Mod/PartDesign/Gui/TaskFilletParameters.cpp
Normal file
|
@ -0,0 +1,168 @@
|
|||
/***************************************************************************
|
||||
* 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 *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#endif
|
||||
|
||||
#include "ui_TaskFilletParameters.h"
|
||||
#include "TaskFilletParameters.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/FeatureFillet.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
|
||||
|
||||
using namespace PartDesignGui;
|
||||
using namespace Gui;
|
||||
|
||||
/* TRANSLATOR PartDesignGui::TaskFilletParameters */
|
||||
|
||||
TaskFilletParameters::TaskFilletParameters(ViewProviderFillet *FilletView,QWidget *parent)
|
||||
: TaskBox(Gui::BitmapFactory().pixmap("PartDesign_Fillet"),tr("Fillet parameters"),true, parent),FilletView(FilletView)
|
||||
{
|
||||
// we need a separate container widget to add all controls to
|
||||
proxy = new QWidget(this);
|
||||
ui = new Ui_TaskFilletParameters();
|
||||
ui->setupUi(proxy);
|
||||
QMetaObject::connectSlotsByName(this);
|
||||
|
||||
connect(ui->doubleSpinBox, SIGNAL(valueChanged(double)),
|
||||
this, SLOT(onLengthChanged(double)));
|
||||
|
||||
this->groupLayout()->addWidget(proxy);
|
||||
|
||||
PartDesign::Fillet* pcFillet = static_cast<PartDesign::Fillet*>(FilletView->getObject());
|
||||
double r = pcFillet->Radius.getValue();
|
||||
|
||||
ui->doubleSpinBox->setMaximum(INT_MAX);
|
||||
ui->doubleSpinBox->setValue(r);
|
||||
ui->doubleSpinBox->selectAll();
|
||||
|
||||
|
||||
setFocus ();
|
||||
}
|
||||
|
||||
void TaskFilletParameters::onLengthChanged(double len)
|
||||
{
|
||||
PartDesign::Fillet* pcFillet = static_cast<PartDesign::Fillet*>(FilletView->getObject());
|
||||
pcFillet->Radius.setValue((float)len);
|
||||
pcFillet->getDocument()->recomputeFeature(pcFillet);
|
||||
}
|
||||
|
||||
double TaskFilletParameters::getLength(void) const
|
||||
{
|
||||
return ui->doubleSpinBox->value();
|
||||
}
|
||||
|
||||
|
||||
TaskFilletParameters::~TaskFilletParameters()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void TaskFilletParameters::changeEvent(QEvent *e)
|
||||
{
|
||||
TaskBox::changeEvent(e);
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(proxy);
|
||||
}
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
//**************************************************************************
|
||||
// TaskDialog
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
TaskDlgFilletParameters::TaskDlgFilletParameters(ViewProviderFillet *FilletView)
|
||||
: TaskDialog(),FilletView(FilletView)
|
||||
{
|
||||
assert(FilletView);
|
||||
parameter = new TaskFilletParameters(FilletView);
|
||||
|
||||
Content.push_back(parameter);
|
||||
}
|
||||
|
||||
TaskDlgFilletParameters::~TaskDlgFilletParameters()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//==== calls from the TaskView ===============================================================
|
||||
|
||||
|
||||
void TaskDlgFilletParameters::open()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TaskDlgFilletParameters::clicked(int)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool TaskDlgFilletParameters::accept()
|
||||
{
|
||||
std::string name = FilletView->getObject()->getNameInDocument();
|
||||
|
||||
//Gui::Command::openCommand("Fillet changed");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Radius = %f",name.c_str(),parameter->getLength());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
|
||||
Gui::Command::commitCommand();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TaskDlgFilletParameters::reject()
|
||||
{
|
||||
// get the support and Sketch
|
||||
PartDesign::Fillet* pcFillet = static_cast<PartDesign::Fillet*>(FilletView->getObject());
|
||||
App::DocumentObject *pcSupport;
|
||||
pcSupport = pcFillet->Base.getValue();
|
||||
|
||||
// role 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(pcFillet)) {
|
||||
if (pcSupport && Gui::Application::Instance->getViewProvider(pcSupport))
|
||||
Gui::Application::Instance->getViewProvider(pcSupport)->show();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "moc_TaskFilletParameters.cpp"
|
109
src/Mod/PartDesign/Gui/TaskFilletParameters.h
Normal file
109
src/Mod/PartDesign/Gui/TaskFilletParameters.h
Normal file
|
@ -0,0 +1,109 @@
|
|||
/***************************************************************************
|
||||
* 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 <Gui/TaskView/TaskView.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
|
||||
#include "ViewProviderFillet.h"
|
||||
|
||||
class Ui_TaskFilletParameters;
|
||||
|
||||
namespace App {
|
||||
class Property;
|
||||
}
|
||||
|
||||
namespace Gui {
|
||||
class ViewProvider;
|
||||
}
|
||||
|
||||
namespace PartDesignGui {
|
||||
|
||||
|
||||
|
||||
class TaskFilletParameters : public Gui::TaskView::TaskBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskFilletParameters(ViewProviderFillet *FilletView,QWidget *parent = 0);
|
||||
~TaskFilletParameters();
|
||||
|
||||
double getLength(void) const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onLengthChanged(double);
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
QWidget* proxy;
|
||||
Ui_TaskFilletParameters* ui;
|
||||
ViewProviderFillet *FilletView;
|
||||
};
|
||||
|
||||
/// simulation dialog for the TaskView
|
||||
class TaskDlgFilletParameters : public Gui::TaskView::TaskDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskDlgFilletParameters(ViewProviderFillet *FilletView);
|
||||
~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();
|
||||
/// is called by the framework if the user presses the help button
|
||||
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
|
42
src/Mod/PartDesign/Gui/TaskFilletParameters.ui
Normal file
42
src/Mod/PartDesign/Gui/TaskFilletParameters.ui
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PartDesignGui::TaskFilletParameters</class>
|
||||
<widget class="QWidget" name="PartDesignGui::TaskFilletParameters">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>135</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Radius:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox">
|
||||
<property name="minimum">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>999999999.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -44,6 +44,9 @@ ViewProvider::~ViewProvider()
|
|||
|
||||
bool ViewProvider::doubleClicked(void)
|
||||
{
|
||||
std::string Msg("Change ");
|
||||
Msg += this->pcObject->getNameInDocument();
|
||||
Gui::Command::openCommand(Msg.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().setEdit('%s',0)",this->pcObject->getNameInDocument());
|
||||
return true;
|
||||
}
|
||||
|
|
130
src/Mod/PartDesign/Gui/ViewProviderFillet.cpp
Normal file
130
src/Mod/PartDesign/Gui/ViewProviderFillet.cpp
Normal file
|
@ -0,0 +1,130 @@
|
|||
/***************************************************************************
|
||||
* 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 *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#endif
|
||||
|
||||
#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>
|
||||
|
||||
|
||||
using namespace PartDesignGui;
|
||||
|
||||
PROPERTY_SOURCE(PartDesignGui::ViewProviderFillet,PartDesignGui::ViewProvider)
|
||||
|
||||
ViewProviderFillet::ViewProviderFillet()
|
||||
{
|
||||
}
|
||||
|
||||
ViewProviderFillet::~ViewProviderFillet()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void ViewProviderFillet::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
|
||||
{
|
||||
QAction* act;
|
||||
act = menu->addAction(QObject::tr("Edit pocket"), receiver, member);
|
||||
act->setData(QVariant((int)ViewProvider::Default));
|
||||
PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member);
|
||||
}
|
||||
|
||||
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().closeDialog();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
// clear the selection (convenience)
|
||||
Gui::Selection().clearSelection();
|
||||
//if(ModNum == 1)
|
||||
// Gui::Command::openCommand("Change fillet parameters");
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderFillet::unsetEdit(int ModNum)
|
||||
{
|
||||
if (ModNum == ViewProvider::Default ) {
|
||||
// and update the pad
|
||||
//getSketchObject()->getDocument()->recompute();
|
||||
|
||||
// when pressing ESC make sure to close the dialog
|
||||
Gui::Control().closeDialog();
|
||||
}
|
||||
else {
|
||||
PartGui::ViewProviderPart::unsetEdit(ModNum);
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderFillet::onDelete(const std::vector<std::string> &)
|
||||
{
|
||||
// get the support and Sketch
|
||||
PartDesign::Fillet* pcFillet = static_cast<PartDesign::Fillet*>(getObject());
|
||||
App::DocumentObject *pcSupport;
|
||||
if (pcFillet->Base.getValue()){
|
||||
pcSupport = static_cast<Sketcher::SketchObject*>(pcFillet->Base.getValue());
|
||||
}
|
||||
|
||||
// if abort command deleted the object the support is visible again
|
||||
if (pcSupport && Gui::Application::Instance->getViewProvider(pcSupport))
|
||||
Gui::Application::Instance->getViewProvider(pcSupport)->show();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
58
src/Mod/PartDesign/Gui/ViewProviderFillet.h
Normal file
58
src/Mod/PartDesign/Gui/ViewProviderFillet.h
Normal file
|
@ -0,0 +1,58 @@
|
|||
/***************************************************************************
|
||||
* 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 PARTGUI_ViewProviderFillet_H
|
||||
#define PARTGUI_ViewProviderFillet_H
|
||||
|
||||
#include "ViewProvider.h"
|
||||
|
||||
|
||||
namespace PartDesignGui {
|
||||
|
||||
class PartDesignGuiExport ViewProviderFillet : public ViewProvider
|
||||
{
|
||||
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> &);
|
||||
|
||||
protected:
|
||||
virtual bool setEdit(int ModNum);
|
||||
virtual void unsetEdit(int ModNum);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace PartDesignGui
|
||||
|
||||
|
||||
#endif // PARTGUI_ViewProviderFillet_H
|
|
@ -58,13 +58,13 @@ void ViewProviderPad::setupContextMenu(QMenu* menu, QObject* receiver, const cha
|
|||
{
|
||||
QAction* act;
|
||||
act = menu->addAction(QObject::tr("Edit pad"), receiver, member);
|
||||
act->setData(QVariant((int)ViewProvider::Pad));
|
||||
act->setData(QVariant((int)ViewProvider::Default));
|
||||
PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member);
|
||||
}
|
||||
|
||||
bool ViewProviderPad::setEdit(int ModNum)
|
||||
{
|
||||
if (ModNum == ViewProvider::Default || ModNum == ViewProvider::Pad) {
|
||||
if (ModNum == ViewProvider::Default ) {
|
||||
// When double-clicking on the item for this pad the
|
||||
// object unsets and sets its edit mode without closing
|
||||
// the task panel
|
||||
|
@ -87,8 +87,8 @@ bool ViewProviderPad::setEdit(int ModNum)
|
|||
|
||||
// clear the selection (convenience)
|
||||
Gui::Selection().clearSelection();
|
||||
if (ModNum == 1)
|
||||
Gui::Command::openCommand("Change pad parameters");
|
||||
//if (ModNum == 1)
|
||||
// Gui::Command::openCommand("Change pad parameters");
|
||||
|
||||
// start the edit dialog
|
||||
if (padDlg)
|
||||
|
@ -105,7 +105,7 @@ bool ViewProviderPad::setEdit(int ModNum)
|
|||
|
||||
void ViewProviderPad::unsetEdit(int ModNum)
|
||||
{
|
||||
if (ModNum == ViewProvider::Default || ModNum == ViewProvider::Pad) {
|
||||
if (ModNum == ViewProvider::Default) {
|
||||
// and update the pad
|
||||
//getSketchObject()->getDocument()->recompute();
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
using namespace PartDesignGui;
|
||||
|
||||
PROPERTY_SOURCE(PartDesignGui::ViewProviderPocket,PartGui::ViewProviderPart)
|
||||
PROPERTY_SOURCE(PartDesignGui::ViewProviderPocket,PartDesignGui::ViewProvider)
|
||||
|
||||
ViewProviderPocket::ViewProviderPocket()
|
||||
{
|
||||
|
@ -59,13 +59,13 @@ void ViewProviderPocket::setupContextMenu(QMenu* menu, QObject* receiver, const
|
|||
{
|
||||
QAction* act;
|
||||
act = menu->addAction(QObject::tr("Edit pocket"), receiver, member);
|
||||
act->setData(QVariant((int)ViewProvider::Pocket));
|
||||
act->setData(QVariant((int)ViewProvider::Default));
|
||||
PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member);
|
||||
}
|
||||
|
||||
bool ViewProviderPocket::setEdit(int ModNum)
|
||||
{
|
||||
if (ModNum == ViewProvider::Default || ModNum == ViewProvider::Pocket) {
|
||||
if (ModNum == ViewProvider::Default ) {
|
||||
// When double-clicking on the item for this pad the
|
||||
// object unsets and sets its edit mode without closing
|
||||
// the task panel
|
||||
|
@ -88,8 +88,8 @@ bool ViewProviderPocket::setEdit(int ModNum)
|
|||
|
||||
// clear the selection (convenience)
|
||||
Gui::Selection().clearSelection();
|
||||
if(ModNum == 1)
|
||||
Gui::Command::openCommand("Change pocket parameters");
|
||||
//if(ModNum == ViewProvider::Default)
|
||||
// Gui::Command::openCommand("Change pocket parameters");
|
||||
|
||||
// start the edit dialog
|
||||
if (padDlg)
|
||||
|
@ -106,7 +106,7 @@ bool ViewProviderPocket::setEdit(int ModNum)
|
|||
|
||||
void ViewProviderPocket::unsetEdit(int ModNum)
|
||||
{
|
||||
if (ModNum == ViewProvider::Default || ModNum == ViewProvider::Pocket) {
|
||||
if (ModNum == ViewProvider::Default ) {
|
||||
// and update the pad
|
||||
//getSketchObject()->getDocument()->recompute();
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace PartDesignGui {
|
|||
|
||||
class PartDesignGuiExport ViewProviderPocket : public ViewProvider
|
||||
{
|
||||
PROPERTY_HEADER(PartGui::ViewProviderPocket);
|
||||
PROPERTY_HEADER(PartDesignGui::ViewProviderPocket);
|
||||
|
||||
public:
|
||||
/// constructor
|
||||
|
|
|
@ -59,13 +59,13 @@ void ViewProviderRevolution::setupContextMenu(QMenu* menu, QObject* receiver, co
|
|||
{
|
||||
QAction* act;
|
||||
act = menu->addAction(QObject::tr("Edit revolution"), receiver, member);
|
||||
act->setData(QVariant((int)ViewProvider::Revolve));
|
||||
act->setData(QVariant((int)ViewProvider::Default));
|
||||
PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member);
|
||||
}
|
||||
|
||||
bool ViewProviderRevolution::setEdit(int ModNum)
|
||||
{
|
||||
if (ModNum == ViewProvider::Default || ModNum == ViewProvider::Revolve) {
|
||||
if (ModNum == ViewProvider::Default ) {
|
||||
// When double-clicking on the item for this pad the
|
||||
// object unsets and sets its edit mode without closing
|
||||
// the task panel
|
||||
|
@ -88,8 +88,8 @@ bool ViewProviderRevolution::setEdit(int ModNum)
|
|||
|
||||
// clear the selection (convenience)
|
||||
Gui::Selection().clearSelection();
|
||||
if (ModNum == 1)
|
||||
Gui::Command::openCommand("Change revolution parameters");
|
||||
//if (ModNum == 1)
|
||||
// Gui::Command::openCommand("Change revolution parameters");
|
||||
|
||||
// start the edit dialog
|
||||
if (padDlg)
|
||||
|
@ -106,7 +106,7 @@ bool ViewProviderRevolution::setEdit(int ModNum)
|
|||
|
||||
void ViewProviderRevolution::unsetEdit(int ModNum)
|
||||
{
|
||||
if (ModNum == ViewProvider::Default || ModNum == ViewProvider::Revolve) {
|
||||
if (ModNum == ViewProvider::Default) {
|
||||
// and update the pad
|
||||
//getSketchObject()->getDocument()->recompute();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user