mirror of https://github.com/CGAL/cgal
Don't select clipped points
This commit is contained in:
parent
2a261c1d2f
commit
1bd785ae44
|
|
@ -85,8 +85,6 @@ void Clipping_box_plugin::init(QMainWindow* mainWindow, CGAL::Three::Scene_inter
|
|||
connect(dock_widget->pushButton, SIGNAL(toggled(bool)),
|
||||
this, SLOT(clip(bool)));
|
||||
|
||||
CGAL::QGLViewer* viewer = *CGAL::QGLViewer::QGLViewerPool().begin();
|
||||
|
||||
item = NULL;
|
||||
visualizer = NULL;
|
||||
shift_pressing = false;
|
||||
|
|
@ -126,7 +124,6 @@ void Clipping_box_plugin::clipbox()
|
|||
this, &Clipping_box_plugin::tab_change);
|
||||
item->setName("Clipping box");
|
||||
item->setRenderingMode(FlatPlusEdges);
|
||||
CGAL::QGLViewer* viewer = *CGAL::QGLViewer::QGLViewerPool().begin();
|
||||
scene->addItem(item);
|
||||
actionClipbox->setEnabled(false);
|
||||
|
||||
|
|
|
|||
|
|
@ -568,6 +568,31 @@ protected:
|
|||
}
|
||||
|
||||
protected Q_SLOTS:
|
||||
|
||||
bool is_inside(QVector4D* box, const Kernel::Point_3& p)
|
||||
{
|
||||
if(!static_cast<CGAL::Three::Viewer_interface*>(CGAL::QGLViewer::QGLViewerPool().first())->isClipping()){
|
||||
return true;
|
||||
}
|
||||
double x = p.x(),
|
||||
y = p.y(),
|
||||
z = p.z();
|
||||
|
||||
if(box[0][0]*x+box[0][1]*y+box[0][2]*z+box[0][3]>0)
|
||||
return false;
|
||||
if(box[1][0]*x+box[1][1]*y+box[1][2]*z+box[1][3]>0)
|
||||
return false;
|
||||
if(box[2][0]*x+box[2][1]*y+box[2][2]*z+box[2][3]>0)
|
||||
return false;
|
||||
if(box[3][0]*x+box[3][1]*y+box[3][2]*z+box[3][3]>0)
|
||||
return false;
|
||||
if(box[4][0]*x+box[4][1]*y+box[4][2]*z+box[4][3]>0)
|
||||
return false;
|
||||
if(box[5][0]*x+box[5][1]*y+box[5][2]*z+box[5][3]>0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void select_points()
|
||||
{
|
||||
Scene_points_with_normal_item* point_set_item = getSelectedItem<Scene_points_with_normal_item>();
|
||||
|
|
@ -604,6 +629,15 @@ protected Q_SLOTS:
|
|||
[&] (const Point_set::Index& idx) -> bool
|
||||
{ return !selected_bitmap[idx]; }));
|
||||
|
||||
QVector4D* clipbox = static_cast<CGAL::Three::Viewer_interface*>(viewer)->clipBox();
|
||||
for(Point_set::iterator it = points->first_selected();
|
||||
it != points->end();
|
||||
++it)
|
||||
{
|
||||
if(!is_inside(clipbox, points->point(*it)))
|
||||
points->unselect(*it);
|
||||
}
|
||||
|
||||
point_set_item->invalidateOpenGLBuffers();
|
||||
point_set_item->itemChanged();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1683,5 +1683,15 @@ void Viewer::setGlPointSize(const GLfloat &p) { d->gl_point_size = p; }
|
|||
|
||||
const GLfloat& Viewer::getGlPointSize() const { return d->gl_point_size; }
|
||||
|
||||
QVector4D* Viewer::clipBox() const
|
||||
{
|
||||
return d->clipbox;
|
||||
}
|
||||
|
||||
bool Viewer::isClipping() const
|
||||
{
|
||||
return d->clipping;
|
||||
}
|
||||
|
||||
#include "Viewer.moc"
|
||||
|
||||
|
|
|
|||
|
|
@ -154,6 +154,8 @@ public:
|
|||
float total_pass()Q_DECL_OVERRIDE;
|
||||
const GLfloat& getGlPointSize()const Q_DECL_OVERRIDE;
|
||||
void setGlPointSize(const GLfloat& p) Q_DECL_OVERRIDE;
|
||||
QVector4D* clipBox() const Q_DECL_OVERRIDE;
|
||||
bool isClipping() const Q_DECL_OVERRIDE;
|
||||
}; // end class Viewer
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -276,6 +276,8 @@ public:
|
|||
virtual int currentPass()const = 0;
|
||||
virtual bool isDepthWriting()const = 0;
|
||||
virtual QOpenGLFramebufferObject* depthPeelingFbo() = 0;
|
||||
virtual QVector4D* clipBox() const =0;
|
||||
virtual bool isClipping() const = 0;
|
||||
}; // end class Viewer_interface
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue