+ add method to get SoDetail from element name

+ fix broken selection mechanism

git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5260 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
wmayer
2011-12-10 21:11:20 +00:00
parent d5655a9e1d
commit e95de7090d
10 changed files with 92 additions and 55 deletions

View File

@@ -87,9 +87,8 @@ void SoBrepFaceSet::doAction(SoAction* action)
return;
}
const SoPickedPoint* pp = hlaction->getElement();
if (pp && pp->getDetail()) {
const SoDetail* detail = pp->getDetail();
const SoDetail* detail = hlaction->getElement();
if (detail) {
if (detail->isOfType(SoFaceDetail::getClassTypeId())) {
int index = static_cast<const SoFaceDetail*>(detail)->getPartIndex();
this->highlightIndex.setValue(index);
@@ -118,10 +117,8 @@ void SoBrepFaceSet::doAction(SoAction* action)
return;
}
const SoPickedPoint* pp = selaction->getElement();
if (pp && pp->getDetail()) {
const SoDetail* detail = pp->getDetail();
const SoDetail* detail = selaction->getElement();
if (detail) {
if (!detail->isOfType(SoFaceDetail::getClassTypeId())) {
return;
}
@@ -774,9 +771,8 @@ void SoBrepEdgeSet::doAction(SoAction* action)
this->hl.clear();
return;
}
const SoPickedPoint* pp = hlaction->getElement();
if (pp && pp->getDetail()) {
const SoDetail* detail = pp->getDetail();
const SoDetail* detail = hlaction->getElement();
if (detail) {
if (!detail->isOfType(SoLineDetail::getClassTypeId())) {
this->highlightIndex = -1;
this->hl.clear();
@@ -824,9 +820,8 @@ void SoBrepEdgeSet::doAction(SoAction* action)
return;
}
const SoPickedPoint* pp = selaction->getElement();
if (pp && pp->getDetail()) {
const SoDetail* detail = pp->getDetail();
const SoDetail* detail = selaction->getElement();
if (detail) {
if (!detail->isOfType(SoLineDetail::getClassTypeId())) {
return;
}
@@ -992,9 +987,8 @@ void SoBrepPointSet::doAction(SoAction* action)
this->highlightIndex = -1;
return;
}
const SoPickedPoint* pp = hlaction->getElement();
if (pp && pp->getDetail()) {
const SoDetail* detail = pp->getDetail();
const SoDetail* detail = hlaction->getElement();
if (detail) {
if (!detail->isOfType(SoPointDetail::getClassTypeId())) {
this->highlightIndex = -1;
return;
@@ -1024,9 +1018,8 @@ void SoBrepPointSet::doAction(SoAction* action)
return;
}
const SoPickedPoint* pp = selaction->getElement();
if (pp && pp->getDetail()) {
const SoDetail* detail = pp->getDetail();
const SoDetail* detail = selaction->getElement();
if (detail) {
if (!detail->isOfType(SoPointDetail::getClassTypeId())) {
return;
}

View File

@@ -371,10 +371,9 @@ std::vector<std::string> ViewProviderPartExt::getDisplayModes(void) const
return StrList;
}
std::string ViewProviderPartExt::getElement(const SoPickedPoint* pp) const
std::string ViewProviderPartExt::getElement(const SoDetail* detail) const
{
std::stringstream str;
const SoDetail* detail = pp->getDetail();
if (detail) {
if (detail->getTypeId() == SoFaceDetail::getClassTypeId()) {
const SoFaceDetail* face_detail = static_cast<const SoFaceDetail*>(detail);
@@ -383,7 +382,7 @@ std::string ViewProviderPartExt::getElement(const SoPickedPoint* pp) const
}
else if (detail->getTypeId() == SoLineDetail::getClassTypeId()) {
const SoLineDetail* line_detail = static_cast<const SoLineDetail*>(detail);
int edge = line_detail->getPartIndex() + 1;
int edge = line_detail->getLineIndex() + 1;
str << "Edge" << edge;
}
else if (detail->getTypeId() == SoPointDetail::getClassTypeId()) {
@@ -396,6 +395,35 @@ std::string ViewProviderPartExt::getElement(const SoPickedPoint* pp) const
return str.str();
}
SoDetail* ViewProviderPartExt::getDetail(const char* subelement) const
{
std::string element = subelement;
std::string::size_type pos = element.find_first_of("0123456789");
int index = -1;
if (pos != std::string::npos) {
index = std::atoi(element.substr(pos).c_str());
element = element.substr(0,pos);
}
SoDetail* detail = 0;
if (index < 0)
return detail;
if (element == "Face") {
detail = new SoFaceDetail();
static_cast<SoFaceDetail*>(detail)->setPartIndex(index - 1);
}
else if (element == "Edge") {
detail = new SoLineDetail();
static_cast<SoLineDetail*>(detail)->setLineIndex(index - 1);
}
else if (element == "Vertex") {
detail = new SoPointDetail();
static_cast<SoPointDetail*>(detail)->setCoordinateIndex(index + nodeset->startIndex.getValue() - 1);
}
return detail;
}
std::vector<Base::Vector3d> ViewProviderPartExt::getSelectionShape(const char* Element) const
{
return std::vector<Base::Vector3d>();

View File

@@ -99,7 +99,8 @@ public:
/// indicates if the ViewProvider use the new Selection model
virtual bool useNewSelectionModel(void) const {return true;}
/// return a hit element to the selection path or 0
virtual std::string getElement(const SoPickedPoint*) const;
virtual std::string getElement(const SoDetail*) const;
virtual SoDetail* getDetail(const char*) const;
/// return the higlight lines for a given element or the whole shape
virtual std::vector<Base::Vector3d> getSelectionShape(const char* Element) const;
//@}