Commit c0870e19 authored by Ralf Habacker's avatar Ralf Habacker
Browse files

Ignore polyline, spline and orthogonal line layout for dot version <= 2.28.0

dot with version at least <= 2.28.0 creates an unknown edge point format,
which leads to unusable results.

CCBUG:414595
parent 6272e5ec
......@@ -187,6 +187,8 @@ QString DotGenerator::currentDotPath()
void DotGenerator::setGeneratorName(const QString &name)
{
m_generator = name;
m_version = generatorVersion();
uDebug() << "found graphviz generator at " << generatorFullPath() << " with version " << m_version;
}
QString DotGenerator::generatorFullPath()
......@@ -351,7 +353,7 @@ bool DotGenerator::readConfigFile(QString diagramType, const QString &variant)
else
uError() << "illegal format of entry 'origin'" << value;
m_generator = settings.readEntry("generator", "dot");
setGeneratorName(settings.readEntry("generator", "dot"));
#ifdef LAYOUTGENERATOR_DATA_DEBUG
uDebug() << m_edgeParameters;
......@@ -576,6 +578,23 @@ QString DotGenerator::fixID(const QString &_id)
return id;
}
/**
* get generator version
* @return version for example 20130928
*/
int DotGenerator::generatorVersion()
{
QProcess p;
QStringList args;
args << QLatin1String("-V");
p.start(generatorFullPath(), args);
p.waitForFinished();
QString out(QLatin1String(p.readAllStandardError()));
QRegExp rx(QLatin1String("\\((.*)\\."));
QString version = rx.indexIn(out) != -1 ? rx.cap(1) : QString();
return version.toInt(0);
}
#if 0
static QDebug operator<<(QDebug out, LayoutGenerator &c)
{
......
......@@ -40,11 +40,11 @@ public:
static QString currentDotPath();
void setGeneratorName(const QString &name);
QString generatorFullPath();
int generatorVersion();
protected:
bool findItem(QStringList &params, const QString &search);
QString fixID(const QString &_id);
int generatorVersion();
double m_scale; ///< scale factor
QString m_configFileName; ///< template filename
......@@ -56,6 +56,7 @@ protected:
bool m_usePosition; ///< use position tag from dot (not used yet)
bool m_useFullNodeLabels; ///< use full node labels
QString m_dotPath; ///< contains path to generator executable
int m_version; ///< version of graphviz generator
friend QDebug operator<<(QDebug out, DotGenerator &c);
};
......
......@@ -238,25 +238,31 @@ bool LayoutGenerator::apply(UMLScene *scene)
s_path.addEllipse(mapToScene(l), 5, 5);
s_debugItems->setPath(s_path);
#endif
path->setLayout(Settings::optionState().generalState.layoutType);
path->cleanup();
if (Settings::optionState().generalState.layoutType == Uml::LayoutType::Polyline) {
for (int i = 0; i < len; i++) {
if (i > 0 && p[i] == p[i-1])
continue;
path->addPoint(mapToScene(p[i]));
}
} else if(Settings::optionState().generalState.layoutType == Uml::LayoutType::Spline) {
for (int i = 0; i < len; i++) {
path->addPoint(mapToScene(p[i]));
}
} else if (Settings::optionState().generalState.layoutType == Uml::LayoutType::Orthogonal) {
for (int i = 0; i < len; i++) {
path->addPoint(mapToScene(p[i]));
}
} else
if (m_version <= 20130928) {
path->setLayout(Uml::LayoutType::Direct);
path->cleanup();
path->setEndPoints(mapToScene(p[0]), mapToScene(p[len-1]));
} else {
path->setLayout(Settings::optionState().generalState.layoutType);
path->cleanup();
if (Settings::optionState().generalState.layoutType == Uml::LayoutType::Polyline) {
for (int i = 0; i < len; i++) {
if (i > 0 && p[i] == p[i-1])
continue;
path->addPoint(mapToScene(p[i]));
}
} else if(Settings::optionState().generalState.layoutType == Uml::LayoutType::Spline) {
for (int i = 0; i < len; i++) {
path->addPoint(mapToScene(p[i]));
}
} else if (Settings::optionState().generalState.layoutType == Uml::LayoutType::Orthogonal) {
for (int i = 0; i < len; i++) {
path->addPoint(mapToScene(p[i]));
}
} else
path->setEndPoints(mapToScene(p[0]), mapToScene(p[len-1]));
}
}
UMLApp::app()->beginMacro(i18n("Apply layout"));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment