Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NeuroScheme
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SimVisSuite
NeuroScheme
Commits
a4bb52ab
Commit
a4bb52ab
authored
6 years ago
by
iagoCL
Browse files
Options
Downloads
Patches
Plain Diff
Connections with same origin and destination are not draw.
Solved bug in scatter plot layout.
parent
aff8c64b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
nsplugins/congen/ConnectionArrowItem.cpp
+87
-85
87 additions, 85 deletions
nsplugins/congen/ConnectionArrowItem.cpp
nsplugins/cortex/ConnectionArrowItem.cpp
+54
-57
54 additions, 57 deletions
nsplugins/cortex/ConnectionArrowItem.cpp
with
141 additions
and
142 deletions
nsplugins/congen/ConnectionArrowItem.cpp
+
87
−
85
View file @
a4bb52ab
...
...
@@ -83,101 +83,103 @@ namespace nslib
void
ConnectionArrowItem
::
createArrow
(
const
QPointF
&
origin
,
const
QPointF
&
dest
)
{
float
itemInvScale
=
1.0
f
/
static_cast
<
float
>
(
this
->
scale
(
));
_arrowOrigin
=
itemInvScale
*
origin
;
_arrowDest
=
itemInvScale
*
dest
;
auto
painterPath
=
QPainterPath
(
);
if
(
origin
!=
dest
)
{
float
itemInvScale
=
1.0
f
/
static_cast
<
float
>
(
this
->
scale
(
))
;
QPolygonF
arrowShape
;
_arrowOrigin
=
itemInvScale
*
origin
;
_arrowDest
=
itemInvScale
*
dest
;
float
arrowWidth
=
6.0
f
*
itemInvScale
*
nslib
::
Config
::
scale
(
);
float
arrowLength
=
3.0
f
*
itemInvScale
*
nslib
::
Config
::
scale
(
);
QPolygonF
arrowShape
;
QLineF
auxLine
(
_arrowOrigin
,
_arrowDest
);
float
arrowWidth
=
6.0
f
*
itemInvScale
*
nslib
::
Config
::
scale
(
);
float
arrowLength
=
3.0
f
*
itemInvScale
*
nslib
::
Config
::
scale
(
);
auto
lengthInv
=
1.0
f
/
auxLine
.
length
(
);
QLineF
auxLine
(
_arrowOrigin
,
_arrowDest
);
double
angle
=
::
acos
(
auxLine
.
dx
(
)
*
lengthInv
);
if
(
auxLine
.
dy
(
)
>=
0
)
{
angle
=
M_PI_x2
-
angle
;
}
auto
lengthInv
=
1.0
f
/
auxLine
.
length
(
);
QPointF
arrowInit
=
auxLine
.
pointAt
(
1.0
f
-
(
arrowLength
*
lengthInv
));
QPointF
arrowP1
=
arrowInit
-
QPointF
(
sin
(
angle
+
M_PI_3
)
*
arrowWidth
,
cos
(
angle
+
M_PI_3
)
*
arrowWidth
);
QPointF
arrowP2
=
arrowInit
-
QPointF
(
sin
(
angle
+
M_PI_067
)
*
arrowWidth
,
cos
(
angle
+
M_PI_067
)
*
arrowWidth
);
QPointF
arrowI1
=
_arrowOrigin
-
QPointF
(
sin
(
angle
+
M_PI_Float
)
*
arrowWidth
,
cos
(
angle
+
M_PI_Float
)
*
arrowWidth
);
QPointF
arrowI2
=
_arrowOrigin
+
QPointF
(
sin
(
angle
-
M_PI_Float
)
*
arrowWidth
,
cos
(
angle
-
M_PI_Float
)
*
arrowWidth
);
float
size
=
arrowLength
;
/*
if ( _arrowOriItem != nullptr ) delete _arrowOriItem;
_arrowOriItem = new QGraphicsEllipseItem( );
_arrowOriItem->setRect( origin.x( ) - size * 0.5f,
origin.y( ) - size * 0.5f,
size,
size );
_arrowOriItem->setPen( Qt::NoPen );
_arrowOriItem->setBrush( QBrush( brushColor ));
_arrowOriItem->setPen( QPen( QBrush( color ), _arrowThickness ));
_arrowOriItem->setParentItem( this );
*/
arrowShape
.
clear
(
);
if
(
this
->
_parentRep
->
getProperty
(
"head"
).
value
<
shiftgen
::
ConnectionArrowRep
::
TArrowHead
>
(
)
==
shiftgen
::
ConnectionArrowRep
::
TArrowHead
::
CIRCLE
)
{
_arrowCircleEnd
=
new
QGraphicsEllipseItem
(
);
_arrowCircleEnd
->
setRect
(
dest
.
x
(
)
-
size
*
0.5
f
,
dest
.
y
(
)
-
size
*
0.5
f
,
size
,
size
);
double
angle
=
::
acos
(
auxLine
.
dx
(
)
*
lengthInv
);
if
(
auxLine
.
dy
(
)
>=
0
)
{
angle
=
M_PI_x2
-
angle
;
}
_arrowCircleEnd
->
setPen
(
_actualPen
);
_arrowCircleEnd
->
setParentItem
(
this
);
QPointF
arrowInit
=
auxLine
.
pointAt
(
1.0
f
-
(
arrowLength
*
lengthInv
));
QPointF
arrowP1
=
arrowInit
-
QPointF
(
sin
(
angle
+
M_PI_3
)
*
arrowWidth
,
cos
(
angle
+
M_PI_3
)
*
arrowWidth
);
QPointF
arrowP2
=
arrowInit
-
QPointF
(
sin
(
angle
+
M_PI_067
)
*
arrowWidth
,
cos
(
angle
+
M_PI_067
)
*
arrowWidth
);
QPointF
arrowI1
=
_arrowOrigin
-
QPointF
(
sin
(
angle
+
M_PI_Float
)
*
arrowWidth
,
cos
(
angle
+
M_PI_Float
)
*
arrowWidth
);
QPointF
arrowI2
=
_arrowOrigin
+
QPointF
(
sin
(
angle
-
M_PI_Float
)
*
arrowWidth
,
cos
(
angle
-
M_PI_Float
)
*
arrowWidth
);
float
size
=
arrowLength
;
/*
if ( _arrowOriItem != nullptr ) delete _arrowOriItem;
_arrowOriItem = new QGraphicsEllipseItem( );
_arrowOriItem->setRect( origin.x( ) - size * 0.5f,
origin.y( ) - size * 0.5f,
size,
size );
_arrowOriItem->setPen( Qt::NoPen );
_arrowOriItem->setBrush( QBrush( brushColor ));
_arrowOriItem->setPen( QPen( QBrush( color ), _arrowThickness ));
_arrowOriItem->setParentItem( this );
*/
arrowShape
.
clear
(
);
if
(
this
->
_parentRep
->
getProperty
(
"head"
).
value
<
shiftgen
::
ConnectionArrowRep
::
TArrowHead
>
(
)
==
shiftgen
::
ConnectionArrowRep
::
TArrowHead
::
CIRCLE
)
{
_arrowCircleEnd
=
new
QGraphicsEllipseItem
(
);
_arrowCircleEnd
->
setRect
(
dest
.
x
(
)
-
size
*
0.5
f
,
dest
.
y
(
)
-
size
*
0.5
f
,
size
,
size
);
_arrowCircleEnd
->
setPen
(
_actualPen
);
_arrowCircleEnd
->
setParentItem
(
this
);
arrowShape
<<
arrowI1
<<
arrowI2
<<
auxLine
.
p1
(
)
<<
auxLine
.
p2
(
)
<<
auxLine
.
p1
(
);
}
else
{
arrowShape
<<
arrowI1
<<
arrowI2
<<
auxLine
.
p1
(
)
<<
arrowInit
<<
arrowP1
<<
auxLine
.
p2
(
)
<<
arrowP2
<<
arrowInit
<<
auxLine
.
p1
(
);
}
arrowShape
<<
arrowI1
<<
arrowI2
<<
auxLine
.
p1
(
)
<<
auxLine
.
p2
(
)
<<
auxLine
.
p1
(
);
}
else
{
arrowShape
<<
arrowI1
<<
arrowI2
<<
auxLine
.
p1
(
)
<<
arrowInit
<<
arrowP1
<<
auxLine
.
p2
(
)
<<
arrowP2
<<
arrowInit
<<
auxLine
.
p1
(
);
painterPath
.
moveTo
(
_arrowDest
);
painterPath
.
addPolygon
(
arrowShape
);
_actualPen
.
setColor
(
color
);
_actualPen
.
setCosmetic
(
true
);
this
->
setPen
(
_actualPen
);
this
->
setBrush
(
color
);
this
->
setZValue
(
-
100.0
f
);
}
auto
painterPath
=
QPainterPath
(
);
painterPath
.
moveTo
(
_arrowDest
);
painterPath
.
addPolygon
(
arrowShape
);
_actualPen
.
setColor
(
color
);
_actualPen
.
setCosmetic
(
true
);
this
->
setPen
(
_actualPen
);
this
->
setBrush
(
color
);
this
->
setPath
(
painterPath
);
this
->
setZValue
(
-
100.0
f
);
}
QPropertyAnimation
&
ConnectionArrowItem
::
lineAnim
(
void
)
...
...
This diff is collapsed.
Click to expand it.
nsplugins/cortex/ConnectionArrowItem.cpp
+
54
−
57
View file @
a4bb52ab
...
...
@@ -55,67 +55,64 @@ namespace nslib
}
void
ConnectionArrowItem
::
createArrow
(
const
QPointF
&
origin
,
const
QPointF
&
dest
)
const
QPointF
&
dest
)
{
float
itemInvScale
=
1.0
f
/
static_cast
<
float
>
(
this
->
scale
(
));
_arrowOrigin
=
itemInvScale
*
origin
;
_arrowDest
=
itemInvScale
*
dest
;
QPolygonF
arrowShape
;
float
arrowWidth
=
3
*
itemInvScale
*
nslib
::
Config
::
scale
(
);
float
arrowLength
=
arrowWidth
;
QLineF
auxLine
(
_arrowOrigin
,
_arrowDest
);
auto
lengthInv
=
1.0
f
/
auxLine
.
length
(
);
double
angle
=
::
acos
(
auxLine
.
dx
(
)
*
lengthInv
);
if
(
auxLine
.
dy
(
)
>=
0
)
angle
=
(
M_PI
*
2.0
)
-
angle
;
QPointF
arrowInit
=
auxLine
.
pointAt
(
1.0
f
-
(
arrowLength
*
lengthInv
));
QPointF
arrowP1
=
arrowInit
-
QPointF
(
sin
(
angle
+
M_PI_3
)
*
arrowWidth
,
cos
(
angle
+
M_PI_3
)
*
arrowWidth
);
QPointF
arrowP2
=
arrowInit
-
QPointF
(
sin
(
angle
+
M_PI
-
M_PI_3
)
*
arrowWidth
,
cos
(
angle
+
M_PI
-
M_PI_3
)
*
arrowWidth
);
float
size
=
arrowLength
;
if
(
_arrowOriItem
!=
nullptr
)
delete
_arrowOriItem
;
_arrowOriItem
=
new
QGraphicsEllipseItem
(
);
_arrowOriItem
->
setRect
(
origin
.
x
(
)
-
size
*
0.5
f
,
origin
.
y
(
)
-
size
*
0.5
f
,
size
,
size
);
_arrowOriItem
->
setPen
(
Qt
::
NoPen
);
_arrowOriItem
->
setBrush
(
QBrush
(
color
));
_arrowOriItem
->
setPen
(
QPen
(
QBrush
(
color
),
_arrowThickness
));
_arrowOriItem
->
setParentItem
(
this
);
arrowShape
.
clear
(
);
arrowShape
<<
auxLine
.
p1
(
)
<<
arrowInit
<<
arrowP1
<<
auxLine
.
p2
(
)
<<
arrowP2
<<
arrowInit
;
this
->
setBrush
(
QBrush
(
color
));
// this->setPen( QPen( color ));
this
->
setPen
(
QPen
(
QBrush
(
color
),
_arrowThickness
));
if
(
origin
!=
dest
)
{
float
itemInvScale
=
1.0
f
/
static_cast
<
float
>
(
this
->
scale
(
));
_arrowOrigin
=
itemInvScale
*
origin
;
_arrowDest
=
itemInvScale
*
dest
;
float
arrowWidth
=
3
*
itemInvScale
*
nslib
::
Config
::
scale
(
);
float
arrowLength
=
arrowWidth
;
QLineF
auxLine
(
_arrowOrigin
,
_arrowDest
);
auto
lengthInv
=
1.0
f
/
auxLine
.
length
(
);
double
angle
=
::
acos
(
auxLine
.
dx
(
)
*
lengthInv
);
if
(
auxLine
.
dy
(
)
>=
0
)
angle
=
(
M_PI
*
2.0
)
-
angle
;
QPointF
arrowInit
=
auxLine
.
pointAt
(
1.0
f
-
(
arrowLength
*
lengthInv
));
QPointF
arrowP1
=
arrowInit
-
QPointF
(
sin
(
angle
+
M_PI_3
)
*
arrowWidth
,
cos
(
angle
+
M_PI_3
)
*
arrowWidth
);
QPointF
arrowP2
=
arrowInit
-
QPointF
(
sin
(
angle
+
M_PI
-
M_PI_3
)
*
arrowWidth
,
cos
(
angle
+
M_PI
-
M_PI_3
)
*
arrowWidth
);
float
size
=
arrowLength
;
if
(
_arrowOriItem
!=
nullptr
)
delete
_arrowOriItem
;
_arrowOriItem
=
new
QGraphicsEllipseItem
(
);
_arrowOriItem
->
setRect
(
origin
.
x
(
)
-
size
*
0.5
f
,
origin
.
y
(
)
-
size
*
0.5
f
,
size
,
size
);
_arrowOriItem
->
setPen
(
Qt
::
NoPen
);
_arrowOriItem
->
setBrush
(
QBrush
(
color
));
_arrowOriItem
->
setPen
(
QPen
(
QBrush
(
color
),
_arrowThickness
));
_arrowOriItem
->
setParentItem
(
this
);
arrowShape
<<
auxLine
.
p1
(
)
<<
arrowInit
<<
arrowP1
<<
auxLine
.
p2
(
)
<<
arrowP2
<<
arrowInit
;
this
->
setBrush
(
QBrush
(
color
));
// this->setPen( QPen( color ));
this
->
setPen
(
QPen
(
QBrush
(
color
),
_arrowThickness
));
this
->
setZValue
(
-
100.0
f
);
}
this
->
setPolygon
(
arrowShape
);
this
->
setZValue
(
-
100.0
f
);
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment