Commit 37764385 authored by Sylvain Thery's avatar Sylvain Thery

selection with transfo

parent e56957ac
......@@ -253,6 +253,11 @@ void Surface_Selection_Plugin::keyPress(View* view, QKeyEvent* event)
{
if(event->key() == Qt::Key_Shift)
{
// generated a false mouse move to update drawing on shift keypressed !
QPoint p = m_schnapps->getSelectedView()->mapFromGlobal(QCursor::pos());
QMouseEvent me = QMouseEvent(QEvent::MouseMove, QPointF(p), Qt::NoButton, Qt::NoButton, Qt::ShiftModifier);
mouseMove(view, &me);
view->setMouseTracking(true);
m_selecting = true;
view->updateGL();
......@@ -425,11 +430,15 @@ void Surface_Selection_Plugin::mouseMove(View* view, QMouseEvent* event)
qglviewer::Vec dir;
view->camera()->convertClickToLine(pixel, orig, dir);
// compute coordinates of ray in map Frame
qglviewer::Vec orig_inv = mh->getFrame()->coordinatesOf(orig);
qglviewer::Vec dir_inv = mh->getFrame()->transformOf(dir);
PFP2::VEC3 rayA(orig_inv.x, orig_inv.y, orig_inv.z);
PFP2::VEC3 AB(dir_inv.x, dir_inv.y, dir_inv.z);
// apply inverse local map transfo
glm::vec4 glmRayA = mh->getInverseTransfoMatrix()*glm::vec4(orig_inv.x, orig_inv.y, orig_inv.z, 1.0f);
glm::vec4 glmAB = glm::transpose(mh->getInverseTransfoMatrix())*glm::vec4(dir_inv.x, dir_inv.y, dir_inv.z, 1.0f);
// put in PFP::VEC3 format
PFP2::VEC3 rayA(glmRayA.x, glmRayA.y, glmRayA.z);
PFP2::VEC3 AB(glmAB.x, glmAB.y, glmAB.z);
PFP2::MAP* map = static_cast<MapHandler<PFP2>*>(mh)->getMap();
......@@ -520,7 +529,8 @@ void Surface_Selection_Plugin::updateSelectedCellsRendering()
{
unsigned int orbit = m_schnapps->getCurrentOrbit();
CellSelectorGen* selector = m_schnapps->getSelectedSelector(orbit);
if (selector == NULL)
return;
switch(orbit)
{
case VERTEX : {
......
......@@ -145,6 +145,7 @@ public slots:
CellSelectorGen* getCellSelector(unsigned int orbit, const QString& name) const;
const CellSelectorSet& getCellSelectorSet(unsigned int orbit) const { return m_cellSelectors[orbit]; }
private slots:
void selectedCellsChanged();
......@@ -181,6 +182,7 @@ public:
*********************************************************/
inline const glm::mat4& getTransfoMatrix() const { return m_transfoMatrix; }
inline const glm::mat4& getInverseTransfoMatrix() const { return m_transfoMatrixInv; }
public slots:
void setScaling(float sx, float sy, float sz);
......@@ -214,6 +216,7 @@ protected:
qglviewer::ManipulatedFrame* m_frame;
glm::mat4 m_transfoMatrix;
glm::mat4 m_transfoMatrixInv;
AttributeMultiVectorGen* m_bbVertexAttribute;
float m_bbDiagSize;
......
......@@ -14,7 +14,6 @@ unsigned int Camera::cameraCount = 0;
Camera::Camera(const QString& name, SCHNApps* s) :
m_name(name),
m_schnapps(s),
// m_transfoMatrix(1.0f),
b_draw(false),
b_drawPath(false),
b_fitToViewsBoundingBox(true)
......
......@@ -236,8 +236,14 @@ void ControlDock_MapTab::selectedSelectorChanged()
{
m_selectedSelector[orbit] = m_selectedMap->getCellSelector(orbit, items[0]->text());
m_schnapps->notifySelectedCellSelectorChanged(m_selectedSelector[orbit]);
//// RECORDING TODO
//QTextStream* rec = m_schnapps->pythonStreamRecorder();
//if (rec)
// *rec << m_selectedMap->getName() << ".setSelectedSelector(" << orbit << ", \"" << items[0]->text() << "\");" << endl;
}
}
}
}
......@@ -262,7 +268,14 @@ void ControlDock_MapTab::addSelector()
if (m_selectedMap)
{
unsigned int orbit = getCurrentOrbit();
m_selectedMap->addCellSelector(orbit, QString("selector_") + QString::number(CellSelectorGen::selectorCount));
QString sel_name = QString("selector_") + QString::number(CellSelectorGen::selectorCount);
m_selectedMap->addCellSelector(orbit, sel_name);
// RECORDING
QTextStream* rec = m_schnapps->pythonStreamRecorder();
if (rec)
*rec << m_selectedMap->getName() << ".addCellSelector(" << orbit << ", \"" << sel_name << "\");" << endl;
}
}
}
......@@ -284,15 +297,19 @@ void ControlDock_MapTab::removeSelector()
case VOLUME: items = list_volumeSelectors->selectedItems(); break;
}
if (!items.empty())
{
m_selectedMap->removeCellSelector(orbit, items[0]->text());
// RECORDING
QTextStream* rec = m_schnapps->pythonStreamRecorder();
if (rec)
*rec << m_selectedMap->getName() << ".removeCellSelector(" << orbit << ", \"" << items[0]->text() << "\");" << endl;
}
}
}
}
void ControlDock_MapTab::mapAdded(MapHandlerGen* m)
{
b_updatingUI = true;
......
......@@ -12,6 +12,8 @@ MapHandlerGen::MapHandlerGen(const QString& name, SCHNApps* s, GenericMap* map)
m_schnapps(s),
m_map(map),
m_frame(NULL),
m_transfoMatrix(1.0f),
m_transfoMatrixInv(1.0f),
m_bbVertexAttribute(NULL),
m_bbDrawer(NULL),
m_render(NULL),
......@@ -404,8 +406,16 @@ void MapHandlerGen::setScaling(float sx, float sy, float sz)
m_transfoMatrix[0][0] = sx;
m_transfoMatrix[1][1] = sy;
m_transfoMatrix[2][2] = sz;
foreach(View* view, l_views)
view->updateGL();
// replace by inverse compute if other transfo than scale
m_transfoMatrixInv[0][0] = 1.0f/sx;
m_transfoMatrixInv[1][1] = 1.0f/sy;
m_transfoMatrixInv[2][2] = 1.0f/sz;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment