Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Few changes #49

Merged
merged 5 commits into from
May 22, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ project(SCHNApps
LANGUAGES CXX
)

#### CGOGN_PATH
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/CMakeOptions.txt)
include(${CMAKE_CURRENT_SOURCE_DIR}/CMakeOptions.txt)
else()
message(FATAL_ERROR "No local options file specifying CGOGN directory: CMakeOptions.txt (see CMakeOptions.txt.sample)")
endif()


list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
set(CGAL_DONT_OVERRIDE_CMAKE_FLAGS TRUE CACHE BOOL "preserve cmake flags" FORCE)

Expand All @@ -24,8 +32,6 @@ set(SCHNAPPS_SOURCE_DIR ${SCHNAPPS_PATH})

set(SCHNAPPS_EXEC_NAME schnapps)

#### CGOGN_PATH
set(CGOGN_BUILD_OR_INSTALL_PATH "${SCHNAPPS_PATH}/../CGoGN_2-build" CACHE PATH "CGoGN build or install dir")

if (EXISTS "${CGOGN_BUILD_OR_INSTALL_PATH}")
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${CGOGN_BUILD_OR_INSTALL_PATH})
Expand Down
7 changes: 7 additions & 0 deletions CMakeOptions.txt.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Example of CMakeOptions.txt file

set(CGOGN_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../cgogn)
set(CGOGN_BUILD_DIR ${CGOGN_ROOT_DIR}/build)
set(CGOGN_RELEASE_BUILD_DIR ${CGOGN_BUILD_DIR}/release)
set(CGOGN_DEBUG_BUILD_DIR ${CGOGN_BUILD_DIR}/debug)

26 changes: 25 additions & 1 deletion schnapps/core/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ uint32 View::view_count_ = 0;
View::View(const QString& name, SCHNApps* s) :
name_(name),
schnapps_(s),
background_color_(0.1f, 0.1f, 0.2f, 0.0f),
current_camera_(nullptr),
bb_min_(0.0, 0.0, 0.0),
bb_max_(0.0, 0.0, 0.0),
Expand All @@ -65,6 +66,8 @@ View::View(const QString& name, SCHNApps* s) :
{
++view_count_;

this->setAutoFillBackground(true);

this->setSnapshotFormat("BMP");
this->setSnapshotFileName(name_);
this->setSnapshotQuality(100);
Expand Down Expand Up @@ -98,6 +101,9 @@ View::View(const QString& name, SCHNApps* s) :
dialog_cameras_->check(current_camera_->get_name(), Qt::Checked);

connect(schnapps_, SIGNAL(schnapps_closing()), this, SLOT(close_dialogs()));

color_dial_ = new QColorDialog(background_color_, nullptr);
connect(color_dial_, SIGNAL(accepted()), this, SLOT(color_selected()));
}

View::~View()
Expand Down Expand Up @@ -326,7 +332,8 @@ void View::init()
this->setCamera(current_camera_);
// delete c;

glClearColor(0.1f, 0.1f, 0.2f, 0.0f);
glClearColor(background_color_.redF(), background_color_.greenF(), background_color_.blueF(), background_color_.alphaF());


frame_drawer_ = cgogn::make_unique<cgogn::rendering::DisplayListDrawer>();
frame_drawer_renderer_ = frame_drawer_->generate_renderer();
Expand All @@ -345,6 +352,10 @@ void View::init()
button_area_ = new ViewButtonArea(this);
button_area_->set_top_right_position(this->width(), 0);

color_button_ = new ViewButton(":icons/icons/color.png", this);
button_area_->add_button(color_button_);
connect(color_button_, SIGNAL(clicked(int, int, int, int)), this, SLOT(ui_color_view(int, int, int, int)));

Vsplit_button_ = new ViewButton(":icons/icons/Vsplit.png", this);
button_area_->add_button(Vsplit_button_);
connect(Vsplit_button_, SIGNAL(clicked(int, int, int, int)), this, SLOT(ui_vertical_split_view(int, int, int, int)));
Expand Down Expand Up @@ -385,6 +396,8 @@ void View::preDraw()

void View::draw()
{
glClearColor(background_color_.redF(), background_color_.greenF(), background_color_.blueF(), background_color_.alphaF());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plutôt que d'appeler glClearColor dans chaque draw, est-ce qu'on ne peut pas l'appeler uniquement dans la méthode color_selected c'est-à-dire seulement quand la couleur du background change ? (il faudra peut-être faire un this->makeCurrent() avant).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok


glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
Expand Down Expand Up @@ -724,6 +737,11 @@ void View::update_bb()
emit(bb_changed());
}

void View::color_selected()
{
background_color_ = color_dial_->currentColor();
}

void View::ui_vertical_split_view(int, int, int, int)
{
schnapps_->split_view(name_, Qt::Horizontal);
Expand All @@ -739,6 +757,12 @@ void View::ui_close_view(int, int, int, int)
schnapps_->remove_view(name_);
}

void View::ui_color_view(int, int, int, int)
{
color_dial_->show();
color_dial_->setCurrentColor(background_color_);
}

void View::ui_maps_list_view(int, int, int globalX, int globalY)
{
if (dialog_maps_->isHidden())
Expand Down
9 changes: 9 additions & 0 deletions schnapps/core/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#ifndef SCHNAPPS_CORE_VIEW_H_
#define SCHNAPPS_CORE_VIEW_H_

#include <QColorDialog>

#include <schnapps/core/dll.h>
#include <schnapps/core/types.h>

Expand Down Expand Up @@ -254,9 +256,12 @@ private slots:

void update_bb();

void color_selected();

void ui_vertical_split_view(int x, int y, int globalX, int globalY);
void ui_horizontal_split_view(int x, int y, int globalX, int globalY);
void ui_close_view(int x, int y, int globalX, int globalY);
void ui_color_view(int x, int y, int globalX, int globalY);

void ui_maps_list_view(int x, int y, int globalX, int globalY);
void ui_plugins_list_view(int x, int y, int globalX, int globalY);
Expand All @@ -279,6 +284,9 @@ private slots:
QString name_;
SCHNApps* schnapps_;

QColorDialog* color_dial_;
QColor background_color_;

Camera* current_camera_;
std::list<PluginInteraction*> plugins_;
std::list<MapHandlerGen*> maps_;
Expand All @@ -289,6 +297,7 @@ private slots:
ViewButtonArea* button_area_;

ViewButton* close_button_;
ViewButton* color_button_;
ViewButton* Vsplit_button_;
ViewButton* Hsplit_button_;

Expand Down
13 changes: 10 additions & 3 deletions schnapps/plugins/volume_render/volume_render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,16 @@ void Plugin_VolumeRender::draw_map(View* view, MapHandlerGen* map, const QMatrix
{
if (p.get_position_vbo())
{
p.shader_simple_color_param_->bind(proj, mv);
map->draw(cgogn::rendering::LINES);
p.shader_simple_color_param_->release();
if(p.volume_drawer_rend_)
{
p.volume_drawer_rend_->draw_edges(proj, mv, view);
}
else
{
p.shader_simple_color_param_->bind(proj, mv);
map->draw(cgogn::rendering::LINES);
p.shader_simple_color_param_->release();
}
}
}

Expand Down
Binary file added schnapps/resources/icons/color.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
155 changes: 155 additions & 0 deletions schnapps/resources/icons/color.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions schnapps/resources/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
<file>icons/arrow_up.png</file>
<file>icons/minus.png</file>
<file>icons/plus.png</file>
<file>icons/color.png</file>
</qresource>
</RCC>