60 text +=
"\n-----------";
62 std::string attr_descriptions;
64 if (attributes !=
nullptr) {
65 for (
auto attr : *attributes) {
66 if (!attr->get_description().empty()) {
67 attr_descriptions +=
"\n " + attr->get_name() +
": " + attr->get_description();
71 std::string rel_descriptions;
72 auto relationships =
m_class_info->direct_relationships();
73 if (relationships !=
nullptr) {
74 for (
auto rel : *relationships) {
75 if (!rel->get_description().empty()) {
76 rel_descriptions +=
"\n " + rel->get_name() +
": " + rel->get_description();
80 std::string method_descriptions;
82 if (methods !=
nullptr) {
83 for (
auto method : *methods) {
84 if (!method->get_description().empty()) {
85 method_descriptions +=
"\n " + method->get_name() +
": " + method->get_description();
90 std::string sep =
"\n-----";
91 if (!attr_descriptions.empty()) {
92 text +=
"\nAttributes:" + attr_descriptions;
93 if (!(rel_descriptions.empty() && method_descriptions.empty())) {
97 if (!rel_descriptions.empty()) {
98 text +=
"\nRelationships:" + rel_descriptions;
99 if (!method_descriptions.empty()) {
103 if (method_descriptions !=
"") {
104 text +=
"\nMethods:" + method_descriptions;
107 QToolTip::showText(he->screenPos(), QString::fromStdString(text),
nullptr, QRect(), 10000);
144 std::list<OksAttribute*> direct_attributes = {};
148 std::list<OksMethod*> direct_methods = {};
152 std::list<OksRelationship*> direct_relationships = {};
154 direct_relationships = *
m_class_info->direct_relationships();
156 std::list<OksAttribute*> all_attributes = {};
160 std::list<OksMethod*> all_methods = {};
164 std::list<OksRelationship*> all_relationships = {};
169 std::list<OksAttribute*> indirect_attributes = all_attributes;
170 std::list<OksMethod*> indirect_methods = all_methods;
171 std::list<OksRelationship*> indirect_relationships = all_relationships;
174 indirect_attributes.remove(attribute);
177 for (
OksMethod* method : direct_methods) {
178 indirect_methods.remove(method);
182 indirect_relationships.remove(relationship);
191 QString AttributeString(QString::fromStdString(attribute->get_name()) +
" : " +
192 QString::fromStdString(attribute->get_type()) +
193 (attribute->get_is_multi_values() ?
"[]" :
""));
197 if (!attribute->get_init_value().empty()) {
198 value = QString::fromStdString(
" = " + attribute->get_init_value());
205 QString relationship_string(QString::fromStdString(relationship->get_name()) +
" : " +
206 QString::fromStdString(relationship->get_type()) +
" - " +
207 QString::fromStdString(m[relationship->get_low_cardinality_constraint()]) +
":" +
208 QString::fromStdString(m[relationship->get_high_cardinality_constraint()]));
213 for (
OksMethod* Method : direct_methods) {
214 QString MethodString(QString::fromStdString(Method->get_name()) +
"()");
220 QString attribute_string(QString::fromStdString(attribute->get_name()) +
" : " +
221 QString::fromStdString(attribute->get_type()));
227 QString relationship_string(QString::fromStdString(relationship->get_name()) +
" : " +
228 QString::fromStdString(relationship->get_type()) +
" - " +
229 QString::fromStdString(m[relationship->get_low_cardinality_constraint()]) +
":" +
230 QString::fromStdString(m[relationship->get_high_cardinality_constraint()]));
235 for (
OksMethod* method : indirect_methods) {
236 QString method_string(QString::fromStdString(method->get_name()) +
"()");
245 double TotalBoundingHeight = 0;
246 double TotalBoundingWidth = 0;
248 QFontMetrics FontMetrics(
m_font);
250 TotalBoundingHeight += SpaceX * 5;
256 if (
m_scene->show_defaults()) {
259 TotalBoundingHeight += FontMetrics.boundingRect(attribute_name).height();
261 if (FontMetrics.boundingRect(attribute_name).width() > TotalBoundingWidth) {
262 TotalBoundingWidth = FontMetrics.boundingRect(attribute_name).width();
266 if (
m_scene->inherited_properties_visible()) {
268 TotalBoundingHeight += FontMetrics.boundingRect(AttributeName).height();
270 if (FontMetrics.boundingRect(AttributeName).width() > TotalBoundingWidth)
271 TotalBoundingWidth = FontMetrics.boundingRect(AttributeName).width();
276 TotalBoundingHeight += FontMetrics.boundingRect(relationship_name).height();
278 if (FontMetrics.boundingRect(relationship_name).width() > TotalBoundingWidth)
279 TotalBoundingWidth = FontMetrics.boundingRect(relationship_name).width();
282 if (
m_scene->inherited_properties_visible()) {
284 TotalBoundingHeight += FontMetrics.boundingRect(relationship_name).height();
286 if (FontMetrics.boundingRect(relationship_name).width() > TotalBoundingWidth)
287 TotalBoundingWidth = FontMetrics.boundingRect(relationship_name).width();
292 TotalBoundingHeight += FontMetrics.boundingRect(MethodName).height();
294 if (FontMetrics.boundingRect(MethodName).width() > TotalBoundingWidth)
295 TotalBoundingWidth = FontMetrics.boundingRect(MethodName).width();
298 if (
m_scene->inherited_properties_visible()) {
300 TotalBoundingHeight += FontMetrics.boundingRect(MethodName).height();
302 if (FontMetrics.boundingRect(MethodName).width() > TotalBoundingWidth)
303 TotalBoundingWidth = FontMetrics.boundingRect(MethodName).width();
307 TotalBoundingWidth += 15;
308 return QRectF(0, 0, TotalBoundingWidth, TotalBoundingHeight);
333 }
else if (
m_scene->highlight_active() &&
344 const QPen bounding_box_pen = QPen(colour, 2.5);
345 const QPen inner_line_pen = QPen(colour, 1.5);
348 painter->setPen(bounding_box_pen);
349 painter->setBackground(background);
353 const QFontMetrics FontMetrics = painter->fontMetrics();
357 double HeightOffset = ClassNameBoundingRect.height() + SpaceY;
358 const auto ClassNamePosition =
359 QPointF((ObjectBoundingRect.width() - ClassNameBoundingRect.width()) / 2, ClassNameBoundingRect.height());
361 painter->drawLine(0, HeightOffset, ObjectBoundingRect.width(), HeightOffset);
365 if (
m_scene->show_defaults()) {
368 const QRectF AttributeBoundingRect = FontMetrics.boundingRect(attribute_name);
369 HeightOffset += AttributeBoundingRect.height();
370 painter->drawText(QPointF(SpaceX, HeightOffset), attribute_name);
373 if (
m_scene->inherited_properties_visible()) {
376 const QRectF AttributeBoundingRect = FontMetrics.boundingRect(AttributeName);
377 HeightOffset += AttributeBoundingRect.height();
378 painter->drawText(QPointF(SpaceX, HeightOffset), AttributeName);
380 painter->setPen(colour);
383 HeightOffset += SpaceY;
384 painter->setPen(inner_line_pen);
385 painter->drawLine(0, HeightOffset, ObjectBoundingRect.width(), HeightOffset);
388 const QRectF relationship_bounding_rect = FontMetrics.boundingRect(relationship_name);
389 HeightOffset += relationship_bounding_rect.height();
390 painter->drawText(QPointF(SpaceX, HeightOffset), relationship_name);
393 if (
m_scene->inherited_properties_visible()) {
396 const QRectF relationship_bounding_rect = FontMetrics.boundingRect(relationship_name);
397 HeightOffset += relationship_bounding_rect.height();
398 painter->drawText(QPointF(SpaceX, HeightOffset), relationship_name);
400 painter->setPen(colour);
403 HeightOffset += SpaceY;
404 painter->setPen(inner_line_pen);
405 painter->drawLine(0, HeightOffset, ObjectBoundingRect.width(), HeightOffset);
408 const QRectF AttributeBoundingRect = FontMetrics.boundingRect(MethodName);
409 HeightOffset += AttributeBoundingRect.height();
410 painter->drawText(QPointF(SpaceX, HeightOffset), MethodName);
413 if (
m_scene->inherited_properties_visible()) {
416 const QRectF AttributeBoundingRect = FontMetrics.boundingRect(MethodName);
417 HeightOffset += AttributeBoundingRect.height();
418 painter->drawText(QPointF(SpaceX, HeightOffset), MethodName);
420 painter->setPen(colour);