コード例 #1
1
ファイル: MainFrame.cpp プロジェクト: Thales1330/PSP
void MainFrame::OnAddElementsClick(wxCommandEvent& event)
{
    Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());

    if(workspace) {
        if(workspace->GetWorkspaceMode() != Workspace::MODE_INSERT) {
            auto elementList = workspace->GetElementList();
            wxString statusBarText = "";
            bool newElement = false;

            switch(event.GetId()) {
                case ID_ADDMENU_BUS: {
                    Bus* newBus = new Bus(wxPoint2DDouble(0, 0),
                                          wxString::Format(_("Bus %d"), workspace->GetElementNumber(ID_BUS)));
                    workspace->IncrementElementNumber(ID_BUS);
                    elementList.push_back(newBus);
                    statusBarText = _("Insert Bus: Click to insert, ESC to cancel.");
                    newElement = true;
                } break;
                case ID_ADDMENU_LINE: {
                    Line* newLine = new Line(wxString::Format(_("Line %d"), workspace->GetElementNumber(ID_LINE)));
                    elementList.push_back(newLine);
                    workspace->IncrementElementNumber(ID_LINE);
                    statusBarText = _("Insert Line: Click on two buses, ESC to cancel.");
                    newElement = true;
                } break;
                case ID_ADDMENU_TRANSFORMER: {
                    Transformer* newTransformer = new Transformer(
                        wxString::Format(_("Transformer %d"), workspace->GetElementNumber(ID_TRANSFORMER)));
                    workspace->IncrementElementNumber(ID_TRANSFORMER);
                    elementList.push_back(newTransformer);
                    statusBarText = _("Insert Transformer: Click on two buses, ESC to cancel.");
                    newElement = true;
                } break;
                case ID_ADDMENU_GENERATOR: {
                    SyncGenerator* newGenerator = new SyncGenerator(
                        wxString::Format(_("Generator %d"), workspace->GetElementNumber(ID_SYNCGENERATOR)));
                    workspace->IncrementElementNumber(ID_SYNCGENERATOR);
                    elementList.push_back(newGenerator);
                    statusBarText = _("Insert Generator: Click on a buses, ESC to cancel.");
                    newElement = true;
                } break;
                case ID_ADDMENU_LOAD: {
                    Load* newLoad = new Load(wxString::Format(_("Load %d"), workspace->GetElementNumber(ID_LOAD)));
                    workspace->IncrementElementNumber(ID_LOAD);
                    elementList.push_back(newLoad);
                    statusBarText = _("Insert Load: Click on a buses, ESC to cancel.");
                    newElement = true;
                } break;
                case ID_ADDMENU_CAPACITOR: {
                    Capacitor* newCapacitor =
                        new Capacitor(wxString::Format(_("Capacitor %d"), workspace->GetElementNumber(ID_CAPACITOR)));
                    workspace->IncrementElementNumber(ID_CAPACITOR);
                    elementList.push_back(newCapacitor);
                    statusBarText = _("Insert Capacitor: Click on a buses, ESC to cancel.");
                    newElement = true;
                } break;
                case ID_ADDMENU_INDUCTOR: {
                    Inductor* newInductor =
                        new Inductor(wxString::Format(_("Inductor %d"), workspace->GetElementNumber(ID_INDUCTOR)));
                    workspace->IncrementElementNumber(ID_INDUCTOR);
                    elementList.push_back(newInductor);
                    statusBarText = _("Insert Inductor: Click on a buses, ESC to cancel.");
                    newElement = true;
                } break;
                case ID_ADDMENU_INDMOTOR: {
                    IndMotor* newIndMotor = new IndMotor(
                        wxString::Format(_("Induction motor %d"), workspace->GetElementNumber(ID_INDMOTOR)));
                    workspace->IncrementElementNumber(ID_INDMOTOR);
                    elementList.push_back(newIndMotor);
                    statusBarText = _("Insert Induction Motor: Click on a buses, ESC to cancel.");
                    newElement = true;
                } break;
                case ID_ADDMENU_SYNCCOMP: {
                    SyncMotor* newSyncCondenser = new SyncMotor(
                        wxString::Format(_("Synchronous condenser %d"), workspace->GetElementNumber(ID_SYNCMOTOR)));
                    workspace->IncrementElementNumber(ID_SYNCMOTOR);
                    elementList.push_back(newSyncCondenser);
                    statusBarText = _("Insert Synchronous Condenser: Click on a buses, ESC to cancel.");
                    newElement = true;
                } break;
            }
            if(newElement) {
                workspace->SetElementList(elementList);
                workspace->SetWorkspaceMode(Workspace::MODE_INSERT);
                workspace->SetStatusBarText(statusBarText);
                workspace->Redraw();
            }
        }
    }
}
コード例 #2
0
ファイル: MainFrame.cpp プロジェクト: Thales1330/PSP
MainFrame::MainFrame(wxWindow* parent, wxLocale* locale, PropertiesData* initProperties, wxString openPath)
    : MainFrameBase(parent)
{
    m_locale = locale;
    m_generalProperties = initProperties;

    Init();

    if(openPath != "") {
        EnableCurrentProjectRibbon();
        Workspace* newWorkspace = new Workspace(this, _("Open project"), this->GetStatusBar(), m_sharedGLContext);
        if(!m_sharedGLContext) m_sharedGLContext = newWorkspace->GetOpenGLContext();

        FileHanding fileHandling(newWorkspace);
        if(fileHandling.OpenProject(openPath)) {
            newWorkspace->SetSavedPath(openPath);

            m_workspaceList.push_back(newWorkspace);

            m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_DISABLESOL, true);
            m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_ENABLESOL, false);

            m_auiNotebook->AddPage(newWorkspace, newWorkspace->GetName(), true);
            m_auiNotebook->Layout();
            newWorkspace->Redraw();
            newWorkspace->SetJustOpened(true);
            newWorkspace->Fit();
            m_projectNumber++;
        }
    }
}
コード例 #3
0
ファイル: MainFrame.cpp プロジェクト: Thales1330/PSP
void MainFrame::OnOpenClick(wxRibbonButtonBarEvent& event)
{
    wxFileDialog openFileDialog(this, _("Open PSP file"), "", "", "PSP files (*.psp)|*.psp",
                                wxFD_OPEN | wxFD_FILE_MUST_EXIST);
    if(openFileDialog.ShowModal() == wxID_CANCEL) return;

    wxFileName fileName(openFileDialog.GetPath());

    EnableCurrentProjectRibbon();
    Workspace* newWorkspace = new Workspace(this, _("Open project"), this->GetStatusBar(), m_sharedGLContext);
    if(!m_sharedGLContext) m_sharedGLContext = newWorkspace->GetOpenGLContext();

    FileHanding fileHandling(newWorkspace);
    if(fileHandling.OpenProject(fileName)) {
        newWorkspace->SetSavedPath(fileName);

        m_workspaceList.push_back(newWorkspace);

        m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_DISABLESOL, true);
        m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_ENABLESOL, false);

        m_auiNotebook->AddPage(newWorkspace, newWorkspace->GetName(), true);
        m_auiNotebook->Layout();
        newWorkspace->Redraw();
        newWorkspace->SetJustOpened(true);
        newWorkspace->Fit();
        m_projectNumber++;
    } else {
        wxMessageDialog msgDialog(this, _("It was not possible to open the selected file."), _("Error"),
                                  wxOK | wxCENTRE | wxICON_ERROR);
        msgDialog.ShowModal();
        delete newWorkspace;
    }
}
コード例 #4
0
ファイル: MainFrame.cpp プロジェクト: Thales1330/PSP
void MainFrame::OnNewClick(wxRibbonButtonBarEvent& event)
{
    EnableCurrentProjectRibbon();

    Workspace* newWorkspace = new Workspace(this, wxString::Format(_("New project %d"), m_projectNumber),
                                            this->GetStatusBar(), m_sharedGLContext);
    if(!m_sharedGLContext) m_sharedGLContext = newWorkspace->GetOpenGLContext();
    m_workspaceList.push_back(newWorkspace);

    m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_DISABLESOL, true);
    m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_ENABLESOL, false);

    m_auiNotebook->AddPage(newWorkspace, newWorkspace->GetName(), true);
    newWorkspace->Redraw();
    m_projectNumber++;
}
コード例 #5
0
ファイル: MainFrame.cpp プロジェクト: Thales1330/PSP
void MainFrame::OnImportClick(wxRibbonButtonBarEvent& event)
{
    // Create a new workspace to import
    Workspace* impWorkspace = new Workspace(this, _("Imported project"), this->GetStatusBar(), m_sharedGLContext);
    ImportForm importForm(this, impWorkspace);
    if(importForm.ShowModal() == wxID_OK) {
        // Import file(s)
        EnableCurrentProjectRibbon();

        if(!m_sharedGLContext) m_sharedGLContext = impWorkspace->GetOpenGLContext();
        m_workspaceList.push_back(impWorkspace);

        m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_DISABLESOL, true);
        m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_ENABLESOL, false);

        m_auiNotebook->AddPage(impWorkspace, impWorkspace->GetName(), true);
        m_auiNotebook->Layout();
        impWorkspace->Redraw();
        impWorkspace->SetJustOpened(true);
        impWorkspace->Fit();
        m_projectNumber++;
    }
}