MyMainWindow::MyMainWindow(QWidget *parent /*= NULL*/)
: QMainWindow(parent)
{
    // Set size of the window.
    {
		//setFixedSize(400, 300);
		resize(400,300);
		setWindowTitle("Qt4 Application #3");
    }

	QPixmap newPix("./data/gui/image/new-file-icon.png");
	QPixmap openPix("./data/gui/image/open-file-icon.png");
	QPixmap quitPix("./data/gui/image/exit-icon.png");

    // Create menu.
	{
		QAction* newFile = new QAction(newPix, "&New...", this);
		QAction* openFile = new QAction(openPix, "&Open...", this);
		QAction* quit = new QAction(quitPix, "&Quit", this);

		newFile->setShortcut(tr("CTRL+N"));
		openFile->setShortcut(tr("CTRL+O"));
		quit->setShortcut(tr("CTRL+Q"));

		QMenu* menuFile = menuBar()->addMenu("&File");
		menuFile->addAction(newFile);
		menuFile->addAction(openFile);
		menuFile->addSeparator();
		menuFile->addAction(quit);

		connect(quit, SIGNAL(triggered()), this, SLOT(handleQuitMenuClicked()));

		//
		QAction* undo = new QAction("&Undo", this);
		QAction* redo = new QAction("&Redo", this);
		QAction* copy = new QAction("&Copy", this);
		QAction* cut = new QAction("Cut", this);
		QAction* paste = new QAction("&Paste", this);
		QAction* deleteItem = new QAction("&Delete", this);

		undo->setShortcut(tr("CTRL+Z"));
		redo->setShortcut(tr("CTRL+Y"));
		copy->setShortcut(tr("CTRL+C"));
		cut->setShortcut(tr("CTRL+X"));
		paste->setShortcut(tr("CTRL+V"));
		deleteItem->setShortcut(tr("CTRL+D"));

		QMenu* menuEdit = menuBar()->addMenu("&Edit");
		menuEdit->addAction(undo);
		menuEdit->addAction(redo);
		menuEdit->addSeparator();
		menuEdit->addAction(copy);
		menuEdit->addAction(cut);
		menuEdit->addAction(paste);
		menuEdit->addAction(deleteItem);

		//
		QAction* about = new QAction("&About...", this);

		QMenu* menuHelp = menuBar()->addMenu("&Help");
		menuHelp->addAction(about);
	}

	// Create toolbar.
	{
		QToolBar* toolbar = addToolBar("main toolbar");
		toolbar->addAction(QIcon(newPix), "New File");
		toolbar->addAction(QIcon(openPix), "Open File");
		toolbar->addSeparator();
		QAction* quit = toolbar->addAction(QIcon(quitPix), "Quit Application");

		connect(quit, SIGNAL(triggered()), this, SLOT(handleQuitMenuClicked()));
	}

	// Create statusbar.
	{
		statusBar()->showMessage("Ready");
	}

	//
	{
		QWidget* window = new QWidget(this);

		QVBoxLayout* vboxLayout = new QVBoxLayout();
		QHBoxLayout* hboxLayout = new QHBoxLayout(window);

		QListWidget* lw = new QListWidget(this);
		lw->addItem("The Omen");
		lw->addItem("The Exorcist");
		lw->addItem("Notes on a scandal");
		lw->addItem("Fargo");
		lw->addItem("Capote");

		QPushButton *add = new QPushButton("Add", this);
		QPushButton *rename = new QPushButton("Rename", this);
		QPushButton *remove = new QPushButton("Remove", this);
		QPushButton *removeall = new QPushButton("Remove All", this);

		vboxLayout->setSpacing(3);
		//vboxLayout->addStretch(1);
		vboxLayout->addWidget(add);
		vboxLayout->addWidget(rename);
		vboxLayout->addWidget(remove);
		vboxLayout->addWidget(removeall);
		vboxLayout->addStretch(1);

		hboxLayout->addWidget(lw);
		hboxLayout->addSpacing(15);
		hboxLayout->addLayout(vboxLayout);

        window->setLayout(hboxLayout);

		setCentralWidget(window);
	}
}
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    centralWidget = new QWidget(this);
    this->setCentralWidget(centralWidget);

    QHBoxLayout *mainLayout = new QHBoxLayout;

    QTableWidget* table = new QTableWidget(this);
    mainLayout->addWidget(table);
    table->setColumnCount(2);
    //table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    table->resize(20, table->height());
    table->setBaseSize(20,20);
    canvas = new Canvas(this);

    // Main MenuBar
    menuBar = new QMenuBar(canvas);

    // File Menus
    QMenu* fileMenu = new QMenu("File");

    QPixmap openPix("img/folder_picture.png");
    QAction* open = new QAction(openPix, "&Open", this);
    fileMenu->addAction(open);

    fileMenu->addSeparator();

    QPixmap savePix("img/disk.png");
    QAction* save = new QAction(savePix, "&Save", this);
    fileMenu->addAction(save);

    QPixmap saveAsPix("img/disk_multiple.png");
    QAction* saveAs = new QAction(saveAsPix, "&Save As", this);
    fileMenu->addAction(saveAs);

    fileMenu->addSeparator();

    QPixmap quitPix("img/door_out.png");
    QAction* quit = new QAction(quitPix, "&Quit", this);
    fileMenu->addAction(quit);

    // Edit Menu
    QMenu* editMenu = new QMenu("Edit");

    QPixmap cutPix("img/cut.png");
    QAction* cut = new QAction(cutPix, "&Cut", this);
    editMenu->addAction(cut);

    QPixmap copyPix("img/copy.png");
    QAction* copy = new QAction(copyPix, "&Copy", this);
    editMenu->addAction(copy);

    QPixmap pastePix("img/paste.png");
    QAction* paste = new QAction(pastePix, "&Paste", this);
    editMenu->addAction(paste);

    editMenu->addSeparator();

    editMenu->addAction("Sprite");
    editMenu->addAction("Animation");

    // View Menus
    QMenu* viewMenu = new QMenu("View");

    QPixmap gridPix("img/grid.png");
    QAction* viewGrid = new QAction(gridPix, "&Grid", this);
    viewMenu->addAction(viewGrid);
    viewGrid->setCheckable(true);
    viewGrid->setChecked(true);

    QAction *viewSprite = viewMenu->addAction("Sprite");
    viewSprite->setCheckable(true);
    viewSprite->setChecked(true);

    QAction *viewSymmetry = viewMenu->addAction("Symmetry Hints");
    viewSymmetry->setCheckable(true);
    viewSymmetry->setChecked(true);

    viewMenu->addSeparator();

    QPixmap zoomInPix("img/zoom_in.png");
    QAction* zoomIn = new QAction(zoomInPix, "&Zoom In", this);
    viewMenu->addAction(zoomIn);

    QPixmap zoomOutPix("img/zoom_out.png");
    QAction* zoomOut = new QAction(zoomOutPix, "&Zoom Out", this);
    viewMenu->addAction(zoomOut);

    QPixmap zoom100Pix("img/zoom.png");
    QAction* zoom100 = new QAction(zoom100Pix, "&Actual Size", this);
    viewMenu->addAction(zoom100);

    // Help Menus
    QMenu* helpMenu = new QMenu("Help");
    QPixmap aboutPix("img/star.png");
    QAction* about = new QAction(aboutPix, "&About", this);
    helpMenu->addAction(about);

    menuBar->addMenu(fileMenu);
    menuBar->addMenu(editMenu);
    menuBar->addMenu(viewMenu);
    menuBar->addMenu(helpMenu);

    // ToolBar
    QToolBar* toolBar = new QToolBar(canvas);

    toolBar->addAction(open);

    toolBar->addSeparator();

    toolBar->addAction(save);
    toolBar->addAction(saveAs);

    toolBar->addSeparator();

    toolBar->addAction(cut);
    toolBar->addAction(copy);
    toolBar->addAction(paste);

    toolBar->addSeparator();

    toolBar->addAction(viewGrid);

    toolBar->addSeparator();

    QSpinBox* gridX = new QSpinBox(this);
    gridX->setPrefix("X: ");
    toolBar->addWidget(gridX);

    toolBar->addSeparator();

    QSpinBox* gridY = new QSpinBox(this);
    gridY->setPrefix("Y: ");
    toolBar->addWidget(gridY);

    toolBar->addSeparator();

    toolBar->addAction(zoomIn);
    toolBar->addAction(zoomOut);
    toolBar->addAction(zoom100);

    toolBar->addSeparator();

    QDoubleSpinBox* speed = new QDoubleSpinBox(this);
    speed->setPrefix("Speed: ");
    speed->setDecimals(3);
    speed->setSingleStep(0.001);
    speed->setAccelerated(true);
    toolBar->addWidget(speed);

    mainLayout->addWidget(canvas);
    setMenuBar(menuBar);
    addToolBar(toolBar);

    toolBar->addSeparator();

    QPixmap playPix("img/play.png");
    QAction* play = new QAction(playPix, "&Play", this);
    toolBar->addAction(play);

    QPixmap pausePix("img/pause.png");
    QAction* pause = new QAction(pausePix, "&Pause", this);
    toolBar->addAction(pause);

    QPixmap stopPix("img/stop.png");
    QAction* stop = new QAction(stopPix, "&Stop", this);
    toolBar->addAction(stop);

    toolBar->addSeparator();

    QSpinBox* frame = new QSpinBox(this);
    frame->setPrefix("Frame: ");
    toolBar->addWidget(frame);

    mainLayout->setMargin(0);
    centralWidget->setLayout(mainLayout);
}
int main(int argc, char **argv)
{

    QApplication app(argc, argv);

    // Initializing the graph and its container
    Q3DScatter *graph = new Q3DScatter();
    QWidget *container = QWidget::createWindowContainer(graph);
    //! [0]

    QSize screenSize = graph->screen()->size();
    container->setMinimumSize(QSize(screenSize.width() / 2.25, screenSize.height() / 4));
    container->setMaximumSize(screenSize);
    container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    container->setFocusPolicy(Qt::StrongFocus);

    //! [1]
    QWidget *widget = new QWidget;
    QGroupBox *menuLayout = new QGroupBox;
    QGroupBox *optionLayout = new QGroupBox;
    QVBoxLayout *vLayout = new QVBoxLayout(widget);
    vLayout->addWidget(menuLayout);
    vLayout->addWidget(container, 1);
    vLayout->addWidget(optionLayout);
    //! [1]

    widget->setWindowTitle(QStringLiteral("CRN Dava Visualization"));

    //! [4]
    /*
    QComboBox *themeList = new QComboBox(widget);
    themeList->addItem(QStringLiteral("Qt"));
    themeList->addItem(QStringLiteral("Primary Colors"));
    themeList->addItem(QStringLiteral("Digia"));
    themeList->addItem(QStringLiteral("Stone Moss"));
    themeList->addItem(QStringLiteral("Army Blue"));
    themeList->addItem(QStringLiteral("Retro"));
    themeList->addItem(QStringLiteral("Ebony"));
    themeList->addItem(QStringLiteral("Isabelle"));
    themeList->setCurrentIndex(6);

    QPushButton *labelButton = new QPushButton(widget);
    labelButton->setText(QStringLiteral("Change label style"));
    */
    int logoHeight = 100, logoWidth = 300;
    int buttonSize = 100;
    QGridLayout *gridMenu = new QGridLayout();
    QPushButton *taLogoLabel = new QPushButton();
    QPushButton *configLabel = new QPushButton();
    QPushButton *saveLabel = new QPushButton();
    QPushButton *openLabel = new QPushButton();
    QPushButton *globeLabel = new QPushButton();
    QPixmap taLogoPix("/home/adityarputra/Pictures/placeholder.png");
    QIcon taLogoIcon(taLogoPix);
    QPixmap configPix("/home/adityarputra/Pictures/placeholder.png");
    QIcon configIcon(configPix);
    QPixmap savePix("/home/adityarputra/Pictures/placeholder.png");
    QIcon saveIcon(savePix);
    QPixmap openPix("/home/adityarputra/Pictures/placeholder.png");
    QIcon openIcon(openPix);
    QPixmap globePix("/home/adityarputra/Pictures/placeholder.png");
    QIcon globeIcon(globePix);

    taLogoLabel->setIcon(taLogoIcon);
    taLogoLabel->setMaximumSize(logoWidth,logoHeight);
    //taLogoLabel->setText("TA logo label");
    configLabel->setIcon(configIcon);
    configLabel->setMaximumSize(buttonSize,buttonSize);
    //configLabel->setText("Config Icon");
    saveLabel->setIcon(saveIcon);
    saveLabel->setMaximumSize(buttonSize,buttonSize);
    //saveLabel->setText("Save Icon");
    openLabel->setIcon(openIcon);
    openLabel->setMaximumSize(buttonSize,buttonSize);
    //openLabel->setText("Open Icon");
    globeLabel->setIcon(globeIcon);
    globeLabel->setMaximumSize(buttonSize,buttonSize);
    //globeLabel->setText("Globe Icon");

    gridMenu->addWidget(taLogoLabel,0,0);
    gridMenu->addWidget(configLabel,0,2);
    gridMenu->addWidget(saveLabel,0,3);
    gridMenu->addWidget(openLabel,0,4);
    gridMenu->addWidget(globeLabel,0,5);

    gridMenu->setColumnStretch(0,300);
    gridMenu->setRowMinimumHeight(0,100);
    gridMenu->setColumnStretch(1,100);
    gridMenu->setColumnStretch(2,100);
    gridMenu->setColumnStretch(3,100);
    gridMenu->setColumnStretch(4,100);
    gridMenu->setColumnStretch(5,100);

    menuLayout->setLayout(gridMenu);

    //-----------------------------------//
    QGridLayout *gridOption = new QGridLayout();
    QComboBox *gasTypeCombo = new QComboBox();
    QPushButton *rewindButton = new QPushButton();
    QPushButton *prevButton = new QPushButton();
    QPushButton *startButton = new QPushButton();
    QPushButton *nextButton = new QPushButton();
    QPushButton *forwardButton = new QPushButton();
    QTableWidget *sensorDataTable = new QTableWidget();
    QPlainTextEdit *console = new QPlainTextEdit();

    sensorDataTable->setRowCount(60);
    sensorDataTable->setColumnCount(9);

    QPixmap buttonPix("/home/adityarputra/Pictures/placeholder.png");
    QIcon buttonIcon(buttonPix);

    rewindButton->setIcon(buttonIcon);
    rewindButton->setMaximumWidth(50);
    prevButton->setIcon(buttonIcon);
    prevButton->setMaximumWidth(50);
    startButton->setIcon(buttonIcon);
    startButton->setMaximumWidth(50);
    nextButton->setIcon(buttonIcon);
    nextButton->setMaximumWidth(50);
    forwardButton->setIcon(buttonIcon);
    forwardButton->setMaximumWidth(50);

    gridOption->addWidget(sensorDataTable,0,6,3,1);
    gridOption->addWidget(gasTypeCombo,0,0,1,5);
    gridOption->addWidget(rewindButton,1,0);
    gridOption->addWidget(prevButton,1,1);
    gridOption->addWidget(startButton,1,2);
    gridOption->addWidget(nextButton,1,3);
    gridOption->addWidget(forwardButton,1,4);
    gridOption->addWidget(console,2,0,1,5);
    gridOption->setColumnStretch(0,50);
    gridOption->setColumnStretch(1,50);
    gridOption->setColumnStretch(2,50);
    gridOption->setColumnStretch(3,50);
    gridOption->setColumnStretch(4,50);
    gridOption->setColumnStretch(5,50);
    gridOption->setColumnStretch(6,400);

    optionLayout->setLayout(gridOption);

    //----------------------------------To be deleted---------------------------------
    /*QCheckBox *smoothCheckBox = new QCheckBox(widget);
    smoothCheckBox->setText(QStringLiteral("Smooth dots"));
    smoothCheckBox->setChecked(true);

    QComboBox *itemStyleList = new QComboBox(widget);
    itemStyleList->addItem(QStringLiteral("Sphere"), int(QAbstract3DSeries::MeshSphere));
    itemStyleList->addItem(QStringLiteral("Cube"), int(QAbstract3DSeries::MeshCube));
    itemStyleList->addItem(QStringLiteral("Minimal"), int(QAbstract3DSeries::MeshMinimal));
    itemStyleList->addItem(QStringLiteral("Point"), int(QAbstract3DSeries::MeshPoint));
    itemStyleList->setCurrentIndex(0);

    QPushButton *cameraButton = new QPushButton(widget);
    cameraButton->setText(QStringLiteral("Change camera preset"));

    QPushButton *itemCountButton = new QPushButton(widget);
    itemCountButton->setText(QStringLiteral("Toggle item count"));

    QCheckBox *backgroundCheckBox = new QCheckBox(widget);
    backgroundCheckBox->setText(QStringLiteral("Show background"));
    backgroundCheckBox->setChecked(true);

    QCheckBox *gridCheckBox = new QCheckBox(widget);
    gridCheckBox->setText(QStringLiteral("Show grid"));
    gridCheckBox->setChecked(true);

    QComboBox *shadowQuality = new QComboBox(widget);
    shadowQuality->addItem(QStringLiteral("None"));
    shadowQuality->addItem(QStringLiteral("Low"));
    shadowQuality->addItem(QStringLiteral("Medium"));
    shadowQuality->addItem(QStringLiteral("High"));
    shadowQuality->addItem(QStringLiteral("Low Soft"));
    shadowQuality->addItem(QStringLiteral("Medium Soft"));
    shadowQuality->addItem(QStringLiteral("High Soft"));
    shadowQuality->setCurrentIndex(4);

    QFontComboBox *fontList = new QFontComboBox(widget);
    fontList->setCurrentFont(QFont("Arial"));*/
    //----------------------------------------------------------------

    // Adding widget to respective layout
    /*
    vLayout->addWidget(labelButton, 0, Qt::AlignTop);
    vLayout->addWidget(cameraButton, 0, Qt::AlignTop);
    vLayout->addWidget(itemCountButton, 0, Qt::AlignTop);
    vLayout->addWidget(backgroundCheckBox);
    vLayout->addWidget(gridCheckBox);
    vLayout->addWidget(smoothCheckBox, 0, Qt::AlignTop);
    vLayout->addWidget(new QLabel(QStringLiteral("Change dot style")));
    vLayout->addWidget(itemStyleList);
    vLayout->addWidget(new QLabel(QStringLiteral("Change theme")));
    vLayout->addWidget(themeList);
    vLayout->addWidget(new QLabel(QStringLiteral("Adjust shadow quality")));
    vLayout->addWidget(shadowQuality);
    vLayout->addWidget(new QLabel(QStringLiteral("Change font")));
    vLayout->addWidget(fontList, 1, Qt::AlignTop);
    */
    //! [5]

    //! [2]
    ScatterDataModifier *modifier = new ScatterDataModifier(graph);
    //! [2]

    connect(configLabel,SIGNAL(clicked(bool)),this,
    /*
    QObject::connect(cameraButton, &QPushButton::clicked, modifier,
                     &ScatterDataModifier::changePresetCamera);
    QObject::connect(labelButton, &QPushButton::clicked, modifier,
                     &ScatterDataModifier::changeLabelStyle);
    QObject::connect(itemCountButton, &QPushButton::clicked, modifier,
                     &ScatterDataModifier::toggleItemCount);

    QObject::connect(backgroundCheckBox, &QCheckBox::stateChanged, modifier,
                     &ScatterDataModifier::setBackgroundEnabled);
    QObject::connect(gridCheckBox, &QCheckBox::stateChanged, modifier,
                     &ScatterDataModifier::setGridEnabled);
    QObject::connect(smoothCheckBox, &QCheckBox::stateChanged, modifier,
                     &ScatterDataModifier::setSmoothDots);

    QObject::connect(modifier, &ScatterDataModifier::backgroundEnabledChanged,
                     backgroundCheckBox, &QCheckBox::setChecked);
    QObject::connect(modifier, &ScatterDataModifier::gridEnabledChanged,
                     gridCheckBox, &QCheckBox::setChecked);
    QObject::connect(itemStyleList, SIGNAL(currentIndexChanged(int)), modifier,
                     SLOT(changeStyle(int)));

    QObject::connect(themeList, SIGNAL(currentIndexChanged(int)), modifier,
                     SLOT(changeTheme(int)));

    QObject::connect(shadowQuality, SIGNAL(currentIndexChanged(int)), modifier,
                     SLOT(changeShadowQuality(int)));

    QObject::connect(modifier, &ScatterDataModifier::shadowQualityChanged, shadowQuality,
                     &QComboBox::setCurrentIndex);
    QObject::connect(graph, &Q3DScatter::shadowQualityChanged, modifier,
                     &ScatterDataModifier::shadowQualityUpdatedByVisual);

    QObject::connect(fontList, &QFontComboBox::currentFontChanged, modifier,
                     &ScatterDataModifier::changeFont);
    QObject::connect(modifier, &ScatterDataModifier::fontChanged, fontList,
                     &QFontComboBox::setCurrentFont);
    */
    //! [6]

    //! [3]
    widget->show();
    return app.exec();
    //! [3]
}