File: MatrixViewConfigurationWidget.cpp

package info (click to toggle)
tulip 6.0.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 196,224 kB
  • sloc: cpp: 571,851; ansic: 13,983; python: 4,105; sh: 1,555; yacc: 522; xml: 484; makefile: 168; pascal: 148; lex: 55
file content (160 lines) | stat: -rw-r--r-- 5,304 bytes parent folder | download
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
/**
 *
 * 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 "MatrixViewConfigurationWidget.h"
#include "ui_MatrixViewConfigurationWidget.h"

#include <tulip/Graph.h>
#include <tulip/ColorButton.h>
#include <tulip/TlpQtTools.h>

using namespace std;
namespace tlp {
MatrixViewConfigurationWidget::MatrixViewConfigurationWidget(QWidget *parent)
    : QWidget(parent), _ui(new Ui::MatrixViewConfigurationWidget()), _modifyingMetricList(false) {
  _ui->setupUi(this);
#ifdef __APPLE__
  _ui->gridDisplayCombo->setMinimumContentsLength(25);
#endif

  connect(_ui->orderingMetricCombo, SIGNAL(currentIndexChanged(int)), this,
          SLOT(orderingMetricComboIndexChanged(int)));
  connect(_ui->backgroundColorBtn, SIGNAL(colorChanged(QColor)), this,
          SIGNAL(changeBackgroundColor(QColor)));
  connect(_ui->gridDisplayCombo, SIGNAL(currentIndexChanged(int)), this,
          SIGNAL(setGridDisplayMode()));
  connect(_ui->showedgesbox, SIGNAL(clicked(bool)), this, SIGNAL(showEdges(bool)));
  connect(_ui->node_labels, SIGNAL(clicked(bool)), this, SIGNAL(nodeLabels(bool)));
  connect(_ui->enableColorInterpolationCBox, SIGNAL(clicked(bool)), this,
          SIGNAL(enableEdgeColorInterpolation(bool)));
  connect(_ui->orientedCBox, SIGNAL(clicked(bool)), this, SIGNAL(updateOriented(bool)));
  connect(_ui->ascendingOrderCBox, SIGNAL(toggled(bool)), this, SLOT(orderingDirectionChanged()));
}

MatrixViewConfigurationWidget::~MatrixViewConfigurationWidget() {
  delete _ui;
}

void MatrixViewConfigurationWidget::setBackgroundColor(const QColor &c) {
  _ui->backgroundColorBtn->setColor(c);
}

Color MatrixViewConfigurationWidget::getBackgroundColor() const {
  return _ui->backgroundColorBtn->tulipColor();
}

void MatrixViewConfigurationWidget::setDisplayEdges(const bool state) {
  _ui->showedgesbox->setChecked(state);
  emit showEdges(state);
}

bool MatrixViewConfigurationWidget::displayGraphEdges() const {
  return _ui->showedgesbox->isChecked();
}

void MatrixViewConfigurationWidget::setDisplayNodeLabels(const bool state) {
  _ui->node_labels->setChecked(state);
  emit nodeLabels(state);
}
bool MatrixViewConfigurationWidget::displayNodeLabels() const {
  return _ui->node_labels->isChecked();
}

void MatrixViewConfigurationWidget::setEdgeColorInterpolation(const bool state) {
  _ui->enableColorInterpolationCBox->setChecked(state);
  emit enableEdgeColorInterpolation(state);
}

bool MatrixViewConfigurationWidget::isEdgeColorInterpolation() const {
  return _ui->enableColorInterpolationCBox->isChecked();
}

void MatrixViewConfigurationWidget::setAscendingOrder(const bool state) {
  _ui->ascendingOrderCBox->setChecked(state);
}

bool MatrixViewConfigurationWidget::ascendingOrder() const {
  return _ui->ascendingOrderCBox->isChecked();
}

void MatrixViewConfigurationWidget::setOriented(const bool state) {
  _ui->orientedCBox->setChecked(state);
}

void MatrixViewConfigurationWidget::setGraph(tlp::Graph *g) {
  if (g == nullptr)
    return;

  QString firstString = _ui->orderingMetricCombo->itemText(0);
  QString currentString = _ui->orderingMetricCombo->currentText();
  _modifyingMetricList = true;
  _ui->orderingMetricCombo->clear();
  _ui->orderingMetricCombo->addItem(firstString);
  int currentIndex = 0;
  int i = 0;
  for (const string &s : g->getProperties()) {
    string type = g->getProperty(s)->getTypename();

    if (type != DoubleProperty::propertyTypename && type != IntegerProperty::propertyTypename &&
        type != StringProperty::propertyTypename)
      continue;

    _ui->orderingMetricCombo->addItem(tlpStringToQString(s));

    if (QStringToTlpString(currentString).compare(s) == 0)
      currentIndex = i;

    ++i;
  }
  _modifyingMetricList = false;
  _ui->orderingMetricCombo->setCurrentIndex(currentIndex);
}

void MatrixViewConfigurationWidget::orderingMetricComboIndexChanged(int i) {
  if (_modifyingMetricList)
    return;

  string name;

  if (i > 0)
    name = QStringToTlpString(_ui->orderingMetricCombo->itemText(i));

  emit metricSelected(name);
}

void MatrixViewConfigurationWidget::orderingDirectionChanged() {
  orderingMetricComboIndexChanged(_ui->orderingMetricCombo->currentIndex());
}

GridDisplayMode MatrixViewConfigurationWidget::gridDisplayMode() const {
  return static_cast<GridDisplayMode>(_ui->gridDisplayCombo->currentIndex());
}

int MatrixViewConfigurationWidget::orderingProperty() const {
  return _ui->orderingMetricCombo->currentIndex();
}

void MatrixViewConfigurationWidget::setOrderingProperty(int index) {
  _ui->orderingMetricCombo->setCurrentIndex(index);
}

void MatrixViewConfigurationWidget::setgridmode(int index) {
  _ui->gridDisplayCombo->setCurrentIndex(index);
}
} // namespace tlp