mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-21 16:50:53 +01:00
Compare commits
95 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f2ba6a4bbe | ||
|
|
5ec7ea194f | ||
|
|
a3525b466d | ||
|
|
f93b0817d6 | ||
|
|
27f6b6c929 | ||
|
|
2c4af2b128 | ||
|
|
10d086d378 | ||
|
|
bcbf6ba431 | ||
|
|
dfacacfdce | ||
|
|
a5b1a92beb | ||
|
|
8477d4d928 | ||
|
|
2147fca19b | ||
|
|
cf868a0cc8 | ||
|
|
51d40f9fcd | ||
|
|
11bf04390e | ||
|
|
ed263bb180 | ||
|
|
0dd3386ec4 | ||
|
|
e2211389e9 | ||
|
|
0e9dc51879 | ||
|
|
3c94d9a054 | ||
|
|
d385c6f8cf | ||
|
|
164b442871 | ||
|
|
83733f2dc6 | ||
|
|
0cc1424f90 | ||
|
|
15261ba896 | ||
|
|
1acf132128 | ||
|
|
5e935a976e | ||
|
|
62fa93ea1b | ||
|
|
57edc4be80 | ||
|
|
6ec416c351 | ||
|
|
40ecef5ff9 | ||
|
|
77164adf4b | ||
|
|
60dd0f2054 | ||
|
|
575a731819 | ||
|
|
e4c73b8666 | ||
|
|
cfe267fcb3 | ||
|
|
931c7811f3 | ||
|
|
af5563c760 | ||
|
|
4de19d8ae4 | ||
|
|
5ab965588b | ||
|
|
438f98d34b | ||
|
|
74b1270d0d | ||
|
|
9119d156c3 | ||
|
|
8070f7eedb | ||
|
|
bc0d70e1ea | ||
|
|
257cc7e91f | ||
|
|
8e6a796ba8 | ||
|
|
bdadd33697 | ||
|
|
f6f0c2106f | ||
|
|
67680f59a9 | ||
|
|
1c7892cc19 | ||
|
|
c890e67ddd | ||
|
|
8c321049d9 | ||
|
|
afdf20cf9f | ||
|
|
0876d2c549 | ||
|
|
223674c93e | ||
|
|
9f4fbe456f | ||
|
|
308b3a99d7 | ||
|
|
e8cbb23c0b | ||
|
|
40a36e069e | ||
|
|
5a951d94d6 | ||
|
|
dec5d3002c | ||
|
|
80e78b4e04 | ||
|
|
438d690edc | ||
|
|
547ae24252 | ||
|
|
72ea869f63 | ||
|
|
3c77a34b32 | ||
|
|
c744721aad | ||
|
|
10a94b2a5a | ||
|
|
dacfd4117f | ||
|
|
48051a17de | ||
|
|
a3ce7cbfbc | ||
|
|
a0ba343951 | ||
|
|
46100f0d94 | ||
|
|
f4bd29a5db | ||
|
|
066c373365 | ||
|
|
499f52e100 | ||
|
|
d544fd3d85 | ||
|
|
02df8a5073 | ||
|
|
e2f6e232ee | ||
|
|
6f23bea143 | ||
|
|
e079fc1aac | ||
|
|
aeecb4c816 | ||
|
|
3be20f27bb | ||
|
|
78b57e56e8 | ||
|
|
5f9251a22e | ||
|
|
70cc553ba0 | ||
|
|
b83834e7ff | ||
|
|
bb4a9c0314 | ||
|
|
74aedf605f | ||
|
|
d248e02e4a | ||
|
|
031c0fc155 | ||
|
|
ec288f4885 | ||
|
|
848be587e3 | ||
|
|
e8d6d4de5d |
@@ -1,5 +1,4 @@
|
|||||||
<definition width="70" version="0.3" hotspot_x="49" hotspot_y="15" height="30" type="element" ic="true" orientation="dyyy"
|
<definition width="20" version="0.4" hotspot_x="3" hotspot_y="10" height="20" link_type="previous_report" type="element" ic="true" orientation="dyyy">
|
||||||
link_type="previous_report">
|
|
||||||
<names>
|
<names>
|
||||||
<name lang="ar">الصفحة السابقة</name>
|
<name lang="ar">الصفحة السابقة</name>
|
||||||
<name lang="de">Vorherige Seite</name>
|
<name lang="de">Vorherige Seite</name>
|
||||||
@@ -9,15 +8,15 @@ link_type="previous_report">
|
|||||||
<name lang="fr">Folio précédent</name>
|
<name lang="fr">Folio précédent</name>
|
||||||
<name lang="pl">Wejście adresowe</name>
|
<name lang="pl">Wejście adresowe</name>
|
||||||
<name lang="es">folio anterior</name>
|
<name lang="es">folio anterior</name>
|
||||||
<name lang="cs">Předchozí list</name>
|
|
||||||
<name lang="nl">Referentie Vorig</name>
|
<name lang="nl">Referentie Vorig</name>
|
||||||
|
<name lang="cs">Předchozí list</name>
|
||||||
</names>
|
</names>
|
||||||
<informations>Author: The QElectroTech team
|
<informations>Author: The QElectroTech team
|
||||||
License: see http://qelectrotech.org/wiki/doc/elements_license</informations>
|
License: see http://qelectrotech.org/wiki/doc/elements_license</informations>
|
||||||
<description>
|
<description>
|
||||||
<polygon x4="-1" antialias="true" style="line-style:normal;line-weight:normal;filling:black;color:black" closed="false" y1="-4" x1="-1" y2="4" x2="-1" y3="0" x3="9" y4="-4"/>
|
<polygon x4="-1" antialias="true" style="line-style:normal;line-weight:normal;filling:black;color:black" closed="false" y1="-4" x1="-1" y2="4" x2="-1" y3="0" x3="9" y4="-4"/>
|
||||||
<line length1="1.5" length2="1.5" antialias="false" end1="none" end2="none" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="9" y2="0" x2="12"/>
|
<line length1="1.5" length2="1.5" antialias="false" end1="none" end2="none" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="9" y2="0" x2="12"/>
|
||||||
<input x="-44" y="0" size="9" rotate="true" text="/"/>
|
<input x="-44" y="0" size="9" rotate="true" text="/" tagg="label"/>
|
||||||
<terminal x="13" y="0" nameHidden="0" number="" name="" orientation="e"/>
|
<terminal x="13" y="0" orientation="e"/>
|
||||||
</description>
|
</description>
|
||||||
</definition>
|
</definition>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<definition width="40" version="0.3" hotspot_x="18" hotspot_y="15" height="30" type="element" ic="true" orientation="dyyy"
|
<definition width="30" version="0.4" hotspot_x="21" hotspot_y="10" height="20" link_type="next_report" type="element" ic="true" orientation="dyyy">
|
||||||
link_type="next_report">
|
|
||||||
<names>
|
<names>
|
||||||
<name lang="ar">الصفحة التالية</name>
|
<name lang="ar">الصفحة التالية</name>
|
||||||
<name lang="de">Nächste Seite</name>
|
<name lang="de">Nächste Seite</name>
|
||||||
@@ -9,15 +8,15 @@ link_type="next_report">
|
|||||||
<name lang="fr">Folio suivant</name>
|
<name lang="fr">Folio suivant</name>
|
||||||
<name lang="pl">Wyjście adresowe</name>
|
<name lang="pl">Wyjście adresowe</name>
|
||||||
<name lang="es">Folio siguiente</name>
|
<name lang="es">Folio siguiente</name>
|
||||||
<name lang="cs">Další list</name>
|
|
||||||
<name lang="nl">Referentie volgend</name>
|
<name lang="nl">Referentie volgend</name>
|
||||||
|
<name lang="cs">Další list</name>
|
||||||
</names>
|
</names>
|
||||||
<informations>Author: The QElectroTech team
|
<informations>Author: The QElectroTech team
|
||||||
License: see http://qelectrotech.org/wiki/doc/elements_license</informations>
|
License: see http://qelectrotech.org/wiki/doc/elements_license</informations>
|
||||||
<description>
|
<description>
|
||||||
<polygon x4="-9" antialias="true" style="line-style:normal;line-weight:normal;filling:black;color:black" closed="false" y1="-4" x1="-9" y2="4" x2="-9" y3="0" x3="2" y4="-4"/>
|
<polygon x4="-9" antialias="true" style="line-style:normal;line-weight:normal;filling:black;color:black" closed="false" y1="-4" x1="-9" y2="4" x2="-9" y3="0" x3="2" y4="-4"/>
|
||||||
<line length1="1.5" length2="1.5" antialias="false" end1="none" end2="none" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="-9" y2="0" x2="-12"/>
|
<line length1="1.5" length2="1.5" antialias="false" end1="none" end2="none" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="-9" y2="0" x2="-12"/>
|
||||||
<input x="6" y="0" size="9" rotate="true" text="/"/>
|
<input x="6" y="0" size="9" rotate="true" text="/" tagg="label"/>
|
||||||
<terminal x="-13" y="0" nameHidden="0" number="" name="" orientation="w"/>
|
<terminal x="-13" y="0" orientation="w"/>
|
||||||
</description>
|
</description>
|
||||||
</definition>
|
</definition>
|
||||||
|
|||||||
BIN
ico/splash.png
BIN
ico/splash.png
Binary file not shown.
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 45 KiB |
1050
lang/qet_ar.ts
1050
lang/qet_ar.ts
File diff suppressed because it is too large
Load Diff
BIN
lang/qet_be.qm
BIN
lang/qet_be.qm
Binary file not shown.
1064
lang/qet_be.ts
1064
lang/qet_be.ts
File diff suppressed because it is too large
Load Diff
1056
lang/qet_ca.ts
1056
lang/qet_ca.ts
File diff suppressed because it is too large
Load Diff
BIN
lang/qet_cs.qm
BIN
lang/qet_cs.qm
Binary file not shown.
1150
lang/qet_cs.ts
1150
lang/qet_cs.ts
File diff suppressed because it is too large
Load Diff
BIN
lang/qet_de.qm
BIN
lang/qet_de.qm
Binary file not shown.
1166
lang/qet_de.ts
1166
lang/qet_de.ts
File diff suppressed because it is too large
Load Diff
BIN
lang/qet_el.qm
BIN
lang/qet_el.qm
Binary file not shown.
1064
lang/qet_el.ts
1064
lang/qet_el.ts
File diff suppressed because it is too large
Load Diff
BIN
lang/qet_en.qm
BIN
lang/qet_en.qm
Binary file not shown.
1062
lang/qet_en.ts
1062
lang/qet_en.ts
File diff suppressed because it is too large
Load Diff
BIN
lang/qet_es.qm
BIN
lang/qet_es.qm
Binary file not shown.
1121
lang/qet_es.ts
1121
lang/qet_es.ts
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>QETElementEditor</name>
|
<name>QETElementEditor</name>
|
||||||
<message numerus="yes">
|
<message numerus="yes">
|
||||||
<location filename="../sources/editor/qetelementeditor.cpp" line="627"/>
|
<location filename="../sources/editor/qetelementeditor.cpp" line="589"/>
|
||||||
<source>%n partie(s) sélectionnée(s).</source>
|
<source>%n partie(s) sélectionnée(s).</source>
|
||||||
<translation>
|
<translation>
|
||||||
<numerusform>%n partie sélectionnée.</numerusform>
|
<numerusform>%n partie sélectionnée.</numerusform>
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
</translation>
|
</translation>
|
||||||
</message>
|
</message>
|
||||||
<message numerus="yes">
|
<message numerus="yes">
|
||||||
<location filename="../sources/editor/qetelementeditor.cpp" line="721"/>
|
<location filename="../sources/editor/qetelementeditor.cpp" line="683"/>
|
||||||
<source>La vérification de cet élément a généré %n avertissement(s) :</source>
|
<source>La vérification de cet élément a généré %n avertissement(s) :</source>
|
||||||
<comment>message box content</comment>
|
<comment>message box content</comment>
|
||||||
<translation>
|
<translation>
|
||||||
@@ -87,8 +87,8 @@
|
|||||||
</translation>
|
</translation>
|
||||||
</message>
|
</message>
|
||||||
<message numerus="yes">
|
<message numerus="yes">
|
||||||
<location filename="../sources/diagramcommands.cpp" line="1221"/>
|
|
||||||
<location filename="../sources/diagramcommands.cpp" line="1236"/>
|
<location filename="../sources/diagramcommands.cpp" line="1236"/>
|
||||||
|
<location filename="../sources/diagramcommands.cpp" line="1251"/>
|
||||||
<source>Délier %n élément(s)</source>
|
<source>Délier %n élément(s)</source>
|
||||||
<translation>
|
<translation>
|
||||||
<numerusform>Délier %n élément</numerusform>
|
<numerusform>Délier %n élément</numerusform>
|
||||||
|
|||||||
1056
lang/qet_hr.ts
1056
lang/qet_hr.ts
File diff suppressed because it is too large
Load Diff
BIN
lang/qet_it.qm
BIN
lang/qet_it.qm
Binary file not shown.
1066
lang/qet_it.ts
1066
lang/qet_it.ts
File diff suppressed because it is too large
Load Diff
1058
lang/qet_nl.ts
1058
lang/qet_nl.ts
File diff suppressed because it is too large
Load Diff
BIN
lang/qet_pl.qm
BIN
lang/qet_pl.qm
Binary file not shown.
1066
lang/qet_pl.ts
1066
lang/qet_pl.ts
File diff suppressed because it is too large
Load Diff
1064
lang/qet_pt.ts
1064
lang/qet_pt.ts
File diff suppressed because it is too large
Load Diff
1056
lang/qet_ro.ts
1056
lang/qet_ro.ts
File diff suppressed because it is too large
Load Diff
1058
lang/qet_ru.ts
1058
lang/qet_ru.ts
File diff suppressed because it is too large
Load Diff
1056
lang/qet_sl.ts
1056
lang/qet_sl.ts
File diff suppressed because it is too large
Load Diff
@@ -24,7 +24,7 @@ APPBIN="$BUNDLE/Contents/MacOS/$APPNAME"
|
|||||||
current_dir=$(dirname "$0")
|
current_dir=$(dirname "$0")
|
||||||
|
|
||||||
# On se remet au depart
|
# On se remet au depart
|
||||||
cd ${current_dir}/../
|
cd "${current_dir}/../"
|
||||||
|
|
||||||
# Emplacement courant
|
# Emplacement courant
|
||||||
current_dir=$(PWD)
|
current_dir=$(PWD)
|
||||||
@@ -74,8 +74,11 @@ svn up
|
|||||||
# recupere le numero de la nouvelle revision
|
# recupere le numero de la nouvelle revision
|
||||||
revAp=$(svnversion | cut -d : -f 2 | tr -d '[:alpha:]')
|
revAp=$(svnversion | cut -d : -f 2 | tr -d '[:alpha:]')
|
||||||
|
|
||||||
|
# On recupere le numero de version de l'originale
|
||||||
|
tagName=$(sed -n "s/const QString displayedVersion =\(.*\)/\1/p" sources/qet.h | cut -d\" -f2 | cut -d\" -f1 )
|
||||||
|
|
||||||
# Dmg de la dernière revision déjà créé
|
# Dmg de la dernière revision déjà créé
|
||||||
if [ -e "packaging/mac-osx/${APPNAME}_$revAp.dmg" ] ; then
|
if [ -e "packaging/mac-osx/${APPNAME} $tagName r$revAp.dmg" ] ; then
|
||||||
echo "There are not new updates, make disk image can"
|
echo "There are not new updates, make disk image can"
|
||||||
echo "take a lot of time (5 min). Can you continu?"
|
echo "take a lot of time (5 min). Can you continu?"
|
||||||
echo "[y/n]"
|
echo "[y/n]"
|
||||||
@@ -101,8 +104,8 @@ echo "Adding the version tag..."
|
|||||||
mkdir temp
|
mkdir temp
|
||||||
cp -Rf "sources/qet.h" "temp/qet.h"
|
cp -Rf "sources/qet.h" "temp/qet.h"
|
||||||
|
|
||||||
# On modifie l'originale avec le numero de version
|
# On modifie l'originale avec le numero de revision du depot svn
|
||||||
sed -i "" "s/const QString displayedVersion = \"0.4-b\"/const QString displayedVersion = \"0.4-beta-r$revAp\"/" sources/qet.h
|
sed -i "" "s/const QString displayedVersion =.*/const QString displayedVersion = \"$tagName r$revAp\";/" sources/qet.h
|
||||||
|
|
||||||
# Apres la compilation
|
# Apres la compilation
|
||||||
cleanVerionTag () {
|
cleanVerionTag () {
|
||||||
@@ -179,7 +182,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# On rajoute le numero de version pour "cmd + i"
|
# On rajoute le numero de version pour "cmd + i"
|
||||||
sed -i "" "s/<string>Created by Qt\/QMake<\/string>/<string>0.4 beta r$revAp<\/string>/" qelectrotech.app/Contents/Info.plist
|
sed -i "" "s/<string>Created by Qt\/QMake<\/string>/<string>$tagName r$revAp<\/string>/" qelectrotech.app/Contents/Info.plist
|
||||||
|
|
||||||
|
|
||||||
### copy over frameworks ############################################
|
### copy over frameworks ############################################
|
||||||
@@ -241,11 +244,11 @@ echo 'Preparing (removing hold files)... '
|
|||||||
if [ -e "/Volumes/${APPNAME}" ]; then
|
if [ -e "/Volumes/${APPNAME}" ]; then
|
||||||
hdiutil detach -quiet "/Volumes/${APPNAME}"
|
hdiutil detach -quiet "/Volumes/${APPNAME}"
|
||||||
fi
|
fi
|
||||||
if [ -e "${APPNAME}_$revAp.dmg" ] ; then
|
if [ -e "${APPNAME} $tagName r$revAp.dmg" ] ; then
|
||||||
rm -f "${APPNAME}_$revAp.dmg"
|
rm -f "${APPNAME} $tagName r$revAp.dmg"
|
||||||
fi
|
fi
|
||||||
if [ -e "packaging/mac-osx/${APPNAME}_$revAp.dmg" ] ; then
|
if [ -e "packaging/mac-osx/${APPNAME} $tagName r$revAp.dmg" ] ; then
|
||||||
rm -f "packaging/mac-osx/${APPNAME}_$revAp.dmg"
|
rm -f "packaging/mac-osx/${APPNAME} $tagName r$revAp.dmg"
|
||||||
fi
|
fi
|
||||||
if [ -e $imagedir ] ; then
|
if [ -e $imagedir ] ; then
|
||||||
rm -rf $imagedir
|
rm -rf $imagedir
|
||||||
@@ -268,13 +271,13 @@ strip "$imagedir/$APPBIN"
|
|||||||
|
|
||||||
# Creating a disk image from a folder
|
# Creating a disk image from a folder
|
||||||
echo 'Creating disk image... '
|
echo 'Creating disk image... '
|
||||||
hdiutil create -quiet -ov -srcfolder $imagedir -format UDBZ -volname "${APPNAME}" "${APPNAME}_${revAp}.dmg"
|
hdiutil create -quiet -ov -srcfolder $imagedir -format UDBZ -volname "${APPNAME}" "${APPNAME} $tagName r$revAp.dmg"
|
||||||
hdiutil internet-enable -yes -quiet "${APPNAME}_${revAp}.dmg"
|
hdiutil internet-enable -yes -quiet "${APPNAME} $tagName r$revAp.dmg"
|
||||||
|
|
||||||
# Clean up disk folder
|
# Clean up disk folder
|
||||||
echo 'Cleaning up... '
|
echo 'Cleaning up... '
|
||||||
cp -Rf "${APPNAME}_$revAp.dmg" "packaging/mac-osx/${APPNAME}_$revAp.dmg"
|
cp -Rf "${APPNAME} $tagName r$revAp.dmg" "packaging/mac-osx/${APPNAME} $tagName r$revAp.dmg"
|
||||||
rm -f "${APPNAME}_$revAp.dmg"
|
rm -f "${APPNAME} $tagName r$revAp.dmg"
|
||||||
rm -rf $imagedir
|
rm -rf $imagedir
|
||||||
rm -rf $BUNDLE
|
rm -rf $BUNDLE
|
||||||
|
|
||||||
@@ -302,6 +305,8 @@ svnversion | grep -q '[MS:]' ; if [ $? -eq 0 ] ; then
|
|||||||
echo This is not the same version as the deposit.
|
echo This is not the same version as the deposit.
|
||||||
echo You can use \'svn diff\' to see the differences.
|
echo You can use \'svn diff\' to see the differences.
|
||||||
echo And use \'svn revert \<fichier\>\' to delete the difference.
|
echo And use \'svn revert \<fichier\>\' to delete the difference.
|
||||||
|
echo To go back, you can use svn update -r 360
|
||||||
|
echo to go to revision number 360.
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,8 @@ INCLUDEPATH += sources \
|
|||||||
sources/properties \
|
sources/properties \
|
||||||
sources/dvevent \
|
sources/dvevent \
|
||||||
sources/editor \
|
sources/editor \
|
||||||
sources/editor/esevent
|
sources/editor/esevent \
|
||||||
|
sources/undocommand
|
||||||
|
|
||||||
|
|
||||||
# Fichiers sources
|
# Fichiers sources
|
||||||
@@ -79,13 +80,15 @@ HEADERS += $$files(sources/*.h) $$files(sources/ui/*.h) $$files(sources/editor/*
|
|||||||
$$files(sources/properties/*.h) \
|
$$files(sources/properties/*.h) \
|
||||||
$$files(sources/editor/ui/*.h) \
|
$$files(sources/editor/ui/*.h) \
|
||||||
$$files(sources/editor/esevent/*.h) \
|
$$files(sources/editor/esevent/*.h) \
|
||||||
$$files(sources/dvevent/*.h)
|
$$files(sources/dvevent/*.h) \
|
||||||
|
$$files(sources/undocommand/*.h)
|
||||||
|
|
||||||
SOURCES += $$files(sources/*.cpp) $$files(sources/editor/*.cpp) $$files(sources/titleblock/*.cpp) $$files(sources/richtext/*.cpp) $$files(sources/ui/*.cpp) $$files(sources/qetgraphicsitem/*.cpp) $$files(sources/factory/*.cpp) \
|
SOURCES += $$files(sources/*.cpp) $$files(sources/editor/*.cpp) $$files(sources/titleblock/*.cpp) $$files(sources/richtext/*.cpp) $$files(sources/ui/*.cpp) $$files(sources/qetgraphicsitem/*.cpp) $$files(sources/factory/*.cpp) \
|
||||||
$$files(sources/properties/*.cpp) \
|
$$files(sources/properties/*.cpp) \
|
||||||
$$files(sources/editor/ui/*.cpp) \
|
$$files(sources/editor/ui/*.cpp) \
|
||||||
$$files(sources/editor/esevent/*.cpp) \
|
$$files(sources/editor/esevent/*.cpp) \
|
||||||
$$files(sources/dvevent/*.cpp)
|
$$files(sources/dvevent/*.cpp) \
|
||||||
|
$$files(sources/undocommand/*.cpp)
|
||||||
|
|
||||||
# Liste des fichiers qui seront incorpores au binaire en tant que ressources Qt
|
# Liste des fichiers qui seront incorpores au binaire en tant que ressources Qt
|
||||||
RESOURCES += qelectrotech.qrc
|
RESOURCES += qelectrotech.qrc
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "conductor.h"
|
#include "conductor.h"
|
||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
#include "potentialtextsdialog.h"
|
#include "potentialtextsdialog.h"
|
||||||
|
#include "qet.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*Constructor
|
*Constructor
|
||||||
@@ -59,7 +60,7 @@ void ConductorAutoNumerotation::checkPotential(Conductor *conductor) {
|
|||||||
foreach (const Conductor *c, c_list) strl<<(c->text());
|
foreach (const Conductor *c, c_list) strl<<(c->text());
|
||||||
|
|
||||||
//check text list, isn't same in potential, ask user what to do
|
//check text list, isn't same in potential, ask user what to do
|
||||||
if (!eachIsEqual(strl)) {
|
if (!QET::eachStrIsEqual(strl)) {
|
||||||
PotentialTextsDialog ptd(conductor, conductor->diagramEditor());
|
PotentialTextsDialog ptd(conductor, conductor->diagramEditor());
|
||||||
if ( ptd.exec() == QDialog::Accepted ) {
|
if ( ptd.exec() == QDialog::Accepted ) {
|
||||||
ConductorAutoNumerotation can(conductor);
|
ConductorAutoNumerotation can(conductor);
|
||||||
@@ -111,7 +112,7 @@ void ConductorAutoNumerotation::numeratePotential() {
|
|||||||
QStringList strl;
|
QStringList strl;
|
||||||
foreach (const Conductor *cc, conductor_list) strl<<(cc->text());
|
foreach (const Conductor *cc, conductor_list) strl<<(cc->text());
|
||||||
//the texts is identicals
|
//the texts is identicals
|
||||||
if (eachIsEqual(strl)) {
|
if (QET::eachStrIsEqual(strl)) {
|
||||||
ConductorProperties cp = conductor_ -> properties();
|
ConductorProperties cp = conductor_ -> properties();
|
||||||
cp.text = strl.at(0);
|
cp.text = strl.at(0);
|
||||||
conductor_ -> setProperties(cp);
|
conductor_ -> setProperties(cp);
|
||||||
@@ -140,13 +141,3 @@ void ConductorAutoNumerotation::numerateNewConductor() {
|
|||||||
applyText(ncc.toRepresentedString());
|
applyText(ncc.toRepresentedString());
|
||||||
m_diagram->project()->addConductorAutoNum(m_diagram -> conductorsAutonumName(), ncc.next());
|
m_diagram->project()->addConductorAutoNum(m_diagram -> conductorsAutonumName(), ncc.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return true if every text of qsl is identical, else false.
|
|
||||||
*/
|
|
||||||
bool eachIsEqual (const QStringList &qsl) {
|
|
||||||
foreach (const QString t, qsl) {
|
|
||||||
if (qsl.at(0) != t) return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -44,6 +44,4 @@ class ConductorAutoNumerotation {
|
|||||||
QSet <Conductor *> conductor_list;
|
QSet <Conductor *> conductor_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool eachIsEqual (const QStringList &);
|
|
||||||
|
|
||||||
#endif // CONDUCTORAUTONUMEROTATION_H
|
#endif // CONDUCTORAUTONUMEROTATION_H
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) : ConfigPage
|
|||||||
projects_view_mode_ = new QGroupBox(tr("Projets"), this);
|
projects_view_mode_ = new QGroupBox(tr("Projets"), this);
|
||||||
windowed_mode_ = new QRadioButton(tr("Utiliser des fen\352tres"), projects_view_mode_);
|
windowed_mode_ = new QRadioButton(tr("Utiliser des fen\352tres"), projects_view_mode_);
|
||||||
tabbed_mode_ = new QRadioButton(tr("Utiliser des onglets"), projects_view_mode_);
|
tabbed_mode_ = new QRadioButton(tr("Utiliser des onglets"), projects_view_mode_);
|
||||||
use_trackpad_ = new QCheckBox(tr("Utiliser les gestures du trackpad"), projects_view_mode_);
|
use_trackpad_ = new QCheckBox(tr("Utiliser les gestes du pav\351 tactile"), projects_view_mode_);
|
||||||
warning_view_mode_ = new QLabel(tr("Ces param\350tres s'appliqueront d\350s la prochaine ouverture d'un \351diteur de sch\351mas."));
|
warning_view_mode_ = new QLabel(tr("Ces param\350tres s'appliqueront d\350s la prochaine ouverture d'un \351diteur de sch\351mas."));
|
||||||
|
|
||||||
elements_management_ = new QGroupBox(tr("Gestion des \351l\351ments"), this);
|
elements_management_ = new QGroupBox(tr("Gestion des \351l\351ments"), this);
|
||||||
|
|||||||
@@ -41,20 +41,22 @@ const qreal Diagram::margin = 5.0;
|
|||||||
|
|
||||||
// static variable to keep track of present background color of the diagram.
|
// static variable to keep track of present background color of the diagram.
|
||||||
QColor Diagram::background_color = Qt::white;
|
QColor Diagram::background_color = Qt::white;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur
|
* @brief Diagram::Diagram
|
||||||
@param parent Le QObject parent du schema
|
* Constructor
|
||||||
|
* @param project : The project of this diagram and also parent QObject
|
||||||
*/
|
*/
|
||||||
Diagram::Diagram(QObject *parent) :
|
Diagram::Diagram(QETProject *project) :
|
||||||
QGraphicsScene(parent),
|
QGraphicsScene (project),
|
||||||
project_(0),
|
project_ (nullptr),
|
||||||
diagram_qet_version_ (-1),
|
diagram_qet_version_ (-1),
|
||||||
draw_grid_ (true),
|
draw_grid_ (true),
|
||||||
use_border_ (true),
|
use_border_ (true),
|
||||||
draw_terminals_ (true),
|
draw_terminals_ (true),
|
||||||
draw_colored_conductors_(true),
|
draw_colored_conductors_ (true)
|
||||||
read_only_(false)
|
|
||||||
{
|
{
|
||||||
|
setProject(project);
|
||||||
qgi_manager_ = new QGIManager(this);
|
qgi_manager_ = new QGIManager(this);
|
||||||
setBackgroundBrush(Qt::white);
|
setBackgroundBrush(Qt::white);
|
||||||
conductor_setter_ = new QGraphicsLineItem(0, 0);
|
conductor_setter_ = new QGraphicsLineItem(0, 0);
|
||||||
@@ -66,18 +68,12 @@ Diagram::Diagram(QObject *parent) :
|
|||||||
conductor_setter_ -> setPen(t);
|
conductor_setter_ -> setPen(t);
|
||||||
conductor_setter_ -> setLine(QLineF(QPointF(0.0, 0.0), QPointF(0.0, 0.0)));
|
conductor_setter_ -> setLine(QLineF(QPointF(0.0, 0.0), QPointF(0.0, 0.0)));
|
||||||
|
|
||||||
// initialise les objets gerant les deplacements
|
//Init object for manage movement
|
||||||
elements_mover_ = new ElementsMover(); // deplacements d'elements/conducteurs/textes
|
elements_mover_ = new ElementsMover();
|
||||||
element_texts_mover_ = new ElementTextsMover(); // deplacements d'ElementTextItem
|
element_texts_mover_ = new ElementTextsMover();
|
||||||
|
|
||||||
connect(
|
connect(&border_and_titleblock, SIGNAL(needTitleBlockTemplate(const QString &)), this, SLOT(setTitleBlockTemplate(const QString &)));
|
||||||
&border_and_titleblock, SIGNAL(needTitleBlockTemplate(const QString &)),
|
connect(&border_and_titleblock, SIGNAL(diagramTitleChanged(const QString &)), this, SLOT(titleChanged(const QString &)));
|
||||||
this, SLOT(setTitleBlockTemplate(const QString &))
|
|
||||||
);
|
|
||||||
connect(
|
|
||||||
&border_and_titleblock, SIGNAL(diagramTitleChanged(const QString &)),
|
|
||||||
this, SLOT(titleChanged(const QString &))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -555,7 +551,7 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
|
|||||||
if (type_id.startsWith("embed://")) element_location.setProject(project_);
|
if (type_id.startsWith("embed://")) element_location.setProject(project_);
|
||||||
|
|
||||||
int state = 0;
|
int state = 0;
|
||||||
Element *nvel_elmt = ElementFactory::Instance()->createElement(element_location, 0, this, &state);
|
Element *nvel_elmt = ElementFactory::Instance() -> createElement(element_location, 0, &state);
|
||||||
if (state) {
|
if (state) {
|
||||||
QString debug_message = QString("Diagram::fromXml() : Le chargement de la description de l'element %1 a echoue avec le code d'erreur %2").arg(element_location.path()).arg(state);
|
QString debug_message = QString("Diagram::fromXml() : Le chargement de la description de l'element %1 a echoue avec le code d'erreur %2").arg(element_location.path()).arg(state);
|
||||||
qDebug() << qPrintable(debug_message);
|
qDebug() << qPrintable(debug_message);
|
||||||
@@ -576,15 +572,16 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// chargement de tous les textes du fichiers XML
|
// Load text
|
||||||
QList<IndependentTextItem *> added_texts;
|
QList<IndependentTextItem *> added_texts;
|
||||||
foreach (QDomElement text_xml, QET::findInDomElement(root, "inputs", "input")) {
|
foreach (QDomElement text_xml, QET::findInDomElement(root, "inputs", "input")) {
|
||||||
IndependentTextItem *iti = new IndependentTextItem(this);
|
IndependentTextItem *iti = new IndependentTextItem();
|
||||||
iti -> fromXml(text_xml);
|
iti -> fromXml(text_xml);
|
||||||
addItem(iti);
|
addItem(iti);
|
||||||
added_texts << iti;
|
added_texts << iti;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load image
|
||||||
QList<DiagramImageItem *> added_images;
|
QList<DiagramImageItem *> added_images;
|
||||||
foreach (QDomElement image_xml, QET::findInDomElement(root, "images", "image")) {
|
foreach (QDomElement image_xml, QET::findInDomElement(root, "images", "image")) {
|
||||||
DiagramImageItem *dii = new DiagramImageItem ();
|
DiagramImageItem *dii = new DiagramImageItem ();
|
||||||
@@ -593,6 +590,7 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
|
|||||||
added_images << dii;
|
added_images << dii;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load shape
|
||||||
QList<QetShapeItem *> added_shapes;
|
QList<QetShapeItem *> added_shapes;
|
||||||
foreach (QDomElement shape_xml, QET::findInDomElement(root, "shapes", "shape")) {
|
foreach (QDomElement shape_xml, QET::findInDomElement(root, "shapes", "shape")) {
|
||||||
QetShapeItem *dii = new QetShapeItem (QPointF(0,0));
|
QetShapeItem *dii = new QetShapeItem (QPointF(0,0));
|
||||||
@@ -601,71 +599,53 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
|
|||||||
added_shapes << dii;
|
added_shapes << dii;
|
||||||
}
|
}
|
||||||
|
|
||||||
// gere la translation des nouveaux elements et texte si celle-ci est demandee
|
// Load conductor
|
||||||
if (position != QPointF()) {
|
|
||||||
// determine quel est le coin superieur gauche du rectangle entourant les elements ajoutes
|
|
||||||
qreal minimum_x = 0, minimum_y = 0;
|
|
||||||
bool init = false;
|
|
||||||
QList<QGraphicsItem *> added_items;
|
|
||||||
foreach (Element *added_element, added_elements) added_items << added_element;
|
|
||||||
foreach (DiagramTextItem *added_text, added_texts) added_items << added_text;
|
|
||||||
foreach (DiagramImageItem *added_image, added_images) added_items << added_image;
|
|
||||||
foreach (QetShapeItem *added_shape, added_shapes) added_items << added_shape;
|
|
||||||
foreach (QGraphicsItem *item, added_items) {
|
|
||||||
QPointF csg = item -> mapToScene(item -> boundingRect()).boundingRect().topLeft();
|
|
||||||
qreal px = csg.x();
|
|
||||||
qreal py = csg.y();
|
|
||||||
if (!init) {
|
|
||||||
minimum_x = px;
|
|
||||||
minimum_y = py;
|
|
||||||
init = true;
|
|
||||||
} else {
|
|
||||||
if (px < minimum_x) minimum_x = px;
|
|
||||||
if (py < minimum_y) minimum_y = py;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
qreal diff_x = position.x() - minimum_x;
|
|
||||||
qreal diff_y = position.y() - minimum_y;
|
|
||||||
foreach (Element *added_element, added_elements) {
|
|
||||||
added_element -> setPos(added_element -> pos().x() + diff_x, added_element -> pos().y() + diff_y);
|
|
||||||
}
|
|
||||||
foreach (DiagramTextItem *added_text, added_texts) {
|
|
||||||
added_text -> setPos(added_text -> pos().x() + diff_x, added_text -> pos().y() + diff_y);
|
|
||||||
}
|
|
||||||
foreach (DiagramImageItem *added_image, added_images) {
|
|
||||||
added_image -> setPos(added_image -> pos().x() + diff_x, added_image -> pos().y() + diff_y);
|
|
||||||
}
|
|
||||||
foreach (QetShapeItem *added_shape, added_shapes) {
|
|
||||||
added_shape -> setPos(added_shape -> pos().x() + diff_x, added_shape -> pos().y() + diff_y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// chargement de tous les Conducteurs du fichier XML
|
|
||||||
QList<Conductor *> added_conductors;
|
QList<Conductor *> added_conductors;
|
||||||
foreach (QDomElement f, QET::findInDomElement(root, "conductors", "conductor")) {
|
foreach (QDomElement f, QET::findInDomElement(root, "conductors", "conductor"))
|
||||||
|
{
|
||||||
if (!Conductor::valideXml(f)) continue;
|
if (!Conductor::valideXml(f)) continue;
|
||||||
// verifie que les bornes que le conducteur relie sont connues
|
|
||||||
|
//Check if terminal that conductor must be linked is know
|
||||||
int id_p1 = f.attribute("terminal1").toInt();
|
int id_p1 = f.attribute("terminal1").toInt();
|
||||||
int id_p2 = f.attribute("terminal2").toInt();
|
int id_p2 = f.attribute("terminal2").toInt();
|
||||||
if (table_adr_id.contains(id_p1) && table_adr_id.contains(id_p2)) {
|
if (table_adr_id.contains(id_p1) && table_adr_id.contains(id_p2))
|
||||||
// pose le conducteur... si c'est possible
|
{
|
||||||
Terminal *p1 = table_adr_id.value(id_p1);
|
Terminal *p1 = table_adr_id.value(id_p1);
|
||||||
Terminal *p2 = table_adr_id.value(id_p2);
|
Terminal *p2 = table_adr_id.value(id_p2);
|
||||||
if (p1 != p2) {
|
if (p1 != p2)
|
||||||
bool can_add_conductor = true;
|
{
|
||||||
bool cia = ((Element *)p2 -> parentItem()) -> internalConnections();
|
Conductor *c = new Conductor(table_adr_id.value(id_p1), table_adr_id.value(id_p2));
|
||||||
if (!cia) {
|
addItem(c);
|
||||||
foreach(QGraphicsItem *item, p2 -> parentItem() -> children()) {
|
|
||||||
if (item == p1) can_add_conductor = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (can_add_conductor) {
|
|
||||||
Conductor *c = new Conductor(table_adr_id.value(id_p1), table_adr_id.value(id_p2), this);
|
|
||||||
c -> fromXml(f);
|
c -> fromXml(f);
|
||||||
added_conductors << c;
|
added_conductors << c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else qDebug() << "Diagram::fromXml() : Le chargement du conducteur" << id_p1 << id_p2 << "a echoue";
|
else qDebug() << "Diagram::fromXml() : Le chargement du conducteur" << id_p1 << id_p2 << "a echoue";
|
||||||
|
}
|
||||||
|
|
||||||
|
//Translate items if a new position was given in parameter
|
||||||
|
if (position != QPointF()) {
|
||||||
|
|
||||||
|
QList<QGraphicsItem *> added_items;
|
||||||
|
foreach (Element *added_element, added_elements ) added_items << added_element;
|
||||||
|
foreach (Conductor *added_cond, added_conductors) added_items << added_cond;
|
||||||
|
foreach (QetShapeItem *added_shape, added_shapes ) added_items << added_shape;
|
||||||
|
foreach (DiagramTextItem *added_text, added_texts ) added_items << added_text;
|
||||||
|
foreach (DiagramImageItem *added_image, added_images ) added_items << added_image;
|
||||||
|
|
||||||
|
//Get the top left corner of the rectangle that contain all added items
|
||||||
|
QRectF items_rect;
|
||||||
|
foreach (QGraphicsItem *item, added_items) {
|
||||||
|
items_rect = items_rect.united(item -> mapToScene(item -> boundingRect()).boundingRect());
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF point_ = items_rect.topLeft();
|
||||||
|
QPointF pos_ = Diagram::snapToGrid(QPointF (position.x() - point_.x(),
|
||||||
|
position.y() - point_.y()));
|
||||||
|
|
||||||
|
//Translate all added items
|
||||||
|
foreach (QGraphicsItem *qgi, added_items)
|
||||||
|
qgi -> setPos( qgi -> pos() += pos_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// remplissage des listes facultatives
|
// remplissage des listes facultatives
|
||||||
@@ -758,6 +738,7 @@ void Diagram::addItem(Conductor *conductor) {
|
|||||||
QGraphicsScene::addItem(conductor);
|
QGraphicsScene::addItem(conductor);
|
||||||
conductor -> terminal1 -> addConductor(conductor);
|
conductor -> terminal1 -> addConductor(conductor);
|
||||||
conductor -> terminal2 -> addConductor(conductor);
|
conductor -> terminal2 -> addConductor(conductor);
|
||||||
|
conductor -> calculateTextItemPosition();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1196,6 +1177,22 @@ QSet<ConductorTextItem *> Diagram::selectedConductorTexts() const {
|
|||||||
return(selected_texts);
|
return(selected_texts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Diagram::selectedElementTexts
|
||||||
|
* @return the list of element texts selected
|
||||||
|
*/
|
||||||
|
QSet<ElementTextItem*> Diagram::selectedElementTexts() const {
|
||||||
|
QSet<ElementTextItem *> selected_texts;
|
||||||
|
foreach(QGraphicsItem *item, selectedItems()) {
|
||||||
|
if (ElementTextItem *cti = qgraphicsitem_cast< ElementTextItem*>(item)) {
|
||||||
|
selected_texts << cti;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(selected_texts);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @return true si le presse-papier semble contenir un schema
|
/// @return true si le presse-papier semble contenir un schema
|
||||||
bool Diagram::clipboardMayContainDiagram() {
|
bool Diagram::clipboardMayContainDiagram() {
|
||||||
QString clipboard_text = QApplication::clipboard() -> text().trimmed();
|
QString clipboard_text = QApplication::clipboard() -> text().trimmed();
|
||||||
@@ -1213,19 +1210,25 @@ QETProject *Diagram::project() const {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Diagram::setProject
|
* @brief Diagram::setProject
|
||||||
* @param project: set parent project of this diagram or 0 if this diagram haven't got a parent project
|
* Set parent project of this diagram, project also become the parent QObject of this diagram
|
||||||
|
* @param project new project
|
||||||
*/
|
*/
|
||||||
void Diagram::setProject(QETProject *project) {
|
void Diagram::setProject(QETProject *project)
|
||||||
if (project_) {
|
{
|
||||||
|
if (project_ == project) return;
|
||||||
|
|
||||||
|
if (project_)
|
||||||
|
{
|
||||||
disconnect (project_, SIGNAL(reportPropertiesChanged(QString)), this, SIGNAL(reportPropertiesChanged(QString)));
|
disconnect (project_, SIGNAL(reportPropertiesChanged(QString)), this, SIGNAL(reportPropertiesChanged(QString)));
|
||||||
disconnect (project_, SIGNAL(XRefPropertiesChanged()), this, SIGNAL(XRefPropertiesChanged()));
|
disconnect (project_, SIGNAL(XRefPropertiesChanged()), this, SIGNAL(XRefPropertiesChanged()));
|
||||||
}
|
}
|
||||||
|
|
||||||
project_ = project;
|
project_ = project;
|
||||||
if (project_) {
|
setParent (project);
|
||||||
|
|
||||||
connect (project_, SIGNAL(reportPropertiesChanged(QString)), this, SIGNAL(reportPropertiesChanged(QString)));
|
connect (project_, SIGNAL(reportPropertiesChanged(QString)), this, SIGNAL(reportPropertiesChanged(QString)));
|
||||||
connect (project_, SIGNAL(XRefPropertiesChanged()), this, SIGNAL(XRefPropertiesChanged()));
|
connect (project_, SIGNAL(XRefPropertiesChanged()), this, SIGNAL(XRefPropertiesChanged()));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return the folio number of this diagram within its parent project, or -1
|
@return the folio number of this diagram within its parent project, or -1
|
||||||
@@ -1253,20 +1256,13 @@ qreal Diagram::declaredQElectroTechVersion(bool fallback_to_project) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return true si le schema est en lecture seule
|
* @brief Diagram::isReadOnly
|
||||||
|
* @return true if this diagram is read only.
|
||||||
|
* This method is same has call Diagram::project() -> isReadOnly()
|
||||||
*/
|
*/
|
||||||
bool Diagram::isReadOnly() const {
|
bool Diagram::isReadOnly() const
|
||||||
return(read_only_);
|
{
|
||||||
}
|
return project_ -> isReadOnly();
|
||||||
|
|
||||||
/**
|
|
||||||
@param read_only true pour passer le schema en lecture seule, false sinon
|
|
||||||
*/
|
|
||||||
void Diagram::setReadOnly(bool read_only) {
|
|
||||||
if (read_only_ != read_only) {
|
|
||||||
read_only_ = read_only;
|
|
||||||
emit(readOnlyChanged(read_only_));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -47,14 +47,14 @@ class ElementTextsMover;
|
|||||||
This class represents an electric diagram. It manages its various child
|
This class represents an electric diagram. It manages its various child
|
||||||
elements, conductors and texts and handles their graphic rendering.
|
elements, conductors and texts and handles their graphic rendering.
|
||||||
*/
|
*/
|
||||||
class Diagram : public QGraphicsScene {
|
class Diagram : public QGraphicsScene
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
Diagram(QObject * = 0);
|
Diagram(QETProject *project);
|
||||||
virtual ~Diagram();
|
virtual ~Diagram();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Diagram(const Diagram &diagram);
|
Diagram(const Diagram &diagram);
|
||||||
|
|
||||||
@@ -97,7 +97,6 @@ class Diagram : public QGraphicsScene {
|
|||||||
bool use_border_;
|
bool use_border_;
|
||||||
bool draw_terminals_;
|
bool draw_terminals_;
|
||||||
bool draw_colored_conductors_;
|
bool draw_colored_conductors_;
|
||||||
bool read_only_;
|
|
||||||
|
|
||||||
QString m_conductors_autonum_name;
|
QString m_conductors_autonum_name;
|
||||||
|
|
||||||
@@ -124,10 +123,7 @@ class Diagram : public QGraphicsScene {
|
|||||||
int folioIndex() const;
|
int folioIndex() const;
|
||||||
qreal declaredQElectroTechVersion(bool = true) const;
|
qreal declaredQElectroTechVersion(bool = true) const;
|
||||||
void showMe() {emit showDiagram(this);}
|
void showMe() {emit showDiagram(this);}
|
||||||
|
|
||||||
// methods related to read only mode
|
|
||||||
bool isReadOnly() const;
|
bool isReadOnly() const;
|
||||||
void setReadOnly(bool);
|
|
||||||
|
|
||||||
// methods related to conductor creation
|
// methods related to conductor creation
|
||||||
void setConductor(bool);
|
void setConductor(bool);
|
||||||
@@ -184,6 +180,7 @@ class Diagram : public QGraphicsScene {
|
|||||||
QList<Element *> elements() const;
|
QList<Element *> elements() const;
|
||||||
QSet<DiagramTextItem *> selectedTexts() const;
|
QSet<DiagramTextItem *> selectedTexts() const;
|
||||||
QSet<ConductorTextItem *> selectedConductorTexts() const;
|
QSet<ConductorTextItem *> selectedConductorTexts() const;
|
||||||
|
QSet<ElementTextItem*> selectedElementTexts() const;
|
||||||
QSet<Conductor *> selectedConductors() const;
|
QSet<Conductor *> selectedConductors() const;
|
||||||
DiagramContent content() const;
|
DiagramContent content() const;
|
||||||
DiagramContent selectedContent();
|
DiagramContent selectedContent();
|
||||||
@@ -215,13 +212,10 @@ class Diagram : public QGraphicsScene {
|
|||||||
signals:
|
signals:
|
||||||
void showDiagram (Diagram *);
|
void showDiagram (Diagram *);
|
||||||
void written();
|
void written();
|
||||||
void readOnlyChanged(bool);
|
|
||||||
void usedTitleBlockTemplateChanged(const QString &);
|
void usedTitleBlockTemplateChanged(const QString &);
|
||||||
void diagramTitleChanged(Diagram *, const QString &);
|
void diagramTitleChanged(Diagram *, const QString &);
|
||||||
/// Signal emitted when users wish to locate an element from the diagram within elements collection
|
void findElementRequired(const ElementsLocation &); /// Signal emitted when users wish to locate an element from the diagram within elements collection
|
||||||
void findElementRequired(const ElementsLocation &);
|
void editElementRequired(const ElementsLocation &); /// Signal emitted when users wish to edit an element from the diagram
|
||||||
/// Signal emitted when users wish to edit an element from the diagram
|
|
||||||
void editElementRequired(const ElementsLocation &);
|
|
||||||
void reportPropertiesChanged(QString);
|
void reportPropertiesChanged(QString);
|
||||||
void XRefPropertiesChanged();
|
void XRefPropertiesChanged();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -77,17 +77,22 @@ DeleteElementsCommand::~DeleteElementsCommand() {
|
|||||||
/// annule les suppressions
|
/// annule les suppressions
|
||||||
void DeleteElementsCommand::undo() {
|
void DeleteElementsCommand::undo() {
|
||||||
diagram -> showMe();
|
diagram -> showMe();
|
||||||
// remet les elements
|
|
||||||
foreach(Element *e, removed_content.elements) {
|
foreach(Element *e, removed_content.elements) {
|
||||||
diagram -> addItem(e);
|
diagram -> addItem(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// remet les conducteurs
|
//We relink element after every element was added to diagram
|
||||||
|
foreach(Element *e, removed_content.elements) {
|
||||||
|
foreach (Element *elmt, m_link_hash[e]) {
|
||||||
|
e -> linkToElement(elmt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach(Conductor *c, removed_content.conductors(DiagramContent::AnyConductor)) {
|
foreach(Conductor *c, removed_content.conductors(DiagramContent::AnyConductor)) {
|
||||||
diagram -> addItem(c);
|
diagram -> addItem(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
// remet les textes
|
|
||||||
foreach(IndependentTextItem *t, removed_content.textFields) {
|
foreach(IndependentTextItem *t, removed_content.textFields) {
|
||||||
diagram -> addItem(t);
|
diagram -> addItem(t);
|
||||||
}
|
}
|
||||||
@@ -113,7 +118,7 @@ void DeleteElementsCommand::redo() {
|
|||||||
diagram -> removeItem(c);
|
diagram -> removeItem(c);
|
||||||
|
|
||||||
//If option one text per folio is enable, and the text item of
|
//If option one text per folio is enable, and the text item of
|
||||||
//current conductor is visible (that mean the conductor own the single displayed text)
|
//current conductor is visible (that mean the conductor have the single displayed text)
|
||||||
//We call adjustTextItemPosition to other conductor at the same potential to keep
|
//We call adjustTextItemPosition to other conductor at the same potential to keep
|
||||||
//a visible text on this potential.
|
//a visible text on this potential.
|
||||||
if (diagram -> defaultConductorProperties.m_one_text_per_folio && c -> textItem() -> isVisible()) {
|
if (diagram -> defaultConductorProperties.m_one_text_per_folio && c -> textItem() -> isVisible()) {
|
||||||
@@ -127,6 +132,9 @@ void DeleteElementsCommand::redo() {
|
|||||||
|
|
||||||
// Remove elements
|
// Remove elements
|
||||||
foreach(Element *e, removed_content.elements) {
|
foreach(Element *e, removed_content.elements) {
|
||||||
|
//Get linked element, for relink it at undo
|
||||||
|
if (!e->linkedElements().isEmpty())
|
||||||
|
m_link_hash.insert(e, e->linkedElements());
|
||||||
diagram -> removeItem(e);
|
diagram -> removeItem(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,6 +232,13 @@ void PasteDiagramCommand::redo() {
|
|||||||
eti -> setPlainText("_");
|
eti -> setPlainText("_");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Reset the text of conductors
|
||||||
|
foreach (Conductor *c, content.conductorsToMove) {
|
||||||
|
ConductorProperties cp = c -> properties();
|
||||||
|
cp.text = c->diagram() ? c -> diagram() -> defaultConductorProperties.text : "_";
|
||||||
|
c -> setProperties(cp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// paste the elements
|
// paste the elements
|
||||||
|
|||||||
@@ -101,6 +101,8 @@ class DeleteElementsCommand : public QUndoCommand {
|
|||||||
DiagramContent removed_content;
|
DiagramContent removed_content;
|
||||||
/// diagram which the content is removed from
|
/// diagram which the content is removed from
|
||||||
Diagram *diagram;
|
Diagram *diagram;
|
||||||
|
/// keep linked element for each removed element linked to other element.
|
||||||
|
QHash <Element *, QList<Element *> > m_link_hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -96,7 +96,8 @@ bool DiagramContext::keyMustShow(const QString &key) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DiagramContext::operator==(const DiagramContext &dc) const {
|
bool DiagramContext::operator==(const DiagramContext &dc) const {
|
||||||
return(content_ == dc.content_);
|
return(content_ == dc.content_ &&
|
||||||
|
content_show == dc.content_show);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DiagramContext::operator!=(const DiagramContext &dc) const {
|
bool DiagramContext::operator!=(const DiagramContext &dc) const {
|
||||||
|
|||||||
@@ -24,17 +24,13 @@ qreal DiagramFolioList::colWidths[4] = {0.1, 0.55, 0.2, 0.15};
|
|||||||
/**
|
/**
|
||||||
* @brief DiagramFolioList::DiagramFolioList
|
* @brief DiagramFolioList::DiagramFolioList
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param project QETproject *: The project from which this constructor was called. Important to setProject().
|
* @param project : The project of this diagram and also parent QObject
|
||||||
* @param parent parent QObject
|
|
||||||
*/
|
*/
|
||||||
DiagramFolioList::DiagramFolioList( QETProject *project, QObject *parent) : Diagram(parent) {
|
DiagramFolioList::DiagramFolioList( QETProject *project) :
|
||||||
if (project) {
|
Diagram(project)
|
||||||
setProject(project);
|
{
|
||||||
id = project -> getFolioSheetsQuantity();
|
id = project -> getFolioSheetsQuantity();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
id = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief DiagramFolioList::~DiagramFolioList
|
* @brief DiagramFolioList::~DiagramFolioList
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
class DiagramFolioList : public Diagram
|
class DiagramFolioList : public Diagram
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DiagramFolioList( QETProject *project = 0, QObject *parent = 0);
|
DiagramFolioList(QETProject *project);
|
||||||
virtual ~DiagramFolioList();
|
virtual ~DiagramFolioList();
|
||||||
virtual QList<QLineF *> lines() const {return list_lines_;}
|
virtual QList<QLineF *> lines() const {return list_lines_;}
|
||||||
virtual QList<QRectF *> rectangles() const {return list_rectangles_;}
|
virtual QList<QRectF *> rectangles() const {return list_rectangles_;}
|
||||||
|
|||||||
@@ -48,11 +48,14 @@
|
|||||||
@param diagram Schema a afficher ; si diagram vaut 0, un nouveau Diagram est utilise
|
@param diagram Schema a afficher ; si diagram vaut 0, un nouveau Diagram est utilise
|
||||||
@param parent Le QWidget parent de cette vue de schema
|
@param parent Le QWidget parent de cette vue de schema
|
||||||
*/
|
*/
|
||||||
DiagramView::DiagramView(Diagram *diagram, QWidget *parent) : QGraphicsView(parent) {
|
DiagramView::DiagramView(Diagram *diagram, QWidget *parent) :
|
||||||
|
QGraphicsView (parent),
|
||||||
|
scene (diagram),
|
||||||
|
m_event_interface (nullptr)
|
||||||
|
{
|
||||||
grabGesture(Qt::PinchGesture);
|
grabGesture(Qt::PinchGesture);
|
||||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
setInteractive(true);
|
setInteractive(true);
|
||||||
m_event_interface = nullptr;
|
|
||||||
|
|
||||||
QString whatsthis = tr(
|
QString whatsthis = tr(
|
||||||
"Ceci est la zone dans laquelle vous concevez vos sch\351mas en y ajoutant"
|
"Ceci est la zone dans laquelle vous concevez vos sch\351mas en y ajoutant"
|
||||||
@@ -67,7 +70,6 @@ DiagramView::DiagramView(Diagram *diagram, QWidget *parent) : QGraphicsView(pare
|
|||||||
setRenderHint(QPainter::TextAntialiasing, true);
|
setRenderHint(QPainter::TextAntialiasing, true);
|
||||||
setRenderHint(QPainter::SmoothPixmapTransform, true);
|
setRenderHint(QPainter::SmoothPixmapTransform, true);
|
||||||
|
|
||||||
scene = diagram ? diagram : new Diagram(this);
|
|
||||||
setScene(scene);
|
setScene(scene);
|
||||||
scene -> undoStack().setClean();
|
scene -> undoStack().setClean();
|
||||||
setWindowIcon(QET::Icons::QETLogo);
|
setWindowIcon(QET::Icons::QETLogo);
|
||||||
@@ -84,7 +86,6 @@ DiagramView::DiagramView(Diagram *diagram, QWidget *parent) : QGraphicsView(pare
|
|||||||
|
|
||||||
connect(scene, SIGNAL(showDiagram(Diagram*)), this, SIGNAL(showDiagram(Diagram*)));
|
connect(scene, SIGNAL(showDiagram(Diagram*)), this, SIGNAL(showDiagram(Diagram*)));
|
||||||
connect(scene, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
|
connect(scene, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
|
||||||
connect(scene, SIGNAL(readOnlyChanged(bool)), this, SLOT(applyReadOnly()));
|
|
||||||
connect(&(scene -> border_and_titleblock), SIGNAL(borderChanged(QRectF, QRectF)), this, SLOT(adjustSceneRect()));
|
connect(&(scene -> border_and_titleblock), SIGNAL(borderChanged(QRectF, QRectF)), this, SLOT(adjustSceneRect()));
|
||||||
connect(&(scene -> border_and_titleblock), SIGNAL(displayChanged()), this, SLOT(adjustSceneRect()));
|
connect(&(scene -> border_and_titleblock), SIGNAL(displayChanged()), this, SLOT(adjustSceneRect()));
|
||||||
connect(&(scene -> border_and_titleblock), SIGNAL(diagramTitleChanged(const QString &)), this, SLOT(updateWindowTitle()));
|
connect(&(scene -> border_and_titleblock), SIGNAL(diagramTitleChanged(const QString &)), this, SLOT(updateWindowTitle()));
|
||||||
@@ -314,7 +315,7 @@ void DiagramView::handleTitleBlockDrop(QDropEvent *e) {
|
|||||||
void DiagramView::handleTextDrop(QDropEvent *e) {
|
void DiagramView::handleTextDrop(QDropEvent *e) {
|
||||||
if (scene -> isReadOnly() || (e -> mimeData() -> hasText() == false) ) return;
|
if (scene -> isReadOnly() || (e -> mimeData() -> hasText() == false) ) return;
|
||||||
|
|
||||||
IndependentTextItem *iti = new IndependentTextItem (e -> mimeData() -> text(), scene);
|
IndependentTextItem *iti = new IndependentTextItem (e -> mimeData() -> text());
|
||||||
|
|
||||||
if (e -> mimeData() -> hasHtml()) {
|
if (e -> mimeData() -> hasHtml()) {
|
||||||
iti -> setHtml (e -> mimeData() -> text());
|
iti -> setHtml (e -> mimeData() -> text());
|
||||||
@@ -863,7 +864,7 @@ bool DiagramView::mustIntegrateTitleBlockTemplate(const TitleBlockTemplateLocati
|
|||||||
bool DiagramView::addElementAtPos(const ElementsLocation &location, const QPoint &pos) {
|
bool DiagramView::addElementAtPos(const ElementsLocation &location, const QPoint &pos) {
|
||||||
// construit une instance de l'element correspondant a l'emplacement
|
// construit une instance de l'element correspondant a l'emplacement
|
||||||
int state;
|
int state;
|
||||||
Element *el = ElementFactory::Instance()->createElement(location, 0, diagram(), &state);
|
Element *el = ElementFactory::Instance()->createElement(location, 0, &state);
|
||||||
if (state) {
|
if (state) {
|
||||||
delete el;
|
delete el;
|
||||||
return(false);
|
return(false);
|
||||||
|
|||||||
@@ -35,25 +35,26 @@ class DiagramView : public QGraphicsView {
|
|||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
DiagramView(Diagram * = 0, QWidget * = 0);
|
DiagramView(Diagram *diagram, QWidget * = 0);
|
||||||
virtual ~DiagramView();
|
virtual ~DiagramView();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DiagramView(const DiagramView &);
|
DiagramView(const DiagramView &);
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
private:
|
|
||||||
Diagram *scene;
|
Diagram *scene;
|
||||||
|
DVEventInterface *m_event_interface;
|
||||||
QMenu *context_menu;
|
QMenu *context_menu;
|
||||||
QAction *paste_here;
|
QAction *paste_here;
|
||||||
QAction *find_element_;
|
QAction *find_element_;
|
||||||
QPoint paste_here_pos;
|
QPoint paste_here_pos;
|
||||||
bool fresh_focus_in_; ///< Indicate the focus was freshly gained
|
|
||||||
ElementsLocation next_location_;
|
|
||||||
QPoint next_position_;
|
QPoint next_position_;
|
||||||
QPointF center_view_;
|
QPointF center_view_;
|
||||||
QPointF rubber_band_origin;
|
QPointF rubber_band_origin;
|
||||||
DVEventInterface *m_event_interface;
|
bool fresh_focus_in_; ///< Indicate the focus was freshly gained
|
||||||
|
ElementsLocation next_location_;
|
||||||
|
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -143,7 +143,9 @@ void DVEventAddShape::updateHelpCross(const QPoint &p) {
|
|||||||
//If line isn't created yet, we create it.
|
//If line isn't created yet, we create it.
|
||||||
if (!m_help_horiz || !m_help_verti) {
|
if (!m_help_horiz || !m_help_verti) {
|
||||||
QPen pen;
|
QPen pen;
|
||||||
pen.setColor(Qt::darkBlue);
|
pen.setWidthF(0.4);
|
||||||
|
pen.setCosmetic(true);
|
||||||
|
pen.setColor(Qt::darkGray);
|
||||||
//Add +5 for each line, because the topleft of diagram isn't draw at position (0:0) but (5:5)
|
//Add +5 for each line, because the topleft of diagram isn't draw at position (0:0) but (5:5)
|
||||||
if (!m_help_horiz) {
|
if (!m_help_horiz) {
|
||||||
m_help_horiz = new QGraphicsLineItem(m_diagram -> border_and_titleblock.rowsHeaderWidth() + 5, 0,
|
m_help_horiz = new QGraphicsLineItem(m_diagram -> border_and_titleblock.rowsHeaderWidth() + 5, 0,
|
||||||
|
|||||||
@@ -296,7 +296,6 @@ void AddPartCommand::redo() {
|
|||||||
part -> setZValue(z);
|
part -> setZValue(z);
|
||||||
}
|
}
|
||||||
editor_scene_ -> clearSelection();
|
editor_scene_ -> clearSelection();
|
||||||
part -> setSelected(true);
|
|
||||||
first_redo = false;
|
first_redo = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ ElementScene::ElementScene(QETElementEditor *editor, QObject *parent) :
|
|||||||
element_editor(editor),
|
element_editor(editor),
|
||||||
decorator_(0)
|
decorator_(0)
|
||||||
{
|
{
|
||||||
|
behavior = Normal;
|
||||||
setItemIndexMethod(NoIndex);
|
setItemIndexMethod(NoIndex);
|
||||||
setGrid(1, 1);
|
setGrid(1, 1);
|
||||||
initPasteArea();
|
initPasteArea();
|
||||||
@@ -64,31 +65,14 @@ ElementScene::~ElementScene() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Passe la scene en mode "selection et deplacement de parties"
|
* @brief ElementScene::mouseMoveEvent
|
||||||
*/
|
* @param e
|
||||||
void ElementScene::slot_move() {
|
|
||||||
behavior = Normal;
|
|
||||||
if (m_event_interface) delete m_event_interface; m_event_interface = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Passe la scene en mode "ajout de borne"
|
|
||||||
*/
|
|
||||||
void ElementScene::slot_addTerminal() {
|
|
||||||
behavior = Terminal;
|
|
||||||
if (m_event_interface) delete m_event_interface; m_event_interface = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Gere les mouvements de la souris
|
|
||||||
@param e objet decrivant l'evenement
|
|
||||||
*/
|
*/
|
||||||
void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
||||||
if (m_event_interface) {
|
if (m_event_interface) {
|
||||||
if (m_event_interface -> mouseMoveEvent(e)) {
|
if (m_event_interface -> mouseMoveEvent(e)) {
|
||||||
if (m_event_interface->isFinish()) {
|
if (m_event_interface->isFinish()) {
|
||||||
emit(partsAdded());
|
emit(partsAdded());
|
||||||
emit(needNormalMode());
|
|
||||||
delete m_event_interface; m_event_interface = nullptr;
|
delete m_event_interface; m_event_interface = nullptr;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -96,7 +80,8 @@ void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QPointF event_pos = e -> scenePos();
|
QPointF event_pos = e -> scenePos();
|
||||||
if (mustSnapToGrid(e)) event_pos = snapToGrid(event_pos);
|
if (!e -> modifiers() & Qt::ControlModifier)
|
||||||
|
event_pos = snapToGrid(event_pos);
|
||||||
|
|
||||||
if (behavior == PasteArea) {
|
if (behavior == PasteArea) {
|
||||||
QRectF current_rect(paste_area_ -> rect());
|
QRectF current_rect(paste_area_ -> rect());
|
||||||
@@ -109,15 +94,14 @@ void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Gere les appuis sur les boutons de la souris
|
* @brief ElementScene::mousePressEvent
|
||||||
@param e objet decrivant l'evenement
|
* @param e
|
||||||
*/
|
*/
|
||||||
void ElementScene::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
void ElementScene::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
||||||
if (m_event_interface) {
|
if (m_event_interface) {
|
||||||
if (m_event_interface -> mousePressEvent(e)) {
|
if (m_event_interface -> mousePressEvent(e)) {
|
||||||
if (m_event_interface->isFinish()) {
|
if (m_event_interface->isFinish()) {
|
||||||
emit(partsAdded());
|
emit(partsAdded());
|
||||||
emit(needNormalMode());
|
|
||||||
delete m_event_interface; m_event_interface = nullptr;
|
delete m_event_interface; m_event_interface = nullptr;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -128,26 +112,20 @@ void ElementScene::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Gere les relachements de boutons de la souris
|
* @brief ElementScene::mouseReleaseEvent
|
||||||
@param e objet decrivant l'evenement
|
* @param e
|
||||||
*/
|
*/
|
||||||
void ElementScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
void ElementScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
||||||
if (m_event_interface) {
|
if (m_event_interface) {
|
||||||
if (m_event_interface -> mouseReleaseEvent(e)) {
|
if (m_event_interface -> mouseReleaseEvent(e)) {
|
||||||
if (m_event_interface->isFinish()) {
|
if (m_event_interface->isFinish()) {
|
||||||
emit(partsAdded());
|
emit(partsAdded());
|
||||||
emit(needNormalMode());
|
|
||||||
delete m_event_interface; m_event_interface = nullptr;
|
delete m_event_interface; m_event_interface = nullptr;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF event_pos = e -> scenePos();
|
|
||||||
if (mustSnapToGrid(e)) event_pos = snapToGrid(event_pos);
|
|
||||||
|
|
||||||
PartTerminal *terminal;
|
|
||||||
|
|
||||||
if (behavior == PasteArea) {
|
if (behavior == PasteArea) {
|
||||||
defined_paste_area_ = paste_area_ -> rect();
|
defined_paste_area_ = paste_area_ -> rect();
|
||||||
removeItem(paste_area_);
|
removeItem(paste_area_);
|
||||||
@@ -156,31 +134,18 @@ void ElementScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e -> button() & Qt::LeftButton) {
|
|
||||||
switch(behavior) {
|
|
||||||
case Terminal:
|
|
||||||
terminal = new PartTerminal(element_editor, 0, this);
|
|
||||||
terminal -> setPos(event_pos);
|
|
||||||
undo_stack.push(new AddPartCommand(tr("borne"), this, terminal));
|
|
||||||
emit(partsAdded());
|
|
||||||
endCurrentBehavior(e);
|
|
||||||
break;
|
|
||||||
case Normal:
|
|
||||||
default:
|
|
||||||
// detecte les deplacements de parties
|
|
||||||
QGraphicsScene::mouseReleaseEvent(e);
|
QGraphicsScene::mouseReleaseEvent(e);
|
||||||
moving_parts_ = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else QGraphicsScene::mouseReleaseEvent(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ElementScene::mouseDoubleClickEvent
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
void ElementScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
|
void ElementScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
|
||||||
if (m_event_interface) {
|
if (m_event_interface) {
|
||||||
if (m_event_interface -> mouseDoubleClickEvent(event)) {
|
if (m_event_interface -> mouseDoubleClickEvent(event)) {
|
||||||
if (m_event_interface->isFinish()) {
|
if (m_event_interface->isFinish()) {
|
||||||
emit(partsAdded());
|
emit(partsAdded());
|
||||||
emit(needNormalMode());
|
|
||||||
delete m_event_interface; m_event_interface = nullptr;
|
delete m_event_interface; m_event_interface = nullptr;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -200,7 +165,6 @@ void ElementScene::keyPressEvent(QKeyEvent *event) {
|
|||||||
if (m_event_interface -> keyPressEvent(event)) {
|
if (m_event_interface -> keyPressEvent(event)) {
|
||||||
if (m_event_interface->isFinish()) {
|
if (m_event_interface->isFinish()) {
|
||||||
emit(partsAdded());
|
emit(partsAdded());
|
||||||
emit(needNormalMode());
|
|
||||||
delete m_event_interface; m_event_interface = nullptr;
|
delete m_event_interface; m_event_interface = nullptr;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -230,27 +194,18 @@ void ElementScene::drawForeground(QPainter *p, const QRectF &rect) {
|
|||||||
p -> restore();
|
p -> restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
A partir d'un evenement souris, cette methode regarde si la touche shift est
|
|
||||||
enfoncee ou non. Si oui, elle laisse le comportement en cours (cercle,
|
|
||||||
texte, polygone, ...). Si non, elle repasse en mode normal / selection.
|
|
||||||
@param event objet decrivant l'evenement souris
|
|
||||||
*/
|
|
||||||
void ElementScene::endCurrentBehavior(const QGraphicsSceneMouseEvent *event) {
|
|
||||||
if (!(event -> modifiers() & Qt::ShiftModifier)) {
|
|
||||||
// la touche Shift n'est pas enfoncee : on demande le mode normal
|
|
||||||
behavior = Normal;
|
|
||||||
emit(needNormalMode());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementScene::setEventInterface
|
* @brief ElementScene::setEventInterface
|
||||||
* Set a new event interface
|
* Set a new event interface
|
||||||
* @param interface
|
* @param interface
|
||||||
*/
|
*/
|
||||||
void ElementScene::setEventInterface(ESEventInterface *interface) {
|
void ElementScene::setEventInterface(ESEventInterface *interface) {
|
||||||
if (m_event_interface) delete m_event_interface;
|
if (m_event_interface) {
|
||||||
|
delete m_event_interface;
|
||||||
|
//We must to re-init because previous interface
|
||||||
|
//Reset his own init when deleted
|
||||||
|
interface->init();
|
||||||
|
}
|
||||||
m_event_interface = interface;
|
m_event_interface = interface;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,7 +270,6 @@ const QDomDocument ElementScene::toXml(bool all_parts) {
|
|||||||
root.setAttribute("hotspot_y", QString("%1").arg(-(qRound(size.y() - (ymargin/2)))));
|
root.setAttribute("hotspot_y", QString("%1").arg(-(qRound(size.y() - (ymargin/2)))));
|
||||||
root.setAttribute("orientation", "dyyy"); //we keep the orientation for compatibility with previous version of qet
|
root.setAttribute("orientation", "dyyy"); //we keep the orientation for compatibility with previous version of qet
|
||||||
root.setAttribute("version", QET::version);
|
root.setAttribute("version", QET::version);
|
||||||
root.setAttribute("ic", "true"); //we keep the internal connection for compatibility with previous version of qet
|
|
||||||
root.setAttribute("link_type", m_elmt_type);
|
root.setAttribute("link_type", m_elmt_type);
|
||||||
|
|
||||||
// noms de l'element
|
// noms de l'element
|
||||||
@@ -504,14 +458,6 @@ void ElementScene::copy() {
|
|||||||
last_copied_ = clipboard_content;
|
last_copied_ = clipboard_content;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Gere le fait de coller le contenu du presse-papier = l'importer dans le
|
|
||||||
presse-papier a une position donnee.
|
|
||||||
*/
|
|
||||||
void ElementScene::paste() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void ElementScene::contextMenu(QContextMenuEvent *event) {
|
void ElementScene::contextMenu(QContextMenuEvent *event) {
|
||||||
if (behavior == ElementScene::Normal)
|
if (behavior == ElementScene::Normal)
|
||||||
element_editor -> contextMenu(event);
|
element_editor -> contextMenu(event);
|
||||||
@@ -1004,16 +950,6 @@ QPointF ElementScene::snapToGrid(QPointF point) {
|
|||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
@param e Evenement souris
|
|
||||||
@return true s'il faut utiliser le snap-to-grid
|
|
||||||
Typiquement, cette methode retourne true si l'evenement souris se produit
|
|
||||||
sans la touche Ctrl enfoncee.
|
|
||||||
*/
|
|
||||||
bool ElementScene::mustSnapToGrid(QGraphicsSceneMouseEvent *e) {
|
|
||||||
return(!(e -> modifiers() & Qt::ControlModifier));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return true if \a item1's zValue() is less than \a item2's.
|
@return true if \a item1's zValue() is less than \a item2's.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class ElementScene : public QGraphicsScene {
|
|||||||
|
|
||||||
// enum
|
// enum
|
||||||
public:
|
public:
|
||||||
enum Behavior { Normal, Terminal, PasteArea };
|
enum Behavior { Normal, PasteArea };
|
||||||
enum ItemOption {
|
enum ItemOption {
|
||||||
SortByZValue = 1,
|
SortByZValue = 1,
|
||||||
IncludeTerminals = 2,
|
IncludeTerminals = 2,
|
||||||
@@ -81,7 +81,6 @@ class ElementScene : public QGraphicsScene {
|
|||||||
*/
|
*/
|
||||||
QPointF fsi_pos;
|
QPointF fsi_pos;
|
||||||
QPointF moving_press_pos;
|
QPointF moving_press_pos;
|
||||||
bool moving_parts_;
|
|
||||||
|
|
||||||
/// Variables related to drawing
|
/// Variables related to drawing
|
||||||
ESEventInterface *m_event_interface;
|
ESEventInterface *m_event_interface;
|
||||||
@@ -132,7 +131,6 @@ class ElementScene : public QGraphicsScene {
|
|||||||
bool wasCopiedFromThisElement(const QString &);
|
bool wasCopiedFromThisElement(const QString &);
|
||||||
void cut();
|
void cut();
|
||||||
void copy();
|
void copy();
|
||||||
void paste();
|
|
||||||
void contextMenu (QContextMenuEvent *event);
|
void contextMenu (QContextMenuEvent *event);
|
||||||
QETElementEditor* editor() const;
|
QETElementEditor* editor() const;
|
||||||
|
|
||||||
@@ -144,7 +142,6 @@ class ElementScene : public QGraphicsScene {
|
|||||||
virtual void keyPressEvent (QKeyEvent *event);
|
virtual void keyPressEvent (QKeyEvent *event);
|
||||||
|
|
||||||
virtual void drawForeground(QPainter *, const QRectF &);
|
virtual void drawForeground(QPainter *, const QRectF &);
|
||||||
virtual void endCurrentBehavior(const QGraphicsSceneMouseEvent *);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QRectF elementContentBoundingRect(const ElementContent &) const;
|
QRectF elementContentBoundingRect(const ElementContent &) const;
|
||||||
@@ -154,14 +151,11 @@ class ElementScene : public QGraphicsScene {
|
|||||||
ElementContent addContentAtPos(const ElementContent &, const QPointF &, QString * = 0);
|
ElementContent addContentAtPos(const ElementContent &, const QPointF &, QString * = 0);
|
||||||
void addPrimitive(QGraphicsItem *);
|
void addPrimitive(QGraphicsItem *);
|
||||||
void initPasteArea();
|
void initPasteArea();
|
||||||
bool mustSnapToGrid(QGraphicsSceneMouseEvent *);
|
|
||||||
static bool zValueLessThan(QGraphicsItem *, QGraphicsItem *);
|
static bool zValueLessThan(QGraphicsItem *, QGraphicsItem *);
|
||||||
QMutex *decorator_lock_;
|
QMutex *decorator_lock_;
|
||||||
void centerElementToOrigine();
|
void centerElementToOrigine();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void slot_move();
|
|
||||||
void slot_addTerminal();
|
|
||||||
void slot_select(const ElementContent &);
|
void slot_select(const ElementContent &);
|
||||||
void slot_selectAll();
|
void slot_selectAll();
|
||||||
void slot_deselectAll();
|
void slot_deselectAll();
|
||||||
@@ -178,11 +172,6 @@ class ElementScene : public QGraphicsScene {
|
|||||||
void stackAction(ElementEditionCommand *);
|
void stackAction(ElementEditionCommand *);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
|
||||||
Signal emitted when the scene requires the element editor to switch back to
|
|
||||||
normal mode.
|
|
||||||
*/
|
|
||||||
void needNormalMode();
|
|
||||||
/// Signal emitted after one or several parts were added
|
/// Signal emitted after one or several parts were added
|
||||||
void partsAdded();
|
void partsAdded();
|
||||||
/// Signal emitted after one or several parts were removed
|
/// Signal emitted after one or several parts were removed
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include "elementview.h"
|
#include "elementview.h"
|
||||||
#include "qetelementeditor.h"
|
#include "qetelementeditor.h"
|
||||||
#include "editorcommands.h"
|
#include "editorcommands.h"
|
||||||
|
#include "qetapp.h"
|
||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
@param scene ElementScene visualisee par cette ElementView
|
@param scene ElementScene visualisee par cette ElementView
|
||||||
@@ -28,6 +29,7 @@ ElementView::ElementView(ElementScene *scene, QWidget *parent) :
|
|||||||
scene_(scene),
|
scene_(scene),
|
||||||
offset_paste_count_(0)
|
offset_paste_count_(0)
|
||||||
{
|
{
|
||||||
|
grabGesture(Qt::PinchGesture);
|
||||||
setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
|
setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
|
||||||
setInteractive(true);
|
setInteractive(true);
|
||||||
setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||||
@@ -35,7 +37,6 @@ ElementView::ElementView(ElementScene *scene, QWidget *parent) :
|
|||||||
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
||||||
zoomReset();
|
zoomReset();
|
||||||
connect(scene_, SIGNAL(pasteAreaDefined(const QRectF &)), this, SLOT(pasteAreaDefined(const QRectF &)));
|
connect(scene_, SIGNAL(pasteAreaDefined(const QRectF &)), this, SLOT(pasteAreaDefined(const QRectF &)));
|
||||||
connect(scene_, SIGNAL(partsAdded()), this, SLOT(adjustSceneRect()));
|
|
||||||
connect(scene_, SIGNAL(needZoomFit()), this, SLOT(zoomFit()));
|
connect(scene_, SIGNAL(needZoomFit()), this, SLOT(zoomFit()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,6 +114,20 @@ void ElementView::zoomOut() {
|
|||||||
scale(0.75, 0.75);
|
scale(0.75, 0.75);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Agrandit le schema avec le trackpad
|
||||||
|
*/
|
||||||
|
void ElementView::zoomInSlowly() {
|
||||||
|
scale(1.02, 1.02);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Retrecit le schema avec le trackpad
|
||||||
|
*/
|
||||||
|
void ElementView::zoomOutSlowly() {
|
||||||
|
scale(0.98, 0.98);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Agrandit ou rectrecit le schema de facon a ce que tous les elements du
|
Agrandit ou rectrecit le schema de facon a ce que tous les elements du
|
||||||
schema soient visibles a l'ecran. S'il n'y a aucun element sur le schema,
|
schema soient visibles a l'ecran. S'il n'y a aucun element sur le schema,
|
||||||
@@ -383,25 +398,66 @@ void ElementView::mouseReleaseEvent(QMouseEvent *e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Gere les actions liees a la rollette de la souris
|
* @brief ElementView::gestures
|
||||||
@param e QWheelEvent decrivant l'evenement rollette
|
* @return
|
||||||
|
*/
|
||||||
|
bool ElementView::gestures() const {
|
||||||
|
return(QETApp::settings().value("diagramview/gestures", false).toBool());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ElementView::wheelEvent
|
||||||
|
* @param e
|
||||||
*/
|
*/
|
||||||
void ElementView::wheelEvent(QWheelEvent *e) {
|
void ElementView::wheelEvent(QWheelEvent *e) {
|
||||||
//Zoom and scrolling
|
//Zoom and scrolling
|
||||||
if (e->buttons() != Qt::MidButton) {
|
if ( gestures() ) {
|
||||||
if (!(e -> modifiers() & Qt::ControlModifier)) {
|
if (e -> modifiers() & Qt::ControlModifier)
|
||||||
if (e -> delta() > 0){
|
e -> delta() > 0 ? zoomInSlowly() : zoomOutSlowly();
|
||||||
zoomIn();
|
else
|
||||||
}
|
QGraphicsView::wheelEvent(e);
|
||||||
else{
|
} else {
|
||||||
zoomOut();
|
e -> delta() > 0 ? zoomIn(): zoomOut();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
QAbstractScrollArea::wheelEvent(e);
|
/**
|
||||||
|
Gere les evenements de la ElementView
|
||||||
|
@param e Evenement
|
||||||
|
*/
|
||||||
|
bool ElementView::event(QEvent *e) {
|
||||||
|
// By default touch events are converted to mouse events. So
|
||||||
|
// after this event we will get a mouse event also but we want
|
||||||
|
// to handle touch events as gestures only. So we need this safeguard
|
||||||
|
// to block mouse events that are actually generated from touch.
|
||||||
|
if (e->type() == QEvent::Gesture)
|
||||||
|
return gestureEvent(static_cast<QGestureEvent *>(e));
|
||||||
|
|
||||||
|
return(QGraphicsView::event(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utilise le pincement du trackpad pour zoomer
|
||||||
|
* @brief ElementView::gestureEvent
|
||||||
|
* @param event
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
bool ElementView::gestureEvent(QGestureEvent *event){
|
||||||
|
if (QGesture *gesture = event->gesture(Qt::PinchGesture)) {
|
||||||
|
QPinchGesture *pinch = static_cast<QPinchGesture *>(gesture);
|
||||||
|
if (pinch->changeFlags() & QPinchGesture::ScaleFactorChanged){
|
||||||
|
qreal value = gesture->property("scaleFactor").toReal();
|
||||||
|
if (value > 1){
|
||||||
|
zoomInSlowly();
|
||||||
|
}else{
|
||||||
|
zoomOutSlowly();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Dessine l'arriere-plan de l'editeur, cad la grille.
|
Dessine l'arriere-plan de l'editeur, cad la grille.
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ class ElementView : public QGraphicsView {
|
|||||||
void mousePressEvent(QMouseEvent *);
|
void mousePressEvent(QMouseEvent *);
|
||||||
void mouseMoveEvent(QMouseEvent *);
|
void mouseMoveEvent(QMouseEvent *);
|
||||||
void mouseReleaseEvent(QMouseEvent *);
|
void mouseReleaseEvent(QMouseEvent *);
|
||||||
|
bool gestureEvent(QGestureEvent *event);
|
||||||
|
bool event(QEvent *event);
|
||||||
void wheelEvent(QWheelEvent *);
|
void wheelEvent(QWheelEvent *);
|
||||||
virtual void drawBackground(QPainter *, const QRectF &);
|
virtual void drawBackground(QPainter *, const QRectF &);
|
||||||
|
|
||||||
@@ -58,6 +60,8 @@ class ElementView : public QGraphicsView {
|
|||||||
void setSelectionMode();
|
void setSelectionMode();
|
||||||
void zoomIn();
|
void zoomIn();
|
||||||
void zoomOut();
|
void zoomOut();
|
||||||
|
void zoomInSlowly();
|
||||||
|
void zoomOutSlowly();
|
||||||
void zoomFit();
|
void zoomFit();
|
||||||
void zoomReset();
|
void zoomReset();
|
||||||
void adjustSceneRect();
|
void adjustSceneRect();
|
||||||
@@ -86,6 +90,7 @@ class ElementView : public QGraphicsView {
|
|||||||
QPointF start_top_left_corner_;
|
QPointF start_top_left_corner_;
|
||||||
QPointF reference_view_;
|
QPointF reference_view_;
|
||||||
QPointF center_view_;
|
QPointF center_view_;
|
||||||
|
bool gestures() const;
|
||||||
bool is_moving_view_; ///< Indicate whether the visualisation mode has been enabled due to mouse/keyboard interactions
|
bool is_moving_view_; ///< Indicate whether the visualisation mode has been enabled due to mouse/keyboard interactions
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ bool ESEventAddEllipse::mousePressEvent(QGraphicsSceneMouseEvent *event) {
|
|||||||
|
|
||||||
//Add ellipse to scene
|
//Add ellipse to scene
|
||||||
m_ellipse -> setRect(m_ellipse -> rect().normalized());
|
m_ellipse -> setRect(m_ellipse -> rect().normalized());
|
||||||
m_scene -> undoStack().push(new AddPartCommand(QObject::tr("Rectangle"), m_scene, m_ellipse));
|
m_scene -> undoStack().push(new AddPartCommand(QObject::tr("Ellipse"), m_scene, m_ellipse));
|
||||||
|
|
||||||
//Set m_ellipse to nullptr for create new ellipse at next mouse press
|
//Set m_ellipse to nullptr for create new ellipse at next mouse press
|
||||||
m_ellipse = nullptr;
|
m_ellipse = nullptr;
|
||||||
|
|||||||
107
sources/editor/esevent/eseventaddterminal.cpp
Normal file
107
sources/editor/esevent/eseventaddterminal.cpp
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2014 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "partterminal.h"
|
||||||
|
#include "editorcommands.h"
|
||||||
|
#include "elementscene.h"
|
||||||
|
#include "eseventaddterminal.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ESEventAddTerminal::ESEventAddTerminal
|
||||||
|
* @param scene
|
||||||
|
*/
|
||||||
|
ESEventAddTerminal::ESEventAddTerminal(ElementScene *scene) :
|
||||||
|
ESEventInterface(scene)
|
||||||
|
{
|
||||||
|
m_terminal = new PartTerminal(m_editor, 0, m_scene);
|
||||||
|
m_running = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ESEventAddTerminal::~ESEventAddTerminal
|
||||||
|
*/
|
||||||
|
ESEventAddTerminal::~ESEventAddTerminal() {
|
||||||
|
delete m_terminal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ESEventAddTerminal::mouseMoveEvent
|
||||||
|
* @param event
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
bool ESEventAddTerminal::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
|
||||||
|
QPointF pos = m_scene -> snapToGrid(event -> scenePos());
|
||||||
|
updateHelpCross(pos);
|
||||||
|
m_terminal -> setPos(pos);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ESEventAddTerminal::mouseReleaseEvent
|
||||||
|
* @param event
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
bool ESEventAddTerminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
|
||||||
|
if (event -> button() == Qt::LeftButton) {
|
||||||
|
m_scene -> undoStack().push(new AddPartCommand(QObject::tr("Borne"), m_scene, m_terminal));
|
||||||
|
|
||||||
|
//Set new terminal with same rotation
|
||||||
|
Qet::Orientation ori = m_terminal -> orientation();
|
||||||
|
m_terminal = new PartTerminal(m_editor, 0, m_scene);
|
||||||
|
m_terminal -> setOrientation(ori);
|
||||||
|
m_terminal -> setPos(m_scene -> snapToGrid(event -> scenePos()));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (event -> button() == Qt::RightButton) {
|
||||||
|
m_running = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ESEventAddTerminal::keyPressEvent
|
||||||
|
* @param event
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
bool ESEventAddTerminal::keyPressEvent(QKeyEvent *event) {
|
||||||
|
if (event -> key() == Qt::Key_Space) {
|
||||||
|
switch (m_terminal->orientation()) {
|
||||||
|
case Qet::North :
|
||||||
|
m_terminal -> setOrientation(Qet::East);
|
||||||
|
break;
|
||||||
|
case Qet::East :
|
||||||
|
m_terminal -> setOrientation(Qet::South);
|
||||||
|
break;
|
||||||
|
case Qet::South :
|
||||||
|
m_terminal -> setOrientation(Qet::West);
|
||||||
|
break;
|
||||||
|
case Qet::West :
|
||||||
|
m_terminal -> setOrientation(Qet::North);
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
m_terminal -> setOrientation(Qet::North);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return (ESEventInterface::keyPressEvent(event));
|
||||||
|
}
|
||||||
45
sources/editor/esevent/eseventaddterminal.h
Normal file
45
sources/editor/esevent/eseventaddterminal.h
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2014 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef ESEVENTADDTERMINAL_H
|
||||||
|
#define ESEVENTADDTERMINAL_H
|
||||||
|
|
||||||
|
#include "eseventinterface.h"
|
||||||
|
|
||||||
|
class ElementScene;
|
||||||
|
class PartTerminal;
|
||||||
|
class QGraphicsSceneMouseEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The ESEventAddTerminal class
|
||||||
|
* This ESEvent manage creation of terminal in an ElementScene
|
||||||
|
*/
|
||||||
|
class ESEventAddTerminal : public ESEventInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ESEventAddTerminal(ElementScene *scene);
|
||||||
|
virtual ~ESEventAddTerminal();
|
||||||
|
|
||||||
|
virtual bool mouseMoveEvent (QGraphicsSceneMouseEvent *event);
|
||||||
|
virtual bool mouseReleaseEvent (QGraphicsSceneMouseEvent *event);
|
||||||
|
virtual bool keyPressEvent (QKeyEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
PartTerminal *m_terminal;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ESEVENTADDTERMINAL_H
|
||||||
@@ -28,8 +28,14 @@ ESEventInterface::ESEventInterface(ElementScene *scene) :
|
|||||||
m_running (false),
|
m_running (false),
|
||||||
m_abort (false)
|
m_abort (false)
|
||||||
{
|
{
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ESEventInterface::init() {
|
||||||
foreach (QGraphicsView *qgv, m_scene->views())
|
foreach (QGraphicsView *qgv, m_scene->views())
|
||||||
qgv->setContextMenuPolicy(Qt::NoContextMenu);
|
qgv->setContextMenuPolicy(Qt::NoContextMenu);
|
||||||
|
|
||||||
|
m_editor->slot_setNoDragToView();
|
||||||
}
|
}
|
||||||
|
|
||||||
ESEventInterface::~ESEventInterface() {
|
ESEventInterface::~ESEventInterface() {
|
||||||
@@ -38,6 +44,8 @@ ESEventInterface::~ESEventInterface() {
|
|||||||
|
|
||||||
foreach (QGraphicsView *qgv, m_scene->views())
|
foreach (QGraphicsView *qgv, m_scene->views())
|
||||||
qgv->setContextMenuPolicy(Qt::DefaultContextMenu);
|
qgv->setContextMenuPolicy(Qt::DefaultContextMenu);
|
||||||
|
|
||||||
|
m_editor->slot_setRubberBandToView();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ESEventInterface::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
|
bool ESEventInterface::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ class ESEventInterface
|
|||||||
ESEventInterface(ElementScene *scene);
|
ESEventInterface(ElementScene *scene);
|
||||||
virtual ~ESEventInterface();
|
virtual ~ESEventInterface();
|
||||||
|
|
||||||
|
void init();
|
||||||
|
|
||||||
virtual bool mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event);
|
virtual bool mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event);
|
||||||
virtual bool mousePressEvent (QGraphicsSceneMouseEvent *event);
|
virtual bool mousePressEvent (QGraphicsSceneMouseEvent *event);
|
||||||
virtual bool mouseMoveEvent (QGraphicsSceneMouseEvent *event);
|
virtual bool mouseMoveEvent (QGraphicsSceneMouseEvent *event);
|
||||||
|
|||||||
@@ -48,6 +48,7 @@
|
|||||||
#include "eseventaddarc.h"
|
#include "eseventaddarc.h"
|
||||||
#include "eseventaddtext.h"
|
#include "eseventaddtext.h"
|
||||||
#include "eseventaddtextfield.h"
|
#include "eseventaddtextfield.h"
|
||||||
|
#include "eseventaddterminal.h"
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
/*
|
/*
|
||||||
@@ -129,7 +130,8 @@ void QETElementEditor::setFileName(const QString &fn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Met en place les actions
|
* @brief QETElementEditor::setupActions
|
||||||
|
* Create action used in Element editor
|
||||||
*/
|
*/
|
||||||
void QETElementEditor::setupActions() {
|
void QETElementEditor::setupActions() {
|
||||||
new_element = new QAction(QET::Icons::DocumentNew, tr("&Nouveau"), this);
|
new_element = new QAction(QET::Icons::DocumentNew, tr("&Nouveau"), this);
|
||||||
@@ -150,36 +152,9 @@ void QETElementEditor::setupActions() {
|
|||||||
paste_from_elmt = new QAction(QET::Icons::Element, tr("un \351l\351ment"), this);
|
paste_from_elmt = new QAction(QET::Icons::Element, tr("un \351l\351ment"), this);
|
||||||
inv_select = new QAction( tr("Inverser la s\351lection"), this);
|
inv_select = new QAction( tr("Inverser la s\351lection"), this);
|
||||||
edit_delete = new QAction(QET::Icons::EditDelete, tr("&Supprimer"), this);
|
edit_delete = new QAction(QET::Icons::EditDelete, tr("&Supprimer"), this);
|
||||||
zoom_in = new QAction(QET::Icons::ZoomIn, tr("Zoom avant"), this);
|
|
||||||
zoom_out = new QAction(QET::Icons::ZoomOut, tr("Zoom arri\350re"), this);
|
|
||||||
zoom_fit = new QAction(QET::Icons::ZoomFitBest, tr("Zoom adapt\351"), this);
|
|
||||||
zoom_reset = new QAction(QET::Icons::ZoomOriginal, tr("Pas de zoom"), this);
|
|
||||||
edit_names = new QAction(QET::Icons::Names, tr("\311diter les noms"), this);
|
edit_names = new QAction(QET::Icons::Names, tr("\311diter les noms"), this);
|
||||||
edit_author = new QAction(QET::Icons::UserInformations, tr("\311diter les informations sur l'auteur"), this);
|
edit_author = new QAction(QET::Icons::UserInformations, tr("\311diter les informations sur l'auteur"), this);
|
||||||
m_edit_properties = new QAction(QET::Icons::ElementEdit, tr("\311diter les propri\351t\351es de l'\351l\351ment"), this);
|
m_edit_properties = new QAction(QET::Icons::ElementEdit, tr("\311diter les propri\351t\351es de l'\351l\351ment"), this);
|
||||||
edit_raise = new QAction(QET::Icons::Raise, tr("Rapprocher"), this);
|
|
||||||
edit_lower = new QAction(QET::Icons::Lower, tr("\311loigner"), this);
|
|
||||||
edit_backward = new QAction(QET::Icons::SendBackward, tr("Envoyer au fond"), this);
|
|
||||||
edit_forward = new QAction(QET::Icons::BringForward, tr("Amener au premier plan"), this);
|
|
||||||
move = new QAction(QET::Icons::PartSelect, tr("D\351placer un objet"), this);
|
|
||||||
add_line = new QAction(QET::Icons::PartLine, tr("Ajouter une ligne"), this);
|
|
||||||
add_rectangle = new QAction(QET::Icons::PartRectangle, tr("Ajouter un rectangle"), this);
|
|
||||||
add_ellipse = new QAction(QET::Icons::PartEllipse, tr("Ajouter une ellipse"), this);
|
|
||||||
add_polygon = new QAction(QET::Icons::PartPolygon, tr("Ajouter un polygone"), this);
|
|
||||||
add_text = new QAction(QET::Icons::PartText, tr("Ajouter du texte"), this);
|
|
||||||
add_arc = new QAction(QET::Icons::PartArc, tr("Ajouter un arc de cercle"), this);
|
|
||||||
add_terminal = new QAction(QET::Icons::Terminal, tr("Ajouter une borne"), this);
|
|
||||||
add_textfield = new QAction(QET::Icons::PartTextField, tr("Ajouter un champ de texte"), this);
|
|
||||||
|
|
||||||
QString add_status_tip = tr("Maintenez la touche Shift enfonc\351e pour effectuer plusieurs ajouts d'affil\351e");
|
|
||||||
add_line -> setStatusTip(add_status_tip);
|
|
||||||
add_rectangle -> setStatusTip(add_status_tip);
|
|
||||||
add_ellipse -> setStatusTip(add_status_tip);
|
|
||||||
add_text -> setStatusTip(add_status_tip);
|
|
||||||
add_arc -> setStatusTip(add_status_tip);
|
|
||||||
add_terminal -> setStatusTip(add_status_tip);
|
|
||||||
add_textfield -> setStatusTip(add_status_tip);
|
|
||||||
add_polygon -> setStatusTip(tr("Utilisez le bouton droit de la souris pour poser le dernier point du polygone"));
|
|
||||||
|
|
||||||
undo = ce_scene -> undoStack().createUndoAction(this, tr("Annuler"));
|
undo = ce_scene -> undoStack().createUndoAction(this, tr("Annuler"));
|
||||||
redo = ce_scene -> undoStack().createRedoAction(this, tr("Refaire"));
|
redo = ce_scene -> undoStack().createRedoAction(this, tr("Refaire"));
|
||||||
@@ -208,19 +183,9 @@ void QETElementEditor::setupActions() {
|
|||||||
edit_delete -> setShortcut(QKeySequence(tr("Backspace")));
|
edit_delete -> setShortcut(QKeySequence(tr("Backspace")));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
zoom_in -> setShortcut(QKeySequence::ZoomIn);
|
|
||||||
zoom_out -> setShortcut(QKeySequence::ZoomOut);
|
|
||||||
zoom_fit -> setShortcut(QKeySequence(tr("Ctrl+9")));
|
|
||||||
zoom_reset -> setShortcut(QKeySequence(tr("Ctrl+0")));
|
|
||||||
|
|
||||||
edit_names -> setShortcut(QKeySequence(tr("Ctrl+E")));
|
edit_names -> setShortcut(QKeySequence(tr("Ctrl+E")));
|
||||||
edit_author -> setShortcut(tr("Ctrl+Y"));
|
edit_author -> setShortcut(tr("Ctrl+Y"));
|
||||||
|
|
||||||
edit_raise -> setShortcut(QKeySequence(tr("Ctrl+Shift+Up")));
|
|
||||||
edit_lower -> setShortcut(QKeySequence(tr("Ctrl+Shift+Down")));
|
|
||||||
edit_backward -> setShortcut(QKeySequence(tr("Ctrl+Shift+End")));
|
|
||||||
edit_forward -> setShortcut(QKeySequence(tr("Ctrl+Shift+Home")));
|
|
||||||
|
|
||||||
connect(new_element, SIGNAL(triggered()), this, SLOT(slot_new()));
|
connect(new_element, SIGNAL(triggered()), this, SLOT(slot_new()));
|
||||||
connect(open, SIGNAL(triggered()), this, SLOT(slot_open()));
|
connect(open, SIGNAL(triggered()), this, SLOT(slot_open()));
|
||||||
connect(open_file, SIGNAL(triggered()), this, SLOT(slot_openFile()));
|
connect(open_file, SIGNAL(triggered()), this, SLOT(slot_openFile()));
|
||||||
@@ -238,19 +203,75 @@ void QETElementEditor::setupActions() {
|
|||||||
connect(paste_in_area, SIGNAL(triggered()), ce_view, SLOT(pasteInArea()));
|
connect(paste_in_area, SIGNAL(triggered()), ce_view, SLOT(pasteInArea()));
|
||||||
connect(paste_from_file, SIGNAL(triggered()), this, SLOT(pasteFromFile()));
|
connect(paste_from_file, SIGNAL(triggered()), this, SLOT(pasteFromFile()));
|
||||||
connect(paste_from_elmt, SIGNAL(triggered()), this, SLOT(pasteFromElement()));
|
connect(paste_from_elmt, SIGNAL(triggered()), this, SLOT(pasteFromElement()));
|
||||||
connect(zoom_in, SIGNAL(triggered()), ce_view, SLOT(zoomIn()));
|
|
||||||
connect(zoom_out, SIGNAL(triggered()), ce_view, SLOT(zoomOut()));
|
|
||||||
connect(zoom_fit, SIGNAL(triggered()), ce_view, SLOT(zoomFit()));
|
|
||||||
connect(zoom_reset, SIGNAL(triggered()), ce_view, SLOT(zoomReset()));
|
|
||||||
connect(edit_delete, SIGNAL(triggered()), ce_scene, SLOT(slot_delete()));
|
connect(edit_delete, SIGNAL(triggered()), ce_scene, SLOT(slot_delete()));
|
||||||
connect(edit_names, SIGNAL(triggered()), ce_scene, SLOT(slot_editNames()));
|
connect(edit_names, SIGNAL(triggered()), ce_scene, SLOT(slot_editNames()));
|
||||||
connect(edit_author, SIGNAL(triggered()), ce_scene, SLOT(slot_editAuthorInformations()));
|
connect(edit_author, SIGNAL(triggered()), ce_scene, SLOT(slot_editAuthorInformations()));
|
||||||
connect(m_edit_properties, SIGNAL(triggered()), ce_scene, SLOT(slot_editProperties()));
|
connect(m_edit_properties, SIGNAL(triggered()), ce_scene, SLOT(slot_editProperties()));
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Action related to change depth of primitive
|
||||||
|
*/
|
||||||
|
m_depth_ag = new QActionGroup(this);
|
||||||
|
|
||||||
|
QAction *edit_forward = new QAction(QET::Icons::BringForward, tr("Amener au premier plan"), m_depth_ag);
|
||||||
|
QAction *edit_raise = new QAction(QET::Icons::Raise, tr("Rapprocher"), m_depth_ag);
|
||||||
|
QAction *edit_lower = new QAction(QET::Icons::Lower, tr("\311loigner"), m_depth_ag);
|
||||||
|
QAction *edit_backward = new QAction(QET::Icons::SendBackward, tr("Envoyer au fond"), m_depth_ag);
|
||||||
|
|
||||||
|
edit_raise -> setShortcut(QKeySequence(tr("Ctrl+Shift+Up")));
|
||||||
|
edit_lower -> setShortcut(QKeySequence(tr("Ctrl+Shift+Down")));
|
||||||
|
edit_backward -> setShortcut(QKeySequence(tr("Ctrl+Shift+End")));
|
||||||
|
edit_forward -> setShortcut(QKeySequence(tr("Ctrl+Shift+Home")));
|
||||||
|
|
||||||
connect(edit_forward, SIGNAL(triggered()), ce_scene, SLOT(slot_bringForward() ));
|
connect(edit_forward, SIGNAL(triggered()), ce_scene, SLOT(slot_bringForward() ));
|
||||||
connect(edit_raise, SIGNAL(triggered()), ce_scene, SLOT(slot_raise() ));
|
connect(edit_raise, SIGNAL(triggered()), ce_scene, SLOT(slot_raise() ));
|
||||||
connect(edit_lower, SIGNAL(triggered()), ce_scene, SLOT(slot_lower() ));
|
connect(edit_lower, SIGNAL(triggered()), ce_scene, SLOT(slot_lower() ));
|
||||||
connect(edit_backward, SIGNAL(triggered()), ce_scene, SLOT(slot_sendBackward() ));
|
connect(edit_backward, SIGNAL(triggered()), ce_scene, SLOT(slot_sendBackward() ));
|
||||||
connect(move, SIGNAL(triggered()), ce_scene, SLOT(slot_move()));
|
|
||||||
|
depth_toolbar = addToolBar(tr("Profondeur", "toolbar title"));
|
||||||
|
depth_toolbar -> setObjectName("depth_toolbar");
|
||||||
|
depth_toolbar -> addActions(m_depth_ag -> actions());
|
||||||
|
addToolBar(Qt::TopToolBarArea, depth_toolbar);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Action related to zoom
|
||||||
|
*/
|
||||||
|
m_zoom_ag = new QActionGroup(this);
|
||||||
|
|
||||||
|
QAction *zoom_in = new QAction(QET::Icons::ZoomIn, tr("Zoom avant"), m_zoom_ag);
|
||||||
|
QAction *zoom_out = new QAction(QET::Icons::ZoomOut, tr("Zoom arri\350re"), m_zoom_ag);
|
||||||
|
QAction *zoom_fit = new QAction(QET::Icons::ZoomFitBest, tr("Zoom adapt\351"), m_zoom_ag);
|
||||||
|
QAction *zoom_reset = new QAction(QET::Icons::ZoomOriginal, tr("Pas de zoom"), m_zoom_ag);
|
||||||
|
|
||||||
|
zoom_in -> setShortcut(QKeySequence::ZoomIn);
|
||||||
|
zoom_out -> setShortcut(QKeySequence::ZoomOut);
|
||||||
|
zoom_fit -> setShortcut(QKeySequence(tr("Ctrl+9")));
|
||||||
|
zoom_reset -> setShortcut(QKeySequence(tr("Ctrl+0")));
|
||||||
|
|
||||||
|
connect(zoom_in, SIGNAL(triggered()), ce_view, SLOT(zoomIn() ));
|
||||||
|
connect(zoom_out, SIGNAL(triggered()), ce_view, SLOT(zoomOut() ));
|
||||||
|
connect(zoom_fit, SIGNAL(triggered()), ce_view, SLOT(zoomFit() ));
|
||||||
|
connect(zoom_reset, SIGNAL(triggered()), ce_view, SLOT(zoomReset() ));
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Action related to primitive creation
|
||||||
|
*/
|
||||||
|
connect (ce_scene, SIGNAL(partsAdded()), this, SLOT(UncheckAddPrimitive()));
|
||||||
|
parts = new QActionGroup(this);
|
||||||
|
|
||||||
|
QAction *add_line = new QAction(QET::Icons::PartLine, tr("Ajouter une ligne"), parts);
|
||||||
|
QAction *add_rectangle = new QAction(QET::Icons::PartRectangle, tr("Ajouter un rectangle"), parts);
|
||||||
|
QAction *add_ellipse = new QAction(QET::Icons::PartEllipse, tr("Ajouter une ellipse"), parts);
|
||||||
|
QAction *add_polygon = new QAction(QET::Icons::PartPolygon, tr("Ajouter un polygone"), parts);
|
||||||
|
QAction *add_text = new QAction(QET::Icons::PartText, tr("Ajouter du texte"), parts);
|
||||||
|
QAction *add_arc = new QAction(QET::Icons::PartArc, tr("Ajouter un arc de cercle"), parts);
|
||||||
|
QAction *add_terminal = new QAction(QET::Icons::Terminal, tr("Ajouter une borne"), parts);
|
||||||
|
QAction *add_textfield = new QAction(QET::Icons::PartTextField, tr("Ajouter un champ de texte"), parts);
|
||||||
|
|
||||||
|
foreach (QAction *action, parts -> actions()) action -> setCheckable(true);
|
||||||
|
|
||||||
connect(add_line, SIGNAL(triggered()), this, SLOT(addLine() ));
|
connect(add_line, SIGNAL(triggered()), this, SLOT(addLine() ));
|
||||||
connect(add_rectangle, SIGNAL(triggered()), this, SLOT(addRect() ));
|
connect(add_rectangle, SIGNAL(triggered()), this, SLOT(addRect() ));
|
||||||
@@ -258,54 +279,16 @@ void QETElementEditor::setupActions() {
|
|||||||
connect(add_polygon, SIGNAL(triggered()), this, SLOT(addPolygon() ));
|
connect(add_polygon, SIGNAL(triggered()), this, SLOT(addPolygon() ));
|
||||||
connect(add_text, SIGNAL(triggered()), this, SLOT(addText() ));
|
connect(add_text, SIGNAL(triggered()), this, SLOT(addText() ));
|
||||||
connect(add_arc, SIGNAL(triggered()), this, SLOT(addArc() ));
|
connect(add_arc, SIGNAL(triggered()), this, SLOT(addArc() ));
|
||||||
connect(add_terminal, SIGNAL(triggered()), ce_scene, SLOT(slot_addTerminal()));
|
connect(add_terminal, SIGNAL(triggered()), this, SLOT(addTerminal() ));
|
||||||
connect(add_textfield, SIGNAL(triggered()), this, SLOT(addTextField() ));
|
connect(add_textfield, SIGNAL(triggered()), this, SLOT(addTextField() ));
|
||||||
|
|
||||||
connect(move, SIGNAL(triggered()), this, SLOT(slot_setRubberBandToView()));
|
|
||||||
connect(add_line, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
|
|
||||||
connect(add_rectangle, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
|
|
||||||
connect(add_ellipse, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
|
|
||||||
connect(add_polygon, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
|
|
||||||
connect(add_text, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
|
|
||||||
connect(add_arc, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
|
|
||||||
connect(add_terminal, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
|
|
||||||
connect(add_textfield, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
|
|
||||||
|
|
||||||
connect(ce_scene, SIGNAL(needNormalMode()), this, SLOT(slot_setNormalMode()));
|
parts_toolbar = addToolBar(tr("Parties", "toolbar title"));
|
||||||
|
|
||||||
move -> setCheckable(true);
|
|
||||||
add_line -> setCheckable(true);
|
|
||||||
add_rectangle -> setCheckable(true);
|
|
||||||
add_ellipse -> setCheckable(true);
|
|
||||||
add_polygon -> setCheckable(true);
|
|
||||||
add_text -> setCheckable(true);
|
|
||||||
add_arc -> setCheckable(true);
|
|
||||||
add_terminal -> setCheckable(true);
|
|
||||||
add_textfield -> setCheckable(true);
|
|
||||||
|
|
||||||
parts = new QActionGroup(this);
|
|
||||||
parts -> addAction(move);
|
|
||||||
parts -> addAction(add_line);
|
|
||||||
parts -> addAction(add_rectangle);
|
|
||||||
parts -> addAction(add_ellipse);
|
|
||||||
parts -> addAction(add_polygon);
|
|
||||||
parts -> addAction(add_arc);
|
|
||||||
parts -> addAction(add_text);
|
|
||||||
parts -> addAction(add_textfield);
|
|
||||||
parts -> addAction(add_terminal);
|
|
||||||
parts -> setExclusive(true);
|
|
||||||
|
|
||||||
parts_toolbar = new QToolBar(tr("Parties", "toolbar title"), this);
|
|
||||||
parts_toolbar -> setObjectName("parts");
|
|
||||||
foreach (QAction *action, parts -> actions()) parts_toolbar -> addAction(action);
|
|
||||||
move -> setChecked(true);
|
|
||||||
parts_toolbar -> setAllowedAreas(Qt::AllToolBarAreas);
|
parts_toolbar -> setAllowedAreas(Qt::AllToolBarAreas);
|
||||||
|
parts_toolbar -> setObjectName("parts");
|
||||||
|
parts_toolbar -> addActions(parts -> actions());
|
||||||
|
addToolBar(Qt::LeftToolBarArea, parts_toolbar);
|
||||||
|
|
||||||
/*
|
|
||||||
QAction *xml_preview = new QAction(QET::Icons::DialogInformation, tr("XML"), this);
|
|
||||||
connect(xml_preview, SIGNAL(triggered()), this, SLOT(xmlPreview()));
|
|
||||||
parts_toolbar -> addAction(xml_preview);
|
|
||||||
*/
|
|
||||||
|
|
||||||
main_toolbar = new QToolBar(tr("Outils", "toolbar title"), this);
|
main_toolbar = new QToolBar(tr("Outils", "toolbar title"), this);
|
||||||
main_toolbar -> setObjectName("main_toolbar");
|
main_toolbar -> setObjectName("main_toolbar");
|
||||||
@@ -313,8 +296,6 @@ void QETElementEditor::setupActions() {
|
|||||||
view_toolbar -> setObjectName("display");
|
view_toolbar -> setObjectName("display");
|
||||||
element_toolbar = new QToolBar(tr("\311l\351ment", "toolbar title"), this);
|
element_toolbar = new QToolBar(tr("\311l\351ment", "toolbar title"), this);
|
||||||
element_toolbar -> setObjectName("element_toolbar");
|
element_toolbar -> setObjectName("element_toolbar");
|
||||||
depth_toolbar = new QToolBar(tr("Profondeur", "toolbar title"), this);
|
|
||||||
depth_toolbar -> setObjectName("depth_toolbar");
|
|
||||||
|
|
||||||
main_toolbar -> addAction(new_element);
|
main_toolbar -> addAction(new_element);
|
||||||
main_toolbar -> addAction(open);
|
main_toolbar -> addAction(open);
|
||||||
@@ -333,16 +314,9 @@ void QETElementEditor::setupActions() {
|
|||||||
element_toolbar -> addAction(edit_names);
|
element_toolbar -> addAction(edit_names);
|
||||||
element_toolbar -> addAction(m_edit_properties);
|
element_toolbar -> addAction(m_edit_properties);
|
||||||
|
|
||||||
depth_toolbar -> addAction(edit_forward);
|
|
||||||
depth_toolbar -> addAction(edit_raise);
|
|
||||||
depth_toolbar -> addAction(edit_lower);
|
|
||||||
depth_toolbar -> addAction(edit_backward);
|
|
||||||
|
|
||||||
addToolBar(Qt::TopToolBarArea, main_toolbar);
|
addToolBar(Qt::TopToolBarArea, main_toolbar);
|
||||||
addToolBar(Qt::TopToolBarArea, view_toolbar);
|
addToolBar(Qt::TopToolBarArea, view_toolbar);
|
||||||
addToolBar(Qt::TopToolBarArea, element_toolbar);
|
addToolBar(Qt::TopToolBarArea, element_toolbar);
|
||||||
addToolBar(Qt::TopToolBarArea, depth_toolbar);
|
|
||||||
addToolBar(Qt::LeftToolBarArea, parts_toolbar);
|
|
||||||
|
|
||||||
connect(ce_scene, SIGNAL(selectionChanged()), this, SLOT(slot_updateInformations()));
|
connect(ce_scene, SIGNAL(selectionChanged()), this, SLOT(slot_updateInformations()));
|
||||||
connect(ce_scene, SIGNAL(selectionChanged()), this, SLOT(slot_updateMenus()));
|
connect(ce_scene, SIGNAL(selectionChanged()), this, SLOT(slot_updateMenus()));
|
||||||
@@ -360,7 +334,7 @@ void QETElementEditor::setupActions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Met en place les menus.
|
* @brief QETElementEditor::setupMenus
|
||||||
*/
|
*/
|
||||||
void QETElementEditor::setupMenus() {
|
void QETElementEditor::setupMenus() {
|
||||||
file_menu = new QMenu(tr("&Fichier"), this);
|
file_menu = new QMenu(tr("&Fichier"), this);
|
||||||
@@ -411,15 +385,9 @@ void QETElementEditor::setupMenus() {
|
|||||||
edit_menu -> addAction(edit_author);
|
edit_menu -> addAction(edit_author);
|
||||||
edit_menu -> addAction(m_edit_properties);
|
edit_menu -> addAction(m_edit_properties);
|
||||||
edit_menu -> addSeparator();
|
edit_menu -> addSeparator();
|
||||||
edit_menu -> addAction(edit_forward);
|
edit_menu -> addActions(m_depth_ag -> actions());
|
||||||
edit_menu -> addAction(edit_raise);
|
|
||||||
edit_menu -> addAction(edit_lower);
|
|
||||||
edit_menu -> addAction(edit_backward);
|
|
||||||
|
|
||||||
display_menu -> addAction(zoom_in);
|
display_menu -> addActions(m_zoom_ag -> actions());
|
||||||
display_menu -> addAction(zoom_out);
|
|
||||||
display_menu -> addAction(zoom_fit);
|
|
||||||
display_menu -> addAction(zoom_reset);
|
|
||||||
|
|
||||||
insertMenu(settings_menu_, file_menu);
|
insertMenu(settings_menu_, file_menu);
|
||||||
insertMenu(settings_menu_, edit_menu);
|
insertMenu(settings_menu_, edit_menu);
|
||||||
@@ -446,10 +414,7 @@ void QETElementEditor::contextMenu(QContextMenuEvent *event) {
|
|||||||
menu.addAction(paste_in_area);
|
menu.addAction(paste_in_area);
|
||||||
menu.addMenu(paste_from_menu);
|
menu.addMenu(paste_from_menu);
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
menu.addAction(edit_forward);
|
menu.addActions(m_depth_ag -> actions());
|
||||||
menu.addAction(edit_raise);
|
|
||||||
menu.addAction(edit_lower);
|
|
||||||
menu.addAction(edit_backward);
|
|
||||||
menu.exec(event -> globalPos());
|
menu.exec(event -> globalPos());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,15 +436,13 @@ void QETElementEditor::slot_updateMenus() {
|
|||||||
paste_from_elmt -> setEnabled(!read_only);
|
paste_from_elmt -> setEnabled(!read_only);
|
||||||
parts_list -> setEnabled(!read_only);
|
parts_list -> setEnabled(!read_only);
|
||||||
|
|
||||||
// actions dependant de la presence de parties selectionnees
|
// Action enabled if primitive selected
|
||||||
deselectall -> setEnabled(selected_items);
|
deselectall -> setEnabled(selected_items);
|
||||||
cut -> setEnabled(selected_items);
|
cut -> setEnabled(selected_items);
|
||||||
copy -> setEnabled(selected_items);
|
copy -> setEnabled(selected_items);
|
||||||
edit_delete -> setEnabled(selected_items);
|
edit_delete -> setEnabled(selected_items);
|
||||||
edit_forward -> setEnabled(selected_items);
|
foreach (QAction *action, m_depth_ag -> actions())
|
||||||
edit_raise -> setEnabled(selected_items);
|
action->setEnabled(selected_items);
|
||||||
edit_lower -> setEnabled(selected_items);
|
|
||||||
edit_backward -> setEnabled(selected_items);
|
|
||||||
|
|
||||||
// actions dependant du contenu du presse-papiers
|
// actions dependant du contenu du presse-papiers
|
||||||
paste -> setEnabled(clipboard_elmt);
|
paste -> setEnabled(clipboard_elmt);
|
||||||
@@ -510,7 +473,6 @@ void QETElementEditor::slot_updateTitle() {
|
|||||||
void QETElementEditor::setupInterface() {
|
void QETElementEditor::setupInterface() {
|
||||||
// editeur
|
// editeur
|
||||||
ce_scene = new ElementScene(this, this);
|
ce_scene = new ElementScene(this, this);
|
||||||
ce_scene -> slot_move();
|
|
||||||
ce_view = new ElementView(ce_scene, this);
|
ce_view = new ElementView(ce_scene, this);
|
||||||
slot_setRubberBandToView();
|
slot_setRubberBandToView();
|
||||||
setCentralWidget(ce_view);
|
setCentralWidget(ce_view);
|
||||||
@@ -596,15 +558,6 @@ void QETElementEditor::slot_setNoDragToView() {
|
|||||||
ce_view -> setDragMode(QGraphicsView::NoDrag);
|
ce_view -> setDragMode(QGraphicsView::NoDrag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Passe l'editeur en mode normal
|
|
||||||
*/
|
|
||||||
void QETElementEditor::slot_setNormalMode() {
|
|
||||||
if (!move -> isChecked()) move -> setChecked(true);
|
|
||||||
ce_view -> setDragMode(QGraphicsView::RubberBandDrag);
|
|
||||||
ce_scene -> slot_move();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Met a jour la zone d'information et d'edition des primitives.
|
Met a jour la zone d'information et d'edition des primitives.
|
||||||
Si plusieurs primitives sont selectionnees, seule leur quantite est
|
Si plusieurs primitives sont selectionnees, seule leur quantite est
|
||||||
@@ -684,7 +637,8 @@ bool QETElementEditor::checkElement() {
|
|||||||
/// Check master, slave and simple element
|
/// Check master, slave and simple element
|
||||||
if(ce_scene -> elementType() == "master" ||
|
if(ce_scene -> elementType() == "master" ||
|
||||||
ce_scene -> elementType() == "slave" ||
|
ce_scene -> elementType() == "slave" ||
|
||||||
ce_scene -> elementType() == "simple" ) {
|
ce_scene -> elementType() == "simple" ||
|
||||||
|
ce_scene -> elementType().contains("report")) {
|
||||||
|
|
||||||
bool wrng = true;
|
bool wrng = true;
|
||||||
foreach (CustomElementPart *cep, ce_scene->primitives()) {
|
foreach (CustomElementPart *cep, ce_scene->primitives()) {
|
||||||
@@ -694,7 +648,7 @@ bool QETElementEditor::checkElement() {
|
|||||||
if (wrng) {
|
if (wrng) {
|
||||||
errors << qMakePair(
|
errors << qMakePair(
|
||||||
tr("Absence de champ texte 'label'", "warning title"),
|
tr("Absence de champ texte 'label'", "warning title"),
|
||||||
tr("Les \351l\351ments ma\356tres, esclaves et simple doivent poss\351der "
|
tr("Les \351l\351ments ma\356tres, esclaves, simple et renvoie de folio doivent poss\351der "
|
||||||
"un champ texte comportant le tagg 'label'", "warning description"));
|
"un champ texte comportant le tagg 'label'", "warning description"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -978,12 +932,28 @@ void QETElementEditor::addText() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief QETElementEditor::addTextField
|
* @brief QETElementEditor::addTextField
|
||||||
* Set text field interface to scene
|
* Set text field creation interface to scene
|
||||||
*/
|
*/
|
||||||
void QETElementEditor::addTextField() {
|
void QETElementEditor::addTextField() {
|
||||||
ce_scene -> setEventInterface(new ESEventAddTextField(ce_scene));
|
ce_scene -> setEventInterface(new ESEventAddTextField(ce_scene));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief QETElementEditor::addTerminal
|
||||||
|
* Set terminal creation interface to scene
|
||||||
|
*/
|
||||||
|
void QETElementEditor::addTerminal() {
|
||||||
|
ce_scene -> setEventInterface(new ESEventAddTerminal(ce_scene));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief QETElementEditor::UncheckAddPrimitive
|
||||||
|
* Uncheck all action related to primitive
|
||||||
|
*/
|
||||||
|
void QETElementEditor::UncheckAddPrimitive() {
|
||||||
|
foreach(QAction *action, parts->actions()) action -> setChecked(false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Lance l'assistant de creation d'un nouvel element.
|
Lance l'assistant de creation d'un nouvel element.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ class QETElementEditor : public QETMainWindow {
|
|||||||
virtual ~QETElementEditor();
|
virtual ~QETElementEditor();
|
||||||
private:
|
private:
|
||||||
QETElementEditor(const QETElementEditor &);
|
QETElementEditor(const QETElementEditor &);
|
||||||
|
void setupActions();
|
||||||
|
void setupMenus();
|
||||||
|
void setupInterface();
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
@@ -74,15 +77,10 @@ class QETElementEditor : public QETMainWindow {
|
|||||||
QAction *cut, *copy, *paste, *paste_in_area, *paste_from_file, *paste_from_elmt;
|
QAction *cut, *copy, *paste, *paste_in_area, *paste_from_file, *paste_from_elmt;
|
||||||
QAction *undo, *redo;
|
QAction *undo, *redo;
|
||||||
QAction *edit_delete, *edit_size_hs, *edit_names, *edit_author, *m_edit_properties;
|
QAction *edit_delete, *edit_size_hs, *edit_names, *edit_author, *m_edit_properties;
|
||||||
QAction *edit_raise, *edit_lower, *edit_backward, *edit_forward;
|
|
||||||
/// actions for the "display" menu
|
|
||||||
QAction *zoom_in, *zoom_out, *zoom_fit, *zoom_reset;
|
|
||||||
/// toolbars
|
/// toolbars
|
||||||
QToolBar *parts_toolbar, *main_toolbar, *view_toolbar, *depth_toolbar, *element_toolbar;
|
QToolBar *parts_toolbar, *main_toolbar, *view_toolbar, *depth_toolbar, *element_toolbar;
|
||||||
/// toolbars actions
|
/// Action group
|
||||||
QActionGroup *parts;
|
QActionGroup *parts, *m_zoom_ag, *m_depth_ag;
|
||||||
QAction *move, *add_line, *add_rectangle, *add_ellipse, *add_polygon, *add_text;
|
|
||||||
QAction *add_arc, *add_terminal, *add_textfield;
|
|
||||||
/// minimum window title
|
/// minimum window title
|
||||||
QString min_title;
|
QString min_title;
|
||||||
/// filename of the currently edited element
|
/// filename of the currently edited element
|
||||||
@@ -120,9 +118,6 @@ class QETElementEditor : public QETMainWindow {
|
|||||||
virtual void firstActivation(QEvent *);
|
virtual void firstActivation(QEvent *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupActions();
|
|
||||||
void setupMenus();
|
|
||||||
void setupInterface();
|
|
||||||
bool canClose();
|
bool canClose();
|
||||||
QWidget *clearToolsDock();
|
QWidget *clearToolsDock();
|
||||||
void copyAndPasteXml(const QDomDocument &);
|
void copyAndPasteXml(const QDomDocument &);
|
||||||
@@ -135,6 +130,8 @@ class QETElementEditor : public QETMainWindow {
|
|||||||
void addArc();
|
void addArc();
|
||||||
void addText();
|
void addText();
|
||||||
void addTextField();
|
void addTextField();
|
||||||
|
void addTerminal();
|
||||||
|
void UncheckAddPrimitive();
|
||||||
|
|
||||||
void slot_new();
|
void slot_new();
|
||||||
void slot_open();
|
void slot_open();
|
||||||
@@ -147,7 +144,6 @@ class QETElementEditor : public QETMainWindow {
|
|||||||
bool slot_saveAsFile();
|
bool slot_saveAsFile();
|
||||||
void slot_setRubberBandToView();
|
void slot_setRubberBandToView();
|
||||||
void slot_setNoDragToView();
|
void slot_setNoDragToView();
|
||||||
void slot_setNormalMode();
|
|
||||||
void slot_updateInformations();
|
void slot_updateInformations();
|
||||||
void slot_updateMenus();
|
void slot_updateMenus();
|
||||||
void slot_updateTitle();
|
void slot_updateTitle();
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ QPixmap ElementsCollectionCache::pixmap() const {
|
|||||||
*/
|
*/
|
||||||
bool ElementsCollectionCache::fetchData(const ElementsLocation &location) {
|
bool ElementsCollectionCache::fetchData(const ElementsLocation &location) {
|
||||||
int state;
|
int state;
|
||||||
Element *custom_elmt = ElementFactory::Instance()->createElement(location, 0, 0, &state);
|
Element *custom_elmt = ElementFactory::Instance() -> createElement(location, 0, &state);
|
||||||
if (state) {
|
if (state) {
|
||||||
qDebug() << "ElementsCollectionCache::fetchData() : Le chargement du composant" << qPrintable(location.toString()) << "a echoue avec le code d'erreur" << state;
|
qDebug() << "ElementsCollectionCache::fetchData() : Le chargement du composant" << qPrintable(location.toString()) << "a echoue avec le code d'erreur" << state;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ void ElementsPanel::startElementDrag(const ElementsLocation &location) {
|
|||||||
|
|
||||||
// element temporaire pour fournir un apercu
|
// element temporaire pour fournir un apercu
|
||||||
int elmt_creation_state;
|
int elmt_creation_state;
|
||||||
Element *temp_elmt = ElementFactory::Instance()->createElement(location, 0, 0, &elmt_creation_state);
|
Element *temp_elmt = ElementFactory::Instance() -> createElement(location, 0, &elmt_creation_state);
|
||||||
if (elmt_creation_state) {
|
if (elmt_creation_state) {
|
||||||
delete temp_elmt;
|
delete temp_elmt;
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -72,6 +72,8 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) {
|
|||||||
prj_del_diagram = new QAction(QET::Icons::DiagramDelete, tr("Supprimer ce sch\351ma"), this);
|
prj_del_diagram = new QAction(QET::Icons::DiagramDelete, tr("Supprimer ce sch\351ma"), this);
|
||||||
prj_move_diagram_up = new QAction(QET::Icons::GoUp, tr("Remonter ce sch\351ma"), this);
|
prj_move_diagram_up = new QAction(QET::Icons::GoUp, tr("Remonter ce sch\351ma"), this);
|
||||||
prj_move_diagram_down = new QAction(QET::Icons::GoDown, tr("Abaisser ce sch\351ma"), this);
|
prj_move_diagram_down = new QAction(QET::Icons::GoDown, tr("Abaisser ce sch\351ma"), this);
|
||||||
|
prj_move_diagram_upx10 = new QAction(QET::Icons::GoUp, tr("Remonter ce sch\351ma x10"), this);
|
||||||
|
prj_move_diagram_downx10 = new QAction(QET::Icons::GoDown, tr("Abaisser ce sch\351ma x10"), this);
|
||||||
tbt_add = new QAction(QET::Icons::TitleBlock, tr("Nouveau mod\350le"), this);
|
tbt_add = new QAction(QET::Icons::TitleBlock, tr("Nouveau mod\350le"), this);
|
||||||
tbt_edit = new QAction(QET::Icons::TitleBlock, tr("\311diter ce mod\350le"), this);
|
tbt_edit = new QAction(QET::Icons::TitleBlock, tr("\311diter ce mod\350le"), this);
|
||||||
tbt_remove = new QAction(QET::Icons::TitleBlock, tr("Supprimer ce mod\350le"), this);
|
tbt_remove = new QAction(QET::Icons::TitleBlock, tr("Supprimer ce mod\350le"), this);
|
||||||
@@ -118,6 +120,8 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) {
|
|||||||
connect(prj_del_diagram, SIGNAL(triggered()), this, SLOT(deleteDiagram()));
|
connect(prj_del_diagram, SIGNAL(triggered()), this, SLOT(deleteDiagram()));
|
||||||
connect(prj_move_diagram_up, SIGNAL(triggered()), this, SLOT(moveDiagramUp()));
|
connect(prj_move_diagram_up, SIGNAL(triggered()), this, SLOT(moveDiagramUp()));
|
||||||
connect(prj_move_diagram_down, SIGNAL(triggered()), this, SLOT(moveDiagramDown()));
|
connect(prj_move_diagram_down, SIGNAL(triggered()), this, SLOT(moveDiagramDown()));
|
||||||
|
connect(prj_move_diagram_upx10, SIGNAL(triggered()), this, SLOT(moveDiagramUpx10()));
|
||||||
|
connect(prj_move_diagram_downx10, SIGNAL(triggered()), this, SLOT(moveDiagramDownx10()));
|
||||||
connect(tbt_add, SIGNAL(triggered()), this, SLOT(addTitleBlockTemplate()));
|
connect(tbt_add, SIGNAL(triggered()), this, SLOT(addTitleBlockTemplate()));
|
||||||
connect(tbt_edit, SIGNAL(triggered()), this, SLOT(editTitleBlockTemplate()));
|
connect(tbt_edit, SIGNAL(triggered()), this, SLOT(editTitleBlockTemplate()));
|
||||||
connect(tbt_remove, SIGNAL(triggered()), this, SLOT(removeTitleBlockTemplate()));
|
connect(tbt_remove, SIGNAL(triggered()), this, SLOT(removeTitleBlockTemplate()));
|
||||||
@@ -311,6 +315,25 @@ void ElementsPanelWidget::moveDiagramDown() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Emet le signal requestForDiagramMoveUpx10 avec le schema selectionne
|
||||||
|
*/
|
||||||
|
void ElementsPanelWidget::moveDiagramUpx10() {
|
||||||
|
if (Diagram *selected_diagram = elements_panel -> selectedDiagram()) {
|
||||||
|
emit(requestForDiagramMoveUpx10(selected_diagram));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Emet le signal requestForDiagramMoveDownx10 avec le schema selectionne
|
||||||
|
*/
|
||||||
|
void ElementsPanelWidget::moveDiagramDownx10() {
|
||||||
|
if (Diagram *selected_diagram = elements_panel -> selectedDiagram()) {
|
||||||
|
emit(requestForDiagramMoveDownx10(selected_diagram));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Opens a template editor to create a new title block template.
|
Opens a template editor to create a new title block template.
|
||||||
*/
|
*/
|
||||||
@@ -431,6 +454,8 @@ void ElementsPanelWidget::updateButtons() {
|
|||||||
prj_del_diagram -> setEnabled(is_writable);
|
prj_del_diagram -> setEnabled(is_writable);
|
||||||
prj_move_diagram_up -> setEnabled(is_writable && diagram_position > 0);
|
prj_move_diagram_up -> setEnabled(is_writable && diagram_position > 0);
|
||||||
prj_move_diagram_down -> setEnabled(is_writable && diagram_position < project_diagrams_count - 1);
|
prj_move_diagram_down -> setEnabled(is_writable && diagram_position < project_diagrams_count - 1);
|
||||||
|
prj_move_diagram_upx10 -> setEnabled(is_writable && diagram_position > 10);
|
||||||
|
prj_move_diagram_downx10 -> setEnabled(is_writable && diagram_position < project_diagrams_count - 10);
|
||||||
setElementsActionEnabled(false);
|
setElementsActionEnabled(false);
|
||||||
} else if (current_type == QET::TitleBlockTemplatesCollection) {
|
} else if (current_type == QET::TitleBlockTemplatesCollection) {
|
||||||
TitleBlockTemplateLocation location = elements_panel -> templateLocationForItem(current_item);
|
TitleBlockTemplateLocation location = elements_panel -> templateLocationForItem(current_item);
|
||||||
@@ -533,8 +558,10 @@ void ElementsPanelWidget::handleContextMenu(const QPoint &pos) {
|
|||||||
case QET::Diagram:
|
case QET::Diagram:
|
||||||
context_menu -> addAction(prj_prop_diagram);
|
context_menu -> addAction(prj_prop_diagram);
|
||||||
context_menu -> addAction(prj_del_diagram);
|
context_menu -> addAction(prj_del_diagram);
|
||||||
|
context_menu -> addAction(prj_move_diagram_upx10);
|
||||||
context_menu -> addAction(prj_move_diagram_up);
|
context_menu -> addAction(prj_move_diagram_up);
|
||||||
context_menu -> addAction(prj_move_diagram_down);
|
context_menu -> addAction(prj_move_diagram_down);
|
||||||
|
context_menu -> addAction(prj_move_diagram_downx10);
|
||||||
break;
|
break;
|
||||||
case QET::TitleBlockTemplatesCollection:
|
case QET::TitleBlockTemplatesCollection:
|
||||||
context_menu -> addAction(tbt_add);
|
context_menu -> addAction(tbt_add);
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class ElementsPanelWidget : public QWidget {
|
|||||||
QAction *new_category, *edit_category, *delete_category;
|
QAction *new_category, *edit_category, *delete_category;
|
||||||
QAction *delete_collection;
|
QAction *delete_collection;
|
||||||
QAction *new_element, *edit_element, *delete_element, *open_element;
|
QAction *new_element, *edit_element, *delete_element, *open_element;
|
||||||
QAction *prj_activate, *prj_close, *prj_edit_prop, *prj_prop_diagram, *prj_add_diagram, *prj_del_diagram, *prj_move_diagram_up, *prj_move_diagram_down;
|
QAction *prj_activate, *prj_close, *prj_edit_prop, *prj_prop_diagram, *prj_add_diagram, *prj_del_diagram, *prj_move_diagram_up, *prj_move_diagram_down, *prj_move_diagram_upx10, *prj_move_diagram_downx10;
|
||||||
QAction *tbt_add, *tbt_edit, *tbt_remove;
|
QAction *tbt_add, *tbt_edit, *tbt_remove;
|
||||||
QAction *copy_elements_, *move_elements_, *cancel_elements_;
|
QAction *copy_elements_, *move_elements_, *cancel_elements_;
|
||||||
QMenu *context_menu;
|
QMenu *context_menu;
|
||||||
@@ -67,6 +67,8 @@ class ElementsPanelWidget : public QWidget {
|
|||||||
void requestForDiagramDeletion(Diagram *);
|
void requestForDiagramDeletion(Diagram *);
|
||||||
void requestForDiagramMoveUp(Diagram *);
|
void requestForDiagramMoveUp(Diagram *);
|
||||||
void requestForDiagramMoveDown(Diagram *);
|
void requestForDiagramMoveDown(Diagram *);
|
||||||
|
void requestForDiagramMoveUpx10(Diagram *);
|
||||||
|
void requestForDiagramMoveDownx10(Diagram *);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void clearFilterTextField();
|
void clearFilterTextField();
|
||||||
@@ -81,6 +83,8 @@ class ElementsPanelWidget : public QWidget {
|
|||||||
void deleteDiagram();
|
void deleteDiagram();
|
||||||
void moveDiagramUp();
|
void moveDiagramUp();
|
||||||
void moveDiagramDown();
|
void moveDiagramDown();
|
||||||
|
void moveDiagramUpx10();
|
||||||
|
void moveDiagramDownx10();
|
||||||
void addTitleBlockTemplate();
|
void addTitleBlockTemplate();
|
||||||
void editTitleBlockTemplate();
|
void editTitleBlockTemplate();
|
||||||
void removeTitleBlockTemplate();
|
void removeTitleBlockTemplate();
|
||||||
|
|||||||
@@ -31,29 +31,31 @@ ElementFactory* ElementFactory::factory_ = 0;
|
|||||||
* @brief ElementFactory::createElement
|
* @brief ElementFactory::createElement
|
||||||
* @param location create element at this location
|
* @param location create element at this location
|
||||||
* @param qgi parent item for this elemnt
|
* @param qgi parent item for this elemnt
|
||||||
* @param s diagram of the element
|
|
||||||
* @param state state of the creation
|
* @param state state of the creation
|
||||||
* @return the element or 0
|
* @return the element or 0
|
||||||
*/
|
*/
|
||||||
Element * ElementFactory::createElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) {
|
Element * ElementFactory::createElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state)
|
||||||
|
{
|
||||||
// recupere la definition de l'element
|
// recupere la definition de l'element
|
||||||
ElementsCollectionItem *element_item = QETApp::collectionItem(location);
|
ElementsCollectionItem *element_item = QETApp::collectionItem(location);
|
||||||
ElementDefinition *element_definition;
|
ElementDefinition *element_definition;
|
||||||
if (!element_item ||\
|
if (!element_item ||\
|
||||||
!element_item -> isElement() ||\
|
!element_item -> isElement() ||\
|
||||||
!(element_definition = qobject_cast<ElementDefinition *>(element_item))) {
|
!(element_definition = qobject_cast<ElementDefinition *>(element_item)))
|
||||||
|
{
|
||||||
if (state) *state = 1;
|
if (state) *state = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element_definition->xml().hasAttribute("link_type")) {
|
if (element_definition->xml().hasAttribute("link_type"))
|
||||||
|
{
|
||||||
QString link_type = element_definition->xml().attribute("link_type");
|
QString link_type = element_definition->xml().attribute("link_type");
|
||||||
if (link_type == "next_report" || link_type == "previous_report") return (new ReportElement(location, link_type, qgi, s, state));
|
if (link_type == "next_report" || link_type == "previous_report") return (new ReportElement(location, link_type, qgi, state));
|
||||||
if (link_type == "master") return (new MasterElement (location, qgi, s, state));
|
if (link_type == "master") return (new MasterElement (location, qgi, state));
|
||||||
if (link_type == "slave") return (new SlaveElement (location, qgi, s, state));
|
if (link_type == "slave") return (new SlaveElement (location, qgi, state));
|
||||||
if (link_type == "terminal") return (new TerminalElement (location, qgi, s, state));
|
if (link_type == "terminal") return (new TerminalElement (location, qgi, state));
|
||||||
}
|
}
|
||||||
|
|
||||||
//default if nothing match for link_type
|
//default if nothing match for link_type
|
||||||
return (new SimpleElement(location, qgi, s, state));
|
return (new SimpleElement(location, qgi, state));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ class ElementFactory
|
|||||||
}
|
}
|
||||||
return factory_;
|
return factory_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete the instance of factory
|
// delete the instance of factory
|
||||||
static void dropInstance () {
|
static void dropInstance () {
|
||||||
static QMutex mutex;
|
static QMutex mutex;
|
||||||
@@ -55,6 +56,7 @@ class ElementFactory
|
|||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//attributes
|
//attributes
|
||||||
private:
|
private:
|
||||||
static ElementFactory* factory_;
|
static ElementFactory* factory_;
|
||||||
@@ -67,7 +69,7 @@ class ElementFactory
|
|||||||
~ElementFactory() {}
|
~ElementFactory() {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Element * createElement (const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0, int * = 0);
|
Element * createElement (const ElementsLocation &, QGraphicsItem * = 0, int * = 0);
|
||||||
};
|
};
|
||||||
//ElementFactory ElementFactory::factory_ = 0;
|
//ElementFactory ElementFactory::factory_ = 0;
|
||||||
#endif // ELEMENTFACTORY_H
|
#endif // ELEMENTFACTORY_H
|
||||||
|
|||||||
@@ -969,11 +969,13 @@ void GenericPanel::diagramRemoved(QETProject *project, Diagram *diagram) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param project Projet auquel appartiennent les schemas concernes
|
* @brief GenericPanel::projectDiagramsOrderChanged
|
||||||
@param from Index de l'onglet avant le deplacement
|
* @param project project where diagram moved
|
||||||
@param to Index de l'onglet apres le deplacement
|
* @param from Index of diagram before move
|
||||||
|
* @param to Index of diagram after move
|
||||||
*/
|
*/
|
||||||
void GenericPanel::projectDiagramsOrderChanged(QETProject *project, int from, int to) {
|
void GenericPanel::projectDiagramsOrderChanged(QETProject *project, int from, int to)
|
||||||
|
{
|
||||||
// get the item representing the provided project
|
// get the item representing the provided project
|
||||||
QTreeWidgetItem *qtwi_project = itemForProject(project);
|
QTreeWidgetItem *qtwi_project = itemForProject(project);
|
||||||
if (!qtwi_project) return;
|
if (!qtwi_project) return;
|
||||||
@@ -988,19 +990,19 @@ void GenericPanel::projectDiagramsOrderChanged(QETProject *project, int from, in
|
|||||||
qtwi_project -> insertChild (to, moved_qtwi_diagram);
|
qtwi_project -> insertChild (to, moved_qtwi_diagram);
|
||||||
|
|
||||||
// update the QTWI labels because they may display the folio index
|
// update the QTWI labels because they may display the folio index
|
||||||
foreach (int diagram_index, QList<int>() << from << to) {
|
for (int i = qMin(from, to); i < qMax(from, to) + 1; i++)
|
||||||
QTreeWidgetItem *qtwi_diagram = qtwi_project -> child(diagram_index);
|
{
|
||||||
|
QTreeWidgetItem *qtwi_diagram = qtwi_project -> child(i);
|
||||||
if (!qtwi_diagram) continue;
|
if (!qtwi_diagram) continue;
|
||||||
|
|
||||||
Diagram *diagram = valueForItem<Diagram *>(qtwi_diagram);
|
Diagram *diagram = valueForItem<Diagram *>(qtwi_diagram);
|
||||||
if (diagram) {
|
if (diagram)
|
||||||
updateDiagramItem(qtwi_diagram, diagram);
|
updateDiagramItem(qtwi_diagram, diagram);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (was_selected) {
|
if (was_selected)
|
||||||
setCurrentItem(moved_qtwi_diagram);
|
setCurrentItem(moved_qtwi_diagram);
|
||||||
}
|
|
||||||
emit(panelContentChanged());
|
emit(panelContentChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ bool nomenclature::saveToCSVFile() {
|
|||||||
QString nomenclature::getNomenclature() {
|
QString nomenclature::getNomenclature() {
|
||||||
//Process...
|
//Process...
|
||||||
QString data = tr("NOMENCLATURE : ") + m_project -> title() + "\n\n";
|
QString data = tr("NOMENCLATURE : ") + m_project -> title() + "\n\n";
|
||||||
data += tr("Folio") +";"+ tr("Sch\351ma") +";"+ tr("D\351signation")+";"+ tr("Label") +";"+ tr("Commentaire") +";"+ tr("Fabriquant") +";"+ tr("Reference") +";"+ tr("Machine-reference")+"\n";
|
data += tr("Folio") +";"+ tr("Sch\351ma") +";"+ tr("D\351signation qet")+";"+ tr("Label") +";"+ tr("D\351signation")+";"+ tr("Commentaire") +";"+ tr("Fabriquant") +";"+ tr("Reference") +";"+ tr("Machine-reference")+"\n";
|
||||||
|
|
||||||
if(m_list_diagram.isEmpty()) return data;
|
if(m_list_diagram.isEmpty()) return data;
|
||||||
|
|
||||||
@@ -115,6 +115,7 @@ QString nomenclature::getElementInfo(const Element *elmt) {
|
|||||||
info += diagram -> title() + ";";
|
info += diagram -> title() + ";";
|
||||||
info += elmt -> name() + ";";
|
info += elmt -> name() + ";";
|
||||||
info += elmt_info["label"].toString() + ";";
|
info += elmt_info["label"].toString() + ";";
|
||||||
|
info += elmt_info["designation"].toString() + ";";
|
||||||
info += elmt_info["comment"].toString() + ";";
|
info += elmt_info["comment"].toString() + ";";
|
||||||
info += elmt_info["manufacturer"].toString() + ";";
|
info += elmt_info["manufacturer"].toString() + ";";
|
||||||
info += elmt_info["manufacturer-reference"].toString() + ";";
|
info += elmt_info["manufacturer-reference"].toString() + ";";
|
||||||
|
|||||||
@@ -113,13 +113,6 @@ QList<Diagram *> ProjectView::getDiagrams(ProjectSaveOptions options) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options & ModifiedDiagramsOnly) {
|
|
||||||
foreach (Diagram *diagram, selection) {
|
|
||||||
if (!diagram -> undoStack().isClean() || !diagram -> wasWritten()) continue;
|
|
||||||
selection.removeOne(diagram);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return(selection);
|
return(selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,8 +308,8 @@ void ProjectView::addNewDiagram() {
|
|||||||
*/
|
*/
|
||||||
void ProjectView::addNewDiagramFolioList() {
|
void ProjectView::addNewDiagramFolioList() {
|
||||||
if (project_ -> isReadOnly()) return;
|
if (project_ -> isReadOnly()) return;
|
||||||
int i = 0; //< Each new diagram is added to the end of the project.
|
int i = 1; //< Each new diagram is added to the end of the project.
|
||||||
//< We use @i to move the folio list at the beginning of the project
|
//< We use @i to move the folio list at second position in the project
|
||||||
foreach (Diagram *d, project_ -> addNewDiagramFolioList()) {
|
foreach (Diagram *d, project_ -> addNewDiagramFolioList()) {
|
||||||
DiagramView *new_diagram_view = new DiagramView(d);
|
DiagramView *new_diagram_view = new DiagramView(d);
|
||||||
addDiagram(new_diagram_view);
|
addDiagram(new_diagram_view);
|
||||||
@@ -371,11 +364,8 @@ void ProjectView::removeDiagram(DiagramView *diagram_view) {
|
|||||||
// verifie que le schema est bien present dans le projet
|
// verifie que le schema est bien present dans le projet
|
||||||
if (!diagram_ids_.values().contains(diagram_view)) return;
|
if (!diagram_ids_.values().contains(diagram_view)) return;
|
||||||
|
|
||||||
// demande confirmation a l'utilisateur
|
|
||||||
if (
|
//Ask confirmation to user.
|
||||||
diagram_view -> diagram() -> wasWritten() ||\
|
|
||||||
!diagram_view -> diagram() -> undoStack().isClean()
|
|
||||||
) {
|
|
||||||
int answer = QET::MessageBox::question(
|
int answer = QET::MessageBox::question(
|
||||||
this,
|
this,
|
||||||
tr("Supprimer le sch\351ma ?", "message box title"),
|
tr("Supprimer le sch\351ma ?", "message box title"),
|
||||||
@@ -386,10 +376,6 @@ void ProjectView::removeDiagram(DiagramView *diagram_view) {
|
|||||||
if (answer != QMessageBox::Yes) {
|
if (answer != QMessageBox::Yes) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// notifie le reste du monde que le DiagramView va disparaitre
|
|
||||||
emit(diagramAboutToBeRemoved(diagram_view));
|
|
||||||
|
|
||||||
// enleve le DiagramView des onglets
|
// enleve le DiagramView des onglets
|
||||||
int diagram_tab_id = diagram_ids_.key(diagram_view);
|
int diagram_tab_id = diagram_ids_.key(diagram_view);
|
||||||
@@ -515,6 +501,48 @@ void ProjectView::moveDiagramDown(Diagram *diagram) {
|
|||||||
moveDiagramDown(findDiagram(diagram));
|
moveDiagramDown(findDiagram(diagram));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Deplace le schema diagram_view vers le haut / la gauche x10
|
||||||
|
*/
|
||||||
|
void ProjectView::moveDiagramUpx10(DiagramView *diagram_view) {
|
||||||
|
if (!diagram_view) return;
|
||||||
|
|
||||||
|
int diagram_view_position = diagram_ids_.key(diagram_view);
|
||||||
|
if (!diagram_view_position) {
|
||||||
|
// le schema est le premier du projet
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
tabs_ -> moveTab(diagram_view_position, diagram_view_position - 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Deplace le schema diagram vers le haut / la gauche x10
|
||||||
|
*/
|
||||||
|
void ProjectView::moveDiagramUpx10(Diagram *diagram) {
|
||||||
|
moveDiagramUpx10(findDiagram(diagram));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Deplace le schema diagram_view vers le bas / la droite x10
|
||||||
|
*/
|
||||||
|
void ProjectView::moveDiagramDownx10(DiagramView *diagram_view) {
|
||||||
|
if (!diagram_view) return;
|
||||||
|
|
||||||
|
int diagram_view_position = diagram_ids_.key(diagram_view);
|
||||||
|
if (diagram_view_position + 1 == diagram_ids_.count()) {
|
||||||
|
// le schema est le dernier du projet
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
tabs_ -> moveTab(diagram_view_position, diagram_view_position + 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Deplace le schema diagram vers le bas / la droite x10
|
||||||
|
*/
|
||||||
|
void ProjectView::moveDiagramDownx10(Diagram *diagram) {
|
||||||
|
moveDiagramDownx10(findDiagram(diagram));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Ce slot demarre un dialogue permettant a l'utilisateur de parametrer et de
|
Ce slot demarre un dialogue permettant a l'utilisateur de parametrer et de
|
||||||
lancer l'impression de toute ou partie du projet.
|
lancer l'impression de toute ou partie du projet.
|
||||||
@@ -777,7 +805,7 @@ void ProjectView::loadDiagrams() {
|
|||||||
// If project have the folios list, move it at the beginning of the project
|
// If project have the folios list, move it at the beginning of the project
|
||||||
if (project_ -> getFolioSheetsQuantity()) {
|
if (project_ -> getFolioSheetsQuantity()) {
|
||||||
for (int i = 0; i < project_->getFolioSheetsQuantity(); i++)
|
for (int i = 0; i < project_->getFolioSheetsQuantity(); i++)
|
||||||
tabs_ -> moveTab(diagrams().size()-1, 0);
|
tabs_ -> moveTab(diagrams().size()-1, + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ class ProjectView : public QWidget {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
enum ProjectSaveOption {
|
enum ProjectSaveOption {
|
||||||
ModifiedDiagramsOnly = 1,
|
|
||||||
CurrentDiagram = 2,
|
CurrentDiagram = 2,
|
||||||
AllDiagramsButCurrent = 4,
|
AllDiagramsButCurrent = 4,
|
||||||
AllDiagrams = 6
|
AllDiagrams = 6
|
||||||
@@ -74,10 +73,14 @@ class ProjectView : public QWidget {
|
|||||||
void moveDiagramUp(Diagram *);
|
void moveDiagramUp(Diagram *);
|
||||||
void moveDiagramDown(DiagramView *);
|
void moveDiagramDown(DiagramView *);
|
||||||
void moveDiagramDown(Diagram *);
|
void moveDiagramDown(Diagram *);
|
||||||
|
void moveDiagramUpx10(DiagramView *);
|
||||||
|
void moveDiagramUpx10(Diagram *);
|
||||||
|
void moveDiagramDownx10(DiagramView *);
|
||||||
|
void moveDiagramDownx10(Diagram *);
|
||||||
void printProject();
|
void printProject();
|
||||||
void exportProject();
|
void exportProject();
|
||||||
QETResult save();
|
QETResult save();
|
||||||
QETResult saveAs(ProjectSaveOptions = ProjectSaveOptions(AllDiagrams | ModifiedDiagramsOnly));
|
QETResult saveAs(ProjectSaveOptions = ProjectSaveOptions(AllDiagrams));
|
||||||
QETResult doSave(ProjectSaveOptions);
|
QETResult doSave(ProjectSaveOptions);
|
||||||
void saveDiagrams(const QList<Diagram *> &);
|
void saveDiagrams(const QList<Diagram *> &);
|
||||||
int cleanProject();
|
int cleanProject();
|
||||||
@@ -88,7 +91,6 @@ class ProjectView : public QWidget {
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void diagramAdded(DiagramView *);
|
void diagramAdded(DiagramView *);
|
||||||
void diagramAboutToBeRemoved(DiagramView *);
|
|
||||||
void diagramRemoved(DiagramView *);
|
void diagramRemoved(DiagramView *);
|
||||||
void diagramActivated(DiagramView *);
|
void diagramActivated(DiagramView *);
|
||||||
void diagramOrderChanged(ProjectView *, int, int);
|
void diagramOrderChanged(ProjectView *, int, int);
|
||||||
|
|||||||
@@ -683,3 +683,18 @@ QPointF QET::graphicsSceneEventPos(QEvent *event) {
|
|||||||
}
|
}
|
||||||
return(event_scene_pos);
|
return(event_scene_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief QET::eachStrIsEqual
|
||||||
|
* @param qsl list of string to compare
|
||||||
|
* @return true if every string is identical, else false;
|
||||||
|
* The list must not be empty
|
||||||
|
* If the list can be empty, call isEmpty() before calling this function
|
||||||
|
*/
|
||||||
|
bool QET::eachStrIsEqual(const QStringList &qsl) {
|
||||||
|
if (qsl.size() == 1) return true;
|
||||||
|
foreach (const QString t, qsl) {
|
||||||
|
if (qsl.at(0) != t) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace QET {
|
|||||||
/// QElectroTech version (as string, used to mark projects and elements XML documents)
|
/// QElectroTech version (as string, used to mark projects and elements XML documents)
|
||||||
const QString version = "0.4";
|
const QString version = "0.4";
|
||||||
/// QElectroTech displayed version
|
/// QElectroTech displayed version
|
||||||
const QString displayedVersion = "0.4-rc1";
|
const QString displayedVersion = "0.4-rc2";
|
||||||
QString license();
|
QString license();
|
||||||
|
|
||||||
/// Oriented movements
|
/// Oriented movements
|
||||||
@@ -154,6 +154,7 @@ namespace QET {
|
|||||||
QString titleBlockColumnLengthToString(const TitleBlockColumnLength &);
|
QString titleBlockColumnLengthToString(const TitleBlockColumnLength &);
|
||||||
bool writeXmlFile(QDomDocument &, const QString &, QString * = 0);
|
bool writeXmlFile(QDomDocument &, const QString &, QString * = 0);
|
||||||
QPointF graphicsSceneEventPos(QEvent *);
|
QPointF graphicsSceneEventPos(QEvent *);
|
||||||
|
bool eachStrIsEqual (const QStringList &qsl);
|
||||||
}
|
}
|
||||||
|
|
||||||
class Qet : public QObject {
|
class Qet : public QObject {
|
||||||
|
|||||||
@@ -346,6 +346,7 @@ QStringList QETApp::elementInfoKeys() {
|
|||||||
QStringList info_list;
|
QStringList info_list;
|
||||||
info_list << "label"
|
info_list << "label"
|
||||||
<< "comment"
|
<< "comment"
|
||||||
|
<< "designation"
|
||||||
<< "manufacturer"
|
<< "manufacturer"
|
||||||
<< "manufacturer-reference"
|
<< "manufacturer-reference"
|
||||||
<< "machine-manufacturer-reference";
|
<< "machine-manufacturer-reference";
|
||||||
@@ -362,6 +363,7 @@ QStringList QETApp::elementInfoKeys() {
|
|||||||
QString QETApp::elementTranslatedInfoKey(QString &info) {
|
QString QETApp::elementTranslatedInfoKey(QString &info) {
|
||||||
if (info == "label") return tr("Label");
|
if (info == "label") return tr("Label");
|
||||||
else if (info == "comment") return tr("Commentaire");
|
else if (info == "comment") return tr("Commentaire");
|
||||||
|
else if (info == "designation") return tr("D\351signation");
|
||||||
else if (info == "manufacturer") return tr("Fabriquant");
|
else if (info == "manufacturer") return tr("Fabriquant");
|
||||||
else if (info == "manufacturer-reference") return tr("R\351f\351rence fabriquant");
|
else if (info == "manufacturer-reference") return tr("R\351f\351rence fabriquant");
|
||||||
else if (info == "machine-manufacturer-reference") return tr("R\351f\351rence fabriquant machine");
|
else if (info == "machine-manufacturer-reference") return tr("R\351f\351rence fabriquant machine");
|
||||||
|
|||||||
@@ -44,10 +44,12 @@
|
|||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
constructeur
|
* @brief QETDiagramEditor::QETDiagramEditor
|
||||||
@param files Liste de fichiers a ouvrir
|
* Constructor
|
||||||
@param parent le widget parent de la fenetre principale
|
* @param files, list of files to open
|
||||||
|
* @param parent, parent widget
|
||||||
*/
|
*/
|
||||||
QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
|
QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
|
||||||
QETMainWindow(parent),
|
QETMainWindow(parent),
|
||||||
@@ -57,13 +59,12 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
|
|||||||
m_selection_actions_group (this),
|
m_selection_actions_group (this),
|
||||||
m_row_column_actions_group (this),
|
m_row_column_actions_group (this),
|
||||||
m_file_actions_group (this),
|
m_file_actions_group (this),
|
||||||
open_dialog_dir (QDesktopServices::storageLocation(QDesktopServices::DesktopLocation)),
|
open_dialog_dir (QDesktopServices::storageLocation(QDesktopServices::DesktopLocation))
|
||||||
can_update_actions (true)
|
|
||||||
{
|
{
|
||||||
// mise en place de l'interface MDI au centre de l'application
|
//Setup the mdi area at center of application
|
||||||
setCentralWidget(&workspace);
|
setCentralWidget(&workspace);
|
||||||
|
|
||||||
// nomme l'objet afin qu'il soit reperable par les feuilles de style
|
//Set object name to be retrieved by the stylesheets
|
||||||
workspace.setBackground(QBrush(Qt::NoBrush));
|
workspace.setBackground(QBrush(Qt::NoBrush));
|
||||||
workspace.setObjectName("mdiarea");
|
workspace.setObjectName("mdiarea");
|
||||||
|
|
||||||
@@ -71,16 +72,11 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
|
|||||||
workspace.setTabsClosable(true);
|
workspace.setTabsClosable(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// mise en place du signalmapper
|
//Set the signal mapper
|
||||||
connect(&windowMapper, SIGNAL(mapped(QWidget *)), this, SLOT(activateWidget(QWidget *)));
|
connect(&windowMapper, SIGNAL(mapped(QWidget *)), this, SLOT(activateWidget(QWidget *)));
|
||||||
|
|
||||||
// titre de la fenetre
|
|
||||||
setWindowTitle(tr("QElectroTech", "window title"));
|
setWindowTitle(tr("QElectroTech", "window title"));
|
||||||
|
|
||||||
// icone de la fenetre
|
|
||||||
setWindowIcon(QET::Icons::QETLogo);
|
setWindowIcon(QET::Icons::QETLogo);
|
||||||
|
|
||||||
// barre de statut de la fenetre
|
|
||||||
statusBar() -> showMessage(tr("QElectroTech", "status bar message"));
|
statusBar() -> showMessage(tr("QElectroTech", "status bar message"));
|
||||||
|
|
||||||
setUpElementsPanel();
|
setUpElementsPanel();
|
||||||
@@ -89,37 +85,30 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
|
|||||||
setUpToolBar();
|
setUpToolBar();
|
||||||
setUpMenu();
|
setUpMenu();
|
||||||
|
|
||||||
// la fenetre est maximisee par defaut
|
tabifyDockWidget(qdw_undo, qdw_pa);
|
||||||
|
|
||||||
|
//By default the windows is maximised
|
||||||
setMinimumSize(QSize(500, 350));
|
setMinimumSize(QSize(500, 350));
|
||||||
setWindowState(Qt::WindowMaximized);
|
setWindowState(Qt::WindowMaximized);
|
||||||
|
|
||||||
// connexions signaux / slots pour une interface sensee
|
connect (&workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(subWindowActivated(QMdiSubWindow*)));
|
||||||
connect(&workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(slot_updateWindowsMenu()));
|
|
||||||
connect(&workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(slot_updateUndoStack()));
|
|
||||||
connect (QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(slot_updatePasteAction()));
|
connect (QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(slot_updatePasteAction()));
|
||||||
|
connect (&undo_group, SIGNAL(cleanChanged(bool)), this, SLOT(activeUndoStackCleanChanged(bool)));
|
||||||
|
|
||||||
// lecture des parametres
|
|
||||||
readSettings();
|
readSettings();
|
||||||
|
|
||||||
// affichage
|
|
||||||
show();
|
show();
|
||||||
|
|
||||||
// si des chemins de fichiers valides sont passes en arguments
|
//If valid file path is given as arguments
|
||||||
uint opened_projects = 0;
|
uint opened_projects = 0;
|
||||||
if (files.count()) {
|
if (files.count())
|
||||||
// alors on ouvre ces fichiers
|
{
|
||||||
foreach(QString file, files) {
|
//So we open this files
|
||||||
bool project_opening = openAndAddProject(file, false);
|
foreach(QString file, files)
|
||||||
if (project_opening) {
|
if (openAndAddProject(file, false))
|
||||||
++ opened_projects;
|
++ opened_projects;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
slot_updateActions();
|
slot_updateActions();
|
||||||
|
|
||||||
// si aucun schema n'a ete ouvert jusqu'a maintenant, on ouvre un nouveau schema
|
|
||||||
//if (!opened_projects) newProject();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -142,6 +131,7 @@ void QETDiagramEditor::setUpElementsPanel() {
|
|||||||
qdw_pa -> setMinimumWidth (160);
|
qdw_pa -> setMinimumWidth (160);
|
||||||
qdw_pa -> setWidget (pa = new ElementsPanelWidget(qdw_pa));
|
qdw_pa -> setWidget (pa = new ElementsPanelWidget(qdw_pa));
|
||||||
|
|
||||||
|
addDockWidget(Qt::LeftDockWidgetArea, qdw_pa);
|
||||||
|
|
||||||
connect(pa, SIGNAL(requestForProject (QETProject *)), this, SLOT(activateProject(QETProject *)));
|
connect(pa, SIGNAL(requestForProject (QETProject *)), this, SLOT(activateProject(QETProject *)));
|
||||||
connect(pa, SIGNAL(requestForProjectClosing (QETProject *)), this, SLOT(closeProject(QETProject *)));
|
connect(pa, SIGNAL(requestForProjectClosing (QETProject *)), this, SLOT(closeProject(QETProject *)));
|
||||||
@@ -153,6 +143,8 @@ void QETDiagramEditor::setUpElementsPanel() {
|
|||||||
connect(pa, SIGNAL(requestForDiagramDeletion (Diagram *)), this, SLOT(removeDiagram(Diagram *)));
|
connect(pa, SIGNAL(requestForDiagramDeletion (Diagram *)), this, SLOT(removeDiagram(Diagram *)));
|
||||||
connect(pa, SIGNAL(requestForDiagramMoveUp (Diagram *)), this, SLOT(moveDiagramUp(Diagram *)));
|
connect(pa, SIGNAL(requestForDiagramMoveUp (Diagram *)), this, SLOT(moveDiagramUp(Diagram *)));
|
||||||
connect(pa, SIGNAL(requestForDiagramMoveDown (Diagram *)), this, SLOT(moveDiagramDown(Diagram *)));
|
connect(pa, SIGNAL(requestForDiagramMoveDown (Diagram *)), this, SLOT(moveDiagramDown(Diagram *)));
|
||||||
|
connect(pa, SIGNAL(requestForDiagramMoveUpx10 (Diagram *)), this, SLOT(moveDiagramUpx10(Diagram *)));
|
||||||
|
connect(pa, SIGNAL(requestForDiagramMoveDownx10 (Diagram *)), this, SLOT(moveDiagramDownx10(Diagram *)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -174,6 +166,8 @@ void QETDiagramEditor::setUpUndoStack() {
|
|||||||
qdw_undo -> setFeatures(QDockWidget::AllDockWidgetFeatures);
|
qdw_undo -> setFeatures(QDockWidget::AllDockWidgetFeatures);
|
||||||
qdw_undo -> setMinimumWidth(160);
|
qdw_undo -> setMinimumWidth(160);
|
||||||
qdw_undo -> setWidget(undo_view);
|
qdw_undo -> setWidget(undo_view);
|
||||||
|
|
||||||
|
addDockWidget(Qt::LeftDockWidgetArea, qdw_undo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -619,30 +613,44 @@ void QETDiagramEditor::exportDialog() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Methode enregistrant le schema dans le dernier nom de fichier connu.
|
* @brief QETDiagramEditor::save
|
||||||
@return true si l'enregistrement a reussi, false sinon
|
* Ask the current active project to save
|
||||||
*/
|
*/
|
||||||
void QETDiagramEditor::save() {
|
void QETDiagramEditor::save() {
|
||||||
if (ProjectView *project_view = currentProject()) {
|
if (ProjectView *project_view = currentProject()) {
|
||||||
QETResult saved = project_view -> save();
|
QETResult saved = project_view -> save();
|
||||||
|
|
||||||
if (saved.isOk()) {
|
if (saved.isOk()) {
|
||||||
|
save_file -> setDisabled(true);
|
||||||
QETApp::projectsRecentFiles() -> fileWasOpened(project_view -> project() -> filePath());
|
QETApp::projectsRecentFiles() -> fileWasOpened(project_view -> project() -> filePath());
|
||||||
} else {
|
|
||||||
|
QString title = (project_view -> project() -> title ());
|
||||||
|
if (title.isEmpty()) title = "QElectroTech ";
|
||||||
|
QString filePath = (project_view -> project() -> filePath ());
|
||||||
|
statusBar()-> showMessage(tr("Projet %1 enregistr\351 dans le repertoire: %2.").arg(title).arg (filePath), 2000);
|
||||||
|
}
|
||||||
|
else {
|
||||||
showError(saved);
|
showError(saved);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Cette methode demande un nom de fichier a l'utilisateur pour enregistrer le schema
|
* @brief QETDiagramEditor::saveAs
|
||||||
@return true si l'enregistrement a reussi, false sinon
|
* Ask the current active project to save as
|
||||||
*/
|
*/
|
||||||
void QETDiagramEditor::saveAs() {
|
void QETDiagramEditor::saveAs() {
|
||||||
if (ProjectView *project_view = currentProject()) {
|
if (ProjectView *project_view = currentProject()) {
|
||||||
QETResult save_file = project_view -> saveAs();
|
QETResult save_file = project_view -> saveAs();
|
||||||
if (save_file.isOk()) {
|
if (save_file.isOk()) {
|
||||||
QETApp::projectsRecentFiles() -> fileWasOpened(project_view -> project() -> filePath());
|
QETApp::projectsRecentFiles() -> fileWasOpened(project_view -> project() -> filePath());
|
||||||
} else {
|
|
||||||
|
QString title = (project_view -> project() -> title ());
|
||||||
|
if (title.isEmpty()) title = "QElectroTech ";
|
||||||
|
QString filePath = (project_view -> project() -> filePath ());
|
||||||
|
statusBar()->showMessage(tr("Projet %1 enregistr\351 dans le repertoire: %2.").arg(title).arg (filePath), 2000);
|
||||||
|
}
|
||||||
|
else {
|
||||||
showError(save_file);
|
showError(save_file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -859,6 +867,8 @@ bool QETDiagramEditor::addProject(QETProject *project, bool update_panel) {
|
|||||||
ProjectView *project_view = new ProjectView(project);
|
ProjectView *project_view = new ProjectView(project);
|
||||||
addProjectView(project_view);
|
addProjectView(project_view);
|
||||||
|
|
||||||
|
undo_group.addStack(project -> undoStack());
|
||||||
|
|
||||||
// met a jour le panel d'elements
|
// met a jour le panel d'elements
|
||||||
if (update_panel) {
|
if (update_panel) {
|
||||||
pa -> elementsPanel().projectWasOpened(project);
|
pa -> elementsPanel().projectWasOpened(project);
|
||||||
@@ -1132,24 +1142,22 @@ void QETDiagramEditor::slot_setVisualisationMode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
gere les actions
|
* @brief QETDiagramEditor::slot_updateActions
|
||||||
|
* Manage actions
|
||||||
*/
|
*/
|
||||||
void QETDiagramEditor::slot_updateActions() {
|
void QETDiagramEditor::slot_updateActions()
|
||||||
|
{
|
||||||
DiagramView *dv = currentDiagram();
|
DiagramView *dv = currentDiagram();
|
||||||
ProjectView *pv = currentProject();
|
ProjectView *pv = currentProject();
|
||||||
|
|
||||||
bool opened_project = pv;
|
bool opened_project = pv;
|
||||||
bool opened_diagram = dv;
|
bool opened_diagram = dv;
|
||||||
bool editable_project = (pv && !pv -> project() -> isReadOnly());
|
bool editable_project = (pv && !pv -> project() -> isReadOnly());
|
||||||
bool editable_diagram = (dv && !dv -> diagram() -> isReadOnly());
|
|
||||||
|
|
||||||
// actions ayant juste besoin d'un document ouvert
|
|
||||||
close_file -> setEnabled(opened_project);
|
close_file -> setEnabled(opened_project);
|
||||||
save_file -> setEnabled(editable_project);
|
|
||||||
save_file_as -> setEnabled(opened_project);
|
save_file_as -> setEnabled(opened_project);
|
||||||
prj_edit_prop -> setEnabled(opened_project);
|
prj_edit_prop -> setEnabled(opened_project);
|
||||||
prj_add_diagram -> setEnabled(editable_project);
|
prj_add_diagram -> setEnabled(editable_project);
|
||||||
//prj_add_diagram_foliolist -> setEnabled(editable_project);
|
|
||||||
prj_del_diagram -> setEnabled(editable_project);
|
prj_del_diagram -> setEnabled(editable_project);
|
||||||
prj_clean -> setEnabled(editable_project);
|
prj_clean -> setEnabled(editable_project);
|
||||||
prj_diagramList -> setEnabled(opened_project);
|
prj_diagramList -> setEnabled(opened_project);
|
||||||
@@ -1160,10 +1168,10 @@ void QETDiagramEditor::slot_updateActions() {
|
|||||||
prj_nomenclature -> setEnabled(editable_project);
|
prj_nomenclature -> setEnabled(editable_project);
|
||||||
m_zoom_actions_group. setEnabled(opened_diagram);
|
m_zoom_actions_group. setEnabled(opened_diagram);
|
||||||
m_select_actions_group. setEnabled(opened_diagram);
|
m_select_actions_group. setEnabled(opened_diagram);
|
||||||
m_add_item_actions_group.setEnabled(editable_diagram);
|
m_add_item_actions_group. setEnabled(editable_project);
|
||||||
m_row_column_actions_group.setEnabled(editable_diagram);
|
m_row_column_actions_group.setEnabled(editable_project);
|
||||||
|
|
||||||
|
|
||||||
|
slot_updateUndoStack();
|
||||||
slot_updateModeActions();
|
slot_updateModeActions();
|
||||||
slot_updatePasteAction();
|
slot_updatePasteAction();
|
||||||
slot_updateComplexActions();
|
slot_updateComplexActions();
|
||||||
@@ -1173,12 +1181,17 @@ void QETDiagramEditor::slot_updateActions() {
|
|||||||
* @brief QETDiagramEditor::slot_updateUndoStack
|
* @brief QETDiagramEditor::slot_updateUndoStack
|
||||||
* Update the undo stack view
|
* Update the undo stack view
|
||||||
*/
|
*/
|
||||||
void QETDiagramEditor::slot_updateUndoStack() {
|
void QETDiagramEditor::slot_updateUndoStack()
|
||||||
|
{
|
||||||
ProjectView *pv = currentProject();
|
ProjectView *pv = currentProject();
|
||||||
if (pv && can_update_actions) {
|
if (pv)
|
||||||
|
{
|
||||||
undo_group.setActiveStack(pv->project()->undoStack());
|
undo_group.setActiveStack(pv->project()->undoStack());
|
||||||
undo -> setEnabled (undo_group.canUndo());
|
save_file -> setEnabled (undo_group.activeStack() -> count() && !pv -> project() -> isReadOnly());
|
||||||
redo -> setEnabled (undo_group.canRedo());
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
save_file -> setDisabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1210,13 +1223,14 @@ void QETDiagramEditor::slot_updateComplexActions() {
|
|||||||
// actions ayant besoin de textes selectionnes
|
// actions ayant besoin de textes selectionnes
|
||||||
int selected_texts = dv ? (dv -> diagram() -> selectedTexts().count()) : 0;
|
int selected_texts = dv ? (dv -> diagram() -> selectedTexts().count()) : 0;
|
||||||
int selected_conductor_texts = dv ? (dv -> diagram() -> selectedConductorTexts().count()) : 0;
|
int selected_conductor_texts = dv ? (dv -> diagram() -> selectedConductorTexts().count()) : 0;
|
||||||
|
int selected_element_texts = dv ? (dv -> diagram() -> selectedElementTexts().count()) : 0;
|
||||||
rotate_texts -> setEnabled(editable_diagram && selected_texts);
|
rotate_texts -> setEnabled(editable_diagram && selected_texts);
|
||||||
|
|
||||||
// actions need only one editable item
|
// actions need only one editable item
|
||||||
int selected_image = dv ? dv -> diagram() -> selectedContent().count(DiagramContent::Images) : 0;
|
int selected_image = dv ? dv -> diagram() -> selectedContent().count(DiagramContent::Images) : 0;
|
||||||
|
|
||||||
int selected_shape = dv ? dv -> diagram() -> selectedContent().count(DiagramContent::Shapes) : 0;
|
int selected_shape = dv ? dv -> diagram() -> selectedContent().count(DiagramContent::Shapes) : 0;
|
||||||
int selected_editable = selected_elements_count + (selected_texts - selected_conductor_texts) + selected_image + selected_shape;
|
int selected_editable = selected_elements_count + (selected_texts - selected_conductor_texts - selected_element_texts) + selected_image + selected_shape;
|
||||||
|
|
||||||
if (selected_editable == 1) {
|
if (selected_editable == 1) {
|
||||||
edit_selection -> setEnabled(true);
|
edit_selection -> setEnabled(true);
|
||||||
@@ -1283,65 +1297,46 @@ void QETDiagramEditor::slot_updatePasteAction() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Ajoute un projet dans l'espace de travail
|
* @brief QETDiagramEditor::addProjectView
|
||||||
@param project_view Le projet a ajouter dans l'espace de travail
|
* Add a new project view to workspace and
|
||||||
|
* build the connection between the projectview / project and this QETDiagramEditor.
|
||||||
|
* @param project_view, project view to add
|
||||||
*/
|
*/
|
||||||
void QETDiagramEditor::addProjectView(ProjectView *project_view) {
|
void QETDiagramEditor::addProjectView(ProjectView *project_view)
|
||||||
|
{
|
||||||
if (!project_view) return;
|
if (!project_view) return;
|
||||||
|
|
||||||
// on maximise la nouvelle fenetre si la fenetre en cours est inexistante ou bien maximisee
|
foreach(DiagramView *dv, project_view -> diagrams())
|
||||||
QWidget *current_window = workspace.activeSubWindow();
|
|
||||||
bool maximise = ((!current_window) || (current_window -> windowState() & Qt::WindowMaximized));
|
|
||||||
|
|
||||||
// ajoute la fenetre
|
|
||||||
QMdiSubWindow *sub_window = workspace.addSubWindow(project_view);
|
|
||||||
sub_window -> setWindowIcon(project_view -> windowIcon());
|
|
||||||
sub_window -> systemMenu() -> clear();
|
|
||||||
|
|
||||||
// lie les schemas du projet a l'editeur :
|
|
||||||
// quand on change de schemas a l'interieur d'un projet, on met a jour les menus
|
|
||||||
connect(project_view, SIGNAL(diagramActivated(DiagramView *)), this, SLOT(slot_updateWindowsMenu()));
|
|
||||||
connect(project_view, SIGNAL(diagramActivated(DiagramView *)), this, SLOT(slot_updateActions()));
|
|
||||||
//connect(project_view->project(), SIGNAL(projectModified(QETProject*,bool)), save_file, SLOT(setEnabled(bool)));
|
|
||||||
|
|
||||||
foreach(DiagramView *dv, project_view -> diagrams()) {
|
|
||||||
diagramWasAdded(dv);
|
diagramWasAdded(dv);
|
||||||
}
|
|
||||||
|
|
||||||
// gere la fermeture du projet
|
//Manage the close event of project
|
||||||
connect(project_view, SIGNAL(projectClosed(ProjectView*)), this, SLOT(projectWasClosed(ProjectView *)));
|
connect(project_view, SIGNAL(projectClosed(ProjectView*)), this, SLOT(projectWasClosed(ProjectView *)));
|
||||||
|
//Manage the adding of diagram
|
||||||
// gere l'ajout et le retrait de schema du projet
|
|
||||||
connect(project_view, SIGNAL(diagramAdded(DiagramView *)), this, SLOT(diagramWasAdded(DiagramView *)));
|
connect(project_view, SIGNAL(diagramAdded(DiagramView *)), this, SLOT(diagramWasAdded(DiagramView *)));
|
||||||
connect(project_view, SIGNAL(diagramAdded(DiagramView *)), this, SLOT(slot_updateActions()));
|
|
||||||
connect(project_view, SIGNAL(diagramAboutToBeRemoved(DiagramView *)), this, SLOT(diagramIsAboutToBeRemoved(DiagramView *)));
|
if (QETProject *project = project_view -> project())
|
||||||
connect(project_view, SIGNAL(diagramRemoved(DiagramView *)), this, SLOT(diagramWasRemoved(DiagramView *)));
|
|
||||||
connect(project_view, SIGNAL(diagramRemoved(DiagramView *)), this, SLOT(slot_updateActions()));
|
|
||||||
if (QETProject *project = project_view -> project()) {
|
|
||||||
// on met aussi les menus a jour quand un projet passe en lecture seule ou non
|
|
||||||
connect(project, SIGNAL(readOnlyChanged(QETProject *, bool)), this, SLOT(slot_updateActions()));
|
connect(project, SIGNAL(readOnlyChanged(QETProject *, bool)), this, SLOT(slot_updateActions()));
|
||||||
}
|
|
||||||
|
|
||||||
// gere les demandes consistant a retrouver un element dans le panel
|
//Manage request for edit or find element and titleblock
|
||||||
connect(project_view, SIGNAL(findElementRequired(const ElementsLocation &)), this, SLOT(findElementInPanel(const ElementsLocation &)));
|
connect(project_view, SIGNAL(findElementRequired(const ElementsLocation &)), this, SLOT(findElementInPanel(const ElementsLocation &)));
|
||||||
|
|
||||||
// gere les demandes pour l'edition d'un element
|
|
||||||
connect(project_view, SIGNAL(editElementRequired(const ElementsLocation &)), this, SLOT(editElementInEditor(const ElementsLocation &)));
|
connect(project_view, SIGNAL(editElementRequired(const ElementsLocation &)), this, SLOT(editElementInEditor(const ElementsLocation &)));
|
||||||
|
connect(project_view, SIGNAL(editTitleBlockTemplate(const TitleBlockTemplateLocation &, bool)), QETApp::instance(), SLOT(openTitleBlockTemplate(TitleBlockTemplateLocation, bool)));
|
||||||
// handles requests to edit and/or duplicate an existing title block template
|
|
||||||
connect(
|
|
||||||
project_view, SIGNAL(editTitleBlockTemplate(const TitleBlockTemplateLocation &, bool)),
|
|
||||||
QETApp::instance(), SLOT(openTitleBlockTemplate(TitleBlockTemplateLocation, bool))
|
|
||||||
);
|
|
||||||
|
|
||||||
// display error messages sent by the project view
|
// display error messages sent by the project view
|
||||||
connect(project_view, SIGNAL(errorEncountered(QString)), this, SLOT(showError(const QString &)));
|
connect(project_view, SIGNAL(errorEncountered(QString)), this, SLOT(showError(const QString &)));
|
||||||
|
|
||||||
// affiche la fenetre
|
//We maximise the new window if the current window is inexistent or maximized
|
||||||
|
QWidget *current_window = workspace.activeSubWindow();
|
||||||
|
bool maximise = ((!current_window) || (current_window -> windowState() & Qt::WindowMaximized));
|
||||||
|
|
||||||
|
//Add the new window
|
||||||
|
QMdiSubWindow *sub_window = workspace.addSubWindow(project_view);
|
||||||
|
sub_window -> setWindowIcon(project_view -> windowIcon());
|
||||||
|
sub_window -> systemMenu() -> clear();
|
||||||
|
|
||||||
|
//Display the new window
|
||||||
if (maximise) project_view -> showMaximized();
|
if (maximise) project_view -> showMaximized();
|
||||||
else project_view -> show();
|
else project_view -> show();
|
||||||
|
|
||||||
slot_updateActions();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1666,6 +1661,7 @@ void QETDiagramEditor::projectWasClosed(ProjectView *project_view) {
|
|||||||
QETProject *project = project_view -> project();
|
QETProject *project = project_view -> project();
|
||||||
if (project) {
|
if (project) {
|
||||||
pa -> elementsPanel().projectWasClosed(project);
|
pa -> elementsPanel().projectWasClosed(project);
|
||||||
|
undo_group.removeStack(project -> undoStack());
|
||||||
QETApp::unregisterProject(project);
|
QETApp::unregisterProject(project);
|
||||||
}
|
}
|
||||||
project_view -> deleteLater();
|
project_view -> deleteLater();
|
||||||
@@ -1792,6 +1788,46 @@ void QETDiagramEditor::moveDiagramDown(Diagram *diagram) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Change l'ordre des schemas d'un projet, en decalant le schema vers le haut /
|
||||||
|
la gauche x10
|
||||||
|
@param diagram Schema a decaler vers le haut / la gauche x10
|
||||||
|
*/
|
||||||
|
void QETDiagramEditor::moveDiagramUpx10(Diagram *diagram) {
|
||||||
|
if (!diagram) return;
|
||||||
|
|
||||||
|
// recupere le projet contenant le schema
|
||||||
|
if (QETProject *diagram_project = diagram -> project()) {
|
||||||
|
if (diagram_project -> isReadOnly()) return;
|
||||||
|
|
||||||
|
// recupere la vue sur ce projet
|
||||||
|
if (ProjectView *project_view = findProject(diagram_project)) {
|
||||||
|
project_view -> moveDiagramUpx10(diagram);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Change l'ordre des schemas d'un projet, en decalant le schema vers le bas /
|
||||||
|
la droite x10
|
||||||
|
@param diagram Schema a decaler vers le bas / la droite x10
|
||||||
|
*/
|
||||||
|
void QETDiagramEditor::moveDiagramDownx10(Diagram *diagram) {
|
||||||
|
if (!diagram) return;
|
||||||
|
|
||||||
|
// recupere le projet contenant le schema
|
||||||
|
if (QETProject *diagram_project = diagram -> project()) {
|
||||||
|
if (diagram_project -> isReadOnly()) return;
|
||||||
|
|
||||||
|
// recupere la vue sur ce projet
|
||||||
|
if (ProjectView *project_view = findProject(diagram_project)) {
|
||||||
|
project_view -> moveDiagramDownx10(diagram);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Nettoie le projet courant
|
Nettoie le projet courant
|
||||||
*/
|
*/
|
||||||
@@ -1817,7 +1853,6 @@ void QETDiagramEditor::nomenclatureProject() {
|
|||||||
void QETDiagramEditor::removeDiagramFromProject() {
|
void QETDiagramEditor::removeDiagramFromProject() {
|
||||||
if (ProjectView *current_project = currentProject()) {
|
if (ProjectView *current_project = currentProject()) {
|
||||||
if (DiagramView *current_diagram = current_project -> currentDiagram()) {
|
if (DiagramView *current_diagram = current_project -> currentDiagram()) {
|
||||||
can_update_actions = false;
|
|
||||||
bool isFolioList = false;
|
bool isFolioList = false;
|
||||||
|
|
||||||
// if diagram to remove is a "folio list sheet", then set a flag.
|
// if diagram to remove is a "folio list sheet", then set a flag.
|
||||||
@@ -1849,36 +1884,17 @@ void QETDiagramEditor::removeDiagramFromProject() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Gere l'ajout d'un schema dans un projet
|
* @brief QETDiagramEditor::diagramWasAdded
|
||||||
@param dv DiagramView concerne
|
* Manage the adding of diagram view in a project
|
||||||
|
* @param dv, added diagram view
|
||||||
*/
|
*/
|
||||||
void QETDiagramEditor::diagramWasAdded(DiagramView *dv) {
|
void QETDiagramEditor::diagramWasAdded(DiagramView *dv)
|
||||||
// quand on change qqc a l'interieur d'un schema, on met a jour les menus
|
{
|
||||||
undo_group.addStack(&(dv -> diagram() -> undoStack()));
|
|
||||||
connect(dv, SIGNAL(selectionChanged()), this, SLOT(slot_updateComplexActions()));
|
connect(dv, SIGNAL(selectionChanged()), this, SLOT(slot_updateComplexActions()));
|
||||||
connect(dv, SIGNAL(modeChanged()), this, SLOT(slot_updateModeActions()));
|
connect(dv, SIGNAL(modeChanged()), this, SLOT(slot_updateModeActions()));
|
||||||
connect(dv, SIGNAL(itemAdded()), this, SLOT(addItemFinish()));
|
connect(dv, SIGNAL(itemAdded()), this, SLOT(addItemFinish()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Gere le retrait d'un schema dans un projet avant que le retrait ne soit effectif
|
|
||||||
@param dv DiagramView concerne
|
|
||||||
*/
|
|
||||||
void QETDiagramEditor::diagramIsAboutToBeRemoved(DiagramView *dv) {
|
|
||||||
undo_group.removeStack(&(dv -> diagram() -> undoStack()));
|
|
||||||
can_update_actions = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Gere le retrait d'un schema dans un projet apres que le retrait soit effectif
|
|
||||||
@param dv DiagramView concerne
|
|
||||||
*/
|
|
||||||
void QETDiagramEditor::diagramWasRemoved(DiagramView *dv) {
|
|
||||||
Q_UNUSED(dv);
|
|
||||||
can_update_actions = true;
|
|
||||||
slot_updateUndoStack();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param location Emplacement de l'element a retrouver dans le panel
|
@param location Emplacement de l'element a retrouver dans le panel
|
||||||
d'elements.
|
d'elements.
|
||||||
@@ -1970,3 +1986,28 @@ void QETDiagramEditor::showError(const QString &error) {
|
|||||||
void QETDiagramEditor::addItemFinish() {
|
void QETDiagramEditor::addItemFinish() {
|
||||||
m_add_item_actions_group.checkedAction()->setChecked(false);
|
m_add_item_actions_group.checkedAction()->setChecked(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief QETDiagramEditor::subWindowActivated
|
||||||
|
* Slot used to update menu and undo stack when subwindows of MDIarea was activated
|
||||||
|
* @param subWindows
|
||||||
|
*/
|
||||||
|
void QETDiagramEditor::subWindowActivated(QMdiSubWindow *subWindows)
|
||||||
|
{
|
||||||
|
Q_UNUSED(subWindows);
|
||||||
|
|
||||||
|
slot_updateActions();
|
||||||
|
slot_updateWindowsMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief QETDiagramEditor::activeUndoStackCleanChanged
|
||||||
|
* Enable the QAction save_file when @clean is set to false
|
||||||
|
* @clean at true do nothing;
|
||||||
|
* @param clean
|
||||||
|
*/
|
||||||
|
void QETDiagramEditor::activeUndoStackCleanChanged(bool clean) {
|
||||||
|
if (!clean) {
|
||||||
|
save_file -> setEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -146,11 +146,11 @@ class QETDiagramEditor : public QETMainWindow {
|
|||||||
void removeDiagramFromProject();
|
void removeDiagramFromProject();
|
||||||
void moveDiagramUp(Diagram *);
|
void moveDiagramUp(Diagram *);
|
||||||
void moveDiagramDown(Diagram *);
|
void moveDiagramDown(Diagram *);
|
||||||
|
void moveDiagramUpx10(Diagram *);
|
||||||
|
void moveDiagramDownx10(Diagram *);
|
||||||
void cleanCurrentProject();
|
void cleanCurrentProject();
|
||||||
void nomenclatureProject();
|
void nomenclatureProject();
|
||||||
void diagramWasAdded(DiagramView *);
|
void diagramWasAdded(DiagramView *);
|
||||||
void diagramIsAboutToBeRemoved(DiagramView *);
|
|
||||||
void diagramWasRemoved(DiagramView *);
|
|
||||||
void findElementInPanel(const ElementsLocation &);
|
void findElementInPanel(const ElementsLocation &);
|
||||||
void findSelectedElementInPanel();
|
void findSelectedElementInPanel();
|
||||||
void editElementInEditor(const ElementsLocation &);
|
void editElementInEditor(const ElementsLocation &);
|
||||||
@@ -158,6 +158,10 @@ class QETDiagramEditor : public QETMainWindow {
|
|||||||
void showError(const QETResult &);
|
void showError(const QETResult &);
|
||||||
void showError(const QString &);
|
void showError(const QString &);
|
||||||
void addItemFinish();
|
void addItemFinish();
|
||||||
|
void subWindowActivated(QMdiSubWindow *subWindows);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void activeUndoStackCleanChanged (bool clean);
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
public:
|
public:
|
||||||
@@ -229,6 +233,5 @@ class QETDiagramEditor : public QETMainWindow {
|
|||||||
QToolBar *diagram_bar;
|
QToolBar *diagram_bar;
|
||||||
QToolBar *m_add_item_toolBar;
|
QToolBar *m_add_item_toolBar;
|
||||||
QUndoGroup undo_group;
|
QUndoGroup undo_group;
|
||||||
bool can_update_actions;
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ CommentItem::CommentItem(Element *elmt) :
|
|||||||
connect(elmt, SIGNAL(yChanged()), this, SLOT (autoPos()));
|
connect(elmt, SIGNAL(yChanged()), this, SLOT (autoPos()));
|
||||||
connect(elmt, SIGNAL(rotationChanged()), this, SLOT (autoPos()));
|
connect(elmt, SIGNAL(rotationChanged()), this, SLOT (autoPos()));
|
||||||
}
|
}
|
||||||
connect(elmt, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT (updateLabel()));
|
connect(elmt, SIGNAL(elementInfoChange(DiagramContext,DiagramContext)), this, SLOT (updateLabel()));
|
||||||
|
|
||||||
updateLabel();
|
updateLabel();
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ void CommentItem::updateLabel() {
|
|||||||
painter.setPen (pen);
|
painter.setPen (pen);
|
||||||
painter.setFont (QETApp::diagramTextsFont(6));
|
painter.setFont (QETApp::diagramTextsFont(6));
|
||||||
|
|
||||||
QRectF drawing_rect(QPointF(0,0), QSizeF(100, 100));
|
QRectF drawing_rect(QPointF(0,0), QSizeF(70, 100));
|
||||||
QRectF text_bounding;
|
QRectF text_bounding;
|
||||||
|
|
||||||
painter.drawText(drawing_rect, Qt::TextWordWrap | Qt::AlignHCenter, m_comment, &text_bounding);
|
painter.drawText(drawing_rect, Qt::TextWordWrap | Qt::AlignHCenter, m_comment, &text_bounding);
|
||||||
@@ -129,6 +129,7 @@ void CommentItem::updateLabel() {
|
|||||||
text_bounding.adjust(-1,0,1,0); //adjust only for better visual
|
text_bounding.adjust(-1,0,1,0); //adjust only for better visual
|
||||||
painter.drawRoundedRect(text_bounding, 2, 2);
|
painter.drawRoundedRect(text_bounding, 2, 2);
|
||||||
|
|
||||||
|
prepareGeometryChange();
|
||||||
m_bounding_rect = text_bounding;
|
m_bounding_rect = text_bounding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,11 +39,12 @@ QBrush Conductor::square_brush = QBrush(Qt::darkGreen);
|
|||||||
@param p2 Seconde Borne a laquelle le conducteur est lie
|
@param p2 Seconde Borne a laquelle le conducteur est lie
|
||||||
@param parent_diagram QGraphicsScene a laquelle appartient le conducteur
|
@param parent_diagram QGraphicsScene a laquelle appartient le conducteur
|
||||||
*/
|
*/
|
||||||
Conductor::Conductor(Terminal *p1, Terminal* p2, Diagram *parent_diagram) :
|
Conductor::Conductor(Terminal *p1, Terminal* p2) :
|
||||||
QObject(),
|
QObject(),
|
||||||
QGraphicsPathItem(0, parent_diagram),
|
QGraphicsPathItem(0),
|
||||||
terminal1(p1),
|
terminal1(p1),
|
||||||
terminal2(p2),
|
terminal2(p2),
|
||||||
|
bMouseOver(false),
|
||||||
destroyed_(false),
|
destroyed_(false),
|
||||||
text_item(0),
|
text_item(0),
|
||||||
segments(NULL),
|
segments(NULL),
|
||||||
@@ -91,7 +92,6 @@ Conductor::Conductor(Terminal *p1, Terminal* p2, Diagram *parent_diagram) :
|
|||||||
// ajout du champ de texte editable
|
// ajout du champ de texte editable
|
||||||
text_item = new ConductorTextItem(properties_.text, this);
|
text_item = new ConductorTextItem(properties_.text, this);
|
||||||
text_item -> setFlag(QGraphicsItem::ItemStacksBehindParent);
|
text_item -> setFlag(QGraphicsItem::ItemStacksBehindParent);
|
||||||
calculateTextItemPosition();
|
|
||||||
connect(
|
connect(
|
||||||
text_item,
|
text_item,
|
||||||
SIGNAL(diagramTextChanged(DiagramTextItem *, const QString &, const QString &)),
|
SIGNAL(diagramTextChanged(DiagramTextItem *, const QString &, const QString &)),
|
||||||
@@ -444,6 +444,10 @@ void Conductor::paint(QPainter *qp, const QStyleOptionGraphicsItem *options, QWi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if mouse over conductor change size
|
||||||
|
if ( bMouseOver ) conductor_pen.setWidthF(3.0);
|
||||||
|
else conductor_pen.setWidthF(1.0);
|
||||||
|
|
||||||
// affectation du QPen et de la QBrush modifies au QPainter
|
// affectation du QPen et de la QBrush modifies au QPainter
|
||||||
qp -> setBrush(conductor_brush);
|
qp -> setBrush(conductor_brush);
|
||||||
QPen final_conductor_pen = conductor_pen;
|
QPen final_conductor_pen = conductor_pen;
|
||||||
@@ -677,7 +681,6 @@ void Conductor::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
if (!(e -> modifiers() & Qt::ControlModifier)) {
|
if (!(e -> modifiers() & Qt::ControlModifier)) {
|
||||||
QGraphicsPathItem::mouseReleaseEvent(e);
|
QGraphicsPathItem::mouseReleaseEvent(e);
|
||||||
}
|
}
|
||||||
calculateTextItemPosition();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -687,10 +690,9 @@ void Conductor::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
void Conductor::hoverEnterEvent(QGraphicsSceneHoverEvent *e) {
|
void Conductor::hoverEnterEvent(QGraphicsSceneHoverEvent *e) {
|
||||||
Q_UNUSED(e);
|
Q_UNUSED(e);
|
||||||
segments_squares_scale_ = 2.0;
|
segments_squares_scale_ = 2.0;
|
||||||
if (isSelected()) {
|
bMouseOver = true;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Gere la sortie de la souris de la zone du conducteur
|
Gere la sortie de la souris de la zone du conducteur
|
||||||
@@ -699,24 +701,23 @@ void Conductor::hoverEnterEvent(QGraphicsSceneHoverEvent *e) {
|
|||||||
void Conductor::hoverLeaveEvent(QGraphicsSceneHoverEvent *e) {
|
void Conductor::hoverLeaveEvent(QGraphicsSceneHoverEvent *e) {
|
||||||
Q_UNUSED(e);
|
Q_UNUSED(e);
|
||||||
segments_squares_scale_ = 1.0;
|
segments_squares_scale_ = 1.0;
|
||||||
if (isSelected()) {
|
|
||||||
update();
|
update();
|
||||||
}
|
bMouseOver = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Gere les mouvements de souris au dessus du conducteur
|
* @brief Conductor::hoverMoveEvent conductor
|
||||||
@param e Le QGraphicsSceneHoverEvent decrivant l'evenement
|
* @param e QGraphicsSceneHoverEvent describing the event
|
||||||
*/
|
*/
|
||||||
void Conductor::hoverMoveEvent(QGraphicsSceneHoverEvent *e) {
|
void Conductor::hoverMoveEvent(QGraphicsSceneHoverEvent *e) {
|
||||||
/*
|
|
||||||
if (isSelected()) {
|
if (isSelected()) {
|
||||||
QPointF hover_point = mapFromScene(e -> pos());
|
QPointF hover_point = mapFromScene(e -> pos()) + scenePos();
|
||||||
ConductorSegment *segment = segments;
|
ConductorSegment *segment = segments;
|
||||||
bool cursor_set = false;
|
bool cursor_set = false;
|
||||||
while (segment -> hasNextSegment()) {
|
while (segment -> hasNextSegment()) {
|
||||||
if (hasClickedOn(hover_point, segment -> secondPoint())) {
|
if (hasClickedOn(hover_point, segment -> secondPoint())) {
|
||||||
setCursor(Qt::CrossCursor);
|
setCursor(Qt::ForbiddenCursor);
|
||||||
cursor_set = true;
|
cursor_set = true;
|
||||||
} else if (hasClickedOn(hover_point, segment -> middle())) {
|
} else if (hasClickedOn(hover_point, segment -> middle())) {
|
||||||
setCursor(segment -> isVertical() ? Qt::SplitHCursor : Qt::SplitVCursor);
|
setCursor(segment -> isVertical() ? Qt::SplitHCursor : Qt::SplitVCursor);
|
||||||
@@ -726,7 +727,7 @@ void Conductor::hoverMoveEvent(QGraphicsSceneHoverEvent *e) {
|
|||||||
}
|
}
|
||||||
if (!cursor_set) setCursor(Qt::ArrowCursor);
|
if (!cursor_set) setCursor(Qt::ArrowCursor);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
QGraphicsPathItem::hoverMoveEvent(e);
|
QGraphicsPathItem::hoverMoveEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -951,27 +952,66 @@ bool Conductor::hasClickedOn(QPointF press_point, QPointF point) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Charge les caracteristiques du conducteur depuis un element XML.
|
* @brief Conductor::fromXml
|
||||||
@param e Un element XML
|
* Load the conductor and her information from xml element
|
||||||
@return true si le chargement a reussi, false sinon
|
* @param e
|
||||||
|
* @return true is loading success else return false
|
||||||
*/
|
*/
|
||||||
bool Conductor::fromXml(QDomElement &e) {
|
bool Conductor::fromXml(QDomElement &e) {
|
||||||
// recupere la "configuration" du conducteur
|
setPos(e.attribute("x", 0).toDouble(),
|
||||||
|
e.attribute("y", 0).toDouble());
|
||||||
|
|
||||||
|
bool return_ = pathFromXml(e);
|
||||||
|
|
||||||
|
text_item -> fromXml(e);
|
||||||
properties_. fromXml(e);
|
properties_. fromXml(e);
|
||||||
readProperties();
|
readProperties();
|
||||||
qreal user_pos_x, user_pos_y;
|
|
||||||
if (
|
return return_;
|
||||||
QET::attributeIsAReal(e, "userx", &user_pos_x) &&
|
|
||||||
QET::attributeIsAReal(e, "usery", &user_pos_y)
|
|
||||||
) {
|
|
||||||
text_item -> forceMovedByUser(true);
|
|
||||||
text_item -> setPos(user_pos_x, user_pos_y);
|
|
||||||
}
|
|
||||||
if (e.hasAttribute("rotation")) {
|
|
||||||
text_item -> setRotationAngle(e.attribute("rotation").toDouble());
|
|
||||||
text_item -> forceRotateByUser(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Exporte les caracteristiques du conducteur sous forme d'une element XML.
|
||||||
|
@param d Le document XML a utiliser pour creer l'element XML
|
||||||
|
@param table_adr_id Hash stockant les correspondances entre les ids des
|
||||||
|
bornes dans le document XML et leur adresse en memoire
|
||||||
|
@return Un element XML representant le conducteur
|
||||||
|
*/
|
||||||
|
QDomElement Conductor::toXml(QDomDocument &d, QHash<Terminal *, int> &table_adr_id) const {
|
||||||
|
QDomElement e = d.createElement("conductor");
|
||||||
|
|
||||||
|
e.setAttribute("x", pos().x());
|
||||||
|
e.setAttribute("y", pos().y());
|
||||||
|
e.setAttribute("terminal1", table_adr_id.value(terminal1));
|
||||||
|
e.setAttribute("terminal2", table_adr_id.value(terminal2));
|
||||||
|
|
||||||
|
// on n'exporte les segments du conducteur que si ceux-ci ont
|
||||||
|
// ete modifies par l'utilisateur
|
||||||
|
if (modified_path) {
|
||||||
|
// parcours et export des segments
|
||||||
|
QDomElement current_segment;
|
||||||
|
foreach(ConductorSegment *segment, segmentsList()) {
|
||||||
|
current_segment = d.createElement("segment");
|
||||||
|
current_segment.setAttribute("orientation", segment -> isHorizontal() ? "horizontal" : "vertical");
|
||||||
|
current_segment.setAttribute("length", QString("%1").arg(segment -> length()));
|
||||||
|
e.appendChild(current_segment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Export the properties and text
|
||||||
|
properties_. toXml(e);
|
||||||
|
text_item -> toXml(e);
|
||||||
|
|
||||||
|
return(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Conductor::pathFromXml
|
||||||
|
* Generate the path from xml file
|
||||||
|
* @param e
|
||||||
|
* @return true if generate path success else return false
|
||||||
|
*/
|
||||||
|
bool Conductor::pathFromXml(const QDomElement &e) {
|
||||||
// parcourt les elements XML "segment" et en extrait deux listes de longueurs
|
// parcourt les elements XML "segment" et en extrait deux listes de longueurs
|
||||||
// les segments non valides sont ignores
|
// les segments non valides sont ignores
|
||||||
QList<qreal> segments_x, segments_y;
|
QList<qreal> segments_x, segments_y;
|
||||||
@@ -997,8 +1037,12 @@ bool Conductor::fromXml(QDomElement &e) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// s'il n'y a pas de segments, on renvoie true
|
//If there isn't segment we generate automatic path and return true
|
||||||
if (!segments_x.size()) return(true);
|
if (!segments_x.size()) {
|
||||||
|
generateConductorPath(terminal1 -> dockConductor(), terminal1 -> orientation(), terminal2 -> dockConductor(), terminal2 -> orientation());
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
// les longueurs recueillies doivent etre coherentes avec les positions des bornes
|
// les longueurs recueillies doivent etre coherentes avec les positions des bornes
|
||||||
qreal width = 0.0, height = 0.0;
|
qreal width = 0.0, height = 0.0;
|
||||||
foreach (qreal t, segments_x) width += t;
|
foreach (qreal t, segments_x) width += t;
|
||||||
@@ -1020,7 +1064,7 @@ bool Conductor::fromXml(QDomElement &e) {
|
|||||||
/* on recree les segments a partir des donnes XML */
|
/* on recree les segments a partir des donnes XML */
|
||||||
// cree la liste de points
|
// cree la liste de points
|
||||||
QList<QPointF> points_list;
|
QList<QPointF> points_list;
|
||||||
points_list << t1;
|
points_list << mapFromScene(t1);
|
||||||
for (int i = 0 ; i < segments_x.size() ; ++ i) {
|
for (int i = 0 ; i < segments_x.size() ; ++ i) {
|
||||||
points_list << QPointF(
|
points_list << QPointF(
|
||||||
points_list.last().x() + segments_x.at(i),
|
points_list.last().x() + segments_x.at(i),
|
||||||
@@ -1038,43 +1082,6 @@ bool Conductor::fromXml(QDomElement &e) {
|
|||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Exporte les caracteristiques du conducteur sous forme d'une element XML.
|
|
||||||
@param d Le document XML a utiliser pour creer l'element XML
|
|
||||||
@param table_adr_id Hash stockant les correspondances entre les ids des
|
|
||||||
bornes dans le document XML et leur adresse en memoire
|
|
||||||
@return Un element XML representant le conducteur
|
|
||||||
*/
|
|
||||||
QDomElement Conductor::toXml(QDomDocument &d, QHash<Terminal *, int> &table_adr_id) const {
|
|
||||||
QDomElement e = d.createElement("conductor");
|
|
||||||
e.setAttribute("terminal1", table_adr_id.value(terminal1));
|
|
||||||
e.setAttribute("terminal2", table_adr_id.value(terminal2));
|
|
||||||
|
|
||||||
// on n'exporte les segments du conducteur que si ceux-ci ont
|
|
||||||
// ete modifies par l'utilisateur
|
|
||||||
if (modified_path) {
|
|
||||||
// parcours et export des segments
|
|
||||||
QDomElement current_segment;
|
|
||||||
foreach(ConductorSegment *segment, segmentsList()) {
|
|
||||||
current_segment = d.createElement("segment");
|
|
||||||
current_segment.setAttribute("orientation", segment -> isHorizontal() ? "horizontal" : "vertical");
|
|
||||||
current_segment.setAttribute("length", QString("%1").arg(segment -> length()));
|
|
||||||
e.appendChild(current_segment);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// exporte la "configuration" du conducteur
|
|
||||||
properties_.toXml(e);
|
|
||||||
if (text_item -> wasRotateByUser()) {
|
|
||||||
e.setAttribute("rotation", QString("%1").arg(text_item -> rotationAngle()));
|
|
||||||
}
|
|
||||||
if (text_item -> wasMovedByUser()) {
|
|
||||||
e.setAttribute("userx", QString("%1").arg(text_item -> pos().x()));
|
|
||||||
e.setAttribute("usery", QString("%1").arg(text_item -> pos().y()));
|
|
||||||
}
|
|
||||||
return(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @return les segments de ce conducteur
|
/// @return les segments de ce conducteur
|
||||||
const QList<ConductorSegment *> Conductor::segmentsList() const {
|
const QList<ConductorSegment *> Conductor::segmentsList() const {
|
||||||
if (segments == NULL) return(QList<ConductorSegment *>());
|
if (segments == NULL) return(QList<ConductorSegment *>());
|
||||||
@@ -1328,9 +1335,12 @@ void Conductor::setText(const QString &t) {
|
|||||||
* @param p : properties
|
* @param p : properties
|
||||||
*/
|
*/
|
||||||
void Conductor::setProperties(const ConductorProperties &p) {
|
void Conductor::setProperties(const ConductorProperties &p) {
|
||||||
|
if (properties_ != p)
|
||||||
|
{
|
||||||
properties_ = p;
|
properties_ = p;
|
||||||
readProperties();
|
readProperties();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Conductor::properties
|
* @brief Conductor::properties
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class Conductor : public QObject, public QGraphicsPathItem {
|
|||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
Conductor(Terminal *, Terminal *, Diagram * = 0);
|
Conductor(Terminal *, Terminal *);
|
||||||
virtual ~Conductor();
|
virtual ~Conductor();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -92,9 +92,15 @@ class Conductor : public QObject, public QGraphicsPathItem {
|
|||||||
bool containsPoint(const QPointF &) const;
|
bool containsPoint(const QPointF &) const;
|
||||||
QString text() const;
|
QString text() const;
|
||||||
void setText(const QString &);
|
void setText(const QString &);
|
||||||
|
|
||||||
|
public:
|
||||||
static bool valideXml (QDomElement &);
|
static bool valideXml (QDomElement &);
|
||||||
bool fromXml (QDomElement &);
|
bool fromXml (QDomElement &);
|
||||||
QDomElement toXml (QDomDocument &, QHash<Terminal *, int> &) const;
|
QDomElement toXml (QDomDocument &, QHash<Terminal *, int> &) const;
|
||||||
|
private:
|
||||||
|
bool pathFromXml(const QDomElement &);
|
||||||
|
|
||||||
|
public:
|
||||||
const QList<ConductorSegment *> segmentsList() const;
|
const QList<ConductorSegment *> segmentsList() const;
|
||||||
void setProperties(const ConductorProperties &);
|
void setProperties(const ConductorProperties &);
|
||||||
ConductorProperties properties() const;
|
ConductorProperties properties() const;
|
||||||
@@ -124,6 +130,8 @@ class Conductor : public QObject, public QGraphicsPathItem {
|
|||||||
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *);
|
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *);
|
||||||
virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
|
virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
|
||||||
|
|
||||||
|
bool bMouseOver;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Functional properties
|
/// Functional properties
|
||||||
ConductorProperties properties_;
|
ConductorProperties properties_;
|
||||||
|
|||||||
@@ -25,12 +25,14 @@
|
|||||||
@param parent_conductor Conducteur auquel ce texte est rattache
|
@param parent_conductor Conducteur auquel ce texte est rattache
|
||||||
@param parent_diagram Schema auquel ce texte et son conducteur parent sont rattaches
|
@param parent_diagram Schema auquel ce texte et son conducteur parent sont rattaches
|
||||||
*/
|
*/
|
||||||
ConductorTextItem::ConductorTextItem(Conductor *parent_conductor, Diagram *parent_diagram) :
|
ConductorTextItem::ConductorTextItem(Conductor *parent_conductor) :
|
||||||
DiagramTextItem(parent_conductor, parent_diagram),
|
DiagramTextItem(parent_conductor),
|
||||||
parent_conductor_(parent_conductor),
|
parent_conductor_(parent_conductor),
|
||||||
moved_by_user_(false),
|
moved_by_user_(false),
|
||||||
rotate_by_user_(false)
|
rotate_by_user_(false)
|
||||||
{}
|
{
|
||||||
|
setAcceptsHoverEvents(true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
@@ -38,8 +40,8 @@ ConductorTextItem::ConductorTextItem(Conductor *parent_conductor, Diagram *paren
|
|||||||
@param parent_conductor Conducteur auquel ce texte est rattache
|
@param parent_conductor Conducteur auquel ce texte est rattache
|
||||||
@param parent_diagram Schema auquel ce texte et son conducteur parent sont rattaches
|
@param parent_diagram Schema auquel ce texte et son conducteur parent sont rattaches
|
||||||
*/
|
*/
|
||||||
ConductorTextItem::ConductorTextItem(const QString &text, Conductor *parent_conductor, Diagram *parent_diagram) :
|
ConductorTextItem::ConductorTextItem(const QString &text, Conductor *parent_conductor) :
|
||||||
DiagramTextItem(text, parent_conductor, parent_diagram),
|
DiagramTextItem(text, parent_conductor),
|
||||||
parent_conductor_(parent_conductor),
|
parent_conductor_(parent_conductor),
|
||||||
moved_by_user_(false),
|
moved_by_user_(false),
|
||||||
rotate_by_user_(false)
|
rotate_by_user_(false)
|
||||||
@@ -60,38 +62,36 @@ Conductor *ConductorTextItem::parentConductor() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Permet de lire le texte a mettre dans le champ a partir d'un element XML.
|
* @brief ConductorTextItem::fromXml
|
||||||
Cette methode se base sur la position du champ pour assigner ou non la
|
* Read the properties stored in the xml element given in parameter
|
||||||
valeur a ce champ.
|
* @param e
|
||||||
@param e L'element XML representant le champ de texte
|
|
||||||
*/
|
*/
|
||||||
void ConductorTextItem::fromXml(const QDomElement &e) {
|
void ConductorTextItem::fromXml(const QDomElement &e) {
|
||||||
setPlainText(e.attribute("text"));
|
if (e.hasAttribute("userx")) {
|
||||||
|
setPos(e.attribute("userx").toDouble(),
|
||||||
qreal user_pos_x, user_pos_y;
|
e.attribute("usery").toDouble());
|
||||||
if (
|
moved_by_user_ = true;
|
||||||
QET::attributeIsAReal(e, "userx", &user_pos_x) &&
|
}
|
||||||
QET::attributeIsAReal(e, "usery", &user_pos_y)
|
if (e.hasAttribute("rotation")) {
|
||||||
) {
|
setRotation(e.attribute("rotation").toDouble());
|
||||||
setPos(user_pos_x, user_pos_y);
|
rotate_by_user_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
setRotationAngle(e.attribute("rotation").toDouble());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param document Le document XML a utiliser
|
* @brief ConductorTextItem::toXml
|
||||||
@return L'element XML representant ce champ de texte
|
* Export the properties of this text in the attribute of the xml element given in parameter
|
||||||
|
* The properties exported are position and rotation (only if moved or rotate by user)
|
||||||
|
* @param xml
|
||||||
*/
|
*/
|
||||||
QDomElement ConductorTextItem::toXml(QDomDocument &document) const {
|
void ConductorTextItem::toXml(QDomElement &xml) const {
|
||||||
QDomElement result = document.createElement("input");
|
if (moved_by_user_) {
|
||||||
result.setAttribute("userx", QString("%1").arg(pos().x()));
|
xml.setAttribute("userx", QString("%1").arg(pos().x()));
|
||||||
result.setAttribute("usery", QString("%1").arg(pos().y()));
|
xml.setAttribute("usery", QString("%1").arg(pos().y()));
|
||||||
result.setAttribute("text", toPlainText());
|
}
|
||||||
if (rotationAngle()) {
|
if (rotate_by_user_) {
|
||||||
result.setAttribute("rotation", QString("%1").arg(rotationAngle()));
|
xml.setAttribute("rotation", QString("%1").arg(rotation()));
|
||||||
}
|
}
|
||||||
return(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -203,3 +203,40 @@ void ConductorTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
QGraphicsTextItem::mouseReleaseEvent(e);
|
QGraphicsTextItem::mouseReleaseEvent(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
When mouse over element
|
||||||
|
change bMouseOver to true (used in paint() function )
|
||||||
|
@param e QGraphicsSceneHoverEvent
|
||||||
|
*/
|
||||||
|
void ConductorTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *e) {
|
||||||
|
Q_UNUSED(e);
|
||||||
|
|
||||||
|
bMouseOver = true;
|
||||||
|
QString str_ToolTip = toPlainText();
|
||||||
|
setToolTip( str_ToolTip );
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
When mouse over element leave the position
|
||||||
|
change bMouseOver to false(used in paint() function )
|
||||||
|
@param e QGraphicsSceneHoverEvent
|
||||||
|
*/
|
||||||
|
void ConductorTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *e) {
|
||||||
|
Q_UNUSED(e);
|
||||||
|
//qDebug() << "Leave mouse over";
|
||||||
|
bMouseOver = false;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Do nothing default function .
|
||||||
|
@param e QGraphicsSceneHoverEvent
|
||||||
|
*/
|
||||||
|
void ConductorTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *e) {
|
||||||
|
Q_UNUSED(e);
|
||||||
|
QGraphicsTextItem::hoverMoveEvent(e);
|
||||||
|
}
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ class ConductorTextItem : public DiagramTextItem {
|
|||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
ConductorTextItem(Conductor * = 0, Diagram * = 0);
|
ConductorTextItem(Conductor * = 0);
|
||||||
ConductorTextItem(const QString &, Conductor * = 0, Diagram * = 0);
|
ConductorTextItem(const QString &, Conductor * = 0);
|
||||||
virtual ~ConductorTextItem();
|
virtual ~ConductorTextItem();
|
||||||
private:
|
private:
|
||||||
ConductorTextItem(const ConductorTextItem &);
|
ConductorTextItem(const ConductorTextItem &);
|
||||||
@@ -42,7 +42,7 @@ class ConductorTextItem : public DiagramTextItem {
|
|||||||
enum { Type = UserType + 1006 };
|
enum { Type = UserType + 1006 };
|
||||||
Conductor *parentConductor() const;
|
Conductor *parentConductor() const;
|
||||||
virtual void fromXml(const QDomElement &);
|
virtual void fromXml(const QDomElement &);
|
||||||
virtual QDomElement toXml(QDomDocument &) const;
|
virtual void toXml (QDomElement &xml) const;
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
@@ -57,6 +57,11 @@ class ConductorTextItem : public DiagramTextItem {
|
|||||||
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *event);
|
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *event);
|
||||||
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *event);
|
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *);
|
||||||
|
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *);
|
||||||
|
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *);
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
Conductor *parent_conductor_;
|
Conductor *parent_conductor_;
|
||||||
|
|||||||
@@ -32,14 +32,20 @@
|
|||||||
* @brief CrossRefItem::CrossRefItem
|
* @brief CrossRefItem::CrossRefItem
|
||||||
* Default constructor
|
* Default constructor
|
||||||
* @param elmt element to display the cross ref and also parent item.
|
* @param elmt element to display the cross ref and also parent item.
|
||||||
|
* elmt must be in a diagram
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @brief CrossRefItem::CrossRefItem
|
||||||
|
* @param elmt
|
||||||
*/
|
*/
|
||||||
CrossRefItem::CrossRefItem(Element *elmt) :
|
CrossRefItem::CrossRefItem(Element *elmt) :
|
||||||
QGraphicsObject(elmt),
|
QGraphicsObject(elmt),
|
||||||
m_element (elmt)
|
m_element (elmt)
|
||||||
{
|
{
|
||||||
|
Q_ASSERT_X(elmt->diagram(), "CrossRefItem constructor", "Parent element is not in a diagram");
|
||||||
|
|
||||||
m_properties = elmt->diagram()->defaultXRefProperties(elmt->kindInformations()["type"].toString());
|
m_properties = elmt->diagram()->defaultXRefProperties(elmt->kindInformations()["type"].toString());
|
||||||
|
|
||||||
connect(elmt, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
|
|
||||||
connect(elmt -> diagram() -> project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
|
connect(elmt -> diagram() -> project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
|
||||||
connect(elmt -> diagram() -> project(), SIGNAL(diagramRemoved(QETProject*,Diagram*)), this, SLOT(updateLabel()));
|
connect(elmt -> diagram() -> project(), SIGNAL(diagramRemoved(QETProject*,Diagram*)), this, SLOT(updateLabel()));
|
||||||
connect(elmt -> diagram(), SIGNAL(XRefPropertiesChanged()), this, SLOT(updateProperties()));
|
connect(elmt -> diagram(), SIGNAL(XRefPropertiesChanged()), this, SLOT(updateProperties()));
|
||||||
@@ -106,6 +112,13 @@ QString CrossRefItem::elementPositionText(const Element *elmt, const bool &add_p
|
|||||||
void CrossRefItem::allElementsPositionText(QString &no_str, QString &nc_str, const bool &add_prefix) const {
|
void CrossRefItem::allElementsPositionText(QString &no_str, QString &nc_str, const bool &add_prefix) const {
|
||||||
QString *tmp_str;
|
QString *tmp_str;
|
||||||
foreach (Element *elmt, m_element->linkedElements()) {
|
foreach (Element *elmt, m_element->linkedElements()) {
|
||||||
|
//We continue if element is a power contact and xref propertie
|
||||||
|
//is set to don't show power contact
|
||||||
|
if (m_properties.displayHas() == XRefProperties::Cross &&
|
||||||
|
!m_properties.showPowerContact() &&
|
||||||
|
elmt -> kindInformations()["type"].toString() == "power")
|
||||||
|
continue;
|
||||||
|
|
||||||
QString state = elmt->kindInformations()["state"].toString();
|
QString state = elmt->kindInformations()["state"].toString();
|
||||||
|
|
||||||
//NO and NC are displayed in single place in the cross
|
//NO and NC are displayed in single place in the cross
|
||||||
@@ -159,6 +172,7 @@ void CrossRefItem::updateProperties() {
|
|||||||
void CrossRefItem::updateLabel() {
|
void CrossRefItem::updateLabel() {
|
||||||
//init the shape and bounding rect
|
//init the shape and bounding rect
|
||||||
m_shape_path = QPainterPath();
|
m_shape_path = QPainterPath();
|
||||||
|
prepareGeometryChange();
|
||||||
m_bounding_rect = QRectF();
|
m_bounding_rect = QRectF();
|
||||||
|
|
||||||
//init the painter
|
//init the painter
|
||||||
@@ -183,8 +197,6 @@ void CrossRefItem::updateLabel() {
|
|||||||
qp.end();
|
qp.end();
|
||||||
|
|
||||||
autoPos();
|
autoPos();
|
||||||
update();
|
|
||||||
checkMustShow();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -274,18 +286,23 @@ void CrossRefItem::buildHeaderContact() {
|
|||||||
* The cross ref item is drawing according to the size of the cross bounding rect.
|
* The cross ref item is drawing according to the size of the cross bounding rect.
|
||||||
*/
|
*/
|
||||||
void CrossRefItem::setUpCrossBoundingRect(QPainter &painter) {
|
void CrossRefItem::setUpCrossBoundingRect(QPainter &painter) {
|
||||||
//this is the default size of cross ref item
|
|
||||||
QRectF default_bounding(0, 0, 40, header + cross_min_heigth);
|
|
||||||
|
|
||||||
//No need to calcul if nothing is linked
|
//No need to calcul if nothing is linked
|
||||||
if (!m_element->isFree()) {
|
if (!m_element->isFree()) {
|
||||||
|
|
||||||
QString no_str, nc_str;
|
QString no_str, nc_str;
|
||||||
allElementsPositionText(no_str, nc_str, true);
|
allElementsPositionText(no_str, nc_str, true);
|
||||||
|
|
||||||
//Adjust the size of default_bounding if needed.
|
//There is no string to display, we return now
|
||||||
//We calcule the size by using a single text
|
if (no_str.isEmpty() && nc_str.isEmpty()) return;
|
||||||
//because in the method fillCrossRef, the text is draw like this (aka single text)
|
|
||||||
|
//this is the default size of cross ref item
|
||||||
|
QRectF default_bounding(0, 0, 40, header + cross_min_heigth);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Adjust the size of default_bounding if needed.
|
||||||
|
* We calcule the size by using a single text
|
||||||
|
* because in the method fillCrossRef, the text is draw like this (aka single text)
|
||||||
|
*/
|
||||||
|
|
||||||
//Adjust according to the NO
|
//Adjust according to the NO
|
||||||
QRectF bounding = painter.boundingRect(QRectF (), Qt::AlignCenter, no_str);
|
QRectF bounding = painter.boundingRect(QRectF (), Qt::AlignCenter, no_str);
|
||||||
@@ -300,11 +317,12 @@ void CrossRefItem::setUpCrossBoundingRect(QPainter &painter) {
|
|||||||
default_bounding.setHeight(bounding.height() + header); //adjust the heigth
|
default_bounding.setHeight(bounding.height() + header); //adjust the heigth
|
||||||
if (bounding.width() > default_bounding.width()/2)
|
if (bounding.width() > default_bounding.width()/2)
|
||||||
default_bounding.setWidth(bounding.width()*2); //adjust the width
|
default_bounding.setWidth(bounding.width()*2); //adjust the width
|
||||||
}
|
|
||||||
|
|
||||||
m_shape_path.addRect(default_bounding);
|
m_shape_path.addRect(default_bounding);
|
||||||
|
prepareGeometryChange();
|
||||||
m_bounding_rect = default_bounding;
|
m_bounding_rect = default_bounding;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CrossRefItem::drawHasCross
|
* @brief CrossRefItem::drawHasCross
|
||||||
@@ -315,6 +333,9 @@ void CrossRefItem::drawHasCross(QPainter &painter) {
|
|||||||
//calcul the size of the cross
|
//calcul the size of the cross
|
||||||
setUpCrossBoundingRect(painter);
|
setUpCrossBoundingRect(painter);
|
||||||
|
|
||||||
|
//Bounding rect is empty that mean there's no contact to draw
|
||||||
|
if (boundingRect().isEmpty()) return;
|
||||||
|
|
||||||
//draw the cross
|
//draw the cross
|
||||||
QRectF br = boundingRect();
|
QRectF br = boundingRect();
|
||||||
painter.drawLine(br.width()/2, 0, br.width()/2, br.height()); //vertical line
|
painter.drawLine(br.width()/2, 0, br.width()/2, br.height()); //vertical line
|
||||||
@@ -337,6 +358,8 @@ void CrossRefItem::drawHasCross(QPainter &painter) {
|
|||||||
* @param painter painter to use
|
* @param painter painter to use
|
||||||
*/
|
*/
|
||||||
void CrossRefItem::drawHasContacts(QPainter &painter) {
|
void CrossRefItem::drawHasContacts(QPainter &painter) {
|
||||||
|
if (m_element -> isFree()) return;
|
||||||
|
|
||||||
m_drawed_contacts = 0;
|
m_drawed_contacts = 0;
|
||||||
|
|
||||||
//Draw each linked contact
|
//Draw each linked contact
|
||||||
@@ -361,6 +384,7 @@ void CrossRefItem::drawHasContacts(QPainter &painter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QRectF br(0, 0, 50, m_drawed_contacts*10+4);
|
QRectF br(0, 0, 50, m_drawed_contacts*10+4);
|
||||||
|
prepareGeometryChange();
|
||||||
m_bounding_rect = br;
|
m_bounding_rect = br;
|
||||||
m_shape_path.addRect(br);
|
m_shape_path.addRect(br);
|
||||||
}
|
}
|
||||||
@@ -492,8 +516,6 @@ void CrossRefItem::fillCrossRef(QPainter &painter) {
|
|||||||
|
|
||||||
rect_.moveTopLeft(QPointF (middle_cross, header));
|
rect_.moveTopLeft(QPointF (middle_cross, header));
|
||||||
painter.drawText(rect_, Qt::AlignTop | Qt::AlignRight, nc_str);
|
painter.drawText(rect_, Qt::AlignTop | Qt::AlignRight, nc_str);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -504,62 +526,27 @@ void CrossRefItem::fillCrossRef(QPainter &painter) {
|
|||||||
void CrossRefItem::AddExtraInfo(QPainter &painter) {
|
void CrossRefItem::AddExtraInfo(QPainter &painter) {
|
||||||
QString comment = m_element -> elementInformations()["comment"].toString();
|
QString comment = m_element -> elementInformations()["comment"].toString();
|
||||||
bool must_show = m_element -> elementInformations().keyMustShow("comment");
|
bool must_show = m_element -> elementInformations().keyMustShow("comment");
|
||||||
|
|
||||||
if (!comment.isEmpty() && must_show) {
|
if (!comment.isEmpty() && must_show) {
|
||||||
painter.save();
|
painter.save();
|
||||||
painter.setFont(QETApp::diagramTextsFont(6));
|
painter.setFont(QETApp::diagramTextsFont(6));
|
||||||
|
|
||||||
QRectF r, text_bounding;
|
QRectF r, text_bounding;
|
||||||
qreal center = boundingRect().center().x();
|
qreal center = boundingRect().center().x();
|
||||||
r = QRectF(QPointF(center - 50, boundingRect().bottom()),
|
r = QRectF(QPointF(center - 35, boundingRect().bottom()),
|
||||||
QPointF(center + 50, boundingRect().bottom() + 50));
|
QPointF(center + 35, boundingRect().bottom() + 50));
|
||||||
painter.drawText(r, Qt::TextWordWrap | Qt::AlignHCenter, comment, &text_bounding);
|
painter.drawText(r, Qt::TextWordWrap | Qt::AlignHCenter, comment, &text_bounding);
|
||||||
|
|
||||||
text_bounding.adjust(-1,0,1,0); //adjust only for better visual
|
text_bounding.adjust(-1,0,1,0); //adjust only for better visual
|
||||||
|
|
||||||
m_shape_path.addRect(text_bounding);
|
m_shape_path.addRect(text_bounding);
|
||||||
|
prepareGeometryChange();
|
||||||
m_bounding_rect = m_bounding_rect.united(text_bounding);
|
m_bounding_rect = m_bounding_rect.united(text_bounding);
|
||||||
painter.drawRoundedRect(text_bounding, 2, 2);
|
painter.drawRoundedRect(text_bounding, 2, 2);
|
||||||
painter.restore();
|
painter.restore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief CrossRefItem::checkMustShow
|
|
||||||
* Check the propertie of this Xref for know if we
|
|
||||||
* must to be show or not
|
|
||||||
*/
|
|
||||||
void CrossRefItem::checkMustShow() {
|
|
||||||
//We always show Xref when is displayed has contact
|
|
||||||
if (m_properties.displayHas() == XRefProperties::Contacts) {
|
|
||||||
this->show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//if Xref is display has cross and we must to don't show power contact, check it
|
|
||||||
else if (m_properties.displayHas() == XRefProperties::Cross && !m_properties.showPowerContact()) {
|
|
||||||
bool power = false;
|
|
||||||
foreach (Element *elmt, m_element->linkedElements()) {
|
|
||||||
// contact checked isn't power, show this xref and return;
|
|
||||||
if (elmt->kindInformations()["type"].toString() != "power") {
|
|
||||||
this->show();
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
power = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (power) {
|
|
||||||
this->hide();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//By default, show this Xref
|
|
||||||
else {
|
|
||||||
this->show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CrossRefItem::setTextParent
|
* @brief CrossRefItem::setTextParent
|
||||||
* Set the text field tagged "label" of m_element
|
* Set the text field tagged "label" of m_element
|
||||||
@@ -568,6 +555,6 @@ void CrossRefItem::checkMustShow() {
|
|||||||
void CrossRefItem::setTextParent() {
|
void CrossRefItem::setTextParent() {
|
||||||
ElementTextItem *eti = m_element->taggedText("label");
|
ElementTextItem *eti = m_element->taggedText("label");
|
||||||
if (eti) setParentItem(eti);
|
if (eti) setParentItem(eti);
|
||||||
else qDebug() << "CrossRefItem,no texte tagged 'label' found to set has parent";
|
else qDebug() << "CrossRefItem,no text tagged 'label' found to set has parent";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,6 @@ class CrossRefItem : public QGraphicsObject
|
|||||||
void drawContact (QPainter &painter, int flags, QString str = QString());
|
void drawContact (QPainter &painter, int flags, QString str = QString());
|
||||||
void fillCrossRef (QPainter &painter);
|
void fillCrossRef (QPainter &painter);
|
||||||
void AddExtraInfo (QPainter &painter);
|
void AddExtraInfo (QPainter &painter);
|
||||||
void checkMustShow ();
|
|
||||||
void setTextParent ();
|
void setTextParent ();
|
||||||
|
|
||||||
//Attributes
|
//Attributes
|
||||||
|
|||||||
@@ -44,8 +44,8 @@
|
|||||||
- 7 : L'analyse d'un element XML decrivant une partie du dessin de l'element a echoue
|
- 7 : L'analyse d'un element XML decrivant une partie du dessin de l'element a echoue
|
||||||
- 8 : Aucune partie du dessin n'a pu etre chargee
|
- 8 : Aucune partie du dessin n'a pu etre chargee
|
||||||
*/
|
*/
|
||||||
CustomElement::CustomElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) :
|
CustomElement::CustomElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state) :
|
||||||
FixedElement(qgi, s),
|
FixedElement(qgi),
|
||||||
elmt_state(-1),
|
elmt_state(-1),
|
||||||
location_(location),
|
location_(location),
|
||||||
forbid_antialiasing(false)
|
forbid_antialiasing(false)
|
||||||
@@ -137,13 +137,12 @@ bool CustomElement::buildFromXml(const QDomElement &xml_def_elmt, int *state) {
|
|||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// on peut d'ores et deja specifier la taille et le hotspot
|
|
||||||
setSize(w, h);
|
setSize(w, h);
|
||||||
setHotspot(QPoint(hot_x, hot_y));
|
setHotspot(QPoint(hot_x, hot_y));
|
||||||
setInternalConnections(xml_def_elmt.attribute("ic") == "true");
|
|
||||||
|
|
||||||
// la definition est supposee avoir des enfants
|
//the definition must have childs
|
||||||
if (xml_def_elmt.firstChild().isNull()) {
|
if (xml_def_elmt.firstChild().isNull())
|
||||||
|
{
|
||||||
if (state) *state = 6;
|
if (state) *state = 6;
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
@@ -759,7 +758,7 @@ Terminal *CustomElement::parseTerminal(QDomElement &e) {
|
|||||||
else if (e.attribute("orientation") == "e") terminalo = Qet::East;
|
else if (e.attribute("orientation") == "e") terminalo = Qet::East;
|
||||||
else if (e.attribute("orientation") == "w") terminalo = Qet::West;
|
else if (e.attribute("orientation") == "w") terminalo = Qet::West;
|
||||||
else return(0);
|
else return(0);
|
||||||
Terminal *new_terminal = new Terminal(terminalx, terminaly, terminalo, this, qobject_cast<Diagram *>(scene()));
|
Terminal *new_terminal = new Terminal(terminalx, terminaly, terminalo, this);
|
||||||
new_terminal -> setZValue(420); // valeur arbitraire pour maintenir les bornes au-dessus des champs de texte
|
new_terminal -> setZValue(420); // valeur arbitraire pour maintenir les bornes au-dessus des champs de texte
|
||||||
list_terminals << new_terminal;
|
list_terminals << new_terminal;
|
||||||
return(new_terminal);
|
return(new_terminal);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class CustomElement : public FixedElement {
|
|||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
CustomElement(const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0, int * = 0);
|
CustomElement(const ElementsLocation &, QGraphicsItem * = 0, int * = 0);
|
||||||
virtual ~CustomElement();
|
virtual ~CustomElement();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -211,6 +211,7 @@ bool DiagramImageItem::fromXml(const QDomElement &e) {
|
|||||||
setScale(e.attribute("size").toDouble());
|
setScale(e.attribute("size").toDouble());
|
||||||
applyRotation(e.attribute("rotation").toDouble());
|
applyRotation(e.attribute("rotation").toDouble());
|
||||||
setPos(e.attribute("x").toDouble(), e.attribute("y").toDouble());
|
setPos(e.attribute("x").toDouble(), e.attribute("y").toDouble());
|
||||||
|
is_movable_ = (e.attribute("is_movable").toInt());
|
||||||
|
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
@@ -226,6 +227,7 @@ QDomElement DiagramImageItem::toXml(QDomDocument &document) const {
|
|||||||
result.setAttribute("y", QString("%1").arg(pos().y()));
|
result.setAttribute("y", QString("%1").arg(pos().y()));
|
||||||
result.setAttribute("rotation", QString("%1").arg(rotation()));
|
result.setAttribute("rotation", QString("%1").arg(rotation()));
|
||||||
result.setAttribute("size", QString("%1").arg(scale()));
|
result.setAttribute("size", QString("%1").arg(scale()));
|
||||||
|
result.setAttribute("is_movable", bool(is_movable_));
|
||||||
|
|
||||||
//write the pixmap in the xml element after he was been transformed to base64
|
//write the pixmap in the xml element after he was been transformed to base64
|
||||||
QByteArray array;
|
QByteArray array;
|
||||||
|
|||||||
@@ -26,12 +26,14 @@
|
|||||||
@param parent Le QGraphicsItem parent du champ de texte
|
@param parent Le QGraphicsItem parent du champ de texte
|
||||||
@param parent_diagram Le schema auquel appartient le champ de texte
|
@param parent_diagram Le schema auquel appartient le champ de texte
|
||||||
*/
|
*/
|
||||||
DiagramTextItem::DiagramTextItem(QGraphicsItem *parent, Diagram *parent_diagram) :
|
DiagramTextItem::DiagramTextItem(QGraphicsItem *parent) :
|
||||||
QGraphicsTextItem(parent, parent_diagram),
|
QGraphicsTextItem(parent),
|
||||||
|
bMouseOver(false),
|
||||||
previous_text_(),
|
previous_text_(),
|
||||||
rotation_angle_(0.0),
|
rotation_angle_(0.0),
|
||||||
m_first_move (true)
|
m_first_move (true)
|
||||||
{
|
{
|
||||||
|
setAcceptsHoverEvents(true);
|
||||||
build();
|
build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,12 +43,14 @@ DiagramTextItem::DiagramTextItem(QGraphicsItem *parent, Diagram *parent_diagram)
|
|||||||
@param parent Le QGraphicsItem parent du champ de texte
|
@param parent Le QGraphicsItem parent du champ de texte
|
||||||
@param parent_diagram Le schema auquel appartient le champ de texte
|
@param parent_diagram Le schema auquel appartient le champ de texte
|
||||||
*/
|
*/
|
||||||
DiagramTextItem::DiagramTextItem(const QString &text, QGraphicsItem *parent, Diagram *parent_diagram) :
|
DiagramTextItem::DiagramTextItem(const QString &text, QGraphicsItem *parent) :
|
||||||
QGraphicsTextItem(text, parent, parent_diagram),
|
QGraphicsTextItem(text, parent),
|
||||||
|
bMouseOver(false),
|
||||||
previous_text_(text),
|
previous_text_(text),
|
||||||
rotation_angle_(0.0)
|
rotation_angle_(0.0)
|
||||||
{
|
{
|
||||||
build();
|
build();
|
||||||
|
setAcceptsHoverEvents(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Destructeur
|
/// Destructeur
|
||||||
@@ -79,6 +83,16 @@ Diagram *DiagramTextItem::diagram() const {
|
|||||||
return(qobject_cast<Diagram *>(scene()));
|
return(qobject_cast<Diagram *>(scene()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief DiagramTextItem::toXml
|
||||||
|
* This method do nothing and return an empty DomElement
|
||||||
|
* This is used to be inherited by child class
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
QDomElement DiagramTextItem::toXml(QDomDocument &) const {
|
||||||
|
return QDomElement();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return l'angle de rotation actuel de ce texte
|
@return l'angle de rotation actuel de ce texte
|
||||||
*/
|
*/
|
||||||
@@ -201,6 +215,24 @@ void DiagramTextItem::setFontSize(int &s) {
|
|||||||
void DiagramTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
|
void DiagramTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
|
||||||
painter -> setRenderHint(QPainter::Antialiasing, false);
|
painter -> setRenderHint(QPainter::Antialiasing, false);
|
||||||
QGraphicsTextItem::paint(painter, option, widget);
|
QGraphicsTextItem::paint(painter, option, widget);
|
||||||
|
|
||||||
|
if ( bMouseOver ) {
|
||||||
|
painter -> save();
|
||||||
|
// Annulation des renderhints
|
||||||
|
painter -> setRenderHint(QPainter::Antialiasing, false);
|
||||||
|
painter -> setRenderHint(QPainter::TextAntialiasing, false);
|
||||||
|
painter -> setRenderHint(QPainter::SmoothPixmapTransform, false);
|
||||||
|
// Dessin du cadre de selection en gris
|
||||||
|
QPen t;
|
||||||
|
t.setColor(Qt::gray);
|
||||||
|
t.setStyle(Qt::DashDotLine);
|
||||||
|
painter -> setPen(t);
|
||||||
|
// Le dessin se fait a partir du rectangle delimitant
|
||||||
|
//painter -> drawRoundRect(boundingRect().adjusted(1, 1, -1, -1), 10, 10);
|
||||||
|
painter -> drawRoundRect(boundingRect().adjusted(0, 0, 0, 0), 10, 10);
|
||||||
|
painter -> restore();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -356,3 +388,39 @@ void DiagramTextItem::edit() {
|
|||||||
editor->show();
|
editor->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
When mouse over element
|
||||||
|
change bMouseOver to true (used in paint() function )
|
||||||
|
@param e QGraphicsSceneHoverEvent
|
||||||
|
*/
|
||||||
|
void DiagramTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *e) {
|
||||||
|
Q_UNUSED(e);
|
||||||
|
|
||||||
|
bMouseOver = true;
|
||||||
|
QString str_ToolTip = toPlainText();
|
||||||
|
setToolTip( str_ToolTip );
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
When mouse over element leave the position
|
||||||
|
change bMouseOver to false (used in paint() function )
|
||||||
|
@param e QGraphicsSceneHoverEvent
|
||||||
|
*/
|
||||||
|
void DiagramTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *e) {
|
||||||
|
Q_UNUSED(e);
|
||||||
|
//qDebug() << "Leave mouse over";
|
||||||
|
bMouseOver = false;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Do nothing default function .
|
||||||
|
@param e QGraphicsSceneHoverEvent
|
||||||
|
*/
|
||||||
|
void DiagramTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *e) {
|
||||||
|
Q_UNUSED(e);
|
||||||
|
QGraphicsTextItem::hoverMoveEvent(e);
|
||||||
|
}
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ class DiagramTextItem : public QGraphicsTextItem {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
DiagramTextItem(QGraphicsItem * = 0, Diagram * = 0);
|
DiagramTextItem(QGraphicsItem * = 0);
|
||||||
DiagramTextItem(const QString &, QGraphicsItem * = 0, Diagram * = 0);
|
DiagramTextItem(const QString &, QGraphicsItem * = 0);
|
||||||
virtual ~DiagramTextItem();
|
virtual ~DiagramTextItem();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -54,7 +54,7 @@ class DiagramTextItem : public QGraphicsTextItem {
|
|||||||
virtual int type() const { return Type; }
|
virtual int type() const { return Type; }
|
||||||
Diagram *diagram() const;
|
Diagram *diagram() const;
|
||||||
virtual void fromXml(const QDomElement &) = 0;
|
virtual void fromXml(const QDomElement &) = 0;
|
||||||
virtual QDomElement toXml(QDomDocument &) const = 0;
|
virtual QDomElement toXml(QDomDocument &) const;
|
||||||
qreal rotationAngle() const;
|
qreal rotationAngle() const;
|
||||||
void setRotationAngle(const qreal &);
|
void setRotationAngle(const qreal &);
|
||||||
void rotateBy(const qreal &);
|
void rotateBy(const qreal &);
|
||||||
@@ -76,8 +76,13 @@ class DiagramTextItem : public QGraphicsTextItem {
|
|||||||
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *event);
|
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *event);
|
||||||
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *event);
|
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
|
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *);
|
||||||
|
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *);
|
||||||
|
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *);
|
||||||
|
|
||||||
virtual void applyRotation(const qreal &);
|
virtual void applyRotation(const qreal &);
|
||||||
|
|
||||||
|
bool bMouseOver;
|
||||||
signals:
|
signals:
|
||||||
/// signal emitted when the text field loses focus
|
/// signal emitted when the text field loses focus
|
||||||
void lostFocus();
|
void lostFocus();
|
||||||
|
|||||||
@@ -30,18 +30,16 @@
|
|||||||
/**
|
/**
|
||||||
Constructeur pour un element sans scene ni parent
|
Constructeur pour un element sans scene ni parent
|
||||||
*/
|
*/
|
||||||
Element::Element(QGraphicsItem *parent, Diagram *scene) :
|
Element::Element(QGraphicsItem *parent) :
|
||||||
QetGraphicsItem(parent),
|
QetGraphicsItem(parent),
|
||||||
internal_connections_(false),
|
must_highlight_(false),
|
||||||
must_highlight_(false)
|
m_mouse_over(false)
|
||||||
{
|
{
|
||||||
Q_UNUSED(scene);
|
|
||||||
|
|
||||||
link_type_ = Simple;
|
link_type_ = Simple;
|
||||||
uuid_ = QUuid::createUuid();
|
uuid_ = QUuid::createUuid();
|
||||||
setZValue(10);
|
setZValue(10);
|
||||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||||
|
setAcceptsHoverEvents(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -101,11 +99,11 @@ void Element::paint(QPainter *painter, const QStyleOptionGraphicsItem *options,
|
|||||||
#endif
|
#endif
|
||||||
if (must_highlight_) drawHighlight(painter, options);
|
if (must_highlight_) drawHighlight(painter, options);
|
||||||
|
|
||||||
// Dessin de l'element lui-meme
|
//Draw the element himself
|
||||||
paint(painter, options);
|
paint(painter, options);
|
||||||
|
|
||||||
// Dessin du cadre de selection si necessaire
|
//Draw the selection rectangle
|
||||||
if (isSelected()) drawSelection(painter, options);
|
if ( isSelected() || m_mouse_over ) drawSelection(painter, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -515,8 +513,9 @@ void Element::initLink(QETProject *prj) {
|
|||||||
* @param dc
|
* @param dc
|
||||||
*/
|
*/
|
||||||
void Element::setElementInformations(DiagramContext dc) {
|
void Element::setElementInformations(DiagramContext dc) {
|
||||||
|
DiagramContext old_info = element_informations_;
|
||||||
element_informations_ = dc;
|
element_informations_ = dc;
|
||||||
emit elementInfoChange(element_informations_);
|
emit elementInfoChange(old_info, element_informations_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -540,3 +539,37 @@ bool comparPos(const Element *elmt1, const Element *elmt2) {
|
|||||||
return elmt1->y() <= elmt2->pos().y();
|
return elmt1->y() <= elmt2->pos().y();
|
||||||
return elmt1->pos().x() <= elmt2->pos().x();
|
return elmt1->pos().x() <= elmt2->pos().x();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When mouse over element
|
||||||
|
* change m_mouse_over to true (used in paint() function )
|
||||||
|
* Also highlight linked elements
|
||||||
|
* @param e QGraphicsSceneHoverEvent
|
||||||
|
*/
|
||||||
|
void Element::hoverEnterEvent(QGraphicsSceneHoverEvent *e) {
|
||||||
|
Q_UNUSED(e);
|
||||||
|
|
||||||
|
foreach (Element *elmt, linkedElements())
|
||||||
|
elmt -> setHighlighted(true);
|
||||||
|
|
||||||
|
m_mouse_over = true;
|
||||||
|
setToolTip( name() );
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When mouse over element leave the position
|
||||||
|
* change m_mouse_over to false(used in paint() function )
|
||||||
|
* Also un-highlight linked elements
|
||||||
|
* @param e QGraphicsSceneHoverEvent
|
||||||
|
*/
|
||||||
|
void Element::hoverLeaveEvent(QGraphicsSceneHoverEvent *e) {
|
||||||
|
Q_UNUSED(e);
|
||||||
|
|
||||||
|
foreach (Element *elmt, linkedElements())
|
||||||
|
elmt -> setHighlighted(false);
|
||||||
|
|
||||||
|
m_mouse_over = false;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
#include "qetgraphicsitem.h"
|
#include "qetgraphicsitem.h"
|
||||||
#include "diagramcontext.h"
|
#include "diagramcontext.h"
|
||||||
|
|
||||||
class Diagram;
|
|
||||||
class ElementTextItem;
|
class ElementTextItem;
|
||||||
class QETProject;
|
class QETProject;
|
||||||
class Terminal;
|
class Terminal;
|
||||||
@@ -32,12 +31,11 @@ class Conductor;
|
|||||||
This is the base class for electrical elements.
|
This is the base class for electrical elements.
|
||||||
*/
|
*/
|
||||||
class Element : public QetGraphicsItem {
|
class Element : public QetGraphicsItem {
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
Element(QGraphicsItem * = 0, Diagram * = 0);
|
Element(QGraphicsItem * = 0);
|
||||||
virtual ~Element();
|
virtual ~Element();
|
||||||
private:
|
private:
|
||||||
Element(const Element &);
|
Element(const Element &);
|
||||||
@@ -121,7 +119,7 @@ class Element : public QetGraphicsItem {
|
|||||||
kind link_type_;
|
kind link_type_;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void elementInfoChange(DiagramContext);
|
void elementInfoChange(DiagramContext old_info, DiagramContext new_info);
|
||||||
|
|
||||||
//METHODS related to information
|
//METHODS related to information
|
||||||
public:
|
public:
|
||||||
@@ -162,9 +160,6 @@ class Element : public QetGraphicsItem {
|
|||||||
void select();
|
void select();
|
||||||
void deselect();
|
void deselect();
|
||||||
|
|
||||||
// methods related to internal connections
|
|
||||||
bool internalConnections();
|
|
||||||
void setInternalConnections(bool);
|
|
||||||
virtual void rotateBy(const qreal &);
|
virtual void rotateBy(const qreal &);
|
||||||
virtual void editProperty();
|
virtual void editProperty();
|
||||||
|
|
||||||
@@ -181,11 +176,17 @@ class Element : public QetGraphicsItem {
|
|||||||
void drawAxes(QPainter *, const QStyleOptionGraphicsItem *);
|
void drawAxes(QPainter *, const QStyleOptionGraphicsItem *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool internal_connections_;
|
|
||||||
bool must_highlight_;
|
bool must_highlight_;
|
||||||
void drawSelection(QPainter *, const QStyleOptionGraphicsItem *);
|
void drawSelection(QPainter *, const QStyleOptionGraphicsItem *);
|
||||||
void drawHighlight(QPainter *, const QStyleOptionGraphicsItem *);
|
void drawHighlight(QPainter *, const QStyleOptionGraphicsItem *);
|
||||||
void updatePixmap();
|
void updatePixmap();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * );
|
||||||
|
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * );
|
||||||
|
private:
|
||||||
|
bool m_mouse_over;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bool comparPos(const Element * elmt1, const Element * elmt2);
|
bool comparPos(const Element * elmt1, const Element * elmt2);
|
||||||
@@ -194,24 +195,6 @@ inline bool Element::isFree() const {
|
|||||||
return (connected_elements.isEmpty());
|
return (connected_elements.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Indicate whether this element allows internal connections, i.e. whether its
|
|
||||||
terminals can be linked together using a conductor.
|
|
||||||
@return true if internal connections are accepted, false otherwise
|
|
||||||
*/
|
|
||||||
inline bool Element::internalConnections() {
|
|
||||||
return(internal_connections_);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Specify whether this element allows internal connections, i.e. whether its
|
|
||||||
terminals can be linked together using a conductor.
|
|
||||||
@return true for internal connections to be accepted, false otherwise
|
|
||||||
*/
|
|
||||||
inline void Element::setInternalConnections(bool ic) {
|
|
||||||
internal_connections_ = ic;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Indicate the current orientation of this element
|
Indicate the current orientation of this element
|
||||||
O = 0°
|
O = 0°
|
||||||
|
|||||||
@@ -26,8 +26,8 @@
|
|||||||
@param parent_element Le QGraphicsItem parent du champ de texte
|
@param parent_element Le QGraphicsItem parent du champ de texte
|
||||||
@param parent_diagram Le schema auquel appartient le champ de texte
|
@param parent_diagram Le schema auquel appartient le champ de texte
|
||||||
*/
|
*/
|
||||||
ElementTextItem::ElementTextItem(Element *parent_element, Diagram *parent_diagram) :
|
ElementTextItem::ElementTextItem(Element *parent_element) :
|
||||||
DiagramTextItem(parent_element, parent_diagram),
|
DiagramTextItem(parent_element),
|
||||||
parent_element_(parent_element),
|
parent_element_(parent_element),
|
||||||
follow_parent_rotations(false),
|
follow_parent_rotations(false),
|
||||||
original_rotation_angle_(0.0)
|
original_rotation_angle_(0.0)
|
||||||
@@ -39,8 +39,8 @@ ElementTextItem::ElementTextItem(Element *parent_element, Diagram *parent_diagra
|
|||||||
@param parent_diagram Le schema auquel appartient le champ de texte
|
@param parent_diagram Le schema auquel appartient le champ de texte
|
||||||
@param text Le texte affiche par le champ de texte
|
@param text Le texte affiche par le champ de texte
|
||||||
*/
|
*/
|
||||||
ElementTextItem::ElementTextItem(const QString &text, Element *parent_element, Diagram *parent_diagram) :
|
ElementTextItem::ElementTextItem(const QString &text, Element *parent_element) :
|
||||||
DiagramTextItem(text, parent_element, parent_diagram),
|
DiagramTextItem(text, parent_element),
|
||||||
parent_element_(parent_element),
|
parent_element_(parent_element),
|
||||||
follow_parent_rotations(false),
|
follow_parent_rotations(false),
|
||||||
original_rotation_angle_(0.0)
|
original_rotation_angle_(0.0)
|
||||||
@@ -174,23 +174,63 @@ void ElementTextItem::adjustItemPosition(int new_block_count) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Effetue la rotation du texte en elle-meme
|
* @brief ElementTextItem::mouseDoubleClickEvent
|
||||||
Pour les ElementTextItem, la rotation s'effectue autour du milieu du bord
|
* @param event
|
||||||
gauche du champ de texte.
|
|
||||||
@param angle Angle de la rotation a effectuer
|
|
||||||
*/
|
*/
|
||||||
void ElementTextItem::applyRotation(const qreal &angle) {
|
void ElementTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||||
QGraphicsTextItem::setRotation(QGraphicsTextItem::rotation() + angle);
|
{
|
||||||
|
/*
|
||||||
|
* Before revision 3559, report element haven't got text tagged label
|
||||||
|
* so if parent is a report and haven't got text tagged label,
|
||||||
|
* we know if this text is used has tagged label.
|
||||||
|
*/
|
||||||
|
bool report_text = false;
|
||||||
|
if (parent_element_ -> linkType() & Element::AllReport && !parent_element_ -> taggedText("label"))
|
||||||
|
{
|
||||||
|
//This is the first of list, so this text is used to display
|
||||||
|
//pos of linked report.
|
||||||
|
if (parent_element_ -> texts().first() == this)
|
||||||
|
report_text = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( (tagg_ == "label" || report_text) && !parent_element_ -> isFree())
|
||||||
|
{
|
||||||
|
//If parent is linked, show the linked element
|
||||||
|
if ( parent_element_ -> linkType() & (Element::AllReport | Element::Slave) )
|
||||||
|
{
|
||||||
|
//Unselect and ungrab mouse to prevent unwanted
|
||||||
|
//move when linked element is in the same scene of this.
|
||||||
|
setSelected(false);
|
||||||
|
ungrabMouse();
|
||||||
|
|
||||||
|
//Show and select the linked element
|
||||||
|
Element *linked = parent_element_ -> linkedElements().first();
|
||||||
|
if (scene() != linked -> scene())
|
||||||
|
linked -> diagram() -> showMe();
|
||||||
|
linked -> setSelected(true);
|
||||||
|
|
||||||
|
//Zoom to the linked element
|
||||||
|
foreach(QGraphicsView *view, linked -> diagram() -> views()) {
|
||||||
|
QRectF fit = linked -> sceneBoundingRect();
|
||||||
|
fit.adjust(-200, -200, 200, 200);
|
||||||
|
view -> fitInView(fit, Qt::KeepAspectRatioByExpanding);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DiagramTextItem::mouseDoubleClickEvent(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementTextItem::mouseMoveEvent
|
* @brief ElementTextItem::mouseMoveEvent
|
||||||
* @param e
|
* @param e
|
||||||
*/
|
*/
|
||||||
void ElementTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
void ElementTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
|
||||||
if (textInteractionFlags() & Qt::TextEditable) {
|
if (textInteractionFlags() & Qt::TextEditable) {
|
||||||
DiagramTextItem::mouseMoveEvent(e);
|
DiagramTextItem::mouseMoveEvent(event);
|
||||||
} else if ((flags() & QGraphicsItem::ItemIsMovable) && (e -> buttons() & Qt::LeftButton)) {
|
} else if ((flags() & QGraphicsItem::ItemIsMovable) && (event -> buttons() & Qt::LeftButton)) {
|
||||||
QPointF old_pos = pos();
|
QPointF old_pos = pos();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -199,7 +239,7 @@ void ElementTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
* Instead of this, we apply to the actual pos,
|
* Instead of this, we apply to the actual pos,
|
||||||
* the vector defined by the movement of cursor since the last pos clicked by left button
|
* the vector defined by the movement of cursor since the last pos clicked by left button
|
||||||
*/
|
*/
|
||||||
QPointF movement = e -> pos() - e -> buttonDownPos(Qt::LeftButton);
|
QPointF movement = event -> pos() - event -> buttonDownPos(Qt::LeftButton);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* the method pos() and setPos() always work with coordinate of parent item
|
* the method pos() and setPos() always work with coordinate of parent item
|
||||||
@@ -207,7 +247,7 @@ void ElementTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
* before applyRotation
|
* before applyRotation
|
||||||
*/
|
*/
|
||||||
QPointF new_pos = pos() + mapMovementToParent(movement);
|
QPointF new_pos = pos() + mapMovementToParent(movement);
|
||||||
e -> modifiers() == Qt::ControlModifier ? setPos(new_pos) : setPos(Diagram::snapToGrid(new_pos));
|
event -> modifiers() == Qt::ControlModifier ? setPos(new_pos) : setPos(Diagram::snapToGrid(new_pos));
|
||||||
|
|
||||||
Diagram *diagram_ptr = diagram();
|
Diagram *diagram_ptr = diagram();
|
||||||
if (diagram_ptr) {
|
if (diagram_ptr) {
|
||||||
@@ -233,7 +273,7 @@ void ElementTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
// on applique le mouvement subi aux autres textes a deplacer
|
// on applique le mouvement subi aux autres textes a deplacer
|
||||||
diagram_ptr -> continueMoveElementTexts(scene_effective_movement);
|
diagram_ptr -> continueMoveElementTexts(scene_effective_movement);
|
||||||
}
|
}
|
||||||
} else e -> ignore();
|
} else event -> ignore();
|
||||||
|
|
||||||
if (m_first_move) {
|
if (m_first_move) {
|
||||||
m_first_move = false;
|
m_first_move = false;
|
||||||
@@ -244,7 +284,7 @@ void ElementTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
* @brief ElementTextItem::mouseReleaseEvent
|
* @brief ElementTextItem::mouseReleaseEvent
|
||||||
* @param e
|
* @param e
|
||||||
*/
|
*/
|
||||||
void ElementTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
void ElementTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
|
||||||
if (Diagram *diagram_ptr = diagram()) {
|
if (Diagram *diagram_ptr = diagram()) {
|
||||||
if (parent_element_) {
|
if (parent_element_) {
|
||||||
if (parent_element_ -> isHighlighted()) {
|
if (parent_element_ -> isHighlighted()) {
|
||||||
@@ -254,7 +294,79 @@ void ElementTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
|
|
||||||
diagram_ptr -> endMoveElementTexts();
|
diagram_ptr -> endMoveElementTexts();
|
||||||
}
|
}
|
||||||
if (!(e -> modifiers() & Qt::ControlModifier)) {
|
if (!(event -> modifiers() & Qt::ControlModifier)) {
|
||||||
QGraphicsTextItem::mouseReleaseEvent(e);
|
QGraphicsTextItem::mouseReleaseEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ElementTextItem::hoverEnterEvent
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
|
void ElementTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Before revision 3559, report element haven't got text tagged label
|
||||||
|
* so if parent is a report and haven't got text tagged label,
|
||||||
|
* we know if this text is used has tagged label.
|
||||||
|
*/
|
||||||
|
bool report_text = false;
|
||||||
|
if (parent_element_ -> linkType() & Element::AllReport && !parent_element_ -> taggedText("label"))
|
||||||
|
{
|
||||||
|
//This is the first of list, so this text is used to display
|
||||||
|
//pos of linked report.
|
||||||
|
if (parent_element_ -> texts().first() == this)
|
||||||
|
report_text = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tagg_ == "label" || report_text)
|
||||||
|
{
|
||||||
|
if (parent_element_ -> linkType() & (Element::AllReport | Element::Slave) && !parent_element_->isFree()) {
|
||||||
|
|
||||||
|
setDefaultTextColor(Qt::blue);
|
||||||
|
|
||||||
|
//Also color the child text if parent is a slave and linked
|
||||||
|
if (parent_element_-> linkType() == Element::Slave && !parent_element_ -> isFree())
|
||||||
|
foreach (QGraphicsItem *qgi, childItems())
|
||||||
|
if (QGraphicsTextItem *qgti = qgraphicsitem_cast<QGraphicsTextItem *> (qgi))
|
||||||
|
qgti -> setDefaultTextColor(Qt::blue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DiagramTextItem::hoverEnterEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ElementTextItem::hoverLeaveEvent
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
|
void ElementTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Before revision 3559, report element haven't got text tagged label
|
||||||
|
* so if parent is a report and haven't got text tagged label,
|
||||||
|
* we know if this text is used has tagged label.
|
||||||
|
*/
|
||||||
|
bool report_text = false;
|
||||||
|
if (parent_element_ -> linkType() & Element::AllReport && !parent_element_ -> taggedText("label"))
|
||||||
|
{
|
||||||
|
//This is the first of list, so this text is used to display
|
||||||
|
//pos of linked report.
|
||||||
|
if (parent_element_ -> texts().first() == this)
|
||||||
|
report_text = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tagg_ == "label" || report_text)
|
||||||
|
{
|
||||||
|
if (defaultTextColor() != Qt::black)
|
||||||
|
setDefaultTextColor(Qt::black);
|
||||||
|
|
||||||
|
//Also color the child text if parent is a slave and linked
|
||||||
|
if (parent_element_-> linkType() == Element::Slave && !parent_element_ -> isFree())
|
||||||
|
foreach (QGraphicsItem *qgi, childItems())
|
||||||
|
if (QGraphicsTextItem *qgti = qgraphicsitem_cast<QGraphicsTextItem *> (qgi))
|
||||||
|
qgti -> setDefaultTextColor(Qt::black);
|
||||||
|
}
|
||||||
|
|
||||||
|
DiagramTextItem::hoverLeaveEvent(event);
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include "diagramtextitem.h"
|
#include "diagramtextitem.h"
|
||||||
|
|
||||||
class Diagram;
|
|
||||||
class Element;
|
class Element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,13 +31,14 @@ class ElementTextItem : public DiagramTextItem {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
ElementTextItem(Element * = 0, Diagram * = 0);
|
ElementTextItem(Element * = 0);
|
||||||
ElementTextItem(const QString &, Element * = 0, Diagram * = 0);
|
ElementTextItem(const QString &, Element * = 0);
|
||||||
virtual ~ElementTextItem();
|
virtual ~ElementTextItem();
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
public:
|
public:
|
||||||
enum { Type = UserType + 1003 };
|
enum { Type = UserType + 1003 };
|
||||||
|
virtual int type () const { return Type; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Element *parent_element_;
|
Element *parent_element_;
|
||||||
@@ -49,12 +49,7 @@ class ElementTextItem : public DiagramTextItem {
|
|||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
virtual int type() const { return Type; }
|
|
||||||
Element *parentElement () const;
|
Element *parentElement () const;
|
||||||
/// @return the rectangle defining the bounds of this text item
|
|
||||||
virtual QRectF boundingRect() const { return(QGraphicsTextItem::boundingRect().adjusted(0.0, -1.1, 0.0, 0.0)); }
|
|
||||||
bool followParentRotations() const;
|
|
||||||
void setFollowParentRotations(bool);
|
|
||||||
void fromXml ( const QDomElement & );
|
void fromXml ( const QDomElement & );
|
||||||
QDomElement toXml ( QDomDocument & ) const;
|
QDomElement toXml ( QDomDocument & ) const;
|
||||||
void setOriginalPos ( const QPointF & );
|
void setOriginalPos ( const QPointF & );
|
||||||
@@ -64,15 +59,18 @@ class ElementTextItem : public DiagramTextItem {
|
|||||||
virtual void setFont ( const QFont & );
|
virtual void setFont ( const QFont & );
|
||||||
void setTagg ( const QString &str ) {tagg_ = str;}
|
void setTagg ( const QString &str ) {tagg_ = str;}
|
||||||
QString tagg () const {return tagg_;}
|
QString tagg () const {return tagg_;}
|
||||||
|
void setFollowParentRotations ( bool fpr);
|
||||||
|
bool followParentRotations () const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void adjustItemPosition(int = 0);
|
void adjustItemPosition(int = 0);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void applyRotation(const qreal &);
|
virtual void mouseDoubleClickEvent ( QGraphicsSceneMouseEvent *event );
|
||||||
|
virtual void mouseMoveEvent ( QGraphicsSceneMouseEvent *event );
|
||||||
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *e);
|
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent *event );
|
||||||
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *e);
|
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent *event );
|
||||||
|
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent *event );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void build ();
|
void build ();
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
*/
|
*/
|
||||||
FixedElement::FixedElement(QGraphicsItem *parent, Diagram *scene) : Element(parent, scene) {
|
FixedElement::FixedElement(QGraphicsItem *parent) : Element(parent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -17,7 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef ELEMENTFIXE_H
|
#ifndef ELEMENTFIXE_H
|
||||||
#define ELEMENTFIXE_H
|
#define ELEMENTFIXE_H
|
||||||
|
|
||||||
#include "element.h"
|
#include "element.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This class represents an element having a fixed number of terminals.
|
This class represents an element having a fixed number of terminals.
|
||||||
*/
|
*/
|
||||||
@@ -27,7 +29,7 @@ class FixedElement : public Element {
|
|||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
FixedElement(QGraphicsItem * = 0, Diagram * = 0);
|
FixedElement(QGraphicsItem * = 0);
|
||||||
virtual ~FixedElement();
|
virtual ~FixedElement();
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
|
|||||||
@@ -29,10 +29,9 @@
|
|||||||
*/
|
*/
|
||||||
GhostElement::GhostElement(
|
GhostElement::GhostElement(
|
||||||
const ElementsLocation &location,
|
const ElementsLocation &location,
|
||||||
QGraphicsItem *qgi,
|
QGraphicsItem *qgi
|
||||||
Diagram *d
|
|
||||||
) :
|
) :
|
||||||
CustomElement(location, qgi, d)
|
CustomElement(location, qgi)
|
||||||
{
|
{
|
||||||
QString tooltip_string = QString(
|
QString tooltip_string = QString(
|
||||||
tr("<u>\311l\351ment manquant\240:</u> %1")
|
tr("<u>\311l\351ment manquant\240:</u> %1")
|
||||||
@@ -74,7 +73,6 @@ bool GhostElement::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr,
|
|||||||
QRect final_bounding_rect = minimalBoundingRect().united(childrenBoundingRect()).toAlignedRect();
|
QRect final_bounding_rect = minimalBoundingRect().united(childrenBoundingRect()).toAlignedRect();
|
||||||
setSize(final_bounding_rect.width(), final_bounding_rect.height());
|
setSize(final_bounding_rect.width(), final_bounding_rect.height());
|
||||||
setHotspot(QPoint() - final_bounding_rect.topLeft());
|
setHotspot(QPoint() - final_bounding_rect.topLeft());
|
||||||
setInternalConnections(true);
|
|
||||||
|
|
||||||
// on peut desormais confectionner le rendu de l'element
|
// on peut desormais confectionner le rendu de l'element
|
||||||
generateDrawings();
|
generateDrawings();
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
#ifndef GHOST_ELEMENT_H
|
#ifndef GHOST_ELEMENT_H
|
||||||
#define GHOST_ELEMENT_H
|
#define GHOST_ELEMENT_H
|
||||||
#include "customelement.h"
|
#include "customelement.h"
|
||||||
class Diagram;
|
|
||||||
class QGraphicsItem;
|
class QGraphicsItem;
|
||||||
class ElementsLocation;
|
class ElementsLocation;
|
||||||
class Terminal;
|
class Terminal;
|
||||||
@@ -37,7 +36,7 @@ class GhostElement : public CustomElement {
|
|||||||
|
|
||||||
// constructor, destructor
|
// constructor, destructor
|
||||||
public:
|
public:
|
||||||
GhostElement(const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0);
|
GhostElement(const ElementsLocation &, QGraphicsItem * = 0);
|
||||||
virtual ~GhostElement();
|
virtual ~GhostElement();
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
|
|||||||
@@ -22,8 +22,8 @@
|
|||||||
Constructeur
|
Constructeur
|
||||||
@param parent_diagram Le schema auquel est rattache le champ de texte
|
@param parent_diagram Le schema auquel est rattache le champ de texte
|
||||||
*/
|
*/
|
||||||
IndependentTextItem::IndependentTextItem(Diagram *parent_diagram) :
|
IndependentTextItem::IndependentTextItem() :
|
||||||
DiagramTextItem(0, parent_diagram)
|
DiagramTextItem(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,8 +31,8 @@ IndependentTextItem::IndependentTextItem(Diagram *parent_diagram) :
|
|||||||
@param text Le texte affiche par le champ de texte
|
@param text Le texte affiche par le champ de texte
|
||||||
@param parent_diagram Le schema auquel est rattache le champ de texte
|
@param parent_diagram Le schema auquel est rattache le champ de texte
|
||||||
*/
|
*/
|
||||||
IndependentTextItem::IndependentTextItem(const QString &text, Diagram *parent_diagram) :
|
IndependentTextItem::IndependentTextItem(const QString &text) :
|
||||||
DiagramTextItem(text, 0, parent_diagram)
|
DiagramTextItem(text, 0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/// Destructeur
|
/// Destructeur
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ class IndependentTextItem : public DiagramTextItem {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
IndependentTextItem(Diagram * = 0);
|
IndependentTextItem();
|
||||||
IndependentTextItem(const QString &, Diagram* = 0);
|
IndependentTextItem(const QString &);
|
||||||
virtual ~IndependentTextItem();
|
virtual ~IndependentTextItem();
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "masterelement.h"
|
#include "masterelement.h"
|
||||||
#include "crossrefitem.h"
|
#include "crossrefitem.h"
|
||||||
|
#include "elementtextitem.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief MasterElement::MasterElement
|
* @brief MasterElement::MasterElement
|
||||||
@@ -26,12 +27,12 @@
|
|||||||
* @param s parent diagram
|
* @param s parent diagram
|
||||||
* @param state int used to know if the creation of element have error
|
* @param state int used to know if the creation of element have error
|
||||||
*/
|
*/
|
||||||
MasterElement::MasterElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) :
|
MasterElement::MasterElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state) :
|
||||||
CustomElement(location, qgi, s, state),
|
CustomElement(location, qgi, state),
|
||||||
cri_ (nullptr)
|
cri_ (nullptr)
|
||||||
{
|
{
|
||||||
link_type_ = Master;
|
link_type_ = Master;
|
||||||
connect(this, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
|
connect(this, SIGNAL(elementInfoChange(DiagramContext, DiagramContext)), this, SLOT(updateLabel(DiagramContext, DiagramContext)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,30 +81,34 @@ void MasterElement::unlinkAllElements() {
|
|||||||
* Unlink the given elmt in parametre
|
* Unlink the given elmt in parametre
|
||||||
* @param elmt element to unlink from this
|
* @param elmt element to unlink from this
|
||||||
*/
|
*/
|
||||||
void MasterElement::unlinkElement(Element *elmt) {
|
void MasterElement::unlinkElement(Element *elmt)
|
||||||
|
{
|
||||||
//Ensure elmt is linked to this element
|
//Ensure elmt is linked to this element
|
||||||
if (connected_elements.contains(elmt)) {
|
if (connected_elements.contains(elmt))
|
||||||
|
{
|
||||||
connected_elements.removeOne(elmt);
|
connected_elements.removeOne(elmt);
|
||||||
elmt -> unlinkElement (this);
|
elmt -> unlinkElement (this);
|
||||||
|
elmt -> setHighlighted (false);
|
||||||
|
|
||||||
//update the graphics cross ref
|
//update the graphics cross ref
|
||||||
disconnect(elmt, SIGNAL(xChanged()), cri_, SLOT(updateLabel()));
|
disconnect(elmt, SIGNAL(xChanged()), cri_, SLOT(updateLabel()));
|
||||||
disconnect(elmt, SIGNAL(yChanged()), cri_, SLOT(updateLabel()));
|
disconnect(elmt, SIGNAL(yChanged()), cri_, SLOT(updateLabel()));
|
||||||
|
|
||||||
if (aboutDeleteXref()) return;
|
|
||||||
cri_ -> updateLabel();
|
cri_ -> updateLabel();
|
||||||
|
aboutDeleteXref();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief MasterElement::initLink
|
* @brief MasterElement::initLink
|
||||||
* Initialise the links between this element and other element.
|
|
||||||
* @param project
|
* @param project
|
||||||
|
* Call init Link from custom element and after
|
||||||
|
* call update label for setup it.
|
||||||
*/
|
*/
|
||||||
void MasterElement::initLink(QETProject *project) {
|
void MasterElement::initLink(QETProject *project) {
|
||||||
//Create the link with other element if needed
|
//Create the link with other element if needed
|
||||||
CustomElement::initLink(project);
|
CustomElement::initLink(project);
|
||||||
updateLabel();
|
updateLabel(DiagramContext(), elementInformations());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -111,16 +116,22 @@ void MasterElement::initLink(QETProject *project) {
|
|||||||
* update label of this element
|
* update label of this element
|
||||||
* and the comment item if he's displayed.
|
* and the comment item if he's displayed.
|
||||||
*/
|
*/
|
||||||
void MasterElement::updateLabel() {
|
void MasterElement::updateLabel(DiagramContext old_info, DiagramContext new_info) {
|
||||||
QString label = elementInformations()["label"].toString();
|
//Label of element
|
||||||
bool show = elementInformations().keyMustShow("label");
|
if (old_info["label"].toString() != new_info["label"].toString()) {
|
||||||
|
if (new_info["label"].toString().isEmpty())
|
||||||
// setup the label
|
setTaggedText("label", "_", false);
|
||||||
if (!label.isEmpty() && show) setTaggedText("label", label, true);
|
else
|
||||||
|
setTaggedText("label", new_info["label"].toString(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ElementTextItem *eti = taggedText("label")) {
|
||||||
|
new_info["label"].toString().isEmpty() ? eti->setVisible(true) : eti -> setVisible(new_info.keyMustShow("label"));
|
||||||
|
}
|
||||||
|
|
||||||
//Delete or update the xref
|
//Delete or update the xref
|
||||||
if (cri_) {
|
if (cri_) {
|
||||||
|
cri_ -> updateLabel();
|
||||||
aboutDeleteXref();
|
aboutDeleteXref();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -143,11 +154,7 @@ void MasterElement::updateLabel() {
|
|||||||
bool MasterElement::aboutDeleteXref() {
|
bool MasterElement::aboutDeleteXref() {
|
||||||
if(!cri_) return true;
|
if(!cri_) return true;
|
||||||
|
|
||||||
QString comment = elementInformations()["comment"].toString();
|
if (cri_ -> boundingRect().isNull()) {
|
||||||
bool must_show = elementInformations().keyMustShow("comment");
|
|
||||||
|
|
||||||
//Delete Xref item if there isn't reason to display it
|
|
||||||
if (linkedElements().isEmpty() && (comment.isEmpty() || !must_show)) {
|
|
||||||
delete cri_;
|
delete cri_;
|
||||||
cri_ = nullptr;
|
cri_ = nullptr;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class MasterElement : public CustomElement
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MasterElement(const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0, int * = 0);
|
explicit MasterElement(const ElementsLocation &, QGraphicsItem * = 0, int * = 0);
|
||||||
~MasterElement();
|
~MasterElement();
|
||||||
|
|
||||||
virtual void linkToElement (Element *elmt);
|
virtual void linkToElement (Element *elmt);
|
||||||
@@ -44,7 +44,7 @@ class MasterElement : public CustomElement
|
|||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateLabel();
|
void updateLabel(DiagramContext old_info, DiagramContext new_info);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool aboutDeleteXref ();
|
bool aboutDeleteXref ();
|
||||||
|
|||||||
@@ -35,16 +35,17 @@ QetShapeItem::QetShapeItem(QPointF p1, QPointF p2, ShapeType type, QGraphicsItem
|
|||||||
m_shapeType(type),
|
m_shapeType(type),
|
||||||
m_shapeStyle(Qt::DashLine),
|
m_shapeStyle(Qt::DashLine),
|
||||||
m_P1 (Diagram::snapToGrid(p1)),
|
m_P1 (Diagram::snapToGrid(p1)),
|
||||||
m_P2 (Diagram::snapToGrid(p2))
|
m_P2 (Diagram::snapToGrid(p2)),
|
||||||
|
m_hovered(false)
|
||||||
|
|
||||||
{
|
{
|
||||||
if (type == Polyline) m_polygon << m_P1 << m_P2;
|
if (type == Polyline) m_polygon << m_P1 << m_P2;
|
||||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||||
|
setAcceptHoverEvents(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
QetShapeItem::~QetShapeItem()
|
QetShapeItem::~QetShapeItem()
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief QetShapeItem::setStyle
|
* @brief QetShapeItem::setStyle
|
||||||
@@ -108,11 +109,7 @@ void QetShapeItem::setNextPoint(QPointF P) {
|
|||||||
* @return the bounding rect of this item
|
* @return the bounding rect of this item
|
||||||
*/
|
*/
|
||||||
QRectF QetShapeItem::boundingRect() const {
|
QRectF QetShapeItem::boundingRect() const {
|
||||||
if (m_shapeType == Polyline)
|
return shape().boundingRect();
|
||||||
return ( shape().boundingRect());
|
|
||||||
|
|
||||||
QRectF b(m_P1, m_P2);
|
|
||||||
return b.normalized();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -121,20 +118,17 @@ QRectF QetShapeItem::boundingRect() const {
|
|||||||
*/
|
*/
|
||||||
QPainterPath QetShapeItem::shape() const {
|
QPainterPath QetShapeItem::shape() const {
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
QPainterPathStroker pps;
|
|
||||||
|
|
||||||
switch (m_shapeType) {
|
switch (m_shapeType) {
|
||||||
case Line:
|
case Line:
|
||||||
path.moveTo(m_P1);
|
path.moveTo(m_P1);
|
||||||
path.lineTo(m_P2);
|
path.lineTo(m_P2);
|
||||||
pps.setWidth(10);
|
|
||||||
path = pps.createStroke(path);
|
|
||||||
break;
|
break;
|
||||||
case Rectangle:
|
case Rectangle:
|
||||||
path.addRect(boundingRect());
|
path.addRect(QRectF(m_P1, m_P2));
|
||||||
break;
|
break;
|
||||||
case Ellipse:
|
case Ellipse:
|
||||||
path.addEllipse(boundingRect());
|
path.addEllipse(QRectF(m_P1, m_P2));
|
||||||
break;
|
break;
|
||||||
case Polyline:
|
case Polyline:
|
||||||
path.addPolygon(m_polygon);
|
path.addPolygon(m_polygon);
|
||||||
@@ -144,7 +138,11 @@ QPainterPath QetShapeItem::shape() const {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return path;
|
QPainterPathStroker pps;
|
||||||
|
pps.setWidth(10);
|
||||||
|
pps.setJoinStyle(Qt::RoundJoin);
|
||||||
|
|
||||||
|
return (pps.createStroke(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -170,24 +168,35 @@ void QetShapeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
|||||||
{
|
{
|
||||||
Q_UNUSED(option); Q_UNUSED(widget);
|
Q_UNUSED(option); Q_UNUSED(widget);
|
||||||
|
|
||||||
QPen pen;
|
QPen pen(m_shapeStyle);
|
||||||
pen.setStyle(m_shapeStyle);
|
|
||||||
if (isSelected()) pen.setColor(Qt::red);
|
|
||||||
painter -> setRenderHint(QPainter::Antialiasing, false);
|
painter -> setRenderHint(QPainter::Antialiasing, false);
|
||||||
pen.setWidthF(1);
|
pen.setWidthF(1);
|
||||||
|
|
||||||
|
|
||||||
|
if (m_hovered) {
|
||||||
|
painter->save();
|
||||||
|
QColor color(Qt::darkBlue);
|
||||||
|
color.setAlpha(25);
|
||||||
|
painter -> setBrush (QBrush (color));
|
||||||
|
painter -> setPen (Qt::NoPen);
|
||||||
|
painter -> drawPath (shape());
|
||||||
|
painter -> restore ();
|
||||||
|
}
|
||||||
|
else if (isSelected()) {
|
||||||
|
pen.setColor(Qt::red);
|
||||||
|
}
|
||||||
|
|
||||||
painter -> setPen(pen);
|
painter -> setPen(pen);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
switch (m_shapeType) {
|
switch (m_shapeType) {
|
||||||
case Line:
|
case Line:
|
||||||
painter->drawLine(QLineF(m_P1, m_P2));
|
painter->drawLine(QLineF(m_P1, m_P2));
|
||||||
break;
|
break;
|
||||||
case Rectangle:
|
case Rectangle:
|
||||||
painter->drawRect(boundingRect());
|
painter->drawRect(QRectF(m_P1, m_P2));
|
||||||
break;
|
break;
|
||||||
case Ellipse:
|
case Ellipse:
|
||||||
painter->drawEllipse(boundingRect());
|
painter->drawEllipse(QRectF(m_P1, m_P2));
|
||||||
break;
|
break;
|
||||||
case Polyline:
|
case Polyline:
|
||||||
painter->drawPolyline(m_polygon);
|
painter->drawPolyline(m_polygon);
|
||||||
@@ -195,6 +204,30 @@ void QetShapeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief QetShapeItem::hoverEnterEvent
|
||||||
|
* Handle hover enter event
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
|
void QetShapeItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) {
|
||||||
|
Q_UNUSED(event);
|
||||||
|
|
||||||
|
m_hovered = true;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief QetShapeItem::hoverLeaveEvent
|
||||||
|
* Handle hover leave event
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
|
void QetShapeItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) {
|
||||||
|
Q_UNUSED(event);
|
||||||
|
|
||||||
|
m_hovered = false;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief QetShapeItem::fromXml
|
* @brief QetShapeItem::fromXml
|
||||||
* Build this item from the xml description
|
* Build this item from the xml description
|
||||||
@@ -204,6 +237,7 @@ void QetShapeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
|||||||
bool QetShapeItem::fromXml(const QDomElement &e) {
|
bool QetShapeItem::fromXml(const QDomElement &e) {
|
||||||
if (e.tagName() != "shape") return (false);
|
if (e.tagName() != "shape") return (false);
|
||||||
|
|
||||||
|
is_movable_ = (e.attribute("is_movable").toInt());
|
||||||
m_shapeStyle = Qt::PenStyle(e.attribute("style","0").toInt());
|
m_shapeStyle = Qt::PenStyle(e.attribute("style","0").toInt());
|
||||||
|
|
||||||
if (e.attribute("type", "0").toInt() != Polyline) {
|
if (e.attribute("type", "0").toInt() != Polyline) {
|
||||||
@@ -235,6 +269,7 @@ QDomElement QetShapeItem::toXml(QDomDocument &document) const {
|
|||||||
//write some attribute
|
//write some attribute
|
||||||
result.setAttribute("type", QString::number(m_shapeType));
|
result.setAttribute("type", QString::number(m_shapeType));
|
||||||
result.setAttribute("style", QString::number(m_shapeStyle));
|
result.setAttribute("style", QString::number(m_shapeStyle));
|
||||||
|
result.setAttribute("is_movable", bool(is_movable_));
|
||||||
|
|
||||||
if (m_shapeType != Polyline) {
|
if (m_shapeType != Polyline) {
|
||||||
result.setAttribute("x1", mapToScene(m_P1).x());
|
result.setAttribute("x1", mapToScene(m_P1).x());
|
||||||
|
|||||||
@@ -68,6 +68,8 @@ class QetShapeItem : public QetGraphicsItem
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
virtual void hoverEnterEvent (QGraphicsSceneHoverEvent *event);
|
||||||
|
virtual void hoverLeaveEvent (QGraphicsSceneHoverEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void changeGraphicsItem (const ShapeType &newtype);
|
void changeGraphicsItem (const ShapeType &newtype);
|
||||||
@@ -81,5 +83,6 @@ class QetShapeItem : public QetGraphicsItem
|
|||||||
Qt::PenStyle m_shapeStyle;
|
Qt::PenStyle m_shapeStyle;
|
||||||
QPointF m_P1, m_P2;
|
QPointF m_P1, m_P2;
|
||||||
QPolygonF m_polygon;
|
QPolygonF m_polygon;
|
||||||
|
bool m_hovered;
|
||||||
};
|
};
|
||||||
#endif // QETSHAPEITEM_H
|
#endif // QETSHAPEITEM_H
|
||||||
|
|||||||
@@ -21,17 +21,24 @@
|
|||||||
#include "qetproject.h"
|
#include "qetproject.h"
|
||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
|
|
||||||
ReportElement::ReportElement(const ElementsLocation &location, QString link_type,QGraphicsItem *qgi, Diagram *s, int *state) :
|
ReportElement::ReportElement(const ElementsLocation &location, QString link_type,QGraphicsItem *qgi, int *state) :
|
||||||
CustomElement(location, qgi, s, state)
|
CustomElement(location, qgi, state),
|
||||||
|
m_text_field (nullptr)
|
||||||
{
|
{
|
||||||
if (!texts().isEmpty())
|
/*
|
||||||
texts().first()->setNoEditable();
|
* Get text tagged label. This is work for report
|
||||||
|
* create after the revision 3559.
|
||||||
|
* for report create before, we take the first text field
|
||||||
|
* because report haven't got a text field tagged label
|
||||||
|
*/
|
||||||
|
m_text_field = taggedText("label");
|
||||||
|
if (!m_text_field && !texts().isEmpty())
|
||||||
|
m_text_field = texts().first();
|
||||||
|
if (m_text_field)
|
||||||
|
m_text_field -> setNoEditable();
|
||||||
|
|
||||||
link_type == "next_report"? link_type_=NextReport : link_type_=PreviousReport;
|
link_type == "next_report"? link_type_=NextReport : link_type_=PreviousReport;
|
||||||
link_type == "next_report"? inverse_report=PreviousReport : inverse_report=NextReport;
|
link_type == "next_report"? inverse_report=PreviousReport : inverse_report=NextReport;
|
||||||
if (s) {
|
|
||||||
label_ = s->defaultReportProperties();
|
|
||||||
connect(s, SIGNAL(reportPropertiesChanged(QString)), this, SLOT(setLabel(QString)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReportElement::~ReportElement() {
|
ReportElement::~ReportElement() {
|
||||||
@@ -44,21 +51,35 @@ ReportElement::~ReportElement() {
|
|||||||
* @param elmt
|
* @param elmt
|
||||||
* element to be linked with this
|
* element to be linked with this
|
||||||
*/
|
*/
|
||||||
void ReportElement::linkToElement(Element * elmt) {
|
void ReportElement::linkToElement(Element * elmt)
|
||||||
|
{
|
||||||
|
if (!diagram() && !elmt -> diagram())
|
||||||
|
{
|
||||||
|
qDebug() << "ReportElement : linkToElement : Unable to link this or element to link isn't in a diagram";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//ensure elmt isn't already linked
|
//ensure elmt isn't already linked
|
||||||
bool i = true;
|
bool i = true;
|
||||||
if (!this->isFree()){
|
if (!this -> isFree())
|
||||||
|
{
|
||||||
if (connected_elements.first() == elmt) i = false;
|
if (connected_elements.first() == elmt) i = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//ensure elmt is an inverse report of this element
|
//ensure elmt is an inverse report of this element
|
||||||
if ((elmt->linkType() == inverse_report) && i) {
|
if ((elmt->linkType() == inverse_report) && i)
|
||||||
|
{
|
||||||
unlinkAllElements();
|
unlinkAllElements();
|
||||||
connected_elements << elmt;
|
connected_elements << elmt;
|
||||||
|
|
||||||
connect(elmt, SIGNAL( xChanged() ), this, SLOT( updateLabel() ));
|
connect(elmt, SIGNAL( xChanged() ), this, SLOT( updateLabel() ));
|
||||||
connect(elmt, SIGNAL( yChanged() ), this, SLOT( updateLabel() ));
|
connect(elmt, SIGNAL( yChanged() ), this, SLOT( updateLabel() ));
|
||||||
|
connect(diagram(), SIGNAL( reportPropertiesChanged(QString) ), this, SLOT( setLabel(QString) ));
|
||||||
connect(diagram() -> project(), SIGNAL( projectDiagramsOrderChanged(QETProject*,int,int) ), this, SLOT( updateLabel() ));
|
connect(diagram() -> project(), SIGNAL( projectDiagramsOrderChanged(QETProject*,int,int) ), this, SLOT( updateLabel() ));
|
||||||
|
|
||||||
|
label_ = diagram() -> defaultReportProperties();
|
||||||
updateLabel();
|
updateLabel();
|
||||||
|
|
||||||
elmt -> linkToElement(this);
|
elmt -> linkToElement(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -67,11 +88,13 @@ void ReportElement::linkToElement(Element * elmt) {
|
|||||||
* @brief ReportElement::unLinkAllElements
|
* @brief ReportElement::unLinkAllElements
|
||||||
* Unlink all of the element in the QList connected_elements
|
* Unlink all of the element in the QList connected_elements
|
||||||
*/
|
*/
|
||||||
void ReportElement::unlinkAllElements(){
|
void ReportElement::unlinkAllElements()
|
||||||
|
{
|
||||||
if (!isFree()){
|
if (!isFree()){
|
||||||
QList <Element *> tmp_elmt = connected_elements;
|
QList <Element *> tmp_elmt = connected_elements;
|
||||||
|
|
||||||
foreach(Element *elmt, connected_elements) {
|
foreach(Element *elmt, connected_elements)
|
||||||
|
{
|
||||||
disconnect(elmt, SIGNAL(xChanged()), this, SLOT(updateLabel()));
|
disconnect(elmt, SIGNAL(xChanged()), this, SLOT(updateLabel()));
|
||||||
disconnect(elmt, SIGNAL(yChanged()), this, SLOT(updateLabel()));
|
disconnect(elmt, SIGNAL(yChanged()), this, SLOT(updateLabel()));
|
||||||
disconnect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
|
disconnect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
|
||||||
@@ -79,7 +102,9 @@ void ReportElement::unlinkAllElements(){
|
|||||||
connected_elements.clear();
|
connected_elements.clear();
|
||||||
updateLabel();
|
updateLabel();
|
||||||
|
|
||||||
foreach(Element *elmt, tmp_elmt){
|
foreach(Element *elmt, tmp_elmt)
|
||||||
|
{
|
||||||
|
elmt -> setHighlighted(false);
|
||||||
elmt -> unlinkAllElements();
|
elmt -> unlinkAllElements();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,18 +136,21 @@ void ReportElement::setLabel(QString label) {
|
|||||||
* Update the displayed label.
|
* Update the displayed label.
|
||||||
* ie the folio and position of the linked folio report
|
* ie the folio and position of the linked folio report
|
||||||
*/
|
*/
|
||||||
void ReportElement::updateLabel() {
|
void ReportElement::updateLabel()
|
||||||
if (texts().isEmpty()) return;
|
{
|
||||||
ElementTextItem *text = texts().first();
|
if (!m_text_field) return;
|
||||||
|
|
||||||
if (!connected_elements.isEmpty()){
|
if (!connected_elements.isEmpty())
|
||||||
|
{
|
||||||
Element *elmt = connected_elements.at(0);
|
Element *elmt = connected_elements.at(0);
|
||||||
QString label = label_;
|
QString label = label_;
|
||||||
label.replace("%f", QString::number(elmt->diagram()->folioIndex()+1));
|
label.replace("%f", QString::number(elmt->diagram()->folioIndex()+1));
|
||||||
label.replace("%c", QString::number(elmt->diagram() -> convertPosition(elmt -> scenePos()).number()));
|
label.replace("%c", QString::number(elmt->diagram() -> convertPosition(elmt -> scenePos()).number()));
|
||||||
label.replace("%l", elmt->diagram() -> convertPosition(elmt -> scenePos()).letter());
|
label.replace("%l", elmt->diagram() -> convertPosition(elmt -> scenePos()).letter());
|
||||||
text->setPlainText(label);
|
m_text_field -> setPlainText(label);
|
||||||
} else {
|
}
|
||||||
text->setPlainText("/");
|
else
|
||||||
|
{
|
||||||
|
m_text_field -> setPlainText("/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#include "customelement.h"
|
#include "customelement.h"
|
||||||
|
|
||||||
|
class ElementTextItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The ReportElement class
|
* @brief The ReportElement class
|
||||||
*this class represent an element that can be linked to an other ReportElement
|
*this class represent an element that can be linked to an other ReportElement
|
||||||
@@ -30,7 +32,7 @@ class ReportElement : public CustomElement {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public :
|
public :
|
||||||
explicit ReportElement(const ElementsLocation &,QString link_type, QGraphicsItem * = 0, Diagram * = 0, int * = 0);
|
explicit ReportElement(const ElementsLocation &,QString link_type, QGraphicsItem * = 0, int * = 0);
|
||||||
~ReportElement();
|
~ReportElement();
|
||||||
virtual void linkToElement(Element *);
|
virtual void linkToElement(Element *);
|
||||||
virtual void unlinkAllElements();
|
virtual void unlinkAllElements();
|
||||||
@@ -39,6 +41,7 @@ class ReportElement : public CustomElement {
|
|||||||
private:
|
private:
|
||||||
int inverse_report;
|
int inverse_report;
|
||||||
QString label_;
|
QString label_;
|
||||||
|
ElementTextItem *m_text_field;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "simpleelement.h"
|
#include "simpleelement.h"
|
||||||
#include "commentitem.h"
|
#include "commentitem.h"
|
||||||
|
#include "elementtextitem.h"
|
||||||
/**
|
/**
|
||||||
* @brief SimpleElement::SimpleElement
|
* @brief SimpleElement::SimpleElement
|
||||||
* @param location
|
* @param location
|
||||||
@@ -24,42 +25,52 @@
|
|||||||
* @param s
|
* @param s
|
||||||
* @param state
|
* @param state
|
||||||
*/
|
*/
|
||||||
SimpleElement::SimpleElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) :
|
SimpleElement::SimpleElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state) :
|
||||||
CustomElement(location, qgi, s, state),
|
CustomElement(location, qgi, state),
|
||||||
m_comment_item (nullptr)
|
m_comment_item (nullptr)
|
||||||
{
|
{
|
||||||
link_type_ = Simple;
|
link_type_ = Simple;
|
||||||
connect(this, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
|
connect(this, SIGNAL(elementInfoChange(DiagramContext, DiagramContext)), this, SLOT(updateLabel(DiagramContext, DiagramContext)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief SimpleElement::~SimpleElement
|
* @brief SimpleElement::~SimpleElement
|
||||||
*/
|
*/
|
||||||
SimpleElement::~SimpleElement() {
|
SimpleElement::~SimpleElement() {
|
||||||
disconnect(this, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
|
|
||||||
if (m_comment_item) delete m_comment_item;
|
if (m_comment_item) delete m_comment_item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief SimpleElement::initLink
|
||||||
|
* @param project
|
||||||
|
* Call init Link from custom element and after
|
||||||
|
* call update label for setup it.
|
||||||
|
*/
|
||||||
void SimpleElement::initLink(QETProject *project) {
|
void SimpleElement::initLink(QETProject *project) {
|
||||||
CustomElement::initLink(project);
|
CustomElement::initLink(project);
|
||||||
updateLabel();
|
updateLabel(DiagramContext(), elementInformations());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief SimpleElement::updateLabel
|
* @brief SimpleElement::updateLabel
|
||||||
* update label of this element
|
* update label of this element
|
||||||
*/
|
*/
|
||||||
void SimpleElement::updateLabel() {
|
void SimpleElement::updateLabel(DiagramContext old_info, DiagramContext new_info) {
|
||||||
//Label of element
|
//Label of element
|
||||||
QString label = elementInformations()["label"].toString();
|
if (old_info["label"].toString() != new_info["label"].toString()) {
|
||||||
bool show = elementInformations().keyMustShow("label");
|
if (new_info["label"].toString().isEmpty())
|
||||||
|
setTaggedText("label", "_", false);
|
||||||
|
else
|
||||||
|
setTaggedText("label", new_info["label"].toString(), true);
|
||||||
|
}
|
||||||
|
|
||||||
// setup the label
|
if (ElementTextItem *eti = taggedText("label")) {
|
||||||
if (!label.isEmpty() && show) setTaggedText("label", label, true);
|
new_info["label"].toString().isEmpty() ? eti->setVisible(true) : eti -> setVisible(new_info.keyMustShow("label"));
|
||||||
|
}
|
||||||
|
|
||||||
//Comment of element
|
//Comment of element
|
||||||
QString comment = elementInformations()["comment"].toString();
|
QString comment = new_info["comment"].toString();
|
||||||
bool must_show = elementInformations().keyMustShow("comment");
|
bool must_show = new_info.keyMustShow("comment");
|
||||||
|
|
||||||
if (!(comment.isEmpty() || !must_show) && !m_comment_item) {
|
if (!(comment.isEmpty() || !must_show) && !m_comment_item) {
|
||||||
m_comment_item = new CommentItem(this);
|
m_comment_item = new CommentItem(this);
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class SimpleElement : public CustomElement {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public :
|
public :
|
||||||
explicit SimpleElement(const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0, int * = 0);
|
explicit SimpleElement(const ElementsLocation &, QGraphicsItem * = 0, int * = 0);
|
||||||
~SimpleElement();
|
~SimpleElement();
|
||||||
|
|
||||||
virtual void initLink(QETProject *project);
|
virtual void initLink(QETProject *project);
|
||||||
@@ -40,7 +40,7 @@ class SimpleElement : public CustomElement {
|
|||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateLabel();
|
void updateLabel(DiagramContext old_info, DiagramContext new_info);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CommentItem *m_comment_item;
|
CommentItem *m_comment_item;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user