FEM: vtk DataAtPoint, implementation
This commit is contained in:
@@ -176,6 +176,7 @@ PyMOD_INIT_FUNC(Fem)
|
||||
Fem::FemPostFilter ::init();
|
||||
Fem::FemPostClipFilter ::init();
|
||||
Fem::FemPostDataAlongLineFilter ::init();
|
||||
Fem::FemPostDataAtPointFilter ::init();
|
||||
Fem::FemPostScalarClipFilter ::init();
|
||||
Fem::FemPostWarpVectorFilter ::init();
|
||||
Fem::FemPostCutFilter ::init();
|
||||
|
||||
@@ -69,9 +69,10 @@ DocumentObjectExecReturn* FemPostFilter::execute(void) {
|
||||
|
||||
if(!m_pipelines.empty() && !m_activePipeline.empty()) {
|
||||
FemPostFilter::FilterPipeline& pipe = m_pipelines[m_activePipeline];
|
||||
if (m_activePipeline.length() >= 13) {
|
||||
if ((m_activePipeline.length() >= 13) || (m_activePipeline.length() >= 11)) {
|
||||
std::string LineClip = m_activePipeline.substr(0,13);
|
||||
if (LineClip == "DataAlongLine") {
|
||||
std::string PointClip = m_activePipeline.substr(0,11);
|
||||
if ((LineClip == "DataAlongLine") || (PointClip == "DataAtPoint")) {
|
||||
pipe.filterSource->SetSourceData(getInputData());
|
||||
pipe.filterTarget->Update();
|
||||
|
||||
@@ -299,6 +300,101 @@ void FemPostDataAlongLineFilter::GetAxisData() {
|
||||
XAxisData.setValues(coords);
|
||||
}
|
||||
|
||||
PROPERTY_SOURCE(Fem::FemPostDataAtPointFilter, Fem::FemPostFilter)
|
||||
|
||||
FemPostDataAtPointFilter::FemPostDataAtPointFilter(void) : FemPostFilter() {
|
||||
|
||||
ADD_PROPERTY_TYPE(Center,(Base::Vector3d(0.0,0.0,1.0)), "DataAtPoint", App::Prop_None, "The center used to define the center of the point");
|
||||
ADD_PROPERTY_TYPE(Radius,(0), "DataAtPoint", App::Prop_None, "The point 2 used to define end point of line");
|
||||
ADD_PROPERTY_TYPE(PointData,(0), "DataAtPoint",App::Prop_None,"Point data values used for plotting");
|
||||
ADD_PROPERTY_TYPE(FieldName,(""),"DataAtPoint",App::Prop_None,"Field used for plotting");
|
||||
ADD_PROPERTY_TYPE(Unit,(""),"DataAtPoint",App::Prop_None,"Unit used for Field");
|
||||
|
||||
PointData.setStatus(App::Property::ReadOnly, true);
|
||||
FieldName.setStatus(App::Property::ReadOnly, true);
|
||||
Unit.setStatus(App::Property::ReadOnly, true);
|
||||
|
||||
FilterPipeline clip;
|
||||
|
||||
m_point = vtkSmartPointer<vtkPointSource>::New();
|
||||
const Base::Vector3d& vec = Center.getValue();
|
||||
m_point->SetCenter(vec.x, vec.y, vec.z);
|
||||
m_point->SetRadius(0);
|
||||
|
||||
m_probe = vtkSmartPointer<vtkProbeFilter>::New();
|
||||
m_probe->SetInputConnection(m_point->GetOutputPort());
|
||||
m_probe->SetValidPointMaskArrayName("ValidPointArray");
|
||||
m_probe->SetPassPointArrays(1);
|
||||
m_probe->SetPassCellArrays(1);
|
||||
// needs vtk > 6.1
|
||||
#if (VTK_MAJOR_VERSION > 6) || (VTK_MINOR_VERSION > 1)
|
||||
m_probe->ComputeToleranceOff();
|
||||
m_probe->SetTolerance(0.01);
|
||||
#endif
|
||||
|
||||
clip.filterSource = m_probe;
|
||||
clip.filterTarget = m_probe;
|
||||
|
||||
addFilterPipeline(clip, "DataAtPoint");
|
||||
setActiveFilterPipeline("DataAtPoint");
|
||||
}
|
||||
|
||||
FemPostDataAtPointFilter::~FemPostDataAtPointFilter() {
|
||||
|
||||
}
|
||||
|
||||
DocumentObjectExecReturn* FemPostDataAtPointFilter::execute(void) {
|
||||
|
||||
//recalculate the filter
|
||||
return Fem::FemPostFilter::execute();
|
||||
}
|
||||
|
||||
|
||||
void FemPostDataAtPointFilter::onChanged(const Property* prop) {
|
||||
if(prop == &Center) {
|
||||
const Base::Vector3d& vec = Center.getValue();
|
||||
m_point->SetCenter(vec.x, vec.y, vec.z);
|
||||
}
|
||||
else if(prop == &FieldName) {
|
||||
GetPointData();
|
||||
}
|
||||
Fem::FemPostFilter::onChanged(prop);
|
||||
}
|
||||
|
||||
short int FemPostDataAtPointFilter::mustExecute(void) const {
|
||||
|
||||
if(Center.isTouched()){
|
||||
|
||||
return 1;
|
||||
}
|
||||
else return App::DocumentObject::mustExecute();
|
||||
}
|
||||
|
||||
void FemPostDataAtPointFilter::GetPointData() {
|
||||
|
||||
std::vector<double> values;
|
||||
|
||||
vtkSmartPointer<vtkDataObject> data = m_probe->GetOutputDataObject(0);
|
||||
vtkDataSet* dset = vtkDataSet::SafeDownCast(data);
|
||||
vtkDataArray* pdata = dset->GetPointData()->GetArray(FieldName.getValue());
|
||||
|
||||
int component = 0;
|
||||
|
||||
for(int i=0; i<dset->GetNumberOfPoints(); ++i) {
|
||||
|
||||
double value = 0;
|
||||
if(pdata->GetNumberOfComponents() == 1)
|
||||
value = pdata->GetComponent(i, component);
|
||||
else {
|
||||
for(int j=0; j<pdata->GetNumberOfComponents(); ++j)
|
||||
value += std::pow(pdata->GetComponent(i, j),2);
|
||||
|
||||
value = std::sqrt(value);
|
||||
}
|
||||
values.push_back(value);
|
||||
}
|
||||
PointData.setValues(values);
|
||||
}
|
||||
|
||||
PROPERTY_SOURCE(Fem::FemPostScalarClipFilter, Fem::FemPostFilter)
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <vtkWarpVector.h>
|
||||
#include <vtkCutter.h>
|
||||
#include <vtkLineSource.h>
|
||||
#include <vtkPointSource.h>
|
||||
#include <vtkProbeFilter.h>
|
||||
#include <vtkThreshold.h>
|
||||
|
||||
@@ -132,6 +133,37 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class AppFemExport FemPostDataAtPointFilter : public FemPostFilter {
|
||||
|
||||
PROPERTY_HEADER(Fem::FemPostDataAtPointFilter);
|
||||
|
||||
public:
|
||||
FemPostDataAtPointFilter(void);
|
||||
virtual ~FemPostDataAtPointFilter();
|
||||
|
||||
App::PropertyVectorDistance Center;
|
||||
App::PropertyDistance Radius;
|
||||
App::PropertyString FieldName;
|
||||
App::PropertyFloatList PointData;
|
||||
App::PropertyString Unit;
|
||||
|
||||
virtual const char* getViewProviderName(void) const {
|
||||
return "FemGui::ViewProviderFemPostDataAtPoint";
|
||||
}
|
||||
virtual short int mustExecute(void) const;
|
||||
|
||||
protected:
|
||||
virtual App::DocumentObjectExecReturn* execute(void);
|
||||
virtual void onChanged(const App::Property* prop);
|
||||
void GetPointData();
|
||||
|
||||
private:
|
||||
|
||||
vtkSmartPointer<vtkPointSource> m_point;
|
||||
vtkSmartPointer<vtkProbeFilter> m_probe;
|
||||
|
||||
};
|
||||
|
||||
class AppFemExport FemPostScalarClipFilter : public FemPostFilter {
|
||||
|
||||
PROPERTY_HEADER(Fem::FemPostScalarClipFilter);
|
||||
|
||||
@@ -150,6 +150,7 @@ PyMOD_INIT_FUNC(FemGui)
|
||||
FemGui::ViewProviderFemPostSphereFunction ::init();
|
||||
FemGui::ViewProviderFemPostClip ::init();
|
||||
FemGui::ViewProviderFemPostDataAlongLine ::init();
|
||||
FemGui::ViewProviderFemPostDataAtPoint ::init();
|
||||
FemGui::ViewProviderFemPostScalarClip ::init();
|
||||
FemGui::ViewProviderFemPostWarpVector ::init();
|
||||
FemGui::ViewProviderFemPostCut ::init();
|
||||
|
||||
@@ -118,6 +118,7 @@ if(BUILD_FEM_VTK)
|
||||
TaskPostDisplay.ui
|
||||
TaskPostClip.ui
|
||||
TaskPostDataAlongLine.ui
|
||||
TaskPostDataAtPoint.ui
|
||||
TaskPostScalarClip.ui
|
||||
TaskPostWarpVector.ui
|
||||
TaskPostCut.ui
|
||||
@@ -290,6 +291,7 @@ if(BUILD_FEM_VTK)
|
||||
SphereWidget.ui
|
||||
TaskPostClip.ui
|
||||
TaskPostDataAlongLine.ui
|
||||
TaskPostDataAtPoint.ui
|
||||
TaskPostScalarClip.ui
|
||||
TaskPostDisplay.ui
|
||||
TaskPostWarpVector.ui
|
||||
|
||||
@@ -1204,6 +1204,32 @@ bool CmdFemPostCreateDataAlongLineFilter::isActive(void)
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
DEF_STD_CMD_A(CmdFemPostCreateDataAtPointFilter);
|
||||
|
||||
CmdFemPostCreateDataAtPointFilter::CmdFemPostCreateDataAtPointFilter()
|
||||
: Command("FEM_PostCreateDataAtPointFilter")
|
||||
{
|
||||
sAppModule = "Fem";
|
||||
sGroup = QT_TR_NOOP("Fem");
|
||||
sMenuText = QT_TR_NOOP("Define/create a clip filter which clips a field data at point");
|
||||
sToolTipText = QT_TR_NOOP("Define/create a clip filter which clips a field data at point");
|
||||
sWhatsThis = "FEM_PostCreateDataAtPointFilter";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "fem-DataAtPoint";
|
||||
}
|
||||
|
||||
void CmdFemPostCreateDataAtPointFilter::activated(int)
|
||||
{
|
||||
|
||||
setupFilter(this, "DataAtPoint");
|
||||
|
||||
}
|
||||
|
||||
bool CmdFemPostCreateDataAtPointFilter::isActive(void)
|
||||
{
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
DEF_STD_CMD_A(CmdFemPostCreateLinearizedStressesFilter);
|
||||
|
||||
CmdFemPostCreateLinearizedStressesFilter::CmdFemPostCreateLinearizedStressesFilter()
|
||||
@@ -1600,6 +1626,7 @@ void CreateFemCommands(void)
|
||||
#ifdef FC_USE_VTK
|
||||
rcCmdMgr.addCommand(new CmdFemPostCreateClipFilter);
|
||||
rcCmdMgr.addCommand(new CmdFemPostCreateDataAlongLineFilter);
|
||||
rcCmdMgr.addCommand(new CmdFemPostCreateDataAtPointFilter);
|
||||
rcCmdMgr.addCommand(new CmdFemPostCreateLinearizedStressesFilter);
|
||||
rcCmdMgr.addCommand(new CmdFemPostCreateScalarClipFilter);
|
||||
rcCmdMgr.addCommand(new CmdFemPostWarpVectorFilter);
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
<file>icons/fem-cut.svg</file>
|
||||
<file>icons/fem-cylinder.svg</file>
|
||||
<file>icons/fem-DataAlongLine.svg</file>
|
||||
<file>icons/fem-DataAtPoint.png</file>
|
||||
<file>icons/fem-data.svg</file>
|
||||
<file>icons/fem-elmer.svg</file>
|
||||
<file>icons/fem-equation-electrostatic.svg</file>
|
||||
|
||||
BIN
src/Mod/Fem/Gui/Resources/icons/fem-DataAtPoint.png
Normal file
BIN
src/Mod/Fem/Gui/Resources/icons/fem-DataAtPoint.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
@@ -29,6 +29,7 @@
|
||||
#include "ui_TaskPostDisplay.h"
|
||||
#include "ui_TaskPostClip.h"
|
||||
#include "ui_TaskPostDataAlongLine.h"
|
||||
#include "ui_TaskPostDataAtPoint.h"
|
||||
#include "ui_TaskPostScalarClip.h"
|
||||
#include "ui_TaskPostWarpVector.h"
|
||||
#include "ui_TaskPostCut.h"
|
||||
@@ -43,6 +44,7 @@
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/Action.h>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
@@ -104,10 +106,12 @@ void PointMarker::customEvent(QEvent*)
|
||||
const SbVec3f& pt1 = vp->pCoords->point[0];
|
||||
const SbVec3f& pt2 = vp->pCoords->point[1];
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Point1 = App.Vector(%f, %f, %f)", m_name.c_str(), pt1[0],pt1[1], pt1[2]);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Point2 = App.Vector(%f, %f, %f)", m_name.c_str(), pt2[0],pt2[1], pt2[2]);
|
||||
if(m_name == "DataAlongLine"){
|
||||
PointsChanged(pt1[0],pt1[1], pt1[2], pt2[0],pt2[1], pt2[2]);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Point1 = App.Vector(%f, %f, %f)", m_name.c_str(), pt1[0],pt1[1], pt1[2]);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Point2 = App.Vector(%f, %f, %f)", m_name.c_str(), pt2[0],pt2[1], pt2[2]);
|
||||
}
|
||||
Gui::Command::doCommand(Gui::Command::Doc, ObjectInvisible().c_str());
|
||||
PointsChanged(pt1[0],pt1[1], pt1[2], pt2[0],pt2[1], pt2[2]);
|
||||
}
|
||||
|
||||
std::string PointMarker::ObjectInvisible(){
|
||||
@@ -138,6 +142,79 @@ ViewProviderPointMarker::~ViewProviderPointMarker()
|
||||
pCoords->unref();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
DataMarker::DataMarker(Gui::View3DInventorViewer* iv, std::string ObjName) : view(iv),
|
||||
vp(new ViewProviderDataMarker)
|
||||
{
|
||||
view->addViewProvider(vp);
|
||||
m_name = ObjName;
|
||||
}
|
||||
|
||||
DataMarker::~DataMarker()
|
||||
{
|
||||
view->removeViewProvider(vp);
|
||||
delete vp;
|
||||
}
|
||||
|
||||
void DataMarker::addPoint(const SbVec3f& pt)
|
||||
{
|
||||
int ct = countPoints();
|
||||
vp->pCoords->point.set1Value(ct, pt);
|
||||
vp->pMarker->numPoints=ct+1;
|
||||
|
||||
}
|
||||
|
||||
int DataMarker::countPoints() const
|
||||
{
|
||||
return vp->pCoords->point.getNum();
|
||||
}
|
||||
|
||||
void DataMarker::customEvent(QEvent*)
|
||||
{
|
||||
const SbVec3f& pt1 = vp->pCoords->point[0];
|
||||
|
||||
if(m_name == "DataAtPoint"){
|
||||
PointsChanged(pt1[0],pt1[1], pt1[2]);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Center = App.Vector(%f, %f, %f)", m_name.c_str(), pt1[0],pt1[1], pt1[2]);
|
||||
}
|
||||
Gui::Command::doCommand(Gui::Command::Doc, ObjectInvisible().c_str());
|
||||
}
|
||||
|
||||
std::string DataMarker::ObjectInvisible(){
|
||||
return "for amesh in App.activeDocument().Objects:\n\
|
||||
if \"Mesh\" in amesh.TypeId:\n\
|
||||
aparttoshow = amesh.Name.replace(\"_Mesh\",\"\")\n\
|
||||
for apart in App.activeDocument().Objects:\n\
|
||||
if aparttoshow == apart.Name:\n\
|
||||
apart.ViewObject.Visibility = False\n";
|
||||
}
|
||||
|
||||
PROPERTY_SOURCE(FemGui::ViewProviderDataMarker, Gui::ViewProviderDocumentObject)
|
||||
|
||||
ViewProviderDataMarker::ViewProviderDataMarker()
|
||||
{
|
||||
pCoords = new SoCoordinate3();
|
||||
pCoords->ref();
|
||||
pCoords->point.setNum(0);
|
||||
pMarker = new SoMarkerSet();
|
||||
pMarker->markerIndex = SoMarkerSet::CIRCLE_FILLED_9_9;
|
||||
pMarker->numPoints=0;
|
||||
pMarker->ref();
|
||||
|
||||
SoGroup* grp = new SoGroup();
|
||||
grp->addChild(pCoords);
|
||||
grp->addChild(pMarker);
|
||||
addDisplayMaskMode(grp, "Base");
|
||||
setDisplayMaskMode("Base");
|
||||
}
|
||||
|
||||
ViewProviderDataMarker::~ViewProviderDataMarker()
|
||||
{
|
||||
pCoords->unref();
|
||||
pMarker->unref();
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
//**************************************************************************
|
||||
// TaskDialog
|
||||
@@ -669,6 +746,170 @@ plt.show()\n";
|
||||
|
||||
//############################################################################################
|
||||
|
||||
TaskPostDataAtPoint::TaskPostDataAtPoint(ViewProviderDocumentObject* view, QWidget* parent)
|
||||
: TaskPostBox(view,Gui::BitmapFactory().pixmap("fem-femmesh-create-node-by-poly"), tr("Data At Point"), parent) {
|
||||
|
||||
assert(view->isDerivedFrom(ViewProviderFemPostDataAtPoint::getClassTypeId()));
|
||||
|
||||
//we load the views widget
|
||||
proxy = new QWidget(this);
|
||||
ui = new Ui_TaskPostDataAtPoint();
|
||||
ui->setupUi(proxy);
|
||||
|
||||
QMetaObject::connectSlotsByName(this);
|
||||
this->groupLayout()->addWidget(proxy);
|
||||
|
||||
const Base::Vector3d& vec = static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Center.getValue();
|
||||
ui->centerX->setValue(vec.x);
|
||||
ui->centerY->setValue(vec.y);
|
||||
ui->centerZ->setValue(vec.z);
|
||||
|
||||
connect(ui->centerX, SIGNAL(valueChanged(double)), this, SLOT(centerChanged(double)));
|
||||
connect(ui->centerY, SIGNAL(valueChanged(double)), this, SLOT(centerChanged(double)));
|
||||
connect(ui->centerZ, SIGNAL(valueChanged(double)), this, SLOT(centerChanged(double)));
|
||||
|
||||
//update all fields
|
||||
updateEnumerationList(getTypedView<ViewProviderFemPostObject>()->Field, ui->Field);
|
||||
}
|
||||
|
||||
TaskPostDataAtPoint::~TaskPostDataAtPoint() {
|
||||
|
||||
}
|
||||
|
||||
void TaskPostDataAtPoint::applyPythonCode() {
|
||||
|
||||
}
|
||||
|
||||
static const char * cursor_star[] = {
|
||||
"32 32 3 1",
|
||||
" c None",
|
||||
". c #FFFFFF",
|
||||
"+ c #FF0000",
|
||||
" . ",
|
||||
" . ",
|
||||
" . ",
|
||||
" . ",
|
||||
" . ",
|
||||
" ",
|
||||
"..... ..... ",
|
||||
" ",
|
||||
" . ",
|
||||
" . ",
|
||||
" . ++ ",
|
||||
" . + + ",
|
||||
" . + ++ + ",
|
||||
" + ++++ + ",
|
||||
" + ++ ++ + ",
|
||||
" + ++++++++ + ",
|
||||
" ++ ++ ++ ++ "};
|
||||
|
||||
void TaskPostDataAtPoint::on_SelectPoint_clicked() {
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc, ObjectVisible().c_str());
|
||||
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->setEditingCursor(QCursor(QPixmap(cursor_star), 7, 7));
|
||||
|
||||
// Derives from QObject and we have a parent object, so we don't
|
||||
// require a delete.
|
||||
std::string ObjName = static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Label.getValue();
|
||||
|
||||
FemGui::DataMarker* marker = new FemGui::DataMarker(viewer, ObjName);
|
||||
viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(),
|
||||
FemGui::TaskPostDataAtPoint::pointCallback, marker);
|
||||
connect(marker, SIGNAL(PointsChanged(double, double, double)), this, SLOT(onChange(double, double, double)));
|
||||
}
|
||||
getTypedView<ViewProviderFemPostObject>()->DisplayMode.setValue(1);
|
||||
updateEnumerationList(getTypedView<ViewProviderFemPostObject>()->Field, ui->Field);
|
||||
|
||||
}
|
||||
|
||||
std::string TaskPostDataAtPoint::ObjectVisible(){
|
||||
return "for amesh in App.activeDocument().Objects:\n\
|
||||
if \"Mesh\" in amesh.TypeId:\n\
|
||||
aparttoshow = amesh.Name.replace(\"_Mesh\",\"\")\n\
|
||||
for apart in App.activeDocument().Objects:\n\
|
||||
if aparttoshow == apart.Name:\n\
|
||||
apart.ViewObject.Visibility = True\n";
|
||||
}
|
||||
|
||||
void TaskPostDataAtPoint::onChange(double x, double y, double z) {
|
||||
|
||||
ui->centerX->setValue(x);
|
||||
ui->centerY->setValue(y);
|
||||
ui->centerZ->setValue(z);
|
||||
|
||||
}
|
||||
|
||||
void TaskPostDataAtPoint::centerChanged(double) {
|
||||
|
||||
Base::Vector3d vec(ui->centerX->value(), ui->centerY->value(), ui->centerZ->value());
|
||||
std::string ObjName = static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Label.getValue();
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Center = App.Vector(%f, %f, %f)",ObjName.c_str(), ui->centerX->value(), ui->centerY->value(), ui->centerZ->value());
|
||||
|
||||
}
|
||||
|
||||
void TaskPostDataAtPoint::pointCallback(void * ud, SoEventCallback * n)
|
||||
{
|
||||
const SoMouseButtonEvent * mbe = static_cast<const SoMouseButtonEvent*>(n->getEvent());
|
||||
Gui::View3DInventorViewer* view = reinterpret_cast<Gui::View3DInventorViewer*>(n->getUserData());
|
||||
DataMarker *pm = reinterpret_cast<DataMarker*>(ud);
|
||||
|
||||
// Mark all incoming mouse button events as handled, especially, to deactivate the selection node
|
||||
n->getAction()->setHandled();
|
||||
|
||||
if (mbe->getButton() == SoMouseButtonEvent::BUTTON1 && mbe->getState() == SoButtonEvent::DOWN) {
|
||||
const SoPickedPoint * point = n->getPickedPoint();
|
||||
if (point == NULL) {
|
||||
Base::Console().Message("No point picked.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
n->setHandled();
|
||||
pm->addPoint(point->getPoint());
|
||||
if (pm->countPoints() == 1) {
|
||||
QEvent *e = new QEvent(QEvent::User);
|
||||
QApplication::postEvent(pm, e);
|
||||
// leave mode
|
||||
view->setEditing(false);
|
||||
view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), pointCallback, ud);
|
||||
}
|
||||
}
|
||||
else if (mbe->getButton() != SoMouseButtonEvent::BUTTON1 && mbe->getState() == SoButtonEvent::UP) {
|
||||
n->setHandled();
|
||||
view->setEditing(false);
|
||||
view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), pointCallback, ud);
|
||||
pm->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
void TaskPostDataAtPoint::on_Field_activated(int i) {
|
||||
|
||||
getTypedView<ViewProviderFemPostObject>()->Field.setValue(i);
|
||||
std::string FieldName = ui->Field->currentText().toStdString();
|
||||
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->FieldName.setValue(FieldName);
|
||||
if ((FieldName == "Von Mises stress") || (FieldName == "Max shear stress (Tresca)") || (FieldName == "Maximum Principal stress") || (FieldName == "Minimum Principal stress") || (FieldName == "Median Principal stress") || (FieldName == "Stress vectors")){
|
||||
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Unit.setValue("MPa");
|
||||
}
|
||||
else if (FieldName == "Displacement"){
|
||||
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Unit.setValue("mm");
|
||||
}
|
||||
else if (FieldName == "Temperature"){
|
||||
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Unit.setValue("K");
|
||||
}
|
||||
|
||||
std::string PointData = " The value at that location is " + std::to_string(static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->PointData[0]) + " " +static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Unit.getValue() + "\n";
|
||||
QMessageBox::information(Gui::getMainWindow(),
|
||||
qApp->translate("CmdFemPostCreateDataAtPointFilter", "Data At Point"),
|
||||
qApp->translate("CmdFemPostCreateDataAtPointFilter", PointData.c_str()));
|
||||
Base::Console().Error(PointData.c_str());
|
||||
}
|
||||
|
||||
//############################################################################################
|
||||
|
||||
TaskPostScalarClip::TaskPostScalarClip(ViewProviderDocumentObject* view, QWidget* parent) :
|
||||
TaskPostBox(view, Gui::BitmapFactory().pixmap("fem-femmesh-create-node-by-poly"), tr("Clip options"), parent) {
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ class QComboBox;
|
||||
class Ui_TaskPostDisplay;
|
||||
class Ui_TaskPostClip;
|
||||
class Ui_TaskPostDataAlongLine;
|
||||
class Ui_TaskPostDataAtPoint;
|
||||
class Ui_TaskPostScalarClip;
|
||||
class Ui_TaskPostWarpVector;
|
||||
class Ui_TaskPostCut;
|
||||
@@ -90,6 +91,45 @@ protected:
|
||||
friend class PointMarker;
|
||||
};
|
||||
|
||||
class ViewProviderDataMarker;
|
||||
class DataMarker : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DataMarker(Gui::View3DInventorViewer* view, std::string ObjName);
|
||||
~DataMarker();
|
||||
|
||||
void addPoint(const SbVec3f&);
|
||||
int countPoints() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void PointsChanged(double x, double y, double z);
|
||||
|
||||
protected:
|
||||
void customEvent(QEvent* e);
|
||||
|
||||
private:
|
||||
Gui::View3DInventorViewer *view;
|
||||
ViewProviderDataMarker *vp;
|
||||
std::string m_name;
|
||||
std::string ObjectInvisible();
|
||||
};
|
||||
|
||||
class FemGuiExport ViewProviderDataMarker : public Gui::ViewProviderDocumentObject
|
||||
{
|
||||
PROPERTY_HEADER(FemGui::ViewProviderDataMarker);
|
||||
|
||||
public:
|
||||
ViewProviderDataMarker();
|
||||
virtual ~ViewProviderDataMarker();
|
||||
|
||||
protected:
|
||||
SoCoordinate3 * pCoords;
|
||||
SoMarkerSet * pMarker;
|
||||
friend class DataMarker;
|
||||
};
|
||||
|
||||
class TaskPostBox : public Gui::TaskView::TaskBox {
|
||||
|
||||
Q_OBJECT
|
||||
@@ -242,6 +282,30 @@ private:
|
||||
Ui_TaskPostDataAlongLine* ui;
|
||||
};
|
||||
|
||||
class TaskPostDataAtPoint: public TaskPostBox {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskPostDataAtPoint(Gui::ViewProviderDocumentObject* view, QWidget* parent = 0);
|
||||
virtual ~TaskPostDataAtPoint();
|
||||
|
||||
virtual void applyPythonCode();
|
||||
static void pointCallback(void * ud, SoEventCallback * n);
|
||||
|
||||
private Q_SLOTS:
|
||||
void on_SelectPoint_clicked();
|
||||
void on_Field_activated(int i);
|
||||
void centerChanged(double);
|
||||
void onChange(double x, double y, double z);
|
||||
|
||||
|
||||
private:
|
||||
std::string ObjectVisible();
|
||||
QWidget* proxy;
|
||||
Ui_TaskPostDataAtPoint* ui;
|
||||
};
|
||||
|
||||
class TaskPostScalarClip : public TaskPostBox {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
151
src/Mod/Fem/Gui/TaskPostDataAtPoint.ui
Normal file
151
src/Mod/Fem/Gui/TaskPostDataAtPoint.ui
Normal file
@@ -0,0 +1,151 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TaskPostDataAtPoint</class>
|
||||
<widget class="QWidget" name="TaskPostDataAtPoint">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>482</width>
|
||||
<height>363</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Center</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="centerX">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>70</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-999999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>999999999.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="centerY">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>70</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-999999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>999999999.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="centerZ">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>70</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-999999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>999999999.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="SelectPoint">
|
||||
<property name="text">
|
||||
<string>Select Point</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout_4">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Field</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="Field"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>SelectPoint</zorder>
|
||||
<zorder>line</zorder>
|
||||
<zorder>line_2</zorder>
|
||||
<zorder>line_3</zorder>
|
||||
<zorder></zorder>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -69,6 +69,24 @@ void ViewProviderFemPostDataAlongLine::setupTaskDialog(TaskDlgPost* dlg) {
|
||||
|
||||
}
|
||||
|
||||
PROPERTY_SOURCE(FemGui::ViewProviderFemPostDataAtPoint, FemGui::ViewProviderFemPostObject)
|
||||
|
||||
ViewProviderFemPostDataAtPoint::ViewProviderFemPostDataAtPoint() {
|
||||
|
||||
sPixmap = "fem-DataAtPoint";
|
||||
}
|
||||
|
||||
ViewProviderFemPostDataAtPoint::~ViewProviderFemPostDataAtPoint() {
|
||||
|
||||
}
|
||||
|
||||
void ViewProviderFemPostDataAtPoint::setupTaskDialog(TaskDlgPost* dlg) {
|
||||
|
||||
//add the function box
|
||||
dlg->appendBox(new TaskPostDataAtPoint(dlg->getView()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
PROPERTY_SOURCE(FemGui::ViewProviderFemPostScalarClip, FemGui::ViewProviderFemPostObject)
|
||||
|
||||
|
||||
@@ -51,6 +51,19 @@ public:
|
||||
ViewProviderFemPostDataAlongLine();
|
||||
~ViewProviderFemPostDataAlongLine();
|
||||
|
||||
protected:
|
||||
virtual void setupTaskDialog(TaskDlgPost* dlg);
|
||||
};
|
||||
|
||||
class FemGuiExport ViewProviderFemPostDataAtPoint: public ViewProviderFemPostObject {
|
||||
|
||||
PROPERTY_HEADER(FemGui::ViewProviderFemPostDataAtPoint);
|
||||
|
||||
public:
|
||||
/// constructor.
|
||||
ViewProviderFemPostDataAtPoint();
|
||||
~ViewProviderFemPostDataAtPoint();
|
||||
|
||||
protected:
|
||||
virtual void setupTaskDialog(TaskDlgPost* dlg);
|
||||
};
|
||||
|
||||
@@ -146,6 +146,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
||||
<< "FEM_PostCreateWarpVectorFilter"
|
||||
<< "FEM_PostCreateDataAlongLineFilter"
|
||||
<< "FEM_PostCreateLinearizedStressesFilter"
|
||||
<< "FEM_PostCreateDataAtPointFilter"
|
||||
<< "Separator"
|
||||
<< "FEM_PostCreateFunctions";
|
||||
#endif
|
||||
@@ -254,6 +255,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
|
||||
<< "FEM_PostCreateWarpVectorFilter"
|
||||
<< "FEM_PostCreateDataAlongLineFilter"
|
||||
<< "FEM_PostCreateLinearizedStressesFilter"
|
||||
<< "FEM_PostCreateDataAtPointFilter"
|
||||
<< "Separator"
|
||||
<< "FEM_PostCreateFunctions";
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user