Added touchMode-detection and partially implemented touchMode for line-

detection (only works when one end-point is selected, yet).
The touchMode refers to a rectangular selection where objects are
selected even if only a part of them is int the box. It's used when the
selection box is drawn from right to left.
This commit is contained in:
SparkyCola
2017-10-03 20:39:30 +02:00
committed by wmayer
parent 1318b0b8ee
commit 826551b740

View File

@@ -1934,6 +1934,11 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s &startPos, const SbVec2s &
int VertexId = -1; // the loop below should be in sync with the main loop in ViewProviderSketch::draw
// so that the vertex indices are calculated correctly
int GeoId = 0;
bool touchMode = false;
//check if selection goes from the right to the left side (for touch-selection where even partially boxed objects get selected)
if(corners[0].getValue()[0] > corners[1].getValue()[0])
touchMode = true;
for (std::vector<Part::Geometry *>::const_iterator it = geomlist.begin(); it != geomlist.end()-2; ++it, ++GeoId) {
if (GeoId >= intGeoCount)
@@ -1963,19 +1968,20 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s &startPos, const SbVec2s &
bool pnt1Inside = polygon.Contains(Base::Vector2d(pnt1.x, pnt1.y));
bool pnt2Inside = polygon.Contains(Base::Vector2d(pnt2.x, pnt2.y));
if (pnt1Inside) {
if (pnt1Inside && !touchMode) {
std::stringstream ss;
ss << "Vertex" << VertexId;
Gui::Selection().addSelection(doc->getName(), sketchObject->getNameInDocument(), ss.str().c_str());
}
if (pnt2Inside) {
if (pnt2Inside && !touchMode) {
std::stringstream ss;
ss << "Vertex" << VertexId + 1;
Gui::Selection().addSelection(doc->getName(), sketchObject->getNameInDocument(), ss.str().c_str());
}
if (pnt1Inside && pnt2Inside) {
//in touchMode it's enough if one of the points is inside, in normal mode both have to be inside
if ( (pnt1Inside && pnt2Inside) || (touchMode && (pnt1Inside || pnt2Inside) )) {
std::stringstream ss;
ss << "Edge" << GeoId + 1;
Gui::Selection().addSelection(doc->getName(), sketchObject->getNameInDocument(), ss.str().c_str());
@@ -2024,7 +2030,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s &startPos, const SbVec2s &
}
}
} else if ((*it)->getTypeId() == Part::GeomEllipse::getClassTypeId()) {
// ----- Check if circle lies inside box selection -----/
// ----- Check if ellipse lies inside box selection -----/
const Part::GeomEllipse *ellipse = static_cast<const Part::GeomEllipse *>(*it);
pnt0 = ellipse->getCenter();
VertexId += 1;