ui: separated GraphView style settings into class GraphViewStyle

This change adds the class GraphViewStyle that holds all values for defining the style of Nodes and Edges in the Graph.
The GraphViewStyleImpl interface and the QtGraphViewStyleImpl implementation are used to request Qt specific metrics,
like the charwidth of used fonts.

This change includes the following fixes:
* aggregation number always in the middle between nodes
* darker color for aggregation edge
* split off QGraphicsLineItem implementations from QtGraphEdge
* fixed some colors in color scheme

fortune cookie message = Sorge dich nicht! Du wirst bekommen was du brauchst.
This commit is contained in:
Eberhard Graether
2015-03-23 11:44:57 +01:00
parent fbd3b7ea5c
commit f5aa698225
30 changed files with 1255 additions and 1009 deletions
+35
View File
@@ -0,0 +1,35 @@
#include "utility/utility.h"
float utility::duration(std::function<void()> func)
{
std::chrono::time_point<std::chrono::system_clock> start = std::chrono::system_clock::now();
func();
std::chrono::duration<float> duration =
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - start);
return duration.count();
}
bool utility::intersectionPoint(Vec2f a1, Vec2f b1, Vec2f a2, Vec2f b2, Vec2f* i)
{
Vec2f p = a1;
Vec2f v = b1 - a1;
Vec2f q = a2;
Vec2f w = b2 - a2;
float denominator = v.x * w.y - v.y * w.x;
if (denominator != 0)
{
float t = (p.y * w.x - p.x * w.y + q.x * w.y - q.y * w.x) / denominator;
float s = (q.y * v.x - q.x * v.y + p.x * v.y - p.y * v.x) / -denominator;
if (t >= 0 && t <= 1 && s >= 0 && s <= 1)
{
*i = p + v * t;
return true;
}
}
return false;
}
+30 -25
View File
@@ -2,40 +2,45 @@
#define UTILITY_H
#include <chrono>
#include <set>
#include "utility/math/Vector2.h"
namespace utility
{
float duration(std::function<void()> func)
{
std::chrono::time_point<std::chrono::system_clock> start = std::chrono::system_clock::now();
func();
std::chrono::duration<float> duration =
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - start);
return duration.count();
}
float duration(std::function<void()> func);
template<typename T>
std::vector<T> concat(const std::vector<T>& a, const std::vector<T>& b)
{
std::vector<T> r(a.size() + b.size());
append(r, a);
append(r, b);
return r;
}
std::vector<T> concat(const std::vector<T>& a, const std::vector<T>& b);
template<typename T>
void append(std::vector<T>& a, const std::vector<T>& b)
{
a.insert(a.begin(), b.begin(), b.end());
}
void append(std::vector<T>& a, const std::vector<T>& b);
template<typename T>
void append(std::set<T>& a, const std::set<T>& b)
{
a.insert(b.begin(), b.end());
}
void append(std::set<T>& a, const std::set<T>& b);
bool intersectionPoint(Vec2f a1, Vec2f b1, Vec2f a2, Vec2f b2, Vec2f* i);
}
template<typename T>
std::vector<T> utility::concat(const std::vector<T>& a, const std::vector<T>& b)
{
std::vector<T> r(a.size() + b.size());
append(r, a);
append(r, b);
return r;
}
template<typename T>
void utility::append(std::vector<T>& a, const std::vector<T>& b)
{
a.insert(a.begin(), b.begin(), b.end());
}
template<typename T>
void utility::append(std::set<T>& a, const std::set<T>& b)
{
a.insert(b.begin(), b.end());
}
#endif // UTILITY_H