Compare commits

..

1 Commits
0.4rc2 ... 0.4b

Author SHA1 Message Date
scorpio810
7c7af63470 Tag version 0.4 beta
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/tags/0.4b@3438 bfdf4180-ca20-0410-9c96-a3a8aa849046
2014-11-02 16:32:01 +00:00
142 changed files with 10826 additions and 13388 deletions

View File

@@ -2,7 +2,6 @@
<names> <names>
<name lang="en">Fluorescent tube</name> <name lang="en">Fluorescent tube</name>
<name lang="fr">Tube fluorescent</name> <name lang="fr">Tube fluorescent</name>
<name lang="it">Tubo fluorescente</name>
</names> </names>
<informations></informations> <informations></informations>
<description> <description>

View File

@@ -1,4 +1,5 @@
<definition width="20" version="0.4" hotspot_x="3" hotspot_y="10" height="20" link_type="previous_report" type="element" ic="true" orientation="dyyy"> <definition width="70" version="0.3" hotspot_x="49" hotspot_y="15" height="30" 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>
@@ -8,15 +9,15 @@
<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="nl">Referentie Vorig</name>
<name lang="cs">Předchozí list</name> <name lang="cs">Předchozí list</name>
<name lang="nl">Referentie Vorig</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="/" tagg="label"/> <input x="-44" y="0" size="9" rotate="true" text="/"/>
<terminal x="13" y="0" orientation="e"/> <terminal x="13" y="0" nameHidden="0" number="" name="" orientation="e"/>
</description> </description>
</definition> </definition>

View File

@@ -1,4 +1,5 @@
<definition width="30" version="0.4" hotspot_x="21" hotspot_y="10" height="20" link_type="next_report" type="element" ic="true" orientation="dyyy"> <definition width="40" version="0.3" hotspot_x="18" hotspot_y="15" height="30" 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>
@@ -8,15 +9,15 @@
<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="nl">Referentie volgend</name>
<name lang="cs">Další list</name> <name lang="cs">Další list</name>
<name lang="nl">Referentie volgend</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="/" tagg="label"/> <input x="6" y="0" size="9" rotate="true" text="/"/>
<terminal x="-13" y="0" orientation="w"/> <terminal x="-13" y="0" nameHidden="0" number="" name="" orientation="w"/>
</description> </description>
</definition> </definition>

View File

@@ -2,6 +2,5 @@
<names> <names>
<name lang="en">Cables</name> <name lang="en">Cables</name>
<name lang="fr">Cables</name> <name lang="fr">Cables</name>
<name lang="it">Cavi</name>
</names> </names>
</qet-directory> </qet-directory>

View File

@@ -1,15 +1,8 @@
<project folioSheetQuantity="0" title="" version="0.4"> <project title="" version="0.3">
<properties/>
<newdiagrams> <newdiagrams>
<border displayrows="true" cols="17" displaycols="true" colsize="60" rows="8" rowsize="80"/> <border displayrows="true" cols="17" displaycols="true" colsize="60" rows="8" rowsize="80"/>
<inset title="" folio="" author="" filename="" date="null"/> <inset title="" folio="" author="" filename="" date="null"/>
<conductors num="_" vertirotatetext="0" displaytext="1" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/> <conductors num="_" type="multi"/>
<report label="/%f.%l%c"/>
<xrefs>
<xref snapto="label" switchprefix="" powerprefix="" displayhas="contacts" type="protection" showpowerctc="false" delayprefix=""/>
<xref snapto="bottom" switchprefix="" powerprefix="" displayhas="cross" type="coil" showpowerctc="false" delayprefix=""/>
</xrefs>
<conductors_autonums/>
</newdiagrams> </newdiagrams>
<diagram title="Exemple Moteur double sens" displayrows="true" cols="15" folio="" displaycols="true" height="500" colsize="50" order="1" rows="6" author="Benoît A" filename="Exemples QET" rowsize="80"> <diagram title="Exemple Moteur double sens" displayrows="true" cols="15" folio="" displaycols="true" height="500" colsize="50" order="1" rows="6" author="Benoît A" filename="Exemples QET" rowsize="80">
<defaultconductor type="simple"/> <defaultconductor type="simple"/>

View File

@@ -1,482 +1,439 @@
<project folioSheetQuantity="0" title="" version="0.4"> <project title="" version="0.3">
<properties/> <properties/>
<newdiagrams> <newdiagrams>
<border displayrows="true" cols="15" displaycols="true" colsize="50" rows="6" rowsize="80"/> <border displayrows="true" cols="15" displaycols="true" colsize="50" rows="6" rowsize="80"/>
<inset title="" folio="%id/%total" author="" filename="" date="null"/> <inset title="" folio="%id/%total" author="" filename="" date="null"/>
<conductors num="_" vertirotatetext="0" displaytext="1" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/> <conductors num="_" vertirotatetext="0" type="multi" horizrotatetext="0"/>
<report label="/%f.%l%c"/>
<xrefs>
<xref snapto="label" switchprefix="" powerprefix="" displayhas="contacts" type="protection" showpowerctc="false" delayprefix=""/>
<xref snapto="bottom" switchprefix="" powerprefix="" displayhas="cross" type="coil" showpowerctc="false" delayprefix=""/>
</xrefs>
<conductors_autonums/>
</newdiagrams> </newdiagrams>
<diagram title="General" displayrows="true" version="0.4" cols="15" folio="%id/%total" displaycols="true" height="500" colsize="50" order="1" rows="6" author="" filename="" date="null" rowsize="80"> <diagram title="General" displayrows="true" cols="15" folio="%id/%total" displaycols="true" height="500" colsize="50" order="1" rows="6" author="" filename="" rowsize="80">
<defaultconductor num="_" vertirotatetext="0" displaytext="1" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/> <defaultconductor num="_" type="multi"/>
<elements> <elements>
<element x="220" y="60" type="embed://import/grafcet2/etape_initiale.elmt" uuid="{290895c8-ebd6-48a0-bce2-fb5ec0e47051}" orientation="0"> <element x="220" y="370" type="embed://import/grafcet/etape.elmt" orientation="0">
<terminals> <terminals>
<terminal x="0" y="21" nameHidden="0" number="" id="0" name="" orientation="2"/> <terminal x="0" y="-21" id="0" orientation="0"/>
</terminals> <terminal x="0" y="21" id="1" orientation="2"/>
<inputs> <terminal x="36" y="-10" id="2" orientation="1"/>
<input x="-30" y="14" text=""/>
<input x="-20" y="0" text="E 00"/>
</inputs>
</element>
<element x="220" y="130" type="embed://import/grafcet2/et.elmt" uuid="{d7760ee4-d015-4bfb-abf4-e29200a216ef}" orientation="0">
<terminals>
<terminal x="0" y="1" nameHidden="0" number="" id="1" name="" orientation="0"/>
<terminal x="4" y="-2" nameHidden="0" number="" id="2" name="" orientation="1"/>
<terminal x="4" y="2" nameHidden="0" number="" id="3" name="" orientation="1"/>
<terminal x="0" y="-1" nameHidden="0" number="" id="4" name="" orientation="2"/>
</terminals>
<inputs/>
</element>
<element x="260" y="160" type="embed://import/grafcet/actions/action.elmt" uuid="{bb97e0c4-140c-49f4-ba51-3fb12c4335b8}" orientation="0">
<terminals>
<terminal x="6" y="0" nameHidden="0" number="" id="5" name="" orientation="3"/>
</terminals>
<inputs>
<input x="8" y="2" text="motor on"/>
</inputs>
</element>
<element x="220" y="420" type="embed://import/grafcet/saut.elmt" uuid="{0208f0ad-81ff-4937-bc00-bd2c3c50db7f}" orientation="0">
<terminals>
<terminal x="0" y="-1" nameHidden="0" number="" id="6" name="" orientation="0"/>
<terminal x="-8" y="0" nameHidden="0" number="" id="7" name="" orientation="3"/>
</terminals>
<inputs>
<input x="-15" y="45" text="E 00"/>
<input x="15" y="2" text="T 03"/>
</inputs>
</element>
<element x="220" y="170" type="embed://import/grafcet2/etape.elmt" uuid="{12113ca8-85f5-4358-8548-fe386fa41760}" orientation="0">
<terminals>
<terminal x="0" y="-21" nameHidden="0" number="" id="8" name="" orientation="0"/>
<terminal x="0" y="21" nameHidden="0" number="" id="9" name="" orientation="2"/>
<terminal x="36" y="-10" nameHidden="0" number="" id="10" name="" orientation="1"/>
</terminals>
<inputs>
<input x="-30" y="14" text=""/>
<input x="-20" y="0" text="E 01"/>
</inputs>
</element>
<element x="490" y="150" type="embed://import/grafcet/actions/action.elmt" uuid="{c09ec501-48a7-4171-b6a5-3ef1f5880177}" orientation="0">
<terminals>
<terminal x="6" y="0" nameHidden="0" number="" id="11" name="" orientation="3"/>
</terminals>
<inputs>
<input x="8" y="2" text="lubrification on"/>
</inputs>
</element>
<element x="440" y="170" type="embed://import/grafcet2/etape.elmt" uuid="{4f75422f-9751-4bb8-98b5-8fd87e5f062c}" orientation="0">
<terminals>
<terminal x="0" y="-21" nameHidden="0" number="" id="12" name="" orientation="0"/>
<terminal x="0" y="21" nameHidden="0" number="" id="13" name="" orientation="2"/>
<terminal x="36" y="-10" nameHidden="0" number="" id="14" name="" orientation="1"/>
</terminals>
<inputs>
<input x="-30" y="14" text=""/>
<input x="-20" y="0" text="E 02"/>
</inputs>
</element>
<element x="220" y="110" type="embed://import/grafcet2/transition.elmt" uuid="{dc46b143-bf5e-4003-be77-f0f80bfcca64}" orientation="0">
<terminals>
<terminal x="0" y="1" nameHidden="0" number="" id="15" name="" orientation="2"/>
<terminal x="0" y="-1" nameHidden="0" number="" id="16" name="" orientation="0"/>
<terminal x="-8" y="0" nameHidden="0" number="" id="17" name="" orientation="3"/>
</terminals>
<inputs>
<input x="15" y="2" text="T 00"/>
</inputs>
</element>
<element x="280" y="360" type="embed://import/grafcet/actions/action.elmt" uuid="{bcc8a9ca-948b-4074-83a3-e4853e2f210c}" orientation="0">
<terminals>
<terminal x="6" y="0" nameHidden="0" number="" id="18" name="" orientation="3"/>
</terminals>
<inputs>
<input x="8" y="2" text="motor off"/>
</inputs>
</element>
<element x="220" y="280" type="embed://import/grafcet2/macro/etape.elmt" uuid="{1944db54-0a05-4305-8f66-b8ce2c6ed487}" orientation="0">
<terminals>
<terminal x="-8" y="39.6667" nameHidden="0" number="" id="19" name="" orientation="3"/>
<terminal x="0" y="40.6667" nameHidden="0" number="" id="20" name="" orientation="2"/>
<terminal x="0" y="-21" nameHidden="0" number="" id="21" name="" orientation="0"/>
</terminals>
<inputs>
<input x="18" y="42" text="1"/>
<input x="18" y="42" text="1"/>
<input x="-30" y="13.6667" text=""/>
<input x="-20" y="-0.333333" text="M 03"/>
</inputs>
</element>
<element x="220" y="230" type="embed://import/grafcet2/transition.elmt" uuid="{578bf044-62aa-4ed7-b9ac-762b8a88d129}" orientation="0">
<terminals>
<terminal x="0" y="1" nameHidden="0" number="" id="22" name="" orientation="2"/>
<terminal x="0" y="-1" nameHidden="0" number="" id="23" name="" orientation="0"/>
<terminal x="-8" y="0" nameHidden="0" number="" id="24" name="" orientation="3"/>
</terminals>
<inputs>
<input x="15" y="2" text="T 02"/>
</inputs>
</element>
<element x="220" y="370" type="embed://import/grafcet/etape.elmt" uuid="{b9ad5d40-37f7-4af2-b69b-12e97b0142a3}" orientation="0">
<terminals>
<terminal x="0" y="-21" nameHidden="0" number="" id="25" name="" orientation="0"/>
<terminal x="0" y="21" nameHidden="0" number="" id="26" name="" orientation="2"/>
<terminal x="36" y="-10" nameHidden="0" number="" id="27" name="" orientation="1"/>
</terminals> </terminals>
<inputs> <inputs>
<input x="-30" y="14" text=""/> <input x="-30" y="14" text=""/>
<input x="-20" y="0" text="E 06"/> <input x="-20" y="0" text="E 06"/>
</inputs> </inputs>
</element> </element>
<element x="220" y="230" type="embed://import/grafcet2/transition.elmt" orientation="0">
<terminals>
<terminal x="0" y="1" id="3" orientation="2"/>
<terminal x="0" y="-1" id="4" orientation="0"/>
<terminal x="-8" y="0" id="5" orientation="3"/>
</terminals>
<inputs>
<input x="15" y="2" text="T 02"/>
</inputs>
</element>
<element x="220" y="280" type="embed://import/grafcet2/macro/etape.elmt" orientation="0">
<terminals>
<terminal x="-8" y="39.6667" id="6" orientation="3"/>
<terminal x="0" y="40.6667" id="7" orientation="2"/>
<terminal x="0" y="-21" id="8" orientation="0"/>
</terminals>
<inputs>
<input x="-30" y="13.6667" text=""/>
<input x="-20" y="-0.333333" text="M 03"/>
</inputs>
</element>
<element x="280" y="360" type="embed://import/grafcet/actions/action.elmt" orientation="0">
<terminals>
<terminal x="6" y="0" id="9" orientation="3"/>
</terminals>
<inputs>
<input x="8" y="2" text="motor off"/>
</inputs>
</element>
<element x="220" y="110" type="embed://import/grafcet2/transition.elmt" orientation="0">
<terminals>
<terminal x="0" y="1" id="10" orientation="2"/>
<terminal x="0" y="-1" id="11" orientation="0"/>
<terminal x="-8" y="0" id="12" orientation="3"/>
</terminals>
<inputs>
<input x="15" y="2" text="T 00"/>
</inputs>
</element>
<element x="440" y="170" type="embed://import/grafcet2/etape.elmt" orientation="0">
<terminals>
<terminal x="0" y="-21" id="13" orientation="0"/>
<terminal x="0" y="21" id="14" orientation="2"/>
<terminal x="36" y="-10" id="15" orientation="1"/>
</terminals>
<inputs>
<input x="-30" y="14" text=""/>
<input x="-20" y="0" text="E 02"/>
</inputs>
</element>
<element x="490" y="150" type="embed://import/grafcet/actions/action.elmt" orientation="0">
<terminals>
<terminal x="6" y="0" id="16" orientation="3"/>
</terminals>
<inputs>
<input x="8" y="2" text="lubrification on"/>
</inputs>
</element>
<element x="220" y="170" type="embed://import/grafcet2/etape.elmt" orientation="0">
<terminals>
<terminal x="0" y="-21" id="17" orientation="0"/>
<terminal x="0" y="21" id="18" orientation="2"/>
<terminal x="36" y="-10" id="19" orientation="1"/>
</terminals>
<inputs>
<input x="-30" y="14" text=""/>
<input x="-20" y="0" text="E 01"/>
</inputs>
</element>
<element x="220" y="420" type="embed://import/grafcet/saut.elmt" orientation="0">
<terminals>
<terminal x="0" y="-1" id="20" orientation="0"/>
<terminal x="-8" y="0" id="21" orientation="3"/>
</terminals>
<inputs>
<input x="-15" y="45" text="E 00"/>
<input x="15" y="2" text="T 03"/>
</inputs>
</element>
<element x="260" y="160" type="embed://import/grafcet/actions/action.elmt" orientation="0">
<terminals>
<terminal x="6" y="0" id="22" orientation="3"/>
</terminals>
<inputs>
<input x="8" y="2" text="motor on"/>
</inputs>
</element>
<element x="220" y="130" type="embed://import/grafcet2/et.elmt" orientation="0">
<terminals>
<terminal x="0" y="1" id="23" orientation="0"/>
<terminal x="4" y="-2" id="24" orientation="1"/>
<terminal x="4" y="2" id="25" orientation="1"/>
<terminal x="0" y="-1" id="26" orientation="2"/>
</terminals>
<inputs/>
</element>
<element x="220" y="60" type="embed://import/grafcet2/etape_initiale.elmt" orientation="0">
<terminals>
<terminal x="0" y="21" id="27" orientation="2"/>
</terminals>
<inputs>
<input x="-30" y="14" text=""/>
<input x="-20" y="0" text="E 00"/>
</inputs>
</element>
</elements> </elements>
<conductors> <conductors>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="14" terminal2="11" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/> <conductor num="_" terminal1="10" terminal2="26" type="multi"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="3" terminal2="12" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/> <conductor num="_" terminal1="7" terminal2="0" type="multi"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="4" terminal2="8" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/> <conductor num="_" terminal1="3" terminal2="8" type="multi"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="2" terminal2="12" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/> <conductor num="_" terminal1="18" terminal2="4" type="multi"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="26" terminal2="6" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/> <conductor num="_" terminal1="14" terminal2="4" type="multi"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="0" terminal2="16" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/> <conductor num="_" terminal1="9" terminal2="2" type="multi"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="18" terminal2="27" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/> <conductor num="_" terminal1="27" terminal2="11" type="multi"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="13" terminal2="23" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/> <conductor num="_" terminal1="1" terminal2="20" type="multi"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="9" terminal2="23" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/> <conductor num="_" terminal1="24" terminal2="13" type="multi"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="22" terminal2="21" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/> <conductor num="_" terminal1="26" terminal2="17" type="multi"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="20" terminal2="25" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/> <conductor num="_" terminal1="25" terminal2="13" type="multi"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="15" terminal2="4" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/> <conductor num="_" terminal1="15" terminal2="16" type="multi"/>
</conductors> </conductors>
</diagram> </diagram>
<diagram title="Macro 3" displayrows="true" version="0.4" cols="15" folio="%id/%total" displaycols="true" height="500" colsize="50" order="2" rows="6" author="" filename="" date="null" rowsize="80"> <diagram title="Macro 3" displayrows="true" cols="15" folio="%id/%total" displaycols="true" height="500" colsize="50" order="2" rows="6" author="" filename="" rowsize="80">
<defaultconductor num="_" vertirotatetext="0" displaytext="1" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/> <defaultconductor num="_" type="multi"/>
<elements> <elements>
<element x="460" y="310" type="embed://import/grafcet2/etape.elmt" uuid="{3ba984a9-4ca5-4fa2-9a11-85c41ddb349b}" orientation="0"> <element x="460" y="160" type="embed://import/grafcet2/etape.elmt" orientation="0">
<terminals> <terminals>
<terminal x="0" y="-21" nameHidden="0" number="" id="0" name="" orientation="0"/> <terminal x="0" y="-21" id="0" orientation="0"/>
<terminal x="0" y="21" nameHidden="0" number="" id="1" name="" orientation="2"/> <terminal x="0" y="21" id="1" orientation="2"/>
<terminal x="36" y="-10" nameHidden="0" number="" id="2" name="" orientation="1"/> <terminal x="36" y="-10" id="2" orientation="1"/>
</terminals>
<inputs>
<input x="-30" y="14" text=""/>
<input x="-20" y="0" text="E 05"/>
</inputs>
</element>
<element x="170" y="350" type="embed://import/automatisme/fonction/entree.elmt" uuid="{12483728-267f-4c2f-b7ea-4ef02acb67b1}" orientation="0">
<terminals>
<terminal x="36" y="0" nameHidden="0" number="" id="3" name="" orientation="1"/>
</terminals>
<inputs>
<input x="25" y="-10" text="_"/>
<input x="-25" y="50" text="_"/>
<input x="-2" y="5" text="I"/>
<input x="-2" y="5" text="I"/>
</inputs>
</element>
<element x="340" y="390" type="embed://import/automatisme/fonction/ou.elmt" uuid="{546bea81-a292-4105-8d0b-e696cbe2b71a}" orientation="0">
<terminals>
<terminal x="36" y="0" nameHidden="0" number="" id="4" name="" orientation="1"/>
<terminal x="-36" y="-20" nameHidden="0" number="" id="5" name="" orientation="3"/>
<terminal x="-36" y="20" nameHidden="0" number="" id="6" name="" orientation="3"/>
</terminals>
<inputs>
<input x="-46" y="10" text="_"/>
<input x="-46" y="-30" text="_"/>
<input x="25" y="-10" text="_"/>
<input x="-25" y="50" text="_"/>
<input x="-11.5" y="5" text="≥1"/>
<input x="-11.5" y="5" text="≥1"/>
</inputs>
</element>
<element x="460" y="460" type="embed://import/grafcet2/macro/etape_sortie.elmt" uuid="{16ff747c-27ef-4d71-a637-e69948ec7778}" orientation="0">
<terminals>
<terminal x="0" y="-21" nameHidden="0" number="" id="7" name="" orientation="0"/>
</terminals>
<inputs>
<input x="-30" y="14" text=""/>
<input x="-20" y="0" text="S 03"/>
</inputs>
</element>
<element x="170" y="430" type="embed://import/automatisme/fonction/entree.elmt" uuid="{901dcb49-d67c-459d-98dc-f77992b63bfb}" orientation="0">
<terminals>
<terminal x="36" y="0" nameHidden="0" number="" id="8" name="" orientation="1"/>
</terminals>
<inputs>
<input x="25" y="-10" text="_"/>
<input x="-25" y="50" text="_"/>
<input x="-2" y="5" text="I"/>
<input x="-2" y="5" text="I"/>
</inputs>
</element>
<element x="330" y="220" type="embed://import/automatisme/fonction/et.elmt" uuid="{dff2338c-a7d0-4c8e-95bd-fde0887d0b1b}" orientation="0">
<terminals>
<terminal x="36" y="0" nameHidden="0" number="" id="9" name="" orientation="1"/>
<terminal x="-36" y="-20" nameHidden="0" number="" id="10" name="" orientation="3"/>
<terminal x="-36" y="20" nameHidden="0" number="" id="11" name="" orientation="3"/>
</terminals>
<inputs>
<input x="-46" y="10" text="_"/>
<input x="-46" y="-30" text="_"/>
<input x="25" y="-10" text="_"/>
<input x="-25" y="50" text="_"/>
<input x="-6" y="5" text="&amp;"/>
<input x="-6" y="5" text="&amp;"/>
</inputs>
</element>
<element x="520" y="170" type="embed://import/grafcet/actions/continue.elmt" uuid="{b216ef62-54ea-4a6b-9900-1987a932f765}" orientation="0">
<terminals>
<terminal x="7" y="0" nameHidden="0" number="" id="12" name="" orientation="3"/>
</terminals>
<inputs>
<input x="25" y="2" text="action"/>
<input x="8" y="3" text="="/>
<input x="8" y="3" text="="/>
</inputs>
</element>
<element x="520" y="300" type="embed://import/grafcet/actions/continue.elmt" uuid="{f962fd78-860d-4193-b517-d06bac16cbf5}" orientation="0">
<terminals>
<terminal x="7" y="0" nameHidden="0" number="" id="13" name="" orientation="3"/>
</terminals>
<inputs>
<input x="25" y="2" text="action"/>
<input x="8" y="3" text="="/>
<input x="8" y="3" text="="/>
</inputs>
</element>
<element x="460" y="220" type="embed://import/grafcet2/transition.elmt" uuid="{3c0fd8ce-8b1f-4f6f-ab43-1d22d4e6b5d8}" orientation="0">
<terminals>
<terminal x="0" y="1" nameHidden="0" number="" id="14" name="" orientation="2"/>
<terminal x="0" y="-1" nameHidden="0" number="" id="15" name="" orientation="0"/>
<terminal x="-8" y="0" nameHidden="0" number="" id="16" name="" orientation="3"/>
</terminals>
<inputs>
<input x="15" y="2" text="T 30"/>
</inputs>
</element>
<element x="520" y="150" type="embed://import/grafcet/actions/continue.elmt" uuid="{c154f8fa-ee5a-4400-a419-dc5aaaddd6a2}" orientation="0">
<terminals>
<terminal x="7" y="0" nameHidden="0" number="" id="17" name="" orientation="3"/>
</terminals>
<inputs>
<input x="25" y="2" text="action"/>
<input x="8" y="3" text="="/>
<input x="8" y="3" text="="/>
</inputs>
</element>
<element x="460" y="70" type="embed://import/grafcet2/macro/etape_entree.elmt" uuid="{b6a9dba6-bded-458f-a948-d0f34ec92671}" orientation="0">
<terminals>
<terminal x="0" y="41" nameHidden="0" number="" id="18" name="" orientation="2"/>
<terminal x="-8" y="40" nameHidden="0" number="" id="19" name="" orientation="3"/>
</terminals>
<inputs>
<input x="19" y="42" text="1"/>
<input x="19" y="42" text="1"/>
<input x="-30" y="14" text=""/>
<input x="-20" y="0" text="E 03"/>
</inputs>
</element>
<element x="170" y="180" type="embed://import/automatisme/fonction/entree.elmt" uuid="{dcc4fd4d-cfa8-4f72-9990-a5ae8e83307d}" orientation="0">
<terminals>
<terminal x="36" y="0" nameHidden="0" number="" id="20" name="" orientation="1"/>
</terminals>
<inputs>
<input x="25" y="-10" text="_"/>
<input x="-25" y="50" text="_"/>
<input x="-2" y="5" text="I"/>
<input x="-2" y="5" text="I"/>
</inputs>
</element>
<element x="520" y="160" type="embed://import/grafcet/actions/continue.elmt" uuid="{91b0d252-9167-4feb-baf1-25120b97a3ae}" orientation="0">
<terminals>
<terminal x="7" y="0" nameHidden="0" number="" id="21" name="" orientation="3"/>
</terminals>
<inputs>
<input x="25" y="2" text="action"/>
<input x="8" y="3" text="="/>
<input x="8" y="3" text="="/>
</inputs>
</element>
<element x="170" y="260" type="embed://import/automatisme/fonction/entree.elmt" uuid="{82fd394e-304e-44c8-a695-c1cda10c3e21}" orientation="0">
<terminals>
<terminal x="36" y="0" nameHidden="0" number="" id="22" name="" orientation="1"/>
</terminals>
<inputs>
<input x="25" y="-10" text="_"/>
<input x="-25" y="50" text="_"/>
<input x="-2" y="5" text="I"/>
<input x="-2" y="5" text="I"/>
</inputs>
</element>
<element x="460" y="390" type="embed://import/grafcet2/transition.elmt" uuid="{bdb1cc69-7e03-4f4f-a4fc-c11413f16278}" orientation="0">
<terminals>
<terminal x="0" y="1" nameHidden="0" number="" id="23" name="" orientation="2"/>
<terminal x="0" y="-1" nameHidden="0" number="" id="24" name="" orientation="0"/>
<terminal x="-8" y="0" nameHidden="0" number="" id="25" name="" orientation="3"/>
</terminals>
<inputs>
<input x="15" y="2" text="T 31"/>
</inputs>
</element>
<element x="460" y="160" type="embed://import/grafcet2/etape.elmt" uuid="{68ae6a60-f2ae-4c1b-99c9-1993b2964eb4}" orientation="0">
<terminals>
<terminal x="0" y="-21" nameHidden="0" number="" id="26" name="" orientation="0"/>
<terminal x="0" y="21" nameHidden="0" number="" id="27" name="" orientation="2"/>
<terminal x="36" y="-10" nameHidden="0" number="" id="28" name="" orientation="1"/>
</terminals> </terminals>
<inputs> <inputs>
<input x="-30" y="14" text=""/> <input x="-30" y="14" text=""/>
<input x="-20" y="0" text="E 04"/> <input x="-20" y="0" text="E 04"/>
</inputs> </inputs>
</element> </element>
</elements> <element x="460" y="390" type="embed://import/grafcet2/transition.elmt" orientation="0">
<conductors>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="3" terminal2="5" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="4" terminal2="25" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="8" terminal2="6" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="20" terminal2="10" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="22" terminal2="11" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="23" terminal2="7" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="28" terminal2="21" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="24" terminal2="1" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="2" terminal2="13" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="18" terminal2="26" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="27" terminal2="15" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="28" terminal2="17" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="9" terminal2="16" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="12" terminal2="28" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="14" terminal2="0" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/>
</conductors>
</diagram>
<diagram title="Conditions" displayrows="true" version="0.4" cols="15" folio="%id/%total" displaycols="true" height="500" colsize="50" order="3" rows="6" author="" filename="" date="null" rowsize="80">
<defaultconductor num="_" vertirotatetext="0" displaytext="1" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/>
<elements>
<element x="450" y="400" type="embed://import/automatisme/lader/output/sortie.elmt" uuid="{3a059f35-2597-48b7-9730-c399198908c5}" orientation="0">
<terminals> <terminals>
<terminal x="-20" y="0" nameHidden="0" number="" id="0" name="" orientation="3"/> <terminal x="0" y="1" id="3" orientation="2"/>
<terminal x="0" y="-1" id="4" orientation="0"/>
<terminal x="-8" y="0" id="5" orientation="3"/>
</terminals> </terminals>
<inputs> <inputs>
<input x="-18" y="-10" text="T03_"/> <input x="15" y="2" text="T 31"/>
</inputs> </inputs>
</element> </element>
<element x="290" y="430" type="embed://import/automatisme/lader/input/entree.elmt" uuid="{c5876a7c-c5c3-4842-baee-050f23a81f6d}" orientation="0"> <element x="170" y="260" type="embed://import/automatisme/fonction/entree.elmt" orientation="0">
<terminals> <terminals>
<terminal x="20" y="0" nameHidden="0" number="" id="1" name="" orientation="1"/> <terminal x="36" y="0" id="6" orientation="1"/>
<terminal x="-20" y="0" nameHidden="0" number="" id="2" name="" orientation="3"/>
</terminals> </terminals>
<inputs> <inputs>
<input x="-18" y="-10" text="Arrêt urgence"/>
</inputs>
</element>
<element x="200" y="400" type="embed://import/sources/multifilaire/src_p.elmt" uuid="{486f95db-99d4-4148-b8c4-cb7ab5e3ab1d}" orientation="0">
<terminals>
<terminal x="6" y="0" nameHidden="0" number="" id="3" name="" orientation="1"/>
</terminals>
<inputs>
<input x="-12" y="3" text="L"/>
<input x="-12" y="3" text="L"/>
</inputs>
</element>
<element x="290" y="370" type="embed://import/automatisme/lader/input/entree.elmt" uuid="{6046d2e7-4cab-4e46-8d15-1ccebefabd3d}" orientation="0">
<terminals>
<terminal x="20" y="0" nameHidden="0" number="" id="4" name="" orientation="1"/>
<terminal x="-20" y="0" nameHidden="0" number="" id="5" name="" orientation="3"/>
</terminals>
<inputs>
<input x="-18" y="-10" text="Bouton stop"/>
</inputs>
</element>
<element x="190" y="100" type="embed://import/automatisme/fonction/entree.elmt" uuid="{9681f5f3-8ad4-4fef-b6fe-501ab028fc1f}" orientation="0">
<terminals>
<terminal x="36" y="0" nameHidden="0" number="" id="6" name="" orientation="1"/>
</terminals>
<inputs>
<input x="25" y="-10" text="_"/>
<input x="-25" y="50" text="Bouton start"/>
<input x="-2" y="5" text="I"/>
<input x="-2" y="5" text="I"/>
</inputs>
</element>
<element x="190" y="220" type="embed://import/automatisme/fonction/entree.elmt" uuid="{1b95c847-07a9-465c-ad5c-095b93bc3d06}" orientation="0">
<terminals>
<terminal x="36" y="0" nameHidden="0" number="" id="7" name="" orientation="1"/>
</terminals>
<inputs>
<input x="25" y="-10" text="_"/>
<input x="-25" y="50" text="Arrêt urgence"/>
<input x="-2" y="5" text="I"/>
<input x="-2" y="5" text="I"/>
</inputs>
</element>
<element x="310" y="220" type="embed://import/automatisme/fonction/non.elmt" uuid="{2ff0c5b1-dd75-4660-b5b5-13df9a365c93}" orientation="0">
<terminals>
<terminal x="-36" y="0" nameHidden="0" number="" id="8" name="" orientation="3"/>
<terminal x="36" y="0" nameHidden="0" number="" id="9" name="" orientation="1"/>
</terminals>
<inputs>
<input x="-46" y="-10" text="_"/>
<input x="25" y="-10" text="_"/> <input x="25" y="-10" text="_"/>
<input x="-25" y="50" text="_"/> <input x="-25" y="50" text="_"/>
<input x="-5" y="5" text="1"/>
<input x="-5" y="5" text="1"/>
</inputs> </inputs>
</element> </element>
<element x="560" y="160" type="embed://import/automatisme/fonction/sortie.elmt" uuid="{2d78796c-4495-4030-8548-acbdfbefbbc0}" orientation="0"> <element x="520" y="160" type="embed://import/grafcet/actions/continue.elmt" orientation="0">
<terminals> <terminals>
<terminal x="-36" y="0" nameHidden="0" number="" id="10" name="" orientation="3"/> <terminal x="7" y="0" id="7" orientation="3"/>
</terminals> </terminals>
<inputs> <inputs>
<input x="-46" y="-10" text="_"/> <input x="25" y="2" text="action"/>
<input x="-25" y="50" text="T01"/>
<input x="-6.5" y="5" text="Q"/>
<input x="-6.5" y="5" text="Q"/>
</inputs> </inputs>
</element> </element>
<element x="420" y="160" type="embed://import/automatisme/fonction/et.elmt" uuid="{39e1f6ea-04f2-4d8f-877e-02cfb7b60f36}" orientation="0"> <element x="170" y="180" type="embed://import/automatisme/fonction/entree.elmt" orientation="0">
<terminals> <terminals>
<terminal x="36" y="0" nameHidden="0" number="" id="11" name="" orientation="1"/> <terminal x="36" y="0" id="8" orientation="1"/>
<terminal x="-36" y="-20" nameHidden="0" number="" id="12" name="" orientation="3"/> </terminals>
<terminal x="-36" y="20" nameHidden="0" number="" id="13" name="" orientation="3"/> <inputs>
<input x="25" y="-10" text="_"/>
<input x="-25" y="50" text="_"/>
</inputs>
</element>
<element x="460" y="70" type="embed://import/grafcet2/macro/etape_entree.elmt" orientation="0">
<terminals>
<terminal x="0" y="41" id="9" orientation="2"/>
<terminal x="-8" y="40" id="10" orientation="3"/>
</terminals>
<inputs>
<input x="-30" y="14" text=""/>
<input x="-20" y="0" text="E 03"/>
</inputs>
</element>
<element x="520" y="150" type="embed://import/grafcet/actions/continue.elmt" orientation="0">
<terminals>
<terminal x="7" y="0" id="11" orientation="3"/>
</terminals>
<inputs>
<input x="25" y="2" text="action"/>
</inputs>
</element>
<element x="460" y="220" type="embed://import/grafcet2/transition.elmt" orientation="0">
<terminals>
<terminal x="0" y="1" id="12" orientation="2"/>
<terminal x="0" y="-1" id="13" orientation="0"/>
<terminal x="-8" y="0" id="14" orientation="3"/>
</terminals>
<inputs>
<input x="15" y="2" text="T 30"/>
</inputs>
</element>
<element x="520" y="300" type="embed://import/grafcet/actions/continue.elmt" orientation="0">
<terminals>
<terminal x="7" y="0" id="15" orientation="3"/>
</terminals>
<inputs>
<input x="25" y="2" text="action"/>
</inputs>
</element>
<element x="520" y="170" type="embed://import/grafcet/actions/continue.elmt" orientation="0">
<terminals>
<terminal x="7" y="0" id="16" orientation="3"/>
</terminals>
<inputs>
<input x="25" y="2" text="action"/>
</inputs>
</element>
<element x="330" y="220" type="embed://import/automatisme/fonction/et.elmt" orientation="0">
<terminals>
<terminal x="36" y="0" id="17" orientation="1"/>
<terminal x="-36" y="-20" id="18" orientation="3"/>
<terminal x="-36" y="20" id="19" orientation="3"/>
</terminals> </terminals>
<inputs> <inputs>
<input x="-46" y="10" text="_"/> <input x="-46" y="10" text="_"/>
<input x="-46" y="-30" text="_"/> <input x="-46" y="-30" text="_"/>
<input x="25" y="-10" text="_"/> <input x="25" y="-10" text="_"/>
<input x="-25" y="50" text="_"/> <input x="-25" y="50" text="_"/>
<input x="-6" y="5" text="&amp;"/> </inputs>
<input x="-6" y="5" text="&amp;"/> </element>
<element x="170" y="430" type="embed://import/automatisme/fonction/entree.elmt" orientation="0">
<terminals>
<terminal x="36" y="0" id="20" orientation="1"/>
</terminals>
<inputs>
<input x="25" y="-10" text="_"/>
<input x="-25" y="50" text="_"/>
</inputs>
</element>
<element x="460" y="460" type="embed://import/grafcet2/macro/etape_sortie.elmt" orientation="0">
<terminals>
<terminal x="0" y="-21" id="21" orientation="0"/>
</terminals>
<inputs>
<input x="-30" y="14" text=""/>
<input x="-20" y="0" text="S 03"/>
</inputs>
</element>
<element x="340" y="390" type="embed://import/automatisme/fonction/ou.elmt" orientation="0">
<terminals>
<terminal x="36" y="0" id="22" orientation="1"/>
<terminal x="-36" y="-20" id="23" orientation="3"/>
<terminal x="-36" y="20" id="24" orientation="3"/>
</terminals>
<inputs>
<input x="-46" y="10" text="_"/>
<input x="-46" y="-30" text="_"/>
<input x="25" y="-10" text="_"/>
<input x="-25" y="50" text="_"/>
</inputs>
</element>
<element x="170" y="350" type="embed://import/automatisme/fonction/entree.elmt" orientation="0">
<terminals>
<terminal x="36" y="0" id="25" orientation="1"/>
</terminals>
<inputs>
<input x="25" y="-10" text="_"/>
<input x="-25" y="50" text="_"/>
</inputs>
</element>
<element x="460" y="310" type="embed://import/grafcet2/etape.elmt" orientation="0">
<terminals>
<terminal x="0" y="-21" id="26" orientation="0"/>
<terminal x="0" y="21" id="27" orientation="2"/>
<terminal x="36" y="-10" id="28" orientation="1"/>
</terminals>
<inputs>
<input x="-30" y="14" text=""/>
<input x="-20" y="0" text="E 05"/>
</inputs> </inputs>
</element> </element>
</elements> </elements>
<conductors> <conductors>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="4" terminal2="0" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/> <conductor num="_" terminal1="12" terminal2="26" type="multi"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="1" terminal2="0" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"> <conductor num="_" terminal1="16" terminal2="2" type="multi"/>
<segment length="0" orientation="horizontal"/> <conductor num="_" terminal1="17" terminal2="14" type="multi"/>
<segment length="56" orientation="horizontal"/> <conductor num="_" terminal1="2" terminal2="11" type="multi"/>
<segment length="-30" orientation="vertical"/> <conductor num="_" terminal1="1" terminal2="13" type="multi"/>
<segment length="56" orientation="horizontal"/> <conductor num="_" terminal1="9" terminal2="0" type="multi"/>
<segment length="0" orientation="horizontal"/> <conductor num="_" terminal1="28" terminal2="15" type="multi"/>
</conductor> <conductor num="_" terminal1="4" terminal2="27" type="multi"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="5" terminal2="2" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"> <conductor num="_" terminal1="2" terminal2="7" type="multi"/>
<segment length="-9" orientation="horizontal"/> <conductor num="_" terminal1="3" terminal2="21" type="multi"/>
<segment length="-27" orientation="horizontal"/> <conductor num="_" terminal1="6" terminal2="19" type="multi"/>
<segment length="60" orientation="vertical"/> <conductor num="_" terminal1="8" terminal2="18" type="multi"/>
<segment length="27" orientation="horizontal"/> <conductor num="_" terminal1="20" terminal2="24" type="multi"/>
<segment length="9" orientation="horizontal"/> <conductor num="_" terminal1="22" terminal2="5" type="multi"/>
</conductor> <conductor num="_" terminal1="25" terminal2="23" type="multi"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="6" terminal2="12" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/> </conductors>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="7" terminal2="8" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/> </diagram>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="9" terminal2="13" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/> <diagram title="Conditions" displayrows="true" cols="15" folio="%id/%total" displaycols="true" height="500" colsize="50" order="3" rows="6" author="" filename="" rowsize="80">
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="11" terminal2="10" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"/> <defaultconductor num="_" type="multi"/>
<conductor num="_" vertirotatetext="0" displaytext="1" terminal1="3" terminal2="5" type="multi" horizrotatetext="0" numsize="9" onetextperfolio="0"> <elements>
<element x="420" y="160" type="embed://import/automatisme/fonction/et.elmt" orientation="0">
<terminals>
<terminal x="36" y="0" id="0" orientation="1"/>
<terminal x="-36" y="-20" id="1" orientation="3"/>
<terminal x="-36" y="20" id="2" orientation="3"/>
</terminals>
<inputs>
<input x="-46" y="10" text="_"/>
<input x="-46" y="-30" text="_"/>
<input x="25" y="-10" text="_"/>
<input x="-25" y="50" text="_"/>
</inputs>
</element>
<element x="560" y="160" type="embed://import/automatisme/fonction/sortie.elmt" orientation="0">
<terminals>
<terminal x="-36" y="0" id="3" orientation="3"/>
</terminals>
<inputs>
<input x="-46" y="-10" text="_"/>
<input x="-25" y="50" text="T01"/>
</inputs>
</element>
<element x="310" y="220" type="embed://import/automatisme/fonction/non.elmt" orientation="0">
<terminals>
<terminal x="-36" y="0" id="4" orientation="3"/>
<terminal x="36" y="0" id="5" orientation="1"/>
</terminals>
<inputs>
<input x="-46" y="-10" text="_"/>
<input x="25" y="-10" text="_"/>
<input x="-25" y="50" text="_"/>
</inputs>
</element>
<element x="190" y="220" type="embed://import/automatisme/fonction/entree.elmt" orientation="0">
<terminals>
<terminal x="36" y="0" id="6" orientation="1"/>
</terminals>
<inputs>
<input x="25" y="-10" text="_"/>
<input x="-25" y="50" text="Arrêt urgence"/>
</inputs>
</element>
<element x="190" y="100" type="embed://import/automatisme/fonction/entree.elmt" orientation="0">
<terminals>
<terminal x="36" y="0" id="7" orientation="1"/>
</terminals>
<inputs>
<input x="25" y="-10" text="_"/>
<input x="-25" y="50" text="Bouton start"/>
</inputs>
</element>
<element x="290" y="370" type="embed://import/automatisme/lader/input/entree.elmt" orientation="0">
<terminals>
<terminal x="20" y="0" id="8" orientation="1"/>
<terminal x="-20" y="0" id="9" orientation="3"/>
</terminals>
<inputs>
<input x="-18" y="-10" text="Bouton stop"/>
</inputs>
</element>
<element x="200" y="400" type="embed://import/sources/multifilaire/src_p.elmt" orientation="0">
<terminals>
<terminal x="6" y="0" id="10" orientation="1"/>
</terminals>
<inputs/>
</element>
<element x="290" y="430" type="embed://import/automatisme/lader/input/entree.elmt" orientation="0">
<terminals>
<terminal x="20" y="0" id="11" orientation="1"/>
<terminal x="-20" y="0" id="12" orientation="3"/>
</terminals>
<inputs>
<input x="-18" y="-10" text="Arrêt urgence"/>
</inputs>
</element>
<element x="450" y="400" type="embed://import/automatisme/lader/output/sortie.elmt" orientation="0">
<terminals>
<terminal x="-20" y="0" id="13" orientation="3"/>
</terminals>
<inputs>
<input x="-18" y="-10" text="T03_"/>
</inputs>
</element>
</elements>
<conductors>
<conductor num="_" terminal1="10" terminal2="9" type="multi">
<segment length="9" orientation="horizontal"/> <segment length="9" orientation="horizontal"/>
<segment length="11" orientation="horizontal"/> <segment length="11" orientation="horizontal"/>
<segment length="-30" orientation="vertical"/> <segment length="-30" orientation="vertical"/>
<segment length="27" orientation="horizontal"/> <segment length="27" orientation="horizontal"/>
<segment length="9" orientation="horizontal"/> <segment length="9" orientation="horizontal"/>
</conductor> </conductor>
<conductor num="_" terminal1="0" terminal2="3" type="multi"/>
<conductor num="_" terminal1="5" terminal2="2" type="multi"/>
<conductor num="_" terminal1="6" terminal2="4" type="multi"/>
<conductor num="_" terminal1="7" terminal2="1" type="multi"/>
<conductor num="_" terminal1="9" terminal2="12" type="multi">
<segment length="-9" orientation="horizontal"/>
<segment length="-27" orientation="horizontal"/>
<segment length="60" orientation="vertical"/>
<segment length="27" orientation="horizontal"/>
<segment length="9" orientation="horizontal"/>
</conductor>
<conductor num="_" terminal1="11" terminal2="13" type="multi">
<segment length="0" orientation="horizontal"/>
<segment length="56" orientation="horizontal"/>
<segment length="-30" orientation="vertical"/>
<segment length="56" orientation="horizontal"/>
<segment length="0" orientation="horizontal"/>
</conductor>
<conductor num="_" terminal1="8" terminal2="13" type="multi"/>
</conductors> </conductors>
<inputs> <inputs>
<input x="360" y="290" text="&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;>&#xa;&lt;html>&lt;head>&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; />&lt;style type=&quot;text/css&quot;>&#xa;p, li { white-space: pre-wrap; }&#xa;&lt;/style>&lt;/head>&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;&quot;>&#xa;&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;>Condition T02 si - moteur en marche - lubrification en marche &lt;/p>&lt;/body>&lt;/html>"/> <input x="540" y="290" text="Condition T02 si&#xa; - moteur en marche&#xa; - lubrification en marche&#xa;"/>
</inputs> </inputs>
</diagram> </diagram>
<collection> <collection>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 44 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -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="589"/> <location filename="../sources/editor/qetelementeditor.cpp" line="626"/>
<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="683"/> <location filename="../sources/editor/qetelementeditor.cpp" line="720"/>
<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>

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -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,11 +74,8 @@ 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} $tagName r$revAp.dmg" ] ; then if [ -e "packaging/mac-osx/${APPNAME}_$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]"
@@ -104,8 +101,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 revision du depot svn # On modifie l'originale avec le numero de version
sed -i "" "s/const QString displayedVersion =.*/const QString displayedVersion = \"$tagName r$revAp\";/" sources/qet.h sed -i "" "s/const QString displayedVersion = \"0.4-dev\"/const QString displayedVersion = \"0.4-dev-r$revAp\"/" sources/qet.h
# Apres la compilation # Apres la compilation
cleanVerionTag () { cleanVerionTag () {
@@ -182,7 +179,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>$tagName r$revAp<\/string>/" qelectrotech.app/Contents/Info.plist sed -i "" "s/<string>Created by Qt\/QMake<\/string>/<string>0.4 dev r$revAp<\/string>/" qelectrotech.app/Contents/Info.plist
### copy over frameworks ############################################ ### copy over frameworks ############################################
@@ -244,11 +241,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} $tagName r$revAp.dmg" ] ; then if [ -e "${APPNAME}_$revAp.dmg" ] ; then
rm -f "${APPNAME} $tagName r$revAp.dmg" rm -f "${APPNAME}_$revAp.dmg"
fi fi
if [ -e "packaging/mac-osx/${APPNAME} $tagName r$revAp.dmg" ] ; then if [ -e "packaging/mac-osx/${APPNAME}_$revAp.dmg" ] ; then
rm -f "packaging/mac-osx/${APPNAME} $tagName r$revAp.dmg" rm -f "packaging/mac-osx/${APPNAME}_$revAp.dmg"
fi fi
if [ -e $imagedir ] ; then if [ -e $imagedir ] ; then
rm -rf $imagedir rm -rf $imagedir
@@ -271,13 +268,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} $tagName r$revAp.dmg" hdiutil create -quiet -ov -srcfolder $imagedir -format UDBZ -volname "${APPNAME}" "${APPNAME}_${revAp}.dmg"
hdiutil internet-enable -yes -quiet "${APPNAME} $tagName r$revAp.dmg" hdiutil internet-enable -yes -quiet "${APPNAME}_${revAp}.dmg"
# Clean up disk folder # Clean up disk folder
echo 'Cleaning up... ' echo 'Cleaning up... '
cp -Rf "${APPNAME} $tagName r$revAp.dmg" "packaging/mac-osx/${APPNAME} $tagName r$revAp.dmg" cp -Rf "${APPNAME}_$revAp.dmg" "packaging/mac-osx/${APPNAME}_$revAp.dmg"
rm -f "${APPNAME} $tagName r$revAp.dmg" rm -f "${APPNAME}_$revAp.dmg"
rm -rf $imagedir rm -rf $imagedir
rm -rf $BUNDLE rm -rf $BUNDLE
@@ -305,8 +302,6 @@ 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

View File

@@ -63,32 +63,18 @@ DEFINES += QET_ALLOW_OVERRIDE_CD_OPTION
TEMPLATE = app TEMPLATE = app
DEPENDPATH += . DEPENDPATH += .
INCLUDEPATH += sources \ INCLUDEPATH += sources sources/editor sources/titleblock sources/ui sources/qetgraphicsitem sources/richtext sources/factory sources/properties sources/dvevent
sources/titleblock \
sources/ui sources/qetgraphicsitem \
sources/richtext \
sources/factory \
sources/properties \
sources/dvevent \
sources/editor \
sources/editor/esevent \
sources/undocommand
# Fichiers sources # Fichiers sources
HEADERS += $$files(sources/*.h) $$files(sources/ui/*.h) $$files(sources/editor/*.h) $$files(sources/titleblock/*.h) $$files(sources/richtext/*.h) $$files(sources/qetgraphicsitem/*.h) $$files(sources/factory/*.h) \ HEADERS += $$files(sources/*.h) $$files(sources/ui/*.h) $$files(sources/editor/*.h) $$files(sources/titleblock/*.h) $$files(sources/richtext/*.h) $$files(sources/qetgraphicsitem/*.h) $$files(sources/factory/*.h) \
$$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/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/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

View File

@@ -180,8 +180,6 @@ QWidget *AboutQET::contributorsTab() const {
addAuthor(contributors, "Nuno Pinheiro", "nuno@nuno-icons.com", tr("Ic\364nes")); addAuthor(contributors, "Nuno Pinheiro", "nuno@nuno-icons.com", tr("Ic\364nes"));
addAuthor(contributors, "Cyril Frausti", "cyril@qelectrotech.org", tr("D\351veloppement")); addAuthor(contributors, "Cyril Frausti", "cyril@qelectrotech.org", tr("D\351veloppement"));
addAuthor(contributors, "Arun Kishore Eswara", "eswara.arun@gmail.com", tr("Documentation")); addAuthor(contributors, "Arun Kishore Eswara", "eswara.arun@gmail.com", tr("Documentation"));
addAuthor(contributors, "Ren\351 Negre", "runsys@qelectrotech.org", tr("D\351veloppement"));
addAuthor(contributors, "Ronny Desmedt", "r.desmedt@live.be", tr("D\351veloppement"));
contributors -> setOpenExternalLinks(true); contributors -> setOpenExternalLinks(true);

View File

@@ -22,7 +22,6 @@
#include "conductor.h" #include "conductor.h"
#include "diagram.h" #include "diagram.h"
#include "potentialtextsdialog.h" #include "potentialtextsdialog.h"
#include "qet.h"
/** /**
*Constructor *Constructor
@@ -52,15 +51,15 @@ void ConductorAutoNumerotation::numerate() {
* A conductor of the potential to check. * A conductor of the potential to check.
*/ */
void ConductorAutoNumerotation::checkPotential(Conductor *conductor) { void ConductorAutoNumerotation::checkPotential(Conductor *conductor) {
//fill list of potential //fill list of potential
QSet <Conductor *> c_list = conductor->relatedPotentialConductors(); QSet <Conductor *> c_list = conductor->relatedPotentialConductors();
c_list << conductor; c_list << conductor;
//fill list of text //fill list of text
QStringList strl; QStringList strl;
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 (!QET::eachStrIsEqual(strl)) { if (!eachIsEqual(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,8 +110,8 @@ void ConductorAutoNumerotation::applyText(QString t) {
void ConductorAutoNumerotation::numeratePotential() { 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 (QET::eachStrIsEqual(strl)) { if (eachIsEqual(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);
@@ -141,3 +140,13 @@ 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;
}

View File

@@ -44,4 +44,6 @@ class ConductorAutoNumerotation {
QSet <Conductor *> conductor_list; QSet <Conductor *> conductor_list;
}; };
bool eachIsEqual (const QStringList &);
#endif // CONDUCTORAUTONUMEROTATION_H #endif // CONDUCTORAUTONUMEROTATION_H

View File

@@ -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 gestes du pav\351 tactile"), projects_view_mode_); use_trackpad_ = new QCheckBox(tr("Utiliser les gestures du trackpad"), 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);

View File

@@ -41,22 +41,20 @@ 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;
/** /**
* @brief Diagram::Diagram Constructeur
* Constructor @param parent Le QObject parent du schema
* @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);
@@ -68,12 +66,18 @@ Diagram::Diagram(QETProject *project) :
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)));
//Init object for manage movement // initialise les objets gerant les deplacements
elements_mover_ = new ElementsMover(); elements_mover_ = new ElementsMover(); // deplacements d'elements/conducteurs/textes
element_texts_mover_ = new ElementTextsMover(); element_texts_mover_ = new ElementTextsMover(); // deplacements d'ElementTextItem
connect(&border_and_titleblock, SIGNAL(needTitleBlockTemplate(const QString &)), this, SLOT(setTitleBlockTemplate(const QString &))); connect(
connect(&border_and_titleblock, SIGNAL(diagramTitleChanged(const QString &)), this, SLOT(titleChanged(const QString &))); &border_and_titleblock, SIGNAL(needTitleBlockTemplate(const QString &)),
this, SLOT(setTitleBlockTemplate(const QString &))
);
connect(
&border_and_titleblock, SIGNAL(diagramTitleChanged(const QString &)),
this, SLOT(titleChanged(const QString &))
);
} }
/** /**
@@ -551,7 +555,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, &state); Element *nvel_elmt = ElementFactory::Instance()->createElement(element_location, 0, this, &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);
@@ -572,16 +576,15 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
} }
} }
// Load text // chargement de tous les textes du fichiers XML
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(); IndependentTextItem *iti = new IndependentTextItem(this);
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 ();
@@ -590,7 +593,6 @@ 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));
@@ -599,53 +601,71 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
added_shapes << dii; added_shapes << dii;
} }
// Load conductor // gere la translation des nouveaux elements et texte si celle-ci est demandee
QList<Conductor *> added_conductors; if (position != QPointF()) {
foreach (QDomElement f, QET::findInDomElement(root, "conductors", "conductor")) // determine quel est le coin superieur gauche du rectangle entourant les elements ajoutes
{ qreal minimum_x = 0, minimum_y = 0;
if (!Conductor::valideXml(f)) continue; bool init = false;
QList<QGraphicsItem *> added_items;
//Check if terminal that conductor must be linked is know foreach (Element *added_element, added_elements) added_items << added_element;
int id_p1 = f.attribute("terminal1").toInt(); foreach (DiagramTextItem *added_text, added_texts) added_items << added_text;
int id_p2 = f.attribute("terminal2").toInt(); foreach (DiagramImageItem *added_image, added_images) added_items << added_image;
if (table_adr_id.contains(id_p1) && table_adr_id.contains(id_p2)) foreach (QetShapeItem *added_shape, added_shapes) added_items << added_shape;
{ foreach (QGraphicsItem *item, added_items) {
Terminal *p1 = table_adr_id.value(id_p1); QPointF csg = item -> mapToScene(item -> boundingRect()).boundingRect().topLeft();
Terminal *p2 = table_adr_id.value(id_p2); qreal px = csg.x();
if (p1 != p2) qreal py = csg.y();
{ if (!init) {
Conductor *c = new Conductor(table_adr_id.value(id_p1), table_adr_id.value(id_p2)); minimum_x = px;
addItem(c); minimum_y = py;
c -> fromXml(f); init = true;
added_conductors << c; } else {
if (px < minimum_x) minimum_x = px;
if (py < minimum_y) minimum_y = py;
} }
} }
else qDebug() << "Diagram::fromXml() : Le chargement du conducteur" << id_p1 << id_p2 << "a echoue"; 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);
}
} }
//Translate items if a new position was given in parameter // chargement de tous les Conducteurs du fichier XML
if (position != QPointF()) { QList<Conductor *> added_conductors;
foreach (QDomElement f, QET::findInDomElement(root, "conductors", "conductor")) {
QList<QGraphicsItem *> added_items; if (!Conductor::valideXml(f)) continue;
foreach (Element *added_element, added_elements ) added_items << added_element; // verifie que les bornes que le conducteur relie sont connues
foreach (Conductor *added_cond, added_conductors) added_items << added_cond; int id_p1 = f.attribute("terminal1").toInt();
foreach (QetShapeItem *added_shape, added_shapes ) added_items << added_shape; int id_p2 = f.attribute("terminal2").toInt();
foreach (DiagramTextItem *added_text, added_texts ) added_items << added_text; if (table_adr_id.contains(id_p1) && table_adr_id.contains(id_p2)) {
foreach (DiagramImageItem *added_image, added_images ) added_items << added_image; // pose le conducteur... si c'est possible
Terminal *p1 = table_adr_id.value(id_p1);
//Get the top left corner of the rectangle that contain all added items Terminal *p2 = table_adr_id.value(id_p2);
QRectF items_rect; if (p1 != p2) {
foreach (QGraphicsItem *item, added_items) { bool can_add_conductor = true;
items_rect = items_rect.united(item -> mapToScene(item -> boundingRect()).boundingRect()); bool cia = ((Element *)p2 -> parentItem()) -> internalConnections();
} if (!cia) {
foreach(QGraphicsItem *item, p2 -> parentItem() -> children()) {
QPointF point_ = items_rect.topLeft(); if (item == p1) can_add_conductor = false;
QPointF pos_ = Diagram::snapToGrid(QPointF (position.x() - point_.x(), }
position.y() - point_.y())); }
if (can_add_conductor) {
//Translate all added items Conductor *c = new Conductor(table_adr_id.value(id_p1), table_adr_id.value(id_p2), this);
foreach (QGraphicsItem *qgi, added_items) c -> fromXml(f);
qgi -> setPos( qgi -> pos() += pos_); added_conductors << c;
}
}
} else qDebug() << "Diagram::fromXml() : Le chargement du conducteur" << id_p1 << id_p2 << "a echoue";
} }
// remplissage des listes facultatives // remplissage des listes facultatives
@@ -738,7 +758,6 @@ 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();
} }
} }
@@ -1177,22 +1196,6 @@ 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();
@@ -1210,24 +1213,18 @@ QETProject *Diagram::project() const {
/** /**
* @brief Diagram::setProject * @brief Diagram::setProject
* Set parent project of this diagram, project also become the parent QObject of this diagram * @param project: set parent project of this diagram or 0 if this diagram haven't got a parent project
* @param project new project
*/ */
void Diagram::setProject(QETProject *project) void Diagram::setProject(QETProject *project) {
{ if (project_) {
if (project_ == project) return; disconnect (project_, SIGNAL(reportPropertiesChanged(QString)), this, SIGNAL(reportPropertiesChanged(QString)));
disconnect (project_, SIGNAL(XRefPropertiesChanged()), this, SIGNAL(XRefPropertiesChanged()));
if (project_)
{
disconnect (project_, SIGNAL(reportPropertiesChanged(QString)), this, SIGNAL(reportPropertiesChanged(QString)));
disconnect (project_, SIGNAL(XRefPropertiesChanged()), this, SIGNAL(XRefPropertiesChanged()));
} }
project_ = project; project_ = project;
setParent (project); if (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())); }
} }
/** /**
@@ -1256,13 +1253,20 @@ qreal Diagram::declaredQElectroTechVersion(bool fallback_to_project) const {
} }
/** /**
* @brief Diagram::isReadOnly @return true si le schema est en lecture seule
* @return true if this diagram is read only. */
* This method is same has call Diagram::project() -> isReadOnly() bool Diagram::isReadOnly() const {
*/ return(read_only_);
bool Diagram::isReadOnly() const }
{
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_));
}
} }
/** /**

View File

@@ -47,16 +47,16 @@ 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(QETProject *project); Diagram(QObject * = 0);
virtual ~Diagram(); virtual ~Diagram();
private: private:
Diagram(const Diagram &diagram); Diagram(const Diagram &diagram);
// ATTRIBUTES // ATTRIBUTES
public: public:
@@ -97,6 +97,7 @@ 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;
@@ -119,11 +120,14 @@ class Diagram : public QGraphicsScene
// methods related to parent project // methods related to parent project
QETProject *project() const; QETProject *project() const;
void setProject(QETProject *); void setProject(QETProject *);
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);}
bool isReadOnly() const;
// methods related to read only mode
bool isReadOnly() const;
void setReadOnly(bool);
// methods related to conductor creation // methods related to conductor creation
void setConductor(bool); void setConductor(bool);
@@ -180,7 +184,6 @@ 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();
@@ -210,14 +213,17 @@ class Diagram : public QGraphicsScene
void invertSelection(); void invertSelection();
signals: signals:
void showDiagram (Diagram *); void showDiagram (Diagram *);
void written(); void written();
void usedTitleBlockTemplateChanged(const QString &); void readOnlyChanged(bool);
void diagramTitleChanged(Diagram *, const QString &); void usedTitleBlockTemplateChanged(const QString &);
void findElementRequired(const ElementsLocation &); /// Signal emitted when users wish to locate an element from the diagram within elements collection void diagramTitleChanged(Diagram *, const QString &);
void editElementRequired(const ElementsLocation &); /// Signal emitted when users wish to edit an element from the diagram /// Signal emitted when users wish to locate an element from the diagram within elements collection
void reportPropertiesChanged(QString); void findElementRequired(const ElementsLocation &);
void XRefPropertiesChanged(); /// Signal emitted when users wish to edit an element from the diagram
void editElementRequired(const ElementsLocation &);
void reportPropertiesChanged(QString);
void XRefPropertiesChanged();
}; };
Q_DECLARE_METATYPE(Diagram *) Q_DECLARE_METATYPE(Diagram *)

View File

@@ -77,22 +77,17 @@ 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);
} }
//We relink element after every element was added to diagram // remet les conducteurs
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);
} }
@@ -118,7 +113,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 have the single displayed text) //current conductor is visible (that mean the conductor own 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()) {
@@ -132,9 +127,6 @@ 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);
} }
@@ -232,13 +224,6 @@ 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

View File

@@ -101,8 +101,6 @@ 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;
}; };
/** /**

View File

@@ -96,8 +96,7 @@ 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 {

View File

@@ -24,12 +24,16 @@ qreal DiagramFolioList::colWidths[4] = {0.1, 0.55, 0.2, 0.15};
/** /**
* @brief DiagramFolioList::DiagramFolioList * @brief DiagramFolioList::DiagramFolioList
* Constructor * Constructor
* @param project : The project of this diagram and also parent QObject * @param project QETproject *: The project from which this constructor was called. Important to setProject().
* @param parent parent QObject
*/ */
DiagramFolioList::DiagramFolioList( QETProject *project) : DiagramFolioList::DiagramFolioList( QETProject *project, QObject *parent) : Diagram(parent) {
Diagram(project) if (project) {
{ setProject(project);
id = project -> getFolioSheetsQuantity(); id = project -> getFolioSheetsQuantity();
}
else
id = 0;
} }
/** /**

View File

@@ -24,7 +24,7 @@
class DiagramFolioList : public Diagram class DiagramFolioList : public Diagram
{ {
public: public:
DiagramFolioList(QETProject *project); DiagramFolioList( QETProject *project = 0, QObject *parent = 0);
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_;}

View File

@@ -48,14 +48,11 @@
@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) : DiagramView::DiagramView(Diagram *diagram, QWidget *parent) : QGraphicsView(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"
@@ -70,6 +67,7 @@ DiagramView::DiagramView(Diagram *diagram, QWidget *parent) :
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);
@@ -86,6 +84,7 @@ DiagramView::DiagramView(Diagram *diagram, QWidget *parent) :
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()));
@@ -315,7 +314,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()); IndependentTextItem *iti = new IndependentTextItem (e -> mimeData() -> text(), scene);
if (e -> mimeData() -> hasHtml()) { if (e -> mimeData() -> hasHtml()) {
iti -> setHtml (e -> mimeData() -> text()); iti -> setHtml (e -> mimeData() -> text());
@@ -864,7 +863,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, &state); Element *el = ElementFactory::Instance()->createElement(location, 0, diagram(), &state);
if (state) { if (state) {
delete el; delete el;
return(false); return(false);

View File

@@ -33,28 +33,27 @@ class DVEventInterface;
class DiagramView : public QGraphicsView { class DiagramView : public QGraphicsView {
Q_OBJECT Q_OBJECT
// constructors, destructor // constructors, destructor
public: public:
DiagramView(Diagram *diagram, QWidget * = 0); DiagramView(Diagram * = 0, QWidget * = 0);
virtual ~DiagramView(); virtual ~DiagramView();
private: private:
DiagramView(const DiagramView &); DiagramView(const DiagramView &);
// attributes
Diagram *scene;
DVEventInterface *m_event_interface;
QMenu *context_menu;
QAction *paste_here;
QAction *find_element_;
QPoint paste_here_pos;
QPoint next_position_;
QPointF center_view_;
QPointF rubber_band_origin;
bool fresh_focus_in_; ///< Indicate the focus was freshly gained
ElementsLocation next_location_;
// attributes
private:
Diagram *scene;
QMenu *context_menu;
QAction *paste_here;
QAction *find_element_;
QPoint paste_here_pos;
bool fresh_focus_in_; ///< Indicate the focus was freshly gained
ElementsLocation next_location_;
QPoint next_position_;
QPointF center_view_;
QPointF rubber_band_origin;
DVEventInterface *m_event_interface;
// methods // methods
public: public:

View File

@@ -143,9 +143,7 @@ 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.setWidthF(0.4); pen.setColor(Qt::yellow);
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,

View File

@@ -296,6 +296,7 @@ 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;
} }

View File

@@ -31,9 +31,6 @@
#include "elementcontent.h" #include "elementcontent.h"
#include "nameslist.h" #include "nameslist.h"
#include "ui/elementpropertieseditorwidget.h" #include "ui/elementpropertieseditorwidget.h"
#include "eseventinterface.h"
#include <QKeyEvent>
/** /**
Constructeur Constructeur
@@ -44,12 +41,11 @@ ElementScene::ElementScene(QETElementEditor *editor, QObject *parent) :
QGraphicsScene(parent), QGraphicsScene(parent),
m_elmt_type("simple"), m_elmt_type("simple"),
qgi_manager(this), qgi_manager(this),
m_event_interface(nullptr),
element_editor(editor), element_editor(editor),
decorator_(0) decorator_(0)
{ {
behavior = Normal;
setItemIndexMethod(NoIndex); setItemIndexMethod(NoIndex);
current_polygon = NULL;
setGrid(1, 1); setGrid(1, 1);
initPasteArea(); initPasteArea();
undo_stack.setClean(); undo_stack.setClean();
@@ -61,28 +57,88 @@ ElementScene::ElementScene(QETElementEditor *editor, QObject *parent) :
/// Destructeur /// Destructeur
ElementScene::~ElementScene() { ElementScene::~ElementScene() {
delete decorator_lock_; delete decorator_lock_;
if (m_event_interface) delete m_event_interface;
} }
/** /**
* @brief ElementScene::mouseMoveEvent Passe la scene en mode "selection et deplacement de parties"
* @param e */
*/ void ElementScene::slot_move() {
behavior = Normal;
}
/**
Passe la scene en mode "ajout de ligne"
*/
void ElementScene::slot_addLine() {
behavior = Line;
}
/**
Passe la scene en mode "ajout de rectangle"
*/
void ElementScene::slot_addRectangle() {
behavior = Rectangle;
}
/**
Passe la scene en mode "ajout de cercle"
*/
void ElementScene::slot_addCircle() {
behavior = Circle;
}
/**
Passe la scene en mode "ajout d'ellipse"
*/
void ElementScene::slot_addEllipse() {
behavior = Ellipse;
}
/**
Passe la scene en mode "ajout de polygone"
*/
void ElementScene::slot_addPolygon() {
behavior = Polygon;
}
/**
Passe la scene en mode "ajout de texte statique"
*/
void ElementScene::slot_addText() {
behavior = Text;
}
/**
Passe la scene en mode "ajout de borne"
*/
void ElementScene::slot_addTerminal() {
behavior = Terminal;
}
/**
Passe la scene en mode "ajout d'arc de cercle"
*/
void ElementScene::slot_addArc() {
behavior = Arc;
}
/**
Passe la scene en mode "ajout de champ de texte"
*/
void ElementScene::slot_addTextField() {
behavior = TextField;
}
/**
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 -> mouseMoveEvent(e)) {
if (m_event_interface->isFinish()) {
emit(partsAdded());
delete m_event_interface; m_event_interface = nullptr;
}
return;
}
}
QPointF event_pos = e -> scenePos(); QPointF event_pos = e -> scenePos();
if (!e -> modifiers() & Qt::ControlModifier) if (mustSnapToGrid(e)) snapToGrid(event_pos);
event_pos = snapToGrid(event_pos);
if (behavior != Polygon && current_polygon != NULL) current_polygon = NULL;
if (behavior == PasteArea) { if (behavior == PasteArea) {
QRectF current_rect(paste_area_ -> rect()); QRectF current_rect(paste_area_ -> rect());
current_rect.moveCenter(event_pos); current_rect.moveCenter(event_pos);
@@ -90,41 +146,107 @@ void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
return; return;
} }
QGraphicsScene::mouseMoveEvent(e); QRectF temp_rect;
QPointF temp_point;
QPolygonF temp_polygon;
if (e -> buttons() & Qt::LeftButton) {
switch(behavior) {
case Line:
current_line -> setLine(QLineF(current_line -> line().p1(), event_pos));
break;
case Rectangle:
temp_rect = current_rectangle -> rect();
temp_rect.setBottomRight(event_pos);
current_rectangle -> setRect(temp_rect);
break;
case Ellipse:
temp_rect = current_ellipse -> rect();
temp_rect.setBottomRight(event_pos);
current_ellipse -> setRect(temp_rect);
break;
case Arc:
temp_rect = current_arc -> rect();
temp_rect.setBottomRight(event_pos);
current_arc -> setRect(temp_rect);
break;
case Polygon:
if (current_polygon == NULL) break;
temp_polygon = current_polygon -> polygon();
temp_polygon.pop_back();
temp_polygon << event_pos;
current_polygon -> setPolygon(temp_polygon);
break;
case Normal:
default:
QGraphicsScene::mouseMoveEvent(e);
}
} else if (behavior == Polygon && current_polygon != NULL) {
temp_polygon = current_polygon -> polygon();
temp_polygon.pop_back();
temp_polygon << event_pos;
current_polygon -> setPolygon(temp_polygon);
} else QGraphicsScene::mouseMoveEvent(e);
} }
/** /**
* @brief ElementScene::mousePressEvent Gere les appuis sur les boutons de la souris
* @param e @param e objet decrivant l'evenement
*/ */
void ElementScene::mousePressEvent(QGraphicsSceneMouseEvent *e) { void ElementScene::mousePressEvent(QGraphicsSceneMouseEvent *e) {
if (m_event_interface) { QPointF event_pos = e -> scenePos();
if (m_event_interface -> mousePressEvent(e)) { if (mustSnapToGrid(e)) snapToGrid(event_pos);
if (m_event_interface->isFinish()) {
emit(partsAdded());
delete m_event_interface; m_event_interface = nullptr;
}
return;
}
}
QGraphicsScene::mousePressEvent(e); if (behavior != Polygon && current_polygon != NULL) current_polygon = NULL;
QPolygonF temp_polygon;
if (e -> button() & Qt::LeftButton) {
switch(behavior) {
case Line:
current_line = new PartLine(element_editor, 0, this);
current_line -> setLine(QLineF(event_pos, event_pos));
break;
case Rectangle:
current_rectangle = new PartRectangle(element_editor, 0, this);
current_rectangle -> setRect(QRectF(event_pos, QSizeF(0.0, 0.0)));
break;
case Ellipse:
current_ellipse = new PartEllipse(element_editor, 0, this);
current_ellipse -> setRect(QRectF(event_pos, QSizeF(0.0, 0.0)));
current_ellipse -> setProperty("antialias", true);
break;
case Arc:
current_arc = new PartArc(element_editor, 0, this);
current_arc -> setRect(QRectF(event_pos, QSizeF(0.0, 0.0)));
current_arc -> setProperty("antialias", true);
break;
case Polygon:
if (current_polygon == NULL) {
current_polygon = new PartPolygon(element_editor, 0, this);
temp_polygon = QPolygonF(0);
} else temp_polygon = current_polygon -> polygon();
// au debut, on insere deux points
if (!temp_polygon.count()) temp_polygon << event_pos;
temp_polygon << event_pos;
current_polygon -> setPolygon(temp_polygon);
break;
case Normal:
default:
QGraphicsScene::mousePressEvent(e);
}
} else QGraphicsScene::mousePressEvent(e);
} }
/** /**
* @brief ElementScene::mouseReleaseEvent Gere les relachements de boutons de la souris
* @param e @param e objet decrivant l'evenement
*/ */
void ElementScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) { void ElementScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
if (m_event_interface) { QPointF event_pos = e -> scenePos();
if (m_event_interface -> mouseReleaseEvent(e)) { if (mustSnapToGrid(e)) snapToGrid(event_pos);
if (m_event_interface->isFinish()) {
emit(partsAdded()); PartTerminal *terminal;
delete m_event_interface; m_event_interface = nullptr; PartText *text;
} PartTextField *textfield;
return; if (behavior != Polygon && current_polygon != NULL) current_polygon = NULL;
}
}
if (behavior == PasteArea) { if (behavior == PasteArea) {
defined_paste_area_ = paste_area_ -> rect(); defined_paste_area_ = paste_area_ -> rect();
@@ -134,43 +256,70 @@ void ElementScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
return; return;
} }
QGraphicsScene::mouseReleaseEvent(e); if (e -> button() & Qt::LeftButton) {
} switch(behavior) {
case Line:
/** if (qgiManager().manages(current_line)) break;
* @brief ElementScene::mouseDoubleClickEvent undo_stack.push(new AddPartCommand(tr("ligne"), this, current_line));
* @param event
*/
void ElementScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
if (m_event_interface) {
if (m_event_interface -> mouseDoubleClickEvent(event)) {
if (m_event_interface->isFinish()) {
emit(partsAdded()); emit(partsAdded());
delete m_event_interface; m_event_interface = nullptr; endCurrentBehavior(e);
} break;
return; case Rectangle:
} if (qgiManager().manages(current_rectangle)) break;
} current_rectangle -> setRect(current_rectangle -> rect().normalized());
undo_stack.push(new AddPartCommand(tr("rectangle"), this, current_rectangle));
QGraphicsScene::mouseDoubleClickEvent(event);
}
/**
* @brief ElementScene::keyPressEvent
* manage key press event
* @param event
*/
void ElementScene::keyPressEvent(QKeyEvent *event) {
if (m_event_interface) {
if (m_event_interface -> keyPressEvent(event)) {
if (m_event_interface->isFinish()) {
emit(partsAdded()); emit(partsAdded());
delete m_event_interface; m_event_interface = nullptr; endCurrentBehavior(e);
} break;
return; case Ellipse:
if (qgiManager().manages(current_ellipse)) break;
current_ellipse -> setRect(current_ellipse -> rect().normalized());
undo_stack.push(new AddPartCommand(tr("ellipse"), this, current_ellipse));
emit(partsAdded());
endCurrentBehavior(e);
break;
case Arc:
if (qgiManager().manages(current_arc)) break;
current_arc-> setRect(current_arc -> rect().normalized());
undo_stack.push(new AddPartCommand(tr("arc"), this, current_arc));
emit(partsAdded());
endCurrentBehavior(e);
break;
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 Text:
text = new PartText(element_editor, 0, this);
text -> setPos(event_pos);
undo_stack.push(new AddPartCommand(tr("texte"), this, text));
emit(partsAdded());
endCurrentBehavior(e);
break;
case TextField:
textfield = new PartTextField(element_editor, 0, this);
textfield -> setPos(event_pos);
undo_stack.push(new AddPartCommand(tr("champ de texte"), this, textfield));
emit(partsAdded());
endCurrentBehavior(e);
break;
case Normal:
default:
// detecte les deplacements de parties
QGraphicsScene::mouseReleaseEvent(e);
moving_parts_ = false;
} }
} } else if (e -> button() & Qt::RightButton) {
QGraphicsScene::keyPressEvent(event); if (behavior == Polygon && current_polygon != NULL) {
undo_stack.push(new AddPartCommand(tr("polygone"), this, current_polygon));
current_polygon = NULL;
emit(partsAdded());
endCurrentBehavior(e);
} else QGraphicsScene::mouseReleaseEvent(e);
} else QGraphicsScene::mouseReleaseEvent(e);
} }
/** /**
@@ -195,18 +344,17 @@ void ElementScene::drawForeground(QPainter *p, const QRectF &rect) {
} }
/** /**
* @brief ElementScene::setEventInterface A partir d'un evenement souris, cette methode regarde si la touche shift est
* Set a new event interface enfoncee ou non. Si oui, elle laisse le comportement en cours (cercle,
* @param interface texte, polygone, ...). Si non, elle repasse en mode normal / selection.
*/ @param event objet decrivant l'evenement souris
void ElementScene::setEventInterface(ESEventInterface *interface) { */
if (m_event_interface) { void ElementScene::endCurrentBehavior(const QGraphicsSceneMouseEvent *event) {
delete m_event_interface; if (!(event -> modifiers() & Qt::ShiftModifier)) {
//We must to re-init because previous interface // la touche Shift n'est pas enfoncee : on demande le mode normal
//Reset his own init when deleted behavior = Normal;
interface->init(); emit(needNormalMode());
} }
m_event_interface = interface;
} }
/** /**
@@ -270,6 +418,7 @@ 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
@@ -458,15 +607,19 @@ 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);
} }
QETElementEditor* ElementScene::editor() const {
return element_editor;
}
/** /**
Selectionne une liste de parties Selectionne une liste de parties
@param content liste des parties a selectionner @param content liste des parties a selectionner
@@ -944,10 +1097,19 @@ void ElementScene::initPasteArea() {
@param point une reference vers un QPointF. Cet objet sera modifie. @param point une reference vers un QPointF. Cet objet sera modifie.
*/ */
QPointF ElementScene::snapToGrid(QPointF point) { void ElementScene::snapToGrid(QPointF &point) {
point.rx() = qRound(point.x() / x_grid) * x_grid; point.rx() = qRound(point.x() / x_grid) * x_grid;
point.ry() = qRound(point.y() / y_grid) * y_grid; point.ry() = qRound(point.y() / y_grid) * y_grid;
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));
} }
/** /**

View File

@@ -23,13 +23,15 @@
#include "qgimanager.h" #include "qgimanager.h"
#include "elementcontent.h" #include "elementcontent.h"
#include "diagramcontext.h" #include "diagramcontext.h"
class CustomElementPart; class CustomElementPart;
class ElementEditionCommand; class ElementEditionCommand;
class ElementPrimitiveDecorator; class ElementPrimitiveDecorator;
class QETElementEditor; class QETElementEditor;
class ESEventInterface; class PartLine;
class QKeyEvent; class PartRectangle;
class PartEllipse;
class PartPolygon;
class PartArc;
/** /**
This class is the canvas allowing the visual edition of an electrial element. This class is the canvas allowing the visual edition of an electrial element.
It displays the various primitives composing the drawing of the element, the It displays the various primitives composing the drawing of the element, the
@@ -41,7 +43,7 @@ class ElementScene : public QGraphicsScene {
// enum // enum
public: public:
enum Behavior { Normal, PasteArea }; enum Behavior { Normal, Line, Rectangle, Circle, Ellipse, Polygon, Text, Terminal, Arc, TextField, PasteArea };
enum ItemOption { enum ItemOption {
SortByZValue = 1, SortByZValue = 1,
IncludeTerminals = 2, IncludeTerminals = 2,
@@ -50,7 +52,7 @@ class ElementScene : public QGraphicsScene {
NonSelected = 16, NonSelected = 16,
SelectedOrNot = 24 SelectedOrNot = 24
}; };
Q_DECLARE_FLAGS(ItemOptions, ItemOption) Q_DECLARE_FLAGS(ItemOptions, ItemOption);
// constructors, destructor // constructors, destructor
public: public:
@@ -62,52 +64,57 @@ class ElementScene : public QGraphicsScene {
// attributes // attributes
private: private:
/// List of localized names /// List of localized names
NamesList _names; NamesList _names;
/// Extra informations /// Extra informations
QString informations_; QString informations_;
/// element type /// element type
QString m_elmt_type; QString m_elmt_type;
/// element kind info /// element kind info
DiagramContext m_elmt_kindInfo; DiagramContext m_elmt_kindInfo;
/// QGraphicsItem manager /// QGraphicsItem manager
QGIManager qgi_manager; QGIManager qgi_manager;
/// Undo stack /// Undo stack
QUndoStack undo_stack; QUndoStack undo_stack;
/** /**
fsi_pos (first selected item pos) : Position of the forst selected item: used fsi_pos (first selected item pos) : Position of the forst selected item: used
to cancel mouse movements; also used to handle movements using keybard to cancel mouse movements; also used to handle movements using keybard
arrwows. arrwows.
*/ */
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; Behavior behavior;
Behavior behavior; PartLine *current_line;
QETElementEditor *element_editor; PartRectangle *current_rectangle;
PartEllipse *current_ellipse;
PartPolygon *current_polygon;
PartArc *current_arc;
QETElementEditor *element_editor;
/// Variables to manage the paste area on the scene /// Variables to manage the paste area on the scene
QGraphicsRectItem *paste_area_; QGraphicsRectItem *paste_area_;
QRectF defined_paste_area_; QRectF defined_paste_area_;
/// Variables to handle copy/paste with offset /// Variables to handle copy/paste with offset
QString last_copied_; QString last_copied_;
/// Decorator item displayed when at least one item is selected /// Decorator item displayed when at least one item is selected
ElementPrimitiveDecorator *decorator_; ElementPrimitiveDecorator *decorator_;
///< Size of the horizontal grid step ///< Size of the horizontal grid step
int x_grid; int x_grid;
///< Size of the vertical grid step ///< Size of the vertical grid step
int y_grid; int y_grid;
// methods // methods
public: public:
void setEventInterface (ESEventInterface *interface);
QPointF snapToGrid(QPointF point);
void setNames(const NamesList &); void setNames(const NamesList &);
NamesList names() const; NamesList names() const;
bool internalConnections();
void setInternalConnections(bool);
QString informations() const; QString informations() const;
void setInformations(const QString &); void setInformations(const QString &);
QString elementType () const {return m_elmt_type;} QString elementType () const {return m_elmt_type;}
@@ -131,17 +138,15 @@ 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;
protected: protected:
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *);
virtual void mousePressEvent (QGraphicsSceneMouseEvent *); virtual void mousePressEvent(QGraphicsSceneMouseEvent *);
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *); virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
virtual void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *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;
@@ -151,11 +156,23 @@ 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();
void snapToGrid(QPointF &);
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_addLine();
void slot_addRectangle();
void slot_addCircle();
void slot_addEllipse();
void slot_addPolygon();
void slot_addText();
void slot_addArc();
void slot_addTerminal();
void slot_addTextField();
void slot_select(const ElementContent &); void slot_select(const ElementContent &);
void slot_selectAll(); void slot_selectAll();
void slot_deselectAll(); void slot_deselectAll();
@@ -172,6 +189,11 @@ 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

View File

@@ -18,7 +18,6 @@
#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
@@ -29,7 +28,6 @@ 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);
@@ -37,6 +35,7 @@ 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()));
} }
@@ -114,20 +113,6 @@ 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,
@@ -142,7 +127,7 @@ void ElementView::zoomFit() {
Reinitialise le zoom Reinitialise le zoom
*/ */
void ElementView::zoomReset() { void ElementView::zoomReset() {
resetSceneRect(); resetSceneRect();
resetMatrix(); resetMatrix();
scale(4.0, 4.0); scale(4.0, 4.0);
} }
@@ -154,8 +139,8 @@ void ElementView::zoomReset() {
*/ */
void ElementView::adjustSceneRect() { void ElementView::adjustSceneRect() {
QRectF esgr = scene_ -> elementSceneGeometricRect(); QRectF esgr = scene_ -> elementSceneGeometricRect();
QRectF vpbr = mapToScene(this -> viewport()->rect()).boundingRect(); QRectF vpbr = mapToScene(this -> viewport() -> rect()).boundingRect();
QRectF new_scene_rect = vpbr.adjusted(-vpbr.width()/4, -vpbr.height()/4, vpbr.width()/4, vpbr.height()/4); QRectF new_scene_rect = vpbr.adjusted(-vpbr.height()/4, -vpbr.width()/4, vpbr.height()/4, vpbr.width()/4);
setSceneRect(new_scene_rect.united(esgr)); setSceneRect(new_scene_rect.united(esgr));
} }
@@ -398,67 +383,26 @@ void ElementView::mouseReleaseEvent(QMouseEvent *e) {
} }
/** /**
* @brief ElementView::gestures Gere les actions liees a la rollette de la souris
* @return @param e QWheelEvent decrivant l'evenement rollette
*/ */
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 ( gestures() ) { if (e->buttons() != Qt::MidButton) {
if (e -> modifiers() & Qt::ControlModifier) if (!(e -> modifiers() & Qt::ControlModifier)) {
e -> delta() > 0 ? zoomInSlowly() : zoomOutSlowly(); if (e -> delta() > 0){
else zoomIn();
QGraphicsView::wheelEvent(e); }
} else { else{
e -> delta() > 0 ? zoomIn(): zoomOut(); zoomOut();
}
}
/**
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();
} }
} }
else {
QAbstractScrollArea::wheelEvent(e);
}
} }
return true;
} }
/** /**
Dessine l'arriere-plan de l'editeur, cad la grille. Dessine l'arriere-plan de l'editeur, cad la grille.
@param p Le QPainter a utiliser pour dessiner @param p Le QPainter a utiliser pour dessiner
@@ -481,32 +425,29 @@ void ElementView::drawBackground(QPainter *p, const QRectF &r) {
qreal zoom_factor = matrix().m11(); qreal zoom_factor = matrix().m11();
// choisit la granularite de la grille en fonction du zoom en cours // choisit la granularite de la grille en fonction du zoom en cours
int drawn_x_grid = 1;//scene_ -> xGrid(); int drawn_x_grid = scene_ -> xGrid();
int drawn_y_grid = 1;//scene_ -> yGrid(); int drawn_y_grid = scene_ -> yGrid();
bool draw_grid = true; bool draw_grid = true;
bool draw_cross = false; bool draw_cross = false;
if (zoom_factor < (4.0/3.0)) {
if (zoom_factor < (4.0/3.0)) { //< no grid // pas de grille du tout
draw_grid = false; draw_grid = false;
} else if (zoom_factor < 4.0) { //< grid 10*10 } else if (zoom_factor < 4.0) {
// grille a 10 px
drawn_x_grid *= 10; drawn_x_grid *= 10;
drawn_y_grid *= 10; drawn_y_grid *= 10;
}else if (zoom_factor < 8.0) { //< grid 5*5 } else if (zoom_factor < 6.0) {
drawn_x_grid *= 5; // grille a 2 px (avec croix)
drawn_y_grid *= 5;
draw_cross = true;
} else if (zoom_factor < 10.0) { //< grid 2*2
drawn_x_grid *= 2; drawn_x_grid *= 2;
drawn_y_grid *= 2; drawn_y_grid *= 2;
draw_cross = true; draw_cross = true;
} else { //< grid 1*1 } else {
// grille a 1 px (avec croix)
draw_cross = true; draw_cross = true;
} }
scene_->setGrid(drawn_x_grid, drawn_y_grid);
if (draw_grid) { if (draw_grid) {
// draw the dot of the grid // dessine les points de la grille
p -> setPen(Qt::black); p -> setPen(Qt::black);
p -> setBrush(Qt::NoBrush); p -> setBrush(Qt::NoBrush);
qreal limite_x = r.x() + r.width(); qreal limite_x = r.x() + r.width();

View File

@@ -47,8 +47,6 @@ 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 &);
@@ -60,8 +58,6 @@ 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();
@@ -90,7 +86,6 @@ 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

View File

@@ -1,189 +0,0 @@
/*
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 "elementscene.h"
#include "partarc.h"
#include "editorcommands.h"
#include "eseventaddarc.h"
/**
* @brief ESEventAddArc::ESEventAddArc
* @param scene
*/
ESEventAddArc::ESEventAddArc(ElementScene *scene) :
ESEventInterface(scene),
m_arc(nullptr),
m_inverted(false)
{}
/**
* @brief ESEventAddArc::~ESEventAddArc
*/
ESEventAddArc::~ESEventAddArc() {
if (m_running || m_abort)
delete m_arc;
}
/**
* @brief ESEventAddPolygon::mousePressEvent
* @param event
* @return
*/
bool ESEventAddArc::mousePressEvent(QGraphicsSceneMouseEvent *event) {
if (event -> button() == Qt::LeftButton) {
if(!m_running) m_running = true;
QPointF pos = m_scene->snapToGrid(event -> scenePos());
//create new arc
if (!m_arc) {
m_arc = new PartArc(m_editor, 0, m_scene);
m_arc -> setRect(QRectF(pos, pos));
m_arc -> setAngle(90);
m_arc -> setProperty("antialias", true);
m_origin = pos;
return true;
}
//Add arc to scene
m_arc -> setRect(m_arc->rect().normalized());
m_scene -> undoStack().push(new AddPartCommand(QObject::tr("Arc"), m_scene, m_arc));
//Set m_arc to nullptr for create new ellipse at next mouse press
m_arc = nullptr;
return true;
}
return false;
}
/**
* @brief ESEventAddArc::mouseMoveEvent
* @param event
* @return
*/
bool ESEventAddArc::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
updateHelpCross(event -> scenePos());
if (!m_arc) return false;
m_mouse_pos = m_scene -> snapToGrid(event -> scenePos());
updateArc();
return true;
}
/**
* @brief ESEventAddArc::mouseReleaseEvent
* @param event
* @return
*/
bool ESEventAddArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
if (event -> button() == Qt::RightButton) {
if (m_arc) {delete m_arc; m_arc = nullptr;}
else {m_running = false;}
return true;
}
return false;
}
/**
* @brief ESEventAddArc::keyPressEvent
* @param event
* @return
*/
bool ESEventAddArc::keyPressEvent(QKeyEvent *event) {
if (m_arc && event->key() == Qt::Key_Space) {
m_inverted = m_inverted ? false : true;
updateArc();
return true;
}
return (ESEventInterface::keyPressEvent(event));
}
/**
* @brief ESEventAddArc::updateArc
* Redraw the arc with curent value
*/
void ESEventAddArc::updateArc() {
qreal width = (m_mouse_pos.x() - m_origin.x())*2;
if (width < 0) width *= -1;
qreal height = (m_mouse_pos.y() - m_origin.y())*2;
if (height < 0) height *= -1;
QPointF pos_ = m_origin;
//Draw arc inverted
if (m_inverted) {
//Adjust the start angle to be snapped at the origin point of draw
if (m_mouse_pos.y() > m_origin.y()) {
if (m_mouse_pos.x() > m_origin.x()) {
pos_.ry() -= height/2;
m_arc->setStartAngle(180);
}
else {
pos_.rx() -= width/2;
m_arc->setStartAngle(90);
}
}
else {
if (m_mouse_pos.x() > m_origin.x()) {
pos_.ry() -= height;
pos_.rx() -= width/2;
m_arc->setStartAngle(270);
}
else {
pos_.rx() -= width;
pos_.ry() -= height/2;
m_arc->setStartAngle(0);
}
}
}
//Draw arc non inverted
else {
//Adjust the start angle to be snapped at the origin point of draw
if (m_mouse_pos.y() > m_origin.y()) {
if (m_mouse_pos.x() > m_origin.x()) {
pos_.rx() -= width/2;
m_arc->setStartAngle(0);
}
else {
pos_.rx() -= width;
pos_.ry() -= height/2;
m_arc->setStartAngle(270);
}
}
else {
if (m_mouse_pos.x() > m_origin.x()) {
pos_.ry() -= height/2;
m_arc->setStartAngle(90);
}
else {
pos_.rx() -= width/2;
pos_.ry() -= height;
m_arc->setStartAngle(180);
}
}
}
m_arc -> setRect(QRectF(pos_, QSizeF(width, height)));
}

View File

@@ -1,51 +0,0 @@
/*
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 ESEVENTADDARC_H
#define ESEVENTADDARC_H
#include "eseventinterface.h"
class ElementScene;
class PartArc;
class QGraphicsSceneMouseEvent;
/**
* @brief The ESEventAddArc class
* This ESEvent manage creation of arc in an ElementScene
*/
class ESEventAddArc : public ESEventInterface
{
public:
ESEventAddArc(ElementScene *scene);
virtual ~ESEventAddArc();
virtual bool mousePressEvent (QGraphicsSceneMouseEvent *event);
virtual bool mouseMoveEvent (QGraphicsSceneMouseEvent *event);
virtual bool mouseReleaseEvent (QGraphicsSceneMouseEvent *event);
virtual bool keyPressEvent (QKeyEvent *event);
private:
void updateArc ();
private:
PartArc *m_arc;
QPointF m_origin, m_mouse_pos;
bool m_inverted;
};
#endif // ESEVENTADDARC_H

View File

@@ -1,106 +0,0 @@
/*
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 "eseventaddellipse.h"
#include "partellipse.h"
#include "editorcommands.h"
#include "elementscene.h"
/**
* @brief ESEventAddEllipse::ESEventAddEllipse
* @param scene
*/
ESEventAddEllipse::ESEventAddEllipse(ElementScene *scene) :
ESEventInterface(scene),
m_ellipse(nullptr)
{}
/**
* @brief ESEventAddEllipse::~ESEventAddEllipse
*/
ESEventAddEllipse::~ESEventAddEllipse() {
if (m_running || m_abort){
delete m_ellipse;
}
}
/**
* @brief ESEventAddEllipse::mousePressEvent
* @param event
* @return
*/
bool ESEventAddEllipse::mousePressEvent(QGraphicsSceneMouseEvent *event) {
if (event -> button() == Qt::LeftButton) {
if(!m_running) m_running = true;
QPointF pos = m_scene->snapToGrid(event -> scenePos());
//create new ellpise
if (!m_ellipse) {
m_ellipse = new PartEllipse(m_editor, 0, m_scene);
m_ellipse -> setRect(QRectF(pos, pos));
m_origin = pos;
return true;
}
//Add ellipse to scene
m_ellipse -> setRect(m_ellipse -> rect().normalized());
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
m_ellipse = nullptr;
return true;
}
return false;
}
/**
* @brief ESEventAddRect::mouseMoveEvent
* @param event
* @return
*/
bool ESEventAddEllipse::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
updateHelpCross(event -> scenePos());
if (!m_ellipse) return false;
QPointF mouse_pos = m_scene -> snapToGrid(event -> scenePos());
qreal width = (mouse_pos.x() - m_origin.x())*2;
qreal height = (mouse_pos.y() - m_origin.y())*2;
QPointF pos(m_origin.x() - width/2,
m_origin.y() - height/2);
m_ellipse -> setRect(QRectF(pos, QSizeF(width, height)));
return true;
}
/**
* @brief ESEventAddEllipse::mouseReleaseEvent
* @param event
* @return
*/
bool ESEventAddEllipse::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
if (event -> button() == Qt::RightButton) {
if (m_ellipse) {delete m_ellipse; m_ellipse = nullptr;}
else {m_running = false;}
return true;
}
return false;
}

View File

@@ -1,47 +0,0 @@
/*
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 ESEVENTADDELLIPSE_H
#define ESEVENTADDELLIPSE_H
#include "eseventinterface.h"
#include <QPointF>
class ElementScene;
class PartEllipse;
class QGraphicsSceneMouseEvent;
/**
* @brief The ESEventAddEllipse class
* This ESEvent manage creation of ellpise in an ElementScene
*/
class ESEventAddEllipse : public ESEventInterface
{
public:
ESEventAddEllipse(ElementScene *scene);
~ESEventAddEllipse();
virtual bool mousePressEvent (QGraphicsSceneMouseEvent *event);
virtual bool mouseMoveEvent (QGraphicsSceneMouseEvent *event);
virtual bool mouseReleaseEvent (QGraphicsSceneMouseEvent *event);
private:
PartEllipse *m_ellipse;
QPointF m_origin;
};
#endif // ESEVENTADDELLIPSE_H

View File

@@ -1,102 +0,0 @@
/*
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 <QGraphicsSceneMouseEvent>
#include <QObject>
#include "eseventaddline.h"
#include "elementscene.h"
#include "qetelementeditor.h"
#include "partline.h"
#include "editorcommands.h"
/**
* @brief ESEventAddLine::ESEventAddLine
* Constructor
* @param scene : scene where we operate this action
*/
ESEventAddLine::ESEventAddLine(ElementScene *scene) :
ESEventInterface (scene),
m_line (nullptr)
{}
/**
* @brief ESEventAddLine::~ESEventAddLine
* destructor
*/
ESEventAddLine::~ESEventAddLine() {
if (m_running || m_abort)
delete m_line;
}
/**
* @brief ESEventAddLine::mousePressEvent
* @param event
* @return
*/
bool ESEventAddLine::mousePressEvent(QGraphicsSceneMouseEvent *event) {
if (event -> button() == Qt::LeftButton) {
if (! m_running) m_running = true;
QPointF pos = m_scene -> snapToGrid(event -> scenePos());
//Create new line
if (!m_line) {
m_line = new PartLine(m_editor, 0, m_scene);
m_line -> setLine(QLineF(pos, pos));
return true;
}
//Add new line to scene
m_scene -> undoStack().push(new AddPartCommand(QObject::tr("ligne"), m_scene, m_line));
//Set m_line to nullptr for create new line at next mouse press
m_line = nullptr;
return true;
}
return false;
}
/**
* @brief ESEventAddLine::mouseMoveEvent
* @param event
* @return
*/
bool ESEventAddLine::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
updateHelpCross (event -> scenePos());
if (!m_line) return false;
m_line -> setP2(m_scene -> snapToGrid(event -> scenePos()));
return true;
}
/**
* @brief ESEventAddLine::mouseReleaseEvent
* @param event
* @return
*/
bool ESEventAddLine::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
if (event -> button() == Qt::RightButton) {
if (m_line) {delete m_line; m_line = nullptr;}
else {m_running = false;}
return true;
}
return false;
}

View File

@@ -1,45 +0,0 @@
/*
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 ESEVENTADDLINE_H
#define ESEVENTADDLINE_H
#include "eseventinterface.h"
class ElementScene;
class PartLine;
class QGraphicsSceneMouseEvent;
/**
* @brief The ESEventAddLine class
* This ESEvent manage creation of line in a ElementScene
*/
class ESEventAddLine : public ESEventInterface
{
public:
ESEventAddLine(ElementScene *scene);
virtual ~ESEventAddLine();
virtual bool mousePressEvent (QGraphicsSceneMouseEvent *event);
virtual bool mouseMoveEvent (QGraphicsSceneMouseEvent *event);
virtual bool mouseReleaseEvent (QGraphicsSceneMouseEvent *event);
private:
PartLine *m_line;
};
#endif // ESEVENTADDLINE_H

View File

@@ -1,117 +0,0 @@
/*
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 "eseventaddpolygon.h"
#include "elementscene.h"
#include "partpolygon.h"
#include "editorcommands.h"
/**
* @brief ESEventAddPolygon::ESEventAddPolygon
* @param scene
*/
ESEventAddPolygon::ESEventAddPolygon(ElementScene *scene) :
ESEventInterface(scene),
m_polygon(nullptr)
{}
/**
* @brief ESEventAddPolygon::~ESEventAddPolygon
*/
ESEventAddPolygon::~ESEventAddPolygon() {
if (m_running || m_abort)
delete m_polygon;
}
/**
* @brief ESEventAddPolygon::mousePressEvent
* @param event
* @return
*/
bool ESEventAddPolygon::mousePressEvent(QGraphicsSceneMouseEvent *event) {
if (event -> button() == Qt::LeftButton) {
if(!m_running) m_running = true;
QPointF pos = m_scene->snapToGrid(event -> scenePos());
//create new polygon
if (!m_polygon) {
m_polygon = new PartPolygon(m_editor, 0, m_scene);
m_polygon -> addPoint(pos);
}
m_polygon -> addPoint(pos);
return true;
}
return false;
}
/**
* @brief ESEventAddPolygon::mouseMoveEvent
* @param event
* @return
*/
bool ESEventAddPolygon::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
updateHelpCross(event -> scenePos());
if (!m_polygon) return false;
m_polygon -> setLastPoint(m_scene -> snapToGrid(event -> scenePos()));
return true;
}
/**
* @brief ESEventAddPolygon::mouseReleaseEvent
* @param event
* @return
*/
bool ESEventAddPolygon::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
if (event -> button() == Qt::RightButton) {
if (m_polygon) {
m_polygon -> removeLastPoint();
if (m_polygon -> polygon().size() > 1)
{ m_polygon -> setLastPoint(m_scene -> snapToGrid(event -> scenePos())); }
else
{ delete m_polygon; m_polygon = nullptr; }
}
else
{ m_running = false; }
return true;
}
return false;
}
/**
* @brief ESEventAddPolygon::mouseDoubleClickEvent
* @param event
* @return
*/
bool ESEventAddPolygon::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
if (event -> button() == Qt::LeftButton) {
if (m_polygon) {
m_polygon -> addPoint(m_scene -> snapToGrid(event -> scenePos()));
m_scene -> undoStack().push(new AddPartCommand(QObject::tr("Polygone"), m_scene, m_polygon));
//Set m_polygon to nullptr for create new polygon at next mouse press
m_polygon = nullptr;
return true;
}
}
return false;
}

View File

@@ -1,46 +0,0 @@
/*
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 ESEVENTADDPOLYGON_H
#define ESEVENTADDPOLYGON_H
#include "eseventinterface.h"
class ElementScene;
class PartPolygon;
class QGraphicsSceneMouseEvent;
/**
* @brief The ESEventAddPolygon class
* This ESEvent manage creation of polygon in an ElementScene
*/
class ESEventAddPolygon : public ESEventInterface
{
public:
ESEventAddPolygon(ElementScene *scene);
virtual ~ESEventAddPolygon();
virtual bool mousePressEvent (QGraphicsSceneMouseEvent *event);
virtual bool mouseMoveEvent (QGraphicsSceneMouseEvent *event);
virtual bool mouseReleaseEvent (QGraphicsSceneMouseEvent *event);
virtual bool mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event);
private:
PartPolygon *m_polygon;
};
#endif // ESEVENTADDPOLYGON_H

View File

@@ -1,97 +0,0 @@
/*
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 "eseventaddrect.h"
#include "elementscene.h"
#include "partrectangle.h"
#include "editorcommands.h"
/**
* @brief ESEventAddRect::ESEventAddRect
* @param scene
*/
ESEventAddRect::ESEventAddRect(ElementScene *scene) :
ESEventInterface(scene),
m_rect(nullptr)
{}
/**
* @brief ESEventAddRect::~ESEventAddRect
*/
ESEventAddRect::~ESEventAddRect() {
if (m_running || m_abort)
delete m_rect;
}
/**
* @brief ESEventAddRect::mousePressEvent
* @param event
* @return
*/
bool ESEventAddRect::mousePressEvent(QGraphicsSceneMouseEvent *event) {
if (event -> button() == Qt::LeftButton) {
if(!m_running) m_running = true;
QPointF pos = m_scene->snapToGrid(event -> scenePos());
//create new rectangle
if (!m_rect) {
m_rect = new PartRectangle(m_editor, 0, m_scene);
m_rect -> setRect(QRectF(pos, pos));
return true;
}
//Add rectangle to scene
m_rect -> setRect(m_rect -> rect().normalized());
m_scene -> undoStack().push(new AddPartCommand(QObject::tr("Rectangle"), m_scene, m_rect));
//Set m_rect to nullptr for create new rectangle at next mouse press
m_rect = nullptr;
return true;
}
return false;
}
/**
* @brief ESEventAddRect::mouseMoveEvent
* @param event
* @return
*/
bool ESEventAddRect::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
updateHelpCross(event -> scenePos());
if (!m_rect) return false;
QRectF rect(m_rect -> rect().topLeft(), m_scene->snapToGrid(event -> scenePos()));
m_rect -> setRect(rect);
return true;
}
/**
* @brief ESEventAddRect::mouseReleaseEvent
* @param event
* @return
*/
bool ESEventAddRect::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
if (event -> button() == Qt::RightButton) {
if (m_rect) {delete m_rect; m_rect = nullptr;}
else {m_running = false;}
return true;
}
return false;
}

View File

@@ -1,41 +0,0 @@
/*
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 ESEVENTADDRECT_H
#define ESEVENTADDRECT_H
#include "eseventinterface.h"
class ElementScene;
class PartRectangle;
class QGraphicsSceneMouseEvent;
class ESEventAddRect : public ESEventInterface
{
public:
ESEventAddRect(ElementScene *scene);
virtual ~ESEventAddRect();
virtual bool mousePressEvent (QGraphicsSceneMouseEvent *event);
virtual bool mouseMoveEvent (QGraphicsSceneMouseEvent *event);
virtual bool mouseReleaseEvent (QGraphicsSceneMouseEvent *event);
private:
PartRectangle *m_rect;
};
#endif // ESEVENTADDRECT_H

View File

@@ -1,107 +0,0 @@
/*
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));
}

View File

@@ -1,45 +0,0 @@
/*
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

View File

@@ -1,76 +0,0 @@
/*
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 "eseventaddtext.h"
#include "parttext.h"
#include "editorcommands.h"
#include "elementscene.h"
/**
* @brief ESEventAddText::ESEventAddText
* @param scene
*/
ESEventAddText::ESEventAddText(ElementScene *scene) :
ESEventInterface(scene)
{
m_text = new PartText(m_editor, 0, m_scene);
m_running = true;
}
/**
* @brief ESEventAddText::~ESEventAddText
*/
ESEventAddText::~ESEventAddText() {
delete m_text;
}
/**
* @brief ESEventAddText::mouseMoveEvent
* @param event
* @return
*/
bool ESEventAddText::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
QPointF pos = m_scene -> snapToGrid(event -> scenePos());
updateHelpCross(pos);
m_text->setPos(pos);
return true;
}
/**
* @brief ESEventAddText::mouseReleaseEvent
* @param event
* @return
*/
bool ESEventAddText::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
if (event->button() == Qt::LeftButton) {
m_scene -> undoStack().push(new AddPartCommand(QObject::tr("Texte"), m_scene, m_text));
//Set new text
m_text = new PartText(m_editor, 0, m_scene);
m_text -> setPos(m_scene -> snapToGrid(event -> scenePos()));
return true;
}
else if (event->button() == Qt::RightButton) {
m_running = false;
return true;
}
return false;
}

View File

@@ -1,44 +0,0 @@
/*
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 ESEVENTADDTEXT_H
#define ESEVENTADDTEXT_H
#include "eseventinterface.h"
class ElementScene;
class PartText;
class QGraphicsSceneMouseEvent;
/**
* @brief The ESEventAddText class
* This ESEvent manage creation of text in an ElementScene
*/
class ESEventAddText : public ESEventInterface
{
public:
ESEventAddText(ElementScene *scene);
virtual ~ESEventAddText();
virtual bool mouseMoveEvent (QGraphicsSceneMouseEvent *event);
virtual bool mouseReleaseEvent (QGraphicsSceneMouseEvent *event);
private:
PartText *m_text;
};
#endif // ESEVENTADDTEXT_H

View File

@@ -1,76 +0,0 @@
/*
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 "parttextfield.h"
#include "editorcommands.h"
#include "elementscene.h"
#include "eseventaddtextfield.h"
/**
* @brief ESEventAddTextField::ESEventAddTextField
* @param scene
*/
ESEventAddTextField::ESEventAddTextField(ElementScene *scene) :
ESEventInterface(scene)
{
m_text = new PartTextField(m_editor, 0, m_scene);
m_running = true;
}
/**
* @brief ESEventAddTextField::~ESEventAddTextField
*/
ESEventAddTextField::~ESEventAddTextField() {
delete m_text;
}
/**
* @brief ESEventAddTextField::ESEventAddTextField
* @param event
* @return
*/
bool ESEventAddTextField::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
QPointF pos = m_scene -> snapToGrid(event -> scenePos());
updateHelpCross(pos);
m_text->setPos(pos);
return true;
}
/**
* @brief ESEventAddTextField::ESEventAddTextField
* @param event
* @return
*/
bool ESEventAddTextField::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
if (event->button() == Qt::LeftButton) {
m_scene -> undoStack().push(new AddPartCommand(QObject::tr("Champ texte"), m_scene, m_text));
//Set new text
m_text = new PartTextField(m_editor, 0, m_scene);
m_text -> setPos(m_scene -> snapToGrid(event -> scenePos()));
return true;
}
else if (event->button() == Qt::RightButton) {
m_running = false;
return true;
}
return false;
}

View File

@@ -1,44 +0,0 @@
/*
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 ESEVENTADDTEXTFIELD_H
#define ESEVENTADDTEXTFIELD_H
#include "eseventinterface.h"
class ElementScene;
class PartTextField;
class QGraphicsSceneMouseEvent;
/**
* @brief The ESEventAddTextField class
* This ESEvent manage creation of text field in an ElementScene
*/
class ESEventAddTextField : public ESEventInterface
{
public:
ESEventAddTextField(ElementScene *scene);
virtual ~ESEventAddTextField();
virtual bool mouseMoveEvent (QGraphicsSceneMouseEvent *event);
virtual bool mouseReleaseEvent (QGraphicsSceneMouseEvent *event);
private:
PartTextField *m_text;
};
#endif // ESEVENTADDTEXTFIELD_H

View File

@@ -1,125 +0,0 @@
/*
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 "eseventinterface.h"
#include "elementscene.h"
#include "qetelementeditor.h"
#include <QGraphicsSceneMouseEvent>
ESEventInterface::ESEventInterface(ElementScene *scene) :
m_scene (scene),
m_editor (scene->editor()),
m_help_horiz (nullptr),
m_help_verti (nullptr),
m_running (false),
m_abort (false)
{
init();
}
void ESEventInterface::init() {
foreach (QGraphicsView *qgv, m_scene->views())
qgv->setContextMenuPolicy(Qt::NoContextMenu);
m_editor->slot_setNoDragToView();
}
ESEventInterface::~ESEventInterface() {
delete m_help_horiz;
delete m_help_verti;
foreach (QGraphicsView *qgv, m_scene->views())
qgv->setContextMenuPolicy(Qt::DefaultContextMenu);
m_editor->slot_setRubberBandToView();
}
bool ESEventInterface::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
Q_UNUSED (event);
return false;
}
bool ESEventInterface::mousePressEvent(QGraphicsSceneMouseEvent *event) {
Q_UNUSED (event);
return false;
}
bool ESEventInterface::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
Q_UNUSED (event);
return false;
}
bool ESEventInterface::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
Q_UNUSED (event);
return false;
}
bool ESEventInterface::wheelEvent(QGraphicsSceneWheelEvent *event) {
Q_UNUSED (event);
return false;
}
/**
* @brief ESEventInterface::keyPressEvent
* By default, press escape key abort the curent action
* @param event
* @return
*/
bool ESEventInterface::keyPressEvent(QKeyEvent *event) {
if (event->key() == Qt::Key_Escape) {
m_running = false;
m_abort = true;
return true;
}
return false;
}
bool ESEventInterface::KeyReleaseEvent(QKeyEvent *event) {
Q_UNUSED (event);
return false;
}
bool ESEventInterface::isRunning() const {
return m_running;
}
bool ESEventInterface::isFinish() const {
return !m_running;
}
void ESEventInterface::updateHelpCross(const QPointF &p) {
//If line isn't created yet, we create it.
if (!m_help_horiz || !m_help_verti) {
QPen pen;
pen.setColor(Qt::darkBlue);
if (!m_help_horiz) {
m_help_horiz = new QGraphicsLineItem(-10000, 0, 10000, 0, 0, m_scene);
m_help_horiz -> setPen(pen);
}
if (!m_help_verti) {
m_help_verti = new QGraphicsLineItem(0, -10000, 0, 10000, 0, m_scene);
m_help_verti -> setPen(pen);
}
}
//Update the position of the cross
QPointF point = m_scene -> snapToGrid(p);
m_help_horiz -> setY(point.y());
m_help_verti -> setX(point.x());
}

View File

@@ -1,57 +0,0 @@
/*
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 ESEVENTINTERFACE_H
#define ESEVENTINTERFACE_H
class QGraphicsSceneMouseEvent;
class QGraphicsSceneWheelEvent;
class QKeyEvent;
class ElementScene;
class QETElementEditor;
class QGraphicsLineItem;
class QPointF;
class ESEventInterface
{
public:
ESEventInterface(ElementScene *scene);
virtual ~ESEventInterface();
void init();
virtual bool mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event);
virtual bool mousePressEvent (QGraphicsSceneMouseEvent *event);
virtual bool mouseMoveEvent (QGraphicsSceneMouseEvent *event);
virtual bool mouseReleaseEvent (QGraphicsSceneMouseEvent *event);
virtual bool wheelEvent (QGraphicsSceneWheelEvent *event);
virtual bool keyPressEvent (QKeyEvent *event);
virtual bool KeyReleaseEvent (QKeyEvent *event);
virtual bool isRunning () const;
virtual bool isFinish () const;
protected:
void updateHelpCross (const QPointF &p);
protected:
ElementScene *m_scene;
QETElementEditor *m_editor;
QGraphicsLineItem *m_help_horiz, *m_help_verti;
bool m_running, m_abort;
};
#endif // ESEVENTINTERFACE_H

View File

@@ -223,15 +223,6 @@ void PartLine::setY1(qreal y1) {
setLine(QLineF(p, line().p2())); setLine(QLineF(p, line().p2()));
} }
/**
* @brief PartLine::setP1
* set first point to P1
* @param p1
*/
void PartLine::setP1(QPointF p1) {
setLine(QLineF(p1, line().p2()));
}
/** /**
* @brief PartLine::setX2 * @brief PartLine::setX2
* set x of P2 * set x of P2
@@ -254,15 +245,6 @@ void PartLine::setY2(qreal y2) {
setLine(QLineF(line().p1(), p)); setLine(QLineF(line().p1(), p));
} }
/**
* @brief PartLine::setP2
* set second point to P2
* @param p2
*/
void PartLine::setP2(QPointF p2) {
setLine(QLineF(line().p1(), p2));
}
/** /**
Gere les changements intervenant sur cette partie Gere les changements intervenant sur cette partie
@param change Type de changement @param change Type de changement

View File

@@ -74,50 +74,35 @@ class PartLine : public CustomElementGraphicPart, public QGraphicsLineItem {
static QList<QPointF> fourEndPoints(const QPointF &, const QPointF &, const qreal &); static QList<QPointF> fourEndPoints(const QPointF &, const QPointF &, const qreal &);
///PROPERTY ///PROPERTY
// X value of the first point // X value of the first point
Q_PROPERTY(qreal x1 READ x1 WRITE setX1) Q_PROPERTY(qreal x1 READ x1 WRITE setX1)
qreal x1() const {return sceneP1().x();} qreal x1() const {return sceneP1().x();}
void setX1(qreal x1); void setX1(qreal x1);
// Y value of the first point
// Y value of the first point
Q_PROPERTY(qreal y1 READ y1 WRITE setY1) Q_PROPERTY(qreal y1 READ y1 WRITE setY1)
qreal y1() const {return sceneP1().y();} qreal y1() const {return sceneP1().y();}
void setY1(qreal y1); void setY1(qreal y1);
// X value of the second point
//pos of firts point
Q_PROPERTY(QPointF p1 READ sceneP1 WRITE setP1)
void setP1 (QPointF p1);
// X value of the second point
Q_PROPERTY(qreal x2 READ x2 WRITE setX2) Q_PROPERTY(qreal x2 READ x2 WRITE setX2)
qreal x2() const {return sceneP2().x();} qreal x2() const {return sceneP2().x();}
void setX2(qreal x2); void setX2(qreal x2);
// Y value of the second point
// Y value of the second point
Q_PROPERTY(qreal y2 READ y2 WRITE setY2) Q_PROPERTY(qreal y2 READ y2 WRITE setY2)
qreal y2() const {return sceneP2().y();} qreal y2() const {return sceneP2().y();}
void setY2(qreal y2); void setY2(qreal y2);
// End type of the first point
//pos of second point
Q_PROPERTY(QPointF p2 READ sceneP2 WRITE setP2)
void setP2 (QPointF p2);
// End type of the first point
Q_PROPERTY(Qet::EndType end1 READ firstEndType WRITE setFirstEndType) Q_PROPERTY(Qet::EndType end1 READ firstEndType WRITE setFirstEndType)
Qet::EndType firstEndType() const {return first_end;} Qet::EndType firstEndType() const {return first_end;}
void setFirstEndType(const Qet::EndType &et) {first_end = et;} void setFirstEndType(const Qet::EndType &et) {first_end = et;}
// End type of the second point
// End type of the second point
Q_PROPERTY(Qet::EndType end2 READ secondEndType WRITE setSecondEndType) Q_PROPERTY(Qet::EndType end2 READ secondEndType WRITE setSecondEndType)
Qet::EndType secondEndType() const {return second_end;} Qet::EndType secondEndType() const {return second_end;}
void setSecondEndType(const Qet::EndType &et) {second_end = et;} void setSecondEndType(const Qet::EndType &et) {second_end = et;}
// Size of end type of first point
// Size of end type of first point
Q_PROPERTY(qreal length1 READ firstEndLength WRITE setFirstEndLength) Q_PROPERTY(qreal length1 READ firstEndLength WRITE setFirstEndLength)
qreal firstEndLength() const {return first_length;} qreal firstEndLength() const {return first_length;}
void setFirstEndLength(const qreal &l) {first_length = qMin(qAbs(l), line().length());} void setFirstEndLength(const qreal &l) {first_length = qMin(qAbs(l), line().length());}
// Size of end type of the second point
// Size of end type of the second point
Q_PROPERTY(qreal length2 READ secondEndLength WRITE setSecondEndLength) Q_PROPERTY(qreal length2 READ secondEndLength WRITE setSecondEndLength)
qreal secondEndLength() const {return second_length;} qreal secondEndLength() const {return second_length;}
void setSecondEndLength(const qreal &l) {second_length = qMin(qAbs(l), line().length());} void setSecondEndLength(const qreal &l) {second_length = qMin(qAbs(l), line().length());}

View File

@@ -173,45 +173,6 @@ QET::ScalingMethod PartPolygon::preferredScalingMethod() const {
return(QET::RoundScaleRatios); return(QET::RoundScaleRatios);
} }
/**
* @brief PartPolygon::addPoint
* Add new point to polygon
* @param point
*/
void PartPolygon::addPoint(const QPointF &point) {
QPolygonF poly = polygon();
poly << point;
setPolygon(poly);
}
/**
* @brief PartPolygon::setLastPoint
* Set the last point of polygon to @point
* @param point
*/
void PartPolygon::setLastPoint(const QPointF &point) {
QPolygonF poly = polygon();
if (poly.size())
poly.pop_back();
poly << point;
setPolygon(poly);
}
/**
* @brief PartPolygon::removeLastPoint
* Remove the last point of polygon
*/
void PartPolygon::removeLastPoint() {
QPolygonF poly = polygon();
if (poly.size())
poly.pop_back();
setPolygon(poly);
}
/** /**
@return le rectangle delimitant cette partie. @return le rectangle delimitant cette partie.
*/ */

View File

@@ -58,10 +58,6 @@ class PartPolygon : public CustomElementGraphicPart, public QGraphicsPolygonItem
virtual void handleUserTransformation(const QRectF &, const QRectF &); virtual void handleUserTransformation(const QRectF &, const QRectF &);
virtual QET::ScalingMethod preferredScalingMethod() const; virtual QET::ScalingMethod preferredScalingMethod() const;
void addPoint (const QPointF &point);
void setLastPoint (const QPointF &point);
void removeLastPoint ();
///PROPERTY ///PROPERTY
// Closed (join the first and last point by a line) // Closed (join the first and last point by a line)
Q_PROPERTY(bool closed READ isClosed WRITE setClosed) Q_PROPERTY(bool closed READ isClosed WRITE setClosed)

View File

@@ -38,18 +38,10 @@
#include "terminaleditor.h" #include "terminaleditor.h"
#include "texteditor.h" #include "texteditor.h"
#include "textfieldeditor.h" #include "textfieldeditor.h"
#include "partterminal.h" #include "partterminal.h"
#include "parttextfield.h" #include "parttextfield.h"
#include "eseventaddline.h"
#include "eseventaddrect.h"
#include "eseventaddellipse.h"
#include "eseventaddpolygon.h"
#include "eseventaddarc.h"
#include "eseventaddtext.h"
#include "eseventaddtextfield.h"
#include "eseventaddterminal.h"
#include <QMessageBox> #include <QMessageBox>
/* /*
Nombre maximum de primitives affichees par la "liste des parties" Nombre maximum de primitives affichees par la "liste des parties"
@@ -130,9 +122,8 @@ void QETElementEditor::setFileName(const QString &fn) {
} }
/** /**
* @brief QETElementEditor::setupActions Met en place les actions
* 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);
open = new QAction(QET::Icons::DocumentOpen, tr("&Ouvrir"), this); open = new QAction(QET::Icons::DocumentOpen, tr("&Ouvrir"), this);
@@ -152,9 +143,36 @@ 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"));
@@ -183,9 +201,19 @@ 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()));
@@ -203,92 +231,72 @@ 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()));
connect(edit_forward, SIGNAL(triggered()), ce_scene, SLOT(slot_bringForward()));
connect(edit_raise, SIGNAL(triggered()), ce_scene, SLOT(slot_raise()));
connect(edit_lower, SIGNAL(triggered()), ce_scene, SLOT(slot_lower()));
connect(edit_backward, SIGNAL(triggered()), ce_scene, SLOT(slot_sendBackward()));
connect(move, SIGNAL(triggered()), ce_scene, SLOT(slot_move()));
connect(add_line, SIGNAL(triggered()), ce_scene, SLOT(slot_addLine()));
connect(add_rectangle, SIGNAL(triggered()), ce_scene, SLOT(slot_addRectangle()));
connect(add_ellipse, SIGNAL(triggered()), ce_scene, SLOT(slot_addEllipse()));
connect(add_polygon, SIGNAL(triggered()), ce_scene, SLOT(slot_addPolygon()));
connect(add_text, SIGNAL(triggered()), ce_scene, SLOT(slot_addText()));
connect(add_arc, SIGNAL(triggered()), ce_scene, SLOT(slot_addArc()));
connect(add_terminal, SIGNAL(triggered()), ce_scene, SLOT(slot_addTerminal()));
connect(add_textfield, SIGNAL(triggered()), ce_scene, SLOT(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()));
/* move -> setCheckable(true);
* Action related to change depth of primitive add_line -> setCheckable(true);
*/ add_rectangle -> setCheckable(true);
m_depth_ag = new QActionGroup(this); add_ellipse -> setCheckable(true);
add_polygon -> setCheckable(true);
add_text -> setCheckable(true);
add_arc -> setCheckable(true);
add_terminal -> setCheckable(true);
add_textfield -> setCheckable(true);
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_raise, SIGNAL(triggered()), ce_scene, SLOT(slot_raise() ));
connect(edit_lower, SIGNAL(triggered()), ce_scene, SLOT(slot_lower() ));
connect(edit_backward, SIGNAL(triggered()), ce_scene, SLOT(slot_sendBackward() ));
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); 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);
QAction *add_line = new QAction(QET::Icons::PartLine, tr("Ajouter une ligne"), parts); parts_toolbar = new QToolBar(tr("Parties", "toolbar title"), this);
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_rectangle, SIGNAL(triggered()), this, SLOT(addRect() ));
connect(add_ellipse, SIGNAL(triggered()), this, SLOT(addEllipse() ));
connect(add_polygon, SIGNAL(triggered()), this, SLOT(addPolygon() ));
connect(add_text, SIGNAL(triggered()), this, SLOT(addText() ));
connect(add_arc, SIGNAL(triggered()), this, SLOT(addArc() ));
connect(add_terminal, SIGNAL(triggered()), this, SLOT(addTerminal() ));
connect(add_textfield, SIGNAL(triggered()), this, SLOT(addTextField() ));
parts_toolbar = addToolBar(tr("Parties", "toolbar title"));
parts_toolbar -> setAllowedAreas(Qt::AllToolBarAreas);
parts_toolbar -> setObjectName("parts"); parts_toolbar -> setObjectName("parts");
parts_toolbar -> addActions(parts -> actions()); foreach (QAction *action, parts -> actions()) parts_toolbar -> addAction(action);
addToolBar(Qt::LeftToolBarArea, parts_toolbar); move -> setChecked(true);
parts_toolbar -> setAllowedAreas(Qt::AllToolBarAreas);
/*
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");
@@ -296,6 +304,8 @@ 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);
@@ -314,9 +324,16 @@ 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()));
@@ -334,8 +351,8 @@ void QETElementEditor::setupActions() {
} }
/** /**
* @brief QETElementEditor::setupMenus Met en place les menus.
*/ */
void QETElementEditor::setupMenus() { void QETElementEditor::setupMenus() {
file_menu = new QMenu(tr("&Fichier"), this); file_menu = new QMenu(tr("&Fichier"), this);
edit_menu = new QMenu(tr("&\311dition"), this); edit_menu = new QMenu(tr("&\311dition"), this);
@@ -350,8 +367,7 @@ void QETElementEditor::setupMenus() {
file_menu -> addAction(new_element); file_menu -> addAction(new_element);
file_menu -> addAction(open); file_menu -> addAction(open);
file_menu -> addAction(open_file); file_menu -> addAction(open_file);
QMenu *recentfile = file_menu -> addMenu(QET::Icons::DocumentOpenRecent, tr("&R\351cemment ouverts")); file_menu -> addMenu(QETApp::elementsRecentFiles() -> menu());
recentfile->addActions(QETApp::elementsRecentFiles()->menu()->actions());
connect(QETApp::elementsRecentFiles(), SIGNAL(fileOpeningRequested(const QString &)), this, SLOT(openRecentFile(const QString &))); connect(QETApp::elementsRecentFiles(), SIGNAL(fileOpeningRequested(const QString &)), this, SLOT(openRecentFile(const QString &)));
file_menu -> addAction(save); file_menu -> addAction(save);
file_menu -> addAction(save_as); file_menu -> addAction(save_as);
@@ -385,9 +401,15 @@ 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 -> addActions(m_depth_ag -> actions()); edit_menu -> addAction(edit_forward);
edit_menu -> addAction(edit_raise);
edit_menu -> addAction(edit_lower);
edit_menu -> addAction(edit_backward);
display_menu -> addActions(m_zoom_ag -> actions()); display_menu -> addAction(zoom_in);
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);
@@ -414,7 +436,10 @@ 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.addActions(m_depth_ag -> actions()); menu.addAction(edit_forward);
menu.addAction(edit_raise);
menu.addAction(edit_lower);
menu.addAction(edit_backward);
menu.exec(event -> globalPos()); menu.exec(event -> globalPos());
} }
@@ -436,13 +461,15 @@ 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);
// Action enabled if primitive selected // actions dependant de la presence de parties selectionnees
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);
foreach (QAction *action, m_depth_ag -> actions()) edit_forward -> setEnabled(selected_items);
action->setEnabled(selected_items); edit_raise -> 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);
@@ -473,6 +500,7 @@ 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);
@@ -558,6 +586,15 @@ 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
@@ -637,8 +674,7 @@ 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()) {
@@ -648,7 +684,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, simple et renvoie de folio doivent poss\351der " tr("Les \351l\351ments ma\356tres, esclaves et simple doivent poss\351der "
"un champ texte comportant le tagg 'label'", "warning description")); "un champ texte comportant le tagg 'label'", "warning description"));
} }
} }
@@ -882,78 +918,6 @@ bool QETElementEditor::isReadOnly() const {
return(read_only); return(read_only);
} }
/**
* @brief QETElementEditor::addLine
* Set line creation interface to scene
*/
void QETElementEditor::addLine() {
ce_scene -> setEventInterface(new ESEventAddLine(ce_scene));
}
/**
* @brief QETElementEditor::addRect
* Set rectangle creation interface to scene
*/
void QETElementEditor::addRect() {
ce_scene -> setEventInterface(new ESEventAddRect(ce_scene));
}
/**
* @brief QETElementEditor::addEllipse
* Set ellipse creation interface to scene
*/
void QETElementEditor::addEllipse() {
ce_scene -> setEventInterface(new ESEventAddEllipse(ce_scene));
}
/**
* @brief QETElementEditor::addPolygon
* Set polygon creation interface to scene
*/
void QETElementEditor::addPolygon() {
ce_scene -> setEventInterface(new ESEventAddPolygon(ce_scene));
}
/**
* @brief QETElementEditor::addArc
* Set arc creation interface to scene
*/
void QETElementEditor::addArc() {
ce_scene -> setEventInterface(new ESEventAddArc(ce_scene));
}
/**
* @brief QETElementEditor::addText
* Set text creation interface to scene
*/
void QETElementEditor::addText() {
ce_scene -> setEventInterface(new ESEventAddText(ce_scene));
}
/**
* @brief QETElementEditor::addTextField
* Set text field creation interface to scene
*/
void QETElementEditor::addTextField() {
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.
*/ */

View File

@@ -23,10 +23,8 @@
#include "elementscene.h" #include "elementscene.h"
#include "orientationset.h" #include "orientationset.h"
#include "elementslocation.h" #include "elementslocation.h"
class ElementItemEditor; class ElementItemEditor;
class ElementView; class ElementView;
/** /**
This class represents an element editor, allowing users to draw, change and This class represents an element editor, allowing users to draw, change and
configure a particular electrical element. configure a particular electrical element.
@@ -36,13 +34,10 @@ class QETElementEditor : public QETMainWindow {
// constructor, destructor // constructor, destructor
public: public:
QETElementEditor(QWidget * = 0); QETElementEditor(QWidget * = 0);
virtual ~QETElementEditor(); virtual ~QETElementEditor();
private: private:
QETElementEditor(const QETElementEditor &); QETElementEditor(const QETElementEditor &);
void setupActions();
void setupMenus();
void setupInterface();
// attributes // attributes
private: private:
@@ -77,10 +72,15 @@ 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;
/// Action group /// toolbars actions
QActionGroup *parts, *m_zoom_ag, *m_depth_ag; QActionGroup *parts;
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
@@ -118,21 +118,14 @@ class QETElementEditor : public QETMainWindow {
virtual void firstActivation(QEvent *); virtual void firstActivation(QEvent *);
private: private:
bool canClose(); void setupActions();
QWidget *clearToolsDock(); void setupMenus();
void copyAndPasteXml(const QDomDocument &); void setupInterface();
bool canClose();
QWidget *clearToolsDock();
void copyAndPasteXml(const QDomDocument &);
public slots: public slots:
void addLine();
void addRect();
void addEllipse();
void addPolygon();
void addArc();
void addText();
void addTextField();
void addTerminal();
void UncheckAddPrimitive();
void slot_new(); void slot_new();
void slot_open(); void slot_open();
void slot_openFile(); void slot_openFile();
@@ -144,6 +137,7 @@ 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();

View File

@@ -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, &state); Element *custom_elmt = ElementFactory::Instance()->createElement(location, 0, 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 {

View File

@@ -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, &elmt_creation_state); Element *temp_elmt = ElementFactory::Instance()->createElement(location, 0, 0, &elmt_creation_state);
if (elmt_creation_state) { if (elmt_creation_state) {
delete temp_elmt; delete temp_elmt;
return; return;

View File

@@ -72,8 +72,6 @@ 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);
@@ -120,8 +118,6 @@ 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()));
@@ -315,25 +311,6 @@ 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.
*/ */
@@ -454,8 +431,6 @@ 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);
@@ -558,10 +533,8 @@ 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);

View File

@@ -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, *prj_move_diagram_upx10, *prj_move_diagram_downx10; 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 *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,8 +67,6 @@ 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();
@@ -83,8 +81,6 @@ 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();

View File

@@ -31,31 +31,29 @@ 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, int *state) Element * ElementFactory::createElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, 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, state)); if (link_type == "next_report" || link_type == "previous_report") return (new ReportElement(location, link_type, qgi, s, state));
if (link_type == "master") return (new MasterElement (location, qgi, state)); if (link_type == "master") return (new MasterElement (location, qgi, s, state));
if (link_type == "slave") return (new SlaveElement (location, qgi, state)); if (link_type == "slave") return (new SlaveElement (location, qgi, s, state));
if (link_type == "terminal") return (new TerminalElement (location, qgi, state)); if (link_type == "terminal") return (new TerminalElement (location, qgi, s, state));
} }
//default if nothing match for link_type //default if nothing match for link_type
return (new SimpleElement(location, qgi, state)); return (new SimpleElement(location, qgi, s, state));
} }

View File

@@ -33,43 +33,41 @@ class Diagram;
*/ */
class ElementFactory class ElementFactory
{ {
//methods for singleton pattern //methods for singleton pattern
public: public:
// return instance of factory // return instance of factory
static ElementFactory* Instance() { static ElementFactory* Instance() {
static QMutex mutex; static QMutex mutex;
if (!factory_) { if (!factory_) {
mutex.lock(); mutex.lock();
if (!factory_) factory_ = new ElementFactory(); if (!factory_) factory_ = new ElementFactory();
mutex.unlock(); mutex.unlock();
}
return factory_;
} }
return factory_;
// delete the instance of factory }
static void dropInstance () { // delete the instance of factory
static QMutex mutex; static void dropInstance () {
if (factory_) { static QMutex mutex;
mutex.lock(); if (factory_) {
delete factory_; mutex.lock();
factory_ = 0; delete factory_;
mutex.unlock(); factory_ = 0;
} mutex.unlock();
} }
}
//attributes //attributes
private: private:
static ElementFactory* factory_; static ElementFactory* factory_;
//methods for the class factory himself //methods for the class factory himself
private: private:
ElementFactory() {} ElementFactory() {}
ElementFactory (const ElementFactory &); ElementFactory (const ElementFactory &);
ElementFactory operator= (const ElementFactory &); ElementFactory operator= (const ElementFactory &);
~ElementFactory() {} ~ElementFactory() {}
public: public:
Element * createElement (const ElementsLocation &, QGraphicsItem * = 0, int * = 0); Element * createElement (const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0, int * = 0);
}; };
//ElementFactory ElementFactory::factory_ = 0; //ElementFactory ElementFactory::factory_ = 0;
#endif // ELEMENTFACTORY_H #endif // ELEMENTFACTORY_H

View File

@@ -969,40 +969,38 @@ void GenericPanel::diagramRemoved(QETProject *project, Diagram *diagram) {
} }
/** /**
* @brief GenericPanel::projectDiagramsOrderChanged @param project Projet auquel appartiennent les schemas concernes
* @param project project where diagram moved @param from Index de l'onglet avant le deplacement
* @param from Index of diagram before move @param to Index de l'onglet apres le deplacement
* @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;
// get the item representing the moved diagram // get the item representing the moved diagram
QTreeWidgetItem *moved_qtwi_diagram = qtwi_project -> child(from); QTreeWidgetItem *moved_qtwi_diagram = qtwi_project -> child(from);
if (!moved_qtwi_diagram) return; if (!moved_qtwi_diagram) return;
// remove the QTWI then insert it back at the adequate location // remove the QTWI then insert it back at the adequate location
bool was_selected = moved_qtwi_diagram -> isSelected(); bool was_selected = moved_qtwi_diagram -> isSelected();
qtwi_project -> removeChild (moved_qtwi_diagram); qtwi_project -> removeChild(moved_qtwi_diagram);
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
for (int i = qMin(from, to); i < qMax(from, to) + 1; i++) foreach (int diagram_index, QList<int>() << from << to) {
{ 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());
} }

View File

@@ -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 qet")+";"+ tr("Label") +";"+ tr("D\351signation")+";"+ tr("Commentaire") +";"+ tr("Fabriquant") +";"+ tr("Reference") +";"+ tr("Machine-reference")+"\n"; data += tr("Folio") +";"+ tr("Sch\351ma") +";"+ tr("D\351signation")+";"+ tr("Label") +";"+ 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,7 +115,6 @@ 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() + ";";

View File

@@ -113,6 +113,13 @@ 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);
} }
@@ -308,8 +315,8 @@ void ProjectView::addNewDiagram() {
*/ */
void ProjectView::addNewDiagramFolioList() { void ProjectView::addNewDiagramFolioList() {
if (project_ -> isReadOnly()) return; if (project_ -> isReadOnly()) return;
int i = 1; //< Each new diagram is added to the end of the project. int i = 0; //< Each new diagram is added to the end of the project.
//< We use @i to move the folio list at second position in the project //< We use @i to move the folio list at the beginning of 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);
@@ -364,19 +371,26 @@ 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
//Ask confirmation to user. if (
int answer = QET::MessageBox::question( diagram_view -> diagram() -> wasWritten() ||\
this, !diagram_view -> diagram() -> undoStack().isClean()
tr("Supprimer le sch\351ma ?", "message box title"), ) {
tr("\312tes-vous s\373r de vouloir supprimer ce sch\351ma du projet ? Ce changement est irr\351versible.", "message box content"), int answer = QET::MessageBox::question(
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, this,
QMessageBox::No tr("Supprimer le sch\351ma ?", "message box title"),
); tr("\312tes-vous s\373r de vouloir supprimer ce sch\351ma du projet ? Ce changement est irr\351versible.", "message box content"),
if (answer != QMessageBox::Yes) { QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
return; QMessageBox::No
);
if (answer != QMessageBox::Yes) {
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);
tabs_ -> removeTab(diagram_tab_id); tabs_ -> removeTab(diagram_tab_id);
@@ -501,48 +515,6 @@ 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.
@@ -805,7 +777,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, + 1); tabs_ -> moveTab(diagrams().size()-1, 0);
} }
} }

View File

@@ -34,6 +34,7 @@ class ProjectView : public QWidget {
public: public:
enum ProjectSaveOption { enum ProjectSaveOption {
ModifiedDiagramsOnly = 1,
CurrentDiagram = 2, CurrentDiagram = 2,
AllDiagramsButCurrent = 4, AllDiagramsButCurrent = 4,
AllDiagrams = 6 AllDiagrams = 6
@@ -73,14 +74,10 @@ 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)); QETResult saveAs(ProjectSaveOptions = ProjectSaveOptions(AllDiagrams | ModifiedDiagramsOnly));
QETResult doSave(ProjectSaveOptions); QETResult doSave(ProjectSaveOptions);
void saveDiagrams(const QList<Diagram *> &); void saveDiagrams(const QList<Diagram *> &);
int cleanProject(); int cleanProject();
@@ -91,6 +88,7 @@ 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);

View File

@@ -683,18 +683,3 @@ 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;
}

View File

@@ -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-rc2"; const QString displayedVersion = "0.4-b";
QString license(); QString license();
/// Oriented movements /// Oriented movements
@@ -154,7 +154,6 @@ 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 {

View File

@@ -346,7 +346,6 @@ 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";
@@ -363,7 +362,6 @@ 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");

View File

@@ -44,12 +44,10 @@
#include <QMessageBox> #include <QMessageBox>
/** /**
* @brief QETDiagramEditor::QETDiagramEditor constructeur
* Constructor @param files Liste de fichiers a ouvrir
* @param files, list of files to open @param parent le widget parent de la fenetre principale
* @param parent, parent widget
*/ */
QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) : QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
QETMainWindow(parent), QETMainWindow(parent),
@@ -59,12 +57,13 @@ 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)
{ {
//Setup the mdi area at center of application // mise en place de l'interface MDI au centre de l'application
setCentralWidget(&workspace); setCentralWidget(&workspace);
//Set object name to be retrieved by the stylesheets // nomme l'objet afin qu'il soit reperable par les feuilles de style
workspace.setBackground(QBrush(Qt::NoBrush)); workspace.setBackground(QBrush(Qt::NoBrush));
workspace.setObjectName("mdiarea"); workspace.setObjectName("mdiarea");
@@ -72,11 +71,16 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
workspace.setTabsClosable(true); workspace.setTabsClosable(true);
#endif #endif
//Set the signal mapper // mise en place du signalmapper
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();
@@ -85,30 +89,37 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
setUpToolBar(); setUpToolBar();
setUpMenu(); setUpMenu();
tabifyDockWidget(qdw_undo, qdw_pa); // la fenetre est maximisee par defaut
//By default the windows is maximised
setMinimumSize(QSize(500, 350)); setMinimumSize(QSize(500, 350));
setWindowState(Qt::WindowMaximized); setWindowState(Qt::WindowMaximized);
connect (&workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(subWindowActivated(QMdiSubWindow*))); // connexions signaux / slots pour une interface sensee
connect (QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(slot_updatePasteAction())); connect(&workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(slot_updateWindowsMenu()));
connect (&undo_group, SIGNAL(cleanChanged(bool)), this, SLOT(activeUndoStackCleanChanged(bool))); connect(&workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(slot_updateUndoStack()));
connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(slot_updatePasteAction()));
// lecture des parametres
readSettings(); readSettings();
// affichage
show(); show();
//If valid file path is given as arguments // si des chemins de fichiers valides sont passes en arguments
uint opened_projects = 0; uint opened_projects = 0;
if (files.count()) if (files.count()) {
{ // alors on ouvre ces fichiers
//So we open this files foreach(QString file, files) {
foreach(QString file, files) bool project_opening = openAndAddProject(file, false);
if (openAndAddProject(file, false)) if (project_opening) {
++ 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();
} }
/** /**
@@ -131,7 +142,6 @@ 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 *)));
@@ -143,8 +153,6 @@ 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 *)));
} }
/** /**
@@ -166,8 +174,6 @@ 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);
} }
/** /**
@@ -613,44 +619,30 @@ void QETDiagramEditor::exportDialog() {
} }
/** /**
* @brief QETDiagramEditor::save Methode enregistrant le schema dans le dernier nom de fichier connu.
* Ask the current active project to save @return true si l'enregistrement a reussi, false sinon
*/ */
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);
} }
} }
} }
/** /**
* @brief QETDiagramEditor::saveAs Cette methode demande un nom de fichier a l'utilisateur pour enregistrer le schema
* Ask the current active project to save as @return true si l'enregistrement a reussi, false sinon
*/ */
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);
} }
} }
@@ -867,8 +859,6 @@ 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);
@@ -1142,36 +1132,38 @@ void QETDiagramEditor::slot_setVisualisationMode() {
} }
/** /**
* @brief QETDiagramEditor::slot_updateActions gere les actions
* 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);
save_file -> setEnabled(editable_project);
save_file_as -> setEnabled(opened_project);
prj_edit_prop -> setEnabled(opened_project);
prj_add_diagram -> setEnabled(editable_project);
//prj_add_diagram_foliolist -> setEnabled(editable_project);
prj_del_diagram -> setEnabled(editable_project);
prj_clean -> setEnabled(editable_project);
prj_diagramList -> setEnabled(opened_project);
prj_nomenclature -> setEnabled(editable_project);
export_diagram -> setEnabled(opened_diagram);
print -> setEnabled(opened_diagram);
infos_diagram -> setEnabled(opened_diagram);
prj_nomenclature -> setEnabled(editable_project);
m_zoom_actions_group.setEnabled(opened_diagram);
m_select_actions_group.setEnabled(opened_diagram);
m_add_item_actions_group.setEnabled(editable_diagram);
m_row_column_actions_group.setEnabled(editable_diagram);
close_file -> setEnabled(opened_project);
save_file_as -> setEnabled(opened_project);
prj_edit_prop -> setEnabled(opened_project);
prj_add_diagram -> setEnabled(editable_project);
prj_del_diagram -> setEnabled(editable_project);
prj_clean -> setEnabled(editable_project);
prj_diagramList -> setEnabled(opened_project);
prj_nomenclature -> setEnabled(editable_project);
export_diagram -> setEnabled(opened_diagram);
print -> setEnabled(opened_diagram);
infos_diagram -> setEnabled(opened_diagram);
prj_nomenclature -> setEnabled(editable_project);
m_zoom_actions_group. setEnabled(opened_diagram);
m_select_actions_group. setEnabled(opened_diagram);
m_add_item_actions_group. setEnabled(editable_project);
m_row_column_actions_group.setEnabled(editable_project);
slot_updateUndoStack();
slot_updateModeActions(); slot_updateModeActions();
slot_updatePasteAction(); slot_updatePasteAction();
slot_updateComplexActions(); slot_updateComplexActions();
@@ -1181,17 +1173,12 @@ 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) if (pv && can_update_actions) {
{
undo_group.setActiveStack(pv->project()->undoStack()); undo_group.setActiveStack(pv->project()->undoStack());
save_file -> setEnabled (undo_group.activeStack() -> count() && !pv -> project() -> isReadOnly()); undo -> setEnabled (undo_group.canUndo());
} redo -> setEnabled (undo_group.canRedo());
else
{
save_file -> setDisabled(true);
} }
} }
@@ -1223,14 +1210,13 @@ 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_element_texts) + selected_image + selected_shape; int selected_editable = selected_elements_count + (selected_texts - selected_conductor_texts) + selected_image + selected_shape;
if (selected_editable == 1) { if (selected_editable == 1) {
edit_selection -> setEnabled(true); edit_selection -> setEnabled(true);
@@ -1297,46 +1283,65 @@ void QETDiagramEditor::slot_updatePasteAction() {
} }
/** /**
* @brief QETDiagramEditor::addProjectView Ajoute un projet dans l'espace de travail
* Add a new project view to workspace and @param project_view Le projet a ajouter dans l'espace de travail
* 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;
foreach(DiagramView *dv, project_view -> diagrams()) // on maximise la nouvelle fenetre si la fenetre en cours est inexistante ou bien maximisee
diagramWasAdded(dv);
//Manage the close event of project
connect(project_view, SIGNAL(projectClosed(ProjectView*)), this, SLOT(projectWasClosed(ProjectView *)));
//Manage the adding of diagram
connect(project_view, SIGNAL(diagramAdded(DiagramView *)), this, SLOT(diagramWasAdded(DiagramView *)));
if (QETProject *project = project_view -> project())
connect(project, SIGNAL(readOnlyChanged(QETProject *, bool)), this, SLOT(slot_updateActions()));
//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(editElementRequired(const ElementsLocation &)), this, SLOT(editElementInEditor(const ElementsLocation &)));
connect(project_view, SIGNAL(editTitleBlockTemplate(const TitleBlockTemplateLocation &, bool)), QETApp::instance(), SLOT(openTitleBlockTemplate(TitleBlockTemplateLocation, bool)));
// display error messages sent by the project view
connect(project_view, SIGNAL(errorEncountered(QString)), this, SLOT(showError(const QString &)));
//We maximise the new window if the current window is inexistent or maximized
QWidget *current_window = workspace.activeSubWindow(); QWidget *current_window = workspace.activeSubWindow();
bool maximise = ((!current_window) || (current_window -> windowState() & Qt::WindowMaximized)); bool maximise = ((!current_window) || (current_window -> windowState() & Qt::WindowMaximized));
//Add the new window // ajoute la fenetre
QMdiSubWindow *sub_window = workspace.addSubWindow(project_view); QMdiSubWindow *sub_window = workspace.addSubWindow(project_view);
sub_window -> setWindowIcon(project_view -> windowIcon()); sub_window -> setWindowIcon(project_view -> windowIcon());
sub_window -> systemMenu() -> clear(); sub_window -> systemMenu() -> clear();
//Display the new window // 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);
}
// gere la fermeture du projet
connect(project_view, SIGNAL(projectClosed(ProjectView*)), this, SLOT(projectWasClosed(ProjectView *)));
// 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(slot_updateActions()));
connect(project_view, SIGNAL(diagramAboutToBeRemoved(DiagramView *)), this, SLOT(diagramIsAboutToBeRemoved(DiagramView *)));
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()));
}
// gere les demandes consistant a retrouver un element dans le panel
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 &)));
// 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
connect(project_view, SIGNAL(errorEncountered(QString)), this, SLOT(showError(const QString &)));
// affiche la fenetre
if (maximise) project_view -> showMaximized(); if (maximise) project_view -> showMaximized();
else project_view -> show(); else project_view -> show();
slot_updateActions();
} }
/** /**
@@ -1661,7 +1666,6 @@ 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();
@@ -1708,7 +1712,7 @@ void QETDiagramEditor::addDiagramToProject() {
*/ */
void QETDiagramEditor::addDiagramFolioListToProject() { void QETDiagramEditor::addDiagramFolioListToProject() {
if (ProjectView *current_project = currentProject()) if (ProjectView *current_project = currentProject())
current_project -> addNewDiagramFolioList(); current_project -> addNewDiagramFolioList();
} }
/** /**
@@ -1788,46 +1792,6 @@ 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
*/ */
@@ -1853,6 +1817,7 @@ 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.
@@ -1884,15 +1849,34 @@ void QETDiagramEditor::removeDiagramFromProject() {
} }
/** /**
* @brief QETDiagramEditor::diagramWasAdded Gere l'ajout d'un schema dans un projet
* Manage the adding of diagram view in a project @param dv DiagramView concerne
* @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();
} }
/** /**
@@ -1986,28 +1970,3 @@ 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);
}
}

View File

@@ -79,159 +79,156 @@ class QETDiagramEditor : public QETMainWindow {
QMdiSubWindow *subWindowForWidget(QWidget *) const; QMdiSubWindow *subWindowForWidget(QWidget *) const;
public slots: public slots:
void printDialog(); void printDialog();
void exportDialog(); void exportDialog();
void save(); void save();
void saveAs(); void saveAs();
bool newProject(); bool newProject();
bool openProject(); bool openProject();
bool openRecentFile(const QString &); bool openRecentFile(const QString &);
bool closeProject(ProjectView *); bool closeProject(ProjectView *);
bool closeProject(QETProject *); bool closeProject(QETProject *);
bool closeCurrentProject(); bool closeCurrentProject();
void slot_cut(); void slot_cut();
void slot_copy(); void slot_copy();
void slot_paste(); void slot_paste();
void slot_zoomIn(); void slot_zoomIn();
void slot_zoomOut(); void slot_zoomOut();
void slot_zoomFit(); void slot_zoomFit();
void slot_zoomContent(); void slot_zoomContent();
void slot_zoomReset(); void slot_zoomReset();
void slot_selectAll(); void slot_selectAll();
void slot_selectNothing(); void slot_selectNothing();
void slot_selectInvert(); void slot_selectInvert();
void slot_delete(); void slot_delete();
void slot_rotate(); void slot_rotate();
void slot_rotateTexts(); void slot_rotateTexts();
void slot_setSelectionMode(); void slot_setSelectionMode();
void slot_setVisualisationMode(); void slot_setVisualisationMode();
void slot_updateActions(); void slot_updateActions();
void slot_updateUndoStack(); void slot_updateUndoStack();
void slot_updateModeActions(); void slot_updateModeActions();
void slot_updateComplexActions(); void slot_updateComplexActions();
void slot_updatePasteAction(); void slot_updatePasteAction();
void slot_updateWindowsMenu(); void slot_updateWindowsMenu();
void slot_addColumn(); void slot_addColumn();
void slot_removeColumn(); void slot_removeColumn();
void slot_addRow(); void slot_addRow();
void slot_removeRow(); void slot_removeRow();
void editSelectionProperties(); void editSelectionProperties();
void slot_resetConductors(); void slot_resetConductors();
void slot_addText(); void slot_addText();
void slot_addImage(); void slot_addImage();
void slot_addLine(); void slot_addLine();
void slot_addRectangle(); void slot_addRectangle();
void slot_addEllipse(); void slot_addEllipse();
void slot_addPolyline(); void slot_addPolyline();
void slot_editSelection(); void slot_editSelection();
void setWindowedMode(); void setWindowedMode();
void setTabbedMode(); void setTabbedMode();
void readSettings(); void readSettings();
void writeSettings(); void writeSettings();
void activateDiagram(Diagram *); void activateDiagram(Diagram *);
void activateProject(QETProject *); void activateProject(QETProject *);
void activateProject(ProjectView *); void activateProject(ProjectView *);
void activateWidget(QWidget *); void activateWidget(QWidget *);
void projectWasClosed(ProjectView *); void projectWasClosed(ProjectView *);
void editCurrentProjectProperties(); void editCurrentProjectProperties();
void editProjectProperties(ProjectView *); void editProjectProperties(ProjectView *);
void editProjectProperties(QETProject *); void editProjectProperties(QETProject *);
void editCurrentDiagramProperties(); void editCurrentDiagramProperties();
void editDiagramProperties(DiagramView *); void editDiagramProperties(DiagramView *);
void editDiagramProperties(Diagram *); void editDiagramProperties(Diagram *);
void addDiagramToProject(); void addDiagramToProject();
void addDiagramFolioListToProject(); void addDiagramFolioListToProject();
void addDiagramToProject(QETProject *); void addDiagramToProject(QETProject *);
void removeDiagram(Diagram *); void removeDiagram(Diagram *);
void removeDiagramFromProject(); void removeDiagramFromProject();
void moveDiagramUp(Diagram *); void moveDiagramUp(Diagram *);
void moveDiagramDown(Diagram *); void moveDiagramDown(Diagram *);
void moveDiagramUpx10(Diagram *); void cleanCurrentProject();
void moveDiagramDownx10(Diagram *); void nomenclatureProject();
void cleanCurrentProject(); void diagramWasAdded(DiagramView *);
void nomenclatureProject(); void diagramIsAboutToBeRemoved(DiagramView *);
void diagramWasAdded(DiagramView *); void diagramWasRemoved(DiagramView *);
void findElementInPanel(const ElementsLocation &); void findElementInPanel(const ElementsLocation &);
void findSelectedElementInPanel(); void findSelectedElementInPanel();
void editElementInEditor(const ElementsLocation &); void editElementInEditor(const ElementsLocation &);
void editSelectedElementInEditor(); void editSelectedElementInEditor();
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: // attributes
void activeUndoStackCleanChanged (bool clean);
// attributes
public: public:
// Actions reachable through menus within QElectroTech // Actions reachable through menus within QElectroTech
QActionGroup *grp_visu_sel; ///< Action group for visualisation vs edition mode QActionGroup *grp_visu_sel; ///< Action group for visualisation vs edition mode
QActionGroup *grp_view_mode; ///< Action group for project QActionGroup *grp_view_mode; ///< Action group for project
QAction *tabbed_view_mode; ///< Display projects as tabs QAction *tabbed_view_mode; ///< Display projects as tabs
QAction *windowed_view_mode; ///< Display projects as windows QAction *windowed_view_mode; ///< Display projects as windows
QAction *mode_selection; ///< Set edition mode QAction *mode_selection; ///< Set edition mode
QAction *mode_visualise; ///< Set visualisation mode QAction *mode_visualise; ///< Set visualisation mode
QAction *export_diagram; ///< Export diagrams of the current project as imagess QAction *export_diagram; ///< Export diagrams of the current project as imagess
QAction *print; ///< Print diagrams of the current project QAction *print; ///< Print diagrams of the current project
QAction *quit_editor; ///< Quit the diagram editor QAction *quit_editor; ///< Quit the diagram editor
QAction *undo; ///< Cancel the latest action QAction *undo; ///< Cancel the latest action
QAction *redo; ///< Redo the latest cancelled operation QAction *redo; ///< Redo the latest cancelled operation
QAction *cut; ///< Cut selection to clipboard QAction *cut; ///< Cut selection to clipboard
QAction *copy; ///< Copy selection to clipboard QAction *copy; ///< Copy selection to clipboard
QAction *paste; ///< Paste clipboard content on the current diagram QAction *paste; ///< Paste clipboard content on the current diagram
QAction *conductor_reset; ///< Reset paths of selected conductors QAction *conductor_reset; ///< Reset paths of selected conductors
QAction *conductor_default; ///< Show a dialog to edit default conductor properties QAction *conductor_default; ///< Show a dialog to edit default conductor properties
QAction *infos_diagram; ///< Show a dialog to edit diagram properties QAction *infos_diagram; ///< Show a dialog to edit diagram properties
QAction *prj_edit_prop; ///< Edit the properties of the current project. QAction *prj_edit_prop; ///< Edit the properties of the current project.
QAction *prj_add_diagram; ///< Add a diagram to the current project. QAction *prj_add_diagram; ///< Add a diagram to the current project.
QAction *prj_del_diagram; ///< Delete a diagram from the current project QAction *prj_del_diagram; ///< Delete a diagram from the current project
QAction *prj_clean; ///< Clean the content of the curent project by removing useless items QAction *prj_clean; ///< Clean the content of the curent project by removing useless items
QAction *prj_diagramList; ///< Sommaire des schemas QAction *prj_diagramList; ///< Sommaire des schemas
QAction *prj_nomenclature; ///< generate nomenclature QAction *prj_nomenclature; ///< generate nomenclature
QAction *tile_window; ///< Show MDI subwindows as tile QAction *tile_window; ///< Show MDI subwindows as tile
QAction *cascade_window; ///< Show MDI subwindows as cascade QAction *cascade_window; ///< Show MDI subwindows as cascade
QAction *prev_window; ///< Switch to the previous document QAction *prev_window; ///< Switch to the previous document
QAction *next_window; ///< Switch to the next document QAction *next_window; ///< Switch to the next document
QAction *edit_selection; ///< To edit selected item QAction *edit_selection; ///< To edit selected item
QActionGroup m_add_item_actions_group; ///Action related to adding (add text image shape...) QActionGroup m_add_item_actions_group; ///Action related to adding (add text image shape...)
QActionGroup m_zoom_actions_group; ///Action related to zoom for diagram QActionGroup m_zoom_actions_group; ///Action related to zoom for diagram
QList <QAction *> m_zoom_action_toolBar; ///Only zoom action must displayed in the toolbar QList <QAction *> m_zoom_action_toolBar; ///Only zoom action must displayed in the toolbar
QActionGroup m_select_actions_group; ///Action related to global selections QActionGroup m_select_actions_group; ///Action related to global selections
QActionGroup m_selection_actions_group; ///Action related to edit a selected item QActionGroup m_selection_actions_group; ///Action related to edit a selected item
QAction *delete_selection; ///< Delete selection QAction *delete_selection; ///< Delete selection
QAction *rotate_selection; ///< Rotate selected elements and text items by 90 degrees QAction *rotate_selection; ///< Rotate selected elements and text items by 90 degrees
QAction *rotate_texts; ///< Direct selected text items to a specific angle QAction *rotate_texts; ///< Direct selected text items to a specific angle
QAction *find_element; ///< Find the selected element in the panel QAction *find_element; ///< Find the selected element in the panel
QAction *selection_prop; ///< Show a dialog describing the selection QAction *selection_prop; ///< Show a dialog describing the selection
QActionGroup m_row_column_actions_group; /// Action related to add/remove rows/column in diagram QActionGroup m_row_column_actions_group; /// Action related to add/remove rows/column in diagram
QActionGroup m_file_actions_group; ///Actions related to file (open, close, save...) QActionGroup m_file_actions_group; ///Actions related to file (open, close, save...)
QAction *close_file; ///< Close current project file QAction *close_file; ///< Close current project file
QAction *save_file; ///< Save current project QAction *save_file; ///< Save current project
QAction *save_file_as; ///< Save current project as a specific file QAction *save_file_as; ///< Save current project as a specific file
private: private:
QMdiArea workspace; QMdiArea workspace;
QSignalMapper windowMapper; QSignalMapper windowMapper;
/// Directory to use for file dialogs such as File > save /// Directory to use for file dialogs such as File > save
QDir open_dialog_dir; QDir open_dialog_dir;
/// Dock for the elements panel /// Dock for the elements panel
QDockWidget *qdw_pa; QDockWidget *qdw_pa;
/// Dock for the undo list /// Dock for the undo list
QDockWidget *qdw_undo; QDockWidget *qdw_undo;
/// Elements panel /// Elements panel
ElementsPanelWidget *pa; ElementsPanelWidget *pa;
QMenu *windows_menu; QMenu *windows_menu;
QToolBar *main_bar; QToolBar *main_bar;
QToolBar *view_bar; QToolBar *view_bar;
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

View File

@@ -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,DiagramContext)), this, SLOT (updateLabel())); connect(elmt, SIGNAL(elementInfoChange(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(70, 100)); QRectF drawing_rect(QPointF(0,0), QSizeF(100, 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,7 +129,6 @@ 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;
} }

View File

@@ -39,12 +39,11 @@ 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) : Conductor::Conductor(Terminal *p1, Terminal* p2, Diagram *parent_diagram) :
QObject(), QObject(),
QGraphicsPathItem(0), QGraphicsPathItem(0, parent_diagram),
terminal1(p1), terminal1(p1),
terminal2(p2), terminal2(p2),
bMouseOver(false),
destroyed_(false), destroyed_(false),
text_item(0), text_item(0),
segments(NULL), segments(NULL),
@@ -92,6 +91,7 @@ Conductor::Conductor(Terminal *p1, Terminal* p2) :
// 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,10 +444,6 @@ 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;
@@ -681,6 +677,7 @@ void Conductor::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
if (!(e -> modifiers() & Qt::ControlModifier)) { if (!(e -> modifiers() & Qt::ControlModifier)) {
QGraphicsPathItem::mouseReleaseEvent(e); QGraphicsPathItem::mouseReleaseEvent(e);
} }
calculateTextItemPosition();
} }
/** /**
@@ -690,8 +687,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;
bMouseOver = true; if (isSelected()) {
update(); update();
}
} }
/** /**
@@ -701,23 +699,24 @@ 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;
update(); if (isSelected()) {
bMouseOver = false; update();
}
} }
/** /**
* @brief Conductor::hoverMoveEvent conductor Gere les mouvements de souris au dessus du conducteur
* @param e QGraphicsSceneHoverEvent describing the event @param e Le QGraphicsSceneHoverEvent decrivant l'evenement
*/ */
void Conductor::hoverMoveEvent(QGraphicsSceneHoverEvent *e) { void Conductor::hoverMoveEvent(QGraphicsSceneHoverEvent *e) {
/*
if (isSelected()) { if (isSelected()) {
QPointF hover_point = mapFromScene(e -> pos()) + scenePos(); QPointF hover_point = mapFromScene(e -> pos());
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::ForbiddenCursor); setCursor(Qt::CrossCursor);
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);
@@ -727,7 +726,7 @@ void Conductor::hoverMoveEvent(QGraphicsSceneHoverEvent *e) {
} }
if (!cursor_set) setCursor(Qt::ArrowCursor); if (!cursor_set) setCursor(Qt::ArrowCursor);
} }
*/
QGraphicsPathItem::hoverMoveEvent(e); QGraphicsPathItem::hoverMoveEvent(e);
} }
@@ -952,66 +951,27 @@ bool Conductor::hasClickedOn(QPointF press_point, QPointF point) const {
} }
/** /**
* @brief Conductor::fromXml Charge les caracteristiques du conducteur depuis un element XML.
* Load the conductor and her information from xml element @param e Un element XML
* @param e @return true si le chargement a reussi, false sinon
* @return true is loading success else return false
*/
bool Conductor::fromXml(QDomElement &e) {
setPos(e.attribute("x", 0).toDouble(),
e.attribute("y", 0).toDouble());
bool return_ = pathFromXml(e);
text_item -> fromXml(e);
properties_. fromXml(e);
readProperties();
return return_;
}
/**
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 { bool Conductor::fromXml(QDomElement &e) {
QDomElement e = d.createElement("conductor"); // recupere la "configuration" du conducteur
properties_.fromXml(e);
e.setAttribute("x", pos().x()); readProperties();
e.setAttribute("y", pos().y()); qreal user_pos_x, user_pos_y;
e.setAttribute("terminal1", table_adr_id.value(terminal1)); if (
e.setAttribute("terminal2", table_adr_id.value(terminal2)); QET::attributeIsAReal(e, "userx", &user_pos_x) &&
QET::attributeIsAReal(e, "usery", &user_pos_y)
// on n'exporte les segments du conducteur que si ceux-ci ont ) {
// ete modifies par l'utilisateur text_item -> forceMovedByUser(true);
if (modified_path) { text_item -> setPos(user_pos_x, user_pos_y);
// parcours et export des segments }
QDomElement current_segment; if (e.hasAttribute("rotation")) {
foreach(ConductorSegment *segment, segmentsList()) { text_item -> setRotationAngle(e.attribute("rotation").toDouble());
current_segment = d.createElement("segment"); text_item -> forceRotateByUser(true);
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;
@@ -1037,12 +997,8 @@ bool Conductor::pathFromXml(const QDomElement &e) {
} }
} }
//If there isn't segment we generate automatic path and return true // s'il n'y a pas de segments, on renvoie true
if (!segments_x.size()) { if (!segments_x.size()) return(true);
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;
@@ -1064,7 +1020,7 @@ bool Conductor::pathFromXml(const 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 << mapFromScene(t1); points_list << 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),
@@ -1082,6 +1038,43 @@ bool Conductor::pathFromXml(const 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 *>());
@@ -1335,11 +1328,8 @@ 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;
{ readProperties();
properties_ = p;
readProperties();
}
} }
/** /**

View File

@@ -41,13 +41,13 @@ class Conductor : public QObject, public QGraphicsPathItem {
Q_PROPERTY(QPointF pos READ pos WRITE setPos) Q_PROPERTY(QPointF pos READ pos WRITE setPos)
Q_PROPERTY(int animPath READ fakePath WRITE updatePathAnimate) Q_PROPERTY(int animPath READ fakePath WRITE updatePathAnimate)
// constructors, destructor // constructors, destructor
public: public:
Conductor(Terminal *, Terminal *); Conductor(Terminal *, Terminal *, Diagram * = 0);
virtual ~Conductor(); virtual ~Conductor();
private: private:
Conductor(const Conductor &); Conductor(const Conductor &);
// attributes // attributes
public: public:
@@ -92,15 +92,9 @@ 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 &);
static bool valideXml(QDomElement &);
public: bool fromXml(QDomElement &);
static bool valideXml (QDomElement &); QDomElement toXml(QDomDocument &, QHash<Terminal *, int> &) const;
bool fromXml (QDomElement &);
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;
@@ -130,8 +124,6 @@ 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_;

View File

@@ -25,14 +25,12 @@
@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) : ConductorTextItem::ConductorTextItem(Conductor *parent_conductor, Diagram *parent_diagram) :
DiagramTextItem(parent_conductor), DiagramTextItem(parent_conductor, parent_diagram),
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
@@ -40,8 +38,8 @@ ConductorTextItem::ConductorTextItem(Conductor *parent_conductor) :
@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) : ConductorTextItem::ConductorTextItem(const QString &text, Conductor *parent_conductor, Diagram *parent_diagram) :
DiagramTextItem(text, parent_conductor), DiagramTextItem(text, parent_conductor, parent_diagram),
parent_conductor_(parent_conductor), parent_conductor_(parent_conductor),
moved_by_user_(false), moved_by_user_(false),
rotate_by_user_(false) rotate_by_user_(false)
@@ -62,36 +60,38 @@ Conductor *ConductorTextItem::parentConductor() const {
} }
/** /**
* @brief ConductorTextItem::fromXml Permet de lire le texte a mettre dans le champ a partir d'un element XML.
* Read the properties stored in the xml element given in parameter Cette methode se base sur la position du champ pour assigner ou non la
* @param e valeur a ce champ.
*/ @param e L'element XML representant le champ de texte
*/
void ConductorTextItem::fromXml(const QDomElement &e) { void ConductorTextItem::fromXml(const QDomElement &e) {
if (e.hasAttribute("userx")) { setPlainText(e.attribute("text"));
setPos(e.attribute("userx").toDouble(),
e.attribute("usery").toDouble()); qreal user_pos_x, user_pos_y;
moved_by_user_ = true; if (
} QET::attributeIsAReal(e, "userx", &user_pos_x) &&
if (e.hasAttribute("rotation")) { QET::attributeIsAReal(e, "usery", &user_pos_y)
setRotation(e.attribute("rotation").toDouble()); ) {
rotate_by_user_ = true; setPos(user_pos_x, user_pos_y);
} }
setRotationAngle(e.attribute("rotation").toDouble());
} }
/** /**
* @brief ConductorTextItem::toXml @param document Le document XML a utiliser
* Export the properties of this text in the attribute of the xml element given in parameter @return L'element XML representant ce champ de texte
* The properties exported are position and rotation (only if moved or rotate by user) */
* @param xml QDomElement ConductorTextItem::toXml(QDomDocument &document) const {
*/ QDomElement result = document.createElement("input");
void ConductorTextItem::toXml(QDomElement &xml) const { result.setAttribute("userx", QString("%1").arg(pos().x()));
if (moved_by_user_) { result.setAttribute("usery", QString("%1").arg(pos().y()));
xml.setAttribute("userx", QString("%1").arg(pos().x())); result.setAttribute("text", toPlainText());
xml.setAttribute("usery", QString("%1").arg(pos().y())); if (rotationAngle()) {
} result.setAttribute("rotation", QString("%1").arg(rotationAngle()));
if (rotate_by_user_) {
xml.setAttribute("rotation", QString("%1").arg(rotation()));
} }
return(result);
} }
/** /**
@@ -203,40 +203,3 @@ 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);
}

View File

@@ -31,8 +31,8 @@ class ConductorTextItem : public DiagramTextItem {
// constructors, destructor // constructors, destructor
public: public:
ConductorTextItem(Conductor * = 0); ConductorTextItem(Conductor * = 0, Diagram * = 0);
ConductorTextItem(const QString &, Conductor * = 0); ConductorTextItem(const QString &, Conductor * = 0, Diagram * = 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 void toXml (QDomElement &xml) const; virtual QDomElement toXml(QDomDocument &) const;
// methods // methods
public: public:
@@ -57,11 +57,6 @@ 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_;

View File

@@ -32,20 +32,14 @@
* @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()));
@@ -112,13 +106,6 @@ 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
@@ -170,12 +157,11 @@ void CrossRefItem::updateProperties() {
* Update the content of the item * Update the content of the item
*/ */
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
QPainter qp; QPainter qp;
qp.begin(&m_drawing); qp.begin(&m_drawing);
QPen pen_; QPen pen_;
@@ -183,7 +169,7 @@ void CrossRefItem::updateLabel() {
qp.setPen(pen_); qp.setPen(pen_);
qp.setFont(QETApp::diagramTextsFont(5)); qp.setFont(QETApp::diagramTextsFont(5));
//Draw cross or contact, only if master element is linked. //Draw cross or contact, only if master element is linked.
if (! m_element->linkedElements().isEmpty()) { if (! m_element->linkedElements().isEmpty()) {
XRefProperties::DisplayHas dh = m_properties.displayHas(); XRefProperties::DisplayHas dh = m_properties.displayHas();
@@ -197,6 +183,8 @@ void CrossRefItem::updateLabel() {
qp.end(); qp.end();
autoPos(); autoPos();
update();
checkMustShow();
} }
/** /**
@@ -286,42 +274,36 @@ 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) {
//No need to calcul if nothing is linked //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
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);
//There is no string to display, we return now //Adjust the size of default_bounding if needed.
if (no_str.isEmpty() && nc_str.isEmpty()) return; //We calcule the size by using a single text
//because in the method fillCrossRef, the text is draw like this (aka single text)
//this is the default size of cross ref item //Adjust according to the NO
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
QRectF bounding = painter.boundingRect(QRectF (), Qt::AlignCenter, no_str); QRectF bounding = painter.boundingRect(QRectF (), Qt::AlignCenter, no_str);
if (bounding.height() > default_bounding.height() - header) if (bounding.height() > default_bounding.height() - header)
default_bounding.setHeight(bounding.height() + header); //adjust the height default_bounding.setHeight(bounding.height() + header); //adjust the height
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
//Adjust according to the NC //Adjust according to the NC
bounding = painter.boundingRect(QRectF (), Qt::AlignCenter, nc_str); bounding = painter.boundingRect(QRectF (), Qt::AlignCenter, nc_str);
if (bounding.height() > default_bounding.height() - header) if (bounding.height() > default_bounding.height() - header)
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);
prepareGeometryChange();
m_bounding_rect = default_bounding;
} }
m_shape_path.addRect(default_bounding);
m_bounding_rect = default_bounding;
} }
/** /**
@@ -330,25 +312,22 @@ void CrossRefItem::setUpCrossBoundingRect(QPainter &painter) {
* @param painter, painter to use * @param painter, painter to use
*/ */
void CrossRefItem::drawHasCross(QPainter &painter) { 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 //draw the cross
if (boundingRect().isEmpty()) return;
//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
painter.drawLine(0, header, br.width(), header); //horizontal line painter.drawLine(0, header, br.width(), header); //horizontal line
//Add the symbolic contacts //Add the symbolic contacts
buildHeaderContact(); buildHeaderContact();
QPointF p((m_bounding_rect.width()/4) - (m_hdr_no_ctc.width()/2), 0); QPointF p((m_bounding_rect.width()/4) - (m_hdr_no_ctc.width()/2), 0);
painter.drawPicture (p, m_hdr_no_ctc); painter.drawPicture (p, m_hdr_no_ctc);
p.setX((m_bounding_rect.width() * 3/4) - (m_hdr_nc_ctc.width()/2)); p.setX((m_bounding_rect.width() * 3/4) - (m_hdr_nc_ctc.width()/2));
painter.drawPicture (p, m_hdr_nc_ctc); painter.drawPicture (p, m_hdr_nc_ctc);
//and fill it //and fill it
fillCrossRef(painter); fillCrossRef(painter);
} }
@@ -358,8 +337,6 @@ 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
@@ -384,7 +361,6 @@ 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);
} }
@@ -516,6 +492,8 @@ 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);
} }
/** /**
@@ -524,29 +502,64 @@ void CrossRefItem::fillCrossRef(QPainter &painter) {
* @param painter painter to use for draw the text * @param painter painter to use for draw the text
*/ */
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 - 35, boundingRect().bottom()), r = QRectF(QPointF(center - 50, boundingRect().bottom()),
QPointF(center + 35, boundingRect().bottom() + 50)); QPointF(center + 50, 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
@@ -555,6 +568,6 @@ void CrossRefItem::AddExtraInfo(QPainter &painter) {
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 text tagged 'label' found to set has parent"; else qDebug() << "CrossRefItem,no texte tagged 'label' found to set has parent";
} }

View File

@@ -48,14 +48,14 @@ class CrossRefItem : public QGraphicsObject
virtual int type() const { return Type; } virtual int type() const { return Type; }
enum CONTACTS { enum CONTACTS {
NO = 1, NO = 1,
NC = 2, NC = 2,
NOC = 3, NOC = 3,
SW = 4, SW = 4,
Power = 8, Power = 8,
DelayOn = 16, DelayOn = 16,
DelayOff = 32, DelayOff = 32,
Delay = 48 Delay = 48
}; };
QRectF boundingRect () const; QRectF boundingRect () const;
@@ -82,6 +82,7 @@ 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

View File

@@ -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, int *state) : CustomElement::CustomElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) :
FixedElement(qgi), FixedElement(qgi, s),
elmt_state(-1), elmt_state(-1),
location_(location), location_(location),
forbid_antialiasing(false) forbid_antialiasing(false)
@@ -137,12 +137,13 @@ 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");
//the definition must have childs // la definition est supposee avoir des enfants
if (xml_def_elmt.firstChild().isNull()) if (xml_def_elmt.firstChild().isNull()) {
{
if (state) *state = 6; if (state) *state = 6;
return(false); return(false);
} }
@@ -758,7 +759,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); Terminal *new_terminal = new Terminal(terminalx, terminaly, terminalo, this, qobject_cast<Diagram *>(scene()));
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);

Some files were not shown because too many files have changed in this diff Show More