Esempio n. 1
0
Data::Type::Type(qlonglong id, QString name,Data::Graph* graph, QMap<QString, QString> * settings) 
{
    this->id = id;
    this->name = name;
	this->inDB = false;
	this->graph = graph;
	this->meta = false;
	
	Util::ApplicationConfig * appConf = Util::ApplicationConfig::get();

	if (settings == NULL)
	{
		this->settings = new QMap<QString, QString>;

		this->settings->insert("scale", appConf->getValue("Viewer.Textures.DefaultNodeScale"));
		this->settings->insert("textureFile", appConf->getValue("Viewer.Textures.Node"));
        this->settings->insert("color.R", "1");
        this->settings->insert("color.G", "1");
        this->settings->insert("color.B", "1");
		this->settings->insert("color.A", "1");
     } 
	else 
		this->settings = settings;

	loadConfig();
}
Esempio n. 2
0
AppCore::Core::Core( QApplication* app )
{
	//Application initialization
	core = this;

	Util::ApplicationConfig* appConf = Util::ApplicationConfig::get();

	messageWindows = new QOSG::MessageWindows();

	//Counting forces for layout algorithm, init layout, viewer and window
	this->alg = new Layout::FRAlgorithm();

	this->thr = new Layout::LayoutThread( this->alg );
	this->cg = new Vwr::CoreGraph();
	this->cw = new QOSG::CoreWindow( 0, this->cg, app, this->thr );

	int width =appConf->getValue( "UI.MainWindow.DefaultWidth" ).toInt();
	int height= appConf->getValue( "UI.MainWindow.DefaultHeight" ).toInt();

	if( appConf->getValue( "Viewer.Display.Multiview" ).toInt() )
	{
		int screenNum = appConf->getValue( "Viewer.Display.ScreenNum" ).toInt();
		width = appConf->getValue( "Viewer.Display.MaxScreenWidth" ).toInt() * screenNum;
		height = appConf->getValue( "Viewer.Display.MaxScreenHeight" ).toInt();
	}



	this->cw->resize( width, height );
	this->cw->show();

	app->exec();
}
Esempio n. 3
0
osg::TextureCubeMap* SkyBox::readCubeMap()
{
	osg::TextureCubeMap* cubemap = new osg::TextureCubeMap;
	try{
		Util::ApplicationConfig* appConf = Util::ApplicationConfig::get();
		osg::Image* imageEast = osgDB::readImageFile(appConf->getValue("Viewer.SkyBox.East").toStdString());
		osg::Image* imageWest = osgDB::readImageFile(appConf->getValue("Viewer.SkyBox.West").toStdString());
		osg::Image* imageNorth = osgDB::readImageFile(appConf->getValue("Viewer.SkyBox.North").toStdString());
		osg::Image* imageSouth = osgDB::readImageFile(appConf->getValue("Viewer.SkyBox.South").toStdString());
		osg::Image* imageUp = osgDB::readImageFile(appConf->getValue("Viewer.SkyBox.Up").toStdString());
		osg::Image* imageDown = osgDB::readImageFile(appConf->getValue("Viewer.SkyBox.Down").toStdString());

		if (imageWest && imageEast && imageDown && imageUp && imageSouth && imageNorth)
		{
			cubemap->setImage(osg::TextureCubeMap::POSITIVE_X, imageWest);
			cubemap->setImage(osg::TextureCubeMap::NEGATIVE_X, imageEast);
			cubemap->setImage(osg::TextureCubeMap::POSITIVE_Y, imageDown);
			cubemap->setImage(osg::TextureCubeMap::NEGATIVE_Y, imageUp);
			cubemap->setImage(osg::TextureCubeMap::POSITIVE_Z, imageSouth);
			cubemap->setImage(osg::TextureCubeMap::NEGATIVE_Z, imageNorth);

			cubemap->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
			cubemap->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
			cubemap->setWrap(osg::Texture::WRAP_R, osg::Texture::CLAMP_TO_EDGE);

			cubemap->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LINEAR);
			cubemap->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
		}

	}
	catch(std::exception & e)
	{
		qDebug() << "Skybox error" << e.what();
	}
	return cubemap;
}
Esempio n. 4
0
bool PickHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
	switch( ea.getEventType() )
	{
	case osgGA::GUIEventAdapter::PUSH:
	{
		//vynulovanie premennej pre ulozenie release eventu
		eaRel = NULL;
		// ak dojde push a nie je zapnuty timer tak spusti sa timer a ulozia eventy
		if (!timer->isActive())
		{
			Util::ApplicationConfig * appConf = Util::ApplicationConfig::get();
			timer->start(appConf->getValue("Mouse.DoubleClickTime").toInt());
			eaPush = &ea;
			aaPush = &aa;
			return false;
		}
		return handlePush(ea, aa);
	}
	case osgGA::GUIEventAdapter::DOUBLECLICK:
	{
		//ak dosiel double click tak vypnut timer
		timer->stop();
		eaRel = NULL;
		return handleDoubleclick(ea, aa);
	}
	case osgGA::GUIEventAdapter::MOVE:
	{
		return handleMove(ea, aa);
	}
	case osgGA::GUIEventAdapter::DRAG:
	{
		Network::Client * client = Network::Client::getInstance();
		if (client->isConnected()){
			client -> sendMovedNodesPosition();
		}
		//ak je drag a ide timer tak vypnut timer a vyvolat push
		//zaruci sa tak spravne spracovany drag
		if (timer->isActive())
		{
			timer->stop();
			handlePush(*eaPush, *aaPush);
		}
		//uz kvoli dalsiemu pokracovaniu dragu
		return handleDrag(ea, aa);
	}
	case osgGA::GUIEventAdapter::RELEASE:
	{
		Network::Server * server = Network::Server::getInstance();
		if (server->isListening()) {
			server -> sendMoveNodes();
		}
		//ak je release a je timer aktivny tak sa ulozi event a nevyvola sa
		if (timer->isActive())
		{
			eaRel = &ea;
			aaRel = &aa;
			return false;
		}
		return handleRelease(ea, aa);
	}
	case osgGA::GUIEventAdapter::KEYDOWN:
	{
		return handleKeyDown(ea, aa);
	}
	case::osgGA::GUIEventAdapter::KEYUP:
	{
		return handleKeyUp(ea, aa);
	}
	default:

		return false;
	}
}
Esempio n. 5
0
void GraphMetrics::computeGraphMetrics( Data::Graph* activeGraph )
{
	QMutableMapIterator<qlonglong, osg::ref_ptr<Data::Node> > i( *activeGraph->getNodes() );

	int numVertices = activeGraph->getNodes()->size();
	QVector<QLinkedList<osg::ref_ptr<Data::Node> > >**   paths;

	paths = new QVector<QLinkedList<osg::ref_ptr<Data::Node> > >* [numVertices]();

	int idx = 0;

	Util::ApplicationConfig* appConf = Util::ApplicationConfig::get();
	QString regexp = appConf->getValue( "Graph.Metrics.Regexp" );

	QRegExp re( regexp );
	re.setPatternSyntax( QRegExp::Wildcard );

	// compute metrics for all nodes in graph
	while ( i.hasNext() ) {
		i.next();

		// compute node degree

		float nodeDegree = static_cast<float>( i.value()->getEdges()->size() ) / static_cast<float>( numVertices - 1 );
		i.value()->setNodeDegree( nodeDegree );

		// get all shortest paths
		DjikstraAlg* alg = new DjikstraAlg( activeGraph );
		QMap<qlonglong, qlonglong> shortestPaths = alg->execute( i.value() );

		QMutableMapIterator<qlonglong, qlonglong> i2( shortestPaths );

		paths[idx] = new QVector<QLinkedList<osg::ref_ptr<Data::Node> > > [numVertices];

		// compute node closeness
		qlonglong pathSum = 0;
		while ( i2.hasNext() ) {
			i2.next();
			pathSum += i2.value();
		}

		if ( numVertices == 1 ) {
			numVertices = 2;
		}

		i.value()->setNodeCloseness( static_cast<float>( pathSum ) / static_cast<float>( numVertices - 1 ) );

		// check for regexp match
		if ( re.exactMatch( ( ( Data::AbsNode* )i.value() )->getName() ) ) {
			i.value()->setNodeMatched( true );
		}

		int idx2 = 0;

		// get shortest paths to all nodes for node betweenness
		QMutableMapIterator<qlonglong, osg::ref_ptr<Data::Node> > i3( *activeGraph->getNodes() );
		while ( i3.hasNext() ) {
			i3.next();
			paths[idx][idx2++] = alg->getAllPaths( i3.value() );
		}

		idx++;
	}

	i.toFront();
	float nodeDegreeWeigth = appConf->getValue( "Graph.Metrics.NodeDegreeWeigth" ).toFloat();
	float betweennessWeigth = appConf->getValue( "Graph.Metrics.BetweennessWeigth" ).toFloat();
	float closenessWeigth = appConf->getValue( "Graph.Metrics.ClosenessWeigth" ).toFloat();
	float regexpWeigth = appConf->getValue( "Graph.Metrics.RgexpWeigth" ).toFloat();

	// iterate through all nodes
	while ( i.hasNext() ) {

		i.next();
		float sum = 0;

		// compute node betweenness
		for ( int x = 0; x < numVertices; x++ ) {
			for ( int y = 0; y < numVertices; y++ ) {
				int cnt = 0;

				for ( int z = 0; z < paths[x][y].size(); z++ ) {
					if ( paths[x][y].at( z ).contains( i.value() ) ) {
						cnt++;
					}
				}

				if ( cnt != 0 ) {
					sum += static_cast<float>( cnt ) / static_cast<float>( paths[x][y].size() );
				}
			}
		}

		i.value()->setNodeBetweeness( sum / ( static_cast<float>( numVertices - 1 ) * static_cast<float>( numVertices - 2 ) )	);

		float base = i.value()->isNodeMatched() ? regexpWeigth : 0;

		// compute overall node metric
		float overallWeight = nodeDegreeWeigth * i.value()->getNodeDegree() + closenessWeigth * i.value()->getNodeCloseness() + betweennessWeigth * i.value()->getNodeBetweeness() + base;

		i.value()->setOverallWeight( overallWeight );
	}
}
Esempio n. 6
0
bool GraphMLImporter::import(
	ImporterContext& context
)
{
	// context
	context_ = &context;
	// helpers
	graphOp_.reset( new GraphOperations( context_->getGraph() ) );
	readNodes_.reset( new ReadNodesStore() );

	// default types
	edgeType_ = NULL;
	nodeType_ = NULL;
	( void )graphOp_->addDefaultTypes( edgeType_, nodeType_ );

	// ziskame pristup ku nastaveniam
	Util::ApplicationConfig* appConf = Util::ApplicationConfig::get();
	edgeTypeAttribute_ = appConf->getValue( "GraphMLParser.edgeTypeAttribute" );
	nodeTypeAttribute_ = appConf->getValue( "GraphMLParser.nodeTypeAttribute" );

	// pole farieb FIXME oddelit farby hran od farieb uzlov
	colors_.push_back( ColorType( 0, 1, 0, 1 ) );
	colors_.push_back( ColorType( 0, 1, 1, 1 ) );
	colors_.push_back( ColorType( 1, 0, 0, 1 ) );
	colors_.push_back( ColorType( 1, 0, 1, 1 ) );
	colors_.push_back( ColorType( 1, 1, 0, 1 ) );
	colors_.push_back( ColorType( 1, 1, 1, 1 ) );

	iColor_ = 0;

	bool ok = true;

	// ziskame graph element
	QDomElement graphElement;
	if ( ok ) {
		QDomNode graphNode;

		QDomDocument doc( "graphMLDocument" );
		if ( doc.setContent( &( context_->getStream() ) ) ) {
			QDomElement docElem = doc.documentElement();
			if ( !docElem.isNull() && docElem.nodeName() == "graphml" ) {
				QDomNodeList graphNodes = docElem.elementsByTagName( "graph" );
				if ( graphNodes.length() > 0 ) {
					graphNode = graphNodes.item( 0 );
					if ( !graphNode.isNull() && graphNode.parentNode() == docElem && graphNode.isElement() ) {
						graphElement = graphNode.toElement();
					}
				}
			}
		}

		ok = !graphElement.isNull();

		context_->getInfoHandler().reportError( ok, "Zvoleny subor nie je validny GraphML subor." );
	}

	if ( ok ) {
		// for progress reporting
		entitiesProcessed_ = 0;
		entitiesCount_ = graphElement.elementsByTagName( "node" ).size() + graphElement.elementsByTagName( "edge" ).count();
	}

	if ( ok ) {
		ok = processGraph( graphElement );
	}

	return ok;
}