Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • adfc2e5
  • /
  • topo-blend
  • /
  • graphs-manager.cpp
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge Iframe embedding
swh:1:cnt:4bbbced5de609757d99bee90e043483c3e1074b4
directory badge Iframe embedding
swh:1:dir:4cd23d1e54634cfb4ba85fc907bddef6128f3245

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
graphs-manager.cpp
#include <QFileDialog>
#include "GraphModifyWidget.h"
#include "QuickAlignment.h"

#include "TopoBlender.h"
#include "GraphCorresponder.h"
#include "Scheduler.h"

#include "graphs-manager.h"
#include "SynthesisManager.h"

void GraphsManager::loadModel()
{
    QStringList fileNames = QFileDialog::getOpenFileNames(0, "Open Model",
        tb->mainWindow()->settings()->getString("lastUsedDirectory"), "Model Files (*.xml)");
    if(fileNames.isEmpty()) return;

    // Keep folder active
    QFileInfo fileInfo(fileNames.front());
    tb->mainWindow()->settings()->set( "lastUsedDirectory", fileInfo.absolutePath() );

    foreach(QString file, fileNames)
    {
        tb->graphs.push_back( new Structure::Graph ( file ) );
    }

    tb->mainWindow()->setStatusBarMessage( "Loaded: \n" + fileNames.join("\n") );

    tb->setSceneBounds();
}

void GraphsManager::saveModel()
{
    if (tb->graphs.size() < 1){
        qDebug() << "Please load a graph.";
        return;
    }

    foreach(Structure::Graph * g, tb->graphs)
        g->setColorAll(Qt::lightGray);

    foreach(Structure::Graph * g, tb->graphs)
    {
        // Highlight selected graph
        g->setColorAll(Qt::yellow);
        tb->drawArea()->updateGL();

        QString filename = QFileDialog::getSaveFileName(0, "Save Model",
            g->property["name"].toString(), "Model Files (*.xml)");

        // Un-highlight
        g->setColorAll(Qt::lightGray);

        if(filename.isEmpty()) 	continue;

        g->saveToFile(filename);
    }
}

void GraphsManager::modifyModel()
{
    if (tb->graphs.size() < 1){
        qDebug() << "Please load a graph";
        return;
    }

    tb->widget->setCheckOption("showEdges");

    tb->viz_params["showNames"] = true;

    GraphModifyWidget modifyDialog(tb->graphs.back());
    tb->drawArea()->connect(&modifyDialog, SIGNAL(updateView()), SLOT(updateGL()));
    modifyDialog.exec();
}

void GraphsManager::quickAlign()
{
    if (tb->graphs.size() < 1){
        qDebug() << "Please load a graph";
        return;
    }

    QuickAlignment alignmentDialog(tb->graphs[0], tb->graphs[1]);
    tb->drawArea()->connect(&alignmentDialog, SIGNAL(updateView()), SLOT(updateGL()));
    alignmentDialog.exec();
}

void GraphsManager::normalizeAllGraphs()
{
    foreach (Structure::Graph* g, tb->graphs)
    {
        g->moveBottomCenterToOrigin();
        g->normalize();
    }

    tb->drawArea()->updateGL();
}

void GraphsManager::clearGraphs()
{
	// Clear any synthesis data
	tb->s_manager->clear();

    // UI and geometry clean up
    Scheduler * scheduler = tb->scheduler;
    if(scheduler)
    {
        scheduler->activeGraph->clearAll();
        scheduler->targetGraph->clearAll();

        // Remove old signals
        scheduler->disconnect(tb);
        tb->disconnect(scheduler);

        scheduler->dock->close();
    }

	// Delete corresponder, blender, and scheduler
	if(tb->gcoor) delete tb->gcoor;
	if(tb->blender) delete tb->blender;
	if(tb->scheduler) delete tb->scheduler;

	// Delete all graphs
	if(tb->graphs.size() > 1) qDeleteAll(tb->graphs);
	tb->graphs.clear();

	tb->gcoor = NULL;
	tb->blender = NULL;
	tb->scheduler = NULL;

    // Clear debug
    tb->debugPoints.clear(); tb->debugPoints2.clear();

    tb->updateDrawArea();
}

back to top

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API