lower the highlighting of selected SM_items and change the color system in VSA.

This commit is contained in:
Maxime Gimeno 2019-04-25 15:00:26 +02:00
parent 7beb5018e4
commit fedc3eabef
7 changed files with 20 additions and 310 deletions

View File

@ -44,7 +44,6 @@ qt5_wrap_ui(basicUI_FILES Surface_mesh_approximation_dockwidget.ui)
polyhedron_demo_plugin(surface_mesh_approximation_plugin
Surface_mesh_approximation_plugin
${basicUI_FILES}
Color_cheat_sheet
VSA_wrapper)
target_link_libraries(surface_mesh_approximation_plugin
PUBLIC

View File

@ -1,260 +0,0 @@
#include "Color_cheat_sheet.h"
const unsigned char Color_cheat_sheet::m_colors[256][3] = {
{0, 0, 0},
{128, 0, 0},
{0, 128, 0},
{128, 128, 0},
{0, 0, 128},
{128, 0, 128},
{0, 128, 128},
{192, 192, 192},
{128, 128, 128},
{255, 0, 0},
{0, 255, 0},
{255, 255, 0},
{0, 0, 255},
{255, 0, 255},
{0, 255, 255},
{255, 255, 255},
{0, 0, 0},
{0, 0, 95},
{0, 0, 135},
{0, 0, 175},
{0, 0, 215},
{0, 0, 255},
{0, 95, 0},
{0, 95, 95},
{0, 95, 135},
{0, 95, 175},
{0, 95, 215},
{0, 95, 255},
{0, 135, 0},
{0, 135, 95},
{0, 135, 135},
{0, 135, 175},
{0, 135, 215},
{0, 135, 255},
{0, 175, 0},
{0, 175, 95},
{0, 175, 135},
{0, 175, 175},
{0, 175, 215},
{0, 175, 255},
{0, 215, 0},
{0, 215, 95},
{0, 215, 135},
{0, 215, 175},
{0, 215, 215},
{0, 215, 255},
{0, 255, 0},
{0, 255, 95},
{0, 255, 135},
{0, 255, 175},
{0, 255, 215},
{0, 255, 255},
{95, 0, 0},
{95, 0, 95},
{95, 0, 135},
{95, 0, 175},
{95, 0, 215},
{95, 0, 255},
{95, 95, 0},
{95, 95, 95},
{95, 95, 135},
{95, 95, 175},
{95, 95, 215},
{95, 95, 255},
{95, 135, 0},
{95, 135, 95},
{95, 135, 135},
{95, 135, 175},
{95, 135, 215},
{95, 135, 255},
{95, 175, 0},
{95, 175, 95},
{95, 175, 135},
{95, 175, 175},
{95, 175, 215},
{95, 175, 255},
{95, 215, 0},
{95, 215, 95},
{95, 215, 135},
{95, 215, 175},
{95, 215, 215},
{95, 215, 255},
{95, 255, 0},
{95, 255, 95},
{95, 255, 135},
{95, 255, 175},
{95, 255, 215},
{95, 255, 255},
{135, 0, 0},
{135, 0, 95},
{135, 0, 135},
{135, 0, 175},
{135, 0, 215},
{135, 0, 255},
{135, 95, 0},
{135, 95, 95},
{135, 95, 135},
{135, 95, 175},
{135, 95, 215},
{135, 95, 255},
{135, 135, 0},
{135, 135, 95},
{135, 135, 135},
{135, 135, 175},
{135, 135, 215},
{135, 135, 255},
{135, 175, 0},
{135, 175, 95},
{135, 175, 135},
{135, 175, 175},
{135, 175, 215},
{135, 175, 255},
{135, 215, 0},
{135, 215, 95},
{135, 215, 135},
{135, 215, 175},
{135, 215, 215},
{135, 215, 255},
{135, 255, 0},
{135, 255, 95},
{135, 255, 135},
{135, 255, 175},
{135, 255, 215},
{135, 255, 255},
{175, 0, 0},
{175, 0, 95},
{175, 0, 135},
{175, 0, 175},
{175, 0, 215},
{175, 0, 255},
{175, 95, 0},
{175, 95, 95},
{175, 95, 135},
{175, 95, 175},
{175, 95, 215},
{175, 95, 255},
{175, 135, 0},
{175, 135, 95},
{175, 135, 135},
{175, 135, 175},
{175, 135, 215},
{175, 135, 255},
{175, 175, 0},
{175, 175, 95},
{175, 175, 135},
{175, 175, 175},
{175, 175, 215},
{175, 175, 255},
{175, 215, 0},
{175, 215, 95},
{175, 215, 135},
{175, 215, 175},
{175, 215, 215},
{175, 215, 255},
{175, 255, 0},
{175, 255, 95},
{175, 255, 135},
{175, 255, 175},
{175, 255, 215},
{175, 255, 255},
{215, 0, 0},
{215, 0, 95},
{215, 0, 135},
{215, 0, 175},
{215, 0, 215},
{215, 0, 255},
{215, 95, 0},
{215, 95, 95},
{215, 95, 135},
{215, 95, 175},
{215, 95, 215},
{215, 95, 255},
{215, 135, 0},
{215, 135, 95},
{215, 135, 135},
{215, 135, 175},
{215, 135, 215},
{215, 135, 255},
{215, 175, 0},
{215, 175, 95},
{215, 175, 135},
{215, 175, 175},
{215, 175, 215},
{215, 175, 255},
{215, 215, 0},
{215, 215, 95},
{215, 215, 135},
{215, 215, 175},
{215, 215, 215},
{215, 215, 255},
{215, 255, 0},
{215, 255, 95},
{215, 255, 135},
{215, 255, 175},
{215, 255, 215},
{215, 255, 255},
{255, 0, 0},
{255, 0, 95},
{255, 0, 135},
{255, 0, 175},
{255, 0, 215},
{255, 0, 255},
{255, 95, 0},
{255, 95, 95},
{255, 95, 135},
{255, 95, 175},
{255, 95, 215},
{255, 95, 255},
{255, 135, 0},
{255, 135, 95},
{255, 135, 135},
{255, 135, 175},
{255, 135, 215},
{255, 135, 255},
{255, 175, 0},
{255, 175, 95},
{255, 175, 135},
{255, 175, 175},
{255, 175, 215},
{255, 175, 255},
{255, 215, 0},
{255, 215, 95},
{255, 215, 135},
{255, 215, 175},
{255, 215, 215},
{255, 215, 255},
{255, 255, 0},
{255, 255, 95},
{255, 255, 135},
{255, 255, 175},
{255, 255, 215},
{255, 255, 255},
{8, 8, 8},
{18, 18, 18},
{28, 28, 28},
{38, 38, 38},
{48, 48, 48},
{58, 58, 58},
{68, 68, 68},
{78, 78, 78},
{88, 88, 88},
{98, 98, 98},
{108, 108, 108},
{118, 118, 118},
{128, 128, 128},
{138, 138, 138},
{148, 148, 148},
{158, 158, 158},
{168, 168, 168},
{178, 178, 178},
{188, 188, 188},
{198, 198, 198},
{208, 208, 208},
{218, 218, 218},
{228, 228, 228},
{238, 238, 238},
};

View File

@ -1,35 +0,0 @@
#ifndef COLOR_CHEAT_SHEET_H
#define COLOR_CHEAT_SHEET_H
#include <cstddef>
#include <QtCore/qcompilerdetection.h>
// 256 color cheat sheet
// Source: https://jonasjacek.github.io/colors/
#ifdef surface_mesh_approximation_plugin_EXPORTS
#define COLOR_CHEAT_SHEET_EXPORT Q_DECL_EXPORT
#else
#define COLOR_CHEAT_SHEET_EXPORT Q_DECL_IMPORT
#endif
class COLOR_CHEAT_SHEET_EXPORT Color_cheat_sheet
{
public:
static const unsigned char &r(const std::size_t &i) {
return m_colors[i][0];
}
static const unsigned char &g(const std::size_t &i) {
return m_colors[i][1];
}
static const unsigned char &b(const std::size_t &i) {
return m_colors[i][2];
}
private:
static const unsigned char m_colors[256][3];
};
#endif // COLOR_CHEAT_SHEET_H

View File

@ -60,9 +60,8 @@ std::size_t VSA_wrapper::add_one_proxy() {
break;
}
if (nb_added == 1) {
const std::size_t c = rand_0_255();
m_proxy_colors.push_back(QColor::fromRgb(
Color_cheat_sheet::r(c), Color_cheat_sheet::g(c), Color_cheat_sheet::b(c)));
const std::size_t h = (rand_0_310()+ 340)%359, s = rand_70_255();
m_proxy_colors.push_back(QColor::fromHsvF(h/359.0,s/255.0,1.0));
}
return nb_added;
@ -95,9 +94,8 @@ bool VSA_wrapper::split(const std::size_t px_idx, const std::size_t n, const std
}
if (splitted) {
for (std::size_t i = m_proxy_colors.size(); i < number_of_proxies(); ++i) {
const std::size_t c = rand_0_255();
m_proxy_colors.push_back(QColor::fromRgb(
Color_cheat_sheet::r(c), Color_cheat_sheet::g(c), Color_cheat_sheet::b(c)));
const std::size_t h = (rand_0_310()+ 340)%359,s=rand_70_255();
m_proxy_colors.push_back(QColor::fromHsvF(h/359.0,s/255.0,1.0));
}
}

View File

@ -8,7 +8,8 @@
#include <QColor>
#include "SMesh_type.h"
#include "Color_cheat_sheet.h"
//#include "Color_cheat_sheet.h"
#include "Color_map.h"
#ifdef surface_mesh_approximation_plugin_EXPORTS
#define VSA_WRAPPER_EXPORT Q_DECL_EXPORT
@ -96,9 +97,15 @@ class VSA_WRAPPER_EXPORT VSA_wrapper {
Compact_metric, EPICK> Compact_approx;
#endif
std::size_t rand_0_255() {
return static_cast<std::size_t>(std::rand() % 255);
std::size_t rand_0_310() {
return static_cast<std::size_t>(std::rand() % 310);
}
std::size_t rand_70_255() {
return static_cast<std::size_t>(std::rand() % 185 + 70);
}
public:
enum Metric { L21, L2, Compact };
@ -155,10 +162,11 @@ public:
// generate proxy colors
m_proxy_colors.clear();
m_proxy_colors.reserve(number_of_proxies());
for (std::size_t i = 0; i < number_of_proxies(); ++i) {
const std::size_t c = rand_0_255();
m_proxy_colors.push_back(QColor::fromRgb(
Color_cheat_sheet::r(c), Color_cheat_sheet::g(c), Color_cheat_sheet::b(c)));
const std::size_t h = (rand_0_310()+ 340)%360,s=rand_70_255();
m_proxy_colors.push_back(QColor::fromHsvF(h/359.0,s/255.0,1.0));
}
m_initialized = true;

View File

@ -63,7 +63,7 @@ void main(void) {
highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec;
vec4 ret_color = vec4((my_color*light_amb).xyz + diffuse.xyz + specular.xyz,1);
if(is_selected)
gl_FragColor = vec4(ret_color.r+70.0/255.0, ret_color.g+70.0/255.0, ret_color.b+70.0/255.0, alpha);
gl_FragColor = vec4(ret_color.r+35.0/255.0, ret_color.g+35.0/255.0, ret_color.b+35.0/255.0, alpha);
else
gl_FragColor = vec4(ret_color.xyz, alpha);
}

View File

@ -64,7 +64,7 @@ void main(void) {
vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec;
vec4 ret_color = vec4((my_color*light_amb).xyz + diffuse.xyz + specular.xyz,1);
if(is_selected)
out_color = vec4(ret_color.r+70.0/255.0, ret_color.g+70.0/255.0, ret_color.b+70.0/255.0, alpha);
out_color = vec4(ret_color.r+35.0/255.0, ret_color.g+35.0/255.0, ret_color.b+35.0/255.0, alpha);
else
out_color = vec4(ret_color.xyz, alpha);
}