Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions licence.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
BSD License 2.0

Copyright (c) 2008-2023, Benoit AUTHEMAN All rights reserved.
Copyright (c) 2025, Siemens Energy Global GmbH & Co. KG

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down
26 changes: 19 additions & 7 deletions samples/edges/Ortho.qml
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,26 @@ Qan.GraphView {
console.error('pos=' + pos)
}
} // Qan.Graph
CheckBox {
Column {
anchors.top: parent.top; anchors.topMargin: 4
anchors.right: parent.right; anchors.rightMargin: 2
id: dashed
text: "Ortho"
checked: defaultEdgeStyle.lineType === Qan.EdgeStyle.Ortho
onClicked: {
defaultEdgeStyle.lineType = !checked ? Qan.EdgeStyle.Straight : Qan.EdgeStyle.Ortho
anchors.right: parent.right; anchors.rightMargin: 4

RadioButton {
text: "Straight"
checked: defaultEdgeStyle.lineType === Qan.EdgeStyle.Straight
onClicked: defaultEdgeStyle.lineType = Qan.EdgeStyle.Straight
}
RadioButton {
text: "Ortho"
checked: defaultEdgeStyle.lineType === Qan.EdgeStyle.Ortho
onClicked: defaultEdgeStyle.lineType = Qan.EdgeStyle.Ortho
}
RadioButton {
text: "OrthoDouble"
checked: defaultEdgeStyle.lineType === Qan.EdgeStyle.OrthoDouble
onClicked: defaultEdgeStyle.lineType = Qan.EdgeStyle.OrthoDouble
}
}


} // Qan.GraphView
8 changes: 4 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ set(qan_qml_files
EdgeTemplate.qml
EdgeStraightPath.qml
EdgeOrthoPath.qml
EdgeOrthoDoublePath.qml
EdgeCurvedPath.qml
EdgeSrcArrowPath.qml
EdgeSrcCirclePath.qml
Expand Down Expand Up @@ -141,12 +142,13 @@ set(qan_qml_files

# Configure Qt
set(CMAKE_AUTOMOC ON)
#qt_wrap_cpp(qan_moc_files ${qan_header_files}) # Creates .moc files from sources
set(CMAKE_AUTORCC ON)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:QT_QML_DEBUG>)

# Configure QuickQanava library ###############################################

qt_policy(SET QTP0001 NEW)

# qt_add_library(QuickQanava STATIC)
qt_add_qml_module(QuickQanava
STATIC
Expand All @@ -156,10 +158,8 @@ qt_add_qml_module(QuickQanava
${qan_source_files} ${qan_header_files} ${qan_moc_files} ${quickcontainers_source_files} ${quickcontainers_header_files}
QML_FILES
${qan_qml_files}
RESOURCE_PREFIX /
OUTPUT_DIRECTORY QuickQanava
)
set(QT_QML_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/QuickQanava)
set(QT_QML_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/qml)

target_include_directories(QuickQanava
PUBLIC
Expand Down
100 changes: 100 additions & 0 deletions src/EdgeOrthoDoublePath.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
Copyright (c) 2008-2024, Benoit AUTHEMAN All rights reserved.
Copyright (c) 2025, Siemens Energy Global GmbH & Co. KG

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the author or Destrat.io nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

//-----------------------------------------------------------------------------
// This file is a part of the QuickQanava software library.
//
// \file EdgeOrthoDoublePath.qml
// \author morgan.bengtsson.ext@siemens-energy.com
// \date 2025 07 21
//-----------------------------------------------------------------------------

import QtQuick
import QtQuick.Shapes

ShapePath {
id: edgeShapePath

// Set in EdgeTemplate.qml createObject() from global qanEdgeOrthoPathComponent
property var edgeTemplate: undefined
property var edgeItem: edgeTemplate.edgeItem

startX: edgeItem.p1.x
startY: edgeItem.p1.y
capStyle: ShapePath.FlatCap
strokeWidth: edgeItem?.style?.lineWidth ?? 2
strokeColor: edgeTemplate.color
strokeStyle: edgeTemplate.dashed
dashPattern: edgeItem?.style?.dashPattern ?? [4, 2]
fillColor: Qt.rgba(0,0,0,0)

property real edgeLengthY: Math.abs(edgeItem.p2.y - edgeItem.p1.y)
property real edgeLengthX: Math.abs(edgeItem.p2.x - edgeItem.p1.x)
property int horizontalDir: Math.sign(edgeItem.p1.x - edgeItem.p2.x);
property int verticalDir: Math.sign(edgeItem.p1.y - edgeItem.p2.y);
property bool isPoint: edgeItem.c1.x === edgeItem.c2.x && edgeItem.c1.y === edgeItem.c2.y
property bool horizontalEdge: (edgeItem.c1.x === edgeItem.c2.x) && !isPoint
property bool verticalEdge: (edgeItem.c1.y === edgeItem.c2.y) && !isPoint
property real radius: Math.min(edgeItem?.style?.orthoRadius ?? 10, (horizontalEdge ? edgeLengthY : edgeLengthX) / 2)

PathLine {
x: edgeShapePath.edgeItem.c1.x + edgeShapePath.horizontalEdge * edgeShapePath.horizontalDir * edgeShapePath.radius
y: edgeShapePath.edgeItem.c1.y + edgeShapePath.verticalEdge * edgeShapePath.verticalDir * edgeShapePath.radius
}
PathArc {
x: edgeShapePath.edgeItem.c1.x - edgeShapePath.verticalEdge * edgeShapePath.horizontalDir * edgeShapePath.radius
y: edgeShapePath.edgeItem.c1.y - edgeShapePath.horizontalEdge * edgeShapePath.verticalDir * edgeShapePath.radius
radiusX: edgeShapePath.radius
radiusY: edgeShapePath.radius
useLargeArc: false
direction: (edgeShapePath.verticalEdge
? edgeShapePath.verticalDir !== edgeShapePath.horizontalDir
: edgeShapePath.verticalDir === edgeShapePath.horizontalDir)
? PathArc.Clockwise
: PathArc.Counterclockwise;
}
PathLine {
x: edgeShapePath.edgeItem.c2.x + edgeShapePath.verticalEdge * edgeShapePath.horizontalDir * edgeShapePath.radius
y: edgeShapePath.edgeItem.c2.y + edgeShapePath.horizontalEdge * edgeShapePath.verticalDir * edgeShapePath.radius
}
PathArc {
x: edgeShapePath.edgeItem.c2.x - edgeShapePath.horizontalEdge * edgeShapePath.horizontalDir * edgeShapePath.radius
y: edgeShapePath.edgeItem.c2.y - edgeShapePath.verticalEdge * edgeShapePath.verticalDir * edgeShapePath.radius
radiusX: edgeShapePath.radius
radiusY: edgeShapePath.radius
useLargeArc: false
direction: (edgeShapePath.horizontalEdge
? edgeShapePath.verticalDir !== edgeShapePath.horizontalDir
: edgeShapePath.verticalDir === edgeShapePath.horizontalDir)
? PathArc.Clockwise
: PathArc.Counterclockwise;
}
PathLine {
x: edgeShapePath.edgeItem.p2.x
y: edgeShapePath.edgeItem.p2.y
}
}
25 changes: 25 additions & 0 deletions src/EdgeTemplate.qml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
Copyright (c) 2008-2024, Benoit AUTHEMAN All rights reserved.
Copyright (c) 2025, Siemens Energy Global GmbH & Co. KG

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -137,6 +138,7 @@ Item {
property var curvedLine : undefined
property var straightLine : undefined
property var orthoLine : undefined
property var orthoDoubleLine: undefined
property var lineType: edgeTemplate.lineType
property var lineWidth: edgeItem?.style?.lineWidth + 2. ?? 4.
property var lineColor: edgeItem &&
Expand All @@ -150,6 +152,7 @@ Item {
switch (lineType) {
case Qan.EdgeStyle.Undefined: // falltrought
case Qan.EdgeStyle.Straight:
if (orthoDoubleLine) orthoDoubleLine.destroy()
if (orthoLine) orthoLine.destroy()
if (curvedLine) curvedLine.destroy()
edgeSelectionShape.data = straightLine = qanEdgeStraightPathComponent.createObject(edgeSelectionShape, {
Expand All @@ -159,6 +162,7 @@ Item {
});
break;
case Qan.EdgeStyle.Ortho:
if (orthoDoubleLine) orthoDoubleLine.destroy()
if (straightLine) straightLine.destroy()
if (curvedLine) curvedLine.destroy()
edgeSelectionShape.data = orthoLine = qanEdgeOrthoPathComponent.createObject(edgeSelectionShape, {
Expand All @@ -167,7 +171,18 @@ Item {
strokeColor: lineColor
})
break;
case Qan.EdgeStyle.OrthoDouble:
if (orthoLine) orthoLine.destroy()
if (straightLine) straightLine.destroy()
if (curvedLine) curvedLine.destroy()
edgeSelectionShape.data = orthoDoubleLine = qanEdgeOrthoDoublePathComponent.createObject(edgeSelectionShape, {
edgeTemplate: edgeTemplate,
strokeWidth: lineWidth,
strokeColor: lineColor
})
break;
case Qan.EdgeStyle.Curved:
if (orthoDoubleLine) orthoDoubleLine.destroy()
if (straightLine) straightLine.destroy()
if (orthoLine) orthoLine.destroy()
edgeSelectionShape.data = curvedLine = qanEdgeCurvedPathComponent.createObject(edgeSelectionShape, {
Expand All @@ -189,21 +204,31 @@ Item {
property var curvedLine : undefined
property var straightLine : undefined
property var orthoLine : undefined
property var orthoDoubleLine: undefined
property var lineType: edgeTemplate.lineType
onLineTypeChanged: {
switch (lineType) {
case Qan.EdgeStyle.Undefined: // falltrought
case Qan.EdgeStyle.Straight:
if (orthoDoubleLine) orthoDoubleLine.destroy()
if (orthoLine) orthoLine.destroy()
if (curvedLine) curvedLine.destroy()
edgeShape.data = straightLine = qanEdgeStraightPathComponent.createObject(edgeShape, {edgeTemplate: edgeTemplate});
break;
case Qan.EdgeStyle.Ortho:
if (orthoDoubleLine) orthoDoubleLine.destroy()
if (straightLine) straightLine.destroy()
if (curvedLine) curvedLine.destroy()
edgeShape.data = orthoLine = qanEdgeOrthoPathComponent.createObject(edgeShape, {edgeTemplate: edgeTemplate})
break;
case Qan.EdgeStyle.OrthoDouble:
if (orthoLine) orthoLine.destroy()
if (straightLine) straightLine.destroy()
if (curvedLine) curvedLine.destroy()
edgeShape.data = orthoDoubleLine = qanEdgeOrthoDoublePathComponent.createObject(edgeShape, {edgeTemplate: edgeTemplate})
break;
case Qan.EdgeStyle.Curved:
if (orthoDoubleLine) orthoDoubleLine.destroy()
if (straightLine) straightLine.destroy()
if (orthoLine) orthoLine.destroy()
edgeShape.data = curvedLine = qanEdgeCurvedPathComponent.createObject(edgeShape, {edgeTemplate: edgeTemplate})
Expand Down
20 changes: 11 additions & 9 deletions src/QuickQanava.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
Copyright (c) 2008-2024, Benoit AUTHEMAN All rights reserved.
Copyright (c) 2025, Siemens Energy Global GmbH & Co. KG

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -74,17 +75,18 @@ struct QuickQanava {
engine->rootContext()->setContextProperty("defaultEdgeStyle", QVariant::fromValue(qan::Edge::style()));
engine->rootContext()->setContextProperty("defaultGroupStyle", QVariant::fromValue(qan::Group::style()));

engine->rootContext()->setContextProperty("qanEdgeStraightPathComponent", new QQmlComponent(engine, "qrc:/QuickQanava/EdgeStraightPath.qml", engine));
engine->rootContext()->setContextProperty("qanEdgeOrthoPathComponent", new QQmlComponent(engine, "qrc:/QuickQanava/EdgeOrthoPath.qml", engine));
engine->rootContext()->setContextProperty("qanEdgeCurvedPathComponent", new QQmlComponent(engine, "qrc:/QuickQanava/EdgeCurvedPath.qml", engine));
engine->rootContext()->setContextProperty("qanEdgeStraightPathComponent", new QQmlComponent(engine, "qrc:/qt/qml/QuickQanava/EdgeStraightPath.qml", engine));
engine->rootContext()->setContextProperty("qanEdgeOrthoPathComponent", new QQmlComponent(engine, "qrc:/qt/qml/QuickQanava/EdgeOrthoPath.qml", engine));
engine->rootContext()->setContextProperty("qanEdgeOrthoDoublePathComponent", new QQmlComponent(engine, "qrc:/qt/qml/QuickQanava/EdgeOrthoDoublePath.qml", engine));
engine->rootContext()->setContextProperty("qanEdgeCurvedPathComponent", new QQmlComponent(engine, "qrc:/qt/qml/QuickQanava/EdgeCurvedPath.qml", engine));

engine->rootContext()->setContextProperty("qanEdgeSrcArrowPathComponent", new QQmlComponent(engine, "qrc:/QuickQanava/EdgeSrcArrowPath.qml", engine));
engine->rootContext()->setContextProperty("qanEdgeSrcCirclePathComponent", new QQmlComponent(engine, "qrc:/QuickQanava/EdgeSrcCirclePath.qml", engine));
engine->rootContext()->setContextProperty("qanEdgeSrcRectPathComponent", new QQmlComponent(engine, "qrc:/QuickQanava/EdgeSrcRectPath.qml", engine));
engine->rootContext()->setContextProperty("qanEdgeSrcArrowPathComponent", new QQmlComponent(engine, "qrc:/qt/qml/QuickQanava/EdgeSrcArrowPath.qml", engine));
engine->rootContext()->setContextProperty("qanEdgeSrcCirclePathComponent", new QQmlComponent(engine, "qrc:/qt/qml/QuickQanava/EdgeSrcCirclePath.qml", engine));
engine->rootContext()->setContextProperty("qanEdgeSrcRectPathComponent", new QQmlComponent(engine, "qrc:/qt/qml/QuickQanava/EdgeSrcRectPath.qml", engine));

engine->rootContext()->setContextProperty("qanEdgeDstArrowPathComponent", new QQmlComponent(engine, "qrc:/QuickQanava/EdgeDstArrowPath.qml", engine));
engine->rootContext()->setContextProperty("qanEdgeDstCirclePathComponent", new QQmlComponent(engine, "qrc:/QuickQanava/EdgeDstCirclePath.qml", engine));
engine->rootContext()->setContextProperty("qanEdgeDstRectPathComponent", new QQmlComponent(engine, "qrc:/QuickQanava/EdgeDstRectPath.qml", engine));
engine->rootContext()->setContextProperty("qanEdgeDstArrowPathComponent", new QQmlComponent(engine, "qrc:/qt/qml/QuickQanava/EdgeDstArrowPath.qml", engine));
engine->rootContext()->setContextProperty("qanEdgeDstCirclePathComponent", new QQmlComponent(engine, "qrc:/qt/qml/QuickQanava/EdgeDstCirclePath.qml", engine));
engine->rootContext()->setContextProperty("qanEdgeDstRectPathComponent", new QQmlComponent(engine, "qrc:/qt/qml/QuickQanava/EdgeDstRectPath.qml", engine));
}
} // initialize()
};
Expand Down
15 changes: 8 additions & 7 deletions src/RectNodeTemplate.qml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
Copyright (c) 2008-2024, Benoit AUTHEMAN All rights reserved.
Copyright (c) 2025, Siemens Energy Global GmbH & Co. KG

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -67,20 +68,20 @@ Item {
anchors.fill: parent
source: {
if (!nodeItem?.style) // Defaul to solid no effect with unconfigured nodes
return "qrc:/QuickQanava/RectSolidBackground.qml";
return "qrc:/qt/qml/QuickQanava/RectSolidBackground.qml";
switch (nodeItem.style.fillType) { // Otherwise, select the delegate according to current style configuration
case Qan.NodeStyle.FillSolid:
switch (nodeItem.style.effectType) {
case Qan.NodeStyle.EffectNone: return "qrc:/QuickQanava/RectSolidBackground.qml";
case Qan.NodeStyle.EffectShadow: return "qrc:/QuickQanava/RectSolidShadowBackground.qml";
case Qan.NodeStyle.EffectGlow: return "qrc:/QuickQanava/RectSolidGlowBackground.qml";
case Qan.NodeStyle.EffectNone: return "qrc:/qt/qml/QuickQanava/RectSolidBackground.qml";
case Qan.NodeStyle.EffectShadow: return "qrc:/qt/qml/QuickQanava/RectSolidShadowBackground.qml";
case Qan.NodeStyle.EffectGlow: return "qrc:/qt/qml/QuickQanava/RectSolidGlowBackground.qml";
}
break;
case Qan.NodeStyle.FillGradient:
switch (nodeItem.style.effectType) {
case Qan.NodeStyle.EffectNone: return "qrc:/QuickQanava/RectGradientBackground.qml";
case Qan.NodeStyle.EffectShadow: return "qrc:/QuickQanava/RectGradientShadowBackground.qml";
case Qan.NodeStyle.EffectGlow: return "qrc:/QuickQanava/RectGradientGlowBackground.qml";
case Qan.NodeStyle.EffectNone: return "qrc:/qt/qml/QuickQanava/RectGradientBackground.qml";
case Qan.NodeStyle.EffectShadow: return "qrc:/qt/qml/QuickQanava/RectGradientShadowBackground.qml";
case Qan.NodeStyle.EffectGlow: return "qrc:/qt/qml/QuickQanava/RectGradientGlowBackground.qml";
}
break;
} // case fillType
Expand Down
3 changes: 2 additions & 1 deletion src/qanConnector.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
Copyright (c) 2008-2024, Benoit AUTHEMAN All rights reserved.
Copyright (c) 2025, Siemens Energy Global GmbH & Co. KG

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -75,7 +76,7 @@ QQmlComponent* Connector::delegate(QQmlEngine& engine, QObject* parent) noexcep
{
static std::unique_ptr<QQmlComponent> delegate;
if (!delegate)
delegate = std::make_unique<QQmlComponent>(&engine, "qrc:/QuickQanava/VisualConnector.qml",
delegate = std::make_unique<QQmlComponent>(&engine, "qrc:/qt/qml/QuickQanava/VisualConnector.qml",
QQmlComponent::PreferSynchronous, parent);
return delegate.get();
}
Expand Down
3 changes: 2 additions & 1 deletion src/qanEdge.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
Copyright (c) 2008-2024, Benoit AUTHEMAN All rights reserved.
Copyright (c) 2025, Siemens Energy Global GmbH & Co. KG

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -75,7 +76,7 @@ QQmlComponent* Edge::delegate(QQmlEngine& engine, QObject* parent) noexcept
{
static std::unique_ptr<QQmlComponent> delegate;
if (!delegate)
delegate = std::make_unique<QQmlComponent>(&engine, "qrc:/QuickQanava/Edge.qml",
delegate = std::make_unique<QQmlComponent>(&engine, "qrc:/qt/qml/QuickQanava/Edge.qml",
QQmlComponent::PreferSynchronous, parent);
return delegate.get();
}
Expand Down
Loading