Ejemplo 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();
}
Ejemplo n.º 2
0
void OptionsWindow::commitChanges()
{

	Util::ApplicationConfig* appConf = Util::ApplicationConfig::get();
	QString str;
	// ulozenie dat aktivnej polozky do struktury
	selectedItem->replaceDataColumn( getModelData() );
	//spustenie prehladavania stromu
	treeSearch( treeModel->getRootItem(),str );

	//ak je otvoreny graf tak sa ulozia aj zmeny urobene v typoch grafu
	if ( Manager::GraphManager::getInstance()->getActiveGraph() != NULL ) {
		saveNodeTypes( treeModel->getRootItem() );
	}

	//ulozenie celych nastaveni
	appConf->saveConfig();

	//reloadovanie nastaveni v ostatnych castiach aplikacie
	Layout::LayoutThread* thr = AppCore::Core::getInstance()->getLayoutThread();

	bool running = thr->isRunning();

	if ( running ) {
		thr->pauseAllAlg();
	}

	viewer->reloadConfig();
	cg->reloadConfig();

	if ( running ) {
		thr->play();
	}

}
Ejemplo n.º 3
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);
    this->cw->resize(
    	appConf->getNumericValue (
    		"UI.MainWindow.DefaultWidth",
    		std::auto_ptr<long> (new long(200)),
    		std::auto_ptr<long> (NULL),
    		1024
    	),
    	appConf->getNumericValue (
			"UI.MainWindow.DefaultHeight",
			std::auto_ptr<long> (new long(200)),
			std::auto_ptr<long> (NULL),
			768
		)
    );
    this->cw->show();

    app->exec();
}
Ejemplo n.º 4
0
OptionsWindow::OptionsWindow( Vwr::CoreGraph* cg, QOSG::ViewerQT* viewer )
{
	//vytvorenie a inicializovanie celeho okna
	this->viewer = viewer;
	this->cg = cg;

	setModal( true );
	resize( 600,250 );

	changes = new QList<QString>();
	selectedItem = NULL;

	Util::ApplicationConfig* appConf = Util::ApplicationConfig::get();
	treeModel = new TreeModel( appConf->getList() );

	QTreeView* treeView = new QTreeView();
	treeView->setFocusPolicy( Qt::NoFocus );
	treeView->setModel( treeModel );
	treeView->setHeaderHidden( true );

	connect( treeView,SIGNAL( clicked( QModelIndex ) ),this,SLOT( itemClicked( QModelIndex ) ) );

	view = new QTreeView();
	view->setFocusPolicy( Qt::NoFocus );
	view->setVisible( false );

	QPushButton* closeButton = new QPushButton( tr( "Close" ) );
	closeButton->setFocusPolicy( Qt::NoFocus );
	connect( closeButton, SIGNAL( clicked() ), this, SLOT( close() ) );

	applyButton= new QPushButton( tr( "Apply" ) );
	applyButton->setFocusPolicy( Qt::NoFocus );
	applyButton->setEnabled( false );
	connect( applyButton, SIGNAL( clicked() ), this, SLOT( commitChanges() ) );

	QHBoxLayout* horizontalLayout = new QHBoxLayout;
	horizontalLayout->addWidget( treeView );
	horizontalLayout->addWidget( view );

	QHBoxLayout* buttonsLayout = new QHBoxLayout;
	buttonsLayout->addStretch( 1 );
	buttonsLayout->addWidget( applyButton );
	buttonsLayout->addWidget( closeButton );

	QVBoxLayout* mainLayout = new QVBoxLayout;
	mainLayout->addLayout( horizontalLayout );
	mainLayout->addStretch( 1 );
	mainLayout->addSpacing( 12 );
	mainLayout->addLayout( buttonsLayout );

	setLayout( mainLayout );

	setWindowTitle( tr( "Config Dialog" ) );
}
Ejemplo n.º 5
0
void OptionsWindow::applyChanges( QString path, QString data )
{
	//ziskanie odkazu na konfigurak
	Util::ApplicationConfig* appConf = Util::ApplicationConfig::get();

	//rozdelenie dat
	QList<QString> list = data.split( ";" );
	//postupne ukladanie dat
	for ( int i=0; i< list.length(); i++ ) {
		QList<QString> att = list[i].split( "," );

		appConf->add( QString( "%1%2" ).arg( path ).arg( att[0] ),att[1] );
		std::cout <<path.toStdString()<< att[0].toStdString() << "\t" << att[1].toStdString() << endl;
	}

}
Ejemplo n.º 6
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();
}
Ejemplo n.º 7
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;
}
Ejemplo n.º 8
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;
	}
}
Ejemplo n.º 9
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 );
	}
}
Ejemplo n.º 10
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;
}