All: Reformat according to new standard
This commit is contained in:
committed by
Kacper Donat
parent
eafd18dac0
commit
25c3ba7338
@@ -21,16 +21,15 @@
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
|
||||
# include <boost/core/ignore_unused.hpp>
|
||||
# include <Inventor/actions/SoGetBoundingBoxAction.h>
|
||||
# include <Inventor/actions/SoGLRenderAction.h>
|
||||
# include <Inventor/events/SoMouseButtonEvent.h>
|
||||
# include <Inventor/nodes/SoEventCallback.h>
|
||||
# include <Inventor/nodes/SoOrthographicCamera.h>
|
||||
# include <Inventor/nodes/SoSwitch.h>
|
||||
# include <QApplication>
|
||||
# include <QMenu>
|
||||
#include <boost/core/ignore_unused.hpp>
|
||||
#include <Inventor/actions/SoGetBoundingBoxAction.h>
|
||||
#include <Inventor/actions/SoGLRenderAction.h>
|
||||
#include <Inventor/events/SoMouseButtonEvent.h>
|
||||
#include <Inventor/nodes/SoEventCallback.h>
|
||||
#include <Inventor/nodes/SoOrthographicCamera.h>
|
||||
#include <Inventor/nodes/SoSwitch.h>
|
||||
#include <QApplication>
|
||||
#include <QMenu>
|
||||
|
||||
|
||||
#include "SoFCColorBar.h"
|
||||
@@ -45,7 +44,8 @@ SO_NODE_ABSTRACT_SOURCE(SoFCColorBarBase)
|
||||
/*!
|
||||
Constructor.
|
||||
*/
|
||||
SoFCColorBarBase::SoFCColorBarBase() : _windowSize(0,0)
|
||||
SoFCColorBarBase::SoFCColorBarBase()
|
||||
: _windowSize(0, 0)
|
||||
{
|
||||
SO_NODE_CONSTRUCTOR(SoFCColorBarBase);
|
||||
}
|
||||
@@ -58,7 +58,7 @@ SoFCColorBarBase::~SoFCColorBarBase() = default;
|
||||
// doc from parent
|
||||
void SoFCColorBarBase::initClass()
|
||||
{
|
||||
SO_NODE_INIT_ABSTRACT_CLASS(SoFCColorBarBase,SoSeparator,"Separator");
|
||||
SO_NODE_INIT_ABSTRACT_CLASS(SoFCColorBarBase, SoSeparator, "Separator");
|
||||
}
|
||||
|
||||
void SoFCColorBarBase::finish()
|
||||
@@ -66,10 +66,10 @@ void SoFCColorBarBase::finish()
|
||||
atexit_cleanup();
|
||||
}
|
||||
|
||||
void SoFCColorBarBase::GLRenderBelowPath(SoGLRenderAction * action)
|
||||
void SoFCColorBarBase::GLRenderBelowPath(SoGLRenderAction* action)
|
||||
{
|
||||
const SbViewportRegion& vp = action->getViewportRegion();
|
||||
const SbVec2s& size = vp.getWindowSize();
|
||||
const SbVec2s& size = vp.getWindowSize();
|
||||
if (_windowSize != size) {
|
||||
_windowSize = size;
|
||||
setViewportSize(size);
|
||||
@@ -107,8 +107,8 @@ float SoFCColorBarBase::getBoundingWidth(const SbVec2s& size)
|
||||
|
||||
// These are the same camera settings for front nodes as defined in the 3d view
|
||||
auto cam = new SoOrthographicCamera;
|
||||
cam->position = SbVec3f(0, 0, 5); // the 5 is just a value > 0
|
||||
cam->height = 10; // sets the coordinate range of the screen to [-5, +5]
|
||||
cam->position = SbVec3f(0, 0, 5); // the 5 is just a value > 0
|
||||
cam->height = 10; // sets the coordinate range of the screen to [-5, +5]
|
||||
cam->nearDistance = 0;
|
||||
cam->farDistance = 10;
|
||||
|
||||
@@ -130,7 +130,7 @@ float SoFCColorBarBase::getBoundingWidth(const SbVec2s& size)
|
||||
return boxWidth;
|
||||
}
|
||||
|
||||
float SoFCColorBarBase::getBounds(const SbVec2s& size, float& fMinX, float&fMinY, float& fMaxX, float& fMaxY)
|
||||
float SoFCColorBarBase::getBounds(const SbVec2s& size, float& fMinX, float& fMinY, float& fMaxX, float& fMaxY)
|
||||
{
|
||||
// ratio of window width / height
|
||||
float fRatio = static_cast<float>(size[0]) / static_cast<float>(size[1]);
|
||||
@@ -151,11 +151,11 @@ float SoFCColorBarBase::getBounds(const SbVec2s& size, float& fMinX, float&fMinY
|
||||
float barWidth = 0.5f;
|
||||
|
||||
// we want the color bar at the rightmost position, therefore we take 4.95 as base
|
||||
fMinX = 4.95f * fRatio; // must be scaled with the ratio to assure it stays at the right
|
||||
fMinX = 4.95f * fRatio; // must be scaled with the ratio to assure it stays at the right
|
||||
|
||||
fMaxX = fMinX + barWidth;
|
||||
fMinY = -baseYValue - 0.6f; // Extend shortened bar towards axis cross
|
||||
fMaxY = baseYValue; // bar has the height of almost whole window height
|
||||
fMinY = -baseYValue - 0.6f; // Extend shortened bar towards axis cross
|
||||
fMaxY = baseYValue; // bar has the height of almost whole window height
|
||||
|
||||
if (fRatio < 1.0f) {
|
||||
// must be adjusted to assure that the size of the bar doesn't shrink
|
||||
@@ -172,15 +172,18 @@ float SoFCColorBarBase::getBounds(const SbVec2s& size, float& fMinX, float&fMinY
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
namespace Gui {
|
||||
namespace Gui
|
||||
{
|
||||
// Proxy class that receives an asynchronous custom event
|
||||
class SoFCColorBarProxyObject : public QObject
|
||||
class SoFCColorBarProxyObject: public QObject
|
||||
{
|
||||
public:
|
||||
explicit SoFCColorBarProxyObject(SoFCColorBar* b)
|
||||
: QObject(nullptr), bar(b) {}
|
||||
: QObject(nullptr)
|
||||
, bar(b)
|
||||
{}
|
||||
~SoFCColorBarProxyObject() override = default;
|
||||
void customEvent(QEvent *) override
|
||||
void customEvent(QEvent*) override
|
||||
{
|
||||
bar->customize(bar->getActiveBar());
|
||||
this->deleteLater();
|
||||
@@ -189,7 +192,7 @@ public:
|
||||
private:
|
||||
SoFCColorBar* bar;
|
||||
};
|
||||
}
|
||||
} // namespace Gui
|
||||
|
||||
SO_NODE_SOURCE(SoFCColorBar)
|
||||
|
||||
@@ -200,18 +203,19 @@ SoFCColorBar::SoFCColorBar()
|
||||
{
|
||||
SO_NODE_CONSTRUCTOR(SoFCColorBar);
|
||||
|
||||
// SoEventCallback * cb = new SoEventCallback;
|
||||
// cb->addEventCallback(SoMouseButtonEvent::getClassTypeId(), eventCallback, this);
|
||||
// insertChild(cb, 0);
|
||||
// SoEventCallback * cb = new SoEventCallback;
|
||||
// cb->addEventCallback(SoMouseButtonEvent::getClassTypeId(), eventCallback, this);
|
||||
// insertChild(cb, 0);
|
||||
|
||||
pColorMode = new SoSwitch;
|
||||
addChild(pColorMode);
|
||||
|
||||
_colorBars.push_back( new SoFCColorGradient );
|
||||
_colorBars.push_back( new SoFCColorLegend );
|
||||
_colorBars.push_back(new SoFCColorGradient);
|
||||
_colorBars.push_back(new SoFCColorLegend);
|
||||
|
||||
for (auto it : _colorBars)
|
||||
for (auto it : _colorBars) {
|
||||
pColorMode->addChild(it);
|
||||
}
|
||||
pColorMode->whichChild = 0;
|
||||
}
|
||||
|
||||
@@ -223,7 +227,7 @@ SoFCColorBar::~SoFCColorBar() = default;
|
||||
// doc from parent
|
||||
void SoFCColorBar::initClass()
|
||||
{
|
||||
SO_NODE_INIT_CLASS(SoFCColorBar,SoFCColorBarBase,"Separator");
|
||||
SO_NODE_INIT_CLASS(SoFCColorBar, SoFCColorBarBase, "Separator");
|
||||
}
|
||||
|
||||
void SoFCColorBar::finish()
|
||||
@@ -239,38 +243,41 @@ SoFCColorBarBase* SoFCColorBar::getActiveBar() const
|
||||
|
||||
void SoFCColorBar::setFormat(const SoLabelTextFormat& fmt)
|
||||
{
|
||||
for (auto it : _colorBars)
|
||||
for (auto it : _colorBars) {
|
||||
it->setFormat(fmt);
|
||||
}
|
||||
}
|
||||
|
||||
void SoFCColorBar::setViewportSize( const SbVec2s& size )
|
||||
void SoFCColorBar::setViewportSize(const SbVec2s& size)
|
||||
{
|
||||
boost::ignore_unused(size);
|
||||
}
|
||||
|
||||
void SoFCColorBar::setRange( float fMin, float fMax, int prec )
|
||||
void SoFCColorBar::setRange(float fMin, float fMax, int prec)
|
||||
{
|
||||
for (auto it : _colorBars)
|
||||
for (auto it : _colorBars) {
|
||||
it->setRange(fMin, fMax, prec);
|
||||
}
|
||||
}
|
||||
|
||||
void SoFCColorBar::setOutsideGrayed (bool bVal)
|
||||
void SoFCColorBar::setOutsideGrayed(bool bVal)
|
||||
{
|
||||
for (auto it : _colorBars)
|
||||
for (auto it : _colorBars) {
|
||||
it->setOutsideGrayed(bVal);
|
||||
}
|
||||
}
|
||||
|
||||
bool SoFCColorBar::isVisible (float fVal) const
|
||||
bool SoFCColorBar::isVisible(float fVal) const
|
||||
{
|
||||
return this->getActiveBar()->isVisible(fVal);
|
||||
}
|
||||
|
||||
float SoFCColorBar::getMinValue () const
|
||||
float SoFCColorBar::getMinValue() const
|
||||
{
|
||||
return this->getActiveBar()->getMinValue();
|
||||
}
|
||||
|
||||
float SoFCColorBar::getMaxValue () const
|
||||
float SoFCColorBar::getMaxValue() const
|
||||
{
|
||||
return this->getActiveBar()->getMaxValue();
|
||||
}
|
||||
@@ -290,14 +297,14 @@ void SoFCColorBar::customize(SoFCColorBarBase* child)
|
||||
}
|
||||
}
|
||||
|
||||
Base::Color SoFCColorBar::getColor( float fVal ) const
|
||||
Base::Color SoFCColorBar::getColor(float fVal) const
|
||||
{
|
||||
return this->getActiveBar()->getColor( fVal );
|
||||
return this->getActiveBar()->getColor(fVal);
|
||||
}
|
||||
|
||||
void SoFCColorBar::eventCallback(void * /*userdata*/, SoEventCallback * node)
|
||||
void SoFCColorBar::eventCallback(void* /*userdata*/, SoEventCallback* node)
|
||||
{
|
||||
const SoEvent * event = node->getEvent();
|
||||
const SoEvent* event = node->getEvent();
|
||||
if (event->getTypeId().isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) {
|
||||
const auto e = static_cast<const SoMouseButtonEvent*>(event);
|
||||
if ((e->getButton() == SoMouseButtonEvent::BUTTON2)) {
|
||||
@@ -308,17 +315,18 @@ void SoFCColorBar::eventCallback(void * /*userdata*/, SoEventCallback * node)
|
||||
}
|
||||
}
|
||||
|
||||
void SoFCColorBar::handleEvent (SoHandleEventAction *action)
|
||||
void SoFCColorBar::handleEvent(SoHandleEventAction* action)
|
||||
{
|
||||
const SoEvent * event = action->getEvent();
|
||||
const SoEvent* event = action->getEvent();
|
||||
|
||||
// check for mouse button events
|
||||
if (event->getTypeId().isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) {
|
||||
const auto e = static_cast<const SoMouseButtonEvent*>(event);
|
||||
|
||||
// check if the cursor is near to the color bar
|
||||
if (!action->getPickedPoint())
|
||||
return; // not inside the rectangle
|
||||
if (!action->getPickedPoint()) {
|
||||
return; // not inside the rectangle
|
||||
}
|
||||
|
||||
// left mouse pressed
|
||||
action->setHandled();
|
||||
@@ -329,9 +337,7 @@ void SoFCColorBar::handleEvent (SoHandleEventAction *action)
|
||||
_timer.start();
|
||||
}
|
||||
else if (_timer.restart() < QApplication::doubleClickInterval()) {
|
||||
QApplication::postEvent(
|
||||
new SoFCColorBarProxyObject(this),
|
||||
new QEvent(QEvent::User));
|
||||
QApplication::postEvent(new SoFCColorBarProxyObject(this), new QEvent(QEvent::User));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -340,7 +346,7 @@ void SoFCColorBar::handleEvent (SoHandleEventAction *action)
|
||||
if (e->getState() == SoButtonEvent::UP) {
|
||||
SoFCColorBarBase* current = getActiveBar();
|
||||
QMenu menu;
|
||||
int i=0;
|
||||
int i = 0;
|
||||
for (auto it : _colorBars) {
|
||||
QAction* item = menu.addAction(QObject::tr(it->getColorBarName()));
|
||||
item->setCheckable(true);
|
||||
@@ -353,9 +359,7 @@ void SoFCColorBar::handleEvent (SoHandleEventAction *action)
|
||||
QAction* select = menu.exec(QCursor::pos());
|
||||
|
||||
if (select == option) {
|
||||
QApplication::postEvent(
|
||||
new SoFCColorBarProxyObject(this),
|
||||
new QEvent(QEvent::User));
|
||||
QApplication::postEvent(new SoFCColorBarProxyObject(this), new QEvent(QEvent::User));
|
||||
}
|
||||
else if (select) {
|
||||
int id = select->data().toInt();
|
||||
|
||||
Reference in New Issue
Block a user