Add simple mesh viewer
This commit is contained in:
parent
fcd90b5db4
commit
8a41337e2d
19 changed files with 275 additions and 2 deletions
|
@ -9,6 +9,9 @@ list(APPEND client_HEADERS
|
|||
image_editor/ImageViewWidget.h
|
||||
canvas/CanvasView.h
|
||||
canvas/CanvasController.h
|
||||
mesh_viewer/MeshViewerView.h
|
||||
mesh_viewer/MeshViewerController.h
|
||||
mesh_viewer/MeshViewerCanvas.h
|
||||
web_client/WebClientView.h)
|
||||
|
||||
|
||||
|
@ -20,6 +23,9 @@ list(APPEND client_LIB_INCLUDES
|
|||
audio_editor/AudioEditorView.cpp
|
||||
image_editor/ImageEditorView.cpp
|
||||
image_editor/ImageViewWidget.cpp
|
||||
mesh_viewer/MeshViewerView.cpp
|
||||
mesh_viewer/MeshViewerController.cpp
|
||||
mesh_viewer/MeshViewerCanvas.cpp
|
||||
canvas/CanvasView.cpp
|
||||
canvas/CanvasController.cpp
|
||||
web_client/WebClientView.cpp
|
||||
|
@ -42,6 +48,7 @@ target_include_directories(sample_gui PUBLIC
|
|||
"${CMAKE_CURRENT_SOURCE_DIR}/image_editor"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/web_client"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/canvas"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/mesh_viewer"
|
||||
)
|
||||
target_link_libraries(sample_gui PUBLIC client windows console core network database geometry audio web)
|
||||
set_property(TARGET sample_gui PROPERTY FOLDER apps)
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "ImageEditorView.h"
|
||||
#include "WebClientView.h"
|
||||
#include "CanvasView.h"
|
||||
#include "MeshViewerView.h"
|
||||
|
||||
#include "TabbedPanelWidget.h"
|
||||
#include "TopBar.h"
|
||||
|
@ -54,6 +55,10 @@ void MediaTool::initializeViews()
|
|||
canvas->setName("CanvasView");
|
||||
tabbedPanel->addPanel(std::move(canvas), "Canvas");
|
||||
|
||||
auto mesh = MeshViewerView::Create();
|
||||
mesh->setName("MeshViewer");
|
||||
tabbedPanel->addPanel(std::move(mesh), "Mesh Viewer");
|
||||
|
||||
auto topBar = TopBar::Create();
|
||||
auto statusBar = StatusBar::Create();
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
CanvasView::CanvasView()
|
||||
: mController(CanvasController::Create())
|
||||
{
|
||||
std::cout << "Creatin canvas" << std::endl;
|
||||
initialize();
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
ImageViewWidget::ImageViewWidget()
|
||||
{
|
||||
std::cout << "Creating image view widget" << std::endl;
|
||||
mName = "ImageViewWidget";
|
||||
}
|
||||
|
||||
|
|
0
apps/sample-gui/mesh_viewer/MeshViewerCanvas.cpp
Normal file
0
apps/sample-gui/mesh_viewer/MeshViewerCanvas.cpp
Normal file
0
apps/sample-gui/mesh_viewer/MeshViewerCanvas.h
Normal file
0
apps/sample-gui/mesh_viewer/MeshViewerCanvas.h
Normal file
0
apps/sample-gui/mesh_viewer/MeshViewerController.cpp
Normal file
0
apps/sample-gui/mesh_viewer/MeshViewerController.cpp
Normal file
0
apps/sample-gui/mesh_viewer/MeshViewerController.h
Normal file
0
apps/sample-gui/mesh_viewer/MeshViewerController.h
Normal file
65
apps/sample-gui/mesh_viewer/MeshViewerView.cpp
Normal file
65
apps/sample-gui/mesh_viewer/MeshViewerView.cpp
Normal file
|
@ -0,0 +1,65 @@
|
|||
#include "MeshViewerView.h"
|
||||
|
||||
#include "MeshNode.h"
|
||||
#include "TransformNode.h"
|
||||
#include "AbstractMesh.h"
|
||||
#include "MeshPrimitives.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
std::unique_ptr<MeshViewerView> MeshViewerView::Create()
|
||||
{
|
||||
return std::make_unique<MeshViewerView>();
|
||||
}
|
||||
|
||||
MeshViewerView::~MeshViewerView()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
MeshViewerView::MeshViewerView()
|
||||
{
|
||||
mName = "MeshViewerView";
|
||||
mBackgroundColor = {204, 204, 255};
|
||||
}
|
||||
|
||||
void MeshViewerView::doPaint(const PaintEvent* event)
|
||||
{
|
||||
if (!mVisible)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mMeshNode)
|
||||
{
|
||||
mMeshNode = std::make_unique<MeshNode>(mLocation);
|
||||
mMeshNode->setName(mName + "_MeshNode");
|
||||
|
||||
mMeshNode->setWidth(mSize.mWidth);
|
||||
mMeshNode->setHeight(mSize.mHeight);
|
||||
|
||||
mMeshNode->setFillColor(mBackgroundColor);
|
||||
|
||||
mRootNode->addChild(mMeshNode.get());
|
||||
}
|
||||
|
||||
if (mTransformDirty)
|
||||
{
|
||||
mMeshNode->setLocation(mLocation);
|
||||
mMeshNode->setWidth(mSize.mWidth);
|
||||
mMeshNode->setHeight(mSize.mHeight);
|
||||
}
|
||||
|
||||
if (mMaterialDirty)
|
||||
{
|
||||
mMeshNode->setFillColor(mBackgroundColor);
|
||||
}
|
||||
|
||||
if (!mMesh)
|
||||
{
|
||||
auto mesh = MeshPrimitives::buildRectangleAsTriMesh();
|
||||
mMesh = std::move(mesh);
|
||||
|
||||
mMeshNode->setMesh(mMesh.get());
|
||||
}
|
||||
}
|
19
apps/sample-gui/mesh_viewer/MeshViewerView.h
Normal file
19
apps/sample-gui/mesh_viewer/MeshViewerView.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
|
||||
#include "Widget.h"
|
||||
|
||||
class MeshNode;
|
||||
class AbstractMesh;
|
||||
|
||||
class MeshViewerView : public Widget
|
||||
{
|
||||
public:
|
||||
MeshViewerView();
|
||||
~MeshViewerView();
|
||||
static std::unique_ptr<MeshViewerView> Create();
|
||||
void doPaint(const PaintEvent* event) override;
|
||||
private:
|
||||
|
||||
std::unique_ptr<AbstractMesh> mMesh;
|
||||
std::unique_ptr<MeshNode> mMeshNode;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue