Inspection: apply clang format
This commit is contained in:
@@ -23,27 +23,27 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <QApplication>
|
||||
# include <QMenu>
|
||||
# include <QMessageBox>
|
||||
#include <QApplication>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
|
||||
# include <Inventor/SoPickedPoint.h>
|
||||
# include <Inventor/actions/SoRayPickAction.h>
|
||||
# include <Inventor/actions/SoSearchAction.h>
|
||||
# include <Inventor/details/SoFaceDetail.h>
|
||||
# include <Inventor/errors/SoDebugError.h>
|
||||
# include <Inventor/events/SoButtonEvent.h>
|
||||
# include <Inventor/events/SoKeyboardEvent.h>
|
||||
# include <Inventor/events/SoMouseButtonEvent.h>
|
||||
# include <Inventor/nodes/SoCoordinate3.h>
|
||||
# include <Inventor/nodes/SoDrawStyle.h>
|
||||
# include <Inventor/nodes/SoIndexedFaceSet.h>
|
||||
# include <Inventor/nodes/SoIndexedLineSet.h>
|
||||
# include <Inventor/nodes/SoMaterial.h>
|
||||
# include <Inventor/nodes/SoMaterialBinding.h>
|
||||
# include <Inventor/nodes/SoNormal.h>
|
||||
# include <Inventor/nodes/SoPointSet.h>
|
||||
# include <Inventor/nodes/SoShapeHints.h>
|
||||
#include <Inventor/SoPickedPoint.h>
|
||||
#include <Inventor/actions/SoRayPickAction.h>
|
||||
#include <Inventor/actions/SoSearchAction.h>
|
||||
#include <Inventor/details/SoFaceDetail.h>
|
||||
#include <Inventor/errors/SoDebugError.h>
|
||||
#include <Inventor/events/SoButtonEvent.h>
|
||||
#include <Inventor/events/SoKeyboardEvent.h>
|
||||
#include <Inventor/events/SoMouseButtonEvent.h>
|
||||
#include <Inventor/nodes/SoCoordinate3.h>
|
||||
#include <Inventor/nodes/SoDrawStyle.h>
|
||||
#include <Inventor/nodes/SoIndexedFaceSet.h>
|
||||
#include <Inventor/nodes/SoIndexedLineSet.h>
|
||||
#include <Inventor/nodes/SoMaterial.h>
|
||||
#include <Inventor/nodes/SoMaterialBinding.h>
|
||||
#include <Inventor/nodes/SoNormal.h>
|
||||
#include <Inventor/nodes/SoPointSet.h>
|
||||
#include <Inventor/nodes/SoShapeHints.h>
|
||||
#endif
|
||||
|
||||
#include <App/GeoFeature.h>
|
||||
@@ -64,14 +64,22 @@ using namespace InspectionGui;
|
||||
|
||||
|
||||
bool ViewProviderInspection::addflag = false;
|
||||
App::PropertyFloatConstraint::Constraints ViewProviderInspection::floatRange = {1.0,64.0,1.0};
|
||||
App::PropertyFloatConstraint::Constraints ViewProviderInspection::floatRange = {1.0, 64.0, 1.0};
|
||||
|
||||
PROPERTY_SOURCE(InspectionGui::ViewProviderInspection, Gui::ViewProviderDocumentObject)
|
||||
|
||||
ViewProviderInspection::ViewProviderInspection()
|
||||
{
|
||||
ADD_PROPERTY_TYPE(OutsideGrayed,(false),"",(App::PropertyType) (App::Prop_Output|App::Prop_Hidden),"");
|
||||
ADD_PROPERTY_TYPE(PointSize,(1.0),"Display",(App::PropertyType) (App::Prop_None/*App::Prop_Hidden*/),"");
|
||||
ADD_PROPERTY_TYPE(OutsideGrayed,
|
||||
(false),
|
||||
"",
|
||||
(App::PropertyType)(App::Prop_Output | App::Prop_Hidden),
|
||||
"");
|
||||
ADD_PROPERTY_TYPE(PointSize,
|
||||
(1.0),
|
||||
"Display",
|
||||
(App::PropertyType)(App::Prop_None /*App::Prop_Hidden*/),
|
||||
"");
|
||||
PointSize.setConstraints(&floatRange);
|
||||
|
||||
pcColorRoot = new SoSeparator();
|
||||
@@ -80,7 +88,7 @@ ViewProviderInspection::ViewProviderInspection()
|
||||
pcMatBinding->ref();
|
||||
pcColorMat = new SoMaterial;
|
||||
pcColorMat->ref();
|
||||
pcColorStyle = new SoDrawStyle();
|
||||
pcColorStyle = new SoDrawStyle();
|
||||
pcColorRoot->addChild(pcColorStyle);
|
||||
pcCoords = new SoCoordinate3;
|
||||
pcCoords->ref();
|
||||
@@ -88,7 +96,7 @@ ViewProviderInspection::ViewProviderInspection()
|
||||
pcColorBar = new Gui::SoFCColorBar;
|
||||
pcColorBar->Attach(this);
|
||||
pcColorBar->ref();
|
||||
pcColorBar->setRange( -0.1f, 0.1f, 3 );
|
||||
pcColorBar->setRange(-0.1f, 0.1f, 3);
|
||||
pcLinkRoot = new SoGroup;
|
||||
pcLinkRoot->ref();
|
||||
|
||||
@@ -96,7 +104,7 @@ ViewProviderInspection::ViewProviderInspection()
|
||||
pcPointStyle->ref();
|
||||
pcPointStyle->style = SoDrawStyle::POINTS;
|
||||
pcPointStyle->pointSize = PointSize.getValue();
|
||||
SelectionStyle.setValue(1); // BBOX
|
||||
SelectionStyle.setValue(1);// BBOX
|
||||
}
|
||||
|
||||
ViewProviderInspection::~ViewProviderInspection()
|
||||
@@ -119,7 +127,7 @@ void ViewProviderInspection::onChanged(const App::Property* prop)
|
||||
pcColorBar->Notify(0);
|
||||
}
|
||||
}
|
||||
else if ( prop == &PointSize ) {
|
||||
else if (prop == &PointSize) {
|
||||
pcPointStyle->pointSize = PointSize.getValue();
|
||||
}
|
||||
else {
|
||||
@@ -139,20 +147,20 @@ void ViewProviderInspection::show()
|
||||
pcColorStyle->style = SoDrawStyle::FILLED;
|
||||
}
|
||||
|
||||
void ViewProviderInspection::attach(App::DocumentObject *pcFeat)
|
||||
void ViewProviderInspection::attach(App::DocumentObject* pcFeat)
|
||||
{
|
||||
// creates the standard viewing modes
|
||||
inherited::attach(pcFeat);
|
||||
|
||||
SoShapeHints * flathints = new SoShapeHints;
|
||||
flathints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE ;
|
||||
SoShapeHints* flathints = new SoShapeHints;
|
||||
flathints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
|
||||
flathints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;
|
||||
|
||||
SoGroup* pcColorShadedRoot = new SoGroup();
|
||||
pcColorShadedRoot->addChild(flathints);
|
||||
|
||||
// color shaded ------------------------------------------
|
||||
SoDrawStyle *pcFlatStyle = new SoDrawStyle();
|
||||
SoDrawStyle* pcFlatStyle = new SoDrawStyle();
|
||||
pcFlatStyle->style = SoDrawStyle::FILLED;
|
||||
pcColorShadedRoot->addChild(pcFlatStyle);
|
||||
|
||||
@@ -163,11 +171,12 @@ void ViewProviderInspection::attach(App::DocumentObject *pcFeat)
|
||||
addDisplayMaskMode(pcColorShadedRoot, "ColorShaded");
|
||||
|
||||
// Check for an already existing color bar
|
||||
Gui::SoFCColorBar* pcBar = ((Gui::SoFCColorBar*)findFrontRootOfType(Gui::SoFCColorBar::getClassTypeId()));
|
||||
Gui::SoFCColorBar* pcBar =
|
||||
((Gui::SoFCColorBar*)findFrontRootOfType(Gui::SoFCColorBar::getClassTypeId()));
|
||||
if (pcBar) {
|
||||
float fMin = pcColorBar->getMinValue();
|
||||
float fMax = pcColorBar->getMaxValue();
|
||||
|
||||
|
||||
// Attach to the foreign color bar and delete our own bar
|
||||
pcBar->Attach(this);
|
||||
pcBar->ref();
|
||||
@@ -215,7 +224,8 @@ bool ViewProviderInspection::setupLines(const Data::ComplexGeoData* data)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ViewProviderInspection::setupPoints(const Data::ComplexGeoData* data, App::PropertyContainer* container)
|
||||
bool ViewProviderInspection::setupPoints(const Data::ComplexGeoData* data,
|
||||
App::PropertyContainer* container)
|
||||
{
|
||||
std::vector<Base::Vector3d> points;
|
||||
std::vector<Base::Vector3f> normals;
|
||||
@@ -227,14 +237,18 @@ bool ViewProviderInspection::setupPoints(const Data::ComplexGeoData* data, App::
|
||||
}
|
||||
|
||||
normals.reserve(normals_d.size());
|
||||
std::transform(normals_d.cbegin(), normals_d.cend(), std::back_inserter(normals), [](const Base::Vector3d& p){
|
||||
return Base::toVector<float>(p);
|
||||
});
|
||||
std::transform(normals_d.cbegin(),
|
||||
normals_d.cend(),
|
||||
std::back_inserter(normals),
|
||||
[](const Base::Vector3d& p) {
|
||||
return Base::toVector<float>(p);
|
||||
});
|
||||
|
||||
// If getPoints() doesn't deliver normals check a second property
|
||||
if (normals.empty() && container) {
|
||||
App::Property* propN = container->getPropertyByName("Normal");
|
||||
if (propN && propN->getTypeId().isDerivedFrom(Points::PropertyNormalList::getClassTypeId())) {
|
||||
if (propN
|
||||
&& propN->getTypeId().isDerivedFrom(Points::PropertyNormalList::getClassTypeId())) {
|
||||
normals = static_cast<Points::PropertyNormalList*>(propN)->getValues();
|
||||
}
|
||||
}
|
||||
@@ -255,9 +269,9 @@ void ViewProviderInspection::setupCoords(const std::vector<Base::Vector3d>& poin
|
||||
this->pcLinkRoot->addChild(this->pcCoords);
|
||||
this->pcCoords->point.setNum(points.size());
|
||||
SbVec3f* pts = this->pcCoords->point.startEditing();
|
||||
for (size_t i=0; i < points.size(); i++) {
|
||||
for (size_t i = 0; i < points.size(); i++) {
|
||||
const Base::Vector3d& p = points[i];
|
||||
pts[i].setValue((float)p.x,(float)p.y,(float)p.z);
|
||||
pts[i].setValue((float)p.x, (float)p.y, (float)p.z);
|
||||
}
|
||||
this->pcCoords->point.finishEditing();
|
||||
}
|
||||
@@ -268,7 +282,7 @@ void ViewProviderInspection::setupNormals(const std::vector<Base::Vector3f>& nor
|
||||
normalNode->vector.setNum(normals.size());
|
||||
SbVec3f* norm = normalNode->vector.startEditing();
|
||||
|
||||
std::size_t i=0;
|
||||
std::size_t i = 0;
|
||||
for (const auto& it : normals) {
|
||||
norm[i++].setValue(it.x, it.y, it.z);
|
||||
}
|
||||
@@ -283,11 +297,11 @@ void ViewProviderInspection::setupLineIndexes(const std::vector<Data::ComplexGeo
|
||||
this->pcLinkRoot->addChild(line);
|
||||
line->coordIndex.setNum(3 * lines.size());
|
||||
int32_t* indices = line->coordIndex.startEditing();
|
||||
unsigned long j=0;
|
||||
unsigned long j = 0;
|
||||
for (const auto& it : lines) {
|
||||
indices[3*j+0] = it.I1;
|
||||
indices[3*j+1] = it.I2;
|
||||
indices[3*j+2] = SO_END_LINE_INDEX;
|
||||
indices[3 * j + 0] = it.I1;
|
||||
indices[3 * j + 1] = it.I2;
|
||||
indices[3 * j + 2] = SO_END_LINE_INDEX;
|
||||
j++;
|
||||
}
|
||||
line->coordIndex.finishEditing();
|
||||
@@ -297,14 +311,14 @@ void ViewProviderInspection::setupFaceIndexes(const std::vector<Data::ComplexGeo
|
||||
{
|
||||
SoIndexedFaceSet* face = new SoIndexedFaceSet();
|
||||
this->pcLinkRoot->addChild(face);
|
||||
face->coordIndex.setNum(4*faces.size());
|
||||
face->coordIndex.setNum(4 * faces.size());
|
||||
int32_t* indices = face->coordIndex.startEditing();
|
||||
unsigned long j=0;
|
||||
unsigned long j = 0;
|
||||
for (const auto& it : faces) {
|
||||
indices[4*j+0] = it.I1;
|
||||
indices[4*j+1] = it.I2;
|
||||
indices[4*j+2] = it.I3;
|
||||
indices[4*j+3] = SO_END_FACE_INDEX;
|
||||
indices[4 * j + 0] = it.I1;
|
||||
indices[4 * j + 1] = it.I2;
|
||||
indices[4 * j + 2] = it.I3;
|
||||
indices[4 * j + 3] = SO_END_FACE_INDEX;
|
||||
j++;
|
||||
}
|
||||
face->coordIndex.finishEditing();
|
||||
@@ -314,8 +328,10 @@ void ViewProviderInspection::updateData(const App::Property* prop)
|
||||
{
|
||||
// set to the expected size
|
||||
if (prop->getTypeId().isDerivedFrom(App::PropertyLink::getClassTypeId())) {
|
||||
App::GeoFeature* object = static_cast<const App::PropertyLink*>(prop)->getValue<App::GeoFeature*>();
|
||||
const App::PropertyComplexGeoData* propData = object ? object->getPropertyOfGeometry() : nullptr;
|
||||
App::GeoFeature* object =
|
||||
static_cast<const App::PropertyLink*>(prop)->getValue<App::GeoFeature*>();
|
||||
const App::PropertyComplexGeoData* propData =
|
||||
object ? object->getPropertyOfGeometry() : nullptr;
|
||||
if (propData) {
|
||||
Gui::coinRemoveAllChildren(this->pcLinkRoot);
|
||||
|
||||
@@ -331,8 +347,9 @@ void ViewProviderInspection::updateData(const App::Property* prop)
|
||||
// force an update of the Inventor data nodes
|
||||
if (this->pcObject) {
|
||||
App::Property* link = this->pcObject->getPropertyByName("Actual");
|
||||
if (link)
|
||||
if (link) {
|
||||
updateData(link);
|
||||
}
|
||||
setDistances();
|
||||
}
|
||||
}
|
||||
@@ -340,7 +357,7 @@ void ViewProviderInspection::updateData(const App::Property* prop)
|
||||
if (strcmp(prop->getName(), "SearchRadius") == 0) {
|
||||
float fSearchRadius = ((App::PropertyFloat*)prop)->getValue();
|
||||
this->search_radius = fSearchRadius;
|
||||
pcColorBar->setRange( -fSearchRadius, fSearchRadius, 4 );
|
||||
pcColorBar->setRange(-fSearchRadius, fSearchRadius, 4);
|
||||
pcColorBar->Notify(0);
|
||||
}
|
||||
}
|
||||
@@ -353,8 +370,9 @@ SoSeparator* ViewProviderInspection::getFrontRoot() const
|
||||
|
||||
void ViewProviderInspection::setDistances()
|
||||
{
|
||||
if (!pcObject)
|
||||
if (!pcObject) {
|
||||
return;
|
||||
}
|
||||
|
||||
App::Property* pDistances = pcObject->getPropertyByName("Distances");
|
||||
if (!pDistances) {
|
||||
@@ -362,27 +380,32 @@ void ViewProviderInspection::setDistances()
|
||||
return;
|
||||
}
|
||||
if (pDistances->getTypeId() != Inspection::PropertyDistanceList::getClassTypeId()) {
|
||||
SoDebugError::post("ViewProviderInspection::setDistances",
|
||||
"Property 'Distances' has type %s (Inspection::PropertyDistanceList was expected)", pDistances->getTypeId().getName());
|
||||
SoDebugError::post(
|
||||
"ViewProviderInspection::setDistances",
|
||||
"Property 'Distances' has type %s (Inspection::PropertyDistanceList was expected)",
|
||||
pDistances->getTypeId().getName());
|
||||
return;
|
||||
}
|
||||
|
||||
// distance values
|
||||
const std::vector<float>& fValues = static_cast<Inspection::PropertyDistanceList*>(pDistances)->getValues();
|
||||
const std::vector<float>& fValues =
|
||||
static_cast<Inspection::PropertyDistanceList*>(pDistances)->getValues();
|
||||
if ((int)fValues.size() != this->pcCoords->point.getNum()) {
|
||||
pcMatBinding->value = SoMaterialBinding::OVERALL;
|
||||
return;
|
||||
}
|
||||
|
||||
if (pcColorMat->diffuseColor.getNum() != static_cast<int>(fValues.size()))
|
||||
if (pcColorMat->diffuseColor.getNum() != static_cast<int>(fValues.size())) {
|
||||
pcColorMat->diffuseColor.setNum(static_cast<int>(fValues.size()));
|
||||
if (pcColorMat->transparency.getNum() != static_cast<int>(fValues.size()))
|
||||
}
|
||||
if (pcColorMat->transparency.getNum() != static_cast<int>(fValues.size())) {
|
||||
pcColorMat->transparency.setNum(static_cast<int>(fValues.size()));
|
||||
}
|
||||
|
||||
SbColor * cols = pcColorMat->diffuseColor.startEditing();
|
||||
float * tran = pcColorMat->transparency.startEditing();
|
||||
SbColor* cols = pcColorMat->diffuseColor.startEditing();
|
||||
float* tran = pcColorMat->transparency.startEditing();
|
||||
|
||||
unsigned long j=0;
|
||||
unsigned long j = 0;
|
||||
for (std::vector<float>::const_iterator jt = fValues.begin(); jt != fValues.end(); ++jt, j++) {
|
||||
App::Color col = pcColorBar->getColor(*jt);
|
||||
cols[j] = SbColor(col.r, col.g, col.b);
|
||||
@@ -404,7 +427,7 @@ QIcon ViewProviderInspection::getIcon() const
|
||||
// Get the icon of the view provider to the associated feature
|
||||
QIcon px = inherited::getIcon();
|
||||
App::Property* pActual = pcObject->getPropertyByName("Actual");
|
||||
if (pActual && pActual->getTypeId().isDerivedFrom( App::PropertyLink::getClassTypeId())) {
|
||||
if (pActual && pActual->getTypeId().isDerivedFrom(App::PropertyLink::getClassTypeId())) {
|
||||
App::DocumentObject* docobj = ((App::PropertyLink*)pActual)->getValue();
|
||||
if (docobj) {
|
||||
Gui::Document* doc = Gui::Application::Instance->getDocument(docobj->getDocument());
|
||||
@@ -418,7 +441,7 @@ QIcon ViewProviderInspection::getIcon() const
|
||||
|
||||
void ViewProviderInspection::setDisplayMode(const char* ModeName)
|
||||
{
|
||||
if (strcmp("Visual Inspection",ModeName)==0) {
|
||||
if (strcmp("Visual Inspection", ModeName) == 0) {
|
||||
setDistances();
|
||||
setDisplayMaskMode("ColorShaded");
|
||||
}
|
||||
@@ -434,30 +457,37 @@ std::vector<std::string> ViewProviderInspection::getDisplayModes() const
|
||||
return StrList;
|
||||
}
|
||||
|
||||
void ViewProviderInspection::OnChange(Base::Subject<int> &/*rCaller*/, int /*rcReason*/)
|
||||
void ViewProviderInspection::OnChange(Base::Subject<int>& /*rCaller*/, int /*rcReason*/)
|
||||
{
|
||||
setActiveMode();
|
||||
}
|
||||
|
||||
namespace InspectionGui {
|
||||
namespace InspectionGui
|
||||
{
|
||||
// Proxy class that receives an asynchronous custom event
|
||||
class ViewProviderProxyObject : public QObject
|
||||
class ViewProviderProxyObject: public QObject
|
||||
{
|
||||
public:
|
||||
explicit ViewProviderProxyObject(QWidget* w) : QObject(nullptr), widget(w) {}
|
||||
explicit ViewProviderProxyObject(QWidget* w)
|
||||
: QObject(nullptr)
|
||||
, widget(w)
|
||||
{}
|
||||
~ViewProviderProxyObject() override = default;
|
||||
void customEvent(QEvent *) override
|
||||
void customEvent(QEvent*) override
|
||||
{
|
||||
if (!widget.isNull()) {
|
||||
QList<Gui::Flag*> flags = widget->findChildren<Gui::Flag*>();
|
||||
if (!flags.isEmpty()) {
|
||||
int ret = QMessageBox::question(Gui::getMainWindow(),
|
||||
QObject::tr("Remove annotations"),
|
||||
QObject::tr("Do you want to remove all annotations?"),
|
||||
QMessageBox::Yes,QMessageBox::No);
|
||||
int ret =
|
||||
QMessageBox::question(Gui::getMainWindow(),
|
||||
QObject::tr("Remove annotations"),
|
||||
QObject::tr("Do you want to remove all annotations?"),
|
||||
QMessageBox::Yes,
|
||||
QMessageBox::No);
|
||||
if (ret == QMessageBox::Yes) {
|
||||
for (auto it : flags)
|
||||
for (auto it : flags) {
|
||||
it->deleteLater();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -465,17 +495,19 @@ public:
|
||||
this->deleteLater();
|
||||
}
|
||||
|
||||
static void addFlag(Gui::View3DInventorViewer* view, const QString& text, const SoPickedPoint * point)
|
||||
static void
|
||||
addFlag(Gui::View3DInventorViewer* view, const QString& text, const SoPickedPoint* point)
|
||||
{
|
||||
Gui::Flag* flag = new Gui::Flag;
|
||||
QPalette p;
|
||||
p.setColor(QPalette::Window, QColor(85,0,127));
|
||||
p.setColor(QPalette::Text, QColor(220,220,220));
|
||||
p.setColor(QPalette::Window, QColor(85, 0, 127));
|
||||
p.setColor(QPalette::Text, QColor(220, 220, 220));
|
||||
flag->setPalette(p);
|
||||
flag->setText(text);
|
||||
flag->setOrigin(point->getPoint());
|
||||
Gui::GLFlagWindow* flags = nullptr;
|
||||
std::list<Gui::GLGraphicsItem*> glItems = view->getGraphicsItemsOfType(Gui::GLFlagWindow::getClassTypeId());
|
||||
std::list<Gui::GLGraphicsItem*> glItems =
|
||||
view->getGraphicsItemsOfType(Gui::GLFlagWindow::getClassTypeId());
|
||||
if (glItems.empty()) {
|
||||
flags = new Gui::GLFlagWindow(view);
|
||||
view->addGraphicsItem(flags);
|
||||
@@ -489,19 +521,21 @@ public:
|
||||
private:
|
||||
QPointer<QWidget> widget;
|
||||
};
|
||||
}
|
||||
}// namespace InspectionGui
|
||||
|
||||
void ViewProviderInspection::inspectCallback(void * ud, SoEventCallback * n)
|
||||
void ViewProviderInspection::inspectCallback(void* ud, SoEventCallback* n)
|
||||
{
|
||||
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(n->getUserData());
|
||||
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(n->getUserData());
|
||||
const SoEvent* ev = n->getEvent();
|
||||
if (ev->getTypeId() == SoMouseButtonEvent::getClassTypeId()) {
|
||||
const SoMouseButtonEvent * mbe = static_cast<const SoMouseButtonEvent *>(ev);
|
||||
const SoMouseButtonEvent* mbe = static_cast<const SoMouseButtonEvent*>(ev);
|
||||
|
||||
// Mark all incoming mouse button events as handled, especially, to deactivate the selection node
|
||||
// Mark all incoming mouse button events as handled, especially, to deactivate the selection
|
||||
// node
|
||||
n->getAction()->setHandled();
|
||||
n->setHandled();
|
||||
if (mbe->getButton() == SoMouseButtonEvent::BUTTON2 && mbe->getState() == SoButtonEvent::UP) {
|
||||
if (mbe->getButton() == SoMouseButtonEvent::BUTTON2
|
||||
&& mbe->getState() == SoButtonEvent::UP) {
|
||||
n->setHandled();
|
||||
// context-menu
|
||||
QMenu menu;
|
||||
@@ -516,9 +550,8 @@ void ViewProviderInspection::inspectCallback(void * ud, SoEventCallback * n)
|
||||
else if (cl == id) {
|
||||
// post an event to a proxy object to make sure to avoid problems
|
||||
// when opening a modal dialog
|
||||
QApplication::postEvent(
|
||||
new ViewProviderProxyObject(view->getGLWidget()),
|
||||
new QEvent(QEvent::User));
|
||||
QApplication::postEvent(new ViewProviderProxyObject(view->getGLWidget()),
|
||||
new QEvent(QEvent::User));
|
||||
view->setEditing(false);
|
||||
view->getWidget()->setCursor(QCursor(Qt::ArrowCursor));
|
||||
view->setRedirectToSceneGraph(false);
|
||||
@@ -527,8 +560,9 @@ void ViewProviderInspection::inspectCallback(void * ud, SoEventCallback * n)
|
||||
view->removeEventCallback(SoButtonEvent::getClassTypeId(), inspectCallback, ud);
|
||||
}
|
||||
}
|
||||
else if (mbe->getButton() == SoMouseButtonEvent::BUTTON1 && mbe->getState() == SoButtonEvent::UP) {
|
||||
const SoPickedPoint * point = n->getPickedPoint();
|
||||
else if (mbe->getButton() == SoMouseButtonEvent::BUTTON1
|
||||
&& mbe->getState() == SoButtonEvent::UP) {
|
||||
const SoPickedPoint* point = n->getPickedPoint();
|
||||
if (!point) {
|
||||
Base::Console().Message("No point picked.\n");
|
||||
return;
|
||||
@@ -541,11 +575,13 @@ void ViewProviderInspection::inspectCallback(void * ud, SoEventCallback * n)
|
||||
if (vp && vp->getTypeId().isDerivedFrom(ViewProviderInspection::getClassTypeId())) {
|
||||
ViewProviderInspection* that = static_cast<ViewProviderInspection*>(vp);
|
||||
QString info = that->inspectDistance(point);
|
||||
Gui::getMainWindow()->setPaneText(1,info);
|
||||
if (addflag)
|
||||
Gui::getMainWindow()->setPaneText(1, info);
|
||||
if (addflag) {
|
||||
ViewProviderProxyObject::addFlag(view, info, point);
|
||||
else
|
||||
}
|
||||
else {
|
||||
Gui::ToolTip::showText(QCursor::pos(), info);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// the nearest picked point was not part of the view provider
|
||||
@@ -555,17 +591,21 @@ void ViewProviderInspection::inspectCallback(void * ud, SoEventCallback * n)
|
||||
action.apply(view->getSoRenderManager()->getSceneGraph());
|
||||
|
||||
const SoPickedPointList& pps = action.getPickedPointList();
|
||||
for (int i=0; i<pps.getLength(); ++i) {
|
||||
const SoPickedPoint * point = pps[i];
|
||||
for (int i = 0; i < pps.getLength(); ++i) {
|
||||
const SoPickedPoint* point = pps[i];
|
||||
vp = view->getViewProviderByPathFromTail(point->getPath());
|
||||
if (vp && vp->getTypeId().isDerivedFrom(ViewProviderInspection::getClassTypeId())) {
|
||||
if (vp
|
||||
&& vp->getTypeId().isDerivedFrom(
|
||||
ViewProviderInspection::getClassTypeId())) {
|
||||
ViewProviderInspection* self = static_cast<ViewProviderInspection*>(vp);
|
||||
QString info = self->inspectDistance(point);
|
||||
Gui::getMainWindow()->setPaneText(1,info);
|
||||
if (addflag)
|
||||
Gui::getMainWindow()->setPaneText(1, info);
|
||||
if (addflag) {
|
||||
ViewProviderProxyObject::addFlag(view, info, point);
|
||||
else
|
||||
}
|
||||
else {
|
||||
Gui::ToolTip::showText(QCursor::pos(), info);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -574,9 +614,8 @@ void ViewProviderInspection::inspectCallback(void * ud, SoEventCallback * n)
|
||||
}
|
||||
// toggle between inspection and navigation mode
|
||||
else if (ev->getTypeId().isDerivedFrom(SoKeyboardEvent::getClassTypeId())) {
|
||||
const SoKeyboardEvent * const ke = static_cast<const SoKeyboardEvent *>(ev);
|
||||
if (ke->getState() == SoButtonEvent::DOWN &&
|
||||
ke->getKey() == SoKeyboardEvent::ESCAPE) {
|
||||
const SoKeyboardEvent* const ke = static_cast<const SoKeyboardEvent*>(ev);
|
||||
if (ke->getState() == SoButtonEvent::DOWN && ke->getKey() == SoKeyboardEvent::ESCAPE) {
|
||||
SbBool toggle = view->isRedirectedToSceneGraph();
|
||||
view->setRedirectToSceneGraph(!toggle);
|
||||
n->setHandled();
|
||||
@@ -584,29 +623,35 @@ void ViewProviderInspection::inspectCallback(void * ud, SoEventCallback * n)
|
||||
}
|
||||
}
|
||||
|
||||
namespace InspectionGui {
|
||||
float calcArea (const SbVec3f& v1, const SbVec3f& v2, const SbVec3f& v3)
|
||||
namespace InspectionGui
|
||||
{
|
||||
SbVec3f a = v2-v1;
|
||||
SbVec3f b = v3-v1;
|
||||
return a.cross(b).length()/2.0f;
|
||||
}
|
||||
|
||||
bool calcWeights(const SbVec3f& v1, const SbVec3f& v2, const SbVec3f& v3,
|
||||
const SbVec3f& p, float& w0, float& w1, float& w2)
|
||||
float calcArea(const SbVec3f& v1, const SbVec3f& v2, const SbVec3f& v3)
|
||||
{
|
||||
float fAreaABC = calcArea(v1,v2,v3);
|
||||
float fAreaPBC = calcArea(p,v2,v3);
|
||||
float fAreaPCA = calcArea(p,v3,v1);
|
||||
float fAreaPAB = calcArea(p,v1,v2);
|
||||
|
||||
w0=fAreaPBC/fAreaABC;
|
||||
w1=fAreaPCA/fAreaABC;
|
||||
w2=fAreaPAB/fAreaABC;
|
||||
|
||||
return fabs(w0+w1+w2-1.0f)<0.001f;
|
||||
SbVec3f a = v2 - v1;
|
||||
SbVec3f b = v3 - v1;
|
||||
return a.cross(b).length() / 2.0f;
|
||||
}
|
||||
|
||||
bool calcWeights(const SbVec3f& v1,
|
||||
const SbVec3f& v2,
|
||||
const SbVec3f& v3,
|
||||
const SbVec3f& p,
|
||||
float& w0,
|
||||
float& w1,
|
||||
float& w2)
|
||||
{
|
||||
float fAreaABC = calcArea(v1, v2, v3);
|
||||
float fAreaPBC = calcArea(p, v2, v3);
|
||||
float fAreaPCA = calcArea(p, v3, v1);
|
||||
float fAreaPAB = calcArea(p, v1, v2);
|
||||
|
||||
w0 = fAreaPBC / fAreaABC;
|
||||
w1 = fAreaPCA / fAreaABC;
|
||||
w2 = fAreaPAB / fAreaABC;
|
||||
|
||||
return fabs(w0 + w1 + w2 - 1.0f) < 0.001f;
|
||||
}
|
||||
}// namespace InspectionGui
|
||||
|
||||
QString ViewProviderInspection::inspectDistance(const SoPickedPoint* pp) const
|
||||
{
|
||||
@@ -614,24 +659,28 @@ QString ViewProviderInspection::inspectDistance(const SoPickedPoint* pp) const
|
||||
const SoDetail* detail = pp->getDetail(pp->getPath()->getTail());
|
||||
if (detail && detail->getTypeId() == SoFaceDetail::getClassTypeId()) {
|
||||
// get the distances of the three points of the picked facet
|
||||
const SoFaceDetail * facedetail = static_cast<const SoFaceDetail*>(detail);
|
||||
const SoFaceDetail* facedetail = static_cast<const SoFaceDetail*>(detail);
|
||||
App::Property* pDistance = this->pcObject->getPropertyByName("Distances");
|
||||
if (pDistance && pDistance->getTypeId() == Inspection::PropertyDistanceList::getClassTypeId()) {
|
||||
Inspection::PropertyDistanceList* dist = static_cast<Inspection::PropertyDistanceList*>(pDistance);
|
||||
if (pDistance
|
||||
&& pDistance->getTypeId() == Inspection::PropertyDistanceList::getClassTypeId()) {
|
||||
Inspection::PropertyDistanceList* dist =
|
||||
static_cast<Inspection::PropertyDistanceList*>(pDistance);
|
||||
int index1 = facedetail->getPoint(0)->getCoordinateIndex();
|
||||
int index2 = facedetail->getPoint(1)->getCoordinateIndex();
|
||||
int index3 = facedetail->getPoint(2)->getCoordinateIndex();
|
||||
float fVal1 = (*dist)[index1];
|
||||
float fVal2 = (*dist)[index2];
|
||||
float fVal3 = (*dist)[index3];
|
||||
|
||||
|
||||
App::Property* pActual = this->pcObject->getPropertyByName("Actual");
|
||||
if (pActual && pActual->getTypeId().isDerivedFrom( App::PropertyLink::getClassTypeId())) {
|
||||
if (pActual
|
||||
&& pActual->getTypeId().isDerivedFrom(App::PropertyLink::getClassTypeId())) {
|
||||
float fSearchRadius = this->search_radius;
|
||||
if (fVal1 > fSearchRadius || fVal2 > fSearchRadius || fVal3 > fSearchRadius) {
|
||||
info = QObject::tr("Distance: > %1").arg(fSearchRadius);
|
||||
}
|
||||
else if (fVal1 < -fSearchRadius || fVal2 < -fSearchRadius || fVal3 < -fSearchRadius) {
|
||||
else if (fVal1 < -fSearchRadius || fVal2 < -fSearchRadius
|
||||
|| fVal3 < -fSearchRadius) {
|
||||
info = QObject::tr("Distance: < %1").arg(-fSearchRadius);
|
||||
}
|
||||
else {
|
||||
@@ -642,7 +691,8 @@ QString ViewProviderInspection::inspectDistance(const SoPickedPoint* pp) const
|
||||
SoPath* selectionPath = searchAction.getPath();
|
||||
|
||||
if (selectionPath) {
|
||||
SoCoordinate3* coords = static_cast<SoCoordinate3*>(selectionPath->getTail());
|
||||
SoCoordinate3* coords =
|
||||
static_cast<SoCoordinate3*>(selectionPath->getTail());
|
||||
const SbVec3f& v1 = coords->point[index1];
|
||||
const SbVec3f& v2 = coords->point[index2];
|
||||
const SbVec3f& v3 = coords->point[index3];
|
||||
@@ -659,13 +709,14 @@ QString ViewProviderInspection::inspectDistance(const SoPickedPoint* pp) const
|
||||
}
|
||||
else if (detail && detail->getTypeId() == SoPointDetail::getClassTypeId()) {
|
||||
// safe downward cast, know the type
|
||||
const SoPointDetail * pointdetail = static_cast<const SoPointDetail*>(detail);
|
||||
const SoPointDetail* pointdetail = static_cast<const SoPointDetail*>(detail);
|
||||
|
||||
// get the distance of the picked point
|
||||
int index = pointdetail->getCoordinateIndex();
|
||||
App::Property* prop = this->pcObject->getPropertyByName("Distances");
|
||||
if (prop && prop->getTypeId() == Inspection::PropertyDistanceList::getClassTypeId()) {
|
||||
Inspection::PropertyDistanceList* dist = static_cast<Inspection::PropertyDistanceList*>(prop);
|
||||
Inspection::PropertyDistanceList* dist =
|
||||
static_cast<Inspection::PropertyDistanceList*>(prop);
|
||||
float fVal = (*dist)[index];
|
||||
info = QObject::tr("Distance: %1").arg(fVal);
|
||||
}
|
||||
@@ -691,6 +742,7 @@ ViewProviderInspectionGroup::~ViewProviderInspectionGroup() = default;
|
||||
*/
|
||||
QIcon ViewProviderInspectionGroup::getIcon() const
|
||||
{
|
||||
// clang-format off
|
||||
static const char * const ScanViewOpen[]={
|
||||
"16 16 10 1",
|
||||
"c c #000000",
|
||||
@@ -747,6 +799,7 @@ QIcon ViewProviderInspectionGroup::getIcon() const
|
||||
".##############c",
|
||||
"..cccccccccccccc",
|
||||
"................"};
|
||||
// clang-format on
|
||||
|
||||
QIcon groupIcon;
|
||||
groupIcon.addPixmap(QPixmap(ScanViewClosed), QIcon::Normal, QIcon::Off);
|
||||
|
||||
Reference in New Issue
Block a user