From 49b9c9eb181a1aae40ff354f32b2a08a6e4ced17 Mon Sep 17 00:00:00 2001 From: rvinktue <91969760+rvinktue@users.noreply.github.com> Date: Fri, 29 Jul 2022 09:55:20 +0200 Subject: [PATCH] Major structure overhaul --- examples/academic/abp/abp.lps | Bin 1896 -> 1896 bytes examples/academic/abp/abp.lts | Bin 0 -> 2264 bytes examples/industrial/1394/run.py | 2 +- tools/release/ltsgraph/camera.h | 5 - tools/release/ltsview/CMakeLists.txt | 50 +- tools/release/ltsview/{ => include}/cluster.h | 2 +- .../{ => include}/fsm_state_positioner.h | 0 tools/release/ltsview/{ => include}/lts.h | 0 .../ltsview/{ => include}/ltsmanager.h | 7 +- .../ltsview/{ => include}/markmanager.h | 0 .../release/ltsview/{ => include}/mathutils.h | 0 tools/release/ltsview/{ => include}/rtree.h | 0 .../release/ltsview/{ => include}/settings.h | 29 +- .../ltsview/{ => include}/simulation.h | 0 .../{ => include}/sp_state_positioner.h | 0 tools/release/ltsview/{ => include}/state.h | 0 .../ltsview/{ => include}/state_positioner.h | 0 .../ltsview/{ => include}/transition.h | 0 .../ltsview/include/ui/graphicsinfodialog.h | 32 ++ .../ltsview/{ => include/ui}/infodock.h | 0 .../ltsview/{ => include/ui}/mainwindow.h | 8 +- .../ltsview/{ => include/ui}/markdock.h | 0 .../{ => include/ui}/markstateruledialog.h | 0 .../{ => include/ui}/savepicturedialog.h | 0 .../ltsview/{ => include/ui}/settingsdialog.h | 3 +- .../ltsview/{ => include/ui}/settingsdock.h | 3 +- .../ltsview/{ => include/ui}/simdock.h | 0 .../include/ui/ui_files/graphicsinfodialog.ui | 69 +++ .../{ => include/ui/ui_files}/infodock.ui | 0 .../{ => include/ui/ui_files}/mainwindow.ui | 9 +- .../{ => include/ui/ui_files}/markdock.ui | 0 .../ui/ui_files}/markstateruledialog.ui | 0 .../ui/ui_files}/savepicturedialog.ui | 0 .../ui/ui_files}/settingsdialog.ui | 488 +++++++++--------- .../{ => include/ui/ui_files}/settingsdock.ui | 0 .../{ => include/ui/ui_files}/simdock.ui | 0 tools/release/ltsview/{ => include}/vectors.h | 0 .../ltsview/{ => include/visualizer}/conedb.h | 0 .../cameras/arcballcamera.h | 76 +++ .../generic_visualizer/cameras/glcamera.h | 58 +++ .../generic_visualizer/glrenderer.h | 42 ++ .../visualizer/generic_visualizer/glscene.h | 64 +++ .../generic_visualizer/glscenegraph.h | 57 ++ .../visualizer/generic_visualizer/glutil.h | 35 ++ .../visualizer/generic_visualizer/vistree.h | 132 +++++ .../{ => include/visualizer}/ltscanvas.h | 13 +- .../ltsview_visualizer/scenegraphgenerator.h | 123 +++++ .../visualizer}/primitivefactory.h | 3 +- .../{ => include/visualizer}/primitives.h | 0 .../visualizer}/visobjectfactory.h | 0 .../{ => include/visualizer}/visualizer.h | 3 +- .../release/ltsview/{ => source}/cluster.cpp | 0 .../{ => source}/fsm_state_positioner.cpp | 0 tools/release/ltsview/{ => source}/lts.cpp | 0 .../ltsview/{ => source}/ltsmanager.cpp | 16 +- tools/release/ltsview/{ => source}/main.cpp | 0 .../ltsview/{ => source}/markmanager.cpp | 0 tools/release/ltsview/{ => source}/rtree.cpp | 0 .../ltsview/{ => source}/simulation.cpp | 0 .../{ => source}/sp_state_positioner.cpp | 0 tools/release/ltsview/{ => source}/state.cpp | 0 .../ltsview/{ => source}/transition.cpp | 0 .../ltsview/source/ui/graphicsinfodialog.cpp | 17 + .../ltsview/{ => source/ui}/infodock.cpp | 0 .../ltsview/{ => source/ui}/mainwindow.cpp | 33 +- .../ltsview/{ => source/ui}/markdock.cpp | 0 .../{ => source/ui}/markstateruledialog.cpp | 0 .../{ => source/ui}/savepicturedialog.cpp | 0 .../{ => source/ui}/settingsdialog.cpp | 50 +- .../ltsview/{ => source/ui}/settingsdock.cpp | 35 +- .../ltsview/{ => source/ui}/simdock.cpp | 0 .../release/ltsview/{ => source}/vectors.cpp | 0 .../{ => source/visualizer}/conedb.cpp | 0 .../cameras/arcballcamera.cpp | 43 ++ .../generic_visualizer/glrenderer.cpp | 17 + .../visualizer/generic_visualizer/glscene.cpp | 51 ++ .../visualizer/generic_visualizer/glutil.cpp | 31 ++ .../generic_visualizer/shaders/simple.fs | 10 + .../generic_visualizer/shaders/simple.vs | 10 + .../{ => source/visualizer}/ltscanvas.cpp | 66 ++- .../scenegraphgenerator.cpp | 107 ++++ .../visualizer}/primitivefactory.cpp | 25 +- .../{ => source/visualizer}/primitives.cpp | 0 .../visualizer}/visobjectfactory.cpp | 0 .../{ => source/visualizer}/visualizer.cpp | 215 ++++---- 85 files changed, 1536 insertions(+), 503 deletions(-) create mode 100644 examples/academic/abp/abp.lts rename tools/release/ltsview/{ => include}/cluster.h (100%) rename tools/release/ltsview/{ => include}/fsm_state_positioner.h (100%) rename tools/release/ltsview/{ => include}/lts.h (100%) rename tools/release/ltsview/{ => include}/ltsmanager.h (94%) rename tools/release/ltsview/{ => include}/markmanager.h (100%) rename tools/release/ltsview/{ => include}/mathutils.h (100%) rename tools/release/ltsview/{ => include}/rtree.h (100%) rename tools/release/ltsview/{ => include}/settings.h (84%) rename tools/release/ltsview/{ => include}/simulation.h (100%) rename tools/release/ltsview/{ => include}/sp_state_positioner.h (100%) rename tools/release/ltsview/{ => include}/state.h (100%) rename tools/release/ltsview/{ => include}/state_positioner.h (100%) rename tools/release/ltsview/{ => include}/transition.h (100%) create mode 100644 tools/release/ltsview/include/ui/graphicsinfodialog.h rename tools/release/ltsview/{ => include/ui}/infodock.h (100%) rename tools/release/ltsview/{ => include/ui}/mainwindow.h (95%) rename tools/release/ltsview/{ => include/ui}/markdock.h (100%) rename tools/release/ltsview/{ => include/ui}/markstateruledialog.h (100%) rename tools/release/ltsview/{ => include/ui}/savepicturedialog.h (100%) rename tools/release/ltsview/{ => include/ui}/settingsdialog.h (92%) rename tools/release/ltsview/{ => include/ui}/settingsdock.h (93%) rename tools/release/ltsview/{ => include/ui}/simdock.h (100%) create mode 100644 tools/release/ltsview/include/ui/ui_files/graphicsinfodialog.ui rename tools/release/ltsview/{ => include/ui/ui_files}/infodock.ui (100%) rename tools/release/ltsview/{ => include/ui/ui_files}/mainwindow.ui (96%) rename tools/release/ltsview/{ => include/ui/ui_files}/markdock.ui (100%) rename tools/release/ltsview/{ => include/ui/ui_files}/markstateruledialog.ui (100%) rename tools/release/ltsview/{ => include/ui/ui_files}/savepicturedialog.ui (100%) rename tools/release/ltsview/{ => include/ui/ui_files}/settingsdialog.ui (52%) rename tools/release/ltsview/{ => include/ui/ui_files}/settingsdock.ui (100%) rename tools/release/ltsview/{ => include/ui/ui_files}/simdock.ui (100%) rename tools/release/ltsview/{ => include}/vectors.h (100%) rename tools/release/ltsview/{ => include/visualizer}/conedb.h (100%) create mode 100644 tools/release/ltsview/include/visualizer/generic_visualizer/cameras/arcballcamera.h create mode 100644 tools/release/ltsview/include/visualizer/generic_visualizer/cameras/glcamera.h create mode 100644 tools/release/ltsview/include/visualizer/generic_visualizer/glrenderer.h create mode 100644 tools/release/ltsview/include/visualizer/generic_visualizer/glscene.h create mode 100644 tools/release/ltsview/include/visualizer/generic_visualizer/glscenegraph.h create mode 100644 tools/release/ltsview/include/visualizer/generic_visualizer/glutil.h create mode 100644 tools/release/ltsview/include/visualizer/generic_visualizer/vistree.h rename tools/release/ltsview/{ => include/visualizer}/ltscanvas.h (88%) create mode 100644 tools/release/ltsview/include/visualizer/ltsview_visualizer/scenegraphgenerator.h rename tools/release/ltsview/{ => include/visualizer}/primitivefactory.h (95%) rename tools/release/ltsview/{ => include/visualizer}/primitives.h (100%) rename tools/release/ltsview/{ => include/visualizer}/visobjectfactory.h (100%) rename tools/release/ltsview/{ => include/visualizer}/visualizer.h (95%) rename tools/release/ltsview/{ => source}/cluster.cpp (100%) rename tools/release/ltsview/{ => source}/fsm_state_positioner.cpp (100%) rename tools/release/ltsview/{ => source}/lts.cpp (100%) rename tools/release/ltsview/{ => source}/ltsmanager.cpp (92%) rename tools/release/ltsview/{ => source}/main.cpp (100%) rename tools/release/ltsview/{ => source}/markmanager.cpp (100%) rename tools/release/ltsview/{ => source}/rtree.cpp (100%) rename tools/release/ltsview/{ => source}/simulation.cpp (100%) rename tools/release/ltsview/{ => source}/sp_state_positioner.cpp (100%) rename tools/release/ltsview/{ => source}/state.cpp (100%) rename tools/release/ltsview/{ => source}/transition.cpp (100%) create mode 100644 tools/release/ltsview/source/ui/graphicsinfodialog.cpp rename tools/release/ltsview/{ => source/ui}/infodock.cpp (100%) rename tools/release/ltsview/{ => source/ui}/mainwindow.cpp (80%) rename tools/release/ltsview/{ => source/ui}/markdock.cpp (100%) rename tools/release/ltsview/{ => source/ui}/markstateruledialog.cpp (100%) rename tools/release/ltsview/{ => source/ui}/savepicturedialog.cpp (100%) rename tools/release/ltsview/{ => source/ui}/settingsdialog.cpp (50%) rename tools/release/ltsview/{ => source/ui}/settingsdock.cpp (61%) rename tools/release/ltsview/{ => source/ui}/simdock.cpp (100%) rename tools/release/ltsview/{ => source}/vectors.cpp (100%) rename tools/release/ltsview/{ => source/visualizer}/conedb.cpp (100%) create mode 100644 tools/release/ltsview/source/visualizer/generic_visualizer/cameras/arcballcamera.cpp create mode 100644 tools/release/ltsview/source/visualizer/generic_visualizer/glrenderer.cpp create mode 100644 tools/release/ltsview/source/visualizer/generic_visualizer/glscene.cpp create mode 100644 tools/release/ltsview/source/visualizer/generic_visualizer/glutil.cpp create mode 100644 tools/release/ltsview/source/visualizer/generic_visualizer/shaders/simple.fs create mode 100644 tools/release/ltsview/source/visualizer/generic_visualizer/shaders/simple.vs rename tools/release/ltsview/{ => source/visualizer}/ltscanvas.cpp (84%) create mode 100644 tools/release/ltsview/source/visualizer/ltsview_visualizer/scenegraphgenerator.cpp rename tools/release/ltsview/{ => source/visualizer}/primitivefactory.cpp (83%) rename tools/release/ltsview/{ => source/visualizer}/primitives.cpp (100%) rename tools/release/ltsview/{ => source/visualizer}/visobjectfactory.cpp (100%) rename tools/release/ltsview/{ => source/visualizer}/visualizer.cpp (81%) diff --git a/examples/academic/abp/abp.lps b/examples/academic/abp/abp.lps index 276b8f5af7c26ca1bcd9cc5dfb2c2bb9b4b8ae22..0b39b42e21d9e4bcb1167289664433023698be29 100644 GIT binary patch delta 1001 zcmXBNeNfYN90&04Zx6q4GU8$;u#zX^NfdAVW_ZV7-&=7z+UiH4!V+09-GfXBsRYga zb~^`NqvQ6VY!Yo3^MG3iD3YBI>6oyM)`mbTphXg_5Toq4Mg9?6|Gn=0zR%|!j0wgJ zG$5+9w1l%gq)>9JGw5_U7xeDVNBTLpca;hY@F@3a^)WC4xe>|09r#8>^x(c0S|_&S}+O4;iLgfLrFNP2k;)0g`;EO0jv#$ z2gP6()<;wg9>T_mB;Y4_BBCQ;9-azO+@s(zB*KT)msz9$g3t_P3LDvP*h|S!mF<4M zym^aVeN;C!*6(mhZ%E*!dO0_ao0er+7n3WXu?QUp-GTfcp#yAZH1tvD*X+ZGYL0WR zvFV*)YHZwfMtU^}hmQZojl;8r(Gjxdv|;4NuroOc z@VU&Kn8NgoH0HarQd1lKd*I7l(li2o=C7i2vpJ_6YlX(wagw?qtIKy^yRt03vXXM` zU-QbGyDkYm*(PE7z5lQG_kumfZJO0O9JQ;y>EFR5sXjIQ@g(T6HoGJN_6qC7>6`L` zB2`qKn3DJ1V{Cbi{v1jE$|M~ew0-$A72z|csyO0|kDDwMt@>7??vuX3RzLeT9+0IH zmy)Dkq(sRCuX07yydPGFFc!nl*<%d^m6^bzW|h5QKm3|=y=4ITfP!&>FJ9#mPb5>+ z#U`9_Tks4M(itGnr*L7SZ0pXJ2TOcsV%}E#Wkm4ox|04%8?;T#;0T)}>4~i^E+Kw# zbziOdb5SNrL)*c28rDbLOp;#c&XmU@T^}k_y7l?2;kQaax>aBz(aSyfwhLwFqq_v! zLL%0^iHB*jG$ktHC2HcnuEs)}U5qw81ln`s2}|ACiB-F#*8A;pozn<}KzDJ+?_&BD zin|Ck6Y-z(mP?g+mZXZ@rrvM$)_hyVu7vB&`uR>_`y@`rczZQ(N1k#kU%c#_9Ku$C zR{xIZGr4(9<}dUIrZ)XWIBAO9i!xdq2T}2OrI|a63w-5gq}E_S!P$za@p$+TsV!Su zLd1GRJeuAFN(iQoR+(iG2-D4&Ynr`*_sm>cbAlG&49HiQ-i)5BM3RMUr}XTG*|d~^pP7~1{=xLXuT?YKMVbuL&J9*ufq78mt%cZ1Z*fwEWt Fz<>IBuNeRU delta 1001 zcmW;Ie^8or9KiAK!>_3U&5533QnE%buw%BFsTZo^dG{g}E3|a1SoVAOjOHKfDJyn1oBP zq6GJ01S=}wg+*AY1v79ZR@7h?uE9zjn1dzZsJ(>}umGbGNx>p455rhQK>$`oq6`FK zbwqNo0@owhR0$r!pG2erYw%|g)q>w)ZA9wt^Kd>0sx;#XY^dB^NXXELOFuj+O+44o zV)Bm+O(@Zm>+8(bK}n#JWskPUTD(oUkkfuYRWAcV`70kWegg+$3M+8FU15;P{=v3# z#V`Yus7$)fT&|ZaRnzRzj`(!l%>nW>@Sd2{D*-?A4-pwE**PQ1cj1rrCr}3Z1)vK` zDm^)`r9Y);E{F4d_;g)=teLxbVgB~gauD^s<90b)M_!dmNTYcDIrHexcioIsz~?5v zNi9mxNJ|z56&E`wdlxb{_4U|=>Mw&ePSsA4r2xU{&S%-Y4-C)$JU!&@{&BbS`LgHZ zRMMwyX!6XI1!Ch+AKN`BPZ>~fiiS-pNb1M zmvoXQ+mn9{nqNdjbvfrRh{v^)U-%O!1f5@ty=S(G58bjiw?6Vo@MUL6b=C*bJG<$z z``*nH?dwZ>eKe*~Sd)84K&JxU!8OzDd_IK=_%wz1tZCfPs-+PhY0Ar*NXDyy$MSZ1 z#(rfUWBS-B&SE_8*!2rISCg&Ybg1X;21rDkIWq2>^~}?w5B7pMBwe6gzlS>Zs{|(u z@1@9EY+DL|EA$a*>Ot3B$9H;*@2@}9am3ocus{N zvev@n=UG`A2gE4rt=i;0rHjGotG+0OYQWYgKGgg7<3`HoB}h9?fLi)YMZH<8$oA%FD}qEA G0PsIOgRs&7 diff --git a/examples/academic/abp/abp.lts b/examples/academic/abp/abp.lts new file mode 100644 index 0000000000000000000000000000000000000000..035c0091c77fd70dc3a6c50158bb9c2e6c4aaa5e GIT binary patch literal 2264 zcmW-heN+?a6~^B%BmyB3iwVd_O^qN0wGlE2MC@ioQZ<4I3o-`IhEMrYwuE4n!)XN3 zRT7sF!5IcuWyr)9aa|WsW7eibtrc-WL9!}}M^S=D4rei2tGhjY!yogW`Q7Kvz0dpn zF`((21{RA9&L&i$%dnt{FkIE~C^tm)_~etPITOoN@>RgDbKJ@rU-YNepKqO%CQY&c z;4@;E0g+!ub(OZDI;nE62B{DjUlb_G&X1wB8j><~hf=l1xj-Bc{_>!#`hHzHS!?QC z5YDiyj5DkDZ!PrJ zB*0R!<3P$?P@#0`IKcuh(9y^?5yx1!nsLqdPRb^` zkg$HpMh^4D?N+%Y!Yx{~dd(K}A*g7YQFC#1dPOB8?C#D{d-%nnbB_u^uP%|1mOb$s z417J~wMVy22LhK}L|)tG$R7JDp_=J_7O(ivMc=zl#zF1JLnVuiM?tQ}HzbTV-fZl= zk^5KQkVLhwew5Kzvu$N*I#?x4V@3SfY@`Q4$B;aDeD{FjY`j-N94O4~dLD8r!1wlD zMr%#?p|UZsDo(^IddyvNeq6!xt!eEoZ#!A`Sn<8K=4Nk2kUcU^z|ua+8u|7)=+Nsz zf~p=XhMK)Jv7j_}WKU>nb)Fm!kh9Da?IZm&utgp+zVFT9=U4oytMc}0N~=pN_k#0w zkQ|xCx3fks2o50K8evSFQWLY{qbY{1MyihdQNF9TUb#YZKnWFl;9quZo{)pvtM?k# zytSu>trzYCtY~rnrAv|4ewpA~DREPk$%vi5ZWhli zUII&pv+~w*F5JEk__1s8J;h7Cz7zE)T+$_6{dr+1)hN~LN?~AW6 z^$vPDb{LlOd3bq!#s~3jrv3pf#ExV;tofO^R==KJg&lDY$?{wAMhG$3mmXydH$eCU z_NCKdE#Tp%`mj#1lc|3}BiPX^;mK60F8c?W8pX}9D-JsbKPkw>d!Ww5nmkG-eyu+A zgZMqufY4G*4@(8D_|O6vJkW}S zuvS+pm!Mhrov4(sr=xrs5Te1e^FLd8u?!E71W z*APm0gnI!_djM_sq|}I=aXyfhXxlvz9L3JU(ItKDo(K%sSval4-5vq2Xv8|5rqdb7NCoj0}azdkmSVU7Rj0S;J_Z&-iD<8}}%NFa!Kp&Cg{Wtgn6kJV^UOTvc zrvaSvFFAf*&VBo{1Z)(tDL-~YgF5u)iBsk9A0Y}H%|GH|3ZdA_=pFt?E#T+(}trN@*+Yu_I%Ef7LB*W0Rb# z#}mby!SoLh>|A{{*_9sP;x#yuVOuXrp^>iOCaXd{Hv*?A7IQ*@3>D0cz-hY{bHag4 z0$~#AN{@0aZ*Xh|T%&^QI=q;(0>~6XZcBWkxEZ*DORZbfbNAH$GRYR4G|gPt)s&{h9RMGnDO@d z=~S;J!MVX{IbosTbhO_vC*tZb!yVmaNCE3Jqt($!h*EO~nXlXR_y6uZM}0PSZ_L!} Zue;TCXTS;mvGd`ZjAK)IDxCm;{{vV(^!ES& literal 0 HcmV?d00001 diff --git a/examples/industrial/1394/run.py b/examples/industrial/1394/run.py index 33dec4b0bd..3581803502 100755 --- a/examples/industrial/1394/run.py +++ b/examples/industrial/1394/run.py @@ -5,5 +5,5 @@ os.system('lps2pbes -v -f nodeadlock.mcf 1394-fin.lps 1394-fin.nodeadlock.pbes') os.system('pbes2bool -v 1394-fin.nodeadlock.pbes') -os.system('lps2lts -v --cached 1394-fin.lps 1394-fin.aut') +os.system('lps2lts -v --cached 1394-fin.lps 1394-fin.lts') diff --git a/tools/release/ltsgraph/camera.h b/tools/release/ltsgraph/camera.h index fbe89a1439..57f96e6b61 100644 --- a/tools/release/ltsgraph/camera.h +++ b/tools/release/ltsgraph/camera.h @@ -83,9 +83,4 @@ class ArcballCameraView QRect m_viewport; }; -class ArcballCameraController -{ - -}; - #endif // MCRL2_LTSGRAPH_CAMERA_H diff --git a/tools/release/ltsview/CMakeLists.txt b/tools/release/ltsview/CMakeLists.txt index 0244298653..20b560360d 100644 --- a/tools/release/ltsview/CMakeLists.txt +++ b/tools/release/ltsview/CMakeLists.txt @@ -1,43 +1,21 @@ +# This file was autogenerated with genCMakeLists.py for LTSView + +# Make sure AUTOUIC knows where to find the .ui files. +set(CMAKE_AUTOUIC_SEARCH_PATHS "./include/ui/ui_files/") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE") add_mcrl2_tool(ltsview MENUNAME "LTSView" DESCRIPTION "Visualisation tool for large state spaces (mCRL2 toolset)" ICON "mcrl2-green" SOURCES - infodock.ui - mainwindow.ui - markdock.ui - markstateruledialog.ui - savepicturedialog.ui - settingsdialog.ui - settingsdock.ui - simdock.ui - ltsview.qrc - cluster.cpp - conedb.cpp - fsm_state_positioner.cpp - infodock.cpp - lts.cpp - ltscanvas.cpp - ltsmanager.cpp - main.cpp - mainwindow.cpp - markdock.cpp - markmanager.cpp - markstateruledialog.cpp - primitivefactory.cpp - primitives.cpp - rtree.cpp - savepicturedialog.cpp - settingsdialog.cpp - settingsdock.cpp - simdock.cpp - simulation.cpp - sp_state_positioner.cpp - state.cpp - transition.cpp - vectors.cpp - visobjectfactory.cpp - visualizer.cpp + ./source/visualizer/ + ./source/visualizer/generic_visualizer/ + ./source/visualizer/generic_visualizer/cameras/ + ./source/visualizer/ltsview_visualizer/ + ./source/ + ./source/ui/ + # Qt wants .ui files in the sources variable; include by directory. + ./include/ui/ui_files/ DEPENDS mcrl2_lts mcrl2_gui @@ -51,4 +29,6 @@ add_mcrl2_tool(ltsview INCLUDE ${OPENGL_INCLUDE_DIR} ${TR_INCLUDE_DIR} + ${Boost_INCLUDE_DIRS} + "./include/visualizer/generic_visualizer/;./include/visualizer/;./include/visualizer/ltsview_visualizer/;./include/visualizer/generic_visualizer/cameras/;./include/ui/;./include/" ) diff --git a/tools/release/ltsview/cluster.h b/tools/release/ltsview/include/cluster.h similarity index 100% rename from tools/release/ltsview/cluster.h rename to tools/release/ltsview/include/cluster.h index 38060b4968..16592d4880 100644 --- a/tools/release/ltsview/cluster.h +++ b/tools/release/ltsview/include/cluster.h @@ -103,12 +103,12 @@ class Cluster void addBranchVisObject(int vo); void clearBranchVisObjects(); + std::vector< Cluster* > descendants; private: std::map< int, int > actionLabelCounts; Cluster* ancestor; float baseRadius; int numDeadlocks; - std::vector< Cluster* > descendants; std::vector > severedDescendants; unsigned int severedDescendantsC; int numMarkedStatesAll; diff --git a/tools/release/ltsview/fsm_state_positioner.h b/tools/release/ltsview/include/fsm_state_positioner.h similarity index 100% rename from tools/release/ltsview/fsm_state_positioner.h rename to tools/release/ltsview/include/fsm_state_positioner.h diff --git a/tools/release/ltsview/lts.h b/tools/release/ltsview/include/lts.h similarity index 100% rename from tools/release/ltsview/lts.h rename to tools/release/ltsview/include/lts.h diff --git a/tools/release/ltsview/ltsmanager.h b/tools/release/ltsview/include/ltsmanager.h similarity index 94% rename from tools/release/ltsview/ltsmanager.h rename to tools/release/ltsview/include/ltsmanager.h index 3f1fe37fb8..6255145a99 100644 --- a/tools/release/ltsview/ltsmanager.h +++ b/tools/release/ltsview/include/ltsmanager.h @@ -22,7 +22,7 @@ class LtsManagerHelper : public QObject Q_OBJECT public: - LtsManagerHelper(Settings *settings): m_settings(settings) {} + LtsManagerHelper() {} LTS *lts() { return m_lts; } public slots: @@ -41,7 +41,6 @@ class LtsManagerHelper : public QObject void finished(); private: - Settings *m_settings; LTS *m_lts; }; @@ -50,7 +49,7 @@ class LtsManager : public QObject Q_OBJECT public: - LtsManager(QObject *parent, Settings *settings, QThread *atermThread); + LtsManager(QObject *parent, QThread *atermThread); LTS *lts() const { return m_lts; } State *selectedState() const { return m_selectedState; } @@ -111,8 +110,6 @@ class LtsManager : public QObject public: LtsManagerHelper m_helper; - - Settings *m_settings; LTS *m_lts; std::unique_ptr m_simulation; State *m_selectedState; diff --git a/tools/release/ltsview/markmanager.h b/tools/release/ltsview/include/markmanager.h similarity index 100% rename from tools/release/ltsview/markmanager.h rename to tools/release/ltsview/include/markmanager.h diff --git a/tools/release/ltsview/mathutils.h b/tools/release/ltsview/include/mathutils.h similarity index 100% rename from tools/release/ltsview/mathutils.h rename to tools/release/ltsview/include/mathutils.h diff --git a/tools/release/ltsview/rtree.h b/tools/release/ltsview/include/rtree.h similarity index 100% rename from tools/release/ltsview/rtree.h rename to tools/release/ltsview/include/rtree.h diff --git a/tools/release/ltsview/settings.h b/tools/release/ltsview/include/settings.h similarity index 84% rename from tools/release/ltsview/settings.h rename to tools/release/ltsview/include/settings.h index 82cd2bdb4a..625b418d63 100644 --- a/tools/release/ltsview/settings.h +++ b/tools/release/ltsview/include/settings.h @@ -14,8 +14,9 @@ #include "mcrl2/gui/setting.h" -struct Settings +class Settings { +public: typedef mcrl2::gui::qt::SettingInt SettingInt; typedef mcrl2::gui::qt::SettingFloat SettingFloat; typedef mcrl2::gui::qt::SettingBool SettingBool; @@ -30,11 +31,17 @@ struct Settings SettingColor backgroundColor; SettingColor stateColor; SettingColor downEdgeColor; - SettingColor upEdgeColor; + + SettingColor upEdgeColorFrom; + SettingColor upEdgeColorTo; + SettingBool longInterpolationUpEdge; + SettingColor markedColor; + SettingColor clusterColorTop; SettingColor clusterColorBottom; - SettingBool longInterpolation; + SettingBool longInterpolationCluster; + SettingColor simPrevColor; SettingColor simCurrColor; SettingColor simSelColor; @@ -53,7 +60,8 @@ struct Settings SettingBool displayTransitions; SettingBool displayBackpointers; SettingBool displayWireframe; - + +private: Settings(): stateSize(0.1f), clusterHeight(0.0f), @@ -64,11 +72,13 @@ struct Settings backgroundColor(QColor(150, 150, 150)), stateColor(QColor(255, 255, 255)), downEdgeColor(QColor(255, 255, 255)), - upEdgeColor(QColor(0, 0, 255)), + upEdgeColorFrom(QColor(0, 0, 0)), + upEdgeColorTo(QColor(0, 0, 255)), + longInterpolationUpEdge(false), markedColor(QColor(255, 0, 0)), clusterColorTop(QColor(255, 255, 255)), clusterColorBottom(QColor(0, 0, 255)), - longInterpolation(false), + longInterpolationCluster(false), simPrevColor(QColor(255, 0, 255)), simCurrColor(QColor(0, 255, 0)), simSelColor(QColor(255, 255, 0)), @@ -88,6 +98,13 @@ struct Settings displayBackpointers(false), displayWireframe(false) {} + +public: + // singleton pattern + static Settings& instance(){ + static Settings INSTANCE; + return INSTANCE; + } }; #endif diff --git a/tools/release/ltsview/simulation.h b/tools/release/ltsview/include/simulation.h similarity index 100% rename from tools/release/ltsview/simulation.h rename to tools/release/ltsview/include/simulation.h diff --git a/tools/release/ltsview/sp_state_positioner.h b/tools/release/ltsview/include/sp_state_positioner.h similarity index 100% rename from tools/release/ltsview/sp_state_positioner.h rename to tools/release/ltsview/include/sp_state_positioner.h diff --git a/tools/release/ltsview/state.h b/tools/release/ltsview/include/state.h similarity index 100% rename from tools/release/ltsview/state.h rename to tools/release/ltsview/include/state.h diff --git a/tools/release/ltsview/state_positioner.h b/tools/release/ltsview/include/state_positioner.h similarity index 100% rename from tools/release/ltsview/state_positioner.h rename to tools/release/ltsview/include/state_positioner.h diff --git a/tools/release/ltsview/transition.h b/tools/release/ltsview/include/transition.h similarity index 100% rename from tools/release/ltsview/transition.h rename to tools/release/ltsview/include/transition.h diff --git a/tools/release/ltsview/include/ui/graphicsinfodialog.h b/tools/release/ltsview/include/ui/graphicsinfodialog.h new file mode 100644 index 0000000000..cfc1f37577 --- /dev/null +++ b/tools/release/ltsview/include/ui/graphicsinfodialog.h @@ -0,0 +1,32 @@ +// Author(s): Ruben Vink +// Copyright: see the accompanying file COPYING or copy at +// https://github.com/mCRL2org/mCRL2/blob/master/COPYING +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef GRAPHICSINFODIALOG_H +#define GRAPHICSINFODIALOG_H + +#include "ui_graphicsinfodialog.h" + +#include +#include +#include + + +class GraphicsInfoDialog : public QDialog +{ + Q_OBJECT + + public: + GraphicsInfoDialog(QWidget *parent); + + QLabel *lbl_info; + QTextEdit *txt_info; + private: + Ui::graphicsDebugInfoDialog m_ui; +}; + +#endif diff --git a/tools/release/ltsview/infodock.h b/tools/release/ltsview/include/ui/infodock.h similarity index 100% rename from tools/release/ltsview/infodock.h rename to tools/release/ltsview/include/ui/infodock.h diff --git a/tools/release/ltsview/mainwindow.h b/tools/release/ltsview/include/ui/mainwindow.h similarity index 95% rename from tools/release/ltsview/mainwindow.h rename to tools/release/ltsview/include/ui/mainwindow.h index 10a7ad499d..f37c40706c 100644 --- a/tools/release/ltsview/mainwindow.h +++ b/tools/release/ltsview/include/ui/mainwindow.h @@ -23,6 +23,9 @@ #include "settingsdialog.h" #include "settingsdock.h" #include "simdock.h" +#include "graphicsinfodialog.h" + +#include class MainWindow : public QMainWindow { @@ -43,6 +46,8 @@ class MainWindow : public QMainWindow void setStatusBar(QString message) { m_ui.statusbar->showMessage(message); } void clearStatusBar() { m_ui.statusbar->clearMessage(); } + void updateGraphicsInfo(); + void startRendering() { setStatusBar("Rendering..."); } void loadingLts() { setProgress(0, "Loading file"); } void rankingStates() { setProgress(1, "Ranking states"); } @@ -76,7 +81,6 @@ class MainWindow : public QMainWindow private: Ui::MainWindow m_ui; - Settings m_settings; LtsManager *m_ltsManager; MarkManager *m_markManager; InfoDock *m_infoDock; @@ -86,6 +90,8 @@ class MainWindow : public QMainWindow SettingsDialog *m_settingsDialog; LtsCanvas *m_ltsCanvas; QProgressDialog *m_progressDialog; + GraphicsInfoDialog *m_graphics_info_dialog; + mcrl2::gui::qt::LogRelay m_logRelay; mcrl2::gui::qt::PersistentFileDialog m_fileDialog; diff --git a/tools/release/ltsview/markdock.h b/tools/release/ltsview/include/ui/markdock.h similarity index 100% rename from tools/release/ltsview/markdock.h rename to tools/release/ltsview/include/ui/markdock.h diff --git a/tools/release/ltsview/markstateruledialog.h b/tools/release/ltsview/include/ui/markstateruledialog.h similarity index 100% rename from tools/release/ltsview/markstateruledialog.h rename to tools/release/ltsview/include/ui/markstateruledialog.h diff --git a/tools/release/ltsview/savepicturedialog.h b/tools/release/ltsview/include/ui/savepicturedialog.h similarity index 100% rename from tools/release/ltsview/savepicturedialog.h rename to tools/release/ltsview/include/ui/savepicturedialog.h diff --git a/tools/release/ltsview/settingsdialog.h b/tools/release/ltsview/include/ui/settingsdialog.h similarity index 92% rename from tools/release/ltsview/settingsdialog.h rename to tools/release/ltsview/include/ui/settingsdialog.h index 058412ac1e..a1c9d5de02 100644 --- a/tools/release/ltsview/settingsdialog.h +++ b/tools/release/ltsview/include/ui/settingsdialog.h @@ -35,7 +35,7 @@ class SettingsDialog : public QDialog Q_OBJECT public: - SettingsDialog(QWidget *parent, Settings *settings); + SettingsDialog(QWidget *parent); private: void setupSpinbox(QSpinBox *spinbox, Settings::SettingInt &setting); @@ -43,7 +43,6 @@ class SettingsDialog : public QDialog private: Ui::SettingsDialog m_ui; - Settings *m_settings; }; #endif diff --git a/tools/release/ltsview/settingsdock.h b/tools/release/ltsview/include/ui/settingsdock.h similarity index 93% rename from tools/release/ltsview/settingsdock.h rename to tools/release/ltsview/include/ui/settingsdock.h index f8ce209b37..e4bab79da2 100644 --- a/tools/release/ltsview/settingsdock.h +++ b/tools/release/ltsview/include/ui/settingsdock.h @@ -35,7 +35,7 @@ class SettingsDock : public QWidget Q_OBJECT public: - SettingsDock(QWidget *parent, Settings *settings); + SettingsDock(QWidget *parent); private slots: void stateSizeChanged(int value); @@ -50,7 +50,6 @@ class SettingsDock : public QWidget private: Ui::SettingsDock m_ui; - Settings *m_settings; }; #endif diff --git a/tools/release/ltsview/simdock.h b/tools/release/ltsview/include/ui/simdock.h similarity index 100% rename from tools/release/ltsview/simdock.h rename to tools/release/ltsview/include/ui/simdock.h diff --git a/tools/release/ltsview/include/ui/ui_files/graphicsinfodialog.ui b/tools/release/ltsview/include/ui/ui_files/graphicsinfodialog.ui new file mode 100644 index 0000000000..8abd0b7225 --- /dev/null +++ b/tools/release/ltsview/include/ui/ui_files/graphicsinfodialog.ui @@ -0,0 +1,69 @@ + + + graphicsDebugInfoDialog + + + + 0 + 0 + 550 + 300 + + + + Graphics Info + + + + + 0 + 0 + 551 + 301 + + + + + + + + 0 + 0 + + + + + 250 + 0 + + + + true + + + Graphics information will show here... + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + Qt::ScrollBarAlwaysOn + + + true + + + + + + + + + diff --git a/tools/release/ltsview/infodock.ui b/tools/release/ltsview/include/ui/ui_files/infodock.ui similarity index 100% rename from tools/release/ltsview/infodock.ui rename to tools/release/ltsview/include/ui/ui_files/infodock.ui diff --git a/tools/release/ltsview/mainwindow.ui b/tools/release/ltsview/include/ui/ui_files/mainwindow.ui similarity index 96% rename from tools/release/ltsview/mainwindow.ui rename to tools/release/ltsview/include/ui/ui_files/mainwindow.ui index 73943378eb..6b342a3f97 100644 --- a/tools/release/ltsview/mainwindow.ui +++ b/tools/release/ltsview/include/ui/ui_files/mainwindow.ui @@ -31,7 +31,7 @@ 0 0 1280 - 23 + 22 @@ -68,6 +68,8 @@ + + @@ -224,6 +226,11 @@ &Preferences... + + + Show graphics info + + diff --git a/tools/release/ltsview/markdock.ui b/tools/release/ltsview/include/ui/ui_files/markdock.ui similarity index 100% rename from tools/release/ltsview/markdock.ui rename to tools/release/ltsview/include/ui/ui_files/markdock.ui diff --git a/tools/release/ltsview/markstateruledialog.ui b/tools/release/ltsview/include/ui/ui_files/markstateruledialog.ui similarity index 100% rename from tools/release/ltsview/markstateruledialog.ui rename to tools/release/ltsview/include/ui/ui_files/markstateruledialog.ui diff --git a/tools/release/ltsview/savepicturedialog.ui b/tools/release/ltsview/include/ui/ui_files/savepicturedialog.ui similarity index 100% rename from tools/release/ltsview/savepicturedialog.ui rename to tools/release/ltsview/include/ui/ui_files/savepicturedialog.ui diff --git a/tools/release/ltsview/settingsdialog.ui b/tools/release/ltsview/include/ui/ui_files/settingsdialog.ui similarity index 52% rename from tools/release/ltsview/settingsdialog.ui rename to tools/release/ltsview/include/ui/ui_files/settingsdialog.ui index 366e1a0636..55942702c2 100644 --- a/tools/release/ltsview/settingsdialog.ui +++ b/tools/release/ltsview/include/ui/ui_files/settingsdialog.ui @@ -6,15 +6,15 @@ 0 0 - 434 - 315 + 358 + 309 Settings - - + + 0 @@ -23,240 +23,250 @@ Colors - - - - - - - Transparency: - - - transparency - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - Background: - - - backgroundColor - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - States: - - - stateColor - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - Transitions: - - - transitionColor - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - Backpointers: - - - backpointerColor - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - Mark: - - - markColor - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - Cluster range: - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Long interpolation - - - - - - - - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - + + + + + Transparency: + + + transparency + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Background: + + + backgroundColor + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + States: + + + stateColor + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + Transitions: + + + transitionColor + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + Backpointers: + + + backpointerColorTo + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Long interpolation + + + + + + + + + + + + + + + + + + + + + Mark: + + + markColor + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + Cluster range: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Long interpolation + + + + + + + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 41 + + + @@ -487,7 +497,7 @@ backgroundColor stateColor transitionColor - backpointerColor + backpointerColorTo markColor longInterpolation clusterColorTop diff --git a/tools/release/ltsview/settingsdock.ui b/tools/release/ltsview/include/ui/ui_files/settingsdock.ui similarity index 100% rename from tools/release/ltsview/settingsdock.ui rename to tools/release/ltsview/include/ui/ui_files/settingsdock.ui diff --git a/tools/release/ltsview/simdock.ui b/tools/release/ltsview/include/ui/ui_files/simdock.ui similarity index 100% rename from tools/release/ltsview/simdock.ui rename to tools/release/ltsview/include/ui/ui_files/simdock.ui diff --git a/tools/release/ltsview/vectors.h b/tools/release/ltsview/include/vectors.h similarity index 100% rename from tools/release/ltsview/vectors.h rename to tools/release/ltsview/include/vectors.h diff --git a/tools/release/ltsview/conedb.h b/tools/release/ltsview/include/visualizer/conedb.h similarity index 100% rename from tools/release/ltsview/conedb.h rename to tools/release/ltsview/include/visualizer/conedb.h diff --git a/tools/release/ltsview/include/visualizer/generic_visualizer/cameras/arcballcamera.h b/tools/release/ltsview/include/visualizer/generic_visualizer/cameras/arcballcamera.h new file mode 100644 index 0000000000..f73ad3d402 --- /dev/null +++ b/tools/release/ltsview/include/visualizer/generic_visualizer/cameras/arcballcamera.h @@ -0,0 +1,76 @@ +// Author(s): Rimco Boudewijns and Sjoerd Cranen +// Generalized by Ruben Vink +// Copyright: see the accompanying file COPYING or copy at +// https://github.com/mCRL2org/mCRL2/blob/master/COPYING +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef MCRL2_OPENGL_ARCBALLCAMERA_H +#define MCRL2_OPENGL_ARCBALLCAMERA_H + +#include "glcamera.h" +#include +#include +#include + +/// \brief The arcball is a camera that moves along the surface of three-dimensional sphere of radius 'zoom'. The center +/// of the sphere can move and the camera can move along the surface by applying a rotation. This viewport +/// also contains the width and height of the window. From this it computes the necessary projection +/// and view matrices to draw objects as if they are viewed from this camera. The assumption is that the camera +/// is always upright towards the z-axis. It also uses a perspective projection where objects further away appear +/// smaller. +class ArcballCamera : Camera +{ +public: + /// \brief Update the view and projection matrix. + void update() override; + + /// \brief Set the distance to the camera position. + void setZoom(float zoom) { m_zoom = zoom; } + float getZoom() const { return m_zoom; } + + /// \brief Set the rotation around the camera position. + void setRotation(const QQuaternion& rotation) { m_rotation = rotation; } + const QQuaternion& getRotation() const { return m_rotation; } + + /// \brief Set the position of the camera. + void setCenter(const QVector3D& center) { m_center = center; } + const QVector3D& getCenter() const { return m_center; } + + /// \brief Sets the position and orientation of the camera to its default values. + void reset(); + /// \brief Sets the rotation of the camera to its default value. + void resetRotation(); + + /// \returns The maximum view distance of this camera. + float getViewdistance() const { return m_viewdistance; } + void setViewdistance(float viewdistance) { m_viewdistance = viewdistance; } + +private: + /// \brief Center of the arcball. + QVector3D m_center = ArcballCamera::DEFAULT_CENTER; + + /// \brief Rotation around the center. + QQuaternion m_rotation = ArcballCamera::DEFAULT_ROTATION; + + /// \brief Distance to the center. + float m_zoom = ArcballCamera::DEFAULT_ZOOM; + + float m_viewdistance = ArcballCamera::DEFAULT_VIEWDISTANCE; + float m_vert_fieldofview = ArcballCamera::DEFAULT_VERTFIELDOFVIEW; +public: + // Default values + static constexpr float DEFAULT_VIEWDISTANCE = 10000.0f; + static constexpr float DEFAULT_VERTFIELDOFVIEW = 55.0f; + static constexpr float DEFAULT_ZOOM = 700.0f; + static QQuaternion DEFAULT_ROTATION; + static QVector3D DEFAULT_CENTER; + +}; +QQuaternion ArcballCamera::DEFAULT_ROTATION = QQuaternion(1.0f, 0.0f, 0.0f, 0.0f); +QVector3D ArcballCamera::DEFAULT_CENTER = QVector3D(0, 0, 0); + +#endif // MCRL2_LTSGRAPH_CAMERA_H diff --git a/tools/release/ltsview/include/visualizer/generic_visualizer/cameras/glcamera.h b/tools/release/ltsview/include/visualizer/generic_visualizer/cameras/glcamera.h new file mode 100644 index 0000000000..7cf09a5e7e --- /dev/null +++ b/tools/release/ltsview/include/visualizer/generic_visualizer/cameras/glcamera.h @@ -0,0 +1,58 @@ +// Author(s): Ruben Vink. +// Copyright: see the accompanying file COPYING or copy at +// https://github.com/mCRL2org/mCRL2/blob/master/COPYING +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef MCRL2_OPENGL_CAMERA_H +#define MCRL2_OPENGL_CAMERA_H + +#include +#include + +/// \brief Camera is an abstract class defining what cameras should implement +/// in order to work with the OpenGL structure. +class Camera +{ + public: + /// \brief Converts the given position from world space coordinates to + /// projection space coordinates. Uses OpenGL coordinates \param ws_vector + /// WorldSpace_vector \returns Position of ws_vector in projection space + QVector3D worldToWindow(QVector3D ws_vector) const + { + return ws_vector.project(m_viewMatrix, m_projectionMatrix, m_viewport); + } + + /// \brief Converts the given position from projection space coordinates to + /// world space coordinates. + QVector3D windowToWorld(QVector3D proj_vector) const + { + return proj_vector.unproject(m_viewMatrix, m_projectionMatrix, m_viewport); + } + + // Getters for various properties + QVector3D getPosition() const { return m_worldPosition; } + const QMatrix4x4& getViewMatrix() const { return m_viewMatrix; } + const QMatrix4x4& getProjectionMatrix() const { return m_projectionMatrix; } + const QRect& getViewport() const { return m_viewport; } + + // setters for various properties + void setPosition(const QVector3D& position) { m_worldPosition = position; } + void setViewport(std::size_t width, std::size_t height) { m_viewport = QRect(0, 0, width, height); } + + // virtual functions + virtual void reset(); + virtual void update() = 0; + protected: + // Matrices to be sent to GPU for rendering + QMatrix4x4 m_projectionMatrix; // view -> projection + QMatrix4x4 m_viewMatrix; // world -> view + // Properties of camera + QVector3D m_worldPosition; + QRect m_viewport; +}; + +#endif \ No newline at end of file diff --git a/tools/release/ltsview/include/visualizer/generic_visualizer/glrenderer.h b/tools/release/ltsview/include/visualizer/generic_visualizer/glrenderer.h new file mode 100644 index 0000000000..1bf2c004ae --- /dev/null +++ b/tools/release/ltsview/include/visualizer/generic_visualizer/glrenderer.h @@ -0,0 +1,42 @@ +// Author(s): Ruben Vink. +// Copyright: see the accompanying file COPYING or copy at +// https://github.com/mCRL2org/mCRL2/blob/master/COPYING +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef MCRL2_OPENGL_RENDERER_H +#define MCRL2_OPENGL_RENDERER_H + +#include "glscenegraph.h" +#include +#include + +/// \brief Objects of type renderer represent a pipeline of shaders. +template +class Renderer : private QOpenGLShaderProgram +{ + public: + void initialize(SceneGraph* scenegraph); + void forceInitialize(SceneGraph* scenegraph); + + virtual void update(); + // in general usage as follows: + // painter.beginNativePainting() + // ~ OpenGL code + // painter.endNativePainting() + // ~ Draw some text using QPainter + virtual void render(QPainter& painter) = 0; + // used to clear buffers etc. + virtual void rebuild(SceneGraph* scenegraph) = 0; + + + private: + virtual void intializeShaders(); + virtual void initializeData(SceneGraph* scenegraph); + bool m_initialized = false; +}; + +#endif // MCRL2_OPENGL_RENDERER_H \ No newline at end of file diff --git a/tools/release/ltsview/include/visualizer/generic_visualizer/glscene.h b/tools/release/ltsview/include/visualizer/generic_visualizer/glscene.h new file mode 100644 index 0000000000..89ce0b4b93 --- /dev/null +++ b/tools/release/ltsview/include/visualizer/generic_visualizer/glscene.h @@ -0,0 +1,64 @@ +// Author(s): Ruben Vink. +// Copyright: see the accompanying file COPYING or copy at +// https://github.com/mCRL2org/mCRL2/blob/master/COPYING +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// Abstracted from ltsgraph/glscene.h (02/08/2022) + +#ifndef MCRL2_OPENGL_GLSCENE_H +#define MCRL2_OPENGL_GLSCENE_H + +#include +#include +#include +#include +#include +#include + +#include "glscenegraph.h" +#include "glrenderer.h" + +class Camera; + +template +class GLScene : private QOpenGLFunctions_3_3_Core +{ +public: + /// \brief Constructor. + /// \param glwidget The widget where this scene is drawn + /// \param scenegraph The scenegraph that is to be drawn. + /// \param cam Camera to be used + GLScene(QOpenGLWidget& glwidget, SceneGraph* scenegraph, Camera* camera, Renderer* renderer) : + m_glwidget(glwidget), + m_scenegraph(scenegraph), + m_camera(camera), + m_renderer(renderer) {} + + /// \brief Initializes all state and data required for rendering. + void initialize(); + + /// \brief Updates the state of the scene. + void update(); + + /// \brief Builds static data based on the current data. + void rebuild(); + + /// \brief Render the scene. + void render(QPainter& painter); + + /// \brief Resize the OpenGL viewport. + void resize(std::size_t width, std::size_t height); + +private: + Camera* m_camera; + SceneGraph* m_scenegraph; + Renderer* m_renderer; + QOpenGLWidget& m_glwidget; /// The widget where this scene is drawn + + float m_device_pixel_ratio; + QFont m_font; +}; +#endif // MCRL2_OPENGL_GLSCENE_H diff --git a/tools/release/ltsview/include/visualizer/generic_visualizer/glscenegraph.h b/tools/release/ltsview/include/visualizer/generic_visualizer/glscenegraph.h new file mode 100644 index 0000000000..1f2eb702b1 --- /dev/null +++ b/tools/release/ltsview/include/visualizer/generic_visualizer/glscenegraph.h @@ -0,0 +1,57 @@ +// Author(s): Ruben Vink. +// Copyright: see the accompanying file COPYING or copy at +// https://github.com/mCRL2org/mCRL2/blob/master/COPYING +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// Abstracted from ltsgraph/glscene.h (02/08/2022) + +#ifndef MCRL2_OPENGL_GLSCENEGRAPH_H +#define MCRL2_OPENGL_GLSCENEGRAPH_H + +#include +#include +#include + +namespace{ + template + struct SceneGraphNode{ + NodeData* data; + SceneGraphNode* parent; + std::vector children; + }; +} + +struct AbstractSceneModelData{ + std::string name; + uint dirty = 0; // Use bit flags to set what part is dirty. Implementation specific + virtual void toGPU() = 0; +}; + +template < typename T > +struct SceneModelData : AbstractSceneModelData{ + void toGPU(QOpenGLShaderProgram& shader_program){ + if (dirty != 0){ + fix(); + dirty = 0; + } + } + void fix(); + T data; +}; + +template +class SceneGraph{ +public: + SceneGraphNode* root; + ModelData model_data; + // updates any changed parts of the scenegraph + void update(); + + // completely builds the scenegraph properties + void rebuild(); +}; + +#endif \ No newline at end of file diff --git a/tools/release/ltsview/include/visualizer/generic_visualizer/glutil.h b/tools/release/ltsview/include/visualizer/generic_visualizer/glutil.h new file mode 100644 index 0000000000..e24844b72f --- /dev/null +++ b/tools/release/ltsview/include/visualizer/generic_visualizer/glutil.h @@ -0,0 +1,35 @@ +// Author(s): Ruben Vink. +// Copyright: see the accompanying file COPYING or copy at +// https://github.com/mCRL2org/mCRL2/blob/master/COPYING +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef MCRL2_OPENGL_GLUTIL_H +#define MCRL2_OPENGL_GLUTIL_H + +#include +#include + +class GlUtil{ +public: + /** + * \brief Calculates control points for the arc described by a origin, handle and destination node. + * \param from Position of the starting point of the arc. + * \param via Position of the handle associated with the arc. + * \param to Position of the end point of the arc. + * \param selfLoop True if the arc represents a self loop. + * \returns Four points describing a cubic Bezier curve (start, control1, control2, end). + */ + static constexpr std::array calculateArc(const QVector3D& from, const QVector3D& via, + const QVector3D& to, bool selfLoop); + +private: + // make constructor private so we don't make objects of this type + GlUtil() {} +}; + + +#endif \ No newline at end of file diff --git a/tools/release/ltsview/include/visualizer/generic_visualizer/vistree.h b/tools/release/ltsview/include/visualizer/generic_visualizer/vistree.h new file mode 100644 index 0000000000..b293393ea5 --- /dev/null +++ b/tools/release/ltsview/include/visualizer/generic_visualizer/vistree.h @@ -0,0 +1,132 @@ +// Author(s): Ruben Vink. +// Copyright: see the accompanying file COPYING or copy at +// https://github.com/mCRL2org/mCRL2/blob/master/COPYING +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +#pragma once +#include +#include + +#ifndef MCRL2_OPENGL_VISTREE_H +#define MCRL2_OPENGL_VISTREE_H + +struct Shape; + + +namespace VisTree{ + + enum ShapeType{ + SPHERE, + HEMISPHERE, + TUBE, + CONE, + TRUNCATED_CONE, + OBLIQUE_CONE, + DISC, + RING, + }; + + struct Shape{ + ShapeType shape; + QMatrix4x4 matrix; + }; + + struct VisTreeNode{ + Shape shape; + VisTreeNode* parent; + std::vector children; + }; + + + namespace Shapes{ + struct Sphere : Shape{ + VisTree::ShapeType shape = VisTree::ShapeType::SPHERE; + float radius; + }; + struct HemiSphere : Shape{ + VisTree::ShapeType shape = VisTree::ShapeType::HEMISPHERE; + float radius; + }; + + // without transform a tube is formed by circle in the xy0 and xy1 planes + struct Tube : Shape{ + VisTree::ShapeType shape = VisTree::ShapeType::TUBE; + float radius; + float height; + }; + + // without transform a cone is formed by a cirle in the xy0 plane and a point at 001 + struct Cone : Shape{ + VisTree::ShapeType shape = VisTree::ShapeType::CONE; + float radius; + float height; + }; + + // without transform a disc is formed by a circle in the xy0 plane (filled) + struct Disc : Shape{ + VisTree::ShapeType shape = VisTree::ShapeType::DISC; + float radius; + }; + + // without transform a disc is formed by a circle in the xy0 plane (not filled) + struct Ring : Shape{ + VisTree::ShapeType shape = VisTree::ShapeType::RING; + float radius; + }; + + // Suppose we have an untransformed cone with a certain radius and height + // We can truncate the cone by 'cutting' it open using two planes at z=a and z=b + // This results in 4 options: + // - a and b both miss -> regular cone + // - bottom is sliced off -> truncate + // - top is sliced off -> truncate + // - both are sliced off -> truncate + // For every case where we truncate we can either fill or not fill the resulting cut + // i.e. ring/disc + struct TruncatedCone : Shape{ + VisTree::ShapeType shape = VisTree::ShapeType::TRUNCATED_CONE; + float radius_bot, radius_top; + float height; + float bot, top; // if bot \in (0, height) a cut occurs + bool fill_bot, fill_top; + }; + + + // Think of a regular cone, but move the tip off-axis + // In this case, untransformed: + // - tip = height*(cos(alpha), sin(alpha), 0) with alpha in [0, 90] degrees + struct ObliqueCone : Shape{ + VisTree::ShapeType shape = VisTree::ShapeType::OBLIQUE_CONE; + float radius; + float height; + float alpha; // in degrees + }; + } + + + template < typename InputTreeType, typename Functor, typename Iterator > + void recurse(VisTreeNode* parent, InputTreeType* current, Functor& f, std::function& getChildIterator){ + VisTreeNode* node = f(parent, current); + node->parent = parent; + parent->children.emplace_back(node); + for(auto child_it = getChildIterator(current); child_it.it != child_it.it_end; ++child_it) + recurse(node, *child_it, f, getChildIterator); + } + + template < typename InputTreeType, typename Functor, typename Iterator > + VisTree::VisTreeNode* generateVisTree(InputTreeType* root, Functor& f, std::function& getChildIterator){ + VisTreeNode* node = f(nullptr, root); + node->parent = nullptr; // this is the root of the vistree + for(auto child_it = getChildIterator(root); child_it.it != child_it.it_end; ++child_it) + VisTree::recurse(node, *child_it, f, getChildIterator); + return node; + } +} + + + + +#endif diff --git a/tools/release/ltsview/ltscanvas.h b/tools/release/ltsview/include/visualizer/ltscanvas.h similarity index 88% rename from tools/release/ltsview/ltscanvas.h rename to tools/release/ltsview/include/visualizer/ltscanvas.h index c98fd55359..503efd1c96 100644 --- a/tools/release/ltsview/ltscanvas.h +++ b/tools/release/ltsview/include/visualizer/ltscanvas.h @@ -9,6 +9,7 @@ #ifndef LTSCANVAS_H #define LTSCANVAS_H +// #include #include #include #include @@ -17,6 +18,9 @@ #include #include +#include +#include + #include "visualizer.h" class LtsCanvas : public QOpenGLWidget @@ -29,7 +33,7 @@ class LtsCanvas : public QOpenGLWidget struct Selection { State* state; Cluster* cluster; }; public: - LtsCanvas(QWidget* parent, Settings* settings, LtsManager* ltsManager, MarkManager* markManager); + LtsCanvas(QWidget* parent, LtsManager* ltsManager, MarkManager* markManager); int viewWidth() const { return m_width; } int viewHeight() const { return m_height; } @@ -68,7 +72,6 @@ class LtsCanvas : public QOpenGLWidget void renderingFinished(); private: - Settings* m_settings; LtsManager* m_ltsManager; Visualizer* m_visualizer; @@ -87,6 +90,12 @@ class LtsCanvas : public QOpenGLWidget Tool m_activeTool; bool m_dragging; QPoint m_lastMousePosition; + + // graphics info variables + QLinkedList frame_times; + double measuring_time = 1; // [s] + public: + QString graphics_info; }; #endif diff --git a/tools/release/ltsview/include/visualizer/ltsview_visualizer/scenegraphgenerator.h b/tools/release/ltsview/include/visualizer/ltsview_visualizer/scenegraphgenerator.h new file mode 100644 index 0000000000..4258805bce --- /dev/null +++ b/tools/release/ltsview/include/visualizer/ltsview_visualizer/scenegraphgenerator.h @@ -0,0 +1,123 @@ +// Author(s): Ruben Vink +// Copyright: see the accompanying file COPYING or copy at +// https://github.com/mCRL2org/mCRL2/blob/master/COPYING +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef MCRL2_OPENGL_SCENEGRAPHGENERATOR_H +#define MCRL2_OPENGL_SCENEGRAPHGENERATOR_H + +#include +#include +#include +#include +#include "glscenegraph.h" +#include "vistree.h" +#include "settings.h" +#include +#include +#include "cluster.h" + +class Cluster; + +namespace +{ + struct NodeData + { + int model_data_id; + int model_matrix_id; + }; + + struct ModelData{ + int model_id; + QMatrix4x4 model_matrix; + }; + + struct Model + { + int n_vertices; + float* vertices; + int n_triangles; + int* triangles; + }; + + std::string qvec4ToString(QVector4D vec){ + return "(" + std::to_string(vec.x()) + ", " + + std::to_string(vec.y()) + ", " + + std::to_string(vec.z()) + ", " + + std::to_string(vec.w()) + ")"; + } +} // namespace + + +struct ConeConvertFunctor{ + QMatrix4x4 current_matrix = QMatrix4x4(); + + void matrixScale(float x, float y, float z); + + void matrixTranslate(float x, float y, float z); + + void matrixTranslate(const QVector3D& v); + + void matrixRotate(float angle, float x, float y, float z); + + bool topClosed = true; + float rot = 0; + VisTree::VisTreeNode* operator()(VisTree::VisTreeNode* parent, Cluster* cluster); + + VisTree::Shape noChildren(Cluster* cluster, bool topClosed, int rot); +}; + +// TODO: Implement +struct TubeConvertFunctor{ + VisTree::VisTreeNode* operator()(VisTree::VisTreeNode* parent, Cluster* cluster); +}; + +struct ClusterChildIterator{ + std::vector::iterator it; + std::vector::iterator it_end; + + std::vector::iterator operator++(); + Cluster* operator*(); +}; + +ClusterChildIterator getClusterChildIterator(Cluster* cluster); + +typedef SceneGraph SG; + +template < typename Functor > +VisTree::VisTreeNode* generateClusterTree(Cluster* root){ + Functor f = Functor(); + auto getIterator = std::function(getClusterChildIterator); + return VisTree::generateVisTree(root, f, getIterator); +} + + + +class SceneGraphGenerator +{ + public: + SceneGraphGenerator(Cluster* root) : m_clusterRoot(root) {}; + + enum Mode + { + TUBES, + CONES, + }; + SG* generate(Mode mode); + + private: + // This should hold all data needed to invoke shaders i.e. verts/tris for general case + SG* m_sceneGraph; + // This is generated for specific case + VisTree::VisTreeNode* m_visTreeRoot; + Cluster* m_clusterRoot; + + SG* generateTubes(Cluster* root); + + SG* generateCones(Cluster* root); +}; + +#endif \ No newline at end of file diff --git a/tools/release/ltsview/primitivefactory.h b/tools/release/ltsview/include/visualizer/primitivefactory.h similarity index 95% rename from tools/release/ltsview/primitivefactory.h rename to tools/release/ltsview/include/visualizer/primitivefactory.h index 965aee65f5..5a0509f2ab 100644 --- a/tools/release/ltsview/primitivefactory.h +++ b/tools/release/ltsview/include/visualizer/primitivefactory.h @@ -24,7 +24,7 @@ class PrimitiveFactory: public QObject Q_OBJECT public: - PrimitiveFactory(Settings* ss); + PrimitiveFactory(); ~PrimitiveFactory(); void drawPrimitive(int p); void drawSimpleSphere(); @@ -42,7 +42,6 @@ class PrimitiveFactory: public QObject std::vector primitives; std::vector oblq_cones; ConeDB* coneDB; - Settings* settings; int disc; int simple_sphere; int sphere; diff --git a/tools/release/ltsview/primitives.h b/tools/release/ltsview/include/visualizer/primitives.h similarity index 100% rename from tools/release/ltsview/primitives.h rename to tools/release/ltsview/include/visualizer/primitives.h diff --git a/tools/release/ltsview/visobjectfactory.h b/tools/release/ltsview/include/visualizer/visobjectfactory.h similarity index 100% rename from tools/release/ltsview/visobjectfactory.h rename to tools/release/ltsview/include/visualizer/visobjectfactory.h diff --git a/tools/release/ltsview/visualizer.h b/tools/release/ltsview/include/visualizer/visualizer.h similarity index 95% rename from tools/release/ltsview/visualizer.h rename to tools/release/ltsview/include/visualizer/visualizer.h index ce09183b73..37cc882161 100644 --- a/tools/release/ltsview/visualizer.h +++ b/tools/release/ltsview/include/visualizer/visualizer.h @@ -25,7 +25,7 @@ class Visualizer: public QObject Q_OBJECT public: - Visualizer(QObject *parent, Settings* settings_, LtsManager *ltsManager_, MarkManager* markManager_); + Visualizer(QObject *parent, LtsManager *ltsManager_, MarkManager* markManager_); void computeBoundsInfo(float& bcw,float& bch); float getHalfStructureHeight() const; @@ -57,7 +57,6 @@ class Visualizer: public QObject void dirtied(); private: - Settings* settings; LtsManager *ltsManager; MarkManager* markManager; VisObjectFactory visObjectFactory; diff --git a/tools/release/ltsview/cluster.cpp b/tools/release/ltsview/source/cluster.cpp similarity index 100% rename from tools/release/ltsview/cluster.cpp rename to tools/release/ltsview/source/cluster.cpp diff --git a/tools/release/ltsview/fsm_state_positioner.cpp b/tools/release/ltsview/source/fsm_state_positioner.cpp similarity index 100% rename from tools/release/ltsview/fsm_state_positioner.cpp rename to tools/release/ltsview/source/fsm_state_positioner.cpp diff --git a/tools/release/ltsview/lts.cpp b/tools/release/ltsview/source/lts.cpp similarity index 100% rename from tools/release/ltsview/lts.cpp rename to tools/release/ltsview/source/lts.cpp diff --git a/tools/release/ltsview/ltsmanager.cpp b/tools/release/ltsview/source/ltsmanager.cpp similarity index 92% rename from tools/release/ltsview/ltsmanager.cpp rename to tools/release/ltsview/source/ltsmanager.cpp index 5092632047..d2b3842608 100644 --- a/tools/release/ltsview/ltsmanager.cpp +++ b/tools/release/ltsview/source/ltsmanager.cpp @@ -41,7 +41,7 @@ void LtsManagerHelper::loadLts(QString filename) void LtsManagerHelper::clusterStates(LTS *lts) { - bool cyclic = m_settings->stateRankStyleCyclic.value(); + bool cyclic = Settings::instance().stateRankStyleCyclic.value(); emit rankingStates(); lts->rankStates(cyclic); emit clusteringStates(); @@ -54,22 +54,20 @@ void LtsManagerHelper::clusterStates(LTS *lts) void LtsManagerHelper::positionClusters(LTS *lts) { emit positioningClusters(); - lts->positionClusters(m_settings->fsmStyle.value()); + lts->positionClusters(Settings::instance().fsmStyle.value()); positionStates(lts); } void LtsManagerHelper::positionStates(LTS *lts) { emit positioningStates(); - lts->positionStates(m_settings->statePosStyleMultiPass.value()); + lts->positionStates(Settings::instance().statePosStyleMultiPass.value()); m_lts = lts; emit finished(); } -LtsManager::LtsManager(QObject *parent, Settings *settings, QThread *atermThread): +LtsManager::LtsManager(QObject *parent, QThread *atermThread): QObject(parent), - m_helper(settings), - m_settings(settings), m_lts(0), m_simulation(nullptr), m_selectedState(0), @@ -84,9 +82,9 @@ LtsManager::LtsManager(QObject *parent, Settings *settings, QThread *atermThread connect(&m_helper, SIGNAL(positioningClusters()), this, SIGNAL(positioningClusters())); connect(&m_helper, SIGNAL(positioningStates()), this, SIGNAL(positioningStates())); - connect(&settings->stateRankStyleCyclic, SIGNAL(changed(bool)), this, SLOT(clusterStates())); - connect(&settings->fsmStyle, SIGNAL(changed(bool)), this, SLOT(positionClusters())); - connect(&settings->statePosStyleMultiPass, SIGNAL(changed(bool)), this, SLOT(positionStates())); + connect(&Settings::instance().stateRankStyleCyclic, SIGNAL(changed(bool)), this, SLOT(clusterStates())); + connect(&Settings::instance().fsmStyle, SIGNAL(changed(bool)), this, SLOT(positionClusters())); + connect(&Settings::instance().statePosStyleMultiPass, SIGNAL(changed(bool)), this, SLOT(positionStates())); } State *LtsManager::currentSimulationState() const diff --git a/tools/release/ltsview/main.cpp b/tools/release/ltsview/source/main.cpp similarity index 100% rename from tools/release/ltsview/main.cpp rename to tools/release/ltsview/source/main.cpp diff --git a/tools/release/ltsview/markmanager.cpp b/tools/release/ltsview/source/markmanager.cpp similarity index 100% rename from tools/release/ltsview/markmanager.cpp rename to tools/release/ltsview/source/markmanager.cpp diff --git a/tools/release/ltsview/rtree.cpp b/tools/release/ltsview/source/rtree.cpp similarity index 100% rename from tools/release/ltsview/rtree.cpp rename to tools/release/ltsview/source/rtree.cpp diff --git a/tools/release/ltsview/simulation.cpp b/tools/release/ltsview/source/simulation.cpp similarity index 100% rename from tools/release/ltsview/simulation.cpp rename to tools/release/ltsview/source/simulation.cpp diff --git a/tools/release/ltsview/sp_state_positioner.cpp b/tools/release/ltsview/source/sp_state_positioner.cpp similarity index 100% rename from tools/release/ltsview/sp_state_positioner.cpp rename to tools/release/ltsview/source/sp_state_positioner.cpp diff --git a/tools/release/ltsview/state.cpp b/tools/release/ltsview/source/state.cpp similarity index 100% rename from tools/release/ltsview/state.cpp rename to tools/release/ltsview/source/state.cpp diff --git a/tools/release/ltsview/transition.cpp b/tools/release/ltsview/source/transition.cpp similarity index 100% rename from tools/release/ltsview/transition.cpp rename to tools/release/ltsview/source/transition.cpp diff --git a/tools/release/ltsview/source/ui/graphicsinfodialog.cpp b/tools/release/ltsview/source/ui/graphicsinfodialog.cpp new file mode 100644 index 0000000000..c1c88934cc --- /dev/null +++ b/tools/release/ltsview/source/ui/graphicsinfodialog.cpp @@ -0,0 +1,17 @@ +// Author(s): Ruben Vink +// Copyright: see the accompanying file COPYING or copy at +// https://github.com/mCRL2org/mCRL2/blob/master/COPYING +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include "graphicsinfodialog.h" + + +GraphicsInfoDialog::GraphicsInfoDialog(QWidget *parent): + QDialog(parent) +{ + m_ui.setupUi(this); + lbl_info = m_ui.lbl_info; +} \ No newline at end of file diff --git a/tools/release/ltsview/infodock.cpp b/tools/release/ltsview/source/ui/infodock.cpp similarity index 100% rename from tools/release/ltsview/infodock.cpp rename to tools/release/ltsview/source/ui/infodock.cpp diff --git a/tools/release/ltsview/mainwindow.cpp b/tools/release/ltsview/source/ui/mainwindow.cpp similarity index 80% rename from tools/release/ltsview/mainwindow.cpp rename to tools/release/ltsview/source/ui/mainwindow.cpp index 654a81e756..703c33ed1d 100644 --- a/tools/release/ltsview/mainwindow.cpp +++ b/tools/release/ltsview/source/ui/mainwindow.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include "mcrl2/lts/lts_io.h" #include "mainwindow.h" @@ -19,15 +20,16 @@ MainWindow::MainWindow(QThread *atermThread): { m_ui.setupUi(this); - m_ltsManager = new LtsManager(this, &m_settings, atermThread); + m_ltsManager = new LtsManager(this, atermThread); m_markManager = new MarkManager(this, m_ltsManager); m_infoDock = new InfoDock(this, m_ltsManager, m_markManager); m_markDock = new MarkDock(this, m_markManager); m_simDock = new SimDock(this, m_ltsManager); - m_settingsDock = new SettingsDock(this, &m_settings); - m_settingsDialog = new SettingsDialog(this, &m_settings); - m_ltsCanvas = new LtsCanvas(this, &m_settings, m_ltsManager, m_markManager); + m_settingsDock = new SettingsDock(this); + m_settingsDialog = new SettingsDialog(this); + m_ltsCanvas = new LtsCanvas(this, m_ltsManager, m_markManager); + m_graphics_info_dialog = new GraphicsInfoDialog(this); setCentralWidget(m_ltsCanvas); m_progressDialog = new QProgressDialog("", QString(), 0, 6, this); m_progressDialog->setMinimumDuration(0); @@ -57,16 +59,17 @@ MainWindow::MainWindow(QThread *atermThread): connect(m_ui.zoomIntoBelow, SIGNAL(triggered()), m_ltsManager, SLOT(zoomInBelow())); connect(m_ui.zoomOut, SIGNAL(triggered()), m_ltsManager, SLOT(zoomOut())); - connect(m_ui.displayStates, SIGNAL(triggered(bool)), &m_settings.displayStates, SLOT(setValue(bool))); - connect(&m_settings.displayStates, SIGNAL(changed(bool)), m_ui.displayStates, SLOT(setChecked(bool))); - connect(m_ui.displayTransitions, SIGNAL(triggered(bool)), &m_settings.displayTransitions, SLOT(setValue(bool))); - connect(&m_settings.displayTransitions, SIGNAL(changed(bool)), m_ui.displayTransitions, SLOT(setChecked(bool))); - connect(m_ui.displayBackpointers, SIGNAL(triggered(bool)), &m_settings.displayBackpointers, SLOT(setValue(bool))); - connect(&m_settings.displayBackpointers, SIGNAL(changed(bool)), m_ui.displayBackpointers, SLOT(setChecked(bool))); - connect(m_ui.displayWireframe, SIGNAL(triggered(bool)), &m_settings.displayWireframe, SLOT(setValue(bool))); - connect(&m_settings.displayWireframe, SIGNAL(changed(bool)), m_ui.displayWireframe, SLOT(setChecked(bool))); + connect(m_ui.displayStates, SIGNAL(triggered(bool)), &Settings::instance().displayStates, SLOT(setValue(bool))); + connect(&Settings::instance().displayStates, SIGNAL(changed(bool)), m_ui.displayStates, SLOT(setChecked(bool))); + connect(m_ui.displayTransitions, SIGNAL(triggered(bool)), &Settings::instance().displayTransitions, SLOT(setValue(bool))); + connect(&Settings::instance().displayTransitions, SIGNAL(changed(bool)), m_ui.displayTransitions, SLOT(setChecked(bool))); + connect(m_ui.displayBackpointers, SIGNAL(triggered(bool)), &Settings::instance().displayBackpointers, SLOT(setValue(bool))); + connect(&Settings::instance().displayBackpointers, SIGNAL(changed(bool)), m_ui.displayBackpointers, SLOT(setChecked(bool))); + connect(m_ui.displayWireframe, SIGNAL(triggered(bool)), &Settings::instance().displayWireframe, SLOT(setValue(bool))); + connect(&Settings::instance().displayWireframe, SIGNAL(changed(bool)), m_ui.displayWireframe, SLOT(setChecked(bool))); connect(m_ui.preferences, SIGNAL(triggered()), m_settingsDialog, SLOT(show())); + connect(m_ui.actionShowGraphicsInfo, SIGNAL(triggered()), m_graphics_info_dialog, SLOT(show())); connect(m_ltsManager, SIGNAL(loadingLts()), this, SLOT(loadingLts())); connect(m_ltsManager, SIGNAL(rankingStates()), this, SLOT(rankingStates())); @@ -87,6 +90,7 @@ MainWindow::MainWindow(QThread *atermThread): connect(m_ltsCanvas, SIGNAL(renderingStarted()), this, SLOT(startRendering())); connect(m_ltsCanvas, SIGNAL(renderingFinished()), this, SLOT(clearStatusBar())); + connect(m_ltsCanvas, SIGNAL(renderingFinished()), this, SLOT(updateGraphicsInfo())); QSettings settings("mCRL2", "LTSView"); restoreGeometry(settings.value("geometry").toByteArray()); @@ -98,6 +102,11 @@ MainWindow::~MainWindow() mcrl2::log::logger::unregister_output_policy(m_logRelay); } +void MainWindow::updateGraphicsInfo(){ + if (!m_ltsCanvas) return; + m_graphics_info_dialog->lbl_info->setText(m_ltsCanvas->graphics_info); +} + void MainWindow::closeEvent(QCloseEvent * /*event*/) { { diff --git a/tools/release/ltsview/markdock.cpp b/tools/release/ltsview/source/ui/markdock.cpp similarity index 100% rename from tools/release/ltsview/markdock.cpp rename to tools/release/ltsview/source/ui/markdock.cpp diff --git a/tools/release/ltsview/markstateruledialog.cpp b/tools/release/ltsview/source/ui/markstateruledialog.cpp similarity index 100% rename from tools/release/ltsview/markstateruledialog.cpp rename to tools/release/ltsview/source/ui/markstateruledialog.cpp diff --git a/tools/release/ltsview/savepicturedialog.cpp b/tools/release/ltsview/source/ui/savepicturedialog.cpp similarity index 100% rename from tools/release/ltsview/savepicturedialog.cpp rename to tools/release/ltsview/source/ui/savepicturedialog.cpp diff --git a/tools/release/ltsview/settingsdialog.cpp b/tools/release/ltsview/source/ui/settingsdialog.cpp similarity index 50% rename from tools/release/ltsview/settingsdialog.cpp rename to tools/release/ltsview/source/ui/settingsdialog.cpp index b6b157ae14..6382a10bb1 100644 --- a/tools/release/ltsview/settingsdialog.cpp +++ b/tools/release/ltsview/source/ui/settingsdialog.cpp @@ -36,31 +36,37 @@ void ColorButtonHandler::setColor() m_button->setStyleSheet(QString("background-color: ") + colorString + "; color: " + colorString + ";"); } -SettingsDialog::SettingsDialog(QWidget *parent, Settings *settings): - QDialog(parent), - m_settings(settings) +SettingsDialog::SettingsDialog(QWidget *parent): + QDialog(parent) { m_ui.setupUi(this); - setupSpinbox(m_ui.transparency, m_settings->transparency); - new ColorButtonHandler(m_ui.backgroundColor, m_settings->backgroundColor); - new ColorButtonHandler(m_ui.stateColor, m_settings->stateColor); - new ColorButtonHandler(m_ui.transitionColor, m_settings->downEdgeColor); - new ColorButtonHandler(m_ui.backpointerColor, m_settings->upEdgeColor); - new ColorButtonHandler(m_ui.markColor, m_settings->markedColor); - new ColorButtonHandler(m_ui.clusterColorTop, m_settings->clusterColorTop); - new ColorButtonHandler(m_ui.clusterColorBottom, m_settings->clusterColorBottom); - setupCheckbox(m_ui.longInterpolation, m_settings->longInterpolation); - new ColorButtonHandler(m_ui.simulationHistoryColor, m_settings->simPrevColor); - new ColorButtonHandler(m_ui.simulationCurrentStateColor, m_settings->simCurrColor); - new ColorButtonHandler(m_ui.simulationSelectedColor, m_settings->simSelColor); - new ColorButtonHandler(m_ui.simulationNextStateColor, m_settings->simPosColor); - setupCheckbox(m_ui.navShowBackpointers, m_settings->navShowBackpointers); - setupCheckbox(m_ui.navShowStates, m_settings->navShowStates); - setupCheckbox(m_ui.navShowTransitions, m_settings->navShowTransitions); - setupCheckbox(m_ui.navSmoothShading, m_settings->navSmoothShading); - setupCheckbox(m_ui.navLighting, m_settings->navLighting); - setupCheckbox(m_ui.navTransparency, m_settings->navTransparency); + setupSpinbox(m_ui.transparency, Settings::instance().transparency); + new ColorButtonHandler(m_ui.backgroundColor, Settings::instance().backgroundColor); + new ColorButtonHandler(m_ui.stateColor, Settings::instance().stateColor); + new ColorButtonHandler(m_ui.transitionColor, Settings::instance().downEdgeColor); + + new ColorButtonHandler(m_ui.backpointerColorTo, Settings::instance().upEdgeColorTo); + new ColorButtonHandler(m_ui.backpointerColorFrom, Settings::instance().upEdgeColorFrom); + setupCheckbox(m_ui.longInterpolation_transition, + Settings::instance().longInterpolationUpEdge); + + new ColorButtonHandler(m_ui.markColor, Settings::instance().markedColor); + + new ColorButtonHandler(m_ui.clusterColorTop, Settings::instance().clusterColorTop); + new ColorButtonHandler(m_ui.clusterColorBottom, Settings::instance().clusterColorBottom); + setupCheckbox(m_ui.longInterpolation, Settings::instance().longInterpolationCluster); + + new ColorButtonHandler(m_ui.simulationHistoryColor, Settings::instance().simPrevColor); + new ColorButtonHandler(m_ui.simulationCurrentStateColor, Settings::instance().simCurrColor); + new ColorButtonHandler(m_ui.simulationSelectedColor, Settings::instance().simSelColor); + new ColorButtonHandler(m_ui.simulationNextStateColor, Settings::instance().simPosColor); + setupCheckbox(m_ui.navShowBackpointers, Settings::instance().navShowBackpointers); + setupCheckbox(m_ui.navShowStates, Settings::instance().navShowStates); + setupCheckbox(m_ui.navShowTransitions, Settings::instance().navShowTransitions); + setupCheckbox(m_ui.navSmoothShading, Settings::instance().navSmoothShading); + setupCheckbox(m_ui.navLighting, Settings::instance().navLighting); + setupCheckbox(m_ui.navTransparency, Settings::instance().navTransparency); } void SettingsDialog::setupSpinbox(QSpinBox *spinbox, Settings::SettingInt &setting) diff --git a/tools/release/ltsview/settingsdock.cpp b/tools/release/ltsview/source/ui/settingsdock.cpp similarity index 61% rename from tools/release/ltsview/settingsdock.cpp rename to tools/release/ltsview/source/ui/settingsdock.cpp index 5a94b9f22c..1d9b16ce0d 100644 --- a/tools/release/ltsview/settingsdock.cpp +++ b/tools/release/ltsview/source/ui/settingsdock.cpp @@ -28,36 +28,35 @@ void ComboboxHandler::setState() m_combobox->setCurrentIndex(m_setting->value() ? 1 : 0); } -SettingsDock::SettingsDock(QWidget *parent, Settings *settings): - QWidget(parent), - m_settings(settings) +SettingsDock::SettingsDock(QWidget *parent): + QWidget(parent) { m_ui.setupUi(this); connect(m_ui.stateSize, SIGNAL(valueChanged(int)), this, SLOT(stateSizeChanged(int))); - connect(&m_settings->stateSize, SIGNAL(changed(float)), this, SLOT(setStateSize(float))); - setStateSize(m_settings->stateSize.value()); + connect(&Settings::instance().stateSize, SIGNAL(changed(float)), this, SLOT(setStateSize(float))); + setStateSize(Settings::instance().stateSize.value()); connect(m_ui.clusterHeight, SIGNAL(valueChanged(int)), this, SLOT(clusterHeightChanged(int))); - connect(&m_settings->clusterHeight, SIGNAL(changed(float)), this, SLOT(setClusterHeight(float))); - setClusterHeight(m_settings->clusterHeight.value()); + connect(&Settings::instance().clusterHeight, SIGNAL(changed(float)), this, SLOT(setClusterHeight(float))); + setClusterHeight(Settings::instance().clusterHeight.value()); - setupSpinbox(m_ui.branchRotation, m_settings->branchRotation); - setupSpinbox(m_ui.branchTilt, m_settings->branchTilt); + setupSpinbox(m_ui.branchRotation, Settings::instance().branchRotation); + setupSpinbox(m_ui.branchTilt, Settings::instance().branchTilt); connect(m_ui.accuracy, SIGNAL(valueChanged(int)), this, SLOT(accuracyChanged(int))); - connect(&m_settings->quality, SIGNAL(changed(int)), this, SLOT(setAccuracy(int))); - setAccuracy(m_settings->quality.value()); + connect(&Settings::instance().quality, SIGNAL(changed(int)), this, SLOT(setAccuracy(int))); + setAccuracy(Settings::instance().quality.value()); - new ComboboxHandler(m_ui.stateRanking, m_settings->stateRankStyleCyclic); - new ComboboxHandler(m_ui.clusterPositioning, m_settings->fsmStyle); - new ComboboxHandler(m_ui.statePositioning, m_settings->statePosStyleMultiPass); - new ComboboxHandler(m_ui.visualizationStyle, m_settings->clusterVisStyleTubes); + new ComboboxHandler(m_ui.stateRanking, Settings::instance().stateRankStyleCyclic); + new ComboboxHandler(m_ui.clusterPositioning, Settings::instance().fsmStyle); + new ComboboxHandler(m_ui.statePositioning, Settings::instance().statePosStyleMultiPass); + new ComboboxHandler(m_ui.visualizationStyle, Settings::instance().clusterVisStyleTubes); } void SettingsDock::stateSizeChanged(int value) { - m_settings->stateSize.setValue(value / 10.0f); + Settings::instance().stateSize.setValue(value / 10.0f); } void SettingsDock::setStateSize(float value) @@ -67,7 +66,7 @@ void SettingsDock::setStateSize(float value) void SettingsDock::clusterHeightChanged(int value) { - m_settings->clusterHeight.setValue(value / 10.0f); + Settings::instance().clusterHeight.setValue(value / 10.0f); } void SettingsDock::setClusterHeight(float value) @@ -77,7 +76,7 @@ void SettingsDock::setClusterHeight(float value) void SettingsDock::accuracyChanged(int value) { - m_settings->quality.setValue(value * 2); + Settings::instance().quality.setValue(value * 2); } void SettingsDock::setAccuracy(int value) diff --git a/tools/release/ltsview/simdock.cpp b/tools/release/ltsview/source/ui/simdock.cpp similarity index 100% rename from tools/release/ltsview/simdock.cpp rename to tools/release/ltsview/source/ui/simdock.cpp diff --git a/tools/release/ltsview/vectors.cpp b/tools/release/ltsview/source/vectors.cpp similarity index 100% rename from tools/release/ltsview/vectors.cpp rename to tools/release/ltsview/source/vectors.cpp diff --git a/tools/release/ltsview/conedb.cpp b/tools/release/ltsview/source/visualizer/conedb.cpp similarity index 100% rename from tools/release/ltsview/conedb.cpp rename to tools/release/ltsview/source/visualizer/conedb.cpp diff --git a/tools/release/ltsview/source/visualizer/generic_visualizer/cameras/arcballcamera.cpp b/tools/release/ltsview/source/visualizer/generic_visualizer/cameras/arcballcamera.cpp new file mode 100644 index 0000000000..d39b0625c6 --- /dev/null +++ b/tools/release/ltsview/source/visualizer/generic_visualizer/cameras/arcballcamera.cpp @@ -0,0 +1,43 @@ +// Author(s): Rimco Boudewijns and Sjoerd Cranen +// Generalized by Ruben Vink +// Copyright: see the accompanying file COPYING or copy at +// https://github.com/mCRL2org/mCRL2/blob/master/COPYING +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#include "arcballcamera.h" + +#include "mcrl2/gui/arcball.h" +#include "mcrl2/gui/glu.h" + +void ArcballCamera::update() +{ + m_viewMatrix.setToIdentity(); + m_viewMatrix.translate(QVector3D(0.0f, 0.0f, -m_zoom)); + m_viewMatrix.rotate(m_rotation); + m_viewMatrix.translate(m_center); + + QMatrix4x4 invertedViewMatrix = m_viewMatrix.inverted(); + m_worldPosition = QVector3D(invertedViewMatrix.column(3)); + + m_projectionMatrix.setToIdentity(); + m_projectionMatrix.perspective(m_vert_fieldofview, static_cast(m_viewport.width()) / static_cast(m_viewport.height()), 1.0f, m_viewdistance); +} + + + + +void ArcballCamera::reset() +{ + m_center = ArcballCamera::DEFAULT_CENTER; + m_rotation = ArcballCamera::DEFAULT_ROTATION; + m_zoom = ArcballCamera::DEFAULT_ZOOM; +} + +void ArcballCamera::resetRotation() +{ + m_rotation = ArcballCamera::DEFAULT_ROTATION; +} diff --git a/tools/release/ltsview/source/visualizer/generic_visualizer/glrenderer.cpp b/tools/release/ltsview/source/visualizer/generic_visualizer/glrenderer.cpp new file mode 100644 index 0000000000..de9cb4e1ea --- /dev/null +++ b/tools/release/ltsview/source/visualizer/generic_visualizer/glrenderer.cpp @@ -0,0 +1,17 @@ +#include "glrenderer.h" +#include "glscenegraph.h" +template +void Renderer::initialize(SceneGraph* scenegraph){ + if (!m_initialized){ + intializeShaders(); + initializeData(scenegraph); + m_initialized = true; + } +} + +template +void Renderer::forceInitialize(SceneGraph* scenegraph){ + intializeShaders(); + initializeData(scenegraph); + m_initialized = true; +} \ No newline at end of file diff --git a/tools/release/ltsview/source/visualizer/generic_visualizer/glscene.cpp b/tools/release/ltsview/source/visualizer/generic_visualizer/glscene.cpp new file mode 100644 index 0000000000..359878957a --- /dev/null +++ b/tools/release/ltsview/source/visualizer/generic_visualizer/glscene.cpp @@ -0,0 +1,51 @@ +// Author(s): Ruben Vink. +// Copyright: see the accompanying file COPYING or copy at +// https://github.com/mCRL2org/mCRL2/blob/master/COPYING +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// Abstracted from ltsgraph/glscene.cpp (02/08/2022) + +#include "glscene.h" +#include "glcamera.h" +#include "glrenderer.h" +#include "glscenegraph.h" + +template +void GLScene::initialize(){ + initializeOpenGLFunctions(); + + m_scenegraph->rebuild(); + m_renderer->initialize(m_scenegraph); +} + +/// \brief Updates the state of the scene. +template +void GLScene::update(){ + m_camera->update(); + m_scenegraph->update(); // often the scenegraph and renderer do not actually + m_renderer->update(); // require update since the image is static +} + +template +void GLScene::rebuild(){ + m_camera->reset(); + m_scenegraph->rebuild(); + m_renderer->rebuild(m_scenegraph); +} + +template +void GLScene::resize(std::size_t width, std::size_t height){ + if (m_camera){ + m_camera->setViewport(width, height); + } +} + +template +void GLScene::render(QPainter& painter){ + // we let the renderer do it's magic + m_renderer->render(painter); +} + diff --git a/tools/release/ltsview/source/visualizer/generic_visualizer/glutil.cpp b/tools/release/ltsview/source/visualizer/generic_visualizer/glutil.cpp new file mode 100644 index 0000000000..846f58ca55 --- /dev/null +++ b/tools/release/ltsview/source/visualizer/generic_visualizer/glutil.cpp @@ -0,0 +1,31 @@ +#include "glutil.h" + + +// Author(s): Rimco Boudewijns and Sjoerd Cranen +/// \brief Takes 3 points and returns 4 control points to be used by an ArcShader +constexpr std::array GlUtil::calculateArc(const QVector3D& from, const QVector3D& via, + const QVector3D& to, bool selfLoop){ + // Pick a point a bit further from the middle point between the nodes. + // This is an affine combination of the points 'via' and '(from + to) / 2.0f'. + const QVector3D base = via * 1.33333f - (from + to) / 6.0f; + + if (selfLoop) + { + // For self-loops, the control points need to lie apart, we'll spread + // them in x-y direction. + const QVector3D diff = QVector3D::crossProduct(base - from, QVector3D(0, 0, 1)); + const QVector3D n_diff = diff * ((via - from).length() / (diff.length() * 2.0f)); + return std::array{from, base + n_diff, base - n_diff, to}; + } + else + { + // Standard case: use the same position for both points. + //return std::array{from, base, base, to}; + // Method 2: project the quadratic bezier curve going through the handle onto a cubic bezier curve. + const QVector3D control = via + (via - ((from + to) / 2.0f)); + return std::array{from, + 0.33333f * from + 0.66666f * control, + 0.33333f * to + 0.66666f * control, + to}; + } + } \ No newline at end of file diff --git a/tools/release/ltsview/source/visualizer/generic_visualizer/shaders/simple.fs b/tools/release/ltsview/source/visualizer/generic_visualizer/shaders/simple.fs new file mode 100644 index 0000000000..0667ae5e93 --- /dev/null +++ b/tools/release/ltsview/source/visualizer/generic_visualizer/shaders/simple.fs @@ -0,0 +1,10 @@ +#version 330 + +uniform vec4 g_color = vec4(1.0f); + +out vec4 fragColor; + +void main(void) +{ + fragColor = g_color; +} \ No newline at end of file diff --git a/tools/release/ltsview/source/visualizer/generic_visualizer/shaders/simple.vs b/tools/release/ltsview/source/visualizer/generic_visualizer/shaders/simple.vs new file mode 100644 index 0000000000..8c5d9683b8 --- /dev/null +++ b/tools/release/ltsview/source/visualizer/generic_visualizer/shaders/simple.vs @@ -0,0 +1,10 @@ +#version 330 + +uniform mat4 g_worldViewProjMatrix; + +layout(location = 0) in vec3 vertex; + +void main(void) +{ + gl_Position = g_worldViewProjMatrix * vec4(vertex, 1.0f); +} \ No newline at end of file diff --git a/tools/release/ltsview/ltscanvas.cpp b/tools/release/ltsview/source/visualizer/ltscanvas.cpp similarity index 84% rename from tools/release/ltsview/ltscanvas.cpp rename to tools/release/ltsview/source/visualizer/ltscanvas.cpp index 706c369c83..de0c792282 100644 --- a/tools/release/ltsview/ltscanvas.cpp +++ b/tools/release/ltsview/source/visualizer/ltscanvas.cpp @@ -17,14 +17,16 @@ #include "icons/pan_cursor.xpm" #include "icons/rotate_cursor.xpm" -LtsCanvas::LtsCanvas(QWidget* parent, Settings* settings, LtsManager* ltsManager, MarkManager* markManager): +#include + +LtsCanvas::LtsCanvas(QWidget* parent, LtsManager* ltsManager, MarkManager* markManager): QOpenGLWidget(parent), - m_settings(settings), m_ltsManager(ltsManager), - m_visualizer(new Visualizer(this, settings, ltsManager, markManager)), + m_visualizer(new Visualizer(this, ltsManager, markManager)), m_width(0), m_height(0), - m_dragging(false) + m_dragging(false), + frame_times(QLinkedList()) { m_selectCursor = QCursor(Qt::ArrowCursor); m_panCursor = QCursor(QPixmap(pan_cursor)); @@ -35,11 +37,11 @@ LtsCanvas::LtsCanvas(QWidget* parent, Settings* settings, LtsManager* ltsManager connect(m_ltsManager, SIGNAL(clusterPositionsChanged()), this, SLOT(clusterPositionsChanged())); connect(m_ltsManager, SIGNAL(ltsZoomed(LTS *)), this, SLOT(clusterPositionsChanged())); connect(m_ltsManager, SIGNAL(ltsZoomed(LTS *)), this, SLOT(resetView())); - connect(&m_settings->backgroundColor, SIGNAL(changed(QColor)), this, SLOT(update())); - connect(&m_settings->displayStates, SIGNAL(changed(bool)), this, SLOT(update())); - connect(&m_settings->displayTransitions, SIGNAL(changed(bool)), this, SLOT(update())); - connect(&m_settings->displayBackpointers, SIGNAL(changed(bool)), this, SLOT(update())); - connect(&m_settings->displayWireframe, SIGNAL(changed(bool)), this, SLOT(update())); + connect(&Settings::instance().backgroundColor, SIGNAL(changed(QColor)), this, SLOT(update())); + connect(&Settings::instance().displayStates, SIGNAL(changed(bool)), this, SLOT(update())); + connect(&Settings::instance().displayTransitions, SIGNAL(changed(bool)), this, SLOT(update())); + connect(&Settings::instance().displayBackpointers, SIGNAL(changed(bool)), this, SLOT(update())); + connect(&Settings::instance().displayWireframe, SIGNAL(changed(bool)), this, SLOT(update())); clusterPositionsChanged(); resetView(); @@ -149,6 +151,11 @@ void LtsCanvas::resizeGL(int width, int height) void LtsCanvas::paintGL() { + // GLint64 start; + // GLint64 end; + // glGetInteger64v(GL_TIMESTAMP, &start); + auto start = std::chrono::high_resolution_clock::now(); + glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60.0f, (GLfloat)m_width / (GLfloat)m_height, m_nearPlane, m_farPlane); @@ -156,6 +163,17 @@ void LtsCanvas::paintGL() emit renderingStarted(); render(m_dragging); emit renderingFinished(); + + auto end = std::chrono::high_resolution_clock::now(); + // glGetInteger64v(GL_TIMESTAMP, &end); + + frame_times.append(QTime::currentTime()); + while(frame_times.back().msecsSinceStartOfDay() - frame_times.front().msecsSinceStartOfDay() > measuring_time * 1000) frame_times.pop_front(); + graphics_info = QString("Version: ").append((const char *)glGetString(GL_VERSION)); + graphics_info.append("\nAverage frame time: ").append(QString::number(measuring_time / frame_times.size())); + graphics_info.append("\nFrame_times length: ").append(QString::number(frame_times.size())); + graphics_info.append("\nLast frametime in msec: ").append(QString::number((end - start).count() / 1e6)); + } void LtsCanvas::render(bool light) @@ -164,9 +182,9 @@ void LtsCanvas::render(bool light) glDepthFunc(GL_LESS); glClearColor( - m_settings->backgroundColor.value().red() / 255.0, - m_settings->backgroundColor.value().green() / 255.0, - m_settings->backgroundColor.value().blue() / 255.0, + Settings::instance().backgroundColor.value().red() / 255.0, + Settings::instance().backgroundColor.value().green() / 255.0, + Settings::instance().backgroundColor.value().blue() / 255.0, 1.0f ); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -175,7 +193,7 @@ void LtsCanvas::render(bool light) glPushMatrix(); glLoadIdentity(); - if (!light || m_settings->navLighting.value()) + if (!light || Settings::instance().navLighting.value()) { glEnable(GL_NORMALIZE); glEnable(GL_LIGHTING); @@ -188,7 +206,7 @@ void LtsCanvas::render(bool light) glDisable(GL_LIGHT0); } - if (!light || m_settings->navSmoothShading.value()) + if (!light || Settings::instance().navSmoothShading.value()) { glShadeModel(GL_SMOOTH); } @@ -197,7 +215,7 @@ void LtsCanvas::render(bool light) glShadeModel(GL_FLAT); } - if (m_settings->displayWireframe.value()) + if (Settings::instance().displayWireframe.value()) { glPolygonMode(GL_FRONT,GL_LINE); } @@ -226,9 +244,9 @@ void LtsCanvas::render(bool light) ); glPopName(); } - if (!light || m_settings->navShowStates.value()) + if (!light || Settings::instance().navShowStates.value()) { - if (m_settings->displayStates.value()) + if (Settings::instance().displayStates.value()) { // Identify that we are drawing states glPushName(StateObject); @@ -244,8 +262,8 @@ void LtsCanvas::render(bool light) glDisable(GL_LIGHT0); m_visualizer->drawTransitions( - m_settings->displayTransitions.value() && (!light || m_settings->navShowTransitions.value()), - m_settings->displayBackpointers.value() && (!light || m_settings->navShowBackpointers.value()) + Settings::instance().displayTransitions.value() && (!light || Settings::instance().navShowTransitions.value()), + Settings::instance().displayBackpointers.value() && (!light || Settings::instance().navShowBackpointers.value()) ); if (m_ltsManager->simulationActive()) @@ -254,8 +272,8 @@ void LtsCanvas::render(bool light) // transitions going out of the current state. // Identify that we are drawing selectable sim states in this mode. m_visualizer->drawSimTransitions( - !light || m_settings->navShowTransitions.value(), - !light || m_settings->navShowBackpointers.value(), + !light || Settings::instance().navShowTransitions.value(), + !light || Settings::instance().navShowBackpointers.value(), m_ltsManager->simulationTransitionHistory(), m_ltsManager->simulationAvailableTransitions(), m_ltsManager->currentSimulationTransition() @@ -263,14 +281,14 @@ void LtsCanvas::render(bool light) } // Enable lighting again, if required - if (!light || m_settings->navLighting.value()) + if (!light || Settings::instance().navLighting.value()) { glEnable(GL_NORMALIZE); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); } - if (!light || m_settings->navTransparency.value()) + if (!light || Settings::instance().navTransparency.value()) { // determine current viewpoint in world coordinates glPushMatrix(); @@ -305,6 +323,8 @@ void LtsCanvas::render(bool light) { qWarning("OpenGL error: %d", error); } + + } void LtsCanvas::mousePressEvent(QMouseEvent* event) diff --git a/tools/release/ltsview/source/visualizer/ltsview_visualizer/scenegraphgenerator.cpp b/tools/release/ltsview/source/visualizer/ltsview_visualizer/scenegraphgenerator.cpp new file mode 100644 index 0000000000..048fa4ffde --- /dev/null +++ b/tools/release/ltsview/source/visualizer/ltsview_visualizer/scenegraphgenerator.cpp @@ -0,0 +1,107 @@ +#include "scenegraphgenerator.h" +#include "cluster.h" +#include "mcrl2/utilities/logger.h" + + + +void ConeConvertFunctor::matrixScale(float x, float y, float z){ + current_matrix.scale(x, y, z); +} + +void ConeConvertFunctor::matrixTranslate(float x, float y, float z){ + current_matrix.translate(x, y, z); +} + +void ConeConvertFunctor::matrixTranslate(const QVector3D& v){ + current_matrix.translate(v); +} + +void ConeConvertFunctor::matrixRotate(float angle, float x, float y, float z){ + current_matrix.rotate(angle, x, y, z); +} + + +VisTree::VisTreeNode* ConeConvertFunctor::operator()(VisTree::VisTreeNode* parent, Cluster* cluster){ + if (parent == nullptr) current_matrix.setToIdentity(); else current_matrix = parent->shape.matrix; + if (!cluster->hasDescendants()){ + VisTree::VisTreeNode* node = new VisTree::VisTreeNode(); + node->shape = noChildren(cluster, topClosed, rot); + return node; + } + + // move down and to the side (if applicable) + float sideways = cluster->isCentered() ? 0 : cluster->getAncestor()->getBaseRadius(); + float branchtilt = cluster->isCentered() ? 0 : Settings::instance().branchTilt.value(); + // TODO: Check order + matrixRotate(cluster->getPosition(), 0, 0, 1); + matrixRotate(branchtilt, 0, 1, 0); + matrixTranslate(sideways, 0, Settings::instance().clusterHeight.value()); + + VisTree::VisTreeNode* node = new VisTree::VisTreeNode(); + VisTree::Shapes::TruncatedCone cone = VisTree::Shapes::TruncatedCone(); + cone.height = Settings::instance().clusterHeight.value(); + cone.fill_top = !cluster->isCentered() || parent == nullptr; + cone.fill_bot = cluster->getNumDescendants() > 1; + cone.matrix = current_matrix; + cone.radius_top = cluster->getTopRadius(); + cone.radius_bot = cluster->getBaseRadius(); + node->shape = cone; + std::cout << "Cone at: " << qvec4ToString(current_matrix.column(3)) << " with:" << + "\n\t- topclosed: " << std::to_string(cone.fill_top) << + "\n\t- botclosed: " << std::to_string(cone.fill_bot) << + "\n\t- topradius: " << std::to_string(cone.radius_top) << + "\n\t- botradius: " << std::to_string(cone.radius_bot) << std::endl; + + return node; +} + +VisTree::Shape ConeConvertFunctor::noChildren(Cluster* cluster, bool topClosed, int rot){ + VisTree::Shapes::Sphere sphere = VisTree::Shapes::Sphere(); + sphere.radius = 1; + // find shape matrix + float r = cluster->getTopRadius(); + // move down and to the side (if applicable) + float sideways = cluster->isCentered() ? 0 : cluster->getAncestor()->getBaseRadius(); + float branchtilt = cluster->isCentered() ? 0 : Settings::instance().branchTilt.value(); + // TODO: Check order + matrixRotate(cluster->getPosition(), 0, 0, 1); + matrixRotate(branchtilt, 0, 1, 0); + matrixTranslate(sideways, 0, Settings::instance().clusterHeight.value()); + matrixScale(r, r, r); + sphere.matrix = current_matrix; + + std::cout << "Sphere at: " << qvec4ToString(current_matrix.column(3)) << " with:" << + "\n\t- radius: 1\n\t- r: " << std::to_string(r) << std::endl; + return sphere; +} + +VisTree::VisTreeNode* TubeConvertFunctor::operator()(VisTree::VisTreeNode* parent, Cluster* cluster){ + std::cout << "TubeConvertFunctor: not implemented yet..." << std::endl; + return nullptr; +} + +ClusterChildIterator getClusterChildIterator(Cluster* cluster){ + return {cluster->descendants.begin(), cluster->descendants.end()}; +} + + +std::vector::iterator ClusterChildIterator::operator++(){ return ++it; } +Cluster* ClusterChildIterator::operator*() { return *it; } + +SG* SceneGraphGenerator::generate(Mode mode){ + switch (mode){ + case Mode::TUBES: + return generateTubes(m_clusterRoot); + break; + case Mode::CONES: + return generateCones(m_clusterRoot); + break; + default: + mCRL2log(mcrl2::log::warning) << "Invalid mode selected in ltsview scenegraphgenerator. Defaulting to tubes." << std::endl; + return generateCones(m_clusterRoot); + } +} + + + + diff --git a/tools/release/ltsview/primitivefactory.cpp b/tools/release/ltsview/source/visualizer/primitivefactory.cpp similarity index 83% rename from tools/release/ltsview/primitivefactory.cpp rename to tools/release/ltsview/source/visualizer/primitivefactory.cpp index 65a8bf3cc8..6bc2353a64 100644 --- a/tools/release/ltsview/primitivefactory.cpp +++ b/tools/release/ltsview/source/visualizer/primitivefactory.cpp @@ -20,15 +20,14 @@ using namespace MathUtils; /* Primitive Factory -------------------------------------------------------- */ -PrimitiveFactory::PrimitiveFactory(Settings* ss) +PrimitiveFactory::PrimitiveFactory() { disc = -1; sphere = -1; hemisphere = -1; simple_sphere = -1; - settings = ss; - connect(&settings->quality, SIGNAL(changed(int)), this, SLOT(qualityChanged())); - connect(&settings->branchTilt, SIGNAL(changed(int)), this, SLOT(branchTiltChanged())); + connect(&Settings::instance().quality, SIGNAL(changed(int)), this, SLOT(qualityChanged())); + connect(&Settings::instance().branchTilt, SIGNAL(changed(int)), this, SLOT(branchTiltChanged())); cos_theta = NULL; sin_theta = NULL; @@ -93,7 +92,7 @@ int PrimitiveFactory::makeObliqueCone(float a,float r,float s) if (result == -1) { P_ObliqueCone* p = new P_ObliqueCone(a,r,s); - p->reshape(settings->quality.value(),cos_theta,sin_theta,deg_to_rad(float(settings->branchTilt.value()))); + p->reshape(Settings::instance().quality.value(),cos_theta,sin_theta,deg_to_rad(float(Settings::instance().branchTilt.value()))); result = static_cast(primitives.size()); primitives.push_back(p); oblq_cones.push_back(p); @@ -107,7 +106,7 @@ int PrimitiveFactory::makeHemisphere() if (hemisphere == -1) { P_Hemisphere* p = new P_Hemisphere(); - p->reshape(settings->quality.value(),cos_theta,sin_theta); + p->reshape(Settings::instance().quality.value(),cos_theta,sin_theta); hemisphere = static_cast(primitives.size()); primitives.push_back(p); } @@ -119,7 +118,7 @@ int PrimitiveFactory::makeSphere() if (sphere == -1) { P_Sphere* p = new P_Sphere(); - p->reshape(settings->quality.value(),cos_theta,sin_theta); + p->reshape(Settings::instance().quality.value(),cos_theta,sin_theta); sphere = static_cast(primitives.size()); primitives.push_back(p); } @@ -128,7 +127,7 @@ int PrimitiveFactory::makeSphere() void PrimitiveFactory::update_geom_tables() { - int qlt = settings->quality.value(); + int qlt = Settings::instance().quality.value(); cos_theta = (float*)realloc(cos_theta,2*qlt*sizeof(float)); sin_theta = (float*)realloc(sin_theta,2*qlt*sizeof(float)); @@ -144,7 +143,7 @@ void PrimitiveFactory::update_geom_tables() void PrimitiveFactory::update_primitives() { - int qlt = settings->quality.value(); + int qlt = Settings::instance().quality.value(); for (unsigned int i = 0; i < primitives.size(); ++i) { primitives[i]->reshape(qlt,cos_theta,sin_theta); @@ -153,8 +152,8 @@ void PrimitiveFactory::update_primitives() void PrimitiveFactory::update_oblique_cones() { - int qlt = settings->quality.value(); - float obt = deg_to_rad(float(settings->branchTilt.value())); + int qlt = Settings::instance().quality.value(); + float obt = deg_to_rad(float(Settings::instance().branchTilt.value())); for (unsigned int i = 0; i < oblq_cones.size(); ++i) { oblq_cones[i]->reshape(qlt,cos_theta,sin_theta,obt); @@ -167,7 +166,7 @@ int PrimitiveFactory::make_ring(float r) if (result == -1) { P_Ring* p = new P_Ring(r); - p->reshape(settings->quality.value(),cos_theta,sin_theta); + p->reshape(Settings::instance().quality.value(),cos_theta,sin_theta); result = static_cast(primitives.size()); primitives.push_back(p); coneDB->addTruncatedCone(r,false,false,result); @@ -180,7 +179,7 @@ void PrimitiveFactory::make_disc() if (disc == -1) { P_Disc* p = new P_Disc(); - p->reshape(settings->quality.value(),cos_theta,sin_theta); + p->reshape(Settings::instance().quality.value(),cos_theta,sin_theta); disc = static_cast(primitives.size()); primitives.push_back(p); } diff --git a/tools/release/ltsview/primitives.cpp b/tools/release/ltsview/source/visualizer/primitives.cpp similarity index 100% rename from tools/release/ltsview/primitives.cpp rename to tools/release/ltsview/source/visualizer/primitives.cpp diff --git a/tools/release/ltsview/visobjectfactory.cpp b/tools/release/ltsview/source/visualizer/visobjectfactory.cpp similarity index 100% rename from tools/release/ltsview/visobjectfactory.cpp rename to tools/release/ltsview/source/visualizer/visobjectfactory.cpp diff --git a/tools/release/ltsview/visualizer.cpp b/tools/release/ltsview/source/visualizer/visualizer.cpp similarity index 81% rename from tools/release/ltsview/visualizer.cpp rename to tools/release/ltsview/source/visualizer/visualizer.cpp index 7a1097eb80..abe17cff82 100644 --- a/tools/release/ltsview/visualizer.cpp +++ b/tools/release/ltsview/source/visualizer/visualizer.cpp @@ -17,35 +17,42 @@ #include +#include "vistree.h" +#include "scenegraphgenerator.h" + using namespace MathUtils; #define SELECT_BLEND 0.3f -Visualizer::Visualizer(QObject *parent, Settings* settings_, LtsManager *ltsManager_, MarkManager* markManager_): +Visualizer::Visualizer(QObject *parent, LtsManager *ltsManager_, MarkManager* markManager_): QObject(parent), - settings(settings_), ltsManager(ltsManager_), markManager(markManager_), - primitiveFactory(settings) + primitiveFactory() { - connect(&settings->stateSize, SIGNAL(changed(float)), this, SIGNAL(dirtied())); - connect(&settings->clusterHeight, SIGNAL(changed(float)), this, SLOT(dirtyMatrices())); - connect(&settings->branchRotation, SIGNAL(changed(int)), this, SLOT(dirtyMatrices())); - connect(&settings->branchTilt, SIGNAL(changed(int)), this, SLOT(branchTiltChanged(int))); - connect(&settings->quality, SIGNAL(changed(int)), this, SLOT(dirtyObjects())); - connect(&settings->transparency, SIGNAL(changed(int)), this, SIGNAL(dirtied())); - connect(&settings->stateColor, SIGNAL(changed(QColor)), this, SIGNAL(dirtied())); - connect(&settings->downEdgeColor, SIGNAL(changed(QColor)), this, SIGNAL(dirtied())); - connect(&settings->upEdgeColor, SIGNAL(changed(QColor)), this, SIGNAL(dirtied())); - connect(&settings->markedColor, SIGNAL(changed(QColor)), this, SLOT(dirtyColorsMark())); - connect(&settings->clusterColorTop, SIGNAL(changed(QColor)), this, SLOT(dirtyColorsNoMark())); - connect(&settings->clusterColorBottom, SIGNAL(changed(QColor)), this, SLOT(dirtyColorsNoMark())); - connect(&settings->longInterpolation, SIGNAL(changed(bool)), this, SLOT(dirtyColorsNoMark())); - connect(&settings->simPrevColor, SIGNAL(changed(QColor)), this, SIGNAL(dirtied())); - connect(&settings->simCurrColor, SIGNAL(changed(QColor)), this, SIGNAL(dirtied())); - connect(&settings->simSelColor, SIGNAL(changed(QColor)), this, SIGNAL(dirtied())); - connect(&settings->simPosColor, SIGNAL(changed(QColor)), this, SIGNAL(dirtied())); - connect(&settings->clusterVisStyleTubes, SIGNAL(changed(bool)), this, SLOT(dirtyObjects())); + connect(&Settings::instance().stateSize, SIGNAL(changed(float)), this, SIGNAL(dirtied())); + connect(&Settings::instance().clusterHeight, SIGNAL(changed(float)), this, SLOT(dirtyMatrices())); + connect(&Settings::instance().branchRotation, SIGNAL(changed(int)), this, SLOT(dirtyMatrices())); + connect(&Settings::instance().branchTilt, SIGNAL(changed(int)), this, SLOT(branchTiltChanged(int))); + connect(&Settings::instance().quality, SIGNAL(changed(int)), this, SLOT(dirtyObjects())); + connect(&Settings::instance().transparency, SIGNAL(changed(int)), this, SIGNAL(dirtied())); + connect(&Settings::instance().stateColor, SIGNAL(changed(QColor)), this, SIGNAL(dirtied())); + connect(&Settings::instance().downEdgeColor, SIGNAL(changed(QColor)), this, SIGNAL(dirtied())); + connect(&Settings::instance().upEdgeColorFrom, SIGNAL(changed(QColor)), this, SIGNAL(dirtied())); + connect(&Settings::instance().upEdgeColorTo, SIGNAL(changed(QColor)), this, + SIGNAL(dirtied())); + connect(&Settings::instance().longInterpolationUpEdge, SIGNAL(changed(bool)), this, + SIGNAL(dirtied())); + + connect(&Settings::instance().markedColor, SIGNAL(changed(QColor)), this, SLOT(dirtyColorsMark())); + connect(&Settings::instance().clusterColorTop, SIGNAL(changed(QColor)), this, SLOT(dirtyColorsNoMark())); + connect(&Settings::instance().clusterColorBottom, SIGNAL(changed(QColor)), this, SLOT(dirtyColorsNoMark())); + connect(&Settings::instance().longInterpolationCluster, SIGNAL(changed(bool)), this, SLOT(dirtyColorsNoMark())); + connect(&Settings::instance().simPrevColor, SIGNAL(changed(QColor)), this, SIGNAL(dirtied())); + connect(&Settings::instance().simCurrColor, SIGNAL(changed(QColor)), this, SIGNAL(dirtied())); + connect(&Settings::instance().simSelColor, SIGNAL(changed(QColor)), this, SIGNAL(dirtied())); + connect(&Settings::instance().simPosColor, SIGNAL(changed(QColor)), this, SIGNAL(dirtied())); + connect(&Settings::instance().clusterVisStyleTubes, SIGNAL(changed(bool)), this, SLOT(dirtyObjects())); connect(ltsManager, SIGNAL(ltsChanged(LTS *)), this, SLOT(setClusterHeight())); connect(ltsManager, SIGNAL(clustersChanged()), this, SLOT(dirtyObjects())); @@ -57,8 +64,8 @@ Visualizer::Visualizer(QObject *parent, Settings* settings_, LtsManager *ltsMana connect(markManager, SIGNAL(marksChanged()), this, SLOT(dirtyColors())); - sin_obt = float(sin(deg_to_rad(settings->branchTilt.value()))); - cos_obt = float(cos(deg_to_rad(settings->branchTilt.value()))); + sin_obt = float(sin(deg_to_rad(Settings::instance().branchTilt.value()))); + cos_obt = float(cos(deg_to_rad(Settings::instance().branchTilt.value()))); update_objects = true; update_matrices = false; @@ -72,14 +79,14 @@ float Visualizer::getHalfStructureHeight() const { return 0.0f; } - return settings->clusterHeight.value() * (ltsManager->lts()->getNumRanks() - 1) / 2.0f; + return Settings::instance().clusterHeight.value() * (ltsManager->lts()->getNumRanks() - 1) / 2.0f; } void Visualizer::setClusterHeight() { float ratio = ltsManager->lts()->getInitialState()->getCluster()->getBCRadius() / ltsManager->lts()->getInitialState()->getCluster()->getBCHeight(); - settings->clusterHeight.setValue(std::max(4,round_to_int(40.0f * ratio)) / 10.0f); + Settings::instance().clusterHeight.setValue(std::max(4,round_to_int(40.0f * ratio)) / 10.0f); dirtyObjects(); } @@ -137,7 +144,7 @@ void Visualizer::computeSubtreeBounds(Cluster* root, float& bw, float& bh) } } bw = std::max(bw,root->getTopRadius()); - bh += settings->clusterHeight.value(); + bh += Settings::instance().clusterHeight.value(); } } @@ -157,7 +164,7 @@ void Visualizer::drawStructure() { updateColors(); } - visObjectFactory.drawObjects(&primitiveFactory,(int)((100 - settings->transparency.value()) * 2.55f), + visObjectFactory.drawObjects(&primitiveFactory,(int)((100 - Settings::instance().transparency.value()) * 2.55f), markManager->stateMatchStyle() == MATCH_MULTI); } @@ -167,11 +174,12 @@ void Visualizer::traverseTree() { visObjectFactory.clear(); update_colors = true; + VisTree::VisTreeNode* visroot = generateClusterTree(ltsManager->lts()->getInitialState()->getCluster()); } glPushMatrix(); glLoadIdentity(); Cluster *root = ltsManager->lts()->getInitialState()->getCluster(); - if (settings->clusterVisStyleTubes.value()) + if (Settings::instance().clusterVisStyleTubes.value()) { traverseTreeT(root, true, 0); } @@ -208,7 +216,7 @@ void Visualizer::traverseTreeC(Cluster* root,bool topClosed,int rot) } else { - int drot = rot + settings->branchRotation.value(); + int drot = rot + Settings::instance().branchRotation.value(); if (drot >= 360) { drot -= 360; @@ -218,7 +226,7 @@ void Visualizer::traverseTreeC(Cluster* root,bool topClosed,int rot) root->clearBranchVisObjects(); } - glTranslatef(0.0f,0.0f,settings->clusterHeight.value()); + glTranslatef(0.0f,0.0f,Settings::instance().clusterHeight.value()); for (int i = 0; i < root->getNumDescendants(); ++i) { Cluster* desc = root->getDescendant(i); @@ -239,25 +247,25 @@ void Visualizer::traverseTreeC(Cluster* root,bool topClosed,int rot) { glRotatef(-desc->getPosition() - rot, 0.0f, 0.0f, 1.0f); glTranslatef(root->getBaseRadius(), 0.0f, 0.0f); - glRotatef(settings->branchTilt.value(), 0.0f, 1.0f, 0.0f); + glRotatef(Settings::instance().branchTilt.value(), 0.0f, 1.0f, 0.0f); traverseTreeC(desc, true, drot); - glRotatef(-settings->branchTilt.value(), 0.0f, 1.0f, 0.0f); + glRotatef(-Settings::instance().branchTilt.value(), 0.0f, 1.0f, 0.0f); glTranslatef(-root->getBaseRadius(), 0.0f, 0.0f); glRotatef(desc->getPosition() + rot, 0.0f, 0.0f, 1.0f); } } } - glTranslatef(0.0f,0.0f,-settings->clusterHeight.value()); + glTranslatef(0.0f,0.0f,-Settings::instance().clusterHeight.value()); float r = root->getBaseRadius() / root->getTopRadius(); glPushMatrix(); - glTranslatef(0.0f,0.0f,0.5f*settings->clusterHeight.value()); + glTranslatef(0.0f,0.0f,0.5f*Settings::instance().clusterHeight.value()); if (r > 1.0f) { r = 1.0f / r; glRotatef(180.0f,1.0f,0.0f,0.0f); glScalef(root->getBaseRadius(),root->getBaseRadius(), - settings->clusterHeight.value()); + Settings::instance().clusterHeight.value()); std::vector ids; ids.push_back(root->getRank()); @@ -279,7 +287,7 @@ void Visualizer::traverseTreeC(Cluster* root,bool topClosed,int rot) } else { - glScalef(root->getTopRadius(),root->getTopRadius(),settings->clusterHeight.value()); + glScalef(root->getTopRadius(),root->getTopRadius(),Settings::instance().clusterHeight.value()); std::vector ids; ids.push_back(root->getRank()); @@ -310,7 +318,7 @@ void Visualizer::traverseTreeT(Cluster* root, bool topClosed, int rot) // root has no descendants; so draw it as a hemispheroid glPushMatrix(); glScalef(root->getTopRadius(),root->getTopRadius(), - std::min(root->getTopRadius(),settings->clusterHeight.value())); + std::min(root->getTopRadius(),Settings::instance().clusterHeight.value())); if (update_objects) { std::vector ids; @@ -336,7 +344,7 @@ void Visualizer::traverseTreeT(Cluster* root, bool topClosed, int rot) } else { - int drot = rot + settings->branchRotation.value(); + int drot = rot + Settings::instance().branchRotation.value(); if (drot >= 360) { drot -= 360; @@ -359,7 +367,7 @@ void Visualizer::traverseTreeT(Cluster* root, bool topClosed, int rot) root->addBranchVisObject(-1); } baserad = desc->getTopRadius(); - glTranslatef(0.0f,0.0f,settings->clusterHeight.value()); + glTranslatef(0.0f,0.0f,Settings::instance().clusterHeight.value()); if (root->getNumDescendants() > 1) { traverseTreeT(desc,false,drot); @@ -368,26 +376,26 @@ void Visualizer::traverseTreeT(Cluster* root, bool topClosed, int rot) { traverseTreeT(desc,false,rot); } - glTranslatef(0.0f,0.0f,-settings->clusterHeight.value()); + glTranslatef(0.0f,0.0f,-Settings::instance().clusterHeight.value()); } else { // make the connecting cone float d_rad = root->getBaseRadius() - root->getTopRadius(); - float sz = sqrt(settings->clusterHeight.value() * - settings->clusterHeight.value() + d_rad * d_rad); + float sz = sqrt(Settings::instance().clusterHeight.value() * + Settings::instance().clusterHeight.value() + d_rad * d_rad); float alpha, sign; if (d_rad < 0.0f) { sign = -1.0f; - alpha = atan(settings->clusterHeight.value() / -d_rad); + alpha = atan(Settings::instance().clusterHeight.value() / -d_rad); } else { sign = 1.0f; if (d_rad > 0.0f) { - alpha = atan(settings->clusterHeight.value() / d_rad); + alpha = atan(Settings::instance().clusterHeight.value() / d_rad); } else { @@ -416,12 +424,12 @@ void Visualizer::traverseTreeT(Cluster* root, bool topClosed, int rot) // recurse into the subtree glTranslatef(root->getBaseRadius(),0.0f, - settings->clusterHeight.value()); - glRotatef(settings->branchTilt.value(),0.0f,1.0f,0.0f); + Settings::instance().clusterHeight.value()); + glRotatef(Settings::instance().branchTilt.value(),0.0f,1.0f,0.0f); traverseTreeT(desc,false,drot); - glRotatef(-settings->branchTilt.value(),0.0f,1.0f,0.0f); + glRotatef(-Settings::instance().branchTilt.value(),0.0f,1.0f,0.0f); glTranslatef(-root->getBaseRadius(),0.0f, - -settings->clusterHeight.value()); + -Settings::instance().clusterHeight.value()); glRotatef(desc->getPosition()+rot,0.0f,0.0f,1.0f); } } @@ -432,7 +440,7 @@ void Visualizer::traverseTreeT(Cluster* root, bool topClosed, int rot) // root has no centered descendant, so draw it as a hemispheroid glPushMatrix(); glScalef(root->getTopRadius(),root->getTopRadius(), - std::min(root->getTopRadius(),settings->clusterHeight.value())); + std::min(root->getTopRadius(),Settings::instance().clusterHeight.value())); if (update_objects) { std::vector ids; @@ -465,12 +473,12 @@ void Visualizer::traverseTreeT(Cluster* root, bool topClosed, int rot) r = 1.0f; } glPushMatrix(); - glTranslatef(0.0f,0.0f,0.5f*settings->clusterHeight.value()); + glTranslatef(0.0f,0.0f,0.5f*Settings::instance().clusterHeight.value()); if (r > 1.0f) { r = 1.0f / r; glRotatef(180.0f,1.0f,0.0f,0.0f); - glScalef(baserad,baserad,settings->clusterHeight.value()); + glScalef(baserad,baserad,Settings::instance().clusterHeight.value()); if (update_objects) { std::vector ids; @@ -488,7 +496,7 @@ void Visualizer::traverseTreeT(Cluster* root, bool topClosed, int rot) else { glScalef(root->getTopRadius(),root->getTopRadius(), - settings->clusterHeight.value()); + Settings::instance().clusterHeight.value()); if (update_objects) { std::vector ids; @@ -522,12 +530,12 @@ void Visualizer::updateColors() QColor c; if (markManager->markStyle() == NO_MARKS) { - QColor from = settings->clusterColorTop.value(); - QColor to = settings->clusterColorBottom.value(); + QColor from = Settings::instance().clusterColorTop.value(); + QColor to = Settings::instance().clusterColorBottom.value(); float hueFrom = from.hueF(); float hueTo = to.hueF(); - bool useLongInterpolation = settings->longInterpolation.value(); + bool useLongInterpolationCluster = Settings::instance().longInterpolationCluster.value(); // set hues equal if one of the colors is grey if (to.red() == to.green() && to.green() == to.blue()) @@ -540,7 +548,7 @@ void Visualizer::updateColors() } float hueDelta = hueTo - hueFrom; - if ((useLongInterpolation && abs(hueDelta) < 0.5f) || (!useLongInterpolation && abs(hueDelta) >= 0.5f)) + if ((useLongInterpolationCluster && abs(hueDelta) < 0.5f) || (!useLongInterpolationCluster && abs(hueDelta) >= 0.5f)) { if (hueDelta > 0.0f) { @@ -620,7 +628,7 @@ void Visualizer::updateColors() } else { - c = settings->markedColor.value(); + c = Settings::instance().markedColor.value(); } } @@ -678,7 +686,7 @@ void Visualizer::drawSimStates(QList historicStates, // Compute absolute positions of nodes, if necessary computeAbsPos(); - float ns = settings->stateSize.value(); + float ns = Settings::instance().stateSize.value(); QColor c; QVector3D p; @@ -690,11 +698,11 @@ void Visualizer::drawSimStates(QList historicStates, { if (markManager->isMarked(currState)) { - c = settings->markedColor.value(); + c = Settings::instance().markedColor.value(); } else { - c = settings->simCurrColor.value(); + c = Settings::instance().simCurrColor.value(); } if (currState == ltsManager->selectedState()) @@ -733,15 +741,15 @@ void Visualizer::drawSimStates(QList historicStates, if (markManager->isMarked(endState)) { - c = settings->markedColor.value(); + c = Settings::instance().markedColor.value(); } else if (currState->getOutTransition(i) == chosenTrans) { - c = settings->simSelColor.value(); + c = Settings::instance().simSelColor.value(); } else { - c = settings->simPosColor.value(); + c = Settings::instance().simPosColor.value(); } if (endState == ltsManager->selectedState()) @@ -781,11 +789,11 @@ void Visualizer::drawSimStates(QList historicStates, { if (markManager->isMarked(s)) { - c = settings->markedColor.value(); + c = Settings::instance().markedColor.value(); } else { - c = settings->simPrevColor.value(); + c = Settings::instance().simPrevColor.value(); } if (s == ltsManager->selectedState()) @@ -850,13 +858,13 @@ void Visualizer::computeStateAbsPos(Cluster* root, int rot) // The outgoing vector of the state lies settings->clusterHeight.value() above the state. glPushMatrix(); - glTranslatef(0.0f, 0.0f, -2 * settings->clusterHeight.value()); + glTranslatef(0.0f, 0.0f, -2 * Settings::instance().clusterHeight.value()); glGetFloatv(GL_MODELVIEW_MATRIX, M); QVector3D p2 = QVector3D(M[12], M[13], M[14]); s->setIncomingControl(p2); // The incoming vector of the state lies settings->clusterHeight.value() beneath the state. - glTranslatef(0.0f, 0.0f, 4 * settings->clusterHeight.value()); + glTranslatef(0.0f, 0.0f, 4 * Settings::instance().clusterHeight.value()); glGetFloatv(GL_MODELVIEW_MATRIX, M); QVector3D p3 = QVector3D(M[12], M[13], M[14]); s->setOutgoingControl(p3); @@ -878,12 +886,12 @@ void Visualizer::computeStateAbsPos(Cluster* root, int rot) // The outgoing vector of the state points out of the cluster, in the // direction the state itself is positioned. Furthermore, it points // settings->clusterHeight.value() up. - glTranslatef(root->getTopRadius() * 3, 0.0f, -settings->clusterHeight.value()); + glTranslatef(root->getTopRadius() * 3, 0.0f, -Settings::instance().clusterHeight.value()); glGetFloatv(GL_MODELVIEW_MATRIX, M); QVector3D p2 = QVector3D(M[12], M[13], M[14]); s->setIncomingControl(p2); - glTranslatef(0.0f, 0.0f, 2 * settings->clusterHeight.value()); + glTranslatef(0.0f, 0.0f, 2 * Settings::instance().clusterHeight.value()); glGetFloatv(GL_MODELVIEW_MATRIX, M); QVector3D p3 = QVector3D(M[12], M[13], M[14]); s->setOutgoingControl(p3); @@ -895,15 +903,15 @@ void Visualizer::computeStateAbsPos(Cluster* root, int rot) glRotatef(-s->getPositionAngle(), 0.0f, 0.0f, 1.0f); glTranslatef(s->getPositionRadius(), 0.0f, 0.0f); - glTranslatef(settings->stateSize.value() * 5.0f, - settings->stateSize.value() * 5.0f, + glTranslatef(Settings::instance().stateSize.value() * 5.0f, + Settings::instance().stateSize.value() * 5.0f, 0.0f); glGetFloatv(GL_MODELVIEW_MATRIX, M); QVector3D p = QVector3D(M[12], M[13], M[14]); s->setLoopControl1(p); glTranslatef(0.0f, - -settings->stateSize.value() * 10.0f, + -Settings::instance().stateSize.value() * 10.0f, 0.0f); glGetFloatv(GL_MODELVIEW_MATRIX, M); p = QVector3D(M[12], M[13], M[14]); @@ -913,12 +921,12 @@ void Visualizer::computeStateAbsPos(Cluster* root, int rot) } // recurse into the descendants - int drot = rot + settings->branchRotation.value(); + int drot = rot + Settings::instance().branchRotation.value(); if (drot >= 360) { drot -= 360; } - glTranslatef(0.0f,0.0f,settings->clusterHeight.value()); + glTranslatef(0.0f,0.0f,Settings::instance().clusterHeight.value()); for (int i = 0; i < root->getNumDescendants(); ++i) { @@ -933,16 +941,16 @@ void Visualizer::computeStateAbsPos(Cluster* root, int rot) { glRotatef(-desc->getPosition()-rot,0.0f,0.0f,1.0f); glTranslatef(root->getBaseRadius(),0.0f,0.0f); - glRotatef(settings->branchTilt.value(),0.0f,1.0f,0.0f); + glRotatef(Settings::instance().branchTilt.value(),0.0f,1.0f,0.0f); computeStateAbsPos(desc,drot); - glRotatef(-settings->branchTilt.value(),0.0f,1.0f,0.0f); + glRotatef(-Settings::instance().branchTilt.value(),0.0f,1.0f,0.0f); glTranslatef(-root->getBaseRadius(),0.0f,0.0f); glRotatef(desc->getPosition()+rot,0.0f,0.0f,1.0f); } } } - glTranslatef(0.0f,0.0f,-settings->clusterHeight.value()); + glTranslatef(0.0f,0.0f,-Settings::instance().clusterHeight.value()); } } @@ -950,7 +958,7 @@ void Visualizer::drawStates(Cluster* root, bool simulating) { if (ltsManager->lts()->getZoomLevel() == root->getState(0)->getZoomLevel()) { - float ns = settings->stateSize.value(); + float ns = Settings::instance().stateSize.value(); for (int i = 0; i < root->getNumStates(); ++i) { State* s = root->getState(i); @@ -962,17 +970,17 @@ void Visualizer::drawStates(Cluster* root, bool simulating) if (!markManager->isMarked(s)) { - c = settings->stateColor.value(); + c = Settings::instance().stateColor.value(); } else { if (markManager->stateMatchStyle() != MATCH_MULTI) { - c = settings->markedColor.value(); + c = Settings::instance().markedColor.value(); } else { - c = settings->stateColor.value(); + c = Settings::instance().stateColor.value(); QList colors = markManager->markColors(s); @@ -1088,28 +1096,31 @@ void Visualizer::drawTransitions(Cluster* root,bool disp_fp,bool disp_bp) // Draw transition from root to endState if (disp_bp && outTransition->isBackpointer()) { - QColor color, black(0, 0, 0); + QColor from, to; if (markManager->isMarked(outTransition)) { - color = settings->markedColor.value(); + from = Settings::instance().markedColor.value(); + to = Settings::instance().markedColor.value(); } else { - color = settings->upEdgeColor.value(); + from = Settings::instance().upEdgeColorFrom.value(); + to = Settings::instance().upEdgeColorTo.value(); } - drawBackPointer(s,black,endState,color); + // TODO: Use settings->longinterpolationUpEdge + drawBackPointer(s,from,endState,to); } else if (disp_fp && !outTransition->isBackpointer()) { if (markManager->isMarked(outTransition)) { - QColor c = settings->markedColor.value(); + QColor c = Settings::instance().markedColor.value(); glColor4ub(c.red(),c.green(),c.blue(),255); } else { - QColor c = settings->downEdgeColor.value(); + QColor c = Settings::instance().downEdgeColor.value(); glColor4ub(c.red(),c.green(),c.blue(),255); } drawForwardPointer(s,endState); @@ -1129,12 +1140,12 @@ void Visualizer::drawTransitions(Cluster* root,bool disp_fp,bool disp_bp) } if (hasMarkedLoop) { - QColor c = settings->markedColor.value(); + QColor c = Settings::instance().markedColor.value(); glColor4ub(c.red(),c.green(),c.blue(),255); } else { - QColor c = settings->downEdgeColor.value(); + QColor c = Settings::instance().downEdgeColor.value(); glColor4ub(c.red(),c.green(),c.blue(),255); } drawLoop(s); @@ -1174,11 +1185,11 @@ void Visualizer::drawSimTransitions(bool draw_fp, bool draw_bp, QColor color, black(0, 0, 0); if (markManager->isMarked(currTrans)) { - color = settings->markedColor.value(); + color = Settings::instance().markedColor.value(); } else { - color = settings->simPrevColor.value(); + color = Settings::instance().simPrevColor.value(); } drawBackPointer(beginState, black, endState, color); } @@ -1186,12 +1197,12 @@ void Visualizer::drawSimTransitions(bool draw_fp, bool draw_bp, { if (markManager->isMarked(currTrans)) { - QColor c = settings->markedColor.value(); + QColor c = Settings::instance().markedColor.value(); glColor4ub(c.red(), c.green(), c.blue(), 255); } else { - QColor transColor = settings->simPrevColor.value(); + QColor transColor = Settings::instance().simPrevColor.value(); glColor4ub(transColor.red(), transColor.green(), transColor.blue(), 255); } if (!currTrans->isSelfLoop()) @@ -1224,17 +1235,17 @@ void Visualizer::drawSimTransitions(bool draw_fp, bool draw_bp, QColor color, black(0, 0, 0); if (markManager->isMarked(currTrans)) { - color = settings->markedColor.value(); + color = Settings::instance().markedColor.value(); } else if (currTrans == chosenTrans) { - color = settings->simSelColor.value(); + color = Settings::instance().simSelColor.value(); glLineWidth(2.0); } else { - color = settings->simPosColor.value(); + color = Settings::instance().simPosColor.value(); } drawBackPointer(beginState, black, endState, color); glLineWidth(1.0); @@ -1244,18 +1255,18 @@ void Visualizer::drawSimTransitions(bool draw_fp, bool draw_bp, { if (currTrans == chosenTrans) { - QColor c = settings->simSelColor.value(); + QColor c = Settings::instance().simSelColor.value(); glColor4ub(c.red(), c.green(), c.blue(), 255); glLineWidth(2.0); } else { - QColor c = settings->simPosColor.value(); + QColor c = Settings::instance().simPosColor.value(); glColor4ub(c.red(), c.green(), c.blue(), 255); } if (markManager->isMarked(currTrans)) { - QColor c = settings->markedColor.value(); + QColor c = Settings::instance().markedColor.value(); glColor4ub(c.red(), c.green(), c.blue(), 255); } @@ -1307,7 +1318,7 @@ void Visualizer::drawBackPointer(State* startState, const QColor& startColor, St } float t,it,b0,b1,b2,b3,x,y,z; - int N = settings->quality.value(); + int N = Settings::instance().quality.value(); float col[3]; col[0] = startColor.red(); @@ -1364,7 +1375,7 @@ void Visualizer::drawLoop(State* state) QVector3D endControl = state->getLoopControl2(); float t,it,b0,b1,b2,b3,x,y,z; - int N = settings->quality.value(); + int N = Settings::instance().quality.value(); glBegin(GL_LINE_STRIP); for (int k = 0; k < N; ++k) { @@ -1402,7 +1413,7 @@ void Visualizer::exportToText(std::string filename) } std::map< Cluster*, unsigned int > clus_id; unsigned int N = 0; - float ch = settings->clusterHeight.value(); + float ch = Settings::instance().clusterHeight.value(); Cluster_iterator ci(ltsManager->lts()); std::ofstream file(filename.c_str()); if (!file)