Gui: make Clipping widget a dockable widget so that it can be used while a task dialog is open
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
# include <Inventor/nodes/SoClipPlane.h>
|
||||
# include <Inventor/nodes/SoGroup.h>
|
||||
# include <Inventor/sensors/SoTimerSensor.h>
|
||||
# include <QDockWidget>
|
||||
# include <QPointer>
|
||||
# include <cmath>
|
||||
#endif
|
||||
@@ -34,6 +35,7 @@
|
||||
#include "Clipping.h"
|
||||
#include "ui_Clipping.h"
|
||||
#include "Application.h"
|
||||
#include "DockWindowManager.h"
|
||||
#include "View3DInventor.h"
|
||||
#include "View3DInventorViewer.h"
|
||||
|
||||
@@ -101,7 +103,8 @@ public:
|
||||
/* TRANSLATOR Gui::Dialog::Clipping */
|
||||
|
||||
Clipping::Clipping(Gui::View3DInventor* view, QWidget* parent)
|
||||
: QWidget(parent), d(new Private)
|
||||
: QDialog(parent)
|
||||
, d(new Private)
|
||||
{
|
||||
// create widgets
|
||||
d->ui.setupUi(this);
|
||||
@@ -183,6 +186,18 @@ Clipping::Clipping(Gui::View3DInventor* view, QWidget* parent)
|
||||
}
|
||||
}
|
||||
|
||||
Clipping* Clipping::makeDockWidget(Gui::View3DInventor* view)
|
||||
{
|
||||
// embed this dialog into a QDockWidget
|
||||
Clipping* clipping = new Clipping(view);
|
||||
Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance();
|
||||
QDockWidget* dw = pDockMgr->addDockWindow("Clipping", clipping, Qt::LeftDockWidgetArea);
|
||||
dw->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable);
|
||||
dw->show();
|
||||
|
||||
return clipping;
|
||||
}
|
||||
|
||||
/** Destroys the object and frees any allocated resources */
|
||||
Clipping::~Clipping()
|
||||
{
|
||||
@@ -194,6 +209,15 @@ Clipping::~Clipping()
|
||||
delete d;
|
||||
}
|
||||
|
||||
void Clipping::reject()
|
||||
{
|
||||
QDialog::reject();
|
||||
QDockWidget* dw = qobject_cast<QDockWidget*>(parent());
|
||||
if (dw) {
|
||||
dw->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
void Clipping::on_groupBoxX_toggled(bool on)
|
||||
{
|
||||
if (on) {
|
||||
@@ -336,22 +360,4 @@ void Clipping::on_dirZ_valueChanged(double)
|
||||
d->clipView->plane.setValue(SbPlane(normal,pln.getDistanceFromOrigin()));
|
||||
}
|
||||
|
||||
// ---------------------------------------
|
||||
|
||||
/* TRANSLATOR Gui::Dialog::TaskClipping */
|
||||
|
||||
TaskClipping::TaskClipping(Gui::View3DInventor* view)
|
||||
{
|
||||
QWidget* widget = new Clipping(view);
|
||||
Gui::TaskView::TaskBox* taskbox = new Gui::TaskView::TaskBox(
|
||||
QPixmap(), widget->windowTitle(), false, 0);
|
||||
taskbox->groupLayout()->addWidget(widget);
|
||||
Content.push_back(taskbox);
|
||||
}
|
||||
|
||||
TaskClipping::~TaskClipping()
|
||||
{
|
||||
// automatically deleted in the sub-class
|
||||
}
|
||||
|
||||
#include "moc_Clipping.cpp"
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
#ifndef GUI_DIALOG_CLIPPING_H
|
||||
#define GUI_DIALOG_CLIPPING_H
|
||||
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
#include <QWidget>
|
||||
#include <QDialog>
|
||||
|
||||
namespace Gui {
|
||||
class View3DInventor;
|
||||
@@ -35,12 +33,13 @@ namespace Dialog {
|
||||
/**
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class GuiExport Clipping : public QWidget
|
||||
class GuiExport Clipping : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Clipping(Gui::View3DInventor* view, QWidget* parent = 0);
|
||||
static Clipping* makeDockWidget(Gui::View3DInventor*);
|
||||
Clipping(Gui::View3DInventor* view, QWidget* parent = nullptr);
|
||||
~Clipping();
|
||||
|
||||
protected Q_SLOTS:
|
||||
@@ -61,27 +60,14 @@ protected Q_SLOTS:
|
||||
void on_dirY_valueChanged(double);
|
||||
void on_dirZ_valueChanged(double);
|
||||
|
||||
private:
|
||||
public:
|
||||
void reject();
|
||||
|
||||
private:
|
||||
class Private;
|
||||
Private* d;
|
||||
};
|
||||
|
||||
/**
|
||||
* Embed the panel into a task dialog.
|
||||
*/
|
||||
class TaskClipping : public Gui::TaskView::TaskDialog
|
||||
{
|
||||
public:
|
||||
TaskClipping(Gui::View3DInventor* view);
|
||||
~TaskClipping();
|
||||
|
||||
public:
|
||||
virtual QDialogButtonBox::StandardButtons getStandardButtons() const
|
||||
{ return QDialogButtonBox::Close; }
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Gui::Dialog::Clipping</class>
|
||||
<widget class="QWidget" name="Gui::Dialog::Clipping">
|
||||
<widget class="QDialog" name="Gui::Dialog::Clipping">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@@ -219,6 +219,16 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
@@ -240,5 +250,22 @@
|
||||
<tabstop>dirZ</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>Gui::Dialog::Clipping</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
||||
@@ -529,9 +529,12 @@ void StdCmdToggleClipPlane::activated(int iMsg)
|
||||
view->toggleClippingPlane();
|
||||
}
|
||||
#else
|
||||
View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
|
||||
if (view) {
|
||||
Gui::Control().showDialog(new Gui::Dialog::TaskClipping(view));
|
||||
static QPointer<Gui::Dialog::Clipping> clipping = nullptr;
|
||||
if (!clipping) {
|
||||
View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
|
||||
if (view) {
|
||||
clipping = Gui::Dialog::Clipping::makeDockWidget(view);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -553,9 +556,8 @@ bool StdCmdToggleClipPlane::isActive(void)
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
if (Gui::Control().activeDialog())
|
||||
return false;
|
||||
return true;
|
||||
View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
|
||||
return view ? true : false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user