+ unify DLL export defines to namespace names

git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5000 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
wmayer
2011-10-10 13:44:52 +00:00
commit 120ca87015
4155 changed files with 2965978 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
/***************************************************************************
* Copyright (c) YEAR YOUR NAME <Your e-mail address> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <Python.h>
#endif
#include <Base/Console.h>
#include "InspectionFeature.h"
/* registration table */
extern struct PyMethodDef Inspection_methods[];
PyDoc_STRVAR(module_Inspection_doc,
"This module is the Inspection module.");
/* Python entry */
extern "C" {
void InspectionExport initInspection() {
// ADD YOUR CODE HERE
//
//
(void) Py_InitModule3("Inspection", Inspection_methods, module_Inspection_doc); /* mod name, table ptr */
Base::Console().Log("Loading Inspection module... done\n");
Inspection::Feature ::init();
Inspection::Group ::init();
}
} // extern "C"

View File

@@ -0,0 +1,38 @@
/***************************************************************************
* Copyright (c) YEAR YOUR NAME <Your e-mail address> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <Python.h>
#include <Base/Console.h>
#include <Base/PyObjectBase.h>
#include <Base/Exception.h>
/* registration table */
struct PyMethodDef Inspection_methods[] = {
{NULL, NULL} /* end of table marker */
};

View File

@@ -0,0 +1,55 @@
if(MSVC)
add_definitions(-DHAVE_ACOSH -DHAVE_ASINH -DHAVE_ATANH)
else(MSVC)
add_definitions(-DHAVE_LIMITS_H -DHAVE_CONFIG_H)
endif(MSVC)
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${Boost_INCLUDE_DIRS}
${OCC_INCLUDE_DIR}
${QT_QTCORE_INCLUDE_DIR}
${PYTHON_INCLUDE_PATH}
${ZLIB_INCLUDE_DIR}
${XERCESC_INCLUDE_DIR}
)
link_directories(${OCC_LIBRARY_DIR})
set(Inspection_LIBS
FreeCADApp
Mesh
Points
Part
)
SET(Inspection_SRCS
AppInspection.cpp
AppInspectionPy.cpp
InspectionFeature.cpp
InspectionFeature.h
PreCompiled.cpp
PreCompiled.h
)
add_library(Inspection SHARED ${Inspection_SRCS})
target_link_libraries(Inspection ${Inspection_LIBS})
fc_copy_script("Mod/Inspection" "Inspection" Init.py)
if(MSVC)
set_target_properties(Inspection PROPERTIES SUFFIX ".pyd")
set_target_properties(Inspection PROPERTIES DEBUG_OUTPUT_NAME "Inspection_d")
set_target_properties(Inspection PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Mod/Inspection)
set_target_properties(Inspection PROPERTIES PREFIX "../")
elseif(MINGW)
set_target_properties(Inspection PROPERTIES SUFFIX ".pyd")
set_target_properties(Inspection PROPERTIES DEBUG_OUTPUT_NAME "Inspection_d")
set_target_properties(Inspection PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Mod/Inspection)
set_target_properties(Inspection PROPERTIES PREFIX "")
else(MSVC)
set_target_properties(Inspection PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Mod/Inspection)
set_target_properties(Inspection PROPERTIES PREFIX "")
endif(MSVC)
install(TARGETS Inspection DESTINATION lib)

View File

@@ -0,0 +1,632 @@
/***************************************************************************
* Copyright (c) 2011 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#include <gp_Pnt.hxx>
#include <BRepExtrema_DistShapeShape.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <TopoDS_Vertex.hxx>
#include <QEventLoop>
#include <QFuture>
#include <QFutureWatcher>
#include <QtConcurrentMap>
#include <boost/signals.hpp>
#include <boost/bind.hpp>
#include <Base/Console.h>
#include <Base/Exception.h>
#include <Base/FutureWatcherProgress.h>
#include <Base/Parameter.h>
#include <Base/Sequencer.h>
#include <Base/Tools.h>
#include <App/Application.h>
#include <Mod/Mesh/App/Mesh.h>
#include <Mod/Mesh/App/MeshFeature.h>
#include <Mod/Mesh/App/Core/Algorithm.h>
#include <Mod/Mesh/App/Core/Grid.h>
#include <Mod/Mesh/App/Core/Iterator.h>
#include <Mod/Mesh/App/Core/MeshKernel.h>
#include <Mod/Points/App/PointsFeature.h>
#include <Mod/Points/App/PointsGrid.h>
#include <Mod/Part/App/PartFeature.h>
#include "InspectionFeature.h"
using namespace Inspection;
InspectActualMesh::InspectActualMesh(const Mesh::MeshObject& rMesh) : _iter(rMesh.getKernel())
{
this->_count = rMesh.countPoints();
this->_iter.Transform(rMesh.getTransform());
}
InspectActualMesh::~InspectActualMesh()
{
}
unsigned long InspectActualMesh::countPoints() const
{
return this->_count;
}
Base::Vector3f InspectActualMesh::getPoint(unsigned long index)
{
_iter.Set(index);
return *_iter;
}
// ----------------------------------------------------------------
InspectActualPoints::InspectActualPoints(const Points::PointKernel& rPoints) : _rKernel(rPoints)
{
}
unsigned long InspectActualPoints::countPoints() const
{
return _rKernel.size();
}
Base::Vector3f InspectActualPoints::getPoint(unsigned long index)
{
Base::Vector3d p = _rKernel.getPoint(index);
return Base::Vector3f((float)p.x,(float)p.y,(float)p.z);
}
// ----------------------------------------------------------------
InspectActualShape::InspectActualShape(const Part::TopoShape& shape) : _rShape(shape)
{
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Mod/Part");
float deviation = hGrp->GetFloat("MeshDeviation",0.2);
Base::BoundBox3d bbox = _rShape.getBoundBox();
Standard_Real deflection = (bbox.LengthX() + bbox.LengthY() + bbox.LengthZ())/300.0 * deviation;
std::vector<Data::ComplexGeoData::Facet> f;
_rShape.getFaces(points, f, (float)deflection);
}
unsigned long InspectActualShape::countPoints() const
{
return points.size();
}
Base::Vector3f InspectActualShape::getPoint(unsigned long index)
{
return Base::toVector<float>(points[index]);
}
// ----------------------------------------------------------------
namespace Inspection {
class MeshInspectGrid : public MeshCore::MeshGrid
{
public:
MeshInspectGrid (const MeshCore::MeshKernel &mesh, float fGridLen, const Base::Matrix4D& m)
: MeshCore::MeshGrid(mesh), _transform(m)
{
Base::BoundBox3f clBBMesh = _pclMesh->GetBoundBox().Transformed(m);
Rebuild(std::max<unsigned long>((unsigned long)(clBBMesh.LengthX() / fGridLen), 1),
std::max<unsigned long>((unsigned long)(clBBMesh.LengthY() / fGridLen), 1),
std::max<unsigned long>((unsigned long)(clBBMesh.LengthZ() / fGridLen), 1));
}
void Validate (const MeshCore::MeshKernel&)
{
// do nothing
}
void Validate (void)
{
// do nothing
}
bool Verify() const
{
// do nothing
return true;
}
protected:
void CalculateGridLength (unsigned long ulCtGrid, unsigned long ulMaxGrids)
{
// do nothing
}
void CalculateGridLength (int iCtGridPerAxis)
{
// do nothing
}
unsigned long HasElements (void) const
{
return _pclMesh->CountFacets();
}
void Pos (const Base::Vector3f &rclPoint, unsigned long &rulX, unsigned long &rulY, unsigned long &rulZ) const
{
rulX = (unsigned long)((rclPoint.x - _fMinX) / _fGridLenX);
rulY = (unsigned long)((rclPoint.y - _fMinY) / _fGridLenY);
rulZ = (unsigned long)((rclPoint.z - _fMinZ) / _fGridLenZ);
assert((rulX < _ulCtGridsX) && (rulY < _ulCtGridsY) && (rulZ < _ulCtGridsZ));
}
void AddFacet (const MeshCore::MeshGeomFacet &rclFacet, unsigned long ulFacetIndex)
{
unsigned long ulX, ulY, ulZ;
unsigned long ulX1, ulY1, ulZ1, ulX2, ulY2, ulZ2;
Base::BoundBox3f clBB;
clBB &= rclFacet._aclPoints[0];
clBB &= rclFacet._aclPoints[1];
clBB &= rclFacet._aclPoints[2];
Pos(Base::Vector3f(clBB.MinX,clBB.MinY,clBB.MinZ), ulX1, ulY1, ulZ1);
Pos(Base::Vector3f(clBB.MaxX,clBB.MaxY,clBB.MaxZ), ulX2, ulY2, ulZ2);
if ((ulX1 < ulX2) || (ulY1 < ulY2) || (ulZ1 < ulZ2)) {
for (ulX = ulX1; ulX <= ulX2; ulX++) {
for (ulY = ulY1; ulY <= ulY2; ulY++) {
for (ulZ = ulZ1; ulZ <= ulZ2; ulZ++) {
if (rclFacet.IntersectBoundingBox(GetBoundBox(ulX, ulY, ulZ)))
_aulGrid[ulX][ulY][ulZ].insert(ulFacetIndex);
}
}
}
}
else
_aulGrid[ulX1][ulY1][ulZ1].insert(ulFacetIndex);
}
void InitGrid (void)
{
unsigned long i, j;
Base::BoundBox3f clBBMesh = _pclMesh->GetBoundBox().Transformed(_transform);
float fLengthX = clBBMesh.LengthX();
float fLengthY = clBBMesh.LengthY();
float fLengthZ = clBBMesh.LengthZ();
_fGridLenX = (1.0f + fLengthX) / float(_ulCtGridsX);
_fMinX = clBBMesh.MinX - 0.5f;
_fGridLenY = (1.0f + fLengthY) / float(_ulCtGridsY);
_fMinY = clBBMesh.MinY - 0.5f;
_fGridLenZ = (1.0f + fLengthZ) / float(_ulCtGridsZ);
_fMinZ = clBBMesh.MinZ - 0.5f;
_aulGrid.clear();
_aulGrid.resize(_ulCtGridsX);
for (i = 0; i < _ulCtGridsX; i++) {
_aulGrid[i].resize(_ulCtGridsY);
for (j = 0; j < _ulCtGridsY; j++)
_aulGrid[i][j].resize(_ulCtGridsZ);
}
}
void RebuildGrid (void)
{
_ulCtElements = _pclMesh->CountFacets();
InitGrid();
unsigned long i = 0;
MeshCore::MeshFacetIterator clFIter(*_pclMesh);
clFIter.Transform(_transform);
for (clFIter.Init(); clFIter.More(); clFIter.Next()) {
AddFacet(*clFIter, i++);
}
}
private:
Base::Matrix4D _transform;
};
}
InspectNominalMesh::InspectNominalMesh(const Mesh::MeshObject& rMesh, float offset) : _iter(rMesh.getKernel())
{
const MeshCore::MeshKernel& kernel = rMesh.getKernel();
_iter.Transform(rMesh.getTransform());
// Max. limit of grid elements
float fMaxGridElements=8000000.0f;
Base::BoundBox3f box = kernel.GetBoundBox().Transformed(rMesh.getTransform());
// estimate the minimum allowed grid length
float fMinGridLen = (float)pow((box.LengthX()*box.LengthY()*box.LengthZ()/fMaxGridElements), 0.3333f);
float fGridLen = 5.0f * MeshCore::MeshAlgorithm(kernel).GetAverageEdgeLength();
// We want to avoid to get too small grid elements otherwise building up the grid structure would take
// too much time and memory.
// Having quite a dense grid speeds up more the following algorithms extremely. Due to the issue above it's
// always a compromise between speed and memory usage.
fGridLen = std::max<float>(fMinGridLen, fGridLen);
// build up grid structure to speed up algorithms
_pGrid = new MeshInspectGrid(kernel, fGridLen, rMesh.getTransform());
_box = box;
_box.Enlarge(offset);
}
InspectNominalMesh::~InspectNominalMesh()
{
delete this->_pGrid;
}
float InspectNominalMesh::getDistance(const Base::Vector3f& point)
{
if (!_box.IsInBox(point))
return FLT_MAX; // must be inside bbox
std::vector<unsigned long> indices;
//_pGrid->GetElements(point, indices);
if (indices.empty()) {
std::set<unsigned long> inds;
_pGrid->MeshGrid::SearchNearestFromPoint(point, inds);
indices.insert(indices.begin(), inds.begin(), inds.end());
}
float fMinDist=FLT_MAX;
bool positive = true;
for (std::vector<unsigned long>::iterator it = indices.begin(); it != indices.end(); ++it) {
_iter.Set(*it);
float fDist = _iter->DistanceToPoint(point);
if (fabs(fDist) < fabs(fMinDist)) {
fMinDist = fDist;
positive = point.DistanceToPlane(_iter->_aclPoints[0], _iter->GetNormal()) > 0;
}
}
if (!positive)
fMinDist = -fMinDist;
return fMinDist;
}
// ----------------------------------------------------------------
InspectNominalFastMesh::InspectNominalFastMesh(const Mesh::MeshObject& rMesh, float offset) : _iter(rMesh.getKernel())
{
const MeshCore::MeshKernel& kernel = rMesh.getKernel();
_iter.Transform(rMesh.getTransform());
// Max. limit of grid elements
float fMaxGridElements=8000000.0f;
Base::BoundBox3f box = kernel.GetBoundBox().Transformed(rMesh.getTransform());
// estimate the minimum allowed grid length
float fMinGridLen = (float)pow((box.LengthX()*box.LengthY()*box.LengthZ()/fMaxGridElements), 0.3333f);
float fGridLen = 5.0f * MeshCore::MeshAlgorithm(kernel).GetAverageEdgeLength();
// We want to avoid to get too small grid elements otherwise building up the grid structure would take
// too much time and memory.
// Having quite a dense grid speeds up more the following algorithms extremely. Due to the issue above it's
// always a compromise between speed and memory usage.
fGridLen = std::max<float>(fMinGridLen, fGridLen);
// build up grid structure to speed up algorithms
_pGrid = new MeshInspectGrid(kernel, fGridLen, rMesh.getTransform());
_box = box;
_box.Enlarge(offset);
max_level = (unsigned long)(offset/fGridLen);
}
InspectNominalFastMesh::~InspectNominalFastMesh()
{
delete this->_pGrid;
}
/**
* This algorithm is not that exact as that from InspectNominalMesh but is by
* factors faster and sufficient for many cases.
*/
float InspectNominalFastMesh::getDistance(const Base::Vector3f& point)
{
if (!_box.IsInBox(point))
return FLT_MAX; // must be inside bbox
std::set<unsigned long> indices;
#if 0 // a point in a neighbour grid can be nearer
std::vector<unsigned long> elements;
_pGrid->GetElements(point, elements);
indices.insert(elements.begin(), elements.end());
#else
unsigned long ulX, ulY, ulZ;
_pGrid->Position(point, ulX, ulY, ulZ);
unsigned long ulLevel = 0;
while (indices.size() == 0 && ulLevel <= max_level)
_pGrid->GetHull(ulX, ulY, ulZ, ulLevel++, indices);
if (indices.size() == 0 || ulLevel==1)
_pGrid->GetHull(ulX, ulY, ulZ, ulLevel, indices);
#endif
float fMinDist=FLT_MAX;
bool positive = true;
for (std::set<unsigned long>::iterator it = indices.begin(); it != indices.end(); ++it) {
_iter.Set(*it);
float fDist = _iter->DistanceToPoint(point);
if (fabs(fDist) < fabs(fMinDist)) {
fMinDist = fDist;
positive = point.DistanceToPlane(_iter->_aclPoints[0], _iter->GetNormal()) > 0;
}
}
if (!positive)
fMinDist = -fMinDist;
return fMinDist;
}
// ----------------------------------------------------------------
InspectNominalPoints::InspectNominalPoints(const Points::PointKernel& Kernel, float offset) : _rKernel(Kernel)
{
int uGridPerAxis = 50; // totally 125.000 grid elements
this->_pGrid = new Points::PointsGrid (Kernel, uGridPerAxis);
}
InspectNominalPoints::~InspectNominalPoints()
{
delete this->_pGrid;
}
float InspectNominalPoints::getDistance(const Base::Vector3f& point)
{
//TODO: Make faster
std::set<unsigned long> indices;
unsigned long x,y,z;
Base::Vector3d pointd(point.x,point.y,point.z);
_pGrid->Position(pointd, x, y, z);
_pGrid->GetElements(x,y,z,indices);
double fMinDist=DBL_MAX;
for (std::set<unsigned long>::iterator it = indices.begin(); it != indices.end(); ++it) {
Base::Vector3d pt = _rKernel.getPoint(*it);
double fDist = Base::Distance(pointd, pt);
if (fDist < fMinDist) {
fMinDist = fDist;
}
}
return (float)fMinDist;
}
// ----------------------------------------------------------------
InspectNominalShape::InspectNominalShape(const TopoDS_Shape& shape, float radius) : _rShape(shape)
{
distss = new BRepExtrema_DistShapeShape();
distss->LoadS1(_rShape);
//distss->SetDeflection(radius);
}
InspectNominalShape::~InspectNominalShape()
{
delete distss;
}
float InspectNominalShape::getDistance(const Base::Vector3f& point)
{
BRepBuilderAPI_MakeVertex mkVert(gp_Pnt(point.x,point.y,point.z));
distss->LoadS2(mkVert.Vertex());
float fMinDist=FLT_MAX;
if (distss->Perform() && distss->NbSolution() > 0)
fMinDist = (float)distss->Value();
return fMinDist;
}
// ----------------------------------------------------------------
// helper class to use Qt's concurrent framework
struct DistanceInspection
{
DistanceInspection(float radius, InspectActualGeometry* a,
std::vector<InspectNominalGeometry*> n)
: radius(radius), actual(a), nominal(n)
{
}
float mapped(unsigned long index)
{
Base::Vector3f pnt = actual->getPoint(index);
float fMinDist=FLT_MAX;
for (std::vector<InspectNominalGeometry*>::iterator it = nominal.begin(); it != nominal.end(); ++it) {
float fDist = (*it)->getDistance(pnt);
if (fabs(fDist) < fabs(fMinDist))
fMinDist = fDist;
}
if (fMinDist > this->radius)
fMinDist = FLT_MAX;
else if (-fMinDist > this->radius)
fMinDist = -FLT_MAX;
return fMinDist;
}
float radius;
InspectActualGeometry* actual;
std::vector<InspectNominalGeometry*> nominal;
};
PROPERTY_SOURCE(Inspection::Feature, App::DocumentObject)
Feature::Feature()
{
ADD_PROPERTY(SearchRadius,(0.05f));
ADD_PROPERTY(Thickness,(0.0f));
ADD_PROPERTY(Actual,(0));
ADD_PROPERTY(Nominals,(0));
ADD_PROPERTY(Distances,(0.0f));
}
Feature::~Feature()
{
}
short Feature::mustExecute() const
{
if (SearchRadius.isTouched())
return 1;
if (Thickness.isTouched())
return 1;
if (Actual.isTouched())
return 1;
if (Nominals.isTouched())
return 1;
return 0;
}
App::DocumentObjectExecReturn* Feature::execute(void)
{
App::DocumentObject* pcActual = Actual.getValue();
if (!pcActual)
throw Base::Exception("No actual geometry to inspect specified");
InspectActualGeometry* actual = 0;
if (pcActual->getTypeId().isDerivedFrom(Mesh::Feature::getClassTypeId())) {
Mesh::Feature* mesh = static_cast<Mesh::Feature*>(pcActual);
actual = new InspectActualMesh(mesh->Mesh.getValue());
}
else if (pcActual->getTypeId().isDerivedFrom(Points::Feature::getClassTypeId())) {
Points::Feature* pts = static_cast<Points::Feature*>(pcActual);
actual = new InspectActualPoints(pts->Points.getValue());
}
else if (pcActual->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
Part::Feature* part = static_cast<Part::Feature*>(pcActual);
actual = new InspectActualShape(part->Shape.getShape());
}
else {
throw Base::Exception("Unknown geometric type");
}
// get a list of nominals
std::vector<InspectNominalGeometry*> inspectNominal;
const std::vector<App::DocumentObject*>& nominals = Nominals.getValues();
for (std::vector<App::DocumentObject*>::const_iterator it = nominals.begin(); it != nominals.end(); ++it) {
InspectNominalGeometry* nominal = 0;
if ((*it)->getTypeId().isDerivedFrom(Mesh::Feature::getClassTypeId())) {
Mesh::Feature* mesh = static_cast<Mesh::Feature*>(*it);
nominal = new InspectNominalMesh(mesh->Mesh.getValue(), this->SearchRadius.getValue());
}
else if ((*it)->getTypeId().isDerivedFrom(Points::Feature::getClassTypeId())) {
Points::Feature* pts = static_cast<Points::Feature*>(*it);
nominal = new InspectNominalPoints(pts->Points.getValue(), this->SearchRadius.getValue());
}
else if ((*it)->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
Part::Feature* part = static_cast<Part::Feature*>(*it);
nominal = new InspectNominalShape(part->Shape.getValue(), this->SearchRadius.getValue());
}
if (nominal)
inspectNominal.push_back(nominal);
}
#if 0 // test with some huge data sets
Standard::SetReentrant(Standard_True);
std::vector<unsigned long> index(actual->countPoints());
std::generate(index.begin(), index.end(), Base::iotaGen<unsigned long>(0));
DistanceInspection check(this->SearchRadius.getValue(), actual, inspectNominal);
QFuture<float> future = QtConcurrent::mapped
(index, boost::bind(&DistanceInspection::mapped, &check, _1));
//future.waitForFinished(); // blocks the GUI
Base::FutureWatcherProgress progress("Inspecting...", actual->countPoints());
QFutureWatcher<float> watcher;
QObject::connect(&watcher, SIGNAL(progressValueChanged(int)),
&progress, SLOT(progressValueChanged(int)));
watcher.setFuture(future);
// keep it responsive during computation
QEventLoop loop;
QObject::connect(&watcher, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
std::vector<float> vals;
vals.insert(vals.end(), future.begin(), future.end());
#else
unsigned long count = actual->countPoints();
std::stringstream str;
str << "Inspecting " << this->Label.getValue() << "...";
Base::SequencerLauncher seq(str.str().c_str(), count);
std::vector<float> vals(count);
for (unsigned long index = 0; index < count; index++) {
Base::Vector3f pnt = actual->getPoint(index);
float fMinDist=FLT_MAX;
for (std::vector<InspectNominalGeometry*>::iterator it = inspectNominal.begin(); it != inspectNominal.end(); ++it) {
float fDist = (*it)->getDistance(pnt);
if (fabs(fDist) < fabs(fMinDist))
fMinDist = fDist;
}
if (fMinDist > this->SearchRadius.getValue())
fMinDist = FLT_MAX;
else if (-fMinDist > this->SearchRadius.getValue())
fMinDist = -FLT_MAX;
vals[index] = fMinDist;
seq.next();
}
#endif
Distances.setValues(vals);
float fRMS = 0;
int countRMS = 0;
for (std::vector<float>::iterator it = vals.begin(); it != vals.end(); ++it) {
if (fabs(*it) < FLT_MAX) {
fRMS += (*it) * (*it);
countRMS++;
}
}
fRMS = fRMS / countRMS;
fRMS = sqrt(fRMS);
Base::Console().Message("RMS value for '%s' with search radius=%.4f is: %.4f\n",
this->Label.getValue(), this->SearchRadius.getValue(), fRMS);
delete actual;
for (std::vector<InspectNominalGeometry*>::iterator it = inspectNominal.begin(); it != inspectNominal.end(); ++it)
delete *it;
return 0;
}
// ----------------------------------------------------------------
PROPERTY_SOURCE(Inspection::Group, App::DocumentObjectGroup)
Group::Group()
{
}
Group::~Group()
{
}

View File

@@ -0,0 +1,208 @@
/***************************************************************************
* Copyright (c) 2011 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef INSPECTION_FEATURE_H
#define INSPECTION_FEATURE_H
#include <App/DocumentObject.h>
#include <App/PropertyLinks.h>
#include <App/DocumentObjectGroup.h>
#include <Mod/Mesh/App/Core/Iterator.h>
#include <Mod/Points/App/Points.h>
class TopoDS_Shape;
class BRepExtrema_DistShapeShape;
namespace MeshCore {
class MeshKernel;
class MeshGrid;
}
namespace Mesh { class MeshObject; }
namespace Points { class PointsGrid; }
namespace Part { class TopoShape; }
namespace Inspection
{
/** Delivers the number of points to be checked and returns the appropriate point to an index. */
class InspectionExport InspectActualGeometry
{
public:
InspectActualGeometry() {}
virtual ~InspectActualGeometry() {}
/// Number of points to be checked
virtual unsigned long countPoints() const = 0;
virtual Base::Vector3f getPoint(unsigned long) = 0;
};
class InspectionExport InspectActualMesh : public InspectActualGeometry
{
public:
InspectActualMesh(const Mesh::MeshObject& rMesh);
~InspectActualMesh();
virtual unsigned long countPoints() const;
virtual Base::Vector3f getPoint(unsigned long);
private:
MeshCore::MeshPointIterator _iter;
unsigned long _count;
};
class InspectionExport InspectActualPoints : public InspectActualGeometry
{
public:
InspectActualPoints(const Points::PointKernel&);
virtual unsigned long countPoints() const;
virtual Base::Vector3f getPoint(unsigned long);
private:
const Points::PointKernel& _rKernel;
};
class InspectionExport InspectActualShape : public InspectActualGeometry
{
public:
InspectActualShape(const Part::TopoShape&);
virtual unsigned long countPoints() const;
virtual Base::Vector3f getPoint(unsigned long);
private:
const Part::TopoShape& _rShape;
std::vector<Base::Vector3d> points;
};
/** Calculates the shortest distance of the underlying geometry to a given point. */
class InspectionExport InspectNominalGeometry
{
public:
InspectNominalGeometry() {}
virtual ~InspectNominalGeometry() {}
virtual float getDistance(const Base::Vector3f&) = 0;
};
class InspectionExport InspectNominalMesh : public InspectNominalGeometry
{
public:
InspectNominalMesh(const Mesh::MeshObject& rMesh, float offset);
~InspectNominalMesh();
virtual float getDistance(const Base::Vector3f&);
private:
MeshCore::MeshFacetIterator _iter;
MeshCore::MeshGrid* _pGrid;
Base::BoundBox3f _box;
};
class InspectionExport InspectNominalFastMesh : public InspectNominalGeometry
{
public:
InspectNominalFastMesh(const Mesh::MeshObject& rMesh, float offset);
~InspectNominalFastMesh();
virtual float getDistance(const Base::Vector3f&);
protected:
MeshCore::MeshFacetIterator _iter;
MeshCore::MeshGrid* _pGrid;
Base::BoundBox3f _box;
unsigned long max_level;
};
class InspectionExport InspectNominalPoints : public InspectNominalGeometry
{
public:
InspectNominalPoints(const Points::PointKernel&, float offset);
~InspectNominalPoints();
virtual float getDistance(const Base::Vector3f&);
private:
const Points::PointKernel& _rKernel;
Points::PointsGrid* _pGrid;
};
class InspectionExport InspectNominalShape : public InspectNominalGeometry
{
public:
InspectNominalShape(const TopoDS_Shape&, float offset);
~InspectNominalShape();
virtual float getDistance(const Base::Vector3f&);
private:
BRepExtrema_DistShapeShape* distss;
const TopoDS_Shape& _rShape;
};
// ----------------------------------------------------------------
/** The inspection feature.
* \author Werner Mayer
*/
class InspectionExport Feature : public App::DocumentObject
{
PROPERTY_HEADER(Inspection::Feature);
public:
/// Constructor
Feature(void);
virtual ~Feature();
/** @name Properties */
//@{
App::PropertyFloat SearchRadius;
App::PropertyFloat Thickness;
App::PropertyLink Actual;
App::PropertyLinkList Nominals;
App::PropertyFloatList Distances;
//@}
/** @name Actions */
//@{
short mustExecute() const;
/// recalculate the Feature
App::DocumentObjectExecReturn* execute(void);
//@}
/// returns the type name of the ViewProvider
const char* getViewProviderName(void) const
{ return "InspectionGui::ViewProviderInspection"; }
};
class InspectionExport Group : public App::DocumentObjectGroup
{
PROPERTY_HEADER(Inspection::Group);
public:
/// Constructor
Group(void);
virtual ~Group();
/// returns the type name of the ViewProvider
const char* getViewProviderName(void) const
{ return "InspectionGui::ViewProviderInspectionGroup"; }
};
} //namespace Inspection
#endif // INSPECTION_FEATURE_H

View File

@@ -0,0 +1,72 @@
lib_LTLIBRARIES=libInspection.la Inspection.la
libInspection_la_SOURCES=\
AppInspectionPy.cpp \
InspectionFeature.cpp \
InspectionFeature.h \
PreCompiled.cpp \
PreCompiled.h
includedir = @includedir@/Mod/Inspection/App
# the library search path.
libInspection_la_LDFLAGS = -L$(top_builddir)/src/Base -L$(top_builddir)/src/App \
-L$(top_builddir)/src/Mod/Mesh/App \
-L$(top_builddir)/src/Mod/Points/App \
-L$(top_builddir)/src/Mod/Part/App \
-L$(OCC_LIB) $(QT4_CORE_LIBS) $(all_libraries) \
-version-info @LIB_CURRENT@:@LIB_REVISION@:@LIB_AGE@
libInspection_la_CPPFLAGS = -DInspectionAppExport=
libInspection_la_LIBADD = \
@BOOST_SYSTEM_LIB@ \
-l@PYTHON_LIB@ \
-lxerces-c \
-lTKernel \
-lTKFillet \
-lTKG2d \
-lTKG3d \
-lTKMath \
-lTKMesh \
-lTKXSBase \
-lTKBool \
-lTKBO \
-lTKBRep \
-lTKTopAlgo \
-lTKGeomAlgo \
-lTKGeomBase \
-lTKOffset \
-lTKPrim \
-lFreeCADBase \
-lFreeCADApp \
-lMesh \
-lPoints \
-lPart
#--------------------------------------------------------------------------------------
# Loader of libInspection
Inspection_la_SOURCES=\
AppInspection.cpp
# the library search path.
Inspection_la_LDFLAGS = $(libInspection_la_LDFLAGS) -module -avoid-version
Inspection_la_CPPFLAGS = $(libInspection_la_CPPFLAGS)
Inspection_la_LIBADD = \
$(libInspection_la_LIBADD) \
-lInspection
Inspection_la_DEPENDENCIES = libInspection.la
#--------------------------------------------------------------------------------------
# set the include path found by configure
AM_CXXFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/src $(all_includes) \
$(QT4_CORE_CXXFLAGS) -I$(OCC_INC)
libdir = $(prefix)/Mod/Inspection
EXTRA_DIST = \
CMakeLists.txt

View File

@@ -0,0 +1,24 @@
/***************************************************************************
* Copyright (c) YEAR YOUR NAME <Your e-mail address> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"

View File

@@ -0,0 +1,72 @@
/***************************************************************************
* Copyright (c) YEAR YOUR NAME <Your e-mail address> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef APP_PRECOMPILED_H
#define APP_PRECOMPILED_H
#include <FCConfig.h>
// Exporting of App classes
#ifdef FC_OS_WIN32
# define InspectionExport __declspec(dllexport)
# define MeshExport __declspec(dllimport)
# define PointsExport __declspec(dllimport)
# define PartExport __declspec(dllimport)
#else // for Linux
# define InspectionExport
# define MeshExport
# define PointsExport
# define PartExport
#endif
#ifdef _MSC_VER
# pragma warning(disable : 4290)
# pragma warning(disable : 4275)
#endif
#ifdef _PreComp_
// standard
#include <cstdio>
#include <cassert>
#include <iostream>
// STL
#include <algorithm>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
// Xerces
#include <xercesc/util/XercesDefs.hpp>
#endif //_PreComp_
#endif

View File

@@ -0,0 +1,13 @@
add_subdirectory(App)
if(FREECAD_BUILD_GUI)
add_subdirectory(Gui)
endif(FREECAD_BUILD_GUI)
install(
FILES
Init.py
InitGui.py
DESTINATION
Mod/Inspection
)

View File

@@ -0,0 +1,69 @@
/***************************************************************************
* Copyright (c) YEAR YOUR NAME <Your e-mail address> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <Python.h>
#endif
#include <Base/Console.h>
#include <Gui/Application.h>
#include "ViewProviderInspection.h"
#include "Workbench.h"
// use a different name to CreateCommand()
void CreateInspectionCommands(void);
/* registration table */
extern struct PyMethodDef InspectionGui_methods[];
PyDoc_STRVAR(module_InspectionGui_doc,
"This module is the InspectionGui module.");
/* Python entry */
extern "C" {
void InspectionGuiExport initInspectionGui()
{
if (!Gui::Application::Instance) {
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
return;
}
// instanciating the commands
CreateInspectionCommands();
InspectionGui::ViewProviderInspection ::init();
InspectionGui::ViewProviderInspectionGroup ::init();
InspectionGui::Workbench ::init();
// ADD YOUR CODE HERE
//
//
(void) Py_InitModule3("InspectionGui", InspectionGui_methods, module_InspectionGui_doc); /* mod name, table ptr */
Base::Console().Log("Loading GUI of Inspection module... done\n");
}
} // extern "C"

View File

@@ -0,0 +1,35 @@
/***************************************************************************
* Copyright (c) YEAR YOUR NAME <Your e-mail address> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <Base/Console.h>
#include <Base/Exception.h>
/* registration table */
struct PyMethodDef InspectionGui_methods[] = {
{NULL, NULL} /* end of table marker */
};

View File

@@ -0,0 +1,72 @@
include_directories(
${CMAKE_SOURCE_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}
${Boost_INCLUDE_DIRS}
${COIN3D_INCLUDE_DIR}
${SOQT_INCLUDE_DIR}
${QT_INCLUDE_DIR}
${PYTHON_INCLUDE_PATH}
${XERCESC_INCLUDE_DIR}
${ZLIB_INCLUDE_DIR}
)
link_directories(${OCC_LIBRARY_DIR})
set(InspectionGui_LIBS
Inspection
FreeCADGui
)
qt4_add_resources(Inspection_QRC_SRCS Resources/Inspection.qrc)
set(InspectionGui_MOC_HDRS
VisualInspection.h
)
fc_wrap_cpp(InspectionGui_MOC_SRCS ${InspectionGui_MOC_HDRS})
SOURCE_GROUP("Moc" FILES ${InspectionGui_MOC_SRCS})
set(Dialogs_UIC_SRCS
VisualInspection.ui
)
qt4_wrap_ui(Dialogs_UIC_HDRS ${Dialogs_UIC_SRCS})
SET(Dialogs_SRCS
${Dialogs_UIC_HDRS}
VisualInspection.cpp
VisualInspection.h
)
SOURCE_GROUP("Dialogs" FILES ${Dialogs_SRCS})
SET(InspectionGui_SRCS
${Inspection_QRC_SRCS}
${Dialogs_SRCS}
AppInspectionGui.cpp
AppInspectionGuiPy.cpp
Command.cpp
PreCompiled.cpp
PreCompiled.h
ViewProviderInspection.cpp
ViewProviderInspection.h
Workbench.cpp
Workbench.h
)
add_library(InspectionGui SHARED ${InspectionGui_SRCS})
target_link_libraries(InspectionGui ${InspectionGui_LIBS})
fc_copy_script("Mod/Inspection" "InspectionGui" InitGui.py)
if(MSVC)
set_target_properties(InspectionGui PROPERTIES SUFFIX ".pyd")
set_target_properties(InspectionGui PROPERTIES DEBUG_OUTPUT_NAME "InspectionGui_d")
set_target_properties(InspectionGui PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Mod/Inspection)
set_target_properties(InspectionGui PROPERTIES PREFIX "../")
elseif(MINGW)
set_target_properties(InspectionGui PROPERTIES SUFFIX ".pyd")
set_target_properties(InspectionGui PROPERTIES DEBUG_OUTPUT_NAME "InspectionGui_d")
set_target_properties(InspectionGui PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Mod/Inspection)
set_target_properties(InspectionGui PROPERTIES PREFIX "")
else(MSVC)
set_target_properties(InspectionGui PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Mod/Inspection)
set_target_properties(InspectionGui PROPERTIES PREFIX "")
endif(MSVC)
install(TARGETS InspectionGui DESTINATION lib)

View File

@@ -0,0 +1,117 @@
/***************************************************************************
* Copyright (c) YEAR YOUR NAME <Your e-mail address> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <Base/Console.h>
#include <App/Document.h>
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/Command.h>
#include <Gui/Document.h>
#include <Gui/MainWindow.h>
#include <Gui/View3DInventor.h>
#include <Gui/View3DInventorViewer.h>
#include <Mod/Inspection/App/InspectionFeature.h>
#include "VisualInspection.h"
#include "ViewProviderInspection.h"
DEF_STD_CMD_A(CmdVisualInspection);
CmdVisualInspection::CmdVisualInspection()
: Command("Inspection_VisualInspection")
{
sAppModule = "Inspection";
sGroup = QT_TR_NOOP("Inspection");
sMenuText = QT_TR_NOOP("Visual inspection...");
sToolTipText = QT_TR_NOOP("Visual inspection");
sStatusTip = QT_TR_NOOP("Visual inspection");
sWhatsThis = "Inspection_VisualInspection";
}
void CmdVisualInspection::activated(int iMsg)
{
InspectionGui::VisualInspection dlg(Gui::getMainWindow());
dlg.exec();
}
bool CmdVisualInspection::isActive(void)
{
return App::GetApplication().getActiveDocument();
}
//--------------------------------------------------------------------------------------
DEF_STD_CMD_A(CmdInspectElement);
CmdInspectElement::CmdInspectElement()
: Command("Inspection_InspectElement")
{
sAppModule = "Inspection";
sGroup = "Inspection";
sMenuText = "Inspection...";
sToolTipText = "Get distance information";
sWhatsThis = "Inspection_InspectElement";
sStatusTip = sToolTipText;
sPixmap = "mesh_pipette";
}
void CmdInspectElement::activated(int iMsg)
{
Gui::Document* doc = Gui::Application::Instance->activeDocument();
Gui::View3DInventor* view = static_cast<Gui::View3DInventor*>(doc->getActiveView());
if (view) {
Gui::View3DInventorViewer* viewer = view->getViewer();
viewer->setEditing(true);
viewer->setRedirectToSceneGraph(true);
viewer->setEditingCursor(QCursor(Gui::BitmapFactory().pixmap("mesh_pipette"),4,29));
viewer->addEventCallback(SoButtonEvent::getClassTypeId(),
InspectionGui::ViewProviderInspection::inspectCallback);
}
}
bool CmdInspectElement::isActive(void)
{
App::Document* doc = App::GetApplication().getActiveDocument();
if (!doc || doc->countObjectsOfType(Inspection::Feature::getClassTypeId()) == 0)
return false;
Gui::MDIView* view = Gui::getMainWindow()->activeWindow();
if (view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
Gui::View3DInventorViewer* viewer = static_cast<Gui::View3DInventor*>(view)->getViewer();
return !viewer->isEditing();
}
return false;
}
void CreateInspectionCommands(void)
{
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
rcCmdMgr.addCommand(new CmdVisualInspection());
rcCmdMgr.addCommand(new CmdInspectElement());
}

View File

@@ -0,0 +1,91 @@
lib_LTLIBRARIES=libInspectionGui.la InspectionGui.la
BUILT_SOURCES=\
ui_VisualInspection.h \
moc_VisualInspection.cpp \
qrc_Inspection.cpp
libInspectionGui_la_SOURCES=\
AppInspectionGuiPy.cpp \
Command.cpp \
PreCompiled.cpp \
PreCompiled.h \
ViewProviderInspection.cpp \
ViewProviderInspection.h \
VisualInspection.cpp \
VisualInspection.h \
Workbench.cpp \
Workbench.h
includedir = @includedir@/Mod/Inspection/Gui
# the library search path.
libInspectionGui_la_LDFLAGS = -L../../../Base -L../../../App -L../../../Gui -L../App \
-L$(top_builddir)/src/Mod/Mesh/App \
-L$(top_builddir)/src/Mod/Points/App \
$(sim_ac_coin_ldflags) $(sim_ac_coin_libs) \
$(sim_ac_soqt_ldflags) $(sim_ac_soqt_libs) \
$(QT_LIBS) $(all_libraries) \
-version-info @LIB_CURRENT@:@LIB_REVISION@:@LIB_AGE@
libInspectionGui_la_CPPFLAGS = -DInspectionAppExport= -DInspectionGuiExport=
libInspectionGui_la_LIBADD = \
@BOOST_SYSTEM_LIB@ \
-l@PYTHON_LIB@ \
-lxerces-c \
-lFreeCADBase \
-lFreeCADApp \
-lFreeCADGui \
-lMesh \
-lPoints \
-lInspection
#--------------------------------------------------------------------------------------
# Loader of libInspectionGui
InspectionGui_la_SOURCES=\
AppInspectionGui.cpp
# the library search path.
InspectionGui_la_LDFLAGS = $(libInspectionGui_la_LDFLAGS) -module -avoid-version
InspectionGui_la_CPPFLAGS = $(libInspectionGui_la_CPPFLAGS)
InspectionGui_la_LIBADD = \
$(libInspectionGui_la_LIBADD) \
-lInspectionGui
InspectionGui_la_DEPENDENCIES = libInspectionGui.la
#--------------------------------------------------------------------------------------
# rule for Qt MetaObject Compiler:
moc_%.cpp: %.h
$(QT_MOC) $< -o $(@F)
# rule for Qt MetaObject Compiler:
%.moc: %.h
$(QT_MOC) $< -o $(@F)
# rules for Qt User Interface Compiler:
ui_%.h: %.ui
$(QT_UIC) $< -o $(@F)
# rules for Qt Resource Compiler:
qrc_%.cpp: Resources/%.qrc
$(QT_RCC) -name $(*F) $< -o $(@F)
# set the include path found by configure
AM_CXXFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/src $(all_includes) $(QT_CXXFLAGS) \
-I$(sim_ac_coin_includedir) -I$(sim_ac_soqt_includedir)
libdir = $(prefix)/Mod/Inspection
CLEANFILES = $(BUILT_SOURCES)
EXTRA_DIST = \
CMakeLists.txt \
VisualInspection.ui \
Resources/Inspection.qrc

View File

@@ -0,0 +1,24 @@
/***************************************************************************
* Copyright (c) YEAR YOUR NAME <Your e-mail address> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"

View File

@@ -0,0 +1,74 @@
/***************************************************************************
* Copyright (c) YEAR YOUR NAME <Your e-mail address> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef GUI_PRECOMPILED_H
#define GUI_PRECOMPILED_H
#include <FCConfig.h>
// Importing of App classes
#ifdef FC_OS_WIN32
# define MeshExport __declspec(dllimport)
# define PointsExport __declspec(dllimport)
# define InspectionExport __declspec(dllimport)
# define InspectionGuiExport __declspec(dllexport)
#else // for Linux
# define MeshExport
# define PointsExport
# define InspectionExport
# define InspectionGuiExport
#endif
#ifdef _PreComp_
// standard
#include <cstdio>
#include <cassert>
// STL
#include <algorithm>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
// Xerces
#include <xercesc/util/XercesDefs.hpp>
#ifdef FC_OS_WIN32
# include <windows.h>
#endif
// Qt Toolkit
#ifndef __Qt4All__
# include <Gui/Qt4All.h>
#endif
#endif //_PreComp_
#endif // GUI_PRECOMPILED_H

View File

@@ -0,0 +1,4 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
</qresource>
</RCC>

View File

@@ -0,0 +1,662 @@
/***************************************************************************
* Copyright (c) 2011 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QMenu>
# include <QMessageBox>
#endif
#include <Inventor/actions/SoRayPickAction.h>
#include <Inventor/SoPickedPoint.h>
#include <Inventor/lists/SoPickedPointList.h>
#include <Inventor/details/SoFaceDetail.h>
#include <Inventor/events/SoMouseButtonEvent.h>
#include <Inventor/nodes/SoCoordinate3.h>
#include <Inventor/nodes/SoDrawStyle.h>
#include <Inventor/nodes/SoIndexedFaceSet.h>
#include <Inventor/nodes/SoPointSet.h>
#include <Inventor/nodes/SoMaterial.h>
#include <Inventor/nodes/SoShapeHints.h>
#include <Inventor/nodes/SoOrthographicCamera.h>
#include <Inventor/nodes/SoMaterialBinding.h>
#include <Inventor/errors/SoDebugError.h>
#include <Base/Exception.h>
#include <App/PropertyLinks.h>
#include <App/GeoFeature.h>
#include <Gui/Application.h>
#include <Gui/Document.h>
#include <Gui/MainWindow.h>
#include <Gui/SoFCColorBar.h>
#include <Gui/SoFCSelection.h>
#include <Gui/ViewProviderGeometryObject.h>
#include <Gui/View3DInventorViewer.h>
#include <Gui/Widgets.h>
#include <Mod/Inspection/App/InspectionFeature.h>
#include "ViewProviderInspection.h"
using namespace InspectionGui;
bool ViewProviderInspection::addflag = false;
App::PropertyFloatConstraint::Constraints ViewProviderInspection::floatRange = {1.0f,64.0f,1.0f};
PROPERTY_SOURCE(InspectionGui::ViewProviderInspection, Gui::ViewProviderDocumentObject)
ViewProviderInspection::ViewProviderInspection() : search_radius(FLT_MAX)
{
ADD_PROPERTY_TYPE(OutsideGrayed,(false),"",(App::PropertyType) (App::Prop_Output|App::Prop_Hidden),"");
ADD_PROPERTY_TYPE(PointSize,(1.0f),"Display",(App::PropertyType) (App::Prop_None/*App::Prop_Hidden*/),"");
PointSize.setConstraints(&floatRange);
pcColorRoot = new SoSeparator();
pcColorRoot->ref();
pcMatBinding = new SoMaterialBinding;
pcMatBinding->ref();
pcColorMat = new SoMaterial;
pcColorMat->ref();
pcColorStyle = new SoDrawStyle();
pcColorRoot->addChild(pcColorStyle);
pcCoords = new SoCoordinate3;
pcCoords->ref();
// simple color bar
pcColorBar = new Gui::SoFCColorBar;
pcColorBar->Attach(this);
pcColorBar->ref();
pcColorBar->setRange( -0.1f, 0.1f, 3 );
pcLinkRoot = new SoGroup;
pcLinkRoot->ref();
pcPointStyle = new SoDrawStyle();
pcPointStyle->ref();
pcPointStyle->style = SoDrawStyle::POINTS;
pcPointStyle->pointSize = PointSize.getValue();
}
ViewProviderInspection::~ViewProviderInspection()
{
pcColorRoot->unref();
pcCoords->unref();
pcMatBinding->unref();
pcColorMat->unref();
pcColorBar->Detach(this);
pcColorBar->unref();
pcLinkRoot->unref();
pcPointStyle->unref();
}
void ViewProviderInspection::onChanged(const App::Property* prop)
{
if (prop == &OutsideGrayed) {
if (pcColorBar) {
pcColorBar->setOutsideGrayed(OutsideGrayed.getValue());
pcColorBar->Notify(0);
}
}
else if ( prop == &PointSize ) {
pcPointStyle->pointSize = PointSize.getValue();
}
else {
inherited::onChanged(prop);
}
}
void ViewProviderInspection::hide(void)
{
inherited::hide();
pcColorStyle->style = SoDrawStyle::INVISIBLE;
}
void ViewProviderInspection::show(void)
{
inherited::show();
pcColorStyle->style = SoDrawStyle::FILLED;
}
void ViewProviderInspection::attach(App::DocumentObject *pcFeat)
{
// creats the standard viewing modes
inherited::attach(pcFeat);
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();
pcFlatStyle->style = SoDrawStyle::FILLED;
pcColorShadedRoot->addChild(pcFlatStyle);
pcColorShadedRoot->addChild(pcColorMat);
pcColorShadedRoot->addChild(pcMatBinding);
pcColorShadedRoot->addChild(pcLinkRoot);
addDisplayMaskMode(pcColorShadedRoot, "ColorShaded");
// Check for an already existing color bar
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();
pcBar->setRange(fMin, fMax, 3);
pcBar->Notify(0);
pcColorBar->Detach(this);
pcColorBar->unref();
pcColorBar = pcBar;
}
pcColorRoot->addChild(pcColorBar);
}
void ViewProviderInspection::updateData(const App::Property* prop)
{
// set to the expected size
if (prop->getTypeId() == App::PropertyLink::getClassTypeId()) {
App::GeoFeature* object = static_cast<const App::PropertyLink*>(prop)->getValue<App::GeoFeature*>();
if (object) {
float accuracy=0;
Base::Type meshId = Base::Type::fromName("Mesh::Feature");
Base::Type shapeId = Base::Type::fromName("Part::Feature");
Base::Type pointId = Base::Type::fromName("Points::Feature");
Base::Type propId = App::PropertyComplexGeoData::getClassTypeId();
// set the Distance property to the correct size to sync size of material node with number
// of vertices/points of the referenced geometry
const Data::ComplexGeoData* data = 0;
if (object->getTypeId().isDerivedFrom(meshId)) {
App::Property* prop = object->getPropertyByName("Mesh");
if (prop && prop->getTypeId().isDerivedFrom(propId)) {
data = static_cast<App::PropertyComplexGeoData*>(prop)->getComplexData();
}
}
else if (object->getTypeId().isDerivedFrom(shapeId)) {
App::Property* prop = object->getPropertyByName("Shape");
if (prop && prop->getTypeId().isDerivedFrom(propId)) {
data = static_cast<App::PropertyComplexGeoData*>(prop)->getComplexData();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Mod/Part");
float deviation = hGrp->GetFloat("MeshDeviation",0.2);
Base::BoundBox3d bbox = data->getBoundBox();
accuracy = (float)((bbox.LengthX() + bbox.LengthY() + bbox.LengthZ())/300.0 * deviation);
}
}
else if (object->getTypeId().isDerivedFrom(pointId)) {
App::Property* prop = object->getPropertyByName("Points");
if (prop && prop->getTypeId().isDerivedFrom(propId)) {
data = static_cast<App::PropertyComplexGeoData*>(prop)->getComplexData();
}
}
if (data) {
this->pcLinkRoot->removeAllChildren();
std::vector<Base::Vector3d> points;
std::vector<Data::ComplexGeoData::Facet> faces;
data->getFaces(points, faces, accuracy);
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++) {
const Base::Vector3d& p = points[i];
pts[i].setValue((float)p.x,(float)p.y,(float)p.z);
}
this->pcCoords->point.finishEditing();
if (!faces.empty()) {
SoIndexedFaceSet* face = new SoIndexedFaceSet();
this->pcLinkRoot->addChild(face);
face->coordIndex.setNum(4*faces.size());
int32_t* indices = face->coordIndex.startEditing();
unsigned long j=0;
std::vector<Data::ComplexGeoData::Facet>::iterator it;
for (it = faces.begin(); it != faces.end(); ++it,j++) {
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;
}
face->coordIndex.finishEditing();
}
else {
this->pcLinkRoot->addChild(this->pcPointStyle);
this->pcLinkRoot->addChild(new SoPointSet());
}
}
}
}
else if (prop->getTypeId() == App::PropertyFloatList::getClassTypeId()) {
// force an update of the Inventor data nodes
if (this->pcObject) {
App::Property* link = this->pcObject->getPropertyByName("Actual");
if (link) updateData(link);
}
setDistances();
}
else if (prop->getTypeId() == App::PropertyFloat::getClassTypeId()) {
if (strcmp(prop->getName(), "SearchRadius") == 0) {
float fSearchRadius = ((App::PropertyFloat*)prop)->getValue();
this->search_radius = fSearchRadius;
pcColorBar->setRange( -fSearchRadius, fSearchRadius, 4 );
pcColorBar->Notify(0);
}
}
}
SoSeparator* ViewProviderInspection::getFrontRoot(void) const
{
return pcColorRoot;
}
void ViewProviderInspection::setDistances()
{
App::Property* pDistances = pcObject->getPropertyByName("Distances");
if (!pDistances) {
SoDebugError::post("ViewProviderInspection::setDistances", "Unknown property 'Distances'");
return;
}
if (pDistances->getTypeId() != App::PropertyFloatList::getClassTypeId()) {
SoDebugError::post("ViewProviderInspection::setDistances",
"Property 'Distances' has type %s (App::PropertyFloatList was expected)", pDistances->getTypeId().getName());
return;
}
// distance values
const std::vector<float>& fValues = ((App::PropertyFloatList*)pDistances)->getValues();
if ((int)fValues.size() != this->pcCoords->point.getNum()) {
pcMatBinding->value = SoMaterialBinding::OVERALL;
return;
}
if (pcColorMat->diffuseColor.getNum() != (int)fValues.size())
pcColorMat->diffuseColor.setNum((int)fValues.size());
if (pcColorMat->transparency.getNum() != (int)fValues.size())
pcColorMat->transparency.setNum((int)fValues.size());
SbColor * cols = pcColorMat->diffuseColor.startEditing();
float * tran = pcColorMat->transparency.startEditing();
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);
if (pcColorBar->isVisible(*jt))
tran[j] = 0.0f;
else
tran[j] = 0.8f;
}
pcColorMat->diffuseColor.finishEditing();
pcColorMat->transparency.finishEditing();
pcMatBinding->value = SoMaterialBinding::PER_VERTEX_INDEXED;
}
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())) {
App::DocumentObject* docobj = ((App::PropertyLink*)pActual)->getValue();
if (docobj) {
Gui::Document* doc = Gui::Application::Instance->getDocument(docobj->getDocument());
Gui::ViewProvider* view = doc->getViewProvider(docobj);
px = view->getIcon();
}
}
return px;
}
void ViewProviderInspection::setDisplayMode(const char* ModeName)
{
if (strcmp("Visual Inspection",ModeName)==0) {
setDistances();
setDisplayMaskMode("ColorShaded");
}
inherited::setDisplayMode(ModeName);
}
std::vector<std::string> ViewProviderInspection::getDisplayModes(void) const
{
// add modes
std::vector<std::string> StrList;
StrList.push_back("Visual Inspection");
return StrList;
}
void ViewProviderInspection::OnChange(Base::Subject<int> &rCaller,int rcReason)
{
setActiveMode();
}
namespace InspectionGui {
// Proxy class that receives an asynchronous custom event
class ViewProviderProxyObject : public QObject
{
public:
ViewProviderProxyObject(QWidget* w) : QObject(0), widget(w) {}
~ViewProviderProxyObject() {}
void customEvent(QEvent *)
{
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);
if (ret == QMessageBox::Yes) {
for (QList<Gui::Flag*>::iterator it = flags.begin(); it != flags.end(); ++it)
(*it)->deleteLater();
}
}
}
this->deleteLater();
}
private:
QPointer<QWidget> widget;
};
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));
flag->setPalette(p);
flag->setText(text);
flag->setOrigin(point->getPoint());
view->addFlag(flag, Gui::FlagLayout::BottomLeft);
}
}
void ViewProviderInspection::inspectCallback(void * ud, SoEventCallback * n)
{
Gui::View3DInventorViewer* view = reinterpret_cast<Gui::View3DInventorViewer*>(n->getUserData());
const SoEvent* ev = n->getEvent();
if (ev->getTypeId() == SoMouseButtonEvent::getClassTypeId()) {
const SoMouseButtonEvent * mbe = static_cast<const SoMouseButtonEvent *>(ev);
// 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) {
n->setHandled();
// context-menu
QMenu menu;
QAction* fl = menu.addAction(QObject::tr("Annotation"));
fl->setCheckable(true);
fl->setChecked(addflag);
QAction* cl = menu.addAction(QObject::tr("Leave info mode"));
QAction* id = menu.exec(QCursor::pos());
if (fl == id) {
addflag = fl->isChecked();
}
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));
view->setEditing(false);
view->getWidget()->setCursor(QCursor(Qt::ArrowCursor));
view->setRedirectToSceneGraph(false);
view->removeEventCallback(SoButtonEvent::getClassTypeId(), inspectCallback);
}
}
else if (mbe->getButton() == SoMouseButtonEvent::BUTTON1 && mbe->getState() == SoButtonEvent::UP) {
const SoPickedPoint * point = n->getPickedPoint();
if (point == NULL) {
Base::Console().Message("No point picked.\n");
return;
}
n->setHandled();
// check if we have picked one a node of the view provider we are insterested in
Gui::ViewProvider* vp = static_cast<Gui::ViewProvider*>(view->getViewProviderByPath(point->getPath()));
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)
addFlag(view, info, point);
else
Gui::ToolTip::showText(QCursor::pos(), info);
}
else {
// the nearest picked point was not part of the view provider
SoRayPickAction action(view->getViewportRegion());
action.setPickAll(TRUE);
action.setPoint(mbe->getPosition());
action.apply(view->getSceneManager()->getSceneGraph());
const SoPickedPointList& pps = action.getPickedPointList();
for (int i=0; i<pps.getLength(); ++i) {
const SoPickedPoint * point = pps[i];
vp = static_cast<Gui::ViewProvider*>(view->getViewProviderByPath(point->getPath()));
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)
addFlag(view, info, point);
else
Gui::ToolTip::showText(QCursor::pos(), info);
break;
}
}
}
}
}
// 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) {
SbBool toggle = view->isRedirectedToSceneGraph();
view->setRedirectToSceneGraph(!toggle);
n->setHandled();
}
}
}
namespace InspectionGui {
float calcArea (const SbVec3f& v1, const SbVec3f& v2, const SbVec3f& v3)
{
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;
}
}
QString ViewProviderInspection::inspectDistance(const SoPickedPoint* pp) const
{
QString info;
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);
App::Property* pDistance = this->pcObject->getPropertyByName("Distances");
if (pDistance && pDistance->getTypeId() == App::PropertyFloatList::getClassTypeId()) {
App::PropertyFloatList* dist = (App::PropertyFloatList*)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())) {
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) {
info = QObject::tr("Distance: < %1").arg(-fSearchRadius);
}
else {
const SbVec3f& v1 = this->pcCoords->point[index1];
const SbVec3f& v2 = this->pcCoords->point[index2];
const SbVec3f& v3 = this->pcCoords->point[index3];
const SbVec3f& p = pp->getObjectPoint();
// get the weights
float w1, w2, w3;
calcWeights(v1,v2,v3,p,w1,w2,w3);
float fVal = w1*fVal1+w2*fVal2+w3*fVal3;
info = QObject::tr("Distance: %1").arg(fVal);
}
}
}
}
else if (detail && detail->getTypeId() == SoPointDetail::getClassTypeId()) {
// safe downward cast, know the type
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() == App::PropertyFloatList::getClassTypeId() ) {
App::PropertyFloatList* dist = (App::PropertyFloatList*)prop;
float fVal = (*dist)[index];
info = QObject::tr("Distance: %1").arg(fVal);
}
}
return info;
}
// -----------------------------------------------
PROPERTY_SOURCE(InspectionGui::ViewProviderInspectionGroup, Gui::ViewProviderDocumentObjectGroup)
/**
* Creates the view provider for an object group.
*/
ViewProviderInspectionGroup::ViewProviderInspectionGroup()
{
}
ViewProviderInspectionGroup::~ViewProviderInspectionGroup()
{
}
/**
* Returns the pixmap for the opened list item.
*/
QIcon ViewProviderInspectionGroup::getIcon() const
{
static const char * const ScanViewOpen[]={
"16 16 10 1",
"c c #000000",
". c None",
"h c #808000",
"# c #808080",
"a c #ffff00",
"r c #ff0000",
"o c #ffff00",
"g c #00ff00",
"t c #00ffff",
"b c #0000ff",
"................",
"...#####........",
"..#hhhhh#.......",
".#hhhhhhh######.",
".#hhhhhhhhhhhh#c",
".#hhhhhhhhhhhh#c",
".#hhhhhhhhhhhh#c",
"#############h#c",
"#aaaaaaaaaa##h#c",
"#aarroggtbbac##c",
".#arroggtbbaac#c",
".#aarroggtbbac#c",
"..#aaaaaaaaaa#cc",
"..#############c",
"...ccccccccccccc",
"................"};
static const char * const ScanViewClosed[] = {
"16 16 9 1",
"c c #000000",
". c None",
"# c #808080",
"a c #ffff00",
"r c #ff0000",
"o c #ffff00",
"g c #00ff00",
"t c #00ffff",
"b c #0000ff",
"................",
"...#####........",
"..#aaaaa#.......",
".#aaaaaaa######.",
".#aaaaaaaaaaaa#c",
".#aarroggtbbaa#c",
".#aarroggtbbaa#c",
".#aarroggtbbaa#c",
".#aarroggtbbaa#c",
".#aarroggtbbaa#c",
".#aarroggtbbaa#c",
".#aarroggtbbaa#c",
".#aaaaaaaaaaaa#c",
".##############c",
"..cccccccccccccc",
"................"};
QIcon groupIcon;
groupIcon.addPixmap(QPixmap(ScanViewClosed), QIcon::Normal, QIcon::Off);
groupIcon.addPixmap(QPixmap(ScanViewOpen), QIcon::Normal, QIcon::On);
return groupIcon;
}

View File

@@ -0,0 +1,117 @@
/***************************************************************************
* Copyright (c) 2011 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef INSPECTIOGUI_VIEWPROVIDERINSPECTION_H
#define INSPECTIOGUI_VIEWPROVIDERINSPECTION_H
#include <Base/Observer.h>
#include <Gui/ViewProviderDocumentObject.h>
#include <Gui/ViewProviderDocumentObjectGroup.h>
class SoGroup;
class SoMaterial;
class SoMaterialBinding;
class SoDrawStyle;
class SoSeparator;
class SoCoordinate3;
namespace Gui {
class SoFCColorBar;
class View3DInventorViewer;
}
namespace InspectionGui {
/**
* @author Werner Mayer
*/
class ViewProviderInspection : public Gui::ViewProviderDocumentObject,
public Base::Observer<int>{
typedef ViewProviderDocumentObject inherited;
PROPERTY_HEADER(InspectionGui::ViewProviderInspection);
public:
ViewProviderInspection();
virtual ~ViewProviderInspection();
App::PropertyBool OutsideGrayed;
App::PropertyFloatConstraint PointSize;
void attach(App::DocumentObject *pcFeat);
/// Sets the viewing mode
void setDisplayMode(const char* ModeName);
/// Returns a list of all possible modes
std::vector<std::string> getDisplayModes(void) const;
/// Update colorbar after recomputation of distances.
void updateData(const App::Property*);
/// Once the color bar settings has been changed this method gets called to update the feature's representation
void OnChange(Base::Subject<int> &rCaller,int rcReason);
QIcon getIcon() const;
/// Returns a color bar
SoSeparator* getFrontRoot(void) const;
/// Hide the object in the view
virtual void hide(void);
/// Show the object in the view
virtual void show(void);
static void inspectCallback(void * ud, SoEventCallback * n);
protected:
void onChanged(const App::Property* prop);
void setDistances();
QString inspectDistance(const SoPickedPoint* pp) const;
protected:
SoMaterial * pcColorMat;
SoMaterialBinding* pcMatBinding;
SoGroup * pcLinkRoot;
Gui::SoFCColorBar* pcColorBar;
SoDrawStyle * pcColorStyle;
SoDrawStyle * pcPointStyle;
SoSeparator * pcColorRoot;
SoCoordinate3 * pcCoords;
private:
float search_radius;
static bool addflag;
static App::PropertyFloatConstraint::Constraints floatRange;
};
class ViewProviderInspectionGroup : public Gui::ViewProviderDocumentObjectGroup
{
PROPERTY_HEADER(InspectionGui::ViewProviderInspectionGroup);
public:
/// constructor
ViewProviderInspectionGroup();
/// destructor
virtual ~ViewProviderInspectionGroup();
QIcon getIcon() const;
};
} // namespace InspectionGui
#endif // INSPECTIOGUI_VIEWPROVIDERINSPECTION_H

View File

@@ -0,0 +1,263 @@
/***************************************************************************
* Copyright (c) 2011 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#include "VisualInspection.h"
#include "ui_VisualInspection.h"
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <App/Application.h>
#include <Gui/Document.h>
#include <Gui/ViewProvider.h>
#include <Gui/Application.h>
#include <Gui/MainWindow.h>
#include <Gui/PrefWidgets.h>
using namespace InspectionGui;
namespace InspectionGui {
class SingleSelectionItem : public QTreeWidgetItem
{
public:
SingleSelectionItem (QTreeWidget* parent)
: QTreeWidgetItem(parent), _compItem(0)
{
}
SingleSelectionItem (QTreeWidgetItem* parent)
: QTreeWidgetItem (parent), _compItem(0)
{
}
~SingleSelectionItem ()
{
}
SingleSelectionItem* getCompetitiveItem() const
{
return _compItem;
}
void setCompetitiveItem(SingleSelectionItem* item)
{
_compItem = item;
}
private:
SingleSelectionItem* _compItem;
};
}
/* TRANSLATOR InspectionGui::DlgVisualInspectionImp */
/**
* Constructs a VisualInspection as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*/
VisualInspection::VisualInspection(QWidget* parent, Qt::WFlags fl)
: QDialog(parent, fl), ui(new Ui_VisualInspection)
{
ui->setupUi(this);
connect(ui->treeWidgetActual, SIGNAL(itemClicked(QTreeWidgetItem*, int)),
this, SLOT(onActivateItem(QTreeWidgetItem*)));
connect(ui->treeWidgetNominal, SIGNAL(itemClicked(QTreeWidgetItem*, int)),
this, SLOT(onActivateItem(QTreeWidgetItem*)));
//FIXME: Not used yet
ui->textLabel2->hide();
ui->prefFloatSpinBox2->hide();
connect(ui->buttonHelp, SIGNAL(clicked()), Gui::getMainWindow(), SLOT(whatsThis()));
App::Document* doc = App::GetApplication().getActiveDocument();
// disable Ok button and enable of at least one item in each view is on
ui->buttonOk->setDisabled(true);
if (!doc) {
ui->treeWidgetActual->setDisabled(true);
ui->treeWidgetNominal->setDisabled(true);
return;
}
Gui::Document* gui = Gui::Application::Instance->getDocument(doc);
std::vector<App::DocumentObject*> obj = doc->getObjects();
Base::Type point = Base::Type::fromName("Points::Feature");
Base::Type mesh = Base::Type::fromName("Mesh::Feature");
Base::Type shape = Base::Type::fromName("Part::Feature");
for (std::vector<App::DocumentObject*>::iterator it = obj.begin(); it != obj.end(); ++it) {
if ((*it)->getTypeId().isDerivedFrom(point) ||
(*it)->getTypeId().isDerivedFrom(mesh) ||
(*it)->getTypeId().isDerivedFrom(shape)) {
Gui::ViewProvider* view = gui->getViewProvider(*it);
QIcon px = view->getIcon();
SingleSelectionItem* item1 = new SingleSelectionItem(ui->treeWidgetActual);
item1->setText(0, QString::fromUtf8((*it)->Label.getValue()));
item1->setData(0, Qt::UserRole, QString::fromAscii((*it)->getNameInDocument()));
item1->setCheckState(0, Qt::Unchecked);
item1->setIcon(0, px);
SingleSelectionItem* item2 = new SingleSelectionItem(ui->treeWidgetNominal);
item2->setText(0, QString::fromUtf8((*it)->Label.getValue()));
item2->setData(0, Qt::UserRole, QString::fromAscii((*it)->getNameInDocument()));
item2->setCheckState(0, Qt::Unchecked);
item2->setIcon(0, px);
item1->setCompetitiveItem(item2);
item2->setCompetitiveItem(item1);
}
}
loadSettings();
}
/*
* Destroys the object and frees any allocated resources
*/
VisualInspection::~VisualInspection()
{
// no need to delete child widgets, Qt does it all for us
delete ui;
}
void VisualInspection::loadSettings()
{
ui->prefFloatSpinBox1->onRestore();
ui->prefFloatSpinBox2->onRestore();
}
void VisualInspection::saveSettings()
{
ui->prefFloatSpinBox1->onSave();
ui->prefFloatSpinBox2->onSave();
}
void VisualInspection::onActivateItem(QTreeWidgetItem* item)
{
if (item) {
SingleSelectionItem* sel = (SingleSelectionItem*)item;
SingleSelectionItem* cmp = sel->getCompetitiveItem();
if (cmp && cmp->checkState(0) == Qt::Checked)
cmp->setCheckState(0, Qt::Unchecked);
}
bool ok=false;
for (QTreeWidgetItemIterator it(ui->treeWidgetActual); *it; ++it) {
SingleSelectionItem* sel = (SingleSelectionItem*)*it;
if (sel->checkState(0) == Qt::Checked) {
ok = true;
break;
}
}
if (ok) {
ok = false;
for (QTreeWidgetItemIterator it (ui->treeWidgetNominal); *it; ++it) {
SingleSelectionItem* sel = (SingleSelectionItem*)*it;
if (sel->checkState(0) == Qt::Checked) {
ok = true;
break;
}
}
}
ui->buttonOk->setEnabled(ok);
}
void VisualInspection::accept()
{
onActivateItem(0);
if (ui->buttonOk->isEnabled()) {
QDialog::accept();
saveSettings();
// collect all nominal geometries
QStringList nominalNames;
for (QTreeWidgetItemIterator it(ui->treeWidgetNominal); *it; it++) {
SingleSelectionItem* sel = (SingleSelectionItem*)*it;
if (sel->checkState(0) == Qt::Checked)
nominalNames << sel->data(0, Qt::UserRole).toString();
}
float searchRadius = ui->prefFloatSpinBox1->value();
float thickness = ui->prefFloatSpinBox2->value();
// open a new command
Gui::Document* doc = Gui::Application::Instance->activeDocument();
doc->openCommand("Visual Inspection");
// create a group
Gui::Application::Instance->runCommand(
true, "App_activeDocument___InspectionGroup=App.ActiveDocument.addObject(\"Inspection::Group\",\"Inspection\")");
// for each actual geometry create an inspection feature
for (QTreeWidgetItemIterator it(ui->treeWidgetActual); *it; it++) {
SingleSelectionItem* sel = (SingleSelectionItem*)*it;
if (sel->checkState(0) == Qt::Checked) {
QString actualName = sel->data(0, Qt::UserRole).toString();
Gui::Application::Instance->runCommand(
true, "App_activeDocument___InspectionGroup.newObject(\"Inspection::Feature\",\"%s_Inspect\")", (const char*)actualName.toAscii());
Gui::Application::Instance->runCommand(
true, "App.ActiveDocument.ActiveObject.Actual=App.ActiveDocument.%s\n"
"App_activeDocument___activeObject___Nominals=list()\n"
"App.ActiveDocument.ActiveObject.SearchRadius=%.3f\n"
"App.ActiveDocument.ActiveObject.Thickness=%.3f\n", (const char*)actualName.toAscii(), searchRadius, thickness);
for (QStringList::Iterator it = nominalNames.begin(); it != nominalNames.end(); ++it) {
Gui::Application::Instance->runCommand(
true, "App_activeDocument___activeObject___Nominals.append(App.ActiveDocument.%s)\n", (const char*)(*it).toAscii());
}
Gui::Application::Instance->runCommand(
true, "App.ActiveDocument.ActiveObject.Nominals=App_activeDocument___activeObject___Nominals\n"
"del App_activeDocument___activeObject___Nominals\n");
}
}
Gui::Application::Instance->runCommand(
true, "del App_activeDocument___InspectionGroup\n");
doc->commitCommand();
doc->getDocument()->recompute();
// hide the checked features
for (QTreeWidgetItemIterator it(ui->treeWidgetActual); *it; it++) {
SingleSelectionItem* sel = (SingleSelectionItem*)*it;
if (sel->checkState(0) == Qt::Checked) {
Gui::Application::Instance->runCommand(
true, "Gui.ActiveDocument.getObject(\"%s\").Visibility=False"
, (const char*)sel->data(0, Qt::UserRole).toString().toAscii());
}
}
for (QTreeWidgetItemIterator it(ui->treeWidgetNominal); *it; it++) {
SingleSelectionItem* sel = (SingleSelectionItem*)*it;
if (sel->checkState(0) == Qt::Checked) {
Gui::Application::Instance->runCommand(
true, "Gui.ActiveDocument.getObject(\"%s\").Visibility=False"
, (const char*)sel->data(0, Qt::UserRole).toString().toAscii());
}
}
}
}
#include "moc_VisualInspection.cpp"

View File

@@ -0,0 +1,55 @@
/***************************************************************************
* Copyright (c) 2011 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef INSPECTIONGUI_VISUALINSPECTION_H
#define INSPECTIONGUI_VISUALINSPECTION_H
#include <QDialog>
#include <vector>
class QTreeWidgetItem;
namespace InspectionGui {
class Ui_VisualInspection;
class VisualInspection : public QDialog
{
Q_OBJECT
public:
VisualInspection(QWidget* parent = 0, Qt::WFlags fl = 0);
~ VisualInspection();
void accept();
protected Q_SLOTS:
void onActivateItem(QTreeWidgetItem*);
void loadSettings();
void saveSettings();
private:
Ui_VisualInspection* ui;
};
} // namespace InspectionGui
#endif // INSPECTIONGUI_VISUALINSPECTION_H

View File

@@ -0,0 +1,329 @@
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>InspectionGui::VisualInspection</class>
<widget class="QDialog" name="InspectionGui::VisualInspection" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>540</width>
<height>406</height>
</rect>
</property>
<property name="windowTitle" >
<string>Visual Inspection</string>
</property>
<property name="sizeGripEnabled" >
<bool>true</bool>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="1" >
<widget class="QGroupBox" name="groupBox_2" >
<property name="title" >
<string>Nominal</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="0" >
<widget class="QTreeWidget" name="treeWidgetNominal" >
<property name="rootIsDecorated" >
<bool>false</bool>
</property>
<column>
<property name="text" >
<string>Objects</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0" >
<widget class="QGroupBox" name="groupBox" >
<property name="title" >
<string>Actual</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="0" >
<widget class="QTreeWidget" name="treeWidgetActual" >
<property name="rootIsDecorated" >
<bool>false</bool>
</property>
<column>
<property name="text" >
<string>Objects</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0" colspan="2" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QPushButton" name="buttonHelp" >
<property name="text" >
<string>&amp;Help</string>
</property>
<property name="shortcut" >
<string>F1</string>
</property>
<property name="autoDefault" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="buttonOk" >
<property name="text" >
<string>&amp;OK</string>
</property>
<property name="shortcut" >
<string/>
</property>
<property name="autoDefault" >
<bool>true</bool>
</property>
<property name="default" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonCancel" >
<property name="text" >
<string>&amp;Cancel</string>
</property>
<property name="shortcut" >
<string/>
</property>
<property name="autoDefault" >
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0" colspan="2" >
<widget class="QGroupBox" name="groupBox_3" >
<property name="title" >
<string>Parameter</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>61</width>
<height>54</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" >
<layout class="QGridLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="1" column="2" >
<widget class="Gui::PrefDoubleSpinBox" name="prefFloatSpinBox2" >
<property name="suffix" >
<string> mm</string>
</property>
<property name="decimals" >
<number>3</number>
</property>
<property name="singleStep" >
<double>0.1</double>
</property>
<property name="prefEntry" stdset="0" >
<cstring>Thickness</cstring>
</property>
<property name="prefPath" stdset="0" >
<cstring>Mod/Inspection/Inspection</cstring>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="textLabel1" >
<property name="text" >
<string>Search distance</string>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="Gui::PrefDoubleSpinBox" name="prefFloatSpinBox1" >
<property name="suffix" >
<string> mm</string>
</property>
<property name="decimals" >
<number>3</number>
</property>
<property name="value" >
<double>0.05</double>
</property>
<property name="prefEntry" stdset="0" >
<cstring>SearchDistance</cstring>
</property>
<property name="prefPath" stdset="0" >
<cstring>Mod/Inspection/Inspection</cstring>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="textLabel2" >
<property name="text" >
<string>Thickness</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>91</width>
<height>21</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>101</width>
<height>21</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<customwidgets>
<customwidget>
<class>Gui::PrefDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>Gui/PrefWidgets.h</header>
<container>0</container>
<pixmap></pixmap>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>prefFloatSpinBox1</tabstop>
<tabstop>prefFloatSpinBox2</tabstop>
<tabstop>buttonHelp</tabstop>
<tabstop>buttonOk</tabstop>
<tabstop>buttonCancel</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonOk</sender>
<signal>clicked()</signal>
<receiver>InspectionGui::VisualInspection</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel" >
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonCancel</sender>
<signal>clicked()</signal>
<receiver>InspectionGui::VisualInspection</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel" >
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -0,0 +1,65 @@
/***************************************************************************
* Copyright (c) YEAR YOUR NAME <Your e-mail address> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include "Workbench.h"
#include <Gui/MenuManager.h>
#include <Gui/ToolBarManager.h>
using namespace InspectionGui;
/// @namespace InspectionGui @class Workbench
TYPESYSTEM_SOURCE(InspectionGui::Workbench, Gui::StdWorkbench)
Workbench::Workbench()
{
}
Workbench::~Workbench()
{
}
Gui::MenuItem* Workbench::setupMenuBar() const
{
Gui::MenuItem* root = StdWorkbench::setupMenuBar();
Gui::MenuItem* item = root->findItem( "&Windows" );
Gui::MenuItem* insp = new Gui::MenuItem;
root->insertItem(item, insp);
insp->setCommand("Inspection");
*insp << "Inspection_VisualInspection"
<< "Inspection_InspectElement";
return root;
}
Gui::ToolBarItem* Workbench::setupToolBars() const
{
Gui::ToolBarItem* root = StdWorkbench::setupToolBars();
//Gui::ToolBarItem* insp = new Gui::ToolBarItem(root);
//insp->setCommand( "Inspection Tools" );
//*insp << "Inspection_VisualInspection";
return root;
}

View File

@@ -0,0 +1,47 @@
/***************************************************************************
* Copyright (c) YEAR YOUR NAME <Your e-mail address> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef Inspection_WORKBENCH_H
#define Inspection_WORKBENCH_H
#include <Gui/Workbench.h>
namespace InspectionGui {
class Workbench : public Gui::StdWorkbench
{
TYPESYSTEM_HEADER();
public:
Workbench();
virtual ~Workbench();
protected:
Gui::MenuItem* setupMenuBar() const;
Gui::ToolBarItem* setupToolBars() const;
};
} // namespace InspectionGui
#endif // Inspection_WORKBENCH_H

View File

@@ -0,0 +1,26 @@
# FreeCAD init script of the Inspection module
# (c) 2001 Juergen Riegel
#***************************************************************************
#* (c) Juergen Riegel (juergen.riegel@web.de) 2002 *
#* *
#* This file is part of the FreeCAD CAx development system. *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* FreeCAD is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Lesser General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with FreeCAD; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#* Juergen Riegel 2002 *
#***************************************************************************/

View File

@@ -0,0 +1,44 @@
# Inspection gui init module
# (c) 2003 Juergen Riegel
#
# Gathering all the information to start FreeCAD
# This is the second one of three init scripts, the third one
# runs when the gui is up
#***************************************************************************
#* (c) Juergen Riegel (juergen.riegel@web.de) 2002
#* *
#* This file is part of the FreeCAD CAx development system. *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU General Public License (GPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* FreeCAD is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Library General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with FreeCAD; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#* Juergen Riegel 2002 *
#***************************************************************************/
class InspectionWorkbench ( Workbench ):
"Inspection workbench object"
MenuText = "Inspection"
ToolTip = "Inspection workbench"
def Initialize(self):
# load the module
import InspectionGui
def GetClassName(self):
return "InspectionGui::Workbench"
Gui.addWorkbench(InspectionWorkbench())

View File

@@ -0,0 +1,3 @@
/** \defgroup TEMPLATE Inspection
* \ingroup WORKBENCHES */

View File

@@ -0,0 +1,10 @@
SUBDIRS=App Gui
# Change data dir from default ($(prefix)/share) to $(prefix)
datadir = $(prefix)/Mod/Inspection
data_DATA = Init.py InitGui.py
EXTRA_DIST = \
$(data_DATA) \
CMakeLists.txt \
Inspection.dox