mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-11-27 02:56:30 -05:00
dynamic update of networkview from p3disc info. Disabled friend level for now.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3752 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
3fa3e2d6db
commit
a32bcbb635
14 changed files with 194 additions and 202 deletions
|
|
@ -125,6 +125,7 @@ GraphWidget::GraphWidget(QWidget *)
|
|||
{
|
||||
QGraphicsScene *scene = new QGraphicsScene(this);
|
||||
scene->setItemIndexMethod(QGraphicsScene::NoIndex);
|
||||
scene->clear() ;
|
||||
scene->setSceneRect(-200, -200, 1000, 1000);
|
||||
setScene(scene);
|
||||
|
||||
|
|
@ -167,15 +168,25 @@ GraphWidget::NodeId GraphWidget::addNode(const std::string& node_short_string,co
|
|||
node->setToolTip(QString::fromStdString(node_complete_string)) ;
|
||||
_nodes.push_back(node) ;
|
||||
scene()->addItem(node);
|
||||
node->setPos(-50+rand()%1000/53.0f, -50+rand()%1000/53.0f);
|
||||
node->setPos(rand()%1000/53.0f, rand()%1000/53.0f);
|
||||
std::cerr << "Added node " << _nodes.size()-1 << std::endl ;
|
||||
return _nodes.size()-1 ;
|
||||
}
|
||||
GraphWidget::EdgeId GraphWidget::addEdge(NodeId n1,NodeId n2)
|
||||
{
|
||||
Edge *edge = new Edge(_nodes[n1],_nodes[n2]);
|
||||
scene()->addItem(edge);
|
||||
return 0 ;
|
||||
std::pair<NodeId,NodeId> ed(std::min(n1,n2),std::max(n1,n2)) ;
|
||||
|
||||
if( _edges.find(ed) == _edges.end() )
|
||||
{
|
||||
Edge *edge = new Edge(_nodes[n1],_nodes[n2]);
|
||||
scene()->addItem(edge);
|
||||
_edges[ed] = edge ;
|
||||
std::cerr << "Added edge " << n1 << " - " << n2 << std::endl ;
|
||||
}
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
void GraphWidget::itemMoved()
|
||||
{
|
||||
if (!timerId)
|
||||
|
|
|
|||
|
|
@ -42,10 +42,12 @@
|
|||
#ifndef GRAPHWIDGET_H
|
||||
#define GRAPHWIDGET_H
|
||||
|
||||
#include <map>
|
||||
#include <QtGui/QGraphicsView>
|
||||
#include <stdint.h>
|
||||
|
||||
class Node;
|
||||
class Edge;
|
||||
|
||||
class GraphWidget : public QGraphicsView
|
||||
{
|
||||
|
|
@ -93,7 +95,7 @@ private:
|
|||
bool mDeterminedBB ;
|
||||
|
||||
std::vector<Node *> _nodes ;
|
||||
std::vector<Node *> _edges ;
|
||||
std::map<std::pair<NodeId,NodeId>,Edge *> _edges ;
|
||||
|
||||
uint32_t _edge_length ;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ void Node::addEdge(Edge *edge)
|
|||
edge->adjust();
|
||||
}
|
||||
|
||||
QList<Edge *> Node::edges() const
|
||||
const QList<Edge *>& Node::edges() const
|
||||
{
|
||||
return edgeList;
|
||||
}
|
||||
|
|
@ -163,8 +163,6 @@ void Node::calculateForces(const double *map,int width,int height,int W,int H,fl
|
|||
yforce += 0.01*pos.y() * val / weight;
|
||||
}
|
||||
|
||||
static const float friction = 0.4 ;
|
||||
|
||||
xforce -= FRICTION_FACTOR * _speedx ;
|
||||
yforce -= FRICTION_FACTOR * _speedy ;
|
||||
|
||||
|
|
@ -193,10 +191,13 @@ void Node::calculateForces(const double *map,int width,int height,int W,int H,fl
|
|||
|
||||
bool Node::advance()
|
||||
{
|
||||
if(_type == GraphWidget::ELASTIC_NODE_TYPE_OWN)
|
||||
return false;
|
||||
|
||||
float f = std::max(fabs(newPos.x() - pos().x()), fabs(newPos.y() - pos().y())) ;
|
||||
|
||||
setPos(newPos);
|
||||
return f > 0.05;
|
||||
return f > 0.5;
|
||||
}
|
||||
|
||||
QRectF Node::boundingRect() const
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public:
|
|||
Node(const std::string& node_string,GraphWidget::NodeType type,GraphWidget::AuthType auth,GraphWidget *graphWidget);
|
||||
|
||||
void addEdge(Edge *edge);
|
||||
QList<Edge *> edges() const;
|
||||
const QList<Edge *>& edges() const;
|
||||
|
||||
int type() const { return Type; }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue