[OpenWalnut-Dev] [OWci] r7148: [ADD #373] Now the navigation slices communicate their positions via an output connector.

Mathias Goldau math at informatik.uni-leipzig.de
Tue Jul 22 13:46:07 CEST 2014


You are right, didn't know of the SelectionManager. Removed also the 
PropTransfer template.

best,
Mathias

Am 22.07.2014 11:38, schrieb Sebastian Eichelbaum:
> Please revert this change. You get the current slice positions via the WSelectionManager (core/kernel/WSelectionManager). Additionally, WPropTransfer is a bad design. It is a transportation-contaier. Not a Property that transfers something (as the name implies).
>
> Cheers,
> Sebastian
>
> On Tue, 22 Jul 2014, math wrote:
>
>> *Branch default*
>> [ADD #373] Now the navigation slices communicate their positions via an output connector.
>>
>> changeset 7148:e2c31c1ecf4f in /srv/hg/ow (Tue Jul 22 11:27:17 2014 +0200):
>>
>> http://www.openwalnut.org/projects/openwalnut/repository/revisions/7148
>>
>> diffstat:
>>
>>   src/core/common/WPropTransfer.cpp                   |   25 ++
>>   src/core/common/WPropTransfer.h                     |  167 ++++++++++++++++++++
>>   src/modules/navigationSlices/WMNavigationSlices.cpp |   13 +
>>   src/modules/navigationSlices/WMNavigationSlices.h   |   10 +-
>>   4 files changed, 214 insertions(+), 1 deletions(-)
>>
>> diffs (268 lines):
>>
>> diff -r 703e2fed0050 -r e2c31c1ecf4f src/core/common/WPropTransfer.cpp
>> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
>> +++ b/src/core/common/WPropTransfer.cpp	Tue Jul 22 11:27:17 2014 +0200
>> @@ -0,0 +1,25 @@
>> +//---------------------------------------------------------------------------
>> +//
>> +// Project: OpenWalnut ( http://www.openwalnut.org )
>> +//
>> +// Copyright 2009 OpenWalnut Community, BSV at Uni-Leipzig and CNCF at MPI-CBS
>> +// For more information see http://www.openwalnut.org/copying
>> +//
>> +// This file is part of OpenWalnut.
>> +//
>> +// OpenWalnut is free software: you can redistribute it and/or modify
>> +// it under the terms of the GNU Lesser General Public License as published by
>> +// the Free Software Foundation, either version 3 of the License, or
>> +// (at your option) any later version.
>> +//
>> +// OpenWalnut is distributed in the hope that it will be useful,
>> +// but WITHOUT ANY WARRANTY; without even the implied warranty of
>> +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> +// GNU Lesser General Public License for more details.
>> +//
>> +// You should have received a copy of the GNU Lesser General Public License
>> +// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
>> +//
>> +//---------------------------------------------------------------------------
>> +
>> +#include "WPropTransfer.h"
>> diff -r 703e2fed0050 -r e2c31c1ecf4f src/core/common/WPropTransfer.h
>> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
>> +++ b/src/core/common/WPropTransfer.h	Tue Jul 22 11:27:17 2014 +0200
>> @@ -0,0 +1,167 @@
>> +//---------------------------------------------------------------------------
>> +//
>> +// Project: OpenWalnut ( http://www.openwalnut.org )
>> +//
>> +// Copyright 2009 OpenWalnut Community, BSV at Uni-Leipzig and CNCF at MPI-CBS
>> +// For more information see http://www.openwalnut.org/copying
>> +//
>> +// This file is part of OpenWalnut.
>> +//
>> +// OpenWalnut is free software: you can redistribute it and/or modify
>> +// it under the terms of the GNU Lesser General Public License as published by
>> +// the Free Software Foundation, either version 3 of the License, or
>> +// (at your option) any later version.
>> +//
>> +// OpenWalnut is distributed in the hope that it will be useful,
>> +// but WITHOUT ANY WARRANTY; without even the implied warranty of
>> +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> +// GNU Lesser General Public License for more details.
>> +//
>> +// You should have received a copy of the GNU Lesser General Public License
>> +// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
>> +//
>> +//---------------------------------------------------------------------------
>> +
>> +#ifndef WPROPTRANSFER_H
>> +#define WPROPTRANSFER_H
>> +
>> +#include <string>
>> +
>> +#include "core/common/math/linearAlgebra/WPosition.h"
>> +#include "core/common/WProperties.h"
>> +#include "core/common/WTransferable.h"
>> +
>> +/**
>> + * Encapulates a WPropertyVariable for transfering it (shared_ptr) over module connectors.
>> + */
>> +template< class T >
>> +class WPropTransfer: public WTransferable
>> +{
>> +public:
>> +    /**
>> +     * Alias for a boost::shared_ptr on this.
>> +     */
>> +    typedef boost::shared_ptr< WPropTransfer< T > > SPtr;
>> +
>> +    /**
>> +     * Default constructor.
>> +     */
>> +    explicit WPropTransfer();
>> +
>> +    /**
>> +     * Create a new Transferable containing a link to a property.
>> +     *
>> +     * \param property
>> +     */
>> +    explicit WPropTransfer( T property );
>> +
>> +    /**
>> +     * Destructor.
>> +     */
>> +    virtual ~WPropTransfer();
>> +
>> +    /**
>> +     * Gives back the name of this transferrable.
>> +     * \return the name
>> +     */
>> +    virtual const std::string getName() const;
>> +
>> +    /**
>> +     * Gives back a description of this transferrable.
>> +     * \return the description
>> +     */
>> +    virtual const std::string getDescription() const;
>> +
>> +    /**
>> +     * Returns a prototype instantiated with the true type of the deriving class.
>> +     *
>> +     * \return the prototype.
>> +     */
>> +    static boost::shared_ptr< WPrototyped > getPrototype();
>> +
>> +    /**
>> +     * Sets a new property, beeing transfered via this transferable.
>> +     *
>> +     * \param property
>> +     */
>> +    void setProperty( T property );
>> +
>> +    /**
>> +     * Retrieve the transfered property.
>> +     *
>> +     * \return Property.
>> +     */
>> +    T getProperty();
>> +
>> +private:
>> +    /**
>> +     * The prototype as singleton.
>> +     */
>> +    static boost::shared_ptr< WPrototyped > m_prototype;
>> +
>> +    /**
>> +     * This is what is beeing shared with this transferable: a single property.
>> +     */
>> +    T m_property;
>> +};
>> +
>> +template< class T >
>> +WPropTransfer< T >::WPropTransfer( T property )
>> +    : m_property( property )
>> +{
>> +}
>> +
>> +template< class T >
>> +void WPropTransfer< T >::setProperty( T property )
>> +{
>> +    m_property = property;
>> +}
>> +
>> +template< class T >
>> +T WPropTransfer< T >::getProperty()
>> +{
>> +    return m_property;
>> +}
>> +
>> +// prototype instance as singleton
>> +template< class T >
>> +boost::shared_ptr< WPrototyped > WPropTransfer< T >::m_prototype = boost::shared_ptr< WPrototyped >();
>> +
>> +template< class T >
>> +boost::shared_ptr< WPrototyped > WPropTransfer< T >::getPrototype()
>> +{
>> +    if( !m_prototype )
>> +    {
>> +        m_prototype = boost::shared_ptr< WPrototyped >( new WPropTransfer< T >() );
>> +    }
>> +
>> +    return m_prototype;
>> +}
>> +
>> +template< class T >
>> +const std::string WPropTransfer< T >::getName() const
>> +{
>> +    return "Property transfer";
>> +}
>> +
>> +template< class T >
>> +const std::string WPropTransfer< T >::getDescription() const
>> +{
>> +    return "Transfers a property trough connectors. Be careful as multiple threads could use this!";
>> +}
>> +
>> +template< class T >
>> +WPropTransfer< T >::WPropTransfer()
>> +{
>> +}
>> +
>> +template< class T >
>> +WPropTransfer< T >::~WPropTransfer()
>> +{
>> +}
>> +
>> +typedef WPropTransfer< WPropDouble > WPropDoubleTransfer;
>> +
>> +typedef WPropTransfer< WPosition > WPositionTransfer;
>> +
>> +#endif  // WPROPTRANSFER_H
>> diff -r 703e2fed0050 -r e2c31c1ecf4f src/modules/navigationSlices/WMNavigationSlices.cpp
>> --- a/src/modules/navigationSlices/WMNavigationSlices.cpp	Mon Jul 21 16:45:10 2014 +0200
>> +++ b/src/modules/navigationSlices/WMNavigationSlices.cpp	Tue Jul 22 11:27:17 2014 +0200
>> @@ -86,6 +86,8 @@
>>
>>   void WMNavigationSlices::connectors()
>>   {
>> +    m_posOC = WModuleOutputData< WPositionTransfer >::createAndAdd( shared_from_this(), "positions", "Positions of all slices as vector: first, xPos, second yPos, third zPos." );
>> +
>>       // call WModule's initialization
>>       WModule::connectors();
>>   }
>> @@ -108,10 +110,21 @@
>>       m_yPos    = m_sliceGroup->addProperty( WKernel::getRunningKernel()->getSelectionManager()->getPropCoronalPos() );
>>       m_zPos    = m_sliceGroup->addProperty( WKernel::getRunningKernel()->getSelectionManager()->getPropAxialPos() );
>>
>> +    // When the position changes we need to update Position output, hence updating function needs to subscribe
>> +    m_xPos->getUpdateCondition()->subscribeSignal( boost::bind( &WMNavigationSlices::updatePositionOutput, this ) );
>> +    m_yPos->getUpdateCondition()->subscribeSignal( boost::bind( &WMNavigationSlices::updatePositionOutput, this ) );
>> +    m_zPos->getUpdateCondition()->subscribeSignal( boost::bind( &WMNavigationSlices::updatePositionOutput, this ) );
>> +
>>       // call WModule's initialization
>>       WModule::properties();
>>   }
>>
>> +void WMNavigationSlices::updatePositionOutput()
>> +{
>> +    WPositionTransfer::SPtr pos( new WPositionTransfer( WPosition( m_xPos->get(), m_yPos->get(), m_zPos->get() ) ) );
>> +    m_posOC->updateData( pos );
>> +}
>> +
>>   void WMNavigationSlices::initOSG()
>>   {
>>       // remove the old slices
>> diff -r 703e2fed0050 -r e2c31c1ecf4f src/modules/navigationSlices/WMNavigationSlices.h
>> --- a/src/modules/navigationSlices/WMNavigationSlices.h	Mon Jul 21 16:45:10 2014 +0200
>> +++ b/src/modules/navigationSlices/WMNavigationSlices.h	Tue Jul 22 11:27:17 2014 +0200
>> @@ -38,7 +38,8 @@
>>   #include "core/common/WPropertyTypes.h"
>>   #include "core/graphicsEngine/WPickInfo.h"
>>   #include "core/graphicsEngine/WGECamera.h"
>> -
>> +#include "core/common/WPropTransfer.h"
>> +#include "core/kernel/WModuleOutputData.h"
>>   #include "core/kernel/WModule.h"
>>
>>   /**
>> @@ -101,6 +102,11 @@
>>        */
>>       virtual void properties();
>>
>> +    /**
>> +     * Handles positions updates of the slices and forwards them to the output connector.
>> +     */
>> +    virtual void updatePositionOutput();
>> +
>>   private:
>>       /**
>>        * Initializes the needed geodes, transformations and vertex arrays.
>> @@ -231,6 +237,8 @@
>>        * If true, the nav slices get positioned in the middle of the first dataset.
>>        */
>>       bool m_first;
>> +
>> +    boost::shared_ptr< WModuleOutputData< WPositionTransfer > > m_posOC;
>>   };
>>
>>   #endif  // WMNAVIGATIONSLICES_H
>> _______________________________________________
>> All-openwalnut-commits mailing list
>> All-openwalnut-commits at lists.informatik.uni-leipzig.de
>> http://lists.informatik.uni-leipzig.de/mailman/listinfo/all-openwalnut-commits
>>
>

-- 
Universität Leipzig
Fakultät für Mathematik und Informatik
Institut für Informatik
Augustusplatz 10, 04109 Leipzig
Phone: +493419732283


More information about the OpenWalnut-Dev mailing list