Skip to content

Commit

Permalink
Better structuring of OMSimulator related files
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Nov 23, 2018
1 parent b0ea5fe commit 0545fc6
Show file tree
Hide file tree
Showing 16 changed files with 902 additions and 704 deletions.
79 changes: 0 additions & 79 deletions OMEdit/OMEditGUI/Annotations/BitmapAnnotation.cpp
Expand Up @@ -248,82 +248,3 @@ void BitmapAnnotation::duplicate()
setSelected(false);
pBitmapAnnotation->setSelected(true);
}

AddOrEditIconDialog::AddOrEditIconDialog(ShapeAnnotation *pShapeAnnotation, GraphicsView *pGraphicsView, QWidget *pParent)
: QDialog(pParent)
{
setAttribute(Qt::WA_DeleteOnClose);
setWindowTitle(QString("%1 - %2 Icon").arg(Helper::applicationName).arg(pShapeAnnotation ? Helper::edit : Helper::add));
setMinimumWidth(400);
mpShapeAnnotation = pShapeAnnotation;
mpGraphicsView = pGraphicsView;
mpFileLabel = new Label(Helper::fileLabel);
mpFileTextBox = new QLineEdit(mpShapeAnnotation ? mpShapeAnnotation->getFileName() : "");
mpFileTextBox->setEnabled(false);
mpBrowseFileButton = new QPushButton(Helper::browse);
connect(mpBrowseFileButton, SIGNAL(clicked()), SLOT(browseImageFile()));
mpPreviewImageLabel = new Label;
mpPreviewImageLabel->setAlignment(Qt::AlignCenter);
if (mpShapeAnnotation) {
mpPreviewImageLabel->setPixmap(QPixmap::fromImage(mpShapeAnnotation->getImage()));
}
mpPreviewImageScrollArea = new QScrollArea;
mpPreviewImageScrollArea->setMinimumSize(400, 150);
mpPreviewImageScrollArea->setWidgetResizable(true);
mpPreviewImageScrollArea->setWidget(mpPreviewImageLabel);
// Create the buttons
mpOkButton = new QPushButton(Helper::ok);
mpOkButton->setAutoDefault(true);
connect(mpOkButton, SIGNAL(clicked()), this, SLOT(addOrEditIcon()));
mpCancelButton = new QPushButton(Helper::cancel);
mpCancelButton->setAutoDefault(false);
connect(mpCancelButton, SIGNAL(clicked()), this, SLOT(reject()));
mpButtonBox = new QDialogButtonBox(Qt::Horizontal);
mpButtonBox->addButton(mpOkButton, QDialogButtonBox::ActionRole);
mpButtonBox->addButton(mpCancelButton, QDialogButtonBox::ActionRole);
// set the layput
QGridLayout *pMainLayout = new QGridLayout;
pMainLayout->addWidget(mpFileLabel, 0, 0);
pMainLayout->addWidget(mpFileTextBox, 0, 1);
pMainLayout->addWidget(mpBrowseFileButton, 0, 2);
pMainLayout->addWidget(mpPreviewImageScrollArea, 1, 0, 1, 3);
pMainLayout->addWidget(mpButtonBox, 2, 0, 1, 3, Qt::AlignRight);
setLayout(pMainLayout);
}

void AddOrEditIconDialog::browseImageFile()
{
QString imageFileName = StringHandler::getOpenFileName(this, QString(Helper::applicationName).append(" - ").append(Helper::chooseFile),
NULL, Helper::bitmapFileTypes, NULL);
if (imageFileName.isEmpty()) {
return;
}
mpFileTextBox->setText(imageFileName);
QPixmap pixmap;
pixmap.load(imageFileName);
mpPreviewImageLabel->setPixmap(pixmap);
}

void AddOrEditIconDialog::addOrEditIcon()
{
if (mpShapeAnnotation) { // edit case
if (mpShapeAnnotation->getFileName().compare(mpFileTextBox->text()) != 0) {
QString oldIcon = mpShapeAnnotation->getFileName();
QString newIcon = mpFileTextBox->text();
UpdateIconCommand *pUpdateIconCommand = new UpdateIconCommand(oldIcon, newIcon, mpShapeAnnotation);
mpGraphicsView->getModelWidget()->getUndoStack()->push(pUpdateIconCommand);
mpGraphicsView->getModelWidget()->updateModelText();
}
} else { // add case
if (mpFileTextBox->text().isEmpty()) {
QMessageBox::critical(this, QString("%1 - %2").arg(Helper::applicationName, Helper::error),
GUIMessages::getMessage(GUIMessages::ENTER_NAME).arg(Helper::fileLabel), Helper::ok);
mpFileTextBox->setFocus();
return;
}
AddIconCommand *pAddIconCommand = new AddIconCommand(mpFileTextBox->text(), mpGraphicsView);
mpGraphicsView->getModelWidget()->getUndoStack()->push(pAddIconCommand);
mpGraphicsView->getModelWidget()->updateModelText();
}
accept();
}
21 changes: 0 additions & 21 deletions OMEdit/OMEditGUI/Annotations/BitmapAnnotation.h
Expand Up @@ -65,25 +65,4 @@ public slots:
void duplicate();
};

class AddOrEditIconDialog : public QDialog
{
Q_OBJECT
public:
AddOrEditIconDialog(ShapeAnnotation *pShapeAnnotation, GraphicsView *pGraphicsView, QWidget *pParent = 0);
private:
ShapeAnnotation *mpShapeAnnotation;
GraphicsView *mpGraphicsView;
Label *mpFileLabel;
QLineEdit *mpFileTextBox;
QPushButton *mpBrowseFileButton;
QScrollArea *mpPreviewImageScrollArea;
Label *mpPreviewImageLabel;
QPushButton *mpOkButton;
QPushButton *mpCancelButton;
QDialogButtonBox *mpButtonBox;
public slots:
void browseImageFile();
void addOrEditIcon();
};

#endif // BITMAPANNOTATION_H
2 changes: 1 addition & 1 deletion OMEdit/OMEditGUI/Annotations/LineAnnotation.cpp
Expand Up @@ -36,7 +36,7 @@
#include "LineAnnotation.h"
#include "Modeling/ItemDelegate.h"
#include "Modeling/Commands.h"
#include "Modeling/BusDialog.h"
#include "OMS/BusDialog.h"

#include <QMessageBox>

Expand Down
2 changes: 1 addition & 1 deletion OMEdit/OMEditGUI/Component/Component.cpp
Expand Up @@ -39,7 +39,7 @@
#include "Modeling/Commands.h"
#include "Modeling/DocumentationWidget.h"
#include "Plotting/VariablesWidget.h"
#include "Modeling/BusDialog.h"
#include "OMS/BusDialog.h"

#include <QMessageBox>
#include <QMenu>
Expand Down
2 changes: 1 addition & 1 deletion OMEdit/OMEditGUI/MainWindow.cpp
Expand Up @@ -32,7 +32,6 @@
* @author Adeel Asghar <adeel.asghar@liu.se>
*/


#include "MainWindow.h"
/* Keep PlotWindowContainer on top to include OSG first */
#include "Plotting/PlotWindowContainer.h"
Expand All @@ -42,6 +41,7 @@
#include "OMS/OMSProxy.h"
#include "Modeling/LibraryTreeWidget.h"
#include "Modeling/ModelicaClassDialog.h"
#include "OMS/ModelDialog.h"
#include "Debugger/GDB/GDBAdapter.h"
#include "Debugger/StackFrames/StackFramesWidget.h"
#include "Debugger/Locals/LocalsWidget.h"
Expand Down
2 changes: 1 addition & 1 deletion OMEdit/OMEditGUI/Modeling/ItemDelegate.cpp
Expand Up @@ -35,7 +35,7 @@
#include "Modeling/LibraryTreeWidget.h"
#include "Plotting/VariablesWidget.h"
#include "Simulation/SimulationOutputWidget.h"
#include "Modeling/BusDialog.h"
#include "OMS/BusDialog.h"

#include <QPainter>

Expand Down
4 changes: 3 additions & 1 deletion OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.cpp
Expand Up @@ -52,7 +52,9 @@
#include "Animation/ThreeDViewer.h"
#endif
#include "OMS/OMSProxy.h"
#include "Modeling/BusDialog.h"
#include "OMS/ModelDialog.h"
#include "OMS/BusDialog.h"
#include "OMS/SystemSimulationInformationDialog.h"

#include <QNetworkReply>

Expand Down

0 comments on commit 0545fc6

Please sign in to comment.