Commit 48da4f4d authored by Marc R.'s avatar Marc R.

Merge branch '202-loading-bounding-box-on-program-start-does-not-work-correctly' into 'master'

Resolve "Simplify creating new bounding box actor"

Closes #202

See merge request !192
parents a36196fe 145e7815
......@@ -56,17 +56,13 @@ namespace Met3D
MBaseMapActor::MBaseMapActor()
: MRotatedGridSupportingActor(),
MBoundingBoxInterface(this),
MBoundingBoxInterface(this, MBoundingBoxConnectionType::HORIZONTAL),
texture(nullptr),
numVertices(4),
colourSaturation(0.3)
{
GDALAllRegister();
bBoxConnection = new MBoundingBoxConnection(
this, MBoundingBoxConnection::HORIZONTAL);
// Create and initialise QtProperties for the GUI.
// ===============================================
beginInitialiseQtProperties();
......@@ -83,7 +79,7 @@ MBaseMapActor::MBaseMapActor()
filenameProperty->setEnabled(false);
// Bounding box of the actor.
actorPropertiesSupGroup->addSubProperty(bBoxConnection->getProperty());
insertBoundingBoxProperty(actorPropertiesSupGroup);
colourSaturationProperty = addProperty(DECORATEDDOUBLE_PROPERTY,
"colour saturation",
......
......@@ -50,7 +50,8 @@ namespace Met3D
MGraticuleActor::MGraticuleActor(MBoundingBoxConnection *boundingBoxConnection)
: MRotatedGridSupportingActor(),
MBoundingBoxInterface(this),
MBoundingBoxInterface(this, MBoundingBoxConnectionType::HORIZONTAL,
boundingBoxConnection),
graticuleVertexBuffer(nullptr),
numVerticesGraticule(0),
coastlineVertexBuffer(nullptr),
......@@ -64,18 +65,6 @@ MGraticuleActor::MGraticuleActor(MBoundingBoxConnection *boundingBoxConnection)
naturalEarthDataLoader = MSystemManagerAndControl::getInstance()
->getNaturalEarthDataLoader();
// Use boundingBoxActor of horizontal cross section actor if graticule is
// part of it.
this->bBoxConnection = boundingBoxConnection;
// Created graticule actor as standalone actor and thus it needs its own
// bounding box actor. (As part of 2D Horizontal Cross-Section it uses
// the bounding box connected to the Horizontal Cross-Section.)
if (boundingBoxConnection == nullptr)
{
this->bBoxConnection = new MBoundingBoxConnection(
this, MBoundingBoxConnection::HORIZONTAL);
}
nLats.clear();
nLats.append(0);
nLons.clear();
......@@ -92,8 +81,10 @@ MGraticuleActor::MGraticuleActor(MBoundingBoxConnection *boundingBoxConnection)
// section.
if (boundingBoxConnection == nullptr)
{
actorPropertiesSupGroup->addSubProperty(
this->bBoxConnection->getProperty());
// Created graticule actor as standalone actor and thus it needs its
// own bounding box actor. (As part of e.g. 2D Horizontal Cross-Section
// it uses the bounding box connected to the Horizontal Cross-Section.)
insertBoundingBoxProperty(actorPropertiesSupGroup);
}
spacingProperty = addProperty(POINTF_LONLAT_PROPERTY, "spacing",
......
......@@ -57,7 +57,7 @@ namespace Met3D
MNWPHorizontalSectionActor::MNWPHorizontalSectionActor()
: MNWPMultiVarActor(),
MBoundingBoxInterface(this),
MBoundingBoxInterface(this, MBoundingBoxConnectionType::HORIZONTAL),
slicePosition_hPa(250.),
slicePositionGranularity_hPa(5.0),
slicePosSynchronizationActor(nullptr),
......@@ -73,8 +73,6 @@ MNWPHorizontalSectionActor::MNWPHorizontalSectionActor()
offsetPickPositionToHandleCentre(QVector2D(0., 0.))
{
enablePicking(true);
bBoxConnection =
new MBoundingBoxConnection(this, MBoundingBoxConnection::HORIZONTAL);
// Create and initialise QtProperties for the GUI.
// ===============================================
......@@ -120,7 +118,7 @@ MNWPHorizontalSectionActor::MNWPHorizontalSectionActor()
properties->mEnum()->setEnumNames(differenceModeProperty, differenceModeNames);
// Horizontal bounding box of the actor.
actorPropertiesSupGroup->addSubProperty(bBoxConnection->getProperty());
insertBoundingBoxProperty(actorPropertiesSupGroup);
// Wind barbs.
vectorGlyphsSettings = new VectorGlyphsSettings(this);
......
......@@ -53,14 +53,11 @@ namespace Met3D
MNWPSurfaceTopographyActor::MNWPSurfaceTopographyActor()
: MNWPMultiVarActor(),
MBoundingBoxInterface(this),
MBoundingBoxInterface(this, MBoundingBoxConnectionType::HORIZONTAL),
topographyVariableIndex(0),
shadingVariableIndex(0),
updateRenderRegion(false)
{
bBoxConnection = new MBoundingBoxConnection(
this, MBoundingBoxConnection::HORIZONTAL);
// Create and initialise QtProperties for the GUI.
// ===============================================
beginInitialiseQtProperties();
......@@ -75,7 +72,7 @@ MNWPSurfaceTopographyActor::MNWPSurfaceTopographyActor()
actorPropertiesSupGroup);
// Bounding box of the actor.
actorPropertiesSupGroup->addSubProperty(bBoxConnection->getProperty());
insertBoundingBoxProperty(actorPropertiesSupGroup);
endInitialiseQtProperties();
}
......
......@@ -54,7 +54,7 @@ namespace Met3D
MNWPVerticalSectionActor::MNWPVerticalSectionActor()
: MNWPMultiVarActor(),
MBoundingBoxInterface(this),
MBoundingBoxInterface(this, MBoundingBoxConnectionType::VERTICAL),
labelDistance(1),
waypointsModel(nullptr),
modifyWaypoint(-1),
......@@ -74,8 +74,6 @@ MNWPVerticalSectionActor::MNWPVerticalSectionActor()
updatePath(false),
offsetPickPositionToHandleCentre(QVector2D(0., 0.))
{
bBoxConnection =
new MBoundingBoxConnection(this, MBoundingBoxConnection::VERTICAL);
enablePicking(true);
// Create and initialise QtProperties for the GUI.
......@@ -107,7 +105,8 @@ MNWPVerticalSectionActor::MNWPVerticalSectionActor()
enableActorUpdates(true);
}
actorPropertiesSupGroup->addSubProperty(bBoxConnection->getProperty());
// Bounding box of the actor.
insertBoundingBoxProperty(actorPropertiesSupGroup);
QString defaultPressureLineLevel = QString("1000.,900.,800.,700.,600.,500.")
+ QString(",400.,300.,200.,100.,90.,80.")
......
......@@ -57,7 +57,7 @@ namespace Met3D
MNWPVolumeRaycasterActor::MNWPVolumeRaycasterActor()
: MNWPMultiVarActor(),
MBoundingBoxInterface(this),
MBoundingBoxInterface(this, MBoundingBoxConnectionType::VOLUME),
updateNextRenderFrame("111"),
renderMode(RenderMode::Original),
variableIndex(0),
......@@ -68,8 +68,6 @@ MNWPVolumeRaycasterActor::MNWPVolumeRaycasterActor()
bBoxEnabled(true),
normalCurveNumVertices(0)
{
bBoxConnection =
new MBoundingBoxConnection(this, MBoundingBoxConnection::VOLUME);
// Enable picking for the scene view's analysis mode. See
// triggerAnalysisOfObjectAtPos().
enablePicking(true);
......@@ -98,8 +96,8 @@ MNWPVolumeRaycasterActor::MNWPVolumeRaycasterActor()
rayCasterSettings = new RayCasterSettings(this);
actorPropertiesSupGroup->addSubProperty(rayCasterSettings->groupProp);
// Bounding box.
actorPropertiesSupGroup->addSubProperty(bBoxConnection->getProperty());
// Bounding box of the actor.
insertBoundingBoxProperty(actorPropertiesSupGroup);
bBoxEnabledProperty = addProperty(
BOOL_PROPERTY, "draw bounding box", actorPropertiesSupGroup);
properties->mBool()->setValue(bBoxEnabledProperty, bBoxEnabled);
......
......@@ -5,7 +5,7 @@
** prediction data.
**
** Copyright 2015-2018 Marc Rautenhaus
** Copyright 2016-2017 Bianca Tost
** Copyright 2016-2018 Bianca Tost
** Copyright 2017 Philipp Kaiser
**
** Computer Graphics and Visualization Group
......@@ -63,7 +63,7 @@ namespace Met3D
MTrajectoryActor::MTrajectoryActor()
: MActor(),
MBoundingBoxInterface(this),
MBoundingBoxInterface(this, MBoundingBoxConnectionType::HORIZONTAL),
trajectorySource(nullptr),
normalsSource(nullptr),
trajectoryFilter(nullptr),
......@@ -83,9 +83,6 @@ MTrajectoryActor::MTrajectoryActor()
shadowEnabled(true),
shadowColoured(false)
{
bBoxConnection =
new MBoundingBoxConnection(this, MBoundingBoxConnection::HORIZONTAL);
// Create and initialise QtProperties for the GUI.
// ===============================================
beginInitialiseQtProperties();
......@@ -241,8 +238,8 @@ MTrajectoryActor::MTrajectoryActor()
GROUP_PROPERTY, "trajectory filters",
actorPropertiesSupGroup);
// Bounding box.
filtersGroupProperty->addSubProperty(bBoxConnection->getProperty());
// Bounding box of the actor.
insertBoundingBoxProperty(actorPropertiesSupGroup);
// Ascent (dp/dt > x).
enableAscentFilterProperty = addProperty(
......
......@@ -49,14 +49,12 @@ namespace Met3D
MVolumeBoundingBoxActor::MVolumeBoundingBoxActor()
: MActor(),
MBoundingBoxInterface(this),
MBoundingBoxInterface(this, MBoundingBoxConnectionType::VOLUME),
coordinateVertexBuffer(nullptr),
axisVertexBuffer(nullptr),
tickLength(0.8),
lineColour(QColor(0, 104, 139, 255))
{
bBoxConnection =
new MBoundingBoxConnection(this, MBoundingBoxConnection::VOLUME);
// Create and initialise QtProperties for the GUI.
// ===============================================
beginInitialiseQtProperties();
......@@ -65,7 +63,7 @@ MVolumeBoundingBoxActor::MVolumeBoundingBoxActor()
setName(getActorType());
// Bounding box of the actor.
actorPropertiesSupGroup->addSubProperty(bBoxConnection->getProperty());
insertBoundingBoxProperty(actorPropertiesSupGroup);
tickLengthProperty = addProperty(DECORATEDDOUBLE_PROPERTY,
"tick length",
......
......@@ -187,9 +187,20 @@ void MBoundingBox::emitPressureLevelChanged()
*** CONSTRUCTOR / DESTRUCTOR ***
*******************************************************************************/
MBoundingBoxInterface::MBoundingBoxInterface(MActor *child)
MBoundingBoxInterface::MBoundingBoxInterface(
MActor *child, MBoundingBoxConnectionType bBoxType,
MBoundingBoxConnection *parentBBoxConnection)
: child(child)
{}
{
if (parentBBoxConnection == nullptr)
{
bBoxConnection = new MBoundingBoxConnection(this, bBoxType);
}
else
{
bBoxConnection = parentBBoxConnection;
}
}
MBoundingBoxInterface::~MBoundingBoxInterface()
......@@ -486,6 +497,12 @@ void MBoundingBoxInterface::switchToBoundingBox(QString bBoxName)
}
void MBoundingBoxInterface::insertBoundingBoxProperty(QtProperty *parentGroup)
{
parentGroup->addSubProperty(bBoxConnection->getProperty());
}
/******************************************************************************
*** MBoundingBoxConnection ***
*******************************************************************************/
......@@ -493,8 +510,8 @@ void MBoundingBoxInterface::switchToBoundingBox(QString bBoxName)
*** CONSTRUCTOR / DESTRUCTOR ***
*******************************************************************************/
MBoundingBoxConnection::MBoundingBoxConnection(MBoundingBoxInterface *actor,
ConnectionType type)
MBoundingBoxConnection::MBoundingBoxConnection(
MBoundingBoxInterface *actor, MBoundingBoxConnectionType type)
: QObject(),
actor(actor),
type(type),
......@@ -549,15 +566,15 @@ MBoundingBoxConnection::~MBoundingBoxConnection()
{
switch (type)
{
case HORIZONTAL:
case MBoundingBoxConnectionType::HORIZONTAL:
disconnect(boundingBox, SIGNAL(horizontal2DCoordsChanged()),
this, SLOT(onBoundingBoxChanged()));
break;
case VERTICAL:
case MBoundingBoxConnectionType::VERTICAL:
disconnect(boundingBox, SIGNAL(pressureLevelChanged()),
this, SLOT(onBoundingBoxChanged()));
break;
case VOLUME:
case MBoundingBoxConnectionType::VOLUME:
disconnect(boundingBox, SIGNAL(coords3DChanged()),
this, SLOT(onBoundingBoxChanged()));
break;
......@@ -706,20 +723,18 @@ void MBoundingBoxConnection::setBoundingBox(QString bBoxID)
{
switch (type)
{
case HORIZONTAL:
case MBoundingBoxConnectionType::HORIZONTAL:
disconnect(boundingBox, SIGNAL(horizontal2DCoordsChanged()),
this, SLOT(onBoundingBoxChanged()));
break;
case VERTICAL:
case MBoundingBoxConnectionType::VERTICAL:
disconnect(boundingBox, SIGNAL(pressureLevelChanged()),
this, SLOT(onBoundingBoxChanged()));
break;
case VOLUME:
case MBoundingBoxConnectionType::VOLUME:
disconnect(boundingBox, SIGNAL(coords3DChanged()),
this, SLOT(onBoundingBoxChanged()));
break;
default:
break;
}
}
......@@ -729,20 +744,18 @@ void MBoundingBoxConnection::setBoundingBox(QString bBoxID)
{
switch (type)
{
case HORIZONTAL:
case MBoundingBoxConnectionType::HORIZONTAL:
connect(boundingBox, SIGNAL(horizontal2DCoordsChanged()),
this, SLOT(onBoundingBoxChanged()));
break;
case VERTICAL:
case MBoundingBoxConnectionType::VERTICAL:
connect(boundingBox, SIGNAL(pressureLevelChanged()),
this, SLOT(onBoundingBoxChanged()));
break;
case VOLUME:
case MBoundingBoxConnectionType::VOLUME:
connect(boundingBox, SIGNAL(coords3DChanged()),
this, SLOT(onBoundingBoxChanged()));
break;
default:
break;
}
}
}
......
......@@ -4,8 +4,8 @@
** three-dimensional visual exploration of numerical ensemble weather
** prediction data.
**
** Copyright 2017 Marc Rautenhaus
** Copyright 2017 Bianca Tost
** Copyright 2017-2018 Bianca Tost
** Copyright 2017-2018 Marc Rautenhaus
**
** Computer Graphics and Visualization Group
** Technische Universitaet Muenchen, Garching, Germany
......@@ -146,6 +146,12 @@ protected:
bool signalEmitEnabled;
};
enum class MBoundingBoxConnectionType
{
HORIZONTAL = 0,
VERTICAL = 1,
VOLUME = 2
};
class MBoundingBoxConnection;
class MActor;
......@@ -161,11 +167,17 @@ class MActor;
cannot be solved due to the static_cast automatically created in Qt's
moc-files when using signals and slots.
(cp. http://www.drdobbs.com/cpp/multiple-inheritance-considered-useful/184402074).
NOTE: To use bounding boxes it is mandatory to insert the bounding box
property with @ref insertBoundingBoxProperty() during creation of properties
in the constructor of the child class!
*/
class MBoundingBoxInterface
{
public:
MBoundingBoxInterface(MActor *child);
MBoundingBoxInterface(MActor *child,
MBoundingBoxConnectionType bBoxType,
MBoundingBoxConnection *parentBBoxConnection = nullptr);
~MBoundingBoxInterface();
/**
......@@ -194,6 +206,11 @@ public:
void switchToBoundingBox(QString bBoxName);
protected:
/**
Use this method to insert bounding box property as subproperty of @p parentGroup.
*/
void insertBoundingBoxProperty(QtProperty *parentGroup);
// Pointer to actor inheriting from the interface.
MActor *child;
// Object realising and handling connection between actor and bounding box.
......@@ -213,14 +230,8 @@ class MBoundingBoxConnection : public QObject
Q_OBJECT
public:
enum ConnectionType
{
HORIZONTAL = 0,
VERTICAL = 1,
VOLUME = 2
};
MBoundingBoxConnection(MBoundingBoxInterface *actor, ConnectionType type);
MBoundingBoxConnection(MBoundingBoxInterface *actor,
MBoundingBoxConnectionType type);
~MBoundingBoxConnection();
MBoundingBox *getBoundingBox() { return boundingBox; }
......@@ -282,7 +293,7 @@ protected:
MSystemManagerAndControl *sysMC;
MBoundingBoxInterface *actor;
ConnectionType type;
MBoundingBoxConnectionType type;
MBoundingBox *boundingBox;
MQtProperties *properties;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment