+ Gui for Pocket and Revolution
git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5059 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
@@ -26,8 +26,14 @@
|
||||
#ifndef _PreComp_
|
||||
#endif
|
||||
|
||||
#include "ViewProviderRevolution.h"
|
||||
#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 "ViewProviderRevolution.h"
|
||||
#include "TaskRevolutionParameters.h"
|
||||
|
||||
using namespace PartDesignGui;
|
||||
|
||||
@@ -49,4 +55,83 @@ std::vector<App::DocumentObject*> ViewProviderRevolution::claimChildren(void)con
|
||||
return temp;
|
||||
}
|
||||
|
||||
void ViewProviderRevolution::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
|
||||
{
|
||||
QAction* act;
|
||||
act = menu->addAction(QObject::tr("Edit revolution"), receiver, member);
|
||||
act->setData(QVariant((int)ViewProvider::Default));
|
||||
act = menu->addAction(QObject::tr("Transform"), receiver, member);
|
||||
act->setData(QVariant((int)ViewProvider::Transform));
|
||||
}
|
||||
|
||||
bool ViewProviderRevolution::setEdit(int ModNum)
|
||||
{
|
||||
// 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().closeDialog();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
// clear the selection (convenience)
|
||||
Gui::Selection().clearSelection();
|
||||
if(ModNum == 1)
|
||||
Gui::Command::openCommand("Change revolution parameters");
|
||||
|
||||
// start the edit dialog
|
||||
if (padDlg)
|
||||
Gui::Control().showDialog(padDlg);
|
||||
else
|
||||
Gui::Control().showDialog(new TaskDlgRevolutionParameters(this));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ViewProviderRevolution::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 ViewProviderRevolution::onDelete(const std::vector<std::string> &)
|
||||
{
|
||||
// get the support and Sketch
|
||||
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(getObject());
|
||||
Sketcher::SketchObject *pcSketch;
|
||||
App::DocumentObject *pcSupport;
|
||||
if (pcRevolution->Sketch.getValue()){
|
||||
pcSketch = static_cast<Sketcher::SketchObject*>(pcRevolution->Sketch.getValue());
|
||||
pcSupport = pcSketch->Support.getValue();
|
||||
}
|
||||
|
||||
// if abort command deleted the object the support is visible again
|
||||
if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch))
|
||||
Gui::Application::Instance->getViewProvider(pcSketch)->show();
|
||||
if (pcSupport && Gui::Application::Instance->getViewProvider(pcSupport))
|
||||
Gui::Application::Instance->getViewProvider(pcSupport)->show();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user