mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-01 20:52:05 -04:00
improved networkview. It now displays GPG connexions from p3disc, and accepts dynamic friend level modification. Needs full recompilation.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3793 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
1597bd9136
commit
2094734391
12 changed files with 150 additions and 173 deletions
|
@ -166,10 +166,34 @@ 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(rand()%1000/53.0f, rand()%1000/53.0f);
|
||||
|
||||
std::map<std::string,QPointF>::const_iterator it(_node_cached_positions.find(gpg_id)) ;
|
||||
if(_node_cached_positions.end() != it)
|
||||
node->setPos(it->second) ;
|
||||
else
|
||||
{
|
||||
qreal x1,y1,x2,y2 ;
|
||||
sceneRect().getCoords(&x1,&y1,&x2,&y2) ;
|
||||
|
||||
float f1 = rand()/(float)RAND_MAX ;
|
||||
float f2 = rand()/(float)RAND_MAX ;
|
||||
|
||||
node->setPos(x1+f1*(x2-x1),y1+f2*(y2-y1));
|
||||
}
|
||||
|
||||
std::cerr << "Added node " << _nodes.size()-1 << std::endl ;
|
||||
return _nodes.size()-1 ;
|
||||
}
|
||||
void GraphWidget::snapshotNodesPositions()
|
||||
{
|
||||
for(uint32_t i=0;i<_nodes.size();++i)
|
||||
_node_cached_positions[_nodes[i]->idString()] = _nodes[i]->mapToScene(QPointF(0,0)) ;
|
||||
}
|
||||
void GraphWidget::clearNodesPositions()
|
||||
{
|
||||
_node_cached_positions.clear() ;
|
||||
}
|
||||
|
||||
GraphWidget::EdgeId GraphWidget::addEdge(NodeId n1,NodeId n2)
|
||||
{
|
||||
std::pair<NodeId,NodeId> ed(std::min(n1,n2),std::max(n1,n2)) ;
|
||||
|
|
|
@ -75,6 +75,8 @@ public:
|
|||
NodeId addNode(const std::string& NodeShortText,const std::string& nodeCompleteText,NodeType type,AuthType auth,const std::string& ssl_id,const std::string& gpg_id) ;
|
||||
EdgeId addEdge(NodeId n1,NodeId n2) ;
|
||||
|
||||
void snapshotNodesPositions() ;
|
||||
void clearNodesPositions() ;
|
||||
void clearGraph() ;
|
||||
virtual void itemMoved();
|
||||
|
||||
|
@ -96,6 +98,7 @@ private:
|
|||
|
||||
std::vector<Node *> _nodes ;
|
||||
std::map<std::pair<NodeId,NodeId>,Edge *> _edges ;
|
||||
std::map<std::string,QPointF> _node_cached_positions ;
|
||||
|
||||
uint32_t _edge_length ;
|
||||
};
|
||||
|
|
|
@ -187,8 +187,10 @@ void Node::calculateForces(const double *map,int width,int height,int W,int H,fl
|
|||
|
||||
// now time filter:
|
||||
|
||||
_speedx += xforce / MASS_FACTOR;
|
||||
_speedy += yforce / MASS_FACTOR;
|
||||
float f = (_type == GraphWidget::ELASTIC_NODE_TYPE_OWN)?10.0f:1.0f ;
|
||||
|
||||
_speedx += xforce / (MASS_FACTOR * f);
|
||||
_speedy += yforce / (MASS_FACTOR * f);
|
||||
|
||||
if(_speedx > 10) _speedx = 10.0f ;
|
||||
if(_speedy > 10) _speedy = 10.0f ;
|
||||
|
@ -203,8 +205,8 @@ 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;
|
||||
// if(_type == GraphWidget::ELASTIC_NODE_TYPE_OWN)
|
||||
// return false;
|
||||
|
||||
float f = std::max(fabs(newPos.x() - pos().x()), fabs(newPos.y() - pos().y())) ;
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ public:
|
|||
const QList<Edge *>& edges() const;
|
||||
|
||||
int type() const { return Type; }
|
||||
const std::string& idString() const { return _gpg_id ; }
|
||||
|
||||
void calculateForces(const double *data,int width,int height,int W,int H,float x,float y,float speedf);
|
||||
bool advance();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue