PartDesign/Gui: share code for revolution and groove view providers
This commit is contained in:
committed by
Stefan Tröger
parent
5ee0cea467
commit
013381ccb6
@@ -26,41 +26,25 @@
|
||||
#ifndef _PreComp_
|
||||
# include <QAction>
|
||||
# include <QMenu>
|
||||
# include <QMessageBox>
|
||||
#endif
|
||||
|
||||
#include <Mod/PartDesign/App/FeatureRevolution.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Application.h>
|
||||
#include "TaskRevolutionParameters.h"
|
||||
|
||||
#include "ViewProviderRevolution.h"
|
||||
#include "TaskRevolutionParameters.h"
|
||||
|
||||
using namespace PartDesignGui;
|
||||
|
||||
PROPERTY_SOURCE(PartDesignGui::ViewProviderRevolution,PartDesignGui::ViewProvider)
|
||||
PROPERTY_SOURCE(PartDesignGui::ViewProviderRevolution,PartDesignGui::ViewProviderSketchBased)
|
||||
|
||||
ViewProviderRevolution::ViewProviderRevolution()
|
||||
{
|
||||
sPixmap = "Tree_PartDesign_Revolution.svg";
|
||||
sPixmap = "Tree_PartDesign_Revolution.svg";
|
||||
}
|
||||
|
||||
ViewProviderRevolution::~ViewProviderRevolution()
|
||||
{
|
||||
}
|
||||
|
||||
std::vector<App::DocumentObject*> ViewProviderRevolution::claimChildren(void)const
|
||||
{
|
||||
std::vector<App::DocumentObject*> temp;
|
||||
App::DocumentObject* sketch = static_cast<PartDesign::Revolution*>(getObject())->Sketch.getValue();
|
||||
if (sketch != NULL)
|
||||
temp.push_back(sketch);
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
void ViewProviderRevolution::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
|
||||
{
|
||||
QAction* act;
|
||||
@@ -69,71 +53,7 @@ void ViewProviderRevolution::setupContextMenu(QMenu* menu, QObject* receiver, co
|
||||
PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member);
|
||||
}
|
||||
|
||||
bool ViewProviderRevolution::setEdit(int ModNum)
|
||||
TaskDlgFeatureParameters *ViewProviderRevolution::getEditDialog()
|
||||
{
|
||||
if (ModNum == ViewProvider::Default ) {
|
||||
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(getObject());
|
||||
if (pcRevolution->getSketchAxisCount() < 0) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setWindowTitle(QObject::tr("Lost link to base sketch"));
|
||||
msgBox.setText(QObject::tr("The object can't be edited because the link to the the base sketch is lost."));
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.exec();
|
||||
return false;
|
||||
}
|
||||
// When double-clicking on the item for this pad the
|
||||
// object unsets and sets its edit mode without closing
|
||||
// the task panel
|
||||
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
|
||||
TaskDlgRevolutionParameters *padDlg = qobject_cast<TaskDlgRevolutionParameters *>(dlg);
|
||||
if (padDlg && padDlg->getRevolutionView() != 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();
|
||||
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 TaskDlgRevolutionParameters(this));
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return PartGui::ViewProviderPart::setEdit(ModNum);
|
||||
}
|
||||
return new TaskDlgRevolutionParameters( this );
|
||||
}
|
||||
|
||||
bool ViewProviderRevolution::onDelete(const std::vector<std::string> &s)
|
||||
{
|
||||
// get the Sketch
|
||||
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(getObject());
|
||||
Sketcher::SketchObject *pcSketch = 0;
|
||||
if (pcRevolution->Sketch.getValue())
|
||||
pcSketch = static_cast<Sketcher::SketchObject*>(pcRevolution->Sketch.getValue());
|
||||
|
||||
// if abort command deleted the object the Sketch is visible again
|
||||
if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch))
|
||||
Gui::Application::Instance->getViewProvider(pcSketch)->show();
|
||||
|
||||
return ViewProvider::onDelete(s);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user