mirror of https://github.com/CGAL/cgal
(WIP) addition of camera positions
This commit is contained in:
parent
d4cba3b3e1
commit
e96e859277
|
|
@ -42,6 +42,7 @@ public:
|
|||
Q_SIGNALS:
|
||||
void selected(int);
|
||||
void requestContextMenu(QPoint global_pos);
|
||||
void requestBasicPositions(Viewer_interface* viewer);
|
||||
void selectedPoint(double, double, double);
|
||||
void selectionRay(double, double, double, double, double, double);
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ Camera_positions_list::Camera_positions_list(QWidget* parent)
|
|||
void Camera_positions_list::setViewer(Viewer_interface* viewer)
|
||||
{
|
||||
m_viewer = viewer;
|
||||
connect(viewer, SIGNAL(requestBasicPositions(Viewer_interface*)),
|
||||
this, SLOT(setBasicPositions(Viewer_interface*)));
|
||||
}
|
||||
|
||||
void Camera_positions_list::on_plusButton_pressed()
|
||||
|
|
@ -135,3 +137,107 @@ void Camera_positions_list::load(QString filename) {
|
|||
}
|
||||
}
|
||||
|
||||
void Camera_positions_list::setBasicPositions(Viewer_interface* viewer)
|
||||
{
|
||||
qglviewer::Vec posFront = qglviewer::Vec(0,0,viewer->sceneRadius()/(sin (viewer->camera()->fieldOfView()/2)));
|
||||
qglviewer::Quaternion dirFront;
|
||||
dirFront.setAxisAngle(qglviewer::Vec(0,1,0),0);
|
||||
QString frontCoord = QString("%1 %2 %3 %4 %5 %6 %7")
|
||||
.arg(posFront[0])
|
||||
.arg(posFront[1])
|
||||
.arg(posFront[2])
|
||||
.arg(dirFront[0])
|
||||
.arg(dirFront[1])
|
||||
.arg(dirFront[2])
|
||||
.arg(dirFront[3]);
|
||||
addItem(tr("Front"),
|
||||
frontCoord);
|
||||
qglviewer::Vec posBack = posFront;
|
||||
posBack.z *= -1;
|
||||
qglviewer::Quaternion dirBack = dirFront;
|
||||
dirBack.setAxisAngle(qglviewer::Vec(0,1,0),M_PI);
|
||||
|
||||
QString backCoord = QString("%1 %2 %3 %4 %5 %6 %7")
|
||||
.arg(posBack[0])
|
||||
.arg(posBack[1])
|
||||
.arg(posBack[2])
|
||||
.arg(dirBack[0])
|
||||
.arg(dirBack[1])
|
||||
.arg(dirBack[2])
|
||||
.arg(dirBack[3]);
|
||||
addItem(tr("Back"),backCoord);
|
||||
|
||||
qglviewer::Vec posTop = posFront;
|
||||
posTop.y = posTop.z;
|
||||
posTop.z *= 0;
|
||||
qglviewer::Quaternion dirTop = dirFront;
|
||||
dirTop.setAxisAngle(qglviewer::Vec(1,0,0),-M_PI_2);
|
||||
QString topCoord = QString("%1 %2 %3 %4 %5 %6 %7")
|
||||
.arg(posTop[0])
|
||||
.arg(posTop[1])
|
||||
.arg(posTop[2])
|
||||
.arg(dirTop[0])
|
||||
.arg(dirTop[1])
|
||||
.arg(dirTop[2])
|
||||
.arg(dirTop[3]);
|
||||
addItem(tr("Top"),topCoord);
|
||||
qglviewer::Vec posBot = posTop;
|
||||
posBot.y *= -1;
|
||||
qglviewer::Quaternion dirBot = dirFront;
|
||||
dirBot.setAxisAngle(qglviewer::Vec(1,0,0),M_PI_2);
|
||||
QString botCoord= QString("%1 %2 %3 %4 %5 %6 %7")
|
||||
.arg(posBot[0])
|
||||
.arg(posBot[1])
|
||||
.arg(posBot[2])
|
||||
.arg(dirBot[0])
|
||||
.arg(dirBot[1])
|
||||
.arg(dirBot[2])
|
||||
.arg(dirBot[3]);
|
||||
addItem(tr("Bottom"),botCoord);
|
||||
|
||||
qglviewer::Vec posRight = posFront;
|
||||
posRight.x = posFront.z;
|
||||
posRight.z *= 0;
|
||||
qglviewer::Quaternion dirRight = dirFront;
|
||||
dirRight.setAxisAngle(qglviewer::Vec(0,1,0),M_PI_2);
|
||||
QString rightCoord = QString("%1 %2 %3 %4 %5 %6 %7")
|
||||
.arg(posRight[0])
|
||||
.arg(posRight[1])
|
||||
.arg(posRight[2])
|
||||
.arg(dirRight[0])
|
||||
.arg(dirRight[1])
|
||||
.arg(dirRight[2])
|
||||
.arg(dirRight[3]);
|
||||
addItem(tr("Right"),rightCoord);
|
||||
|
||||
qglviewer::Vec posLeft = posRight;
|
||||
posLeft.x *= -1;
|
||||
qglviewer::Quaternion dirLeft = dirFront;
|
||||
dirLeft.setAxisAngle(qglviewer::Vec(0,1,0),-M_PI_2);
|
||||
QString leftCoord = QString("%1 %2 %3 %4 %5 %6 %7")
|
||||
.arg(posLeft[0])
|
||||
.arg(posLeft[1])
|
||||
.arg(posLeft[2])
|
||||
.arg(dirLeft[0])
|
||||
.arg(dirLeft[1])
|
||||
.arg(dirLeft[2])
|
||||
.arg(dirLeft[3]);
|
||||
addItem(tr("Left"),leftCoord);
|
||||
insertItem(tr("Left"),leftCoord);
|
||||
insertItem(tr("Right"),rightCoord);
|
||||
insertItem(tr("Bottom"),botCoord);
|
||||
insertItem(tr("Top"),topCoord);
|
||||
insertItem(tr("Back"),backCoord);
|
||||
insertItem(tr("Front"), frontCoord);
|
||||
|
||||
}
|
||||
|
||||
void Camera_positions_list::insertItem(QString text, QString data)
|
||||
{
|
||||
QStandardItem* item = new QStandardItem(text);
|
||||
|
||||
item->setData(data, Qt::UserRole);
|
||||
m_model->insertRow(0, item);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@ public:
|
|||
|
||||
public Q_SLOTS:
|
||||
void load(QString filename);
|
||||
void setBasicPositions(Viewer_interface*);
|
||||
protected Q_SLOTS:
|
||||
|
||||
void on_plusButton_pressed();
|
||||
void on_minusButton_pressed();
|
||||
void on_upButton_pressed();
|
||||
|
|
@ -25,7 +27,7 @@ protected Q_SLOTS:
|
|||
void on_openButton_pressed();
|
||||
void on_saveButton_pressed();
|
||||
void on_clearButton_pressed();
|
||||
|
||||
void insertItem(QString text, QString data);
|
||||
void activatedRow(QModelIndex index);
|
||||
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -36,8 +36,11 @@ private:
|
|||
|
||||
void Polyhedron_demo_camera_positions_plugin::init(QMainWindow* mainWindow, Scene_interface*)
|
||||
{
|
||||
|
||||
cpl = new Camera_positions_list(mainWindow);
|
||||
cpl->setViewer(mainWindow->findChild<Viewer_interface*>("viewer"));
|
||||
Viewer_interface* viewer = mainWindow->findChild<Viewer_interface*>("viewer");
|
||||
cpl->setViewer(viewer);
|
||||
cpl->setBasicPositions(viewer);
|
||||
mainWindow->addDockWidget(Qt::LeftDockWidgetArea, cpl);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,13 +51,13 @@ Scene::Scene(QObject* parent)
|
|||
Scene::Item_id
|
||||
Scene::addItem(Scene_item* item)
|
||||
{
|
||||
|
||||
Bbox bbox_before = bbox();
|
||||
m_entries.push_back(item);
|
||||
connect(item, SIGNAL(itemChanged()),
|
||||
this, SLOT(itemChanged()));
|
||||
if(bbox_before + item->bbox() != bbox_before)
|
||||
{ Q_EMIT updated_bbox(); }
|
||||
Q_EMIT requestBasicPositions();
|
||||
QAbstractListModel::beginResetModel();
|
||||
Q_EMIT updated();
|
||||
QAbstractListModel::endResetModel();
|
||||
|
|
|
|||
|
|
@ -158,6 +158,7 @@ Q_SIGNALS:
|
|||
void itemAboutToBeDestroyed(Scene_item*);
|
||||
void selectionRay(double, double, double, double, double, double);
|
||||
void selectionChanged(int i);
|
||||
void requestBasicPositions();
|
||||
|
||||
private Q_SLOTS:
|
||||
void setSelectionRay(double, double, double, double, double, double);
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ Viewer::Viewer(QWidget* parent, bool antialiasing)
|
|||
pickMatrix_[5]=1;
|
||||
pickMatrix_[10]=1;
|
||||
pickMatrix_[15]=1;
|
||||
prev_radius = sceneRadius();
|
||||
}
|
||||
|
||||
Viewer::~Viewer()
|
||||
|
|
@ -90,6 +91,7 @@ void Viewer::draw()
|
|||
{
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
d->inFastDrawing = false;
|
||||
testRadius();
|
||||
QGLViewer::draw();
|
||||
d->draw_aux(false, this);
|
||||
}
|
||||
|
|
@ -97,6 +99,7 @@ void Viewer::draw()
|
|||
void Viewer::fastDraw()
|
||||
{
|
||||
d->inFastDrawing = true;
|
||||
testRadius();
|
||||
QGLViewer::fastDraw();
|
||||
d->draw_aux(false, this);
|
||||
}
|
||||
|
|
@ -374,3 +377,12 @@ void Viewer::endSelection(const QPoint& point)
|
|||
pickMatrix_[10]=1;
|
||||
pickMatrix_[15]=1;
|
||||
}
|
||||
|
||||
void Viewer::testRadius()
|
||||
{
|
||||
if(prev_radius != sceneRadius())
|
||||
{
|
||||
Q_EMIT Viewer_interface::requestBasicPositions(this);
|
||||
prev_radius = sceneRadius();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ public Q_SLOTS:
|
|||
void setTwoSides(bool b);
|
||||
|
||||
void turnCameraBy180Degres();
|
||||
|
||||
QString dumpCameraCoordinates();
|
||||
bool moveCameraToCoordinates(QString,
|
||||
float animation_duration = 0.5f);
|
||||
|
|
@ -54,6 +53,8 @@ protected:
|
|||
|
||||
protected:
|
||||
Viewer_impl* d;
|
||||
double prev_radius;
|
||||
void testRadius();
|
||||
}; // end class Viewer
|
||||
|
||||
#endif // VIEWER_H
|
||||
|
|
|
|||
Loading…
Reference in New Issue