Beispiel #1
0
// postprocessormode(mode = {"point", "surface", "volume"})
void pythonPostprocessorMode(char *str)
{
    logMessage("pythonPostprocessorMode()");

    if (Util::scene()->sceneSolution()->isSolved())
        sceneView()->actSceneModePostprocessor->trigger();
    else
        throw invalid_argument(QObject::tr("Problem is not solved.").toStdString());

    if (QString(str) == "point")
        sceneView()->actPostprocessorModeLocalPointValue->trigger();
    else if (QString(str) == "surface")
        sceneView()->actPostprocessorModeSurfaceIntegral->trigger();
    else if (QString(str) == "volume")
        sceneView()->actPostprocessorModeVolumeIntegral->trigger();
    else
        throw invalid_argument(QObject::tr("Postprocessor mode '%1' is not implemented.").arg(QString(str)).toStdString());

    sceneView()->doInvalidated();
}
Beispiel #2
0
// mode(mode = {"node", "edge", "label", "postprocessor"})
void pythonMode(char *str)
{
    logMessage("pythonMode()");

    if (QString(str) == "node")
        sceneView()->actSceneModeNode->trigger();
    else if (QString(str) == "edge")
        sceneView()->actSceneModeEdge->trigger();
    else if (QString(str) == "label")
        sceneView()->actSceneModeLabel->trigger();
    else if (QString(str) == "postprocessor")
        if (Util::scene()->sceneSolution()->isSolved())
            sceneView()->actSceneModePostprocessor->trigger();
        else
            throw invalid_argument(QObject::tr("Problem is not solved.").toStdString());
    else
        throw invalid_argument(QObject::tr("Mode '%1' is not implemented.").arg(QString(str)).toStdString());

    sceneView()->doInvalidated();
}
Beispiel #3
0
int main(int argc, char **argv)
{
	QApplication app(argc, argv);

	QWidget window;

	QTextEdit editor;
	QFile mainFile("./main.rb");
	mainFile.open(QIODevice::ReadOnly | QIODevice::Text);
	editor.setPlainText(mainFile.readAll());

	Runner runner;

	MyPushButton helloButton(runner, "Run", editor);
	helloButton.resize(100, 30);
	MyPushButton::connect(&helloButton, SIGNAL (clicked()), &helloButton, SLOT (handleClicked()));

	QPushButton stopButton("Stop");
	stopButton.resize(100, 30);
	QPushButton::connect(&stopButton, SIGNAL (clicked()), &runner, SLOT (Stop()));

	QHBoxLayout mainLayout;

	QVBoxLayout editorLayout;
	editorLayout.addWidget(&editor);
	editorLayout.addWidget(&helloButton);
	editorLayout.addWidget(&stopButton);

	QGraphicsScene scene(0, 0, 600, 600);

	Drawing::Init(&scene);

	QGraphicsView sceneView(&scene);
	sceneView.setMinimumSize(610, 610);

	mainLayout.addLayout(&editorLayout);
	mainLayout.addWidget(&sceneView);

	window.setLayout(&mainLayout);
	window.show();

	return app.exec();
}
Beispiel #4
0
// zoombestfit()
void pythonZoomBestFit()
{
    logMessage("pythonZoomBestFit()");

    sceneView()->doZoomBestFit();
}
Beispiel #5
0
// newdocument(name, type, physicfield, numberofrefinements, polynomialorder, adaptivitytype, adaptivitysteps, adaptivitytolerance, frequency, analysistype, timestep, totaltime, initialcondition)
void pythonNewDocument(char *name, char *type, char *physicfield,
                       int numberofrefinements, int polynomialorder, char *adaptivitytype,
                       double adaptivitysteps, double adaptivitytolerance,
                       double frequency,
                       char *analysistype, double timestep, double totaltime, double initialcondition)
{
    logMessage("pythonNewDocument()");

    Util::scene()->clear();
    Util::scene()->problemInfo()->name = QString(name);

    // type
    Util::scene()->problemInfo()->problemType = problemTypeFromStringKey(QString(type));
    if (Util::scene()->problemInfo()->problemType == ProblemType_Undefined)
        throw invalid_argument(QObject::tr("Problem type '%1' is not implemented.").arg(QString(type)).toStdString());

    // physicfield
    PhysicField physicField = physicFieldFromStringKey(QString(physicfield));
    if (physicField != PhysicField_Undefined)
        Util::scene()->problemInfo()->setHermes(hermesFieldFactory(physicField));
    else
        throw invalid_argument(QObject::tr("Physic field '%1' is not implemented.").arg(QString(physicfield)).toStdString());

    // numberofrefinements
    if (numberofrefinements >= 0)
        Util::scene()->problemInfo()->numberOfRefinements = numberofrefinements;
    else
        throw out_of_range(QObject::tr("Number of refinements '%1' is out of range.").arg(numberofrefinements).toStdString());

    // polynomialorder
    if (polynomialorder >= 1 && polynomialorder <= 10)
        Util::scene()->problemInfo()->polynomialOrder = polynomialorder;
    else
        throw out_of_range(QObject::tr("Polynomial order '%1' is out of range.").arg(polynomialorder).toStdString());

    // adaptivitytype
    Util::scene()->problemInfo()->adaptivityType = adaptivityTypeFromStringKey(QString(adaptivitytype));
    if (Util::scene()->problemInfo()->adaptivityType == AdaptivityType_Undefined)
        throw invalid_argument(QObject::tr("Adaptivity type '%1' is not implemented.").arg(QString(adaptivitytype)).toStdString());

    // adaptivitysteps
    if (adaptivitysteps >= 0)
        Util::scene()->problemInfo()->adaptivitySteps = adaptivitysteps;
    else
        throw out_of_range(QObject::tr("Adaptivity step '%1' is out of range.").arg(adaptivitysteps).toStdString());

    // adaptivitytolerance
    if (adaptivitytolerance >= 0)
        Util::scene()->problemInfo()->adaptivityTolerance = adaptivitytolerance;
    else
        throw out_of_range(QObject::tr("Adaptivity tolerance '%1' is out of range.").arg(adaptivitytolerance).toStdString());

    // frequency
    if (Util::scene()->problemInfo()->hermes()->hasHarmonic())
    {
        if (frequency >= 0)
            Util::scene()->problemInfo()->frequency = frequency;
        else
            throw invalid_argument(QObject::tr("The frequency can not be used for this problem.").toStdString());
    }

    // analysis type
    Util::scene()->problemInfo()->analysisType = analysisTypeFromStringKey(QString(analysistype));
    if (Util::scene()->problemInfo()->analysisType == AnalysisType_Undefined)
        throw invalid_argument(QObject::tr("Analysis type '%1' is not implemented").arg(QString(adaptivitytype)).toStdString());

    // analysis type
    Util::scene()->problemInfo()->analysisType = analysisTypeFromStringKey(QString(analysistype));
    if (Util::scene()->problemInfo()->analysisType == AnalysisType_Undefined)
        throw invalid_argument(QObject::tr("Analysis type '%1' is not implemented").arg(QString(adaptivitytype)).toStdString());

    // transient timestep
    if (timestep > 0)
        Util::scene()->problemInfo()->timeStep = Value(QString::number(timestep));
    else if (Util::scene()->problemInfo()->analysisType == AnalysisType_Transient)
        throw out_of_range(QObject::tr("Time step must be positive.").toStdString());

    // transient timetotal
    if (totaltime > 0)
        Util::scene()->problemInfo()->timeTotal = Value(QString::number(totaltime));
    else if (Util::scene()->problemInfo()->analysisType == AnalysisType_Transient)
        throw out_of_range(QObject::tr("Total time must be positive.").toStdString());

    // transient initial condition
    Util::scene()->problemInfo()->initialCondition = Value(QString::number(initialcondition));

    // invalidate
    sceneView()->doDefaultValues();
    Util::scene()->refresh();
}
Beispiel #6
0
// zoomregion(x1, y1, x2, y2)
void pythonZoomRegion(double x1, double y1, double x2, double y2)
{
    logMessage("pythonZoomRegion()");

    sceneView()->doZoomRegion(Point(x1, y1), Point(x2, y2));
}
Beispiel #7
0
// zoomin()
void pythonZoomIn()
{
    logMessage("pythonZoomIn()");

    sceneView()->doZoomIn();
}
void ViewSceneScreen::LoadResources()
{
    BaseScreen::LoadResources();
 
    ScopedPtr<Scene> scene(new Scene());
    Entity *entity = scene->GetRootNode(GameCore::Instance()->GetScenePath());
    scene->AddNode(entity);
    scene->ReleaseRootNode(GameCore::Instance()->GetScenePath());
    
    DVASSERT(camera == NULL);
    camera = new Camera();
    
	Core* core = DAVA::Core::Instance();
	float32 aspect = core->GetVirtualScreenHeight() / core->GetVirtualScreenWidth();
    
	camera->SetupPerspective(70.f, aspect, 0.5f, 2500.f);
	camera->SetLeft(Vector3(1, 0, 0));
	camera->SetUp(Vector3(0, 0, 1.f));
    camera->SetTarget(Vector3(0, 0, 0));
    camera->SetPosition(Vector3(0, 0, 100));


    //TODO: debug
    camera->SetPosition(Vector3(18.7855f, 111.0697f, 57.0635f));
    camera->SetDirection(Vector3(-1.2904f, 9.0496f, -4.0545f));
    //ENDOFTODO

    
    scene->AddCamera(camera);
    scene->SetCurrentCamera(camera);
    
    const Rect screenRect = GetRect();
    ScopedPtr<UI3DView> sceneView(new UI3DView(screenRect));
    sceneView->SetScene(scene);
    sceneView->SetInputEnabled(false);
    AddControl(sceneView);
    
    ScopedPtr<UIButton> backButton(CreateButton(Rect(0, 0, 90, 30), L"Back"));
    backButton->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &ViewSceneScreen::OnBack));
    backButton->SetDebugDraw(true);
    AddControl(backButton);
    
    
    const float32 joyPADSize = 100.f;
    
    moveJoyPAD = new UIJoypad(Rect(0, screenRect.dy - joyPADSize, joyPADSize, joyPADSize));
    moveJoyPAD->GetBackground()->SetSprite("~res:/Gfx/Joypad/joypad", 0);
    moveJoyPAD->SetStickSprite("~res:/Gfx/Joypad/joypad", 1);

    AddControl(moveJoyPAD);
    
    viewJoyPAD = new UIJoypad(Rect(screenRect.dx - joyPADSize, screenRect.dy - joyPADSize, joyPADSize, joyPADSize));
    viewJoyPAD->GetBackground()->SetSprite("~res:/Gfx/Joypad/joypad", 0);
    viewJoyPAD->SetStickSprite("~res:/Gfx/Joypad/joypad", 1);
    AddControl(viewJoyPAD);
    
    viewXAngle = 0;
    viewYAngle = 0;
    
    DVASSERT(info == NULL);
    info = new UIStaticText(Rect(0, 0, screenRect.dx, 30.f));
    info->SetFont(font);
    info->SetTextColor(Color::White);
    info->SetTextAlign(ALIGN_VCENTER | ALIGN_RIGHT);
    
    AddControl(info);
}