mirror of https://github.com/CGAL/cgal
Merge branch 'CGAL-Qt5_support-GF'
This commit is contained in:
commit
508b467203
|
|
@ -46,6 +46,8 @@ Scene::Scene()
|
|||
m_blue_ramp.build_blue();
|
||||
m_max_distance_function = (FT)0.0;
|
||||
texture = new Texture(m_grid_size,m_grid_size);
|
||||
startTimer(0);
|
||||
ready_to_cut = false;
|
||||
are_buffers_initialized = false;
|
||||
|
||||
}
|
||||
|
|
@ -1230,23 +1232,27 @@ void Scene::cut_segment_plane()
|
|||
|
||||
void Scene::cutting_plane()
|
||||
{
|
||||
switch( m_cut_plane )
|
||||
if(ready_to_cut)
|
||||
{
|
||||
case UNSIGNED_FACETS:
|
||||
return unsigned_distance_function();
|
||||
case SIGNED_FACETS:
|
||||
return signed_distance_function();
|
||||
case UNSIGNED_EDGES:
|
||||
return unsigned_distance_function_to_edges();
|
||||
case CUT_SEGMENTS:
|
||||
return cut_segment_plane();
|
||||
case NONE: // do nothing
|
||||
return;
|
||||
}
|
||||
ready_to_cut = false;
|
||||
switch( m_cut_plane )
|
||||
{
|
||||
case UNSIGNED_FACETS:
|
||||
return unsigned_distance_function();
|
||||
case SIGNED_FACETS:
|
||||
return signed_distance_function();
|
||||
case UNSIGNED_EDGES:
|
||||
return unsigned_distance_function_to_edges();
|
||||
case CUT_SEGMENTS:
|
||||
return cut_segment_plane();
|
||||
case NONE: // do nothing
|
||||
return;
|
||||
}
|
||||
|
||||
// Should not be here
|
||||
std::cerr << "Unknown cut_plane type" << std::endl;
|
||||
CGAL_assertion(false);
|
||||
// Should not be here
|
||||
std::cerr << "Unknown cut_plane type" << std::endl;
|
||||
CGAL_assertion(false);
|
||||
}
|
||||
}
|
||||
|
||||
void Scene::toggle_view_poyhedron()
|
||||
|
|
@ -1312,16 +1318,8 @@ void Scene::deactivate_cutting_plane()
|
|||
}
|
||||
void Scene::initGL(Viewer * /* viewer */)
|
||||
{
|
||||
//qDebug()<<"context from scene is valid :"<<context->isValid();
|
||||
//gl = 0;
|
||||
//gl = viewer->context()->versionFunctions<QOpenGLFunctions_3_3_Core>();
|
||||
gl = new QOpenGLFunctions_3_3_Core();
|
||||
|
||||
//if (!gl) {
|
||||
// qFatal("Could not obtain required OpenGL context version");
|
||||
// exit(1);
|
||||
//}
|
||||
if(!gl->initializeOpenGLFunctions())
|
||||
if(!gl->initializeOpenGLFunctions())
|
||||
{
|
||||
qFatal("ERROR : OpenGL Functions not initialized. Check your OpenGL Verison (should be >=3.3)");
|
||||
exit(1);
|
||||
|
|
@ -1330,3 +1328,10 @@ void Scene::initGL(Viewer * /* viewer */)
|
|||
gl->glGenTextures(1, &textureId);
|
||||
compile_shaders();
|
||||
}
|
||||
|
||||
void Scene::timerEvent(QTimerEvent *)
|
||||
{
|
||||
if(manipulatedFrame()->isSpinning())
|
||||
set_fast_distance(true);
|
||||
ready_to_cut = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ private:
|
|||
std::list<Point> m_points;
|
||||
std::list<Segment> m_segments;
|
||||
std::vector<Segment> m_cut_segments;
|
||||
bool ready_to_cut;
|
||||
|
||||
// distance functions (simple 2D arrays)
|
||||
Color_ramp m_red_ramp;
|
||||
|
|
@ -248,6 +249,10 @@ public:
|
|||
// cutting plane activation/deactivation
|
||||
void activate_cutting_plane();
|
||||
void deactivate_cutting_plane();
|
||||
|
||||
//timer sends a top when all the events are finished
|
||||
void timerEvent(QTimerEvent *);
|
||||
|
||||
|
||||
public slots:
|
||||
// cutting plane
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ void Viewer::mouseReleaseEvent(QMouseEvent* e)
|
|||
if ( m_custom_mouse )
|
||||
{
|
||||
m_pScene->set_fast_distance(false);
|
||||
|
||||
// Recompute distance function
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
m_pScene->cutting_plane();
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ void Viewer::triangulate_facet()
|
|||
|
||||
LCC::Dart_of_orbit_range<1>::const_iterator
|
||||
he_circ = lcc.darts_of_orbit<1>(dartIter).begin(),
|
||||
he_circ_end(he_circ);
|
||||
he_circ_end = lcc.darts_of_orbit<1>(dartIter).end();
|
||||
|
||||
// Iterates on the vector of facet handles
|
||||
CDT::Vertex_handle previous, first;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ public:
|
|||
static QString dumpFrame(const qglviewer::Frame&);
|
||||
|
||||
virtual bool inFastDrawing() const = 0;
|
||||
GLfloat pickMatrix_[16];
|
||||
|
||||
Q_SIGNALS:
|
||||
void selected(int);
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ void Polyhedron_demo_join_and_split_polyhedra_plugin::on_actionColorConnectedCom
|
|||
CGAL::internal::corefinement::Dummy_true(),
|
||||
marker
|
||||
);
|
||||
item->changed();
|
||||
scene->itemChanged(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ void Polyhedron_demo_self_intersection_plugin::on_actionSelfIntersection_trigger
|
|||
scene->addItem(selection_item);
|
||||
item->setRenderingMode(Wireframe);
|
||||
scene->itemChanged(item);
|
||||
scene->itemChanged(selection_item);
|
||||
}
|
||||
else
|
||||
QMessageBox::information(mw, tr("No self intersection"),
|
||||
|
|
|
|||
|
|
@ -116,13 +116,13 @@ Scene::erase(QList<int> indices)
|
|||
max_index = (std::max)(max_index, index);
|
||||
Scene_item* item = m_entries[index];
|
||||
to_be_removed.push_back(item);
|
||||
Q_EMIT itemAboutToBeDestroyed(item);
|
||||
delete item;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Q_FOREACH(Scene_item* item, to_be_removed) {
|
||||
Q_EMIT itemAboutToBeDestroyed(item);
|
||||
delete item;
|
||||
m_entries.removeAll(item);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -122,9 +122,14 @@ void Scene_item::select(double /*orig_x*/,
|
|||
void Scene_item::attrib_buffers(Viewer_interface* viewer, int program_name) const
|
||||
{
|
||||
GLint is_both_sides = 0;
|
||||
//ModelViewMatrix used for the transformation of the camera.
|
||||
QMatrix4x4 mvp_mat;
|
||||
// ModelView Matrix used for the lighting system
|
||||
QMatrix4x4 mv_mat;
|
||||
// transformation of the manipulated frame
|
||||
QMatrix4x4 f_mat;
|
||||
// used for the picking. Is Identity except while selecting an item.
|
||||
QMatrix4x4 pick_mat;
|
||||
f_mat.setToIdentity();
|
||||
//fills the MVP and MV matrices.
|
||||
GLdouble d_mat[16];
|
||||
|
|
@ -136,6 +141,10 @@ void Scene_item::attrib_buffers(Viewer_interface* viewer, int program_name) cons
|
|||
viewer->camera()->getModelViewMatrix(d_mat);
|
||||
for (int i=0; i<16; ++i)
|
||||
mv_mat.data()[i] = GLfloat(d_mat[i]);
|
||||
for (int i=0; i<16; ++i)
|
||||
pick_mat.data()[i] = viewer->pickMatrix_[i];
|
||||
|
||||
mvp_mat = pick_mat * mvp_mat;
|
||||
|
||||
viewer->glGetIntegerv(GL_LIGHT_MODEL_TWO_SIDE, &is_both_sides);
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include <QMouseEvent>
|
||||
#include <QKeyEvent>
|
||||
#include <QGLViewer/manipulatedCameraFrame.h>
|
||||
#include <QDebug>
|
||||
class Viewer_impl {
|
||||
public:
|
||||
Scene_draw_interface* scene;
|
||||
|
|
@ -46,6 +47,12 @@ Viewer::Viewer(QWidget* parent, bool antialiasing)
|
|||
tr("Selects and display context "
|
||||
"menu of the selected item"));
|
||||
#endif // QGLVIEWER_VERSION >= 2.5.0
|
||||
for(int i=0; i<16; i++)
|
||||
pickMatrix_[i]=0;
|
||||
pickMatrix_[0]=1;
|
||||
pickMatrix_[5]=1;
|
||||
pickMatrix_[10]=1;
|
||||
pickMatrix_[15]=1;
|
||||
}
|
||||
|
||||
Viewer::~Viewer()
|
||||
|
|
@ -217,7 +224,6 @@ void Viewer::postSelection(const QPoint& pixel)
|
|||
dir.x, dir.y, dir.z);
|
||||
}
|
||||
}
|
||||
|
||||
bool Viewer_interface::readFrame(QString s, qglviewer::Frame& frame)
|
||||
{
|
||||
QStringList list = s.split(" ", QString::SkipEmptyParts);
|
||||
|
|
@ -279,3 +285,70 @@ QString Viewer::dumpCameraCoordinates()
|
|||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Viewer::pickMatrix
|
||||
* Source code of gluPickMatrix slightly modified : instead of multiplying the current matrix by this value,
|
||||
* sets the viewer's pickMatrix_ so that the drawing area is only around the cursor. This is because since CGAL 4.7,
|
||||
* the drawing sustem changed to use shaders, and these need this value. pickMatrix_ is passed to the shaders in
|
||||
* Scene_item::attrib_buffers(Viewer_interface* viewer, int program_name).
|
||||
* @param x
|
||||
* @param y
|
||||
* @param width
|
||||
* @param height
|
||||
* @param viewport
|
||||
*/
|
||||
|
||||
void Viewer::pickMatrix(GLdouble x, GLdouble y, GLdouble width, GLdouble height,
|
||||
GLint viewport[4])
|
||||
{
|
||||
//GLfloat m[16];
|
||||
GLfloat sx, sy;
|
||||
GLfloat tx, ty;
|
||||
|
||||
sx = viewport[2] / width;
|
||||
sy = viewport[3] / height;
|
||||
tx = (viewport[2] + 2.0 * (viewport[0] - x)) / width;
|
||||
ty = (viewport[3] + 2.0 * (viewport[1] - y)) / height;
|
||||
|
||||
#define M(row, col) pickMatrix_[col*4+row]
|
||||
M(0, 0) = sx;
|
||||
M(0, 1) = 0.0;
|
||||
M(0, 2) = 0.0;
|
||||
M(0, 3) = tx;
|
||||
M(1, 0) = 0.0;
|
||||
M(1, 1) = sy;
|
||||
M(1, 2) = 0.0;
|
||||
M(1, 3) = ty;
|
||||
M(2, 0) = 0.0;
|
||||
M(2, 1) = 0.0;
|
||||
M(2, 2) = 1.0;
|
||||
M(2, 3) = 0.0;
|
||||
M(3, 0) = 0.0;
|
||||
M(3, 1) = 0.0;
|
||||
M(3, 2) = 0.0;
|
||||
M(3, 3) = 1.0;
|
||||
#undef M
|
||||
|
||||
//pickMatrix_[i] = m[i];
|
||||
}
|
||||
void Viewer::beginSelection(const QPoint &point)
|
||||
{
|
||||
QGLViewer::beginSelection(point);
|
||||
//set the picking matrix to allow the picking
|
||||
static GLint viewport[4];
|
||||
camera()->getViewport(viewport);
|
||||
pickMatrix(point.x(), point.y(), selectRegionWidth(), selectRegionHeight(), viewport);
|
||||
|
||||
}
|
||||
void Viewer::endSelection(const QPoint& point)
|
||||
{
|
||||
QGLViewer::endSelection(point);
|
||||
//set dthe pick matrix to Identity
|
||||
for(int i=0; i<16; i++)
|
||||
pickMatrix_[i]=0;
|
||||
pickMatrix_[0]=1;
|
||||
pickMatrix_[5]=1;
|
||||
pickMatrix_[10]=1;
|
||||
pickMatrix_[15]=1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,11 +29,13 @@ public:
|
|||
void initializeGL();
|
||||
void drawWithNames();
|
||||
void postSelection(const QPoint&);
|
||||
|
||||
void beginSelection(const QPoint &point);
|
||||
void endSelection(const QPoint &point);
|
||||
void setScene(Scene_draw_interface* scene);
|
||||
bool antiAliasing() const;
|
||||
|
||||
bool inFastDrawing() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setAntiAliasing(bool b);
|
||||
void setTwoSides(bool b);
|
||||
|
|
@ -47,6 +49,8 @@ public Q_SLOTS:
|
|||
protected:
|
||||
void mousePressEvent(QMouseEvent*);
|
||||
void keyPressEvent(QKeyEvent*);
|
||||
void pickMatrix(GLdouble x, GLdouble y, GLdouble width, GLdouble height,
|
||||
GLint viewport[4]);
|
||||
|
||||
protected:
|
||||
Viewer_impl* d;
|
||||
|
|
|
|||
|
|
@ -1558,7 +1558,7 @@ void Viewer::draw()
|
|||
drawText( width()-200, 40, tr("Shift+Wheel: Resize trackball"), fontPrompt );
|
||||
|
||||
}
|
||||
if(m_curMode != NORMAL && m_showTrackball)
|
||||
if(m_curMode != NONE && m_curMode != SELECT && m_showTrackball)
|
||||
{
|
||||
|
||||
rendering_program_spheres.bind();
|
||||
|
|
|
|||
Loading…
Reference in New Issue