Commit 52bccdc7 authored by Robin Eschbach's avatar Robin Eschbach
Browse files

Merge branch 'sprint_5' into 'hs-worms/TOP-2021'

[MERGE #128] Sprint 5

See merge request top/21s/sivert-vis/sivert-vis-project!92
parents b4830226 1fc4ab70
......@@ -80,6 +80,16 @@ namespace WPropertyHelper
}
}
namespace PC_CONFIRMOVERWRITE
{
void addTo( WPropFilename prop )
{
prop->addConstraint( boost::shared_ptr< WPropertyConstraintConfirmOverwrite< WPVBaseTypes::PV_PATH > >(
new WPropertyConstraintConfirmOverwrite< WPVBaseTypes::PV_PATH >()
) );
}
}
namespace PC_ISVALID
{
void addTo( WPropSelection prop )
......
......@@ -34,6 +34,7 @@
#include "constraints/WPropertyConstraintIsDirectory.h"
#include "constraints/WPropertyConstraintSelectOnlyOne.h"
#include "constraints/WPropertyConstraintIsValid.h"
#include "constraints/WPropertyConstraintConfirmOverwrite.h"
/**
......@@ -107,6 +108,19 @@ namespace WPropertyHelper
void addTo( WPropFilename prop );
}
/**
* Contains functions for easily adding contraints of type PC_CONFIRMOVERWRITE to properties compatible with this constraint.
*/
namespace PC_CONFIRMOVERWRITE
{
/**
* Add the PC_CONFIRMOVERWRITE constraint to the property.
*
* \param prop the property where to add the constraint.
*/
void addTo( WPropFilename prop );
}
/**
* Contains functions for easily adding constraints of type PC_ISVALID to properties compatible with this constraint.
*/
......
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@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 "WPropertyConstraintConfirmOverwrite.h"
#include "../WPropertyVariable.h"
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@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 WPROPERTYCONSTRAINTCONFIRMOVERWRITE_H
#define WPROPERTYCONSTRAINTCONFIRMOVERWRITE_H
#include "../WPropertyTypes.h"
#include "WPropertyConstraintTypes.h"
/**
* This class allows constraining properties to be existing filenames. This is especially useful for WPropFilename.
*/
template < typename T >
class WPropertyConstraintConfirmOverwrite: public WPropertyVariable< T >::PropertyConstraint
{
public:
/**
* Constructor.
*/
WPropertyConstraintConfirmOverwrite();
/**
* Destructor.
*/
virtual ~WPropertyConstraintConfirmOverwrite();
/**
* Checks whether the specified value is a directory or not.
*
* \param property the property whose new value should be set.
* \param value the new value to check
*
* \return true if the file/path is a directory
*/
virtual bool accept( boost::shared_ptr< WPropertyVariable< T > > property, const T& value );
/**
* Allows simple identification of the real constraint type.
*
* \return the type
*/
virtual PROPERTYCONSTRAINT_TYPE getType();
/**
* Method to clone the constraint and create a new one with the correct dynamic type.
*
* \return the constraint.
*/
virtual boost::shared_ptr< typename WPropertyVariable< T >::PropertyConstraint > clone();
private:
};
template < typename T >
WPropertyConstraintConfirmOverwrite< T >::WPropertyConstraintConfirmOverwrite()
{
}
template < typename T >
WPropertyConstraintConfirmOverwrite< T >::~WPropertyConstraintConfirmOverwrite()
{
}
template < typename T >
bool WPropertyConstraintConfirmOverwrite< T >::accept( boost::shared_ptr< WPropertyVariable< T > > /* property */, const T& /* value */ )
{
return true;
}
template < typename T >
PROPERTYCONSTRAINT_TYPE WPropertyConstraintConfirmOverwrite< T >::getType()
{
return PC_CONFIRMOVERWRITE;
}
template < typename T >
boost::shared_ptr< typename WPropertyVariable< T >::PropertyConstraint > WPropertyConstraintConfirmOverwrite< T >::clone()
{
return boost::shared_ptr< typename WPropertyVariable< T >::PropertyConstraint >( new WPropertyConstraintConfirmOverwrite< T >( *this ) );
}
#endif // WPROPERTYCONSTRAINTCONFIRMOVERWRITE_H
......@@ -39,7 +39,8 @@ typedef enum
PC_ISDIRECTORY, // type ID for WPropertyConstraintIsDirectory
PC_SELECTONLYONE, // type ID for WPropertyConstraintSelectOnlyOne
PC_SELECTATLEASTONE, // type ID for WPropertyConstraintSelectAtLeastOne
PC_ISVALID // type ID for WPropertyConstraintIsValid
PC_ISVALID, // type ID for WPropertyConstraintIsValid
PC_CONFIRMOVERWRITE // type ID for WPropertyConstraintConfirmOverwrite
}
PROPERTYCONSTRAINT_TYPE;
......
......@@ -24,6 +24,7 @@
#include "WDataSetCSV.h"
WDataSetCSV::WDataSetCSV( WDataSetCSV::ContentSPtr header, WDataSetCSV::ContentSPtr data )
: m_header( header ), m_data( data )
{
......@@ -46,3 +47,13 @@ WDataSetCSV::ContentSPtr WDataSetCSV::getData()
{
return m_data;
}
WDataSetCSV::SeperatedRowSPtr WDataSetCSV::getRawDataSet()
{
return rawDataSet;
}
void WDataSetCSV::setRawDataSet( WDataSetCSV::SeperatedRowSPtr rawDataSetIn )
{
rawDataSet = rawDataSetIn;
}
......@@ -25,16 +25,20 @@
#ifndef WDATASETCSV_H
#define WDATASETCSV_H
#include "WDataSet.h"
#include "string"
#include "vector"
#include "WDataSet.h"
/**
* Represents a CSV dataset.
*/
class WDataSetCSV : public WDataSet
{
/**
* Only test class may be friend
*/
friend class WDataSetCSVTest;
public:
/**
* represents a vector containing a vector of strings.
......@@ -46,6 +50,16 @@ public:
*/
typedef boost::shared_ptr< std::vector< std::vector< std::string > > > ContentSPtr;
/**
* represents a pointer to a vector of csv-raw-row as string
*/
typedef boost::shared_ptr< std::vector< std:: string > > SeperatedRowSPtr;
/**
* represents an element within WDataSetCSV object.
*/
typedef std::vector< std::string > ContentElem;
/**
* Construct WDataSetCSV object
*
......@@ -78,6 +92,20 @@ public:
*/
WDataSetCSV::ContentSPtr getData();
/**
* Getter method to receive csv rawdata
*
* \param rawDataSetIn as WDataSetCSV::SeperatedRowSPtr object
*/
void setRawDataSet( WDataSetCSV::SeperatedRowSPtr rawDataSetIn );
/**
* Getter method to receive csv data
*
* \return rawDataSet as std::vector< std:: string > object
*/
SeperatedRowSPtr getRawDataSet();
private:
/**
* Stores the column titles of a loaded CSV file.
......@@ -88,6 +116,11 @@ private:
* Stores the data of a loaded CSV file.
*/
WDataSetCSV::ContentSPtr m_data;
/**
* Stores the rawdata of a loaded CSV file.
*/
SeperatedRowSPtr rawDataSet;
};
#endif // WDATASETCSV_H
......@@ -310,6 +310,11 @@ const boost::shared_ptr< WDataSetFibers::ColorScheme > WDataSetFibers::getColorS
return boost::static_pointer_cast< ColorScheme >( *i );
}
void WDataSetFibers::setSelectedColorScheme( size_t idx )
{
m_colorProp->set( m_colors->getSelector( idx ) );
}
const boost::shared_ptr< WDataSetFibers::ColorScheme > WDataSetFibers::getColorScheme( size_t idx ) const
{
WItemSelection::ReadTicket l = m_colors->getReadTicket();
......
......@@ -399,6 +399,13 @@ public:
*/
const boost::shared_ptr< ColorScheme > getColorScheme( size_t idx ) const;
/**
* Sets the selected color scheme.
*
* \param idx the index
*/
void setSelectedColorScheme( size_t idx );
/**
* Convenience method returning the currently selected scheme. This is a comfortable alternative to using the color scheme selection
* property.
......
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@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 <string>
#include "WDataSetPointsAndEventID.h"
boost::shared_ptr< WPrototyped > WDataSetPointsAndEventID::m_prototype = boost::shared_ptr< WPrototyped >();
WDataSetPointsAndEventID::WDataSetPointsAndEventID( WDataSetPointsAndEventID::VertexArray vertices,
WDataSetPointsAndEventID::ColorArray colors,
WDataSetPointsAndEventID::EventIDArray eventIDs,
WBoundingBox boundingBox ):
WDataSetPoints( vertices, colors, boundingBox ),
m_eventIDs( eventIDs )
{
WAssert( eventIDs->size() == vertices->size() / 3 , "Number of ints in eventID array must be 1 per vertex" );
}
WDataSetPointsAndEventID::WDataSetPointsAndEventID( WDataSetPointsAndEventID::VertexArray vertices,
WDataSetPointsAndEventID::ColorArray colors,
WDataSetPointsAndEventID::EventIDArray eventIDs ):
WDataSetPoints( vertices, colors ),
m_eventIDs( eventIDs )
{
WAssert( eventIDs->size() == vertices->size() / 3 , "Number of ints in eventID array must be 1 per vertex" );
}
WDataSetPointsAndEventID::WDataSetPointsAndEventID()
{
}
WDataSetPointsAndEventID::~WDataSetPointsAndEventID()
{
}
const std::string WDataSetPointsAndEventID::getName() const
{
return "WDataSetPointsAndEventID";
}
const std::string WDataSetPointsAndEventID::getDescription() const
{
return "Dataset which contains points including their eventID.";
}
boost::shared_ptr< WPrototyped > WDataSetPointsAndEventID::getPrototype()
{
if( !m_prototype )
{
m_prototype = boost::shared_ptr< WPrototyped >( new WDataSetPointsAndEventID() );
}
return m_prototype;
}
WDataSetPointsAndEventID::EventIDArray WDataSetPointsAndEventID::getEventIDs() const
{
return m_eventIDs;
}
int WDataSetPointsAndEventID::getEventID( const int pointIdx ) const
{
if( !isValidPointIdx( pointIdx ) )
{
throw WOutOfBounds( "The specified index is invalid." );
}
return m_eventIDs->operator[]( pointIdx );
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@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 WDATASETPOINTSANDEVENTID_H
#define WDATASETPOINTSANDEVENTID_H
#include <string>
#include <vector>
#include <boost/shared_ptr.hpp>
#include "WDataSetPoints.h"
/**
* Dataset to store a bunch of points with their sizes but without order or topology.
*/
class WDataSetPointsAndEventID : public WDataSetPoints
{
public:
/**
* Pointer to dataset.
*/
typedef boost::shared_ptr< WDataSetPointsAndEventID > SPtr;
/**
* Pointer to const dataset.
*/
typedef boost::shared_ptr< const WDataSetPointsAndEventID > ConstSPtr;
/**
* Sizes for each vertix in VertexArray
*/
typedef boost::shared_ptr< std::vector< int > > EventIDArray;
/**
* Constructs a new set of points. If no color is specified, white is used for all points.
*
* \note the number of floats in vertices must be a multiple of 3
* \note the number of floats in colors (if not NULL) must be vertices->size() / 3 times one of 1,3, or 4
* \note the number of floats in sizes must be vertices->size() / 3
*
* \param vertices the vertices of the points, stored in x1,y1,z1,x2,y2,z2, ..., xn,yn,zn scheme
* \param colors the colors of each vertex. Can be NULL. Stored as R1,G1,B1,A1, ... Rn,Gn,Bn,An
* \param eventIDs the eventID of each vertex.
* \param boundingBox The bounding box of the points (first minimum, second maximum).
*/
WDataSetPointsAndEventID( VertexArray vertices, ColorArray colors,
EventIDArray eventIDs, WBoundingBox boundingBox );
/**
* Constructs a new set of points. The bounding box is calculated during construction. If no color is specified, white is used for all
* points.
*
* \note the number of floats in vertices must be a multiple of 3
* \note the number of floats in colors (if not NULL) must be vertices->size() / 3 times one of 1,3, or 4
* \note the number of floats in sizes must be vertices->size() / 3
*
* \param vertices the vertices of the points, stored in x1,y1,z1,x2,y2,z2, ..., xn,yn,zn scheme
* \param eventIDs the eventID of each vertex.
* \param colors the colors of each vertex. Can be NULL. Stored as R1,[G1,B1,[A1,]] ... Rn,[Gn,Bn,[An]]
*/
WDataSetPointsAndEventID( VertexArray vertices, ColorArray colors,
EventIDArray eventIDs );
/**
* Constructs a new set of points. The constructed instance is empty.
*/
WDataSetPointsAndEventID();
/**
* Destructor.
*/
~WDataSetPointsAndEventID();
/**
* Gets the name of this prototype.
*
* \return the name.
*/
const std::string getName() const;
/**
* Gets the description for this prototype.
*
* \return the description
*/
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();
/**
* Getter for the point eventIDs
* \return The eventIDs
*/
EventIDArray getEventIDs() const;
/**
* The eventID of a given point.
*
* \throw WOutOfBounds if invalid index is used.
* \param pointIdx the point index.
*
* \return the eventID
*/
int getEventID( const int pointIdx ) const;
protected:
/**
* The prototype as singleton.
*/
static boost::shared_ptr< WPrototyped > m_prototype;
private:
/**
* An array of the eventID per vertex.
*/
EventIDArray m_eventIDs;
};
#endif // WDATASETPOINTSANDEVENTID_H
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@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 "WDataSetPointsAndFibers.h"
WDataSetPointsAndFibers::WDataSetPointsAndFibers( WDataSetPoints::SPtr points, WDataSetFibers::SPtr fibers )
: m_points( points ), m_fibers( fibers )
{
}
WDataSetPointsAndFibers::WDataSetPointsAndFibers()
{
}
WDataSetPointsAndFibers::~WDataSetPointsAndFibers()
{
}
WDataSetPoints::SPtr WDataSetPointsAndFibers::getPoints()
{
return m_points;
}
WDataSetFibers::SPtr WDataSetPointsAndFibers::getFibers()
{
return m_fibers;
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying