30 #include "WConnectorData.h"
31 #include "WFiberHandler.h"
32 #include "action/WFiberActionAddFiber.h"
33 #include "action/WFiberActionAddVertex.h"
34 #include "action/WFiberActionMultideselect.h"
35 #include "action/WFiberActionMultiselect.h"
36 #include "action/WFiberActionRemoveFiber.h"
37 #include "action/WFiberActionRemoveVertex.h"
38 #include "action/WFiberActionToggle.h"
39 #include "core/common/WPathHelper.h"
47 m_hidden = std::shared_ptr< std::vector< char > >(
new std::vector< char >() );
67 std::sort( fiber->begin(), fiber->end(), []( osg::Vec3 a, osg::Vec3 b )
86 auto fiber =
m_fibers->begin() + fiberIdx;
87 if( std::find( fiber->begin(), fiber->end(), vertex ) != fiber->end() )
92 fiber->push_back( vertex );
103 auto fiber =
m_fibers->begin() + fiberIdx;
104 for(
auto vertex = fiber->begin(); vertex != fiber->end(); vertex++ )
106 auto it = std::find( vertices.begin(), vertices.end(), *vertex );
107 if( it != vertices.end() )
109 vertices.erase( it );
113 if( vertices.empty() )
118 for(
auto vertex = vertices.begin(); vertex != vertices.end(); vertex++ )
120 fiber->push_back( *vertex );
132 auto fiber =
m_fibers->begin() + fiberIdx;
134 for(
auto vertex = vertices.begin(); vertex != vertices.end(); vertex++ )
136 auto it = std::find( fiber->begin(), fiber->end(), *vertex );
137 if( it != fiber->end() )
151 auto fiber =
m_fibers->begin() + fiberIdx;
152 fiber->emplace( fiber->begin() + position, vertex );
162 auto fiber =
m_fibers->begin() + fiberIdx;
165 for(
auto it = fiber->begin(); it != fiber->end(); it++ )
205 WPropertyGroup::SPtr fiberGroup = properties->addPropertyGroup(
"Fibers",
"Property group for fiber selection, adding and deleting." );
206 WPropertyGroup::SPtr undoGroup = properties->addPropertyGroup(
"Undo | Redo",
"Property group for undo and redo." );
223 selections->addItem(
ItemType::create(
"Line Loop",
"Line Loop",
"", NULL ) );
225 m_selectionType = fiberGroup->addProperty(
"Selection Type",
"The type of the selection", selections->getSelectorFirst(), notifier );
233 static bool sortComparator( std::shared_ptr< WItemSelectionItem > a, std::shared_ptr< WItemSelectionItem > b )
235 return a->getName().compare( b->getName() ) < 0;
315 std::string name = selection->getName();
318 name = name.substr( 0, name.size() - 2 );
354 for(
size_t fiberIdx = 0; fiberIdx <
m_fibers->size(); fiberIdx++ )
357 if( std::find( fiber.begin(), fiber.end(), vertex ) != fiber.end() )
441 std::string name =
"Track " + boost::lexical_cast< std::string >(
m_fiberCount );
Handles undo and redo action.
std::shared_ptr< WActionHandler > SPtr
A shared_ptr to this class.
The action when adding a fiber.
std::shared_ptr< WFiberActionAddFiber > SPtr
A shared_ptr to this class.
The action when adding a Vertex.
std::shared_ptr< WFiberActionAddVertex > SPtr
A shared_ptr to this class.
The action when adding multiple Vertices.
std::shared_ptr< WFiberActionMultideselect > SPtr
A shared_ptr to this class.
The action when adding multiple Vertices.
std::shared_ptr< WFiberActionMultiselect > SPtr
A shared_ptr to this class.
The action when removing a fiber.
std::shared_ptr< WFiberActionRemoveFiber > SPtr
A shared_ptr to this class.
The action when removing a Vertex.
std::shared_ptr< WFiberActionRemoveVertex > SPtr
A shared_ptr to this class.
The action when toggling a fiber.
std::shared_ptr< WFiberActionToggle > SPtr
A shared_ptr to this class.
void addVertexToFiber(osg::Vec3 vertex, size_t fiberIdx, bool silent=false)
Adds a vertex to the currently selected fiber.
void removeVerticesFromFiber(std::vector< osg::Vec3 > vertices, size_t fiberIdx, bool silent=false)
Removes multiple vertices from the currently selected fiber.
void selectLastPoint()
Selects the last point of the currently selected fiber.
WPropTrigger m_undoTrigger
Property (button) to undo the last action.
WActionHandler::SPtr getActionHandler()
void setFiberCount(size_t fiberCount)
Sets the fiber count.
void updateProperty(WPropertyBase::SPtr property)
Update handler for the properties.
WPropTrigger m_addFiber
Property (button) to add a new fiber.
void toggleFiber(size_t idx, bool silent=false)
Toggles the visibility of a fiber.
std::vector< osg::Vec3 > PCFiber
Vector of 3D vectors, representing points.
void addVertexToFiberAt(osg::Vec3 vertex, size_t fiberIdx, size_t position, bool silent=false)
Adds a vertex to the currently selected fiber.
PCFiberListSPtr getFibers()
void addFiber(std::string name, bool silent=false, bool updateSelector=true)
Adds a new fiber.
WActionHandler::SPtr m_actionHandler
Handles the undo and redo action.
void selectorUpdate(size_t idx)
Updates the UI selector.
bool isHidden(size_t idx)
Checks if a fiber is hidden.
WPropTrigger m_removeFiber
Property (button) to remove a fiber.
bool getFiberOfPoint(osg::Vec3 vertex, size_t *idx=NULL)
Gets the index of the fiber of a point.
void removeVertexFromFiber(osg::Vec3 vertex, size_t fiberIdx, bool silent=false)
Removes a vertex from the currently selected fiber.
size_t getSelectedFiber()
WPropTrigger m_redoTrigger
Property (button) to redo the last action.
void createNewFiber()
Creates a new fiber.
WMPointConnector * m_pointConnector
A reference to the WMPointConnector this belongs to.
std::vector< PCFiber > PCFiberList
Vector, that could contain multiple fibers.
void addVerticesToFiber(std::vector< osg::Vec3 > vertices, size_t fiberIdx, bool silent=false)
Adds multiple vertices to the currently selected fiber.
std::shared_ptr< PCFiberList > PCFiberListSPtr
Shared pointer to fibers-vector.
WPropSelection m_selectionType
The type of the selection.
std::shared_ptr< std::vector< char > > m_hidden
Vector for the visibility of the fibers.
void sortVertices()
Sorts the vertices by their z value.
bool isPointHidden(osg::Vec3 vertex)
Checks whether a point is in a hidden fiber.
int m_fiberCount
Stores the amount of new created fibers.
void selectFiber(size_t idx)
Selects a fiber by its index in the fibers vector.
void removeFiber(size_t idx, bool silent=false, bool updateSelector=true)
Removes a fiber at an index in the fibers vector.
WFiberHandler(WMPointConnector *pointConnector)
Creates the list of fibers.
size_t m_selectedFiber
Represents the index of the current active fiber.
PCFiberListSPtr m_fibers
A pointer to the list of fibers.
std::shared_ptr< WItemSelection > m_possibleFiberSelections
The list of possible fibers, which can be selected.
WPropSelection m_fiberSelection
Represents the current active fiber selection property.
WPropTrigger m_toggleFiber
Property (button) to toggle the visibility of a fiber.
void createProperties(WPropertyGroup::SPtr properties)
Creates the properties for this handler.
void addFiberAt(std::string name, size_t position, bool hidden, bool silent=false, PCFiber fiber=PCFiber())
Adds a new or an old fiber at a specific position.
void clear()
Clears the data in this handler.
WMPointConnector * getPointConnector()
static SPtr create(T value, std::string name, std::string description="", const char **icon=NULL)
Create a instance of the item.
std::shared_ptr< WItemSelectionItem > SPtr
Abbreviation for a shared pointer.
A class containing a list of named items.
std::shared_ptr< WItemSelection > SPtr
Convenience typedef for a std::shared_ptr< WItemSelection >
This module connects the points in a point dataset.
void updateAll()
Updates all.
std::shared_ptr< WOnscreenSelection > getOnscreenSelection()
std::shared_ptr< WConnectorData > getConnectorData()
void updateOutput()
Updates the fiber output.
WSelectionType
The different types of selection.
boost::function< void(std::shared_ptr< WPropertyBase >)> PropertyChangeNotifierType
Signal signature emitted during set operations.
std::shared_ptr< WPropertyBase > SPtr
Convenience typedef for a std::shared_ptr< WPropertyBase >
std::shared_ptr< WPropertyGroup > SPtr
shared pointer to object of this type
@ PV_TRIGGER_TRIGGERED
Trigger property: got triggered.
@ PV_TRIGGER_READY
Trigger property: is ready to be triggered (again)
void addTo(WPropSelection prop)
Add the PC_NOTEMPTY constraint to the property.
void addTo(WPropSelection prop)
Add the PC_SELECTONLYONE constraint to the property.