diff options
author | Aleks Kissinger <aleks0@gmail.com> | 2018-03-12 21:44:49 +0100 |
---|---|---|
committer | Aleks Kissinger <aleks0@gmail.com> | 2018-03-12 21:44:49 +0100 |
commit | 39c2c74c664a6c770639ead8f45322352cacb997 (patch) | |
tree | e93bf563eef3c3cd9762b36d06205b91e35a33db | |
parent | 09c331761648541de907c866c56fb6084c6f7a9b (diff) |
style loading works
-rw-r--r-- | images/crop.svg | 48 | ||||
-rw-r--r-- | images/refresh.svg | 1 | ||||
-rw-r--r-- | src/data/graphelementdata.cpp | 2 | ||||
-rw-r--r-- | src/data/node.cpp | 2 | ||||
-rw-r--r-- | src/data/nodestyle.cpp | 119 | ||||
-rw-r--r-- | src/data/nodestyle.h | 32 | ||||
-rw-r--r-- | src/data/project.cpp | 13 | ||||
-rw-r--r-- | src/data/project.h | 21 | ||||
-rw-r--r-- | src/data/tikzassembler.cpp | 14 | ||||
-rw-r--r-- | src/data/tikzassembler.h | 10 | ||||
-rw-r--r-- | src/data/tikzlexer.l | 2 | ||||
-rw-r--r-- | src/data/tikzparser.y | 7 | ||||
-rw-r--r-- | src/data/tikzstyles.cpp | 36 | ||||
-rw-r--r-- | src/data/tikzstyles.h | 29 | ||||
-rw-r--r-- | src/gui/nodeitem.cpp | 6 | ||||
-rw-r--r-- | src/gui/toolpalette.cpp | 2 | ||||
-rw-r--r-- | src/main.cpp | 1 | ||||
-rw-r--r-- | src/tikzit.cpp | 91 | ||||
-rw-r--r-- | src/tikzit.h | 14 | ||||
-rw-r--r-- | stylepalette.cpp | 33 | ||||
-rw-r--r-- | stylepalette.h | 5 | ||||
-rw-r--r-- | stylepalette.ui | 197 | ||||
-rw-r--r-- | tikzit.pro | 8 | ||||
-rw-r--r-- | tikzit.qrc | 1 |
24 files changed, 457 insertions, 237 deletions
diff --git a/images/crop.svg b/images/crop.svg index 226faa8..d10e9ba 100644 --- a/images/crop.svg +++ b/images/crop.svg @@ -1,47 +1 @@ -<?xml version="1.0" encoding="iso-8859-1"?> -<!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> -<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" - viewBox="0 0 60 60" style="enable-background:new 0 0 60 60;" xml:space="preserve"> -<g> - <path style="fill:#26B99A;" d="M59.707,0.293c-0.391-0.391-1.023-0.391-1.414,0l-14,14L39,19.586l-19.5,19.5l-5.207,5.207l-14,14 - c-0.391,0.391-0.391,1.023,0,1.414C0.488,59.902,0.744,60,1,60s0.512-0.098,0.707-0.293l14-14l5.207-5.207l19.5-19.5l5.293-5.293 - l14-14C60.098,1.316,60.098,0.684,59.707,0.293z"/> - <polygon style="fill:#7383BF;" points="15,45 15,1 7,1 7,43 7,53 17,53 59,53 59,45 "/> - <g> - <polygon style="fill:#556080;" points="15,15 45,15 45,45 53,45 53,17 53,7 43,7 15,7 "/> - <rect x="1" y="7" style="fill:#556080;" width="6" height="8"/> - <rect x="45" y="53" style="fill:#556080;" width="8" height="6"/> - </g> -</g> -<g> -</g> -<g> -</g> -<g> -</g> -<g> -</g> -<g> -</g> -<g> -</g> -<g> -</g> -<g> -</g> -<g> -</g> -<g> -</g> -<g> -</g> -<g> -</g> -<g> -</g> -<g> -</g> -<g> -</g> -</svg> +<?xml version="1.0" ?><svg enable-background="new 0 0 128 129.396" height="48" id="svg2" overflow="visible" version="1.0" width="48" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><defs id="defs365"><linearGradient id="linearGradient3099"><stop id="stop3101" offset="0" style="stop-color:#ffffff;stop-opacity:1;"/><stop id="stop3103" offset="1" style="stop-color:#ffffff;stop-opacity:0;"/></linearGradient><linearGradient id="linearGradient3078"><stop id="stop3080" offset="0" style="stop-color:#c4a000"/><stop id="stop3082" offset="1" style="stop-color:#fce94f"/></linearGradient><linearGradient gradientUnits="userSpaceOnUse" id="XMLID_45_" x1="68.175293" x2="74.587158" y1="21.424805" y2="27.836672"><stop id="stop695" offset="0" style="stop-color:#BABDB6"/><stop id="stop697" offset="1" style="stop-color:#EEEEEC"/></linearGradient><radialGradient cx="165.06104" cy="23.333008" gradientTransform="matrix(1.000000,0.000000,0.000000,1.010300,1.007969e-18,-0.159801)" gradientUnits="userSpaceOnUse" id="XMLID_52_" r="7.2848282"><stop id="stop812" offset="0" style="stop-color:#EF3535"/><stop id="stop2239" offset="0" style="stop-color:#c91a1a;stop-opacity:1;"/><stop id="stop814" offset="1" style="stop-color:#ff4c4c;stop-opacity:1;"/></radialGradient><linearGradient gradientTransform="matrix(2.051000,0.000000,0.167200,-0.989000,-799.2049,221.0724)" gradientUnits="userSpaceOnUse" id="path3311_1_" x1="1420.5474" x2="1420.6542" y1="-50.919434" y2="-79.574341"><stop id="stop4970" offset="0" style="stop-color:#C4A000"/><stop id="stop4972" offset="1" style="stop-color:#957A00"/></linearGradient><linearGradient gradientTransform="matrix(1.213800,0.000000,0.282500,-1.671200,46.72625,447.9442)" gradientUnits="userSpaceOnUse" id="path3230_2_" x1="1668.7646" x2="1679.5989" y1="185.30176" y2="175.78883"><stop id="stop4977" offset="0" style="stop-color:#FFFFFF"/><stop id="stop4979" offset="1" style="stop-color:#CFCFCF"/></linearGradient><linearGradient gradientUnits="userSpaceOnUse" id="XMLID_897_" x1="292.97168" x2="296.93979" y1="4.7592773" y2="10.711433"><stop id="stop45093" offset="0" style="stop-color:#EEEEEC"/><stop id="stop45095" offset="1" style="stop-color:#ffffff;stop-opacity:1;"/></linearGradient><radialGradient cx="165.06104" cy="23.333008" gradientTransform="matrix(1.000000,0.000000,0.000000,1.010300,1.007969e-18,-0.159801)" gradientUnits="userSpaceOnUse" id="radialGradient16850" r="7.2848282"><stop id="stop16852" offset="0" style="stop-color:#EF3535"/><stop id="stop16854" offset="1" style="stop-color:#a40000;stop-opacity:0"/></radialGradient><linearGradient id="linearGradient2229"><stop id="stop2231" offset="0" style="stop-color:#e2e2e2;stop-opacity:1;"/><stop id="stop2233" offset="1" style="stop-color:#d8d8d8;stop-opacity:1;"/></linearGradient><linearGradient id="linearGradient2251"><stop id="stop2253" offset="0" style="stop-color:#df2a2a;stop-opacity:1;"/><stop id="stop2255" offset="1" style="stop-color:#df2a2a;stop-opacity:0;"/></linearGradient><linearGradient id="linearGradient2259"><stop id="stop2261" offset="0" style="stop-color:#9a0c00;stop-opacity:1;"/><stop id="stop2263" offset="1" style="stop-color:#9a0c00;stop-opacity:0;"/></linearGradient><linearGradient id="linearGradient2269"><stop id="stop2271" offset="0" style="stop-color:#000000;stop-opacity:1;"/><stop id="stop2273" offset="1" style="stop-color:#000000;stop-opacity:0;"/></linearGradient><linearGradient gradientTransform="matrix(1.213781,0,0.282495,-1.671173,-1834.231,751.0328)" gradientUnits="userSpaceOnUse" id="linearGradient1890" x1="1668.7646" x2="1679.5989" xlink:href="#path3230_2_" y1="185.30176" y2="175.78883"/><linearGradient gradientTransform="matrix(1.213781,0,0.282495,-1.671173,-1774.231,387.0328)" gradientUnits="userSpaceOnUse" id="linearGradient1893" x1="1668.7646" x2="1679.5989" xlink:href="#path3230_2_" y1="185.30176" y2="175.78883"/><linearGradient gradientTransform="matrix(2.050967,0,0.167197,-0.988984,-2791.942,99.82423)" gradientUnits="userSpaceOnUse" id="linearGradient1896" x1="1420.5474" x2="1420.6542" xlink:href="#path3311_1_" y1="-50.919434" y2="-79.574341"/><linearGradient gradientTransform="matrix(-4.127761,0,0,4.136601,2003.489,504.25)" gradientUnits="userSpaceOnUse" id="linearGradient2975" x1="292.97168" x2="296.93979" xlink:href="#XMLID_897_" y1="4.7592773" y2="10.711433"/><linearGradient gradientTransform="translate(759.0237,516.155)" gradientUnits="userSpaceOnUse" id="linearGradient2977" x1="20.288025" x2="24.32597" xlink:href="#linearGradient2229" y1="6.4603648" y2="23.942537"/><linearGradient gradientUnits="userSpaceOnUse" id="linearGradient2979" x1="294.59497" x2="297.18515" xlink:href="#XMLID_52_" y1="12.187603" y2="13.3396"/><linearGradient gradientTransform="matrix(3.637893,0,0,3.470375,-297.0923,500.1478)" gradientUnits="userSpaceOnUse" id="linearGradient2981" x1="296.48611" x2="296.52905" xlink:href="#XMLID_52_" y1="15.506916" y2="9.8769522"/><linearGradient gradientTransform="matrix(4.053427,0,0,4.136601,-416.5113,504.25)" gradientUnits="userSpaceOnUse" id="linearGradient2983" x1="292.97168" x2="296.93979" xlink:href="#XMLID_897_" y1="4.7592773" y2="10.711433"/><linearGradient gradientTransform="translate(759.0237,516.155)" gradientUnits="userSpaceOnUse" id="linearGradient2985" x1="20.288025" x2="24.32597" xlink:href="#linearGradient2229" y1="6.4603648" y2="23.942537"/><linearGradient gradientUnits="userSpaceOnUse" id="linearGradient2987" x1="22.225399" x2="24.190449" xlink:href="#XMLID_45_" y1="23.843431" y2="22.860907"/><linearGradient gradientTransform="matrix(1.161878,0,0,0.992497,756.5929,516.4208)" gradientUnits="userSpaceOnUse" id="linearGradient2989" x1="7.184845" x2="25.152235" xlink:href="#XMLID_52_" y1="31.056622" y2="50.774887"/><linearGradient gradientTransform="matrix(1.161878,0,0,0.992497,756.3567,516.219)" gradientUnits="userSpaceOnUse" id="linearGradient2991" x1="13.82536" x2="7.6700611" xlink:href="#XMLID_52_" y1="40.068752" y2="2.3262277"/><radialGradient cx="34.376091" cy="37.50008" fx="34.376091" fy="37.50008" gradientTransform="matrix(1,0,0,1.060381,759.0237,513.8555)" gradientUnits="userSpaceOnUse" id="radialGradient2993" r="8.3887873" xlink:href="#XMLID_52_"/><linearGradient gradientUnits="userSpaceOnUse" id="linearGradient2995" x1="298.47852" x2="298.86948" xlink:href="#linearGradient2251" y1="13.599585" y2="13.802949"/><linearGradient gradientUnits="userSpaceOnUse" id="linearGradient2997" x1="298.47852" x2="298.86948" xlink:href="#linearGradient2259" y1="13.599585" y2="13.802949"/><linearGradient gradientTransform="matrix(3.624438,0,0,3.624438,-294.1553,499.3078)" gradientUnits="userSpaceOnUse" id="linearGradient2999" x1="296.76199" x2="297.79822" xlink:href="#XMLID_52_" y1="12.012225" y2="10.946587"/><linearGradient gradientTransform="matrix(1.161878,0,0,0.992497,753.9116,516.219)" gradientUnits="userSpaceOnUse" id="linearGradient3001" x1="39.619942" x2="-3.532515" xlink:href="#radialGradient16850" y1="44.540932" y2="-11.889042"/><radialGradient cx="25.1875" cy="41.625" fx="25.1875" fy="41.625" gradientTransform="matrix(1,0,0,0.32526,2.352345e-13,28.08607)" gradientUnits="userSpaceOnUse" id="radialGradient3003" r="18.0625" xlink:href="#linearGradient2269"/><linearGradient gradientUnits="userSpaceOnUse" id="linearGradient3084" x1="42.426411" x2="32.350136" xlink:href="#linearGradient3078" y1="58.076275" y2="16.35697"/><linearGradient gradientUnits="userSpaceOnUse" id="linearGradient3105" x1="28.835155" x2="52.131729" xlink:href="#linearGradient3099" y1="11.913623" y2="70.073158"/><radialGradient cx="25.1875" cy="41.625" fx="25.1875" fy="41.625" gradientTransform="matrix(1,0,0,0.32526,2.34556e-13,28.08607)" gradientUnits="userSpaceOnUse" id="radialGradient3253" r="18.0625" xlink:href="#linearGradient2269"/></defs><path d="M 43.25 41.625 A 18.0625 5.875 0 1 1 7.125,41.625 A 18.0625 5.875 0 1 1 43.25 41.625 z" id="path3251" style="opacity:0.26704544;color:#000000;fill:url(#radialGradient3253);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" transform="matrix(0.968858,0,0,0.465206,6.096886,24.90272)"/><path d="M 44.46875 3.6875 L 16.4375 44.46875 L 44.46875 44.46875 L 44.46875 3.6875 z M 38.53125 23.5 L 38.53125 37.5 L 29.5 37.5 L 38.53125 23.5 z " id="path1465" style="fill:url(#linearGradient3084);fill-opacity:1.0;fill-rule:evenodd;stroke:#c4a000;stroke-width:1.02738464px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"/><path d="M 43.5,43.5 L 43.5,6.8437499 L 18.375,43.4375 L 43.5,43.5 z " id="path3006" style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:url(#linearGradient3105);stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;opacity:0.63874346"/><g id="g1903" transform="matrix(0.827925,0,0,0.827925,-628.8636,-425.078)"><path d="M 793.19801,517.78 C 793.40996,517.84854 793.61527,517.92466 793.82199,517.9975 C 794.47341,520.1945 797.49348,522.41622 796.34505,524.60413 C 792.51921,530.98452 788.72072,537.44957 784.92346,543.88027 C 784.17771,544.02717 783.42543,544.10718 782.67169,544.12496 C 781.0853,544.16517 779.45676,543.93047 777.95113,543.39089 C 783.002,534.83962 788.055,526.26948 793.19801,517.78 z " id="path16717" style="fill:url(#linearGradient2975);stroke:#888a85;stroke-width:1.2078383;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"/><path d="M 793.31252,520.405 C 793.0814,520.71245 792.86291,521.27594 792.62649,521.56125 C 788.57964,528.31398 784.46448,535.05533 780.40268,541.78 C 780.34213,542.03312 779.58875,542.79229 780.39063,542.72296 C 781.50219,542.92084 782.66238,543.07357 783.77046,542.78 C 787.52945,536.56279 791.21634,530.29758 794.96675,524.07818 C 795.30922,523.6909 795.37586,523.15292 795.0161,522.7662 C 794.48609,521.94959 793.94916,521.09148 793.40607,520.31125 L 793.33551,520.38196 L 793.31252,520.405 z " id="path16719" style="fill:url(#linearGradient2977);fill-opacity:1;stroke:none;stroke-width:1.25;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"/><polygon id="polygon45129" points="297.04443,12.300293 296.39941,13.384766 295.13281,14.71875 294.73242,13.672852 295.74658,11.960449 297.04443,12.300293 " style="fill:url(#linearGradient2979);fill-opacity:1;stroke:#9a0c00;stroke-width:0.33993483;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" transform="matrix(3.637893,0,0,3.470375,-297.0923,500.1478)"/><path d="M 779.42995,543.12375 C 778.2076,543.61047 778.21593,545.15893 777.50497,546.08776 C 777.16265,546.80356 776.56118,547.43399 776.30495,548.18625 C 776.29527,548.70164 776.7529,549.54647 777.3362,549.0925 C 778.72118,547.94617 779.90057,546.55382 780.78042,544.96563 C 781.01279,544.4756 781.57618,544.07147 781.6487,543.56125 C 781.11013,542.99044 780.13588,543.02823 779.42995,543.12375 z " id="polygon16896" style="fill:url(#linearGradient2981);fill-opacity:1;stroke:none;stroke-width:1.00000012;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"/><path d="M 771.9838,517.78 C 771.77567,517.84854 771.57405,517.92466 771.37105,517.9975 C 770.73137,520.1945 767.76569,522.41622 768.89343,524.60413 C 772.65038,530.98452 776.38046,537.44957 780.10934,543.88027 C 780.84166,544.02717 781.58039,544.10718 782.32055,544.12496 C 783.87838,544.16517 785.47759,543.93047 786.95611,543.39089 C 781.99619,534.83962 777.03419,526.26948 771.9838,517.78 z " id="polygon45097" style="fill:url(#linearGradient2983);stroke:#888a85;stroke-width:1.2078383;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"/><path d="M 771.74337,520.405 C 771.36033,521.53168 770.29371,522.36096 770.02855,523.56125 C 773.73708,529.95536 777.4995,536.33038 781.20546,542.7175 C 782.40382,542.9758 783.6339,542.81066 784.81881,542.56125 C 784.63004,541.82081 784.08061,541.23032 783.78883,540.5317 C 779.89423,533.96117 775.96513,527.39787 772.11083,520.81125 C 772.09617,520.65964 771.89412,520.32712 771.74337,520.405 z " id="path16635" style="fill:url(#linearGradient2985);fill-opacity:1;stroke:none;stroke-width:1.25;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"/><path d="M 24.190449 23.843431 A 0.98252523 0.98252523 0 1 1 22.225399,23.843431 A 0.98252523 0.98252523 0 1 1 24.190449 23.843431 z" id="path16731" style="color:#000000;fill:url(#linearGradient2987);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.25;stroke-linecap:round;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" transform="matrix(0.979893,0,0,1,759.3351,516.329)"/><path d="M 776.72409,546.44193 C 779.9591,548.16858 780.21993,553.05485 777.30204,557.35629 C 774.38418,561.66025 769.39755,563.75147 766.16108,562.03242 C 762.92458,560.30577 762.66525,555.42203 765.58314,551.1206 C 768.49951,546.81917 773.48762,544.72794 776.72409,546.44193 z M 774.86897,549.18408 C 773.43244,548.42045 770.36151,549.7246 768.40263,552.61811 C 766.43972,555.51161 766.57973,558.53162 768.0149,559.29295 C 769.45005,560.06118 772.52369,558.75243 774.48257,555.85892 C 776.44683,552.96542 776.30546,549.94771 774.86897,549.18408 z " id="path45138" style="fill:url(#linearGradient2989);fill-opacity:1;stroke:#a40000;stroke-opacity:1"/><path d="M 773.3492,546.73829 C 771.42407,547.12551 769.71474,548.19231 768.30229,549.21953 C 767.55053,549.91443 767.05873,550.66945 766.38664,551.47374 C 764.67832,553.8258 763.96241,556.91717 765.31381,559.54341 C 765.93326,560.99651 767.95644,561.59085 769.68202,561.22254 C 771.13394,560.97408 772.36334,560.06147 773.49443,559.42364 C 774.41534,558.63286 775.04845,557.79713 775.82733,556.83236 C 777.63669,554.35796 778.61924,551.08369 777.1253,548.32008 C 776.4016,547.17795 774.89066,546.57329 773.3492,546.73829 z M 773.82121,547.69977 C 775.83772,547.95012 777.17819,549.73258 776.94376,551.42163 C 776.96453,553.70857 775.79774,555.86573 774.22061,557.65576 C 772.8034,559.05774 770.87199,560.38403 768.55645,560.29208 C 767.1976,560.28921 766.12388,559.37978 765.74063,558.33162 C 765.12399,555.79969 765.93535,553.06639 767.70683,550.99362 C 769.06507,549.47031 770.90168,548.10652 773.17434,547.75193 C 773.39003,547.73665 773.60522,547.70943 773.82121,547.69977 z " id="path16771" style="fill:url(#linearGradient2991);fill-opacity:1;stroke:none;stroke-opacity:1"/><path d="M 789.35546,546.44193 C 786.12045,548.16858 785.85963,553.05485 788.77752,557.35629 C 791.69538,561.66025 796.68201,563.75147 799.91848,562.03242 C 803.15498,560.30577 803.41431,555.42203 800.49642,551.1206 C 797.58005,546.81917 792.59193,544.72794 789.35546,546.44193 z M 791.21059,549.18408 C 792.64711,548.42045 795.71805,549.7246 797.67693,552.61811 C 799.63984,555.51161 799.49983,558.53162 798.06466,559.29295 C 796.62951,560.06118 793.55587,558.75243 791.59699,555.85892 C 789.63273,552.96542 789.77409,549.94771 791.21059,549.18408 z " id="path11967" style="fill:url(#radialGradient2993);fill-opacity:1;stroke:#a40000;stroke-opacity:1"/><polygon id="polygon45101" points="296.95605,12.300293 297.6001,13.384766 298.86719,14.71875 299.26807,13.672852 298.25391,11.960449 296.95605,12.300293 " style="fill:url(#linearGradient2995);fill-opacity:1;stroke:url(#linearGradient2997);stroke-width:0.3332485;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" transform="matrix(3.624438,0,0,3.624438,-294.1553,499.3078)"/><path d="M 785.17995,544.0925 C 784.7532,544.29132 784.16314,544.29398 783.8362,544.5925 C 784.78622,545.99389 785.72611,547.50716 786.68708,548.80508 C 787.35563,549.55962 788.04289,550.3053 788.80495,550.9675 C 789.54023,549.57608 788.94011,547.90629 787.99245,546.78 C 787.38991,545.88031 787.16263,544.66704 786.1487,544.18625 C 785.84465,544.06784 785.49808,544.00837 785.17995,544.0925 z " id="polygon16860" style="fill:url(#linearGradient2999);fill-opacity:1;stroke:none;stroke-width:0.27590489;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"/><path d="M 791.30379,546.60409 C 789.7834,546.83384 788.40884,547.68975 788.06334,548.99206 C 786.93219,551.38751 787.84846,554.10557 789.34312,556.21891 C 790.44504,557.56411 791.28319,559.14882 792.9827,559.99288 C 794.45335,560.9165 796.32384,561.88345 798.20034,561.29377 C 799.71366,560.86032 800.57101,559.6132 800.88051,558.32191 C 801.48494,556.01188 800.58482,553.64595 799.17355,551.68543 C 798.51487,550.77172 797.84056,549.80222 797.06023,548.99078 C 795.86567,548.08733 794.42231,547.33925 792.97139,546.75843 C 792.43729,546.64802 791.85616,546.52569 791.30379,546.60409 z M 791.73949,547.8137 C 793.4968,547.74692 794.974,548.55316 796.11586,549.58266 C 797.14816,550.55179 798.13752,551.38787 798.77837,552.58154 C 799.85556,554.40211 800.16623,556.5615 799.61848,558.54507 C 799.0901,559.86958 797.39232,560.51711 795.82736,560.16152 C 793.84548,559.93269 792.61002,558.4905 791.30079,557.35316 C 789.79504,555.92177 788.86017,553.87453 788.79021,551.87078 C 788.80432,550.85311 788.76374,549.69236 789.48835,548.83721 C 789.90063,548.29406 790.86836,547.78289 791.73949,547.8137 z " id="path16795" style="fill:url(#linearGradient3001);fill-opacity:1;stroke:none;stroke-opacity:1"/><path d="M 43.25 41.625 A 18.0625 5.875 0 1 1 7.125,41.625 A 18.0625 5.875 0 1 1 43.25 41.625 z" id="path2267" style="opacity:0.26704544;color:#000000;fill:url(#radialGradient3003);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" transform="matrix(1.256055,0,0,0.819149,751.8243,525.2454)"/></g><path d="M 43.506026,40.61612 L 42.747596,40.61612" id="path3022" style="opacity:1;fill:#2e3436;fill-opacity:0.75;fill-rule:evenodd;stroke:#c4a000;stroke-width:0.99999964px;stroke-linecap:square;stroke-linejoin:miter;stroke-opacity:1"/><path d="M 43.506026,36.61612 L 42.747596,36.61612" id="path3046" style="opacity:1;fill:#2e3436;fill-opacity:0.75;fill-rule:evenodd;stroke:#c4a000;stroke-width:0.99999964px;stroke-linecap:square;stroke-linejoin:miter;stroke-opacity:1"/><path d="M 43.506026,32.61612 L 42.747596,32.61612" id="path3050" style="opacity:1;fill:#2e3436;fill-opacity:0.75;fill-rule:evenodd;stroke:#c4a000;stroke-width:0.99999964px;stroke-linecap:square;stroke-linejoin:miter;stroke-opacity:1"/><path d="M 43.506026,28.61612 L 42.747596,28.61612" id="path3054" style="opacity:1;fill:#2e3436;fill-opacity:0.75;fill-rule:evenodd;stroke:#c4a000;stroke-width:0.99999964px;stroke-linecap:square;stroke-linejoin:miter;stroke-opacity:1"/><path d="M 43.506026,24.61612 L 42.747596,24.61612" id="path3058" style="opacity:1;fill:#2e3436;fill-opacity:0.75;fill-rule:evenodd;stroke:#c4a000;stroke-width:0.99999964px;stroke-linecap:square;stroke-linejoin:miter;stroke-opacity:1"/><path d="M 43.506026,20.61612 L 42.747596,20.61612" id="path3062" style="opacity:1;fill:#2e3436;fill-opacity:0.75;fill-rule:evenodd;stroke:#c4a000;stroke-width:0.99999964px;stroke-linecap:square;stroke-linejoin:miter;stroke-opacity:1"/><path d="M 43.506026,16.61612 L 42.747596,16.61612" id="path3066" style="opacity:1;fill:#2e3436;fill-opacity:0.75;fill-rule:evenodd;stroke:#c4a000;stroke-width:0.99999964px;stroke-linecap:square;stroke-linejoin:miter;stroke-opacity:1"/><path d="M 43.506026,12.61612 L 42.747596,12.61612" id="path3070" style="opacity:1;fill:#2e3436;fill-opacity:0.75;fill-rule:evenodd;stroke:#c4a000;stroke-width:0.99999964px;stroke-linecap:square;stroke-linejoin:miter;stroke-opacity:1"/></svg>
\ No newline at end of file diff --git a/images/refresh.svg b/images/refresh.svg new file mode 100644 index 0000000..29dff8a --- /dev/null +++ b/images/refresh.svg @@ -0,0 +1 @@ +<?xml version="1.0" ?><svg height="48px" id="svg11300" width="48px" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><defs id="defs3"><linearGradient id="linearGradient2690"><stop id="stop2692" offset="0" style="stop-color:#c4d7eb;stop-opacity:1;"/><stop id="stop2694" offset="1" style="stop-color:#c4d7eb;stop-opacity:0;"/></linearGradient><linearGradient id="linearGradient2682"><stop id="stop2684" offset="0" style="stop-color:#3977c3;stop-opacity:1;"/><stop id="stop2686" offset="1" style="stop-color:#89aedc;stop-opacity:0;"/></linearGradient><linearGradient id="linearGradient2402"><stop id="stop2404" offset="0" style="stop-color:#729fcf;stop-opacity:1;"/><stop id="stop2406" offset="1" style="stop-color:#528ac5;stop-opacity:1;"/></linearGradient><linearGradient id="linearGradient2380"><stop id="stop2382" offset="0" style="stop-color:#b9cfe7;stop-opacity:1"/><stop id="stop2384" offset="1" style="stop-color:#729fcf;stop-opacity:1"/></linearGradient><linearGradient id="linearGradient2871"><stop id="stop2873" offset="0" style="stop-color:#3465a4;stop-opacity:1;"/><stop id="stop2875" offset="1" style="stop-color:#3465a4;stop-opacity:1"/></linearGradient><linearGradient id="linearGradient2847"><stop id="stop2849" offset="0" style="stop-color:#3465a4;stop-opacity:1;"/><stop id="stop2851" offset="1" style="stop-color:#3465a4;stop-opacity:0;"/></linearGradient><linearGradient id="linearGradient2831"><stop id="stop2833" offset="0" style="stop-color:#3465a4;stop-opacity:1;"/><stop id="stop2855" offset="0.33333334" style="stop-color:#5b86be;stop-opacity:1;"/><stop id="stop2835" offset="1" style="stop-color:#83a8d8;stop-opacity:0;"/></linearGradient><linearGradient id="linearGradient2797"><stop id="stop2799" offset="0" style="stop-color:#ffffff;stop-opacity:1;"/><stop id="stop2801" offset="1" style="stop-color:#ffffff;stop-opacity:0;"/></linearGradient><linearGradient id="linearGradient8662"><stop id="stop8664" offset="0" style="stop-color:#000000;stop-opacity:1;"/><stop id="stop8666" offset="1" style="stop-color:#000000;stop-opacity:0;"/></linearGradient><linearGradient gradientTransform="translate(0.465413,-0.277593)" gradientUnits="userSpaceOnUse" id="linearGradient1486" x1="13.478554" x2="15.419417" xlink:href="#linearGradient2831" y1="10.612206" y2="19.115122"/><linearGradient gradientTransform="matrix(-1,0,0,-1,47.52791,45.84741)" gradientUnits="userSpaceOnUse" id="linearGradient1488" x1="37.128052" x2="37.065414" xlink:href="#linearGradient2847" y1="29.729605" y2="26.194071"/><linearGradient gradientUnits="userSpaceOnUse" id="linearGradient1491" x1="5.9649176" x2="52.854097" xlink:href="#linearGradient2797" y1="26.048164" y2="26.048164"/><linearGradient gradientUnits="userSpaceOnUse" id="linearGradient1493" x1="5.9649176" x2="52.854097" xlink:href="#linearGradient2797" y1="26.048164" y2="26.048164"/><linearGradient gradientUnits="userSpaceOnUse" id="linearGradient1501" x1="46.834816" x2="45.380436" xlink:href="#linearGradient2871" y1="45.264122" y2="50.939667"/><radialGradient cx="24.837126" cy="36.421127" fx="24.837126" fy="36.421127" gradientTransform="matrix(1,0,0,0.536723,-9.680928e-14,16.87306)" gradientUnits="userSpaceOnUse" id="radialGradient1503" r="15.644737" xlink:href="#linearGradient8662"/><linearGradient gradientUnits="userSpaceOnUse" id="linearGradient2386" x1="62.513836" x2="15.984863" xlink:href="#linearGradient2380" y1="36.061237" y2="20.60858"/><linearGradient gradientUnits="userSpaceOnUse" id="linearGradient2408" x1="18.935766" x2="53.588622" xlink:href="#linearGradient2402" y1="23.667896" y2="26.649362"/><linearGradient gradientUnits="userSpaceOnUse" id="linearGradient2688" x1="36.713837" x2="37.124462" xlink:href="#linearGradient2682" y1="31.455952" y2="24.842253"/><linearGradient gradientUnits="userSpaceOnUse" id="linearGradient2696" x1="32.647972" x2="37.124462" xlink:href="#linearGradient2690" y1="30.748846" y2="24.842253"/></defs><g id="layer1"><path d="M 40.481863 36.421127 A 15.644737 8.3968935 0 1 1 9.1923885,36.421127 A 15.644737 8.3968935 0 1 1 40.481863 36.421127 z" id="path8660" style="opacity:0.38333333;color:#000000;fill:url(#radialGradient1503);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" transform="matrix(-1.489736,0,0,-1.001252,61.20865,75.2819)"/><path d="M 20.152913,10.409904 C 20.152913,10.409904 11.215413,9.784904 13.965413,20.284904 L 6.2779132,20.284904 C 6.2779132,20.284904 6.7779132,8.409904 20.152913,10.409904 z " id="path2865" style="color:#000000;fill:url(#linearGradient1486);fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient1488);stroke-width:0.99999958;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:block;overflow:visible"/><g id="g1878" style="fill:url(#linearGradient2386);fill-opacity:1.0;stroke:#3465a4;stroke-opacity:1" transform="matrix(-0.579051,-0.489228,-0.489228,0.579051,56.91585,13.37137)"><path d="M 44.306783,50.229694 C 62.821497,35.818859 49.664587,13.411704 22.462411,12.49765 L 22.113843,3.1515478 L 7.6245439,20.496754 L 22.714328,33.219189 C 22.714328,33.219189 22.462411,23.337969 22.462411,23.337969 C 41.292171,24.336946 55.444038,37.409698 44.306783,50.229694 z " id="path1880" style="opacity:1;color:#000000;fill:url(#linearGradient2386);fill-opacity:1.0;fill-rule:nonzero;stroke:url(#linearGradient1501);stroke-width:1.31916928;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:block;overflow:visible"/></g><path d="M 28.375,33.4375 C 28.375,33.4375 37.3125,34.0625 34.5625,23.5625 L 42.338388,23.5625 C 42.338388,25.065102 41.75,35.4375 28.375,33.4375 z " id="path2839" style="color:#000000;fill:url(#linearGradient2696);fill-opacity:1.0;fill-rule:nonzero;stroke:url(#linearGradient2688);stroke-width:0.99999958;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:block;overflow:visible"/><g id="g2779" style="color:#000000;fill:url(#linearGradient2408);fill-opacity:1.0;fill-rule:nonzero;stroke:url(#linearGradient1501);stroke-width:1.31916928;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:block;overflow:visible;opacity:1" transform="matrix(0.579051,0.489228,0.489228,-0.579051,-7.921023,30.53599)"><path d="M 44.306783,50.229694 C 62.821497,35.818859 49.664587,13.411704 22.462411,12.49765 L 22.399432,3.0690297 L 7.793943,20.424005 L 22.462411,33.006349 C 22.462411,33.006349 22.462411,23.337969 22.462411,23.337969 C 41.292171,24.336946 55.444038,37.409698 44.306783,50.229694 z " id="path2781" style="opacity:1;color:#000000;fill:url(#linearGradient2408);fill-opacity:1.0;fill-rule:nonzero;stroke:url(#linearGradient1501);stroke-width:1.31916928;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:block;overflow:visible"/></g><path d="M 7.0625,38.1875 L 7.125,23.3125 L 20.0625,22.9375 L 15.673627,28.116317 L 19.540852,30.489516 C 16.540852,32.739516 14.991304,32.911644 13.991304,35.474144 L 11.174446,33.363872 L 7.0625,38.1875 z " id="path2791" style="opacity:0.27222224;color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.99999982;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"/><g id="g2793" style="opacity:0.5;fill:none;fill-opacity:1;stroke:#ffffff;stroke-opacity:1" transform="matrix(0.508536,0.429651,0.429651,-0.508536,-3.973188,30.54119)"><path d="M 51.090265,45.943705 C 60.210465,30.723955 46.631614,12.20113 19.485058,11.948579 L 19.513464,3.7032834 L 6.5341979,19.296639 L 19.367661,30.26876 C 19.367661,30.26876 19.423281,21.261882 19.423281,21.261882 C 36.951096,21.037973 54.618466,31.365254 51.090265,45.943705 z " id="path2795" style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient1493);stroke-width:1.50208926;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:block;overflow:visible"/></g><g id="g2805" style="opacity:0.5;fill:none;fill-opacity:1;stroke:#ffffff;stroke-opacity:1" transform="matrix(-0.508536,-0.429651,-0.429651,0.508536,53.049,13.36548)"><path d="M 51.389927,46.505946 C 60.510127,31.286196 47.050763,12.432359 19.628482,12.069755 L 19.342824,4.0507204 L 6.3413093,19.379475 L 19.809059,30.764589 C 19.809059,30.764589 19.627294,21.311346 19.627294,21.311346 C 37.872231,21.693318 54.411175,32.236592 51.389927,46.505946 z " id="path2807" style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient1491);stroke-width:1.50208926;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:block;overflow:visible"/></g><path d="M 6.8125,16.5 C 10.405935,6.0587275 23.256282,10.355393 27,12 C 31.175307,12.211475 32.674736,9.164996 36,9 C 21.950264,-0.7899963 7.1875,2.5 6.8125,16.5 z " id="path2811" style="opacity:0.27222224;color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.99999982;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"/></g></svg>
\ No newline at end of file diff --git a/src/data/graphelementdata.cpp b/src/data/graphelementdata.cpp index 41fcbf0..43f7516 100644 --- a/src/data/graphelementdata.cpp +++ b/src/data/graphelementdata.cpp @@ -66,7 +66,7 @@ QString GraphElementData::property(QString key) if (i != -1) { return _properties[i].value(); } else { - return 0; + return QString(); // null QString } } diff --git a/src/data/node.cpp b/src/data/node.cpp index f94a3df..c78f49c 100644 --- a/src/data/node.cpp +++ b/src/data/node.cpp @@ -70,7 +70,7 @@ void Node::setStyleName(const QString &styleName) void Node::attachStyle() { if (_styleName == "none") _style = noneStyle; - else _style = tikzit->nodeStyle(_styleName); + else _style = tikzit->styles()->nodeStyle(_styleName); } NodeStyle *Node::style() const diff --git a/src/data/nodestyle.cpp b/src/data/nodestyle.cpp index 7eca791..e38d3a3 100644 --- a/src/data/nodestyle.cpp +++ b/src/data/nodestyle.cpp @@ -1,32 +1,113 @@ #include "nodestyle.h" +#include <QPainter> NodeStyle *noneStyle = new NodeStyle(); -NodeStyle::NodeStyle() +NodeStyle::NodeStyle() : _name("none"), _data(0) { - name = "none"; - shape = NodeShape::Circle; - fillColor = Qt::white; - strokeColor = Qt::black; - strokeThickness = 1; } -NodeStyle::NodeStyle(QString nm, NodeShape sh, QColor fillCol) + +NodeStyle::NodeStyle(QString name, GraphElementData *data): _name(name), _data(data) +{ +} + +bool NodeStyle::isNone() { return _data == 0; } + +GraphElementData *NodeStyle::data() const +{ + return _data; +} + +QString NodeStyle::name() const +{ + return _name; +} + +NodeShape NodeStyle::shape() const { - name = nm; - shape = sh; - fillColor = fillCol; - strokeColor = Qt::black; - strokeThickness = 1; + QString sh = _data->property("shape"); + if (sh.isNull()) return NodeShape::Circle; + else if (sh == "circle") return NodeShape::Circle; + else if (sh == "rectangle") return NodeShape::Rectangle; + else return NodeShape::Circle; } -NodeStyle::NodeStyle(QString nm, NodeShape sh, QColor fillCol, QColor strokeCol, int strokeThick) +QColor NodeStyle::fillColor() const { - name = nm; - shape = sh; - fillColor = fillCol; - strokeColor = strokeCol; - strokeThickness = strokeThick; + QString col = _data->property("fill"); + + if (col.isNull()) { + return QColor(Qt::white); + } else { + QColor namedColor(col); + if (namedColor.isValid()) { + return namedColor; + } else { + // TODO: read RGB colors + return QColor(Qt::white); + } + } +} + +QColor NodeStyle::strokeColor() const +{ + QString col = _data->property("draw"); + + if (col.isNull()) { + return QColor(Qt::black); + } else { + QColor namedColor(col); + if (namedColor.isValid()) { + return namedColor; + } else { + // TODO: read RGB colors + return QColor(Qt::white); + } + } +} + +int NodeStyle::strokeThickness() const +{ + return 1; +} + +QPen NodeStyle::pen() const +{ + QPen p(strokeColor()); + p.setWidthF((float)strokeThickness() * 3.0f); + return p; +} + +QBrush NodeStyle::brush() const +{ + return QBrush(fillColor()); +} + +QPainterPath NodeStyle::path() const +{ + QPainterPath pth; + pth.addEllipse(QPointF(0.0f,0.0f), 30.0f, 30.0f); + return pth; +} + +QPainterPath NodeStyle::palettePath() const +{ + return path(); +} + +QIcon NodeStyle::icon() const +{ + // draw an icon matching the style + QPixmap px(100,100); + px.fill(Qt::transparent); + QPainter painter(&px); + QPainterPath pth = path(); + painter.setPen(pen()); + painter.setBrush(brush()); + + pth.translate(50.0f, 50.0f); + painter.drawPath(pth); + return QIcon(px); } -bool NodeStyle::isNone() { return name == "none"; } diff --git a/src/data/nodestyle.h b/src/data/nodestyle.h index 00d1b20..58c0c12 100644 --- a/src/data/nodestyle.h +++ b/src/data/nodestyle.h @@ -1,24 +1,40 @@ #ifndef NODESTYLE_H #define NODESTYLE_H +#include "graphelementdata.h" + #include <QColor> +#include <QPen> +#include <QBrush> +#include <QPainterPath> +#include <QIcon> enum NodeShape { - Square, UpTriangle, DownTriangle, Circle + Rectangle, UpTriangle, DownTriangle, Circle }; class NodeStyle { public: NodeStyle(); - NodeStyle(QString nm, NodeShape sh, QColor fillCol); - NodeStyle(QString nm, NodeShape sh, QColor fillCol, QColor strokeCol, int strokeThick); + NodeStyle(QString name, GraphElementData *data); bool isNone(); - QString name; - NodeShape shape; - QColor fillColor; - QColor strokeColor; - int strokeThickness; + + GraphElementData *data() const; + QString name() const; + NodeShape shape() const; + QColor fillColor() const; + QColor strokeColor() const; + int strokeThickness() const; + + QPen pen() const; + QBrush brush() const; + QPainterPath path() const; + QPainterPath palettePath() const; + QIcon icon() const; +private: + QString _name; + GraphElementData *_data; }; extern NodeStyle *noneStyle; diff --git a/src/data/project.cpp b/src/data/project.cpp deleted file mode 100644 index b129dc0..0000000 --- a/src/data/project.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "project.h" - -#include "QDebug" - -Project::Project(QObject *parent) : QObject(parent) -{ - -} - -void Project::addStyle(QString name, GraphElementData *properties) -{ - qDebug() << "got style {" << name << "} = [" << properties << "]"; -} diff --git a/src/data/project.h b/src/data/project.h deleted file mode 100644 index cbc2cb9..0000000 --- a/src/data/project.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef PROJECT_H -#define PROJECT_H - -#include "graphelementdata.h" - -#include <QObject> -#include <QString> - -class Project : public QObject -{ - Q_OBJECT -public: - explicit Project(QObject *parent = 0); - void addStyle(QString name, GraphElementData *properties); - -signals: - -public slots: -}; - -#endif // PROJECT_H diff --git a/src/data/tikzassembler.cpp b/src/data/tikzassembler.cpp index 456464a..e0197da 100644 --- a/src/data/tikzassembler.cpp +++ b/src/data/tikzassembler.cpp @@ -7,14 +7,14 @@ int yyparse(void *scanner); TikzAssembler::TikzAssembler(Graph *graph, QObject *parent) : - QObject(parent), _graph(graph), _project(0) + QObject(parent), _graph(graph), _tikzStyles(0) { yylex_init(&scanner); yyset_extra(this, scanner); } -TikzAssembler::TikzAssembler(Project *project, QObject *parent) : - QObject(parent), _graph(0), _project(project) +TikzAssembler::TikzAssembler(TikzStyles *tikzStyles, QObject *parent) : + QObject(parent), _graph(0), _tikzStyles(tikzStyles) { yylex_init(&scanner); yyset_extra(this, scanner); @@ -37,9 +37,9 @@ Graph *TikzAssembler::graph() const return _graph; } -Project *TikzAssembler::project() const +TikzStyles *TikzAssembler::tikzStyles() const { - return _project; + return _tikzStyles; } bool TikzAssembler::isGraph() const @@ -47,8 +47,8 @@ bool TikzAssembler::isGraph() const return _graph != 0; } -bool TikzAssembler::isProject() const +bool TikzAssembler::isTikzStyles() const { - return _project != 0; + return _tikzStyles != 0; } diff --git a/src/data/tikzassembler.h b/src/data/tikzassembler.h index 8dbbc9b..38d67a7 100644 --- a/src/data/tikzassembler.h +++ b/src/data/tikzassembler.h @@ -7,7 +7,7 @@ #include "node.h" #include "graph.h" -#include "project.h" +#include "tikzstyles.h" #include <QObject> #include <QHash> @@ -17,15 +17,15 @@ class TikzAssembler : public QObject Q_OBJECT public: explicit TikzAssembler(Graph *graph, QObject *parent = 0); - explicit TikzAssembler(Project *project, QObject *parent = 0); + explicit TikzAssembler(TikzStyles *tikzStyles, QObject *parent = 0); void addNodeToMap(Node *n); Node *nodeWithName(QString name); bool parse(const QString &tikz); Graph *graph() const; - Project *project() const; + TikzStyles *tikzStyles() const; bool isGraph() const; - bool isProject() const; + bool isTikzStyles() const; signals: @@ -35,7 +35,7 @@ public slots: private: QHash<QString,Node*> _nodeMap; Graph *_graph; - Project *_project; + TikzStyles *_tikzStyles; void *scanner; }; diff --git a/src/data/tikzlexer.l b/src/data/tikzlexer.l index faf0d43..0a7ff39 100644 --- a/src/data/tikzlexer.l +++ b/src/data/tikzlexer.l @@ -68,6 +68,7 @@ FLOAT \-?[0-9]*(\.[0-9]+)? \\begin\{tikzpicture\} { return BEGIN_TIKZPICTURE_CMD; } \\end\{tikzpicture\} { return END_TIKZPICTURE_CMD; } +\\tikzstyle { return TIKZSTYLE_CMD; } \\begin\{pgfonlayer\} { return BEGIN_PGFONLAYER_CMD; } \\end\{pgfonlayer\} { return END_PGFONLAYER_CMD; } \\draw { return DRAW_CMD; } @@ -78,6 +79,7 @@ node { return NODE; } at { return AT; } to { return TO; } ; { return SEMICOLON; } += { return EQUALS; } \([ ]*{FLOAT}[ ]*,[ ]*{FLOAT}[ ]*\) { yylloc->last_column = yylloc->first_column + 1; diff --git a/src/data/tikzparser.y b/src/data/tikzparser.y index a4db3dd..76674f1 100644 --- a/src/data/tikzparser.y +++ b/src/data/tikzparser.y @@ -7,7 +7,7 @@ /* * Copyright 2010 Chris Heunen - * Copyright 2010-2013 Aleks Kissinger + * Copyright 2010-2017 Aleks Kissinger * Copyright 2013 K. Johan Paulsson * Copyright 2013 Alex Merry <dev@randomguy3.me.uk> * @@ -85,6 +85,7 @@ void yyerror(YYLTYPE *yylloc, void *scanner, const char *str) { %token BEGIN_TIKZPICTURE_CMD "\\begin{tikzpicture}" %token END_TIKZPICTURE_CMD "\\end{tikzpicture}" +%token TIKZSTYLE_CMD "\\tikzstyle" %token BEGIN_PGFONLAYER_CMD "\\begin{pgfonlayer}" %token END_PGFONLAYER_CMD "\\end{pgfonlayer}" %token DRAW_CMD "\\draw" @@ -133,8 +134,8 @@ tikz: tikzstyles | tikzpicture; tikzstyles: tikzstyles tikzstyle | ; tikzstyle: "\\tikzstyle" DELIMITEDSTRING "=" "[" properties "]" { - if (assembler->isProject()) { - assembler->project()->addStyle(QString($2), $5); + if (assembler->isTikzStyles()) { + assembler->tikzStyles()->addStyle(QString($2), $5); } } diff --git a/src/data/tikzstyles.cpp b/src/data/tikzstyles.cpp new file mode 100644 index 0000000..186e19b --- /dev/null +++ b/src/data/tikzstyles.cpp @@ -0,0 +1,36 @@ +#include "tikzstyles.h" +#include "nodestyle.h" + +#include <QDebug> + +TikzStyles::TikzStyles(QObject *parent) : QObject(parent) +{ + +} + +NodeStyle *TikzStyles::nodeStyle(QString name) const +{ + foreach (NodeStyle *s , _nodeStyles) + if (s->name() == name) return s; + return noneStyle; //NodeStyle(name, NodeShape::Circle, Qt::white); +} + +QVector<NodeStyle *> TikzStyles::nodeStyles() const +{ + return _nodeStyles; +} + +void TikzStyles::clear() +{ + _nodeStyles.clear(); +} + +void TikzStyles::addStyle(QString name, GraphElementData *data) +{ + //qDebug() << "got style {" << name << "} = [" << data << "]"; + if (!data->property("fill").isNull()) { // node style + _nodeStyles << new NodeStyle(name, data); + } else { // edge style + // TODO: edge styles + } +} diff --git a/src/data/tikzstyles.h b/src/data/tikzstyles.h new file mode 100644 index 0000000..eaf7e64 --- /dev/null +++ b/src/data/tikzstyles.h @@ -0,0 +1,29 @@ +#ifndef PROJECT_H +#define PROJECT_H + +#include "graphelementdata.h" +#include "nodestyle.h" + +#include <QObject> +#include <QString> + +class TikzStyles : public QObject +{ + Q_OBJECT +public: + explicit TikzStyles(QObject *parent = 0); + void addStyle(QString name, GraphElementData *data); + + NodeStyle *nodeStyle(QString name) const; + QVector<NodeStyle *> nodeStyles() const; + void clear(); + +signals: + +public slots: + +private: + QVector<NodeStyle*> _nodeStyles; +}; + +#endif // PROJECT_H diff --git a/src/gui/nodeitem.cpp b/src/gui/nodeitem.cpp index 71226f3..21cdf79 100644 --- a/src/gui/nodeitem.cpp +++ b/src/gui/nodeitem.cpp @@ -57,10 +57,10 @@ void NodeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidge painter->setBrush(Qt::NoBrush); painter->drawPath(shape()); } else { - QPen pen(_node->style()->strokeColor); - pen.setWidth(_node->style()->strokeThickness); + QPen pen(_node->style()->strokeColor()); + pen.setWidth(_node->style()->strokeThickness()); painter->setPen(pen); - painter->setBrush(QBrush(_node->style()->fillColor)); + painter->setBrush(QBrush(_node->style()->fillColor())); painter->drawPath(shape()); } diff --git a/src/gui/toolpalette.cpp b/src/gui/toolpalette.cpp index 430df3f..0a832a6 100644 --- a/src/gui/toolpalette.cpp +++ b/src/gui/toolpalette.cpp @@ -20,7 +20,7 @@ ToolPalette::ToolPalette(QWidget *parent) : select = new QAction(QIcon(":/images/Inkscape_icons_edit_select_all.svg"), "Select"); vertex = new QAction(QIcon(":/images/Inkscape_icons_draw_ellipse.svg"), "Add Vertex"); edge = new QAction(QIcon(":/images/Inkscape_icons_draw_path.svg"), "Add Edge"); - crop = new QAction(QIcon(":/images/Inkscape_icons_draw_rectangle.svg"), "Bounding Box"); + crop = new QAction(QIcon(":/images/crop.svg"), "Bounding Box"); tools->addAction(select); tools->addAction(vertex); diff --git a/src/main.cpp b/src/main.cpp index 96069ef..49b064d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,6 +20,7 @@ int main(int argc, char *argv[]) QApplication a(argc, argv); a.setQuitOnLastWindowClosed(false); tikzit = new Tikzit(); + tikzit->init(); return a.exec(); } diff --git a/src/tikzit.cpp b/src/tikzit.cpp index 746268c..6ef86dd 100644 --- a/src/tikzit.cpp +++ b/src/tikzit.cpp @@ -1,7 +1,12 @@ #include "tikzit.h" +#include "tikzassembler.h" +#include "tikzstyles.h" +#include <QFile> #include <QFileDialog> #include <QSettings> +#include <QDebug> +#include <QMessageBox> // application-level instance of Tikzit Tikzit *tikzit; @@ -9,25 +14,27 @@ Tikzit *tikzit; // font to use for node labels QFont Tikzit::LABEL_FONT("Courrier", 9); -Tikzit::Tikzit() +Tikzit::Tikzit() : _styleFile("[default]"), _activeWindow(0) { - _mainMenu = new MainMenu(); +} - _activeWindow = 0; +void Tikzit::init() +{ + QSettings settings("tikzit", "tikzit"); + _mainMenu = new MainMenu(); QMainWindow *dummy = new QMainWindow(); _toolPalette = new ToolPalette(dummy); _propertyPalette = new PropertyPalette(dummy); _stylePalette = new StylePalette(dummy); + _styles = new TikzStyles(this); - loadStyles(); - - //_toolPalette->show(); - //_propertyPalette->show(); _stylePalette->show(); - _windows << new MainWindow(); _windows[0]->show(); + + QString styleFile = settings.value("previous-tikzstyles-file").toString(); + if (!styleFile.isEmpty()) loadStyles(styleFile); } //QMenuBar *Tikzit::mainMenu() const @@ -45,13 +52,6 @@ PropertyPalette *Tikzit::propertyPalette() const return _propertyPalette; } -void Tikzit::loadStyles() -{ - _nodeStyles << new NodeStyle("black dot", NodeShape::Circle, Qt::black, Qt::black, 1); - _nodeStyles << new NodeStyle("white dot", NodeShape::Circle, Qt::white, Qt::black, 1); - _nodeStyles << new NodeStyle("gray dot", NodeShape::Circle, Qt::gray, Qt::black, 1); -} - void Tikzit::newDoc() { MainWindow *w = new MainWindow(); @@ -81,13 +81,6 @@ void Tikzit::removeWindow(MainWindow *w) } } -NodeStyle *Tikzit::nodeStyle(QString name) -{ - foreach (NodeStyle *s , _nodeStyles) - if (s->name == name) return s; - return noneStyle; //NodeStyle(name, NodeShape::Circle, Qt::white); -} - void Tikzit::open() { QSettings settings("tikzit", "tikzit"); @@ -109,8 +102,62 @@ void Tikzit::open() } } +void Tikzit::openTikzStyles() { + QSettings settings("tikzit", "tikzit"); + QString fileName = QFileDialog::getOpenFileName(0, + tr("Open File"), + settings.value("previous-tikzstyles-path").toString(), + tr("TiKZ Style Files (*.tikzstyles)")); + + if (!fileName.isEmpty()) { + loadStyles(fileName); + } +} + +void Tikzit::loadStyles(QString fileName) +{ + QSettings settings("tikzit", "tikzit"); + QFile file(fileName); + if (file.open(QIODevice::ReadOnly)) { + QFileInfo fi(file); + settings.setValue("previous-tikzstyles-path", fi.absolutePath()); + settings.setValue("previous-tikzstyles-file", fileName); + _styleFile = fi.fileName(); + QTextStream in(&file); + QString styleTikz = in.readAll(); + file.close(); + + _styles->clear(); + TikzAssembler ass(_styles); + bool parseSuccess = ass.parse(styleTikz); + if (parseSuccess) { + qDebug() << "parse successful"; + } else { + qDebug() << "parse failed"; + } + _stylePalette->reloadStyles(); + + } else { + settings.setValue("previous-tikzstyles-file", ""); + QMessageBox::warning(0, "Style file not found.", "Could not open style file, reverting to default."); + } +} + +QString Tikzit::styleFile() const +{ + return _styleFile; +} + + +TikzStyles *Tikzit::styles() const +{ + return _styles; +} + void Tikzit::quit() { _stylePalette->close(); QApplication::quit(); } + + diff --git a/src/tikzit.h b/src/tikzit.h index 07878aa..802b3ab 100644 --- a/src/tikzit.h +++ b/src/tikzit.h @@ -38,6 +38,7 @@ #include "propertypalette.h" #include "stylepalette.h" #include "nodestyle.h" +#include "tikzstyles.h" #include <QObject> #include <QVector> @@ -68,7 +69,6 @@ public: MainWindow *activeWindow() const; void setActiveWindow(MainWindow *activeWindow); void removeWindow(MainWindow *w); - NodeStyle *nodeStyle(QString name); static QFont LABEL_FONT; // Ui::MainMenu *_mainMenuUi; @@ -77,10 +77,15 @@ public: void newDoc(); void open(); void quit(); + void init(); + + void openTikzStyles(); + TikzStyles *styles() const; + QString styleFile() const; private: -// void createMenu(); - void loadStyles(); + // void createMenu(); + void loadStyles(QString fileName); MainMenu *_mainMenu; ToolPalette *_toolPalette; @@ -88,7 +93,8 @@ private: StylePalette *_stylePalette; QVector<MainWindow*> _windows; MainWindow *_activeWindow; - QVector<NodeStyle*> _nodeStyles; + TikzStyles *_styles; + QString _styleFile; }; diff --git a/stylepalette.cpp b/stylepalette.cpp index 312f675..8852eb7 100644 --- a/stylepalette.cpp +++ b/stylepalette.cpp @@ -1,8 +1,14 @@ #include "stylepalette.h" #include "ui_stylepalette.h" +#include "tikzit.h" #include <QDebug> +#include <QIcon> +#include <QSize> #include <QSettings> +#include <QPainter> +#include <QPixmap> +#include <QPainterPath> StylePalette::StylePalette(QWidget *parent) : QDockWidget(parent), @@ -15,6 +21,13 @@ StylePalette::StylePalette(QWidget *parent) : if (geom != QVariant()) { restoreGeometry(geom.toByteArray()); } + + _model = new QStandardItemModel(this); + ui->styleListView->setModel(_model); + ui->styleListView->setViewMode(QListView::IconMode); + ui->styleListView->setMovement(QListView::Static); + + ui->styleListView->setGridSize(QSize(75,60)); } StylePalette::~StylePalette() @@ -22,9 +35,25 @@ StylePalette::~StylePalette() delete ui; } -void StylePalette::on_buttonOpenProject_clicked() +void StylePalette::reloadStyles() +{ + _model->clear(); + QString f = tikzit->styleFile(); + // + ui->styleFile->setText(f); + + QStandardItem *it; + QSize sz(60,60); + + foreach(NodeStyle *ns, tikzit->styles()->nodeStyles()) { + it = new QStandardItem(ns->icon(), ns->name()); + _model->appendRow(it); + } +} + +void StylePalette::on_buttonOpenTikzstyles_clicked() { - qDebug() << "got click"; + tikzit->openTikzStyles(); } void StylePalette::closeEvent(QCloseEvent *event) diff --git a/stylepalette.h b/stylepalette.h index b5c16f1..99dde02 100644 --- a/stylepalette.h +++ b/stylepalette.h @@ -2,6 +2,7 @@ #define STYLEPALETTE_H #include <QDockWidget> +#include <QStandardItemModel> namespace Ui { class StylePalette; @@ -14,12 +15,14 @@ class StylePalette : public QDockWidget public: explicit StylePalette(QWidget *parent = 0); ~StylePalette(); + void reloadStyles(); public slots: - void on_buttonOpenProject_clicked(); + void on_buttonOpenTikzstyles_clicked(); private: Ui::StylePalette *ui; + QStandardItemModel *_model; protected: void closeEvent(QCloseEvent *event) override; diff --git a/stylepalette.ui b/stylepalette.ui index 8068ea4..a8c893f 100644 --- a/stylepalette.ui +++ b/stylepalette.ui @@ -7,13 +7,13 @@ <x>0</x> <y>0</y> <width>250</width> - <height>350</height> + <height>430</height> </rect> </property> <property name="minimumSize"> <size> <width>250</width> - <height>350</height> + <height>430</height> </size> </property> <property name="floating"> @@ -23,79 +23,126 @@ <string>Styles</string> </property> <widget class="QWidget" name="dockWidgetContents"> - <widget class="QLabel" name="label"> - <property name="geometry"> - <rect> - <x>10</x> - <y>12</y> - <width>51</width> - <height>16</height> - </rect> - </property> - <property name="text"> - <string>Project:</string> - </property> - </widget> - <widget class="QLabel" name="label_2"> - <property name="geometry"> - <rect> - <x>60</x> - <y>13</y> - <width>131</width> - <height>16</height> - </rect> - </property> - <property name="font"> - <font> - <family>Courier</family> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>[default]</string> - </property> - </widget> - <widget class="QToolButton" name="newProjectButton"> - <property name="geometry"> - <rect> - <x>195</x> - <y>10</y> - <width>22</width> - <height>22</height> - </rect> - </property> - <property name="toolTip"> - <string>New Project</string> - </property> - <property name="text"> - <string/> - </property> - <property name="icon"> - <iconset resource="tikzit.qrc"> - <normaloff>:/images/document-new.svg</normaloff>:/images/document-new.svg</iconset> - </property> - </widget> - <widget class="QToolButton" name="openProjectButton"> - <property name="geometry"> - <rect> - <x>220</x> - <y>10</y> - <width>22</width> - <height>22</height> - </rect> - </property> - <property name="toolTip"> - <string>New Project</string> - </property> - <property name="text"> - <string/> - </property> - <property name="icon"> - <iconset resource="tikzit.qrc"> - <normaloff>:/images/document-open.svg</normaloff>:/images/document-open.svg</iconset> - </property> - </widget> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <property name="spacing"> + <number>2</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Styles:</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="styleFile"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="font"> + <font> + <family>Courier</family> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="text"> + <string>[default]</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="buttonOpenTikzstyles"> + <property name="toolTip"> + <string>New Project</string> + </property> + <property name="text"> + <string/> + </property> + <property name="icon"> + <iconset resource="tikzit.qrc"> + <normaloff>:/images/document-open.svg</normaloff>:/images/document-open.svg</iconset> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="toolButton_3"> + <property name="text"> + <string/> + </property> + <property name="icon"> + <iconset resource="tikzit.qrc"> + <normaloff>:/images/refresh.svg</normaloff>:/images/refresh.svg</iconset> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QListView" name="styleListView"> + <property name="font"> + <font> + <pointsize>8</pointsize> + <italic>true</italic> + </font> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="layoutButtons"> + <property name="spacing"> + <number>2</number> + </property> + <item> + <widget class="QToolButton" name="toolButton"> + <property name="minimumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="text"> + <string>+</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="toolButton_2"> + <property name="minimumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="text"> + <string>-</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> </widget> </widget> <resources> @@ -49,8 +49,8 @@ SOURCES += src/gui/mainwindow.cpp \ src/gui/mainmenu.cpp \ src/util.cpp \ stylepalette.cpp \ - src/data/project.cpp \ - src/data/tikzassembler.cpp + src/data/tikzassembler.cpp \ + src/data/tikzstyles.cpp HEADERS += src/gui/mainwindow.h \ src/gui/toolpalette.h \ @@ -73,8 +73,8 @@ HEADERS += src/gui/mainwindow.h \ src/gui/mainmenu.h \ src/util.h \ stylepalette.h \ - src/data/project.h \ - src/data/tikzassembler.h + src/data/tikzassembler.h \ + src/data/tikzstyles.h FORMS += src/gui/mainwindow.ui \ src/gui/propertypalette.ui \ @@ -18,6 +18,7 @@ <file>images/edge.svg</file> <file>images/node.svg</file> <file>images/select.svg</file> + <file>images/refresh.svg</file> </qresource> <qresource prefix="/qt/etc"> <file>qt.conf</file> |