mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-21 07:20:28 -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
|
@ -42,7 +42,8 @@ class RsDisc
|
||||||
RsDisc() { return; }
|
RsDisc() { return; }
|
||||||
virtual ~RsDisc() { return; }
|
virtual ~RsDisc() { return; }
|
||||||
|
|
||||||
virtual bool getDiscFriends(std::string id, std::list<std::string> &friends) = 0;
|
virtual bool getDiscFriends(std::string id, std::list<std::string>& friends) = 0;
|
||||||
|
virtual bool getDiscGPGFriends(std::string id, std::list<std::string>& gpg_friends) = 0;
|
||||||
virtual bool getDiscVersions(std::map<std::string, std::string> &versions) = 0;
|
virtual bool getDiscVersions(std::map<std::string, std::string> &versions) = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,6 +29,14 @@
|
||||||
|
|
||||||
RsDisc *rsDisc = NULL;
|
RsDisc *rsDisc = NULL;
|
||||||
|
|
||||||
|
bool p3Discovery::getDiscGPGFriends(std::string id, std::list<std::string>& gpg_friends)
|
||||||
|
{
|
||||||
|
if (mDisc)
|
||||||
|
{
|
||||||
|
return mDisc->potentialGPGproxies(id, gpg_friends);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
bool p3Discovery::getDiscFriends(std::string id, std::list<std::string> &friends)
|
bool p3Discovery::getDiscFriends(std::string id, std::list<std::string> &friends)
|
||||||
{
|
{
|
||||||
if (mDisc)
|
if (mDisc)
|
||||||
|
|
|
@ -38,6 +38,7 @@ class p3Discovery: public RsDisc
|
||||||
virtual ~p3Discovery() { return; }
|
virtual ~p3Discovery() { return; }
|
||||||
|
|
||||||
virtual bool getDiscFriends(std::string id, std::list<std::string> &friends);
|
virtual bool getDiscFriends(std::string id, std::list<std::string> &friends);
|
||||||
|
virtual bool getDiscGPGFriends(std::string id, std::list<std::string> &gpg_friends);
|
||||||
virtual bool getDiscVersions(std::map<std::string, std::string> &versions);
|
virtual bool getDiscVersions(std::map<std::string, std::string> &versions);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -615,7 +615,7 @@ void p3disc::recvPeerDetails(RsDiscReply *item, const std::string &certGpgId)
|
||||||
for (std::list<RsPeerNetItem>::iterator pitem = item->rsPeerList.begin(); pitem != item->rsPeerList.end(); pitem++)
|
for (std::list<RsPeerNetItem>::iterator pitem = item->rsPeerList.begin(); pitem != item->rsPeerList.end(); pitem++)
|
||||||
{
|
{
|
||||||
bool new_info ;
|
bool new_info ;
|
||||||
addDiscoveryData(item->PeerId(), pitem->pid, pitem->currentlocaladdr, pitem->currentremoteaddr, 0, time(NULL),new_info);
|
addDiscoveryData(item->PeerId(), pitem->pid,rsPeers->getGPGId(item->PeerId()),item->aboutId, pitem->currentlocaladdr, pitem->currentremoteaddr, 0, time(NULL),new_info);
|
||||||
|
|
||||||
if(new_info)
|
if(new_info)
|
||||||
should_notify_discovery = true ;
|
should_notify_discovery = true ;
|
||||||
|
@ -895,11 +895,14 @@ void p3disc::setGPGOperation(AuthGPGOperation *operation)
|
||||||
/*************************************************************************************/
|
/*************************************************************************************/
|
||||||
/* Storing Network Graph */
|
/* Storing Network Graph */
|
||||||
/*************************************************************************************/
|
/*************************************************************************************/
|
||||||
int p3disc::addDiscoveryData(std::string fromId, std::string aboutId, struct sockaddr_in laddr, struct sockaddr_in raddr, uint32_t flags, time_t ts,bool& new_info)
|
int p3disc::addDiscoveryData(const std::string& fromId, const std::string& aboutId,const std::string& from_gpg_id,const std::string& about_gpg_id, const struct sockaddr_in& laddr, const struct sockaddr_in& raddr, uint32_t flags, time_t ts,bool& new_info)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
new_info = false ;
|
new_info = false ;
|
||||||
|
|
||||||
|
gpg_neighbors[from_gpg_id].insert(about_gpg_id) ;
|
||||||
|
|
||||||
std::cerr << "Adding discovery data " << fromId << " - " << aboutId << std::endl ;
|
std::cerr << "Adding discovery data " << fromId << " - " << aboutId << std::endl ;
|
||||||
/* Store Network information */
|
/* Store Network information */
|
||||||
std::map<std::string, autoneighbour>::iterator it;
|
std::map<std::string, autoneighbour>::iterator it;
|
||||||
|
@ -963,7 +966,7 @@ int p3disc::addDiscoveryData(std::string fromId, std::string aboutId, struct soc
|
||||||
/*************************************************************************************/
|
/*************************************************************************************/
|
||||||
/* Extracting Network Graph Details */
|
/* Extracting Network Graph Details */
|
||||||
/*************************************************************************************/
|
/*************************************************************************************/
|
||||||
bool p3disc::potentialproxies(std::string id, std::list<std::string> &proxyIds)
|
bool p3disc::potentialproxies(const std::string& id, std::list<std::string> &proxyIds)
|
||||||
{
|
{
|
||||||
/* find id -> and extract the neighbour_of ids */
|
/* find id -> and extract the neighbour_of ids */
|
||||||
|
|
||||||
|
@ -979,13 +982,31 @@ bool p3disc::potentialproxies(std::string id, std::list<std::string> &proxyIds)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(sit = it->second.neighbour_of.begin();
|
for(sit = it->second.neighbour_of.begin(); sit != it->second.neighbour_of.end(); sit++)
|
||||||
sit != it->second.neighbour_of.end(); sit++)
|
|
||||||
{
|
{
|
||||||
proxyIds.push_back(sit->first);
|
proxyIds.push_back(sit->first);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
bool p3disc::potentialGPGproxies(const std::string& gpg_id, std::list<std::string> &proxyGPGIds)
|
||||||
|
{
|
||||||
|
/* find id -> and extract the neighbour_of ids */
|
||||||
|
|
||||||
|
if(gpg_id == rsPeers->getGPGOwnId()) // SSL id // This is treated appart, because otherwise we don't receive any disc info about us
|
||||||
|
return rsPeers->getGPGAcceptedList(proxyGPGIds) ;
|
||||||
|
|
||||||
|
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
|
std::map<std::string, std::set<std::string> >::iterator it = gpg_neighbors.find(gpg_id) ;
|
||||||
|
|
||||||
|
if(it == gpg_neighbors.end())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for(std::set<std::string>::const_iterator sit(it->second.begin()); sit != it->second.end(); ++sit)
|
||||||
|
proxyGPGIds.push_back(*sit);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void p3disc::getversions(std::map<std::string, std::string> &versions)
|
void p3disc::getversions(std::map<std::string, std::string> &versions)
|
||||||
{
|
{
|
||||||
|
|
|
@ -89,7 +89,8 @@ virtual void statusChange(const std::list<pqipeer> &plist);
|
||||||
int tick();
|
int tick();
|
||||||
|
|
||||||
/* GUI requires access */
|
/* GUI requires access */
|
||||||
bool potentialproxies(std::string id, std::list<std::string> &proxyIds);
|
bool potentialGPGproxies(const std::string& id, std::list<std::string> &proxyGPGIds);
|
||||||
|
bool potentialproxies(const std::string& id, std::list<std::string> &proxyIds);
|
||||||
void getversions(std::map<std::string, std::string> &versions);
|
void getversions(std::map<std::string, std::string> &versions);
|
||||||
|
|
||||||
/************* from AuthGPService ****************/
|
/************* from AuthGPService ****************/
|
||||||
|
@ -130,8 +131,9 @@ void recvHeartbeatMsg(RsDiscHeartbeat *item);
|
||||||
void removeFriend(std::string ssl_id); //keep tracks of removed friend so we're not gonna add them again immediately
|
void removeFriend(std::string ssl_id); //keep tracks of removed friend so we're not gonna add them again immediately
|
||||||
|
|
||||||
/* handle network shape */
|
/* handle network shape */
|
||||||
int addDiscoveryData(std::string fromId, std::string aboutId,
|
int addDiscoveryData(const std::string& fromId, const std::string& aboutId,
|
||||||
struct sockaddr_in laddr, struct sockaddr_in raddr,
|
const std::string& fromGPGId,const std::string& aboutGPGId,
|
||||||
|
const struct sockaddr_in& laddr, const struct sockaddr_in& raddr,
|
||||||
uint32_t flags, time_t ts,bool& new_info);
|
uint32_t flags, time_t ts,bool& new_info);
|
||||||
|
|
||||||
int idServers();
|
int idServers();
|
||||||
|
@ -152,6 +154,10 @@ int idServers();
|
||||||
|
|
||||||
std::map<std::string, std::list<std::string> > sendIdList;
|
std::map<std::string, std::list<std::string> > sendIdList;
|
||||||
std::list<RsDiscReply*> pendingDiscReplyInList;
|
std::list<RsDiscReply*> pendingDiscReplyInList;
|
||||||
|
|
||||||
|
// Neighbors at the gpg level.
|
||||||
|
//
|
||||||
|
std::map<std::string,std::set<std::string> > gpg_neighbors ;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -54,11 +54,10 @@ NetworkView::NetworkView(QWidget *parent)
|
||||||
setMaxFriendLevel(ui.maxFriendLevelSB->value()) ;
|
setMaxFriendLevel(ui.maxFriendLevelSB->value()) ;
|
||||||
|
|
||||||
/* add button */
|
/* add button */
|
||||||
connect( ui.refreshButton, SIGNAL( clicked( void ) ), this, SLOT( updateDisplay( void ) ) );
|
connect( ui.refreshButton, SIGNAL( clicked( void ) ), this, SLOT( redraw( void ) ) );
|
||||||
connect( mScene, SIGNAL( changed ( const QList<QRectF> & ) ), this, SLOT ( changedScene( void ) ) );
|
connect( mScene, SIGNAL( changed ( const QList<QRectF> & ) ), this, SLOT ( changedScene( void ) ) );
|
||||||
|
|
||||||
/* Hide Settings frame */
|
/* Hide Settings frame */
|
||||||
shownwSettingsFrame(false);
|
|
||||||
connect( ui.maxFriendLevelSB, SIGNAL(valueChanged(int)), this, SLOT(setMaxFriendLevel(int)));
|
connect( ui.maxFriendLevelSB, SIGNAL(valueChanged(int)), this, SLOT(setMaxFriendLevel(int)));
|
||||||
connect( ui.edgeLengthSB, SIGNAL(valueChanged(int)), this, SLOT(setEdgeLength(int)));
|
connect( ui.edgeLengthSB, SIGNAL(valueChanged(int)), this, SLOT(setEdgeLength(int)));
|
||||||
|
|
||||||
|
@ -71,6 +70,8 @@ void NetworkView::setEdgeLength(int l)
|
||||||
}
|
}
|
||||||
void NetworkView::setMaxFriendLevel(int m)
|
void NetworkView::setMaxFriendLevel(int m)
|
||||||
{
|
{
|
||||||
|
ui.graphicsView->snapshotNodesPositions() ;
|
||||||
|
clear() ;
|
||||||
_max_friend_level = m ;
|
_max_friend_level = m ;
|
||||||
updateDisplay() ;
|
updateDisplay() ;
|
||||||
}
|
}
|
||||||
|
@ -78,51 +79,26 @@ void NetworkView::changedFoFCheckBox( )
|
||||||
{
|
{
|
||||||
updateDisplay();
|
updateDisplay();
|
||||||
}
|
}
|
||||||
|
void NetworkView::redraw()
|
||||||
void NetworkView::clearPeerItems()
|
|
||||||
{
|
{
|
||||||
std::map<std::string, QGraphicsItem *>::iterator pit;
|
ui.graphicsView->clearNodesPositions() ;
|
||||||
|
clear() ;
|
||||||
for(pit = mPeerItems.begin(); pit != mPeerItems.end(); pit++)
|
updateDisplay() ;
|
||||||
{
|
|
||||||
mScene->destroyItemGroup((QGraphicsItemGroup *) pit->second);
|
|
||||||
}
|
|
||||||
mPeerItems.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetworkView::clear()
|
||||||
void NetworkView::clearOtherItems()
|
|
||||||
{
|
{
|
||||||
std::list<QGraphicsItem *>::iterator oit;
|
ui.graphicsView->clearGraph() ;
|
||||||
|
_node_ids.clear() ;
|
||||||
for(oit = mOtherItems.begin(); oit != mOtherItems.end(); oit++)
|
update() ;
|
||||||
{
|
|
||||||
mScene->removeItem(*oit);
|
|
||||||
delete (*oit);
|
|
||||||
}
|
|
||||||
mOtherItems.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void NetworkView::clearLineItems()
|
|
||||||
{
|
|
||||||
std::list<QGraphicsItem *>::iterator oit;
|
|
||||||
|
|
||||||
for(oit = mLineItems.begin(); oit != mLineItems.end(); oit++)
|
|
||||||
{
|
|
||||||
mScene->removeItem(*oit);
|
|
||||||
delete (*oit);
|
|
||||||
}
|
|
||||||
mLineItems.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class NodeInfo
|
class NodeInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NodeInfo(const std::string& _gpg_id,const std::string& _ssl_id,uint32_t lev) : gpg_id(_gpg_id),ssl_id(_ssl_id),friend_level(lev) {}
|
NodeInfo(const std::string& _gpg_id,uint32_t lev) : gpg_id(_gpg_id),friend_level(lev) {}
|
||||||
|
|
||||||
std::string gpg_id ;
|
std::string gpg_id ;
|
||||||
std::string ssl_id ;
|
|
||||||
uint32_t friend_level ;
|
uint32_t friend_level ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
@ -139,7 +115,6 @@ void NetworkView::updateDisplay()
|
||||||
|
|
||||||
/* add all friends */
|
/* add all friends */
|
||||||
std::string ownGPGId = rsPeers->getGPGOwnId();
|
std::string ownGPGId = rsPeers->getGPGOwnId();
|
||||||
std::string ownSSLId = rsPeers->getOwnId();
|
|
||||||
#ifdef DEBUG_NETWORKVIEW
|
#ifdef DEBUG_NETWORKVIEW
|
||||||
std::cerr << "NetworkView::updateDisplay()" << std::endl;
|
std::cerr << "NetworkView::updateDisplay()" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
@ -149,31 +124,9 @@ void NetworkView::updateDisplay()
|
||||||
std::deque<NodeInfo> nodes_to_treat ; // list of nodes to be treated. Used as a queue. The int is the level of friendness
|
std::deque<NodeInfo> nodes_to_treat ; // list of nodes to be treated. Used as a queue. The int is the level of friendness
|
||||||
std::set<std::string> nodes_considered ; // list of nodes already considered. Eases lookup.
|
std::set<std::string> nodes_considered ; // list of nodes already considered. Eases lookup.
|
||||||
|
|
||||||
nodes_to_treat.push_front(NodeInfo(ownGPGId,ownSSLId,0)) ; // initialize queue with own id.
|
nodes_to_treat.push_front(NodeInfo(ownGPGId,0)) ; // initialize queue with own id.
|
||||||
nodes_considered.insert(rsPeers->getOwnId()) ;
|
nodes_considered.insert(rsPeers->getOwnId()) ;
|
||||||
|
|
||||||
// compute the list of GPG friends
|
|
||||||
|
|
||||||
std::set<std::string> gpg_friends ;
|
|
||||||
std::list<std::string> friends ;
|
|
||||||
std::set<std::string> ssl_friends ;
|
|
||||||
|
|
||||||
if(!rsPeers->getFriendList(friends))
|
|
||||||
return ;
|
|
||||||
|
|
||||||
for(std::list<std::string>::const_iterator it(friends.begin());it!=friends.end();++it)
|
|
||||||
{
|
|
||||||
RsPeerDetails d ;
|
|
||||||
if(!rsPeers->getPeerDetails(*it,d))
|
|
||||||
continue ;
|
|
||||||
|
|
||||||
gpg_friends.insert(d.gpg_id) ;
|
|
||||||
ssl_friends.insert(d.id) ;
|
|
||||||
}
|
|
||||||
#ifdef DEBUG_NETWORKVIEW
|
|
||||||
std::cerr << "Found " << ssl_friends.size() << " gpg friends." << std::endl ;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Put own id in queue, and empty the queue, treating all nodes.
|
// Put own id in queue, and empty the queue, treating all nodes.
|
||||||
//
|
//
|
||||||
while(!nodes_to_treat.empty())
|
while(!nodes_to_treat.empty())
|
||||||
|
@ -181,22 +134,8 @@ void NetworkView::updateDisplay()
|
||||||
NodeInfo info(nodes_to_treat.back()) ;
|
NodeInfo info(nodes_to_treat.back()) ;
|
||||||
nodes_to_treat.pop_back() ;
|
nodes_to_treat.pop_back() ;
|
||||||
#ifdef DEBUG_NETWORKVIEW
|
#ifdef DEBUG_NETWORKVIEW
|
||||||
std::cerr << " Poped out of queue: " << info.ssl_id << ", with level " << info.friend_level << std::endl ;
|
std::cerr << " Poped out of queue: " << info.gpg_id << ", with level " << info.friend_level << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
std::list<std::string> friendList;
|
|
||||||
rsDisc->getDiscFriends(info.ssl_id, friendList);
|
|
||||||
|
|
||||||
#ifdef DEBUG_NETWORKVIEW
|
|
||||||
std::cerr << " Got a list of " << friendList.size() << " friends for this peer." << std::endl ;
|
|
||||||
#endif
|
|
||||||
// if(!rsPeers->getPeerDetails(info.gpg_id,detail))
|
|
||||||
// {
|
|
||||||
// std::cerr << "Could not request GPG details for node " << info.gpg_id << std::endl ;
|
|
||||||
// continue ;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if(info.friend_level <= _max_friend_level && (info.friend_level != 1 || ssl_friends.find(info.ssl_id) != ssl_friends.end()))
|
|
||||||
{
|
|
||||||
GraphWidget::NodeType type ;
|
GraphWidget::NodeType type ;
|
||||||
GraphWidget::AuthType auth ;
|
GraphWidget::AuthType auth ;
|
||||||
|
|
||||||
|
@ -213,7 +152,7 @@ void NetworkView::updateDisplay()
|
||||||
}
|
}
|
||||||
|
|
||||||
RsPeerDetails detail ;
|
RsPeerDetails detail ;
|
||||||
if (!rsPeers->getPeerDetails(info.ssl_id, detail))
|
if(!rsPeers->getPeerDetails(info.gpg_id, detail))
|
||||||
continue ;
|
continue ;
|
||||||
|
|
||||||
switch(detail.validLvl)
|
switch(detail.validLvl)
|
||||||
|
@ -227,39 +166,31 @@ void NetworkView::updateDisplay()
|
||||||
default: auth = GraphWidget::ELASTIC_NODE_AUTH_UNKNOWN ; break ;
|
default: auth = GraphWidget::ELASTIC_NODE_AUTH_UNKNOWN ; break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_node_ids.find(info.ssl_id) == _node_ids.end())
|
if(info.friend_level <= _max_friend_level && _node_ids.find(info.gpg_id) == _node_ids.end())
|
||||||
{
|
{
|
||||||
_node_ids[info.ssl_id] = ui.graphicsView->addNode(" "+detail.name +"("+detail.location+")", "("+detail.name+","+info.ssl_id+","+detail.gpg_id+")",type,auth,info.ssl_id,info.gpg_id);
|
_node_ids[info.gpg_id] = ui.graphicsView->addNode(" "+detail.name, detail.name+"@"+detail.gpg_id,type,auth,"",info.gpg_id);
|
||||||
#ifdef DEBUG_NETWORKVIEW
|
#ifdef DEBUG_NETWORKVIEW
|
||||||
std::cerr << " inserted node " << info.ssl_id << ", type=" << type << ", auth=" << auth << std::endl ;
|
std::cerr << " inserted node " << info.gpg_id << ", type=" << type << ", auth=" << auth << std::endl ;
|
||||||
std::cerr << " NetworkView::updateDisplay() Added Friend: " << info.ssl_id << std::endl;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::list<std::string> friendList;
|
||||||
|
rsDisc->getDiscGPGFriends(info.gpg_id, friendList);
|
||||||
|
|
||||||
|
#ifdef DEBUG_NETWORKVIEW
|
||||||
|
std::cerr << " Got a list of " << friendList.size() << " friends for this peer." << std::endl ;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(info.friend_level+1 <= _max_friend_level)
|
||||||
for(std::list<std::string>::const_iterator sit(friendList.begin()); sit != friendList.end(); ++sit)
|
for(std::list<std::string>::const_iterator sit(friendList.begin()); sit != friendList.end(); ++sit)
|
||||||
if(nodes_considered.find(*sit) == nodes_considered.end())
|
if(nodes_considered.find(*sit) == nodes_considered.end())
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_NETWORKVIEW
|
#ifdef DEBUG_NETWORKVIEW
|
||||||
std::cerr << " adding to queue: " << *sit << ", with level " << info.friend_level+1 << std::endl ;
|
std::cerr << " adding to queue: " << *sit << ", with level " << info.friend_level+1 << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
nodes_to_treat.push_front( NodeInfo("unknown",*sit,info.friend_level + 1) ) ;
|
nodes_to_treat.push_front( NodeInfo(*sit,info.friend_level + 1) ) ;
|
||||||
nodes_considered.insert(*sit) ;
|
nodes_considered.insert(*sit) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// now insert in list the GPG signers that are not our friends, to get 2nd order peers in the network.
|
|
||||||
//
|
|
||||||
for(std::list<std::string>::const_iterator sit(detail.gpgSigners.begin()); sit != detail.gpgSigners.end(); ++sit)
|
|
||||||
if(nodes_considered.find(*sit) == nodes_considered.end() && gpg_friends.find(*sit) == gpg_friends.end())
|
|
||||||
{
|
|
||||||
#ifdef DEBUG_NETWORKVIEW
|
|
||||||
std::cerr << " adding to queue: " << *sit << ", with level " << info.friend_level+1 << std::endl ;
|
|
||||||
#endif
|
|
||||||
nodes_to_treat.push_front( NodeInfo(*sit,*sit,info.friend_level + 1) ) ;
|
|
||||||
nodes_considered.insert(*sit) ;
|
|
||||||
gpg_friends.insert(*sit) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* iterate through all friends */
|
/* iterate through all friends */
|
||||||
|
@ -272,13 +203,11 @@ void NetworkView::updateDisplay()
|
||||||
{
|
{
|
||||||
std::list<std::string> friendList ;
|
std::list<std::string> friendList ;
|
||||||
|
|
||||||
if(rsDisc->getDiscFriends(it->first,friendList))
|
if(rsDisc->getDiscGPGFriends(it->first,friendList))
|
||||||
for(std::list<std::string>::const_iterator sit(friendList.begin()); sit != friendList.end(); sit++)
|
for(std::list<std::string>::const_iterator sit(friendList.begin()); sit != friendList.end(); sit++)
|
||||||
{
|
{
|
||||||
if(it->first < *sit)
|
|
||||||
{
|
|
||||||
#ifdef DEBUG_NETWORKVIEW
|
#ifdef DEBUG_NETWORKVIEW
|
||||||
std::cerr << "NetworkView: Adding Arrow: ";
|
std::cerr << "NetworkView: Adding Edge: ";
|
||||||
std::cerr << *sit << " <-> " << it->first;
|
std::cerr << *sit << " <-> " << it->first;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
@ -287,24 +216,7 @@ void NetworkView::updateDisplay()
|
||||||
ui.graphicsView->addEdge(_node_ids[*sit], it->second);
|
ui.graphicsView->addEdge(_node_ids[*sit], it->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
_should_update = false ;
|
_should_update = false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Toggles the Settings pane on and off, changes toggle button text
|
|
||||||
*/
|
|
||||||
void NetworkView::shownwSettingsFrame(bool show)
|
|
||||||
{
|
|
||||||
if (show) {
|
|
||||||
// ui.viewsettingsframe->setVisible(true);
|
|
||||||
// ui.nviewsettingsButton->setChecked(true);
|
|
||||||
// ui.nviewsettingsButton->setToolTip(tr("Hide Settings"));
|
|
||||||
} else {
|
|
||||||
// ui.viewsettingsframe->setVisible(false);
|
|
||||||
// ui.nviewsettingsButton->setChecked(false);
|
|
||||||
// ui.nviewsettingsButton->setToolTip(tr("Show Settings"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -46,25 +46,14 @@ class NetworkView : public RsAutoUpdatePage
|
||||||
void setEdgeLength(int) ;
|
void setEdgeLength(int) ;
|
||||||
|
|
||||||
void changedFoFCheckBox( );
|
void changedFoFCheckBox( );
|
||||||
|
void redraw();
|
||||||
/** Called when Settings button is toggled */
|
|
||||||
void shownwSettingsFrame(bool show);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void clearPeerItems();
|
void clear();
|
||||||
void clearOtherItems();
|
|
||||||
void clearLineItems();
|
|
||||||
|
|
||||||
QGraphicsScene *mScene;
|
QGraphicsScene *mScene;
|
||||||
|
|
||||||
std::map<std::string, QGraphicsItem *> mPeerItems;
|
|
||||||
std::list<QGraphicsItem *> mOtherItems;
|
|
||||||
|
|
||||||
std::list<QGraphicsItem *> mLineItems;
|
|
||||||
bool mLineChanged;
|
|
||||||
|
|
||||||
|
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
Ui::NetworkView ui;
|
Ui::NetworkView ui;
|
||||||
int _max_friend_level ;
|
int _max_friend_level ;
|
||||||
|
|
|
@ -54,6 +54,9 @@
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="2">
|
<item row="0" column="2">
|
||||||
<widget class="QComboBox" name="comboBox">
|
<widget class="QComboBox" name="comboBox">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Basic</string>
|
<string>Basic</string>
|
||||||
|
@ -73,6 +76,9 @@
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Display mode:</string>
|
<string>Display mode:</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -84,7 +90,10 @@
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>10</number>
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -166,10 +166,34 @@ GraphWidget::NodeId GraphWidget::addNode(const std::string& node_short_string,co
|
||||||
node->setToolTip(QString::fromStdString(node_complete_string)) ;
|
node->setToolTip(QString::fromStdString(node_complete_string)) ;
|
||||||
_nodes.push_back(node) ;
|
_nodes.push_back(node) ;
|
||||||
scene()->addItem(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 ;
|
std::cerr << "Added node " << _nodes.size()-1 << std::endl ;
|
||||||
return _nodes.size()-1 ;
|
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)
|
GraphWidget::EdgeId GraphWidget::addEdge(NodeId n1,NodeId n2)
|
||||||
{
|
{
|
||||||
std::pair<NodeId,NodeId> ed(std::min(n1,n2),std::max(n1,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) ;
|
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) ;
|
EdgeId addEdge(NodeId n1,NodeId n2) ;
|
||||||
|
|
||||||
|
void snapshotNodesPositions() ;
|
||||||
|
void clearNodesPositions() ;
|
||||||
void clearGraph() ;
|
void clearGraph() ;
|
||||||
virtual void itemMoved();
|
virtual void itemMoved();
|
||||||
|
|
||||||
|
@ -96,6 +98,7 @@ private:
|
||||||
|
|
||||||
std::vector<Node *> _nodes ;
|
std::vector<Node *> _nodes ;
|
||||||
std::map<std::pair<NodeId,NodeId>,Edge *> _edges ;
|
std::map<std::pair<NodeId,NodeId>,Edge *> _edges ;
|
||||||
|
std::map<std::string,QPointF> _node_cached_positions ;
|
||||||
|
|
||||||
uint32_t _edge_length ;
|
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:
|
// now time filter:
|
||||||
|
|
||||||
_speedx += xforce / MASS_FACTOR;
|
float f = (_type == GraphWidget::ELASTIC_NODE_TYPE_OWN)?10.0f:1.0f ;
|
||||||
_speedy += yforce / MASS_FACTOR;
|
|
||||||
|
_speedx += xforce / (MASS_FACTOR * f);
|
||||||
|
_speedy += yforce / (MASS_FACTOR * f);
|
||||||
|
|
||||||
if(_speedx > 10) _speedx = 10.0f ;
|
if(_speedx > 10) _speedx = 10.0f ;
|
||||||
if(_speedy > 10) _speedy = 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()
|
bool Node::advance()
|
||||||
{
|
{
|
||||||
if(_type == GraphWidget::ELASTIC_NODE_TYPE_OWN)
|
// if(_type == GraphWidget::ELASTIC_NODE_TYPE_OWN)
|
||||||
return false;
|
// return false;
|
||||||
|
|
||||||
float f = std::max(fabs(newPos.x() - pos().x()), fabs(newPos.y() - pos().y())) ;
|
float f = std::max(fabs(newPos.x() - pos().x()), fabs(newPos.y() - pos().y())) ;
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,7 @@ public:
|
||||||
const QList<Edge *>& edges() const;
|
const QList<Edge *>& edges() const;
|
||||||
|
|
||||||
int type() const { return Type; }
|
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);
|
void calculateForces(const double *data,int width,int height,int W,int H,float x,float y,float speedf);
|
||||||
bool advance();
|
bool advance();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue