コード例 #1
0
ファイル: NewEdgeExecutor.cpp プロジェクト: kapecp/3dsoftviz
void NewEdgeExecutor::execute_server()
{

	Server* server = Server::getInstance();

	QString name;
	int from, to;
	bool oriented;

	*stream >> name >> from >> to >> oriented;
	//qDebug()<< "[NEW NODE]" << "[" << x << "," << y << "," << z << "]";


	Data::Graph* currentGraph = Manager::GraphManager::getInstance()->getActiveGraph();
	QMap<qlonglong, osg::ref_ptr<Data::Node> >* nodes = currentGraph -> getNodes();

	osg::ref_ptr<Data::Node> node_from = *nodes->find( from );
	osg::ref_ptr<Data::Node> node_to = *nodes->find( to );

	Data::Type* type = currentGraph->addType( Data::GraphLayout::META_EDGE_TYPE );

	osg::ref_ptr<Data::Edge> newEdge = currentGraph->addEdge( "NewEdge",node_from,node_to,type,oriented );

	if ( ( ( QOSG::CoreWindow* )server->getCoreWindowReference() )->playing() ) {
		server->getLayoutThread()->play();
	}

	server->sendNewEdge( newEdge );
}
コード例 #2
0
void AddMetaNodeExecutor::execute_client() {

    int count, metaNodeId, id_edge, id_node;
    QString name, edgeName;
    float x, y, z;

    *stream >> metaNodeId >> name;

    Data::Graph * currentGraph = Manager::GraphManager::getInstance()->getActiveGraph();
    QMap<qlonglong, osg::ref_ptr<Data::Node> >* nodes = currentGraph -> getNodes();

    *stream >> x >> y >> z;

    osg::ref_ptr<Data::Node> metaNode = currentGraph->addNode(metaNodeId, name, currentGraph->getNodeMetaType(), osg::Vec3(x,y,z));

    *stream >> edgeName;
    *stream >> count;
    for (int i = 0; i < count; i++) {
        *stream >> id_edge >> id_node;
        if (nodes->contains(id_node)) {
            currentGraph->addEdge(id_edge, edgeName, *nodes->find(id_node), metaNode, currentGraph->getEdgeMetaType(), true);
        }
    }

}
コード例 #3
0
void AddMetaNodeExecutor::execute_server()
{

	int count, id;
	QString name, edgeName;
	float x, y, z;

	*stream >> name;

	Data::Graph* currentGraph = Manager::GraphManager::getInstance()->getActiveGraph();
	QMap<qlonglong, osg::ref_ptr<Data::Node> >* nodes = currentGraph -> getNodes();

	*stream >> x >> y >> z;

	osg::ref_ptr<Data::Node> metaNode = currentGraph->addNode( name, currentGraph->getNodeMetaType(), osg::Vec3( x,y,z ) );

	*stream >> edgeName;
	*stream >> count;
	QLinkedList<osg::ref_ptr<Data::Node> >* selectedNodes = new QLinkedList<osg::ref_ptr<Data::Node> >();

	for ( int i = 0; i < count; i++ ) {
		*stream >> id;
		if ( nodes->contains( id ) ) {
			currentGraph->addEdge( edgeName, *nodes->find( id ), metaNode, currentGraph->getEdgeMetaType(), true );
			selectedNodes->append( *nodes->find( id ) );
		}
	}

	Server* server = Server::getInstance();
	server->sendAddMetaNode( metaNode,selectedNodes,edgeName,osg::Vec3( x,y,z ) );

	if ( ( ( QOSG::CoreWindow* )server->getCoreWindowReference() )->playing() ) {
		server->getLayoutThread()->play();
	}


}
コード例 #4
0
void CoreWindow::addMetaNode()
{	
	Data::Graph * currentGraph = Manager::GraphManager::getInstance()->getActiveGraph();

	if (currentGraph != NULL)
	{
		osg::Vec3 position = viewerWidget->getPickHandler()->getSelectionCenter(true); 

		osg::ref_ptr<Data::Node> metaNode = currentGraph->addNode("metaNode", currentGraph->getNodeMetaType(), position);	
		QLinkedList<osg::ref_ptr<Data::Node> > * selectedNodes = viewerWidget->getPickHandler()->getSelectedNodes();

		QLinkedList<osg::ref_ptr<Data::Node> >::const_iterator i = selectedNodes->constBegin();

		while (i != selectedNodes->constEnd()) 
		{
			Data::Edge * e = currentGraph->addEdge("metaEdge", (*i), metaNode, currentGraph->getEdgeMetaType(), true);
			e->setCamera(viewerWidget->getCamera());
			++i;
		}

		if (isPlaying)
			layout->play();
	}
}
コード例 #5
0
bool CoreWindow::add_EdgeClick()
{
	Data::Type *edgeType = NULL;
	Data::Type *nodeType = NULL;
	Data::Graph * currentGraph = Manager::GraphManager::getInstance()->getActiveGraph();
	
	
	QLinkedList<osg::ref_ptr<Data::Node> > * selectedNodes = viewerWidget->getPickHandler()->getSelectedNodes();
	QLinkedList<osg::ref_ptr<Data::Node> >::const_iterator ni = selectedNodes->constBegin();
	
	if (
		selectedNodes==NULL
			) {
				AppCore::Core::getInstance()->messageWindows->showMessageBox("Upozornenie","Žiadny uzol oznaèený",false);
				return false;
			}

	osg::ref_ptr<Data::Node> node1, node2;
	int i=0;
	
	while (ni != selectedNodes->constEnd()) 
	{
		osg::ref_ptr<Data::Node> existingNode = (* ni);
		++ni;i++;
	}
		if (	
			i!=2
			) {
				AppCore::Core::getInstance()->messageWindows->showMessageBox("Upozornenie","Musite vybrat práve 2 vrcholy",false);
				return false;
			}
	ni = selectedNodes->constBegin();
	node2=(* ni);
	++ni;
	node1=(* ni);
	++ni;
	QMap<qlonglong, osg::ref_ptr<Data::Edge> > *mapa = currentGraph->getEdges();
	Data::Type* type = currentGraph->addType(Data::GraphLayout::META_EDGE_TYPE);
	for (QMap<qlonglong, osg::ref_ptr<Data::Edge> >::iterator it = mapa->begin (); it != mapa->end (); ++it) {
			osg::ref_ptr<Data::Edge> existingEdge = it.value ();
			if (
				existingEdge->getSrcNode () ->getName () == node1 ->getName () && 
				existingEdge->getDstNode () ->getName () == node2 ->getName ()
			) {
				AppCore::Core::getInstance()->messageWindows->showMessageBox("Hrana najdená","Medzi vrcholmi nesmie byt hrana",false);
				return false;
			}
			if (
				existingEdge->getSrcNode () ->getName () == node2 ->getName () && 
				existingEdge->getDstNode () ->getName () == node1 ->getName ()
			) {
				AppCore::Core::getInstance()->messageWindows->showMessageBox("Hrana najdená","Medzi vrcholmi nesmie byt hrana",false);
				return false;
			}
		}

	
	currentGraph->addEdge("GUI_edge", node1, node2, type, false);
	if (isPlaying)
			layout->play();
	QString nodename1 = QString(node1->getName());
	QString nodename2 = QString(node2->getName());
	return true;
	//context.getGraph ().addEdge (QString (""), node1[1], node1[2], edgeType, true);

}