Example #1
0
void createPGM(){
    char *cropped = strrchr(filename, '/');
    char *namext, *namenoxt;
    if (cropped != NULL) {
        namext = cropped;
        namenoxt = removeFileExt(&namext[1]);
    } else {
        namext = filename;
        namenoxt = removeFileExt(namext);
    }
    
    pgmptr = fopen(strcat(namenoxt, ".pgm"), "w");
    fprintf(pgmptr, "P2 %d %d 255", LINE_HEIGHT, data.chunkSize/(format.sampleRate/PPS));
}
Example #2
0
void GenGraphForm::doBrowse()
{
    QString s = Q3FileDialog::getSaveFileName(
            filename->text(),
            "DOT Graph (*.dot)",
            this,
            "export graph file dialog",
            "Choose a file to save" );
    if (s.length()>0)
    {
        if (removeFileExt(s)==s) // no extension specified
            s += ".dot";
        filename->setText(s);
        change();
    }
}
Example #3
0
void GenGraphForm::doExport()
{
    if (!tasks.empty())
    {
        killAllTasks();
        return;
    }
    if (filename->text()==QString("")) return;

    QString dotfile = filename->text();

    QString basefile = removeFileExt(dotfile);

    if (basefile==dotfile) // no extension specified
        dotfile += ".dot";

    std::ofstream fdot;
    fdot.open(dotfile, std::ofstream::out | std::ofstream::trunc);
    if (!fdot.is_open())
    {
        qFatal("Output to %s failed.\n",(const char*)dotfile);
        return;
    }
    {
        sofa::simulation::tree::ExportDotVisitor act(sofa::core::ExecParams::defaultInstance() /* PARAMS FIRST */, &fdot);
        act.showNode = this->showNodes->isOn();
        act.showObject = this->showObjects->isOn();
        act.showBehaviorModel = this->showBehaviorModels->isOn();
        act.showCollisionModel = this->showCollisionModels->isOn();
        act.showVisualModel = this->showVisualModels->isOn();
        act.showMapping = this->showMappings->isOn();
        act.showContext = this->showContext->isOn();
        act.showCollisionPipeline = this->showCollisionPipeline->isOn();
        act.showSolver = this->showSolvers->isOn();
        act.showMechanicalState = this->showMechanicalStates->isOn();
        act.showForceField = this->showForceFields->isOn();
        act.showInteractionForceField = this->showInteractionForceFields->isOn();
        act.showConstraint = this->showConstraints->isOn();
        act.showMass = this->showMass->isOn();
        act.showTopology = this->showTopology->isOn();
        act.showMechanicalMapping = this->showMechanicalMappings->isOn();
        act.labelNodeName = this->labelNodeName->isOn();
        act.labelNodeClass = this->labelNodeClass->isOn();
        act.labelObjectName = this->labelObjectName->isOn();
        act.labelObjectClass = this->labelObjectClass->isOn();
        graph->executeVisitor(&act);
    }
    fdot.close();

    QStringList argv0;
    if (layoutDirV->isOn())
        argv0 << "dot" << "-Grankdir=TB";
    else if (layoutDirH->isOn())
        argv0 << "dot" << "-Grankdir=LR";
    else if (layoutSpring->isOn())
        argv0 << "neato";
    else if (layoutRadial->isOn())
        argv0 << "twopi";

    bool exp = false;

    exportedFile = dotfile;

    if (genPNG->isOn())
    {
        QStringList argv = argv0;
        argv << "-Tpng" << "-o" << basefile+".png";
        argv << dotfile;
        addTask(argv);
        if (!exp)
        {
            exp = true;
            exportedFile = basefile+".png";
        }
    }

    if (genPS->isOn())
    {
        QStringList argv = argv0;
        argv << "-Tps" << "-o" << basefile+".ps";
        argv << dotfile;
        addTask(argv);
        if (!exp)
        {
            exp = true;
            exportedFile = basefile+".ps";
        }
    }

    if (genFIG->isOn())
    {
        QStringList argv = argv0;
        argv << "-Tfig" << "-o" << basefile+".fig";
        argv << dotfile;
        addTask(argv);
        if (!exp)
        {
            exp = true;
            exportedFile = basefile+".fig";
        }
    }

    if (genSVG->isOn())
    {
        QStringList argv = argv0;
        argv << "-Tsvg" << "-o" << basefile+".svg";
        argv << dotfile;
        addTask(argv);
        if (!exp)
        {
            exp = true;
            exportedFile = basefile+".svg";
        }
    }
    //exported = true;
    //displayButton->setEnabled(true);
}