Skip to content

Commit

Permalink
Merge 4744a9c into b5bfb7d
Browse files Browse the repository at this point in the history
  • Loading branch information
Sedictious committed Aug 5, 2019
2 parents b5bfb7d + 4744a9c commit ba66ce5
Show file tree
Hide file tree
Showing 15 changed files with 339 additions and 53 deletions.
3 changes: 3 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ set(EVOPLEX_GUI_H
#contextmenutable.h
experimentdesigner.h
experimentwidget.h
fullinspector.h
graphdesigner.h
graphattrsdlg.h
graphgendlg.h
Expand Down Expand Up @@ -120,6 +121,7 @@ set(EVOPLEX_GUI_CXX
attrwidget.cpp
attrsgendlg.cpp
experimentdesigner.cpp
fullinspector.cpp
graphattrsdlg.cpp
graphgendlg.cpp
graphdesigner.cpp
Expand Down Expand Up @@ -155,6 +157,7 @@ set(EVOPLEX_GUI_UIFORM
attrsgendlg
consoletitlebar
experimentdesigner
fullinspector
basegraphgl
graphsettings
gridsettings
Expand Down
69 changes: 36 additions & 33 deletions src/gui/basegraphgl.cpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
/**
* This file is part of Evoplex.
*
* Evoplex is a multi-agent system for networks.
* Copyright (C) 2018 - Marcos Cardinot <marcos@cardinot.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* This file is part of Evoplex.
*
* Evoplex is a multi-agent system for networks.
* Copyright (C) 2018 - Marcos Cardinot <marcos@cardinot.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <QtConcurrent>
#include <QFutureWatcher>
Expand Down Expand Up @@ -120,6 +120,7 @@ void BaseGraphGL::slotSelectNode(int nodeid)
try {
Node node = m_abstractGraph->node(nodeid);
selectNode(node, m_bCenter->isChecked());
emit(nodeSelected(node));
} catch (std::out_of_range) {
if (selectedNode().isNull()) {
clearSelection();
Expand Down Expand Up @@ -187,13 +188,13 @@ void BaseGraphGL::attrValueChanged(int attrId) const
if (v.isValid()) {
node.setAttr(aw->id(), v);
// let the other widgets aware that they all need to be updated
emit (updateWidgets(true));
emit(updateWidgets(true));
} else {
aw->blockSignals(true);
aw->setValue(node.attr(aw->id()));
aw->blockSignals(false);
QString err = "The input for '" + aw->attrName() +
"' is invalid.\nExpected: " + aw->attrRangeStr();
"' is invalid.\nExpected: " + aw->attrRangeStr();
QMessageBox::warning(parentWidget(), "Graph", err);
}
}
Expand Down Expand Up @@ -413,7 +414,7 @@ void BaseGraphGL::keyPressEvent(QKeyEvent* e)
}

void BaseGraphGL::keyReleaseEvent(QKeyEvent* e)
{
{
if (!e->isAutoRepeat()) {
updateCache();
if (e->key() == Qt::Key_Space) {
Expand All @@ -423,7 +424,7 @@ void BaseGraphGL::keyReleaseEvent(QKeyEvent* e)
auto attrRange = m_nodeAttrsScope.value(attrName);
node.setAttr(m_nodeAttr, attrRange->next(node.attr(m_nodeAttr)));
updateInspector(node);
emit (updateWidgets(true));
emit(updateWidgets(true));
}
}
}
Expand All @@ -440,28 +441,28 @@ void BaseGraphGL::resizeEvent(QResizeEvent* e)
void BaseGraphGL::updateEdgeInspector(const Edge& edge)
{
m_ui->inspector->setCurrentIndex(1);

m_ui->edgeId->setText(QString::number(edge.id()));

m_ui->inspector->show();
m_ui->inspector->adjustSize();
m_inspGeo = m_ui->inspector->frameGeometry();
m_inspGeo += QMargins(5,5,5,5);
m_inspGeo += QMargins(5, 5, 5, 5);
}

void BaseGraphGL::updateEdgesInspector(const Node& srcNode, const Node& trgtNode)
{
m_ui->edgesList->clear();
QSet<int> edges;

for (auto const& e : srcNode.outEdges()) {
if (e.second.neighbour().id() == trgtNode.id()){
if (e.second.neighbour().id() == trgtNode.id()) {
edges.insert(e.first);
}
}

if (edges.size() == 0){
return;
if (edges.size() == 0) {
return;
}
// If there is only one edge to the target node, open the edgeInspector directly
if (edges.size() == 1)
Expand All @@ -470,9 +471,9 @@ void BaseGraphGL::updateEdgesInspector(const Node& srcNode, const Node& trgtNode
updateEdgeInspector(srcNode.outEdges().at(eId));
return;
}

m_ui->inspector->setCurrentIndex(2);

for (auto const& id : edges) {
new QListWidgetItem(QString::number(id), m_ui->edgesList);
}
Expand All @@ -481,7 +482,7 @@ void BaseGraphGL::updateEdgesInspector(const Node& srcNode, const Node& trgtNode
m_ui->inspector->show();
m_ui->inspector->adjustSize();
m_inspGeo = m_ui->inspector->frameGeometry();
m_inspGeo += QMargins(5,5,5,5);
m_inspGeo += QMargins(5, 5, 5, 5);
}

void BaseGraphGL::updateInspector(const Node& node)
Expand Down Expand Up @@ -513,11 +514,13 @@ void BaseGraphGL::updateInspector(const Node& node)
m_ui->inspector->show();
m_ui->inspector->adjustSize();
m_inspGeo = m_ui->inspector->frameGeometry();
m_inspGeo += QMargins(5,5,5,5);
m_inspGeo += QMargins(5, 5, 5, 5);
}

void BaseGraphGL::clearSelection()
{
emit(clearedSelected());

if (m_ui->inspector->isVisible()) {
m_ui->inspector->hide();
update();
Expand Down
15 changes: 15 additions & 0 deletions src/gui/basegraphgl.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#ifndef BASEGRAPHGL_H
#define BASEGRAPHGL_H

#include <map>
#include <memory>
#include <vector>

Expand All @@ -35,6 +36,8 @@

#include "colormap.h"
#include "experimentwidget.h"
#include "fullinspector.h"

#include "maingui.h"

class Ui_BaseGraphGL;
Expand Down Expand Up @@ -80,6 +83,9 @@ class BaseGraphGL : public QOpenGLWidget, public GraphGLInterface
void paint(QPaintDevice* device, bool paintBackground) const;

inline int currStep() const { return m_currStep; }
inline void setInspector(FullInspector* inspector);
std::map<int, Node> m_selectedNodes; //TODO: This shouldn't be public
// void updateFullInspector();

protected:
explicit BaseGraphGL(QWidget* parent);
Expand Down Expand Up @@ -116,6 +122,8 @@ class BaseGraphGL : public QOpenGLWidget, public GraphGLInterface
void keyReleaseEvent(QKeyEvent* e) override;

signals:
void nodeSelected(const Node&);
void clearedSelected();
void updateWidgets(bool) const;

public slots:
Expand Down Expand Up @@ -145,6 +153,8 @@ private slots:
QRect m_inspGeo; // inspector geometry with margin
SelectionMode m_curMode;
std::vector<std::shared_ptr<AttrWidget>> m_attrWidgets;
FullInspector* m_inspector;
bool m_fullInspectorVisible;

void attrValueChanged(int attrId) const;

Expand All @@ -155,6 +165,11 @@ private slots:
void updateEdgesInspector(const Node& pnode, const Node& cnode);
};

inline void BaseGraphGL::setInspector(FullInspector* inspector) {
m_fullInspectorVisible = true;
m_inspector = inspector;
}

inline void BaseGraphGL::paintEvent(QPaintEvent*)
{ paint(this, true); }

Expand Down
2 changes: 1 addition & 1 deletion src/gui/forms/basegraphgl.ui
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ color: rgb(255, 255, 255);</string>
<bool>false</bool>
</property>
<property name="currentIndex">
<number>1</number>
<number>2</number>
</property>
<widget class="QWidget" name="nodeInspector">
<layout class="QVBoxLayout" name="verticalLayout">
Expand Down
130 changes: 130 additions & 0 deletions src/gui/forms/fullinspector.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FullInspector</class>
<widget class="QDockWidget" name="FullInspector">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>403</width>
<height>558</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>278</height>
</size>
</property>
<property name="features">
<set>QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable</set>
</property>
<property name="windowTitle">
<string>Full Inspector</string>
</property>
<widget class="QWidget" name="FullInspectoContents">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="gridWidget" native="true">
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>20</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>20</number>
</property>
<property name="bottomMargin">
<number>20</number>
</property>
<property name="horizontalSpacing">
<number>0</number>
</property>
<property name="verticalSpacing">
<number>30</number>
</property>
<item row="0" column="1">
<widget class="QListWidget" name="ids">
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lids">
<property name="text">
<string>Ids:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QTableWidget" name="attrs">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustIgnored</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::AllEditTriggers</set>
</property>
<attribute name="horizontalHeaderCascadingSectionResizes">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderCascadingSectionResizes">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderStretchLastSection">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Attribute</string>
</property>
</column>
<column>
<property name="text">
<string>Value</string>
</property>
</column>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lattrs">
<property name="text">
<string>Attributes:</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>

0 comments on commit ba66ce5

Please sign in to comment.