1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
|
/**
*
* This file is part of Tulip (www.tulip-software.org)
*
* Authors: David Auber and the Tulip development Team
* from LaBRI, University of Bordeaux
*
* Tulip is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* Tulip 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.
*
*/
#include "RepresentExport.h"
#include "ReadGraph.h"
#include "ExportSvg.h"
#include <iostream>
#include <tulip/ExportModule.h>
#include <tulip/LayoutProperty.h>
#include <tulip/ColorProperty.h>
#include <tulip/IntegerProperty.h>
#include <tulip/DoubleProperty.h>
#include <tulip/SizeProperty.h>
#include <tulip/StringProperty.h>
using namespace std;
using namespace tlp;
namespace {
const char * paramHelp[] = {
// viewLayout
HTML_HELP_OPEN() \
HTML_HELP_DEF( "type", "LayoutProperty" ) \
HTML_HELP_DEF( "default", "viewLayout" ) \
HTML_HELP_BODY() \
"Indicates the property to use for element layout." \
HTML_HELP_CLOSE(),
// viewColor
HTML_HELP_OPEN() \
HTML_HELP_DEF( "type", "ColorProperty" ) \
HTML_HELP_DEF( "default", "viewColor" ) \
HTML_HELP_BODY() \
"Indicates the property to use for element color." \
HTML_HELP_CLOSE(),
// viewShape
HTML_HELP_OPEN() \
HTML_HELP_DEF( "type", "IntegerProperty" ) \
HTML_HELP_DEF( "default", "viewShape" ) \
HTML_HELP_BODY() \
"Indicates the property to use for defining element shape." \
HTML_HELP_CLOSE(),
// viewSrcAnchorShape
HTML_HELP_OPEN() \
HTML_HELP_DEF( "type", "IntegerProperty" ) \
HTML_HELP_DEF( "default", "viewSrcAnchorShape" ) \
HTML_HELP_BODY() \
"Indicates the property to use for defining element shape." \
HTML_HELP_CLOSE(),
// viewTgtAnchorShape
HTML_HELP_OPEN() \
HTML_HELP_DEF( "type", "IntegerProperty" ) \
HTML_HELP_DEF( "default", "viewTgtAnchorShape" ) \
HTML_HELP_BODY() \
"Indicates the property to use for defining element shape." \
HTML_HELP_CLOSE(),
// viewSize
HTML_HELP_OPEN() \
HTML_HELP_DEF( "type", "SizeProperty" ) \
HTML_HELP_DEF( "default", "viewSize" )
HTML_HELP_BODY() \
"Indicates the property to use for defining element size." \
HTML_HELP_CLOSE(),
// viewLabel
HTML_HELP_OPEN() \
HTML_HELP_DEF( "type", "StringProperty" ) \
HTML_HELP_DEF( "default", "viewLabel" )
HTML_HELP_BODY() \
"Indicates the property to use for defining element label." \
HTML_HELP_CLOSE(),
// viewLabelColor
HTML_HELP_OPEN() \
HTML_HELP_DEF( "type", "ColorProperty" ) \
HTML_HELP_DEF( "default", "viewLabelColor" )
HTML_HELP_BODY() \
"Indicates the property to use for defining element label color." \
HTML_HELP_CLOSE(),
// viewBorderColor
HTML_HELP_OPEN() \
HTML_HELP_DEF( "type", "viewBorderColor" ) \
HTML_HELP_DEF( "default", "viewSize" )
HTML_HELP_BODY() \
"Indicates the property to use for defining element border color." \
HTML_HELP_CLOSE(),
// viewBorderWidth
HTML_HELP_OPEN() \
HTML_HELP_DEF( "type", "DoubleProperty" ) \
HTML_HELP_DEF( "default", "viewBorderWidth" )
HTML_HELP_BODY() \
"Indicates the property to use for defining element border width." \
HTML_HELP_CLOSE(),
// viewRotation
HTML_HELP_OPEN() \
HTML_HELP_DEF( "type", "DoubleProperty" ) \
HTML_HELP_DEF( "default", "viewRotation" )
HTML_HELP_BODY() \
"Indicates the property to use for defining element rotation." \
HTML_HELP_CLOSE(),
// color interpolation
HTML_HELP_OPEN() \
HTML_HELP_DEF( "type", "bool" ) \
HTML_HELP_DEF( "default", "false" )
HTML_HELP_BODY() \
"Indicates if edge color interpolation has to be used" \
HTML_HELP_CLOSE(),
// edge extremities
HTML_HELP_OPEN() \
HTML_HELP_DEF( "type", "bool" ) \
HTML_HELP_DEF( "default", "false" )
HTML_HELP_BODY() \
"Indicates if edge extremities have to be exported" \
HTML_HELP_CLOSE(),
};
}
class ExportMultiple_svg:public tlp::ExportModule {
public:
PLUGININFORMATION("SVG Export","Sami Gasri, Charles-Antoine Lami, Bruno Pinaud","16/07/2013","Exports a graph drawing in a SVG formatted file","1.5", "File")
std::string icon() const {
return ":/tulip/graphperspective/icons/32/export_svg.png";
}
std::string fileExtension() const {
return "svg";
}
ExportMultiple_svg(tlp::PluginContext* context) : tlp::ExportModule(context) {
addInParameter<LayoutProperty>("Element's layout property", paramHelp[0], "viewLayout");
addInParameter<ColorProperty>("Element's color property", paramHelp[1], "viewColor");
addInParameter<IntegerProperty>("Element's shape property", paramHelp[2], "viewShape");
addInParameter<IntegerProperty>("Element's SrcAnchorShape property", paramHelp[3], "viewSrcAnchorShape");
addInParameter<IntegerProperty>("Element's TgtAnchorShape property", paramHelp[4], "viewTgtAnchorShape");
addInParameter<SizeProperty>("Element's size property", paramHelp[5], "viewSize");
addInParameter<StringProperty>("Element's label property", paramHelp[6], "viewLabel");
addInParameter<ColorProperty>("Element's label color property", paramHelp[7], "viewLabelColor");
addInParameter<ColorProperty>("Element's border color property", paramHelp[8], "viewBorderColor");
addInParameter<DoubleProperty>("Element's border width property", paramHelp[9], "viewBorderWidth");
addInParameter<DoubleProperty>("Element's rotation property", paramHelp[10], "viewRotation");
addInParameter<bool>("Edge color interpolation", paramHelp[11], "false");
addInParameter<bool>("Edge extremities", paramHelp[12], "false");
}
~ExportMultiple_svg() {}
bool exportGraph(ostream &os) {
pluginProgress->showPreview(false);
RepresentExport *svg = new ExportSvg(); // We call our first concrete builder
ReadGraph gr1(graph, dataSet, pluginProgress, svg); // We analyse the graph
os << gr1; // We retrieve the result
delete svg;
return true;
}
};
PLUGIN(ExportMultiple_svg)
|