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
|
/**
*
* This file is part of Tulip (https://tulip.labri.fr)
*
* 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 <ogdf/energybased/DavidsonHarelLayout.h>
#include <tulip/StringCollection.h>
#include <tulip2ogdf/OGDFLayoutPluginBase.h>
#define SETTINGSLIST "standard;repulse;planar"
#define STANDARD_ELT 0
#define REPULSE_ELT 1
#define PLANAR_ELT 2
#define SPEEDLIST "fast;medium;hq"
#define FAST_ELT 0
#define MEDIUM_ELT 1
#define HQ_ELT 2
using namespace tlp;
using namespace ogdf;
static const char *paramHelp[] = {
// Settings
"Fixes the cost values to special configurations.",
// Speed
"More convenient way of setting the speed of the algorithm. Influences number of iterations "
"per temperature step, starting temperature, and cooling factor.",
// preferredEdgeLength
"The preferred edge length.",
// preferredEdgeLengthMultiplier
"The preferred edge length multiplier for attraction."};
class OGDFDavidsonHarel : public OGDFLayoutPluginBase {
tlp::StringCollection settings;
tlp::StringCollection speed;
public:
PLUGININFORMATION("Davidson Harel (OGDF)", "Rene Weiskircher", "12/11/2007",
"Implements the Davidson-Harel layout algorithm which uses simulated annealing "
"to find a layout of minimal energy.<br/>Due to this approach, the algorithm "
"can only handle graphs of rather limited size.<br/>It is based on the "
"following publication:<br/><b>Drawing Graphs Nicely Using Simulated "
"Annealing</b>,<br/>Ron Davidson, David Harel, ACM Transactions on Graphics "
"15(4), pp. 301-331, 1996.",
"1.4", "Force Directed")
OGDFDavidsonHarel(const tlp::PluginContext *context)
: OGDFLayoutPluginBase(context, context ? new ogdf::DavidsonHarelLayout() : nullptr) {
addInParameter<StringCollection>("settings", paramHelp[0], SETTINGSLIST, true,
"standard<br/>repulse<br/>planar");
addInParameter<StringCollection>("speed", paramHelp[1], SPEEDLIST, true,
"fast<br/>medium<br/>hq");
addInParameter<double>("edge length", paramHelp[2], "0.0");
addInParameter<double>("edge length multiplier", paramHelp[3], "2.0");
}
void beforeCall() override {
ogdf::DavidsonHarelLayout *davidson = static_cast<ogdf::DavidsonHarelLayout *>(ogdfLayoutAlgo);
if (dataSet != nullptr) {
settings.setCurrent(0);
if (dataSet->get("settings", settings)) {
switch (settings.getCurrent()) {
case STANDARD_ELT:
davidson->fixSettings(DavidsonHarelLayout::SettingsParameter::Standard);
break;
case REPULSE_ELT:
davidson->fixSettings(DavidsonHarelLayout::SettingsParameter::Repulse);
break;
default:
davidson->fixSettings(DavidsonHarelLayout::SettingsParameter::Planar);
}
}
speed.setCurrent(0);
if (dataSet->get("speed", speed)) {
switch (speed.getCurrent()) {
case FAST_ELT:
davidson->setSpeed(DavidsonHarelLayout::SpeedParameter::Fast);
break;
case MEDIUM_ELT:
davidson->setSpeed(DavidsonHarelLayout::SpeedParameter::Medium);
break;
default:
davidson->setSpeed(DavidsonHarelLayout::SpeedParameter::HQ);
}
}
double val = 0;
if (dataSet->get("edge length", val))
davidson->setPreferredEdgeLength(val);
if (dataSet->get("edge length multiplier", val))
davidson->setPreferredEdgeLengthMultiplier(val);
}
}
~OGDFDavidsonHarel() override {}
};
PLUGIN(OGDFDavidsonHarel)
|