-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added QtMinimal and QtMinimal_GLWidget
- Loading branch information
Showing
13 changed files
with
1,305 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
project(QtMinimal) | ||
|
||
|
||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CEE_STANDARD_CXX_FLAGS}") | ||
|
||
if (CMAKE_COMPILER_IS_GNUCXX) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-long-long") | ||
endif() | ||
|
||
|
||
find_package(OpenGL) | ||
|
||
if (CEE_USE_QT6) | ||
find_package(Qt6 COMPONENTS REQUIRED OpenGLWidgets) | ||
set(QT_LIBRARIES Qt6::OpenGLWidgets ) | ||
elseif (CEE_USE_QT5) | ||
find_package(Qt5 REQUIRED COMPONENTS Widgets) | ||
set(QT_LIBRARIES Qt5::Widgets) | ||
else() | ||
message(FATAL_ERROR "No supported Qt version selected for build") | ||
endif() | ||
|
||
|
||
include_directories(${LibCore_SOURCE_DIR}) | ||
include_directories(${LibGeometry_SOURCE_DIR}) | ||
include_directories(${LibRender_SOURCE_DIR}) | ||
include_directories(${LibViewing_SOURCE_DIR}) | ||
include_directories(${LibGuiQt_SOURCE_DIR}) | ||
|
||
set(CEE_LIBS LibGuiQt LibViewing LibRender LibGeometry LibCore) | ||
|
||
|
||
set(CEE_CODE_FILES | ||
QMMain.cpp | ||
QMMainWindow.cpp | ||
QMMainWindow.h | ||
QMWidget.cpp | ||
QMWidget.h | ||
) | ||
|
||
# Headers that need MOCing | ||
set(MOC_HEADER_FILES | ||
QMMainWindow.h | ||
) | ||
|
||
if (CEE_USE_QT6) | ||
qt_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES}) | ||
elseif (CEE_USE_QT5) | ||
qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES}) | ||
endif() | ||
|
||
add_executable(${PROJECT_NAME} ${CEE_CODE_FILES} ${MOC_SOURCE_FILES}) | ||
target_link_libraries(${PROJECT_NAME} ${CEE_LIBS} ${OPENGL_LIBRARIES} ${QT_LIBRARIES}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
//################################################################################################## | ||
// | ||
// Custom Visualization Core library | ||
// Copyright (C) 2011-2013 Ceetron AS | ||
// | ||
// This library may be used under the terms of either the GNU General Public License or | ||
// the GNU Lesser General Public License as follows: | ||
// | ||
// GNU General Public License Usage | ||
// This library is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This library is distributed in the hope that it will be useful, but WITHOUT ANY | ||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
// FITNESS FOR A PARTICULAR PURPOSE. | ||
// | ||
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>> | ||
// for more details. | ||
// | ||
// GNU Lesser General Public License Usage | ||
// This library is free software; you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation; either version 2.1 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This library is distributed in the hope that it will be useful, but WITHOUT ANY | ||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
// FITNESS FOR A PARTICULAR PURPOSE. | ||
// | ||
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>> | ||
// for more details. | ||
// | ||
//################################################################################################## | ||
|
||
#include "cvfLibCore.h" | ||
|
||
#include "QMMainWindow.h" | ||
|
||
#include <QApplication> | ||
|
||
#include <locale.h> | ||
|
||
|
||
//-------------------------------------------------------------------------------------------------- | ||
/// | ||
//-------------------------------------------------------------------------------------------------- | ||
int main(int argc, char *argv[]) | ||
{ | ||
cvf::LogManager* logManager = cvf::LogManager::instance(); | ||
logManager->logger("cee.cvf.OpenGL")->setLevel(cvf::Logger::LL_DEBUG); | ||
|
||
QApplication app(argc, argv); | ||
|
||
// On Linux, Qt will use the system locale, force number formatting settings back to "C" locale | ||
setlocale(LC_NUMERIC,"C"); | ||
|
||
QMMainWindow window; | ||
QString platform = cvf::System::is64Bit() ? "(64bit)" : "(32bit)"; | ||
window.setWindowTitle("Qt Minimal " + platform); | ||
window.resize(1000, 800);; | ||
window.show(); | ||
|
||
return app.exec(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
//################################################################################################## | ||
// | ||
// Custom Visualization Core library | ||
// Copyright (C) 2011-2013 Ceetron AS | ||
// | ||
// This library may be used under the terms of either the GNU General Public License or | ||
// the GNU Lesser General Public License as follows: | ||
// | ||
// GNU General Public License Usage | ||
// This library is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This library is distributed in the hope that it will be useful, but WITHOUT ANY | ||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
// FITNESS FOR A PARTICULAR PURPOSE. | ||
// | ||
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>> | ||
// for more details. | ||
// | ||
// GNU Lesser General Public License Usage | ||
// This library is free software; you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation; either version 2.1 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This library is distributed in the hope that it will be useful, but WITHOUT ANY | ||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
// FITNESS FOR A PARTICULAR PURPOSE. | ||
// | ||
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>> | ||
// for more details. | ||
// | ||
//################################################################################################## | ||
|
||
#include "cvfLibCore.h" | ||
#include "cvfLibRender.h" | ||
#include "cvfLibGeometry.h" | ||
#include "cvfLibViewing.h" | ||
|
||
#include "QMMainWindow.h" | ||
#include "QMWidget.h" | ||
|
||
#include <QFrame> | ||
#include <QHBoxLayout> | ||
#include <QAction> | ||
#include <QMenu> | ||
#include <QMenuBar> | ||
|
||
|
||
|
||
//-------------------------------------------------------------------------------------------------- | ||
/// | ||
//-------------------------------------------------------------------------------------------------- | ||
QMMainWindow::QMMainWindow() | ||
{ | ||
QFrame* mainFrame = new QFrame; | ||
QHBoxLayout* frameLayout = new QHBoxLayout(mainFrame); | ||
setCentralWidget(mainFrame); | ||
|
||
m_contextGroup = new cvf::OpenGLContextGroup; | ||
|
||
// Pass pointer to ourselves to get notified when the vizWidget is ready for use and we can load our default scene | ||
m_vizWidget = new QMWidget(m_contextGroup.p(), mainFrame, this); | ||
|
||
m_vizWidget->setFocus(); | ||
frameLayout->addWidget(m_vizWidget); | ||
|
||
QMenu* menu = menuBar()->addMenu("&Scenes"); | ||
menu->addAction("Default Scene", this, SLOT(slotCreateDefaultScene())); | ||
menu->addSeparator(); | ||
menu->addAction("Clear Scene", this, SLOT(slotClearScene())); | ||
} | ||
|
||
//-------------------------------------------------------------------------------------------------- | ||
/// | ||
//-------------------------------------------------------------------------------------------------- | ||
void QMMainWindow::handleVizWidgetIsOpenGLReady() | ||
{ | ||
slotCreateDefaultScene(); | ||
} | ||
|
||
//-------------------------------------------------------------------------------------------------- | ||
/// | ||
//-------------------------------------------------------------------------------------------------- | ||
void QMMainWindow::slotCreateDefaultScene() | ||
{ | ||
cvf::ref<cvf::ModelBasicList> model = new cvf::ModelBasicList; | ||
|
||
const bool useShaders = true; | ||
|
||
CVF_ASSERT(m_contextGroup->isContextGroupInitialized()); | ||
cvf::ShaderProgramGenerator spGen("SimpleHeadlight", cvf::ShaderSourceProvider::instance()); | ||
spGen.configureStandardHeadlightColor(); | ||
cvf::ref<cvf::ShaderProgram> shaderProg = spGen.generate(); | ||
|
||
{ | ||
cvf::GeometryBuilderDrawableGeo builder; | ||
cvf::GeometryUtils::createSphere(2, 10, 10, &builder); | ||
|
||
cvf::ref<cvf::Effect> eff = new cvf::Effect; | ||
if (useShaders) | ||
{ | ||
eff->setShaderProgram(shaderProg.p()); | ||
eff->setUniform(new cvf::UniformFloat("u_color", cvf::Color4f(cvf::Color3::GREEN))); | ||
} | ||
else | ||
{ | ||
eff->setRenderState(new cvf::RenderStateMaterial_FF(cvf::Color3::BLUE)); | ||
} | ||
|
||
cvf::ref<cvf::Part> part = new cvf::Part; | ||
part->setName("MySphere"); | ||
part->setDrawable(0, builder.drawableGeo().p()); | ||
part->setEffect(eff.p()); | ||
|
||
model->addPart(part.p()); | ||
} | ||
|
||
{ | ||
cvf::GeometryBuilderDrawableGeo builder; | ||
cvf::GeometryUtils::createBox(cvf::Vec3f(5, 0, 0), 2, 3, 4, &builder); | ||
|
||
cvf::ref<cvf::Effect> eff = new cvf::Effect; | ||
if (useShaders) | ||
{ | ||
eff->setShaderProgram(shaderProg.p()); | ||
eff->setUniform(new cvf::UniformFloat("u_color", cvf::Color4f(cvf::Color3::YELLOW))); | ||
} | ||
else | ||
{ | ||
eff->setRenderState(new cvf::RenderStateMaterial_FF(cvf::Color3::RED)); | ||
} | ||
|
||
cvf::ref<cvf::Part> part = new cvf::Part; | ||
part->setName("MyBox"); | ||
part->setDrawable(0, builder.drawableGeo().p()); | ||
part->setEffect(eff.p()); | ||
|
||
model->addPart(part.p()); | ||
} | ||
|
||
model->updateBoundingBoxesRecursive(); | ||
|
||
cvf::ref<cvf::Scene> scene = new cvf::Scene; | ||
scene->addModel(model.p()); | ||
|
||
CVF_ASSERT(m_vizWidget); | ||
m_vizWidget->setScene(scene.p()); | ||
} | ||
|
||
|
||
//-------------------------------------------------------------------------------------------------- | ||
/// | ||
//-------------------------------------------------------------------------------------------------- | ||
void QMMainWindow::slotClearScene() | ||
{ | ||
CVF_ASSERT(m_vizWidget); | ||
m_vizWidget->setScene(NULL); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
//################################################################################################## | ||
// | ||
// Custom Visualization Core library | ||
// Copyright (C) 2011-2013 Ceetron AS | ||
// | ||
// This library may be used under the terms of either the GNU General Public License or | ||
// the GNU Lesser General Public License as follows: | ||
// | ||
// GNU General Public License Usage | ||
// This library is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This library is distributed in the hope that it will be useful, but WITHOUT ANY | ||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
// FITNESS FOR A PARTICULAR PURPOSE. | ||
// | ||
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>> | ||
// for more details. | ||
// | ||
// GNU Lesser General Public License Usage | ||
// This library is free software; you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation; either version 2.1 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This library is distributed in the hope that it will be useful, but WITHOUT ANY | ||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
// FITNESS FOR A PARTICULAR PURPOSE. | ||
// | ||
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>> | ||
// for more details. | ||
// | ||
//################################################################################################## | ||
|
||
#pragma once | ||
|
||
#include "cvfBase.h" | ||
#include "cvfObject.h" | ||
#include "cvfOpenGLContextGroup.h" | ||
|
||
#include <QMainWindow> | ||
#include <QPointer> | ||
|
||
class QMWidget; | ||
|
||
|
||
//================================================================================================== | ||
// | ||
// | ||
// | ||
//================================================================================================== | ||
class QMMainWindow : public QMainWindow | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
QMMainWindow(); | ||
|
||
void handleVizWidgetIsOpenGLReady(); | ||
|
||
private slots: | ||
void slotCreateDefaultScene(); | ||
void slotClearScene(); | ||
|
||
private: | ||
cvf::ref<cvf::OpenGLContextGroup> m_contextGroup; | ||
QPointer<QMWidget> m_vizWidget; | ||
}; | ||
|
Oops, something went wrong.