Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
77b572f7
Commit
77b572f7
authored
Mar 22, 2021
by
Robin Eschbach
Browse files
[ADD
#139
] automatic sorting to point connector
parent
bfea5ce5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
3 deletions
+44
-3
src/modules/pointConnector/WFiberHandler.cpp
src/modules/pointConnector/WFiberHandler.cpp
+32
-0
src/modules/pointConnector/WFiberHandler.h
src/modules/pointConnector/WFiberHandler.h
+5
-0
src/modules/pointConnector/WMPointConnector.cpp
src/modules/pointConnector/WMPointConnector.cpp
+7
-3
No files found.
src/modules/pointConnector/WFiberHandler.cpp
View file @
77b572f7
...
...
@@ -47,9 +47,41 @@ WFiberHandler::WFiberHandler( WMPointConnector* pointConnector )
m_fiberCount
=
1
;
}
void
WFiberHandler
::
sortVertices
()
{
if
(
m_fibers
->
empty
()
)
{
return
;
}
for
(
auto
fiber
=
m_fibers
->
begin
();
fiber
!=
m_fibers
->
end
();
fiber
++
)
{
if
(
fiber
->
empty
()
)
{
continue
;
}
std
::
sort
(
fiber
->
begin
(),
fiber
->
end
(),
[](
osg
::
Vec3
a
,
osg
::
Vec3
b
)
{
if
(
a
.
z
()
!=
b
.
z
()
)
{
return
a
.
z
()
<
b
.
z
();
}
if
(
a
.
x
()
!=
b
.
x
()
)
{
return
a
.
x
()
<
b
.
x
();
}
return
a
.
y
()
<
b
.
y
();
}
);
}
}
void
WFiberHandler
::
addVertexToFiber
(
osg
::
Vec3
vertex
,
size_t
fiberIdx
,
bool
silent
)
{
m_fibers
->
at
(
fiberIdx
).
push_back
(
vertex
);
sortVertices
();
if
(
!
silent
)
{
...
...
src/modules/pointConnector/WFiberHandler.h
View file @
77b572f7
...
...
@@ -165,6 +165,11 @@ public:
*/
void
selectLastPoint
();
/**
* Sorts the vertices by their z value.
*/
void
sortVertices
();
/**
* Checks if a fiber is hidden.
* \param idx The index of the fiber to check.
...
...
src/modules/pointConnector/WMPointConnector.cpp
View file @
77b572f7
...
...
@@ -206,6 +206,8 @@ void WMPointConnector::handleInput()
m_fiberHandler
->
setFiberCount
(
fibers
->
size
()
);
m_fiberHandler
->
selectorUpdate
(
fibers
->
size
()
-
1
);
m_fiberHandler
->
sortVertices
();
updatePoints
();
updateOutput
();
}
...
...
@@ -271,10 +273,12 @@ void WMPointConnector::handleClick( osg::Vec3 cameraPosition, osg::Vec3 directio
{
if
(
m_fiberHandler
->
getSelectedFiber
()
==
fiberIdx
)
{
return
;
m_connectorData
->
selectPoint
(
hitIdx
);
}
else
{
m_fiberHandler
->
selectFiber
(
fiberIdx
);
m_fiberHandler
->
selectorUpdate
(
fiberIdx
);
}
m_fiberHandler
->
selectFiber
(
fiberIdx
);
m_fiberHandler
->
selectorUpdate
(
fiberIdx
);
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment