Remove mdbviz
The MultiDrawBuffer no longer exists. Change-Id: I31c2df9a5363daab018e33156104e3dd7904230e Reviewed-on: https://skia-review.googlesource.com/c/skia/+/532012 Commit-Queue: Kevin Lubick <kjlubick@google.com> Auto-Submit: Kevin Lubick <kjlubick@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
ec8c595b9f
commit
72680f0c88
61
BUILD.gn
61
BUILD.gn
@ -2900,67 +2900,6 @@ if (skia_enable_tools) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skia_qt_path != "" && (is_win || is_linux || is_mac)) {
|
|
||||||
action_foreach("generate_mocs") {
|
|
||||||
script = "gn/call.py"
|
|
||||||
sources = [ "tools/mdbviz/MainWindow.h" ]
|
|
||||||
outputs = [ "$target_gen_dir/mdbviz/{{source_name_part}}_moc.cpp" ]
|
|
||||||
args = [
|
|
||||||
"$skia_qt_path" + "/bin/moc",
|
|
||||||
"{{source}}",
|
|
||||||
"-o",
|
|
||||||
"gen/mdbviz/{{source_name_part}}_moc.cpp",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
action_foreach("generate_resources") {
|
|
||||||
script = "gn/call.py"
|
|
||||||
sources = [ "tools/mdbviz/resources.qrc" ]
|
|
||||||
outputs = [ "$target_gen_dir/mdbviz/{{source_name_part}}_res.cpp" ]
|
|
||||||
args = [
|
|
||||||
"$skia_qt_path" + "/bin/rcc",
|
|
||||||
"{{source}}",
|
|
||||||
"-o",
|
|
||||||
"gen/mdbviz/{{source_name_part}}_res.cpp",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
test_app("mdbviz") {
|
|
||||||
if (is_win) {
|
|
||||||
# on Windows we need to disable some exception handling warnings due to the Qt headers
|
|
||||||
cflags = [ "/Wv:18" ] # 18 -> VS2013, 19 -> VS2015, 1910 -> VS2017
|
|
||||||
}
|
|
||||||
sources = [
|
|
||||||
"tools/UrlDataManager.cpp",
|
|
||||||
"tools/debugger/DebugCanvas.cpp",
|
|
||||||
"tools/debugger/DebugLayerManager.cpp",
|
|
||||||
"tools/debugger/DrawCommand.cpp",
|
|
||||||
"tools/debugger/JsonWriteBuffer.cpp",
|
|
||||||
"tools/mdbviz/MainWindow.cpp",
|
|
||||||
"tools/mdbviz/Model.cpp",
|
|
||||||
"tools/mdbviz/main.cpp",
|
|
||||||
|
|
||||||
# generated files
|
|
||||||
"$target_gen_dir/mdbviz/MainWindow_moc.cpp",
|
|
||||||
"$target_gen_dir/mdbviz/resources_res.cpp",
|
|
||||||
]
|
|
||||||
lib_dirs = [ "$skia_qt_path/lib" ]
|
|
||||||
libs = [
|
|
||||||
"Qt5Core.lib",
|
|
||||||
"Qt5Gui.lib",
|
|
||||||
"Qt5Widgets.lib",
|
|
||||||
]
|
|
||||||
include_dirs = [
|
|
||||||
"$skia_qt_path/include",
|
|
||||||
"$skia_qt_path/include/QtCore",
|
|
||||||
"$skia_qt_path/include/QtWidgets",
|
|
||||||
]
|
|
||||||
deps = [
|
|
||||||
":generate_mocs",
|
|
||||||
":generate_resources",
|
|
||||||
":skia",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_android && defined(ndk) && ndk != "") {
|
if (is_android && defined(ndk) && ndk != "") {
|
||||||
copy("gdbserver") {
|
copy("gdbserver") {
|
||||||
sources = [ "$ndk/$ndk_gdbserver" ]
|
sources = [ "$ndk/$ndk_gdbserver" ]
|
||||||
|
@ -36,7 +36,6 @@ declare_args() {
|
|||||||
skia_include_multiframe_procs = false
|
skia_include_multiframe_procs = false
|
||||||
skia_lex = false
|
skia_lex = false
|
||||||
skia_libgifcodec_path = "third_party/externals/libgifcodec"
|
skia_libgifcodec_path = "third_party/externals/libgifcodec"
|
||||||
skia_qt_path = getenv("QT_PATH")
|
|
||||||
skia_tools_require_resources = false
|
skia_tools_require_resources = false
|
||||||
skia_update_fuchsia_sdk = false
|
skia_update_fuchsia_sdk = false
|
||||||
skia_use_angle = false
|
skia_use_angle = false
|
||||||
|
@ -56,7 +56,6 @@ ignore = re.compile('|'.join([
|
|||||||
r'third_party/.*',
|
r'third_party/.*',
|
||||||
r'tools/fiddle/.*',
|
r'tools/fiddle/.*',
|
||||||
r'tools/gpu/vk/.*',
|
r'tools/gpu/vk/.*',
|
||||||
r'tools/mdbviz/.*',
|
|
||||||
r'tools/sk_app/.*',
|
r'tools/sk_app/.*',
|
||||||
r'tools/viewer/.*',
|
r'tools/viewer/.*',
|
||||||
]))
|
]))
|
||||||
|
@ -1,47 +0,0 @@
|
|||||||
load("//bazel:macros.bzl", "generated_cc_atom")
|
|
||||||
|
|
||||||
licenses(["notice"])
|
|
||||||
|
|
||||||
generated_cc_atom(
|
|
||||||
name = "Model_hdr",
|
|
||||||
hdrs = ["Model.h"],
|
|
||||||
visibility = ["//:__subpackages__"],
|
|
||||||
deps = [
|
|
||||||
"//include/core:SkBitmap_hdr",
|
|
||||||
"//include/private:SkTDArray_hdr",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
generated_cc_atom(
|
|
||||||
name = "Model_src",
|
|
||||||
srcs = ["Model.cpp"],
|
|
||||||
visibility = ["//:__subpackages__"],
|
|
||||||
deps = [
|
|
||||||
":Model_hdr",
|
|
||||||
"//include/core:SkBitmap_hdr",
|
|
||||||
"//include/core:SkCanvas_hdr",
|
|
||||||
"//include/core:SkPicture_hdr",
|
|
||||||
"//include/core:SkStream_hdr",
|
|
||||||
"//tools/debugger:DebugCanvas_hdr",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
generated_cc_atom(
|
|
||||||
name = "main_src",
|
|
||||||
srcs = ["main.cpp"],
|
|
||||||
visibility = ["//:__subpackages__"],
|
|
||||||
deps = [":mainwindow_hdr"],
|
|
||||||
)
|
|
||||||
|
|
||||||
generated_cc_atom(
|
|
||||||
name = "mainwindow_hdr",
|
|
||||||
hdrs = ["mainwindow.h"],
|
|
||||||
visibility = ["//:__subpackages__"],
|
|
||||||
deps = [":Model_hdr"],
|
|
||||||
)
|
|
||||||
|
|
||||||
generated_cc_atom(
|
|
||||||
name = "mainwindow_src",
|
|
||||||
srcs = ["mainwindow.cpp"],
|
|
||||||
visibility = ["//:__subpackages__"],
|
|
||||||
)
|
|
@ -1,114 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2017 Google Inc.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
|
||||||
* found in the LICENSE file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "tools/mdbviz/Model.h"
|
|
||||||
|
|
||||||
#include "include/core/SkBitmap.h"
|
|
||||||
#include "include/core/SkCanvas.h"
|
|
||||||
#include "include/core/SkPicture.h"
|
|
||||||
#include "include/core/SkStream.h"
|
|
||||||
#include "tools/debugger/DebugCanvas.h"
|
|
||||||
|
|
||||||
Model::Model() : fCurOp(0) {
|
|
||||||
SkImageInfo ii = SkImageInfo::MakeN32Premul(1024, 1024);
|
|
||||||
fBM.allocPixels(ii, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
Model::~Model() {
|
|
||||||
this->resetOpsTask();
|
|
||||||
}
|
|
||||||
|
|
||||||
Model::ErrorCode Model::load(const char* filename) {
|
|
||||||
std::unique_ptr<SkStream> stream = SkStream::MakeFromFile(filename);
|
|
||||||
if (!stream) {
|
|
||||||
return ErrorCode::kCouldntOpenFile;
|
|
||||||
}
|
|
||||||
sk_sp<SkPicture> pic(SkPicture::MakeFromStream(stream.get()));
|
|
||||||
if (!pic) {
|
|
||||||
return ErrorCode::kCouldntDecodeSKP;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
std::unique_ptr<DebugCanvas> temp(
|
|
||||||
new DebugCanvas(SkScalarCeilToInt(pic->cullRect().width()),
|
|
||||||
SkScalarCeilToInt(pic->cullRect().height())));
|
|
||||||
|
|
||||||
temp->setPicture(pic.get());
|
|
||||||
pic->playback(temp.get());
|
|
||||||
temp->setPicture(nullptr);
|
|
||||||
this->resetOpsTask();
|
|
||||||
temp->detachCommands(&fOps);
|
|
||||||
}
|
|
||||||
|
|
||||||
this->setCurOp(fOps.count()-1);
|
|
||||||
|
|
||||||
return ErrorCode::kOK;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* Model::ErrorString(ErrorCode err) {
|
|
||||||
static const char* kStrings[] = {
|
|
||||||
"OK",
|
|
||||||
"Couldn't read file",
|
|
||||||
"Couldn't decode picture"
|
|
||||||
};
|
|
||||||
|
|
||||||
return kStrings[(int)err];
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* Model::getOpName(int index) const {
|
|
||||||
return DrawCommand::GetCommandString(fOps[index]->getType());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Model::isHierarchyPush(int index) const {
|
|
||||||
DrawCommand::OpType type = fOps[index]->getType();
|
|
||||||
|
|
||||||
return DrawCommand::kSave_OpType == type || DrawCommand::kSaveLayer_OpType == type ||
|
|
||||||
DrawCommand::kBeginDrawPicture_OpType == type;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Model::isHierarchyPop(int index) const {
|
|
||||||
DrawCommand::OpType type = fOps[index]->getType();
|
|
||||||
|
|
||||||
return DrawCommand::kRestore_OpType == type || DrawCommand::kEndDrawPicture_OpType == type;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Model::setCurOp(int curOp) {
|
|
||||||
SkASSERT(curOp < fOps.count());
|
|
||||||
|
|
||||||
if (curOp == fCurOp) {
|
|
||||||
return; // the render state is already up to date
|
|
||||||
}
|
|
||||||
|
|
||||||
fCurOp = curOp;
|
|
||||||
this->drawTo(fCurOp);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Model::drawTo(int index) {
|
|
||||||
SkASSERT(index < fOps.count());
|
|
||||||
|
|
||||||
SkCanvas canvas(fBM);
|
|
||||||
|
|
||||||
int saveCount = canvas.save();
|
|
||||||
|
|
||||||
for (int i = 0; i <= index; ++i) {
|
|
||||||
if (fOps[i]->isVisible()) {
|
|
||||||
fOps[i]->execute(&canvas);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
canvas.restoreToCount(saveCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Model::resetOpsTask() {
|
|
||||||
for (int i = 0; i < fOps.count(); ++i) {
|
|
||||||
delete fOps[i];
|
|
||||||
}
|
|
||||||
fOps.reset();
|
|
||||||
fCurOp = 0;
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2017 Google Inc.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
|
||||||
* found in the LICENSE file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "include/core/SkBitmap.h"
|
|
||||||
#include "include/private/SkTDArray.h"
|
|
||||||
|
|
||||||
class DrawCommand;
|
|
||||||
|
|
||||||
// This class encapsulates the both the in-memory representation of the draw ops
|
|
||||||
// and the state of Skia/Ganesh's rendering. It should never have any Qt intrusions.
|
|
||||||
class Model {
|
|
||||||
public:
|
|
||||||
enum class ErrorCode {
|
|
||||||
kOK,
|
|
||||||
kCouldntOpenFile,
|
|
||||||
kCouldntDecodeSKP
|
|
||||||
};
|
|
||||||
|
|
||||||
Model();
|
|
||||||
~Model();
|
|
||||||
|
|
||||||
static const char* ErrorString(ErrorCode);
|
|
||||||
|
|
||||||
// Replace the list of draw ops by reading the provided skp filename and
|
|
||||||
// reset the Skia draw state. It is up to the view portion to update itself
|
|
||||||
// after this call (i.e., rebuild the opsTask view).
|
|
||||||
ErrorCode load(const char* filename);
|
|
||||||
|
|
||||||
// Update the rendering state to the provided op
|
|
||||||
void setCurOp(int curOp);
|
|
||||||
int curOp() const { return fCurOp; }
|
|
||||||
|
|
||||||
int numOps() const { return fOps.count(); }
|
|
||||||
const char* getOpName(int index) const;
|
|
||||||
|
|
||||||
bool isHierarchyPush(int index) const;
|
|
||||||
bool isHierarchyPop(int index) const;
|
|
||||||
|
|
||||||
// Get the bits visually representing the current rendering state
|
|
||||||
void* getPixels() const { return fBM.getPixels(); }
|
|
||||||
int width() const { return fBM.width(); }
|
|
||||||
int height() const { return fBM.height(); }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// draw the ops up to (and including) the index-th op
|
|
||||||
void drawTo(int index);
|
|
||||||
void resetOpsTask();
|
|
||||||
|
|
||||||
private:
|
|
||||||
SkTDArray<DrawCommand*> fOps;
|
|
||||||
int fCurOp; // The current op the rendering state is at
|
|
||||||
SkBitmap fBM;
|
|
||||||
};
|
|
Binary file not shown.
Before Width: | Height: | Size: 215 B |
@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2017 Google Inc.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
|
||||||
* found in the LICENSE file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <QtWidgets>
|
|
||||||
|
|
||||||
#include "tools/mdbviz/mainwindow.h"
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
QApplication app(argc, argv);
|
|
||||||
QCoreApplication::setOrganizationName("Google");
|
|
||||||
QCoreApplication::setApplicationName("MDB Viz");
|
|
||||||
QCoreApplication::setApplicationVersion("0.0");
|
|
||||||
|
|
||||||
QCommandLineParser parser;
|
|
||||||
parser.setApplicationDescription(QCoreApplication::applicationName());
|
|
||||||
parser.addVersionOption();
|
|
||||||
parser.process(app);
|
|
||||||
|
|
||||||
MainWindow mainWin;
|
|
||||||
mainWin.show();
|
|
||||||
|
|
||||||
return app.exec();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,206 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2017 Google Inc.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
|
||||||
* found in the LICENSE file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <QtWidgets>
|
|
||||||
|
|
||||||
#include "MainWindow.h"
|
|
||||||
|
|
||||||
MainWindow::MainWindow() {
|
|
||||||
this->createActions();
|
|
||||||
this->createStatusBar();
|
|
||||||
this->createDockWindows();
|
|
||||||
|
|
||||||
this->setWindowTitle("MDB Viz");
|
|
||||||
|
|
||||||
this->readSettings();
|
|
||||||
this->setUnifiedTitleAndToolBarOnMac(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::openFile() {
|
|
||||||
QString fileName = QFileDialog::getOpenFileName(this);
|
|
||||||
if (!fileName.isEmpty()) {
|
|
||||||
this->loadFile(fileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::setupOpsTaskWidget() {
|
|
||||||
fOpsTaskWidget->clear();
|
|
||||||
|
|
||||||
QTreeWidgetItem* item = nullptr;
|
|
||||||
SkTDArray<QTreeWidgetItem*> parents;
|
|
||||||
|
|
||||||
for (int i = 0; i < fModel.numOps(); i++) {
|
|
||||||
item = new QTreeWidgetItem();
|
|
||||||
|
|
||||||
item->setText(0, QString::number(i));
|
|
||||||
item->setData(0, Qt::UserRole, i);
|
|
||||||
item->setText(1, fModel.getOpName(i));
|
|
||||||
|
|
||||||
if (fModel.isHierarchyPop(i)) {
|
|
||||||
parents.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parents.isEmpty()) {
|
|
||||||
fOpsTaskWidget->addTopLevelItem(item);
|
|
||||||
} else {
|
|
||||||
parents.top()->addChild(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fModel.isHierarchyPush(i)) {
|
|
||||||
*parents.push() = item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fOpsTaskWidget->setCurrentItem(item);
|
|
||||||
fOpsTaskWidget->expandToDepth(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::presentCurrentRenderState() {
|
|
||||||
fImage = QImage((uchar*)fModel.getPixels(), fModel.width(), fModel.height(),
|
|
||||||
QImage::Format_RGBA8888);
|
|
||||||
fImageLabel->setPixmap(QPixmap::fromImage(fImage));
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::loadFile(const QString &fileName) {
|
|
||||||
QFile file(fileName);
|
|
||||||
if (!file.open(QFile::ReadOnly | QFile::Text)) {
|
|
||||||
QMessageBox::warning(this, tr("MDB Viz"),
|
|
||||||
tr("Cannot read file %1:\n%2.")
|
|
||||||
.arg(QDir::toNativeSeparators(fileName), file.errorString()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QTextStream in(&file);
|
|
||||||
#ifndef QT_NO_CURSOR
|
|
||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::string str = file.fileName().toLocal8Bit().constData();
|
|
||||||
|
|
||||||
Model::ErrorCode err = fModel.load(str.c_str());
|
|
||||||
if (Model::ErrorCode::kOK != err) {
|
|
||||||
this->statusBar()->showMessage(Model::ErrorString(err));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this->setupOpsTaskWidget();
|
|
||||||
this->presentCurrentRenderState();
|
|
||||||
|
|
||||||
#ifndef QT_NO_CURSOR
|
|
||||||
QApplication::restoreOverrideCursor();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::about() {
|
|
||||||
QMessageBox::about(this, "About MDB Viz", "Visualize MDB");
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::createActions() {
|
|
||||||
|
|
||||||
// File menu
|
|
||||||
QMenu* fileMenu = this->menuBar()->addMenu(tr("&File"));
|
|
||||||
QToolBar* fileToolBar = this->addToolBar(tr("File"));
|
|
||||||
|
|
||||||
const QIcon openIcon = QIcon::fromTheme("document-open", QIcon(":/images/open.png"));
|
|
||||||
QAction* openAct = new QAction(openIcon, tr("&Open..."), this);
|
|
||||||
openAct->setShortcuts(QKeySequence::Open);
|
|
||||||
openAct->setStatusTip(tr("Open an existing file"));
|
|
||||||
connect(openAct, &QAction::triggered, this, &MainWindow::openFile);
|
|
||||||
fileMenu->addAction(openAct);
|
|
||||||
fileToolBar->addAction(openAct);
|
|
||||||
|
|
||||||
fileMenu->addSeparator();
|
|
||||||
|
|
||||||
const QIcon exitIcon = QIcon::fromTheme("application-exit");
|
|
||||||
QAction *exitAct = fileMenu->addAction(exitIcon, tr("E&xit"), this, &QWidget::close);
|
|
||||||
exitAct->setShortcuts(QKeySequence::Quit);
|
|
||||||
exitAct->setStatusTip(tr("Exit the application"));
|
|
||||||
|
|
||||||
// View menu
|
|
||||||
fViewMenu = this->menuBar()->addMenu(tr("&View"));
|
|
||||||
|
|
||||||
// Help menu
|
|
||||||
this->menuBar()->addSeparator();
|
|
||||||
|
|
||||||
QMenu* helpMenu = this->menuBar()->addMenu(tr("&Help"));
|
|
||||||
|
|
||||||
QAction *aboutAct = helpMenu->addAction(tr("&About"), this, &MainWindow::about);
|
|
||||||
aboutAct->setStatusTip(tr("Show the application's About box"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::onCurrentItemChanged(QTreeWidgetItem* cur, QTreeWidgetItem* /* prev */) {
|
|
||||||
int currentRow = cur->data(0, Qt::UserRole).toInt();
|
|
||||||
fModel.setCurOp(currentRow);
|
|
||||||
this->presentCurrentRenderState();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::createStatusBar() {
|
|
||||||
this->statusBar()->showMessage(tr("Ready"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::createDockWindows() {
|
|
||||||
|
|
||||||
// Op List Window
|
|
||||||
{
|
|
||||||
QDockWidget* opsTaskDock = new QDockWidget("Ops", this);
|
|
||||||
opsTaskDock->setAllowedAreas(Qt::LeftDockWidgetArea);
|
|
||||||
|
|
||||||
fOpsTaskWidget = new QTreeWidget(opsTaskDock);
|
|
||||||
|
|
||||||
QTreeWidgetItem* headerItem = new QTreeWidgetItem;
|
|
||||||
headerItem->setText(0, "Index");
|
|
||||||
headerItem->setText(1, "Op Name");
|
|
||||||
fOpsTaskWidget->setHeaderItem(headerItem);
|
|
||||||
|
|
||||||
fOpsTaskWidget->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
|
|
||||||
fOpsTaskWidget->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
|
|
||||||
|
|
||||||
opsTaskDock->setWidget(fOpsTaskWidget);
|
|
||||||
this->addDockWidget(Qt::LeftDockWidgetArea, opsTaskDock);
|
|
||||||
|
|
||||||
fViewMenu->addAction(opsTaskDock->toggleViewAction());
|
|
||||||
|
|
||||||
connect(fOpsTaskWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
|
|
||||||
this, SLOT(onCurrentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Main canvas Window
|
|
||||||
{
|
|
||||||
QDockWidget* mainCanvasDock = new QDockWidget("Main Canvas", this);
|
|
||||||
mainCanvasDock->setAllowedAreas(Qt::RightDockWidgetArea);
|
|
||||||
|
|
||||||
fImageLabel = new QLabel(mainCanvasDock);
|
|
||||||
|
|
||||||
fImage = QImage(1024, 1024, QImage::Format_RGBA8888);
|
|
||||||
fImage.fill(0);
|
|
||||||
fImageLabel->setPixmap(QPixmap::fromImage(fImage));
|
|
||||||
|
|
||||||
mainCanvasDock->setWidget(fImageLabel);
|
|
||||||
this->addDockWidget(Qt::RightDockWidgetArea, mainCanvasDock);
|
|
||||||
|
|
||||||
fViewMenu->addAction(mainCanvasDock->toggleViewAction());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::readSettings() {
|
|
||||||
QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
|
|
||||||
const QByteArray geometry = settings.value("geometry", QByteArray()).toByteArray();
|
|
||||||
if (geometry.isEmpty()) {
|
|
||||||
const QRect availableGeometry = QApplication::desktop()->availableGeometry(this);
|
|
||||||
resize(availableGeometry.width() / 3, availableGeometry.height() / 2);
|
|
||||||
move((availableGeometry.width() - width()) / 2,
|
|
||||||
(availableGeometry.height() - height()) / 2);
|
|
||||||
} else {
|
|
||||||
this->restoreGeometry(geometry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::writeSettings() {
|
|
||||||
QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
|
|
||||||
settings.setValue("geometry", this->saveGeometry());
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2017 Google Inc.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
|
||||||
* found in the LICENSE file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef MainWindow_DEFINED
|
|
||||||
#define MainWindow_DEFINED
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <QMainWindow>
|
|
||||||
|
|
||||||
#include "tools/mdbviz/Model.h"
|
|
||||||
|
|
||||||
class QLabel;
|
|
||||||
class QMenu;
|
|
||||||
class QTreeWidget;
|
|
||||||
class QTreeWidgetItem;
|
|
||||||
|
|
||||||
|
|
||||||
class MainWindow : public QMainWindow {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
MainWindow();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void openFile();
|
|
||||||
void about();
|
|
||||||
void onCurrentItemChanged(QTreeWidgetItem* cur, QTreeWidgetItem* prev);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void loadFile(const QString &fileName);
|
|
||||||
void setupOpsTaskWidget();
|
|
||||||
void presentCurrentRenderState();
|
|
||||||
|
|
||||||
|
|
||||||
void createActions();
|
|
||||||
void createStatusBar();
|
|
||||||
void createDockWindows();
|
|
||||||
|
|
||||||
void readSettings();
|
|
||||||
void writeSettings();
|
|
||||||
|
|
||||||
QImage fImage;
|
|
||||||
QLabel* fImageLabel;
|
|
||||||
|
|
||||||
QTreeWidget* fOpsTaskWidget;
|
|
||||||
|
|
||||||
QMenu* fViewMenu;
|
|
||||||
|
|
||||||
Model fModel;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,5 +0,0 @@
|
|||||||
<!DOCTYPE RCC><RCC version="1.0">
|
|
||||||
<qresource>
|
|
||||||
<file>images/open.png</file>
|
|
||||||
</qresource>
|
|
||||||
</RCC>
|
|
Loading…
Reference in New Issue
Block a user