Skip to content
This repository has been archived by the owner on Jul 8, 2022. It is now read-only.

Commit

Permalink
Small refactoring of clip planes wrt serialization and UI
Browse files Browse the repository at this point in the history
This allows to have another deserialization callback on the clipPlanes object,
needed in/for Brayns integration. Also, let the UI keep receiving updates
of the clip planes when/if modified from HTTP/python.
  • Loading branch information
tribal-tec committed Jan 20, 2017
1 parent 3f96377 commit 3bff480
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 102 deletions.
23 changes: 13 additions & 10 deletions apps/livreGUI/MainWindow.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2011-2016, EPFL/Blue Brain Project
/* Copyright (c) 2011-2017, EPFL/Blue Brain Project
* Jafet Villafranca <jafet.villafrancadiaz@epfl.ch>
* Raphael Dumusc <raphael.dumusc@epfl.ch>
*
Expand Down Expand Up @@ -42,12 +42,6 @@ struct MainWindow::Impl

parent->setCentralWidget( new TransferFunctionEditor( controller ));

#ifdef LIVRE_USE_MONSTEER
_ui.simulationDockWidget->setWidget( new monsteer::qt::SteeringWidget );
#else
_ui.simulationDockWidget->setHidden( true );
#endif

_ui.animationDockWidget->setWidget(
new AnimationController( controller ));

Expand All @@ -56,11 +50,20 @@ struct MainWindow::Impl

_ui.renderParametersDockWidget->setWidget( new RenderParametersController( controller ));

_ui.clipPlanesDockWidget->setWidget( new ClipPlanesController( controller ));
parent->tabifyDockWidget( _ui.renderParametersDockWidget,
_ui.clipPlanesDockWidget );

#ifdef LIVRE_USE_MONSTEER
_ui.simulationDockWidget->setWidget( new monsteer::qt::SteeringWidget );
#else
_ui.simulationDockWidget->setHidden( true );
#endif
if( !_ui.simulationDockWidget->isHidden( ))
parent->tabifyDockWidget( _ui.simulationDockWidget,
_ui.renderParametersDockWidget);
parent->tabifyDockWidget( _ui.clipPlanesDockWidget,
_ui.simulationDockWidget );

_ui.clipPlanesDockWidget->setWidget( new ClipPlanesController( controller ));
_ui.renderParametersDockWidget->raise();
}

~Impl(){}
Expand Down
9 changes: 9 additions & 0 deletions apps/livreGUI/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ background-color: darkGray; width: 1px; height: 1px;
<widget class="QWidget" name="renderParametersDockWidgetPlaceholder"/>
</widget>
<widget class="QDockWidget" name="clipPlanesDockWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Clip Planes</string>
</property>
<attribute name="dockWidgetArea">
<number>2</number>
</attribute>
Expand Down
8 changes: 4 additions & 4 deletions apps/livreGUI/clipPlanesController/ClipPlanesController.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2015-2016, EPFL/Blue Brain Project
/* Copyright (c) 2015-2017, EPFL/Blue Brain Project
* ahmet.bilgili@epfl.ch
*
* This file is part of Livre <https://github.com/BlueBrain/Livre>
Expand Down Expand Up @@ -27,7 +27,7 @@
namespace livre
{

struct ClipPlanesController::Impl
struct ClipPlanesController::Impl : public QObject
{
Impl( ClipPlanesController* parent, Controller& controller )
: _parent( parent )
Expand All @@ -39,7 +39,8 @@ struct ClipPlanesController::Impl
_clipPlanes.clear();

parent->connect( parent, &ClipPlanesController::clipPlanesReceived,
[&](){ clipPlanesReceived( );});
this, &ClipPlanesController::Impl::clipPlanesReceived,
Qt::QueuedConnection );

slidersWidget->connect( _ui.clipPlanesCheckBox, &QCheckBox::stateChanged,
[&]( int value )
Expand Down Expand Up @@ -99,7 +100,6 @@ struct ClipPlanesController::Impl
_clipPlanes.registerDeserializedCallback(
[&]{
emit _parent->clipPlanesReceived();
_clipPlanes.registerDeserializedCallback( nullptr );
});
}

Expand Down
14 changes: 10 additions & 4 deletions apps/livreGUI/clipPlanesController/ClipPlanesController.ui
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</size>
</property>
<property name="windowTitle">
<string>Clip Planes</string>
<string>Clip planes</string>
</property>
<widget class="QWidget" name="clipPlanesWidget" native="true">
<property name="geometry">
Expand All @@ -34,7 +34,13 @@
<height>211</height>
</rect>
</property>
<widget class="QWidget" name="layoutWidget">
<property name="minimumSize">
<size>
<width>250</width>
<height>0</height>
</size>
</property>
<widget class="QWidget" name="layoutSliderWidget">
<property name="geometry">
<rect>
<x>0</x>
Expand Down Expand Up @@ -351,12 +357,12 @@
</property>
</widget>
</widget>
<widget class="QWidget" name="layoutWidget">
<widget class="QWidget" name="layoutButtonWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>10</y>
<width>130</width>
<width>133</width>
<height>17</height>
</rect>
</property>
Expand Down
15 changes: 5 additions & 10 deletions livre/core/render/TransferFunction1D.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2011-2016, EPFL/Blue Brain Project
/* Copyright (c) 2011-2017, EPFL/Blue Brain Project
* Ahmet Bilgili <ahmet.bilgili@epfl.ch>
* Stefan.Eilemann@epfl.ch
*
Expand All @@ -25,12 +25,14 @@
#include <livre/core/types.h>

#include <lexis/render/lookupTable1D.h>
#include <co/distributable.h>

namespace livre
{

/** Color and transparency for an RGBA 1 dimensional Transfer Function. */
class TransferFunction1D : public ::lexis::render::LookupTable1D
class TransferFunction1D :
public co::Distributable< ::lexis::render::LookupTable1D >
{
static const size_t NCHANNELS = 4;

Expand Down Expand Up @@ -61,14 +63,7 @@ class TransferFunction1D : public ::lexis::render::LookupTable1D
* @param tf The transfer function to be copied.
*/
explicit TransferFunction1D( const TransferFunction1D& tf )
: ::lexis::render::LookupTable1D( tf ) {}

/**
* Create a transfer function.
* @param rgba A std::vector with samples of the transfer function.
*/
explicit TransferFunction1D( const std::vector< uint8_t >& rgba )
: ::lexis::render::LookupTable1D( rgba ) {}
: co::Distributable< ::lexis::render::LookupTable1D >( tf ) {}

TransferFunction1D& operator=( const TransferFunction1D& rhs )
{
Expand Down
18 changes: 12 additions & 6 deletions livre/eq/FrameData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ class FrameData::Impl : public co::ObjectMap
: co::ObjectMap( handler, factory )
{
frameSettings.setID( servus::make_uint128( "livre::FrameSettings" ));
renderSettings.setID( servus::make_uint128( "livre::RenderSettings" ));
cameraSettings.setID( servus::make_uint128( "livre::CameraSettings" ));
volumeSettings.setID( servus::make_uint128( "livre::VolumeSettings" ));
vrParameters.setID(
servus::make_uint128( "livre::VolumeRendererParameters" ));
renderSettings.getClipPlanes().setID( servus::make_uint128( "livre::ClipPlanes" ));
renderSettings.getTransferFunction().setID( servus::make_uint128( "livre::TransferFunction" ));
}

FrameSettings frameSettings;
Expand All @@ -58,31 +59,35 @@ FrameData::FrameData()
void FrameData::registerObjects()
{
LBCHECK( _impl->register_( &_impl->frameSettings, co::OBJECTTYPE_CUSTOM ));
LBCHECK( _impl->register_( &_impl->renderSettings, co::OBJECTTYPE_CUSTOM));
LBCHECK( _impl->register_( &_impl->cameraSettings, co::OBJECTTYPE_CUSTOM));
LBCHECK( _impl->register_( &_impl->volumeSettings, co::OBJECTTYPE_CUSTOM));
LBCHECK( _impl->register_( &_impl->vrParameters, co::OBJECTTYPE_CUSTOM ));
LBCHECK( _impl->register_( &_impl->renderSettings.getClipPlanes(), co::OBJECTTYPE_CUSTOM));
LBCHECK( _impl->register_( &_impl->renderSettings.getTransferFunction(), co::OBJECTTYPE_CUSTOM));
}

void FrameData::deregisterObjects()
{
LBCHECK( _impl->deregister( &_impl->frameSettings ));
LBCHECK( _impl->deregister( &_impl->renderSettings ));
LBCHECK( _impl->deregister( &_impl->cameraSettings ));
LBCHECK( _impl->deregister( &_impl->volumeSettings ));
LBCHECK( _impl->deregister( &_impl->vrParameters ));
LBCHECK( _impl->deregister( &_impl->renderSettings.getClipPlanes( )));
LBCHECK( _impl->deregister( &_impl->renderSettings.getTransferFunction( )));
}

void FrameData::mapObjects()
{
LBCHECK( _impl->map( _impl->frameSettings.getID(), &_impl->frameSettings ));
LBCHECK( _impl->map( _impl->renderSettings.getID(),
&_impl->renderSettings ));
LBCHECK( _impl->map( _impl->cameraSettings.getID(),
&_impl->cameraSettings ));
LBCHECK( _impl->map( _impl->volumeSettings.getID(),
&_impl->volumeSettings ));
LBCHECK( _impl->map( _impl->vrParameters.getID(), &_impl->vrParameters ));
LBCHECK( _impl->map( _impl->renderSettings.getClipPlanes().getID(),
&_impl->renderSettings.getClipPlanes( )));
LBCHECK( _impl->map( _impl->renderSettings.getTransferFunction().getID(),
&_impl->renderSettings.getTransferFunction( )));
}

void FrameData::unmapObjects()
Expand All @@ -91,10 +96,11 @@ void FrameData::unmapObjects()
return;

LBCHECK( _impl->unmap( &_impl->frameSettings ));
LBCHECK( _impl->unmap( &_impl->renderSettings ));
LBCHECK( _impl->unmap( &_impl->cameraSettings ));
LBCHECK( _impl->unmap( &_impl->volumeSettings ));
LBCHECK( _impl->unmap( &_impl->vrParameters ));
LBCHECK( _impl->unmap( &_impl->renderSettings.getClipPlanes( )));
LBCHECK( _impl->unmap( &_impl->renderSettings.getTransferFunction( )));
_impl->clear();
}

Expand Down
36 changes: 1 addition & 35 deletions livre/eq/settings/RenderSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,56 +28,22 @@ namespace livre
{

RenderSettings::RenderSettings()
: _depth( 0 )
{
_transferFunction.registerDeserializedCallback( [this]
{ setDirty( DIRTY_TF ); });

_clipPlanes.registerDeserializedCallback( [this]
{ setDirty( DIRTY_CLIPPLANES ); });

_clipPlanes.clear();
}

void RenderSettings::resetTransferFunction( )
void RenderSettings::resetTransferFunction()
{
setTransferFunction( TransferFunction1D( ));
}

void RenderSettings::setTransferFunction( const TransferFunction1D& tf )
{
_transferFunction = tf;
setDirty( DIRTY_TF );
}

void RenderSettings::setClipPlanes( const ClipPlanes& clipPlanes )
{
_clipPlanes = clipPlanes;
setDirty( DIRTY_CLIPPLANES );
}

void RenderSettings::serialize( co::DataOStream& os, const uint64_t dirtyBits )
{
if( dirtyBits & DIRTY_TF )
os << _transferFunction;

if( dirtyBits & DIRTY_DEPTH )
os << _depth;

if( dirtyBits & DIRTY_CLIPPLANES )
os << _clipPlanes;
}

void RenderSettings::deserialize( co::DataIStream& is, const uint64_t dirtyBits )
{
if( dirtyBits & DIRTY_TF )
is >> _transferFunction;

if( dirtyBits & DIRTY_DEPTH )
is >> _depth;

if( dirtyBits & DIRTY_CLIPPLANES )
is >> _clipPlanes;
}

}
37 changes: 4 additions & 33 deletions livre/eq/settings/RenderSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,10 @@
#include <livre/core/render/TransferFunction1D.h>
#include <livre/core/render/ClipPlanes.h>

#include <co/serializable.h>

namespace livre
{

class RenderSettings : public co::Serializable
class RenderSettings
{
public:

Expand All @@ -57,7 +55,7 @@ class RenderSettings : public co::Serializable
* @return Returns the transfer function.
*/
TransferFunction1D& getTransferFunction()
{ setDirty( DIRTY_TF ); return _transferFunction; }
{ _transferFunction.notifyChanged(); return _transferFunction; }
const TransferFunction1D& getTransferFunction() const
{ return _transferFunction; }

Expand All @@ -70,40 +68,13 @@ class RenderSettings : public co::Serializable
/**
* @return Returns the clip planes.
*/
ClipPlanes& getClipPlanes() { return _clipPlanes; }
ClipPlanes& getClipPlanes()
{ _clipPlanes.notifyChanged(); return _clipPlanes; }
const ClipPlanes& getClipPlanes( ) const { return _clipPlanes; }

/**
* @brief adjustQuality Adjusts the quality.
* @param delta The adjustment factor.
*/
void adjustQuality( float delta );

/**
* @brief increaseError Increases the error.
*/
void increaseError( );

/**
* @brief decreaseError Decreases the error.
*/
void decreaseError( );

private:
virtual void serialize( co::DataOStream& os, const uint64_t dirtyBits );
virtual void deserialize( co::DataIStream& is, const uint64_t dirtyBits );

TransferFunction1D _transferFunction;
ClipPlanes _clipPlanes;
uint8_t _depth;

/** The changed parts of the data since the last pack(). */
enum DirtyBits
{
DIRTY_TF = co::Serializable::DIRTY_CUSTOM << 0u,
DIRTY_DEPTH = co::Serializable::DIRTY_CUSTOM << 1u,
DIRTY_CLIPPLANES = co::Serializable::DIRTY_CUSTOM << 2u
};
};

}
Expand Down

0 comments on commit 3bff480

Please sign in to comment.