nextpnr/gui/basewindow.h

127 lines
3.3 KiB
C
Raw Normal View History

2018-06-22 22:21:20 +08:00
/*
* nextpnr -- Next Generation Place and Route
*
* Copyright (C) 2018 Miodrag Milanovic <miodrag@symbioticeda.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
2018-06-21 19:41:16 +08:00
#ifndef BASEMAINWINDOW_H
#define BASEMAINWINDOW_H
#include "nextpnr.h"
2018-08-03 00:50:08 +08:00
#include "worker.h"
2018-06-21 19:41:16 +08:00
#include <QMainWindow>
#include <QMenu>
#include <QMenuBar>
#include <QProgressBar>
2018-06-21 19:41:16 +08:00
#include <QStatusBar>
2018-06-21 19:55:36 +08:00
#include <QTabWidget>
#include <QToolBar>
2018-06-21 19:41:16 +08:00
Q_DECLARE_METATYPE(std::string)
2018-07-15 01:44:37 +08:00
Q_DECLARE_METATYPE(NEXTPNR_NAMESPACE_PREFIX DecalXY)
2018-06-22 19:10:27 +08:00
NEXTPNR_NAMESPACE_BEGIN
2018-07-14 20:06:05 +08:00
class PythonTab;
2018-07-16 02:31:42 +08:00
class DesignWidget;
2018-07-26 19:21:46 +08:00
class FPGAViewWidget;
2018-07-14 20:06:05 +08:00
2018-06-21 19:41:16 +08:00
class BaseMainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit BaseMainWindow(std::unique_ptr<Context> context, QWidget *parent = 0);
virtual ~BaseMainWindow();
Context *getContext() { return ctx.get(); }
2018-06-21 19:41:16 +08:00
2018-08-03 00:50:08 +08:00
void load_json(std::string filename);
2018-08-03 01:25:20 +08:00
2018-06-21 19:41:16 +08:00
protected:
void createMenusAndBars();
2018-08-03 00:50:08 +08:00
void disableActions();
2018-08-03 01:25:20 +08:00
virtual void onDisableActions(){};
virtual void onJsonLoaded(){};
virtual void onPackFinished(){};
virtual void onBudgetFinished(){};
virtual void onPlaceFinished(){};
virtual void onRouteFinished(){};
2018-06-21 19:41:16 +08:00
protected Q_SLOTS:
void writeInfo(std::string text);
void closeTab(int index);
2018-06-26 20:17:17 +08:00
virtual void new_proj() = 0;
virtual void open_proj() = 0;
virtual bool save_proj() = 0;
2018-06-21 19:41:16 +08:00
2018-08-03 00:50:08 +08:00
void open_json();
void budget();
void place();
void pack_finished(bool status);
void budget_finish(bool status);
void place_finished(bool status);
void route_finished(bool status);
void taskCanceled();
void taskStarted();
void taskPaused();
2018-06-26 21:47:22 +08:00
Q_SIGNALS:
void contextChanged(Context *ctx);
2018-07-06 02:06:12 +08:00
void updateTreeView();
2018-06-26 21:47:22 +08:00
2018-06-21 19:41:16 +08:00
protected:
2018-08-03 01:21:25 +08:00
// state variables
std::unique_ptr<Context> ctx;
2018-08-03 00:50:08 +08:00
TaskManager *task;
2018-08-03 01:21:25 +08:00
bool timing_driven;
std::string currentJson;
// main widgets
2018-06-21 19:41:16 +08:00
QTabWidget *tabWidget;
2018-06-21 20:12:02 +08:00
QTabWidget *centralTabWidget;
2018-07-14 20:06:05 +08:00
PythonTab *console;
2018-08-03 01:21:25 +08:00
DesignWidget *designview;
FPGAViewWidget *fpgaView;
2018-06-21 19:55:36 +08:00
2018-08-03 01:21:25 +08:00
// Menus, bars and actions
2018-06-21 19:41:16 +08:00
QMenuBar *menuBar;
2018-08-03 01:21:25 +08:00
QMenu *menuDesign;
2018-06-21 19:41:16 +08:00
QStatusBar *statusBar;
2018-08-03 01:21:25 +08:00
QToolBar *mainActionBar;
QProgressBar *progressBar;
2018-08-03 01:25:20 +08:00
QAction *actionNew;
QAction *actionOpen;
2018-07-21 18:15:50 +08:00
QAction *actionSave;
2018-08-03 00:50:08 +08:00
QAction *actionLoadJSON;
QAction *actionPack;
QAction *actionAssignBudget;
QAction *actionPlace;
QAction *actionRoute;
QAction *actionPlay;
QAction *actionPause;
QAction *actionStop;
2018-06-21 19:41:16 +08:00
};
2018-06-22 19:10:27 +08:00
NEXTPNR_NAMESPACE_END
2018-06-21 19:41:16 +08:00
#endif // BASEMAINWINDOW_H