Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/trunk/meshlab/src/meshlabplugins/edit_pickpoints/editpickpoints.cpp b/trunk/meshlab/src/meshlabplugins/edit_pickpoints/editpickpoints.cpp
- index ecd250b..6869590 100644
- --- a/trunk/meshlab/src/meshlabplugins/edit_pickpoints/editpickpoints.cpp
- +++ b/trunk/meshlab/src/meshlabplugins/edit_pickpoints/editpickpoints.cpp
- @@ -75,7 +75,7 @@ void EditPickPointsPlugin::Decorate(MeshModel &mm, GLArea *gla, QPainter *painte
- {
- //qDebug() << "GLarea is different or no faces!!! ";
- return;
- - }
- + }
- //make sure we picking points on the right meshes!
- @@ -87,6 +87,25 @@ void EditPickPointsPlugin::Decorate(MeshModel &mm, GLArea *gla, QPainter *painte
- pickPointsDialog->setCurrentMeshModel(&mm, gla);
- currentModel = &mm;
- }
- +
- +
- + if (pickPointsDialog->snapToExistingVertices())
- + {
- + qDebug() << "Scanning for nearby vertices to snap to near " << currentMousePosition.x() << " " << gla->height() - currentMousePosition.y();
- + std::vector<CVertexO*> vertices;
- +
- + int result = GLPickTri<CMeshO>::PickVert(currentMousePosition.x(), gla->height() - currentMousePosition.y(), mm.cm, vertices, 40, 40);
- + if (result)
- + {
- +
- + qDebug() << "Nearest vertex found.";
- + glColor3f(0, 1, 0);
- + glPointSize(4.5);
- + glBegin(GL_POINTS);
- + glVertex(vertices[0]->P());
- + glEnd();
- + }
- + }
- //We have to calculate the position here because it doesnt work in the mouseEvent functions for some reason
- Point3f pickedPoint;
- @@ -106,7 +125,17 @@ void EditPickPointsPlugin::Decorate(MeshModel &mm, GLArea *gla, QPainter *painte
- currentMousePosition.x(),
- currentMousePosition.y(),
- pickedPoint[0], pickedPoint[1], pickedPoint[2]); */
- -
- + if (pickPointsDialog->snapToExistingVertices())
- + {
- + std::cout << "Snap to existing vertices is set." << std::endl;
- + std::vector<CMeshO::VertexPointer> vertices;
- + int result = GLPickTri<CMeshO>::PickVert(currentMousePosition.x(), gla->height() - currentMousePosition.y(), mm.cm, vertices, 40, 40);
- + if (result)
- + {
- + std::cout << "Nearest vertex found." << std::endl;
- + pickedPoint = vertices[0]->P();
- + }
- + }
- //find the normal of the face we just clicked
- CFaceO *face;
- @@ -134,6 +163,7 @@ void EditPickPointsPlugin::Decorate(MeshModel &mm, GLArea *gla, QPainter *painte
- bool EditPickPointsPlugin::StartEdit(MeshModel &mm, GLArea *gla )
- {
- + gla->setMouseTracking(true);
- //qDebug() << "StartEdit Pick Points: " << mm.fileName.c_str() << " ..." << mm.cm.fn;
- //if there are no faces then we cant do anything with this plugin
- @@ -177,6 +207,7 @@ bool EditPickPointsPlugin::StartEdit(MeshModel &mm, GLArea *gla )
- void EditPickPointsPlugin::EndEdit(MeshModel &mm, GLArea *gla)
- {
- + gla->setMouseTracking(false);
- //qDebug() << "EndEdit Pick Points: " << mm.fileName.c_str() << " ..." << mm.cm.fn;
- // some cleaning at the end.
- @@ -235,6 +266,7 @@ void EditPickPointsPlugin::mouseMoveEvent(QMouseEvent *event, MeshModel &mm, GLA
- gla->suspendedEditor = true;
- QCoreApplication::sendEvent(gla, event);
- gla->suspendedEditor = false;
- + currentMousePosition = event->pos();
- }
- if(Qt::RightButton & event->buttons() &&
- @@ -247,6 +279,8 @@ void EditPickPointsPlugin::mouseMoveEvent(QMouseEvent *event, MeshModel &mm, GLA
- //set flag that we need to add a new point
- registerPoint = true;
- }
- +
- +
- }
- void EditPickPointsPlugin::mouseReleaseEvent(QMouseEvent *event, MeshModel &mm, GLArea * gla)
- diff --git a/trunk/meshlab/src/meshlabplugins/edit_pickpoints/pickpointsDialog.cpp b/trunk/meshlab/src/meshlabplugins/edit_pickpoints/pickpointsDialog.cpp
- index 4269dc5..e0ea076 100644
- --- a/trunk/meshlab/src/meshlabplugins/edit_pickpoints/pickpointsDialog.cpp
- +++ b/trunk/meshlab/src/meshlabplugins/edit_pickpoints/pickpointsDialog.cpp
- @@ -378,6 +378,11 @@ bool PickPointsDialog::drawNormalAsPin()
- return ui.pinRadioButton->isChecked();
- }
- +bool PickPointsDialog::snapToExistingVertices()
- +{
- + return ui.snapToExistingVerticesCheckBox->isChecked();
- +}
- +
- void PickPointsDialog::addPoint(vcg::Point3f &point, QString &name, bool present)
- {
- //bool result = GLPickTri<CMeshO>::PickNearestFace(currentMousePosition.x(),gla->height()-currentMousePosition.y(),
- @@ -418,9 +423,9 @@ PickedPointTreeWidgetItem * PickPointsDialog::addTreeWidgetItemForPoint(vcg::Poi
- //select the newest item
- ui.pickedPointsTreeWidget->setCurrentItem(widgetItem);
- - //add a checkbox to the widget item's 5th column (QT makes us add it in this strange way)
- + //add a checkbox to the widget item's 5th column (QT makes us add it in this strange way)
- TreeCheckBox *checkBox = new TreeCheckBox(ui.pickedPointsTreeWidget, widgetItem, this);
- - ui.pickedPointsTreeWidget->setItemWidget(widgetItem, 4, checkBox);
- + ui.pickedPointsTreeWidget->setItemWidget(widgetItem, 4, checkBox);
- //set the box to show the proper check
- checkBox->setChecked(present);
- diff --git a/trunk/meshlab/src/meshlabplugins/edit_pickpoints/pickpointsDialog.h b/trunk/meshlab/src/meshlabplugins/edit_pickpoints/pickpointsDialog.h
- index dc2a4b2..2a07c6b 100644
- --- a/trunk/meshlab/src/meshlabplugins/edit_pickpoints/pickpointsDialog.h
- +++ b/trunk/meshlab/src/meshlabplugins/edit_pickpoints/pickpointsDialog.h
- @@ -126,6 +126,8 @@ public:
- bool showNormal();
- bool drawNormalAsPin();
- +
- + bool snapToExistingVertices();
- //set flag that says the next value will overwite one we may want to jump back to
- void recordNextPointForUndo();
- diff --git a/trunk/meshlab/src/meshlabplugins/edit_pickpoints/pickpointsDialog.ui b/trunk/meshlab/src/meshlabplugins/edit_pickpoints/pickpointsDialog.ui
- index c71eee4..424bd4d 100644
- --- a/trunk/meshlab/src/meshlabplugins/edit_pickpoints/pickpointsDialog.ui
- +++ b/trunk/meshlab/src/meshlabplugins/edit_pickpoints/pickpointsDialog.ui
- @@ -1,84 +1,85 @@
- -<ui version="4.0" >
- +<?xml version="1.0" encoding="UTF-8"?>
- +<ui version="4.0">
- <class>pickpointsDialog</class>
- - <widget class="QWidget" name="pickpointsDialog" >
- - <property name="geometry" >
- + <widget class="QWidget" name="pickpointsDialog">
- + <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>542</width>
- - <height>654</height>
- + <height>672</height>
- </rect>
- </property>
- - <property name="windowTitle" >
- + <property name="windowTitle">
- <string>Form</string>
- </property>
- - <widget class="QFrame" name="frame" >
- - <property name="geometry" >
- + <widget class="QFrame" name="frame">
- + <property name="geometry">
- <rect>
- <x>0</x>
- <y>10</y>
- <width>531</width>
- - <height>631</height>
- + <height>651</height>
- </rect>
- </property>
- - <property name="frameShape" >
- + <property name="frameShape">
- <enum>QFrame::StyledPanel</enum>
- </property>
- - <property name="frameShadow" >
- + <property name="frameShadow">
- <enum>QFrame::Raised</enum>
- </property>
- - <widget class="QTreeWidget" name="pickedPointsTreeWidget" >
- - <property name="geometry" >
- + <widget class="QTreeWidget" name="pickedPointsTreeWidget">
- + <property name="geometry">
- <rect>
- <x>10</x>
- - <y>80</y>
- + <y>100</y>
- <width>501</width>
- <height>291</height>
- </rect>
- </property>
- - <property name="columnCount" >
- + <property name="columnCount">
- <number>5</number>
- </property>
- <column>
- - <property name="text" >
- + <property name="text">
- <string>1</string>
- </property>
- </column>
- <column>
- - <property name="text" >
- + <property name="text">
- <string>2</string>
- </property>
- </column>
- <column>
- - <property name="text" >
- + <property name="text">
- <string>3</string>
- </property>
- </column>
- <column>
- - <property name="text" >
- + <property name="text">
- <string>4</string>
- </property>
- </column>
- <column>
- - <property name="text" >
- + <property name="text">
- <string>5</string>
- </property>
- </column>
- </widget>
- - <widget class="QGroupBox" name="groupBox" >
- - <property name="geometry" >
- + <widget class="QGroupBox" name="groupBox">
- + <property name="geometry">
- <rect>
- <x>10</x>
- <y>10</y>
- <width>291</width>
- - <height>51</height>
- + <height>81</height>
- </rect>
- </property>
- - <property name="title" >
- + <property name="title">
- <string>Mode: </string>
- </property>
- - <widget class="QRadioButton" name="pickPointModeRadioButton" >
- - <property name="geometry" >
- + <widget class="QRadioButton" name="pickPointModeRadioButton">
- + <property name="geometry">
- <rect>
- <x>10</x>
- <y>20</y>
- @@ -86,15 +87,15 @@
- <height>23</height>
- </rect>
- </property>
- - <property name="text" >
- + <property name="text">
- <string>Pick Point</string>
- </property>
- - <property name="checked" >
- + <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- - <widget class="QRadioButton" name="movePointRadioButton" >
- - <property name="geometry" >
- + <widget class="QRadioButton" name="movePointRadioButton">
- + <property name="geometry">
- <rect>
- <x>100</x>
- <y>20</y>
- @@ -102,12 +103,12 @@
- <height>23</height>
- </rect>
- </property>
- - <property name="text" >
- + <property name="text">
- <string>Move Point</string>
- </property>
- </widget>
- - <widget class="QRadioButton" name="selectPointRadioButton" >
- - <property name="geometry" >
- + <widget class="QRadioButton" name="selectPointRadioButton">
- + <property name="geometry">
- <rect>
- <x>190</x>
- <y>20</y>
- @@ -115,13 +116,26 @@
- <height>24</height>
- </rect>
- </property>
- - <property name="text" >
- + <property name="text">
- <string>Select Point</string>
- </property>
- </widget>
- + <widget class="QCheckBox" name="snapToExistingVerticesCheckBox">
- + <property name="geometry">
- + <rect>
- + <x>10</x>
- + <y>50</y>
- + <width>191</width>
- + <height>22</height>
- + </rect>
- + </property>
- + <property name="text">
- + <string>Snap to existing vertices</string>
- + </property>
- + </widget>
- </widget>
- - <widget class="QWidget" name="layoutWidget" >
- - <property name="geometry" >
- + <widget class="QWidget" name="layoutWidget">
- + <property name="geometry">
- <rect>
- <x>310</x>
- <y>10</y>
- @@ -129,37 +143,37 @@
- <height>64</height>
- </rect>
- </property>
- - <layout class="QGridLayout" >
- - <item row="1" column="0" >
- - <widget class="QPushButton" name="loadPointsButton" >
- - <property name="text" >
- + <layout class="QGridLayout">
- + <item row="1" column="0">
- + <widget class="QPushButton" name="loadPointsButton">
- + <property name="text">
- <string>Load Points From File</string>
- </property>
- </widget>
- </item>
- - <item row="0" column="0" >
- - <widget class="QPushButton" name="saveButton" >
- - <property name="text" >
- + <item row="0" column="0">
- + <widget class="QPushButton" name="saveButton">
- + <property name="text">
- <string>Save</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- - <widget class="QGroupBox" name="groupBox_2" >
- - <property name="geometry" >
- + <widget class="QGroupBox" name="groupBox_2">
- + <property name="geometry">
- <rect>
- <x>10</x>
- - <y>420</y>
- + <y>440</y>
- <width>431</width>
- <height>131</height>
- </rect>
- </property>
- - <property name="title" >
- + <property name="title">
- <string>Template Controls</string>
- </property>
- - <widget class="QCheckBox" name="defaultTemplateCheckBox" >
- - <property name="geometry" >
- + <widget class="QCheckBox" name="defaultTemplateCheckBox">
- + <property name="geometry">
- <rect>
- <x>10</x>
- <y>20</y>
- @@ -167,12 +181,12 @@
- <height>24</height>
- </rect>
- </property>
- - <property name="text" >
- + <property name="text">
- <string>Save this as your default template</string>
- </property>
- </widget>
- - <widget class="QLabel" name="label" >
- - <property name="geometry" >
- + <widget class="QLabel" name="label">
- + <property name="geometry">
- <rect>
- <x>10</x>
- <y>100</y>
- @@ -180,12 +194,12 @@
- <height>18</height>
- </rect>
- </property>
- - <property name="text" >
- + <property name="text">
- <string>Template Name:</string>
- </property>
- </widget>
- - <widget class="QLabel" name="templateNameLabel" >
- - <property name="geometry" >
- + <widget class="QLabel" name="templateNameLabel">
- + <property name="geometry">
- <rect>
- <x>110</x>
- <y>100</y>
- @@ -193,12 +207,12 @@
- <height>20</height>
- </rect>
- </property>
- - <property name="palette" >
- + <property name="palette">
- <palette>
- <active>
- - <colorrole role="WindowText" >
- - <brush brushstyle="SolidPattern" >
- - <color alpha="255" >
- + <colorrole role="WindowText">
- + <brush brushstyle="SolidPattern">
- + <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>255</blue>
- @@ -207,9 +221,9 @@
- </colorrole>
- </active>
- <inactive>
- - <colorrole role="WindowText" >
- - <brush brushstyle="SolidPattern" >
- - <color alpha="255" >
- + <colorrole role="WindowText">
- + <brush brushstyle="SolidPattern">
- + <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>255</blue>
- @@ -218,9 +232,9 @@
- </colorrole>
- </inactive>
- <disabled>
- - <colorrole role="WindowText" >
- - <brush brushstyle="SolidPattern" >
- - <color alpha="255" >
- + <colorrole role="WindowText">
- + <brush brushstyle="SolidPattern">
- + <color alpha="255">
- <red>127</red>
- <green>125</green>
- <blue>123</blue>
- @@ -230,12 +244,12 @@
- </disabled>
- </palette>
- </property>
- - <property name="text" >
- + <property name="text">
- <string>TextLabel</string>
- </property>
- </widget>
- - <widget class="QWidget" name="layoutWidget" >
- - <property name="geometry" >
- + <widget class="QWidget" name="layoutWidget">
- + <property name="geometry">
- <rect>
- <x>10</x>
- <y>60</y>
- @@ -243,31 +257,31 @@
- <height>30</height>
- </rect>
- </property>
- - <layout class="QHBoxLayout" name="horizontalLayout" >
- + <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- - <widget class="QPushButton" name="saveTemplateButton" >
- - <property name="text" >
- + <widget class="QPushButton" name="saveTemplateButton">
- + <property name="text">
- <string>Save</string>
- </property>
- </widget>
- </item>
- <item>
- - <widget class="QPushButton" name="loadTemplateButton" >
- - <property name="text" >
- + <widget class="QPushButton" name="loadTemplateButton">
- + <property name="text">
- <string>Load</string>
- </property>
- </widget>
- </item>
- <item>
- - <widget class="QPushButton" name="clearTemplateButton" >
- - <property name="text" >
- + <widget class="QPushButton" name="clearTemplateButton">
- + <property name="text">
- <string>Clear</string>
- </property>
- </widget>
- </item>
- <item>
- - <widget class="QPushButton" name="addPointToTemplateButton" >
- - <property name="text" >
- + <widget class="QPushButton" name="addPointToTemplateButton">
- + <property name="text">
- <string>Add Point</string>
- </property>
- </widget>
- @@ -275,20 +289,20 @@
- </layout>
- </widget>
- </widget>
- - <widget class="QGroupBox" name="groupBox_3" >
- - <property name="geometry" >
- + <widget class="QGroupBox" name="groupBox_3">
- + <property name="geometry">
- <rect>
- <x>10</x>
- - <y>560</y>
- + <y>580</y>
- <width>431</width>
- <height>61</height>
- </rect>
- </property>
- - <property name="title" >
- + <property name="title">
- <string>Normal Options</string>
- </property>
- - <widget class="QCheckBox" name="showNormalCheckBox" >
- - <property name="geometry" >
- + <widget class="QCheckBox" name="showNormalCheckBox">
- + <property name="geometry">
- <rect>
- <x>10</x>
- <y>20</y>
- @@ -296,43 +310,43 @@
- <height>24</height>
- </rect>
- </property>
- - <property name="text" >
- + <property name="text">
- <string>Show Normal?</string>
- </property>
- - <property name="checked" >
- + <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- - <widget class="QWidget" name="layoutWidget" >
- - <property name="geometry" >
- + <widget class="QWidget" name="layoutWidget">
- + <property name="geometry">
- <rect>
- <x>170</x>
- <y>20</y>
- - <width>181</width>
- + <width>199</width>
- <height>26</height>
- </rect>
- </property>
- - <layout class="QHBoxLayout" name="horizontalLayout_4" >
- + <layout class="QHBoxLayout" name="horizontalLayout_4">
- <item>
- - <widget class="QLabel" name="label_2" >
- - <property name="text" >
- + <widget class="QLabel" name="label_2">
- + <property name="text">
- <string>Draw as a: </string>
- </property>
- </widget>
- </item>
- <item>
- - <widget class="QRadioButton" name="pinRadioButton" >
- - <property name="text" >
- + <widget class="QRadioButton" name="pinRadioButton">
- + <property name="text">
- <string>Pin</string>
- </property>
- - <property name="checked" >
- + <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- - <widget class="QRadioButton" name="lineRadioButton" >
- - <property name="text" >
- + <widget class="QRadioButton" name="lineRadioButton">
- + <property name="text">
- <string>Line</string>
- </property>
- </widget>
- @@ -340,69 +354,61 @@
- </layout>
- </widget>
- </widget>
- - <widget class="QWidget" name="layoutWidget" >
- - <property name="geometry" >
- + <widget class="QWidget" name="layoutWidget">
- + <property name="geometry">
- <rect>
- <x>10</x>
- - <y>380</y>
- - <width>431</width>
- + <y>400</y>
- + <width>476</width>
- <height>41</height>
- </rect>
- </property>
- - <layout class="QHBoxLayout" name="horizontalLayout_2" >
- + <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- - <widget class="QPushButton" name="renamePointButton" >
- - <property name="text" >
- + <widget class="QPushButton" name="renamePointButton">
- + <property name="text">
- <string>Rename Point</string>
- </property>
- </widget>
- </item>
- <item>
- - <widget class="QPushButton" name="clearPointButton" >
- - <property name="text" >
- + <widget class="QPushButton" name="clearPointButton">
- + <property name="text">
- <string>Clear Point</string>
- </property>
- </widget>
- </item>
- <item>
- - <widget class="QPushButton" name="removePointButton" >
- - <property name="text" >
- + <widget class="QPushButton" name="removePointButton">
- + <property name="text">
- <string>Remove Point</string>
- </property>
- </widget>
- </item>
- <item>
- - <widget class="QPushButton" name="removeAllPointsButton" >
- - <property name="text" >
- + <widget class="QPushButton" name="removeAllPointsButton">
- + <property name="text">
- <string>Remove All Points</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- - <widget class="QPushButton" name="undoButton" >
- - <property name="geometry" >
- + <widget class="QPushButton" name="undoButton">
- + <property name="geometry">
- <rect>
- <x>450</x>
- - <y>380</y>
- + <y>400</y>
- <width>71</width>
- <height>81</height>
- </rect>
- </property>
- - <property name="text" >
- + <property name="text">
- <string>Undo
- last
- move</string>
- </property>
- </widget>
- - <zorder>pickedPointsTreeWidget</zorder>
- - <zorder>groupBox</zorder>
- - <zorder>layoutWidget</zorder>
- - <zorder>groupBox_2</zorder>
- - <zorder>groupBox_3</zorder>
- - <zorder>layoutWidget</zorder>
- - <zorder>undoButton</zorder>
- - <zorder>renamePointButton</zorder>
- </widget>
- </widget>
- <resources/>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement