+ implement property editor item for FEM mesh
This commit is contained in:
parent
b55defa4f3
commit
4f2291f420
|
@ -82,6 +82,7 @@ public:
|
|||
App::Property *Copy(void) const;
|
||||
void Paste(const App::Property &from);
|
||||
unsigned int getMemSize (void) const;
|
||||
const char* getEditorName(void) const { return "FemGui::PropertyFemMeshItem"; }
|
||||
//@}
|
||||
|
||||
private:
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <Gui/Application.h>
|
||||
#include <Gui/WidgetFactory.h>
|
||||
#include <Gui/Language/Translator.h>
|
||||
#include "PropertyFemMeshItem.h"
|
||||
#include "DlgSettingsFemImp.h"
|
||||
#include "ViewProviderFemMesh.h"
|
||||
#include "ViewProviderFemMeshShape.h"
|
||||
|
@ -104,6 +105,7 @@ void FemGuiExport initFemGui()
|
|||
FemGui::ViewProviderFemConstraintPulley ::init();
|
||||
FemGui::ViewProviderResult ::init();
|
||||
FemGui::ViewProviderResultPython ::init();
|
||||
FemGui::PropertyFemMeshItem ::init();
|
||||
|
||||
// register preferences pages
|
||||
new Gui::PrefPageProducer<FemGui::DlgSettingsFemImp> ("FEM");
|
||||
|
|
|
@ -42,6 +42,7 @@ SOURCE_GROUP("Python" FILES ${Python_SRCS})
|
|||
|
||||
set(FemGui_MOC_HDRS
|
||||
DlgSettingsFemImp.h
|
||||
PropertyFemMeshItem.h
|
||||
TaskObjectName.h
|
||||
TaskCreateNodeSet.h
|
||||
TaskDlgCreateNodeSet.h
|
||||
|
@ -187,6 +188,8 @@ SET(FemGui_SRCS_Module
|
|||
Resources/Fem.qrc
|
||||
PreCompiled.cpp
|
||||
PreCompiled.h
|
||||
PropertyFemMeshItem.cpp
|
||||
PropertyFemMeshItem.h
|
||||
Workbench.cpp
|
||||
Workbench.h
|
||||
)
|
||||
|
|
204
src/Mod/Fem/Gui/PropertyFemMeshItem.cpp
Normal file
204
src/Mod/Fem/Gui/PropertyFemMeshItem.cpp
Normal file
|
@ -0,0 +1,204 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2015 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_
|
||||
#endif
|
||||
|
||||
#include "PropertyFemMeshItem.h"
|
||||
#include <Mod/Fem/App/FemMeshProperty.h>
|
||||
#include <SMESH_Mesh.hxx>
|
||||
|
||||
using namespace FemGui;
|
||||
|
||||
|
||||
TYPESYSTEM_SOURCE(FemGui::PropertyFemMeshItem, Gui::PropertyEditor::PropertyItem);
|
||||
|
||||
PropertyFemMeshItem::PropertyFemMeshItem()
|
||||
{
|
||||
m_n = static_cast<Gui::PropertyEditor::PropertyIntegerItem*>
|
||||
(Gui::PropertyEditor::PropertyIntegerItem::create());
|
||||
m_n->setParent(this);
|
||||
m_n->setPropertyName(QLatin1String("Nodes"));
|
||||
this->appendChild(m_n);
|
||||
m_e = static_cast<Gui::PropertyEditor::PropertyIntegerItem*>
|
||||
(Gui::PropertyEditor::PropertyIntegerItem::create());
|
||||
m_e->setParent(this);
|
||||
m_e->setPropertyName(QLatin1String("Edges"));
|
||||
this->appendChild(m_e);
|
||||
m_f = static_cast<Gui::PropertyEditor::PropertyIntegerItem*>
|
||||
(Gui::PropertyEditor::PropertyIntegerItem::create());
|
||||
m_f->setParent(this);
|
||||
m_f->setPropertyName(QLatin1String("Faces"));
|
||||
this->appendChild(m_f);
|
||||
m_p = static_cast<Gui::PropertyEditor::PropertyIntegerItem*>
|
||||
(Gui::PropertyEditor::PropertyIntegerItem::create());
|
||||
m_p->setParent(this);
|
||||
m_p->setPropertyName(QLatin1String("Polygons"));
|
||||
this->appendChild(m_p);
|
||||
m_v = static_cast<Gui::PropertyEditor::PropertyIntegerItem*>
|
||||
(Gui::PropertyEditor::PropertyIntegerItem::create());
|
||||
m_v->setParent(this);
|
||||
m_v->setPropertyName(QLatin1String("Volumes"));
|
||||
this->appendChild(m_v);
|
||||
m_h = static_cast<Gui::PropertyEditor::PropertyIntegerItem*>
|
||||
(Gui::PropertyEditor::PropertyIntegerItem::create());
|
||||
m_h->setParent(this);
|
||||
m_h->setPropertyName(QLatin1String("Polyhedrons"));
|
||||
this->appendChild(m_h);
|
||||
}
|
||||
|
||||
void PropertyFemMeshItem::initialize()
|
||||
{
|
||||
this->setReadOnly(true);
|
||||
}
|
||||
|
||||
QVariant PropertyFemMeshItem::value(const App::Property*) const
|
||||
{
|
||||
int ctN = 0;
|
||||
int ctE = 0;
|
||||
int ctF = 0;
|
||||
int ctP = 0;
|
||||
int ctV = 0;
|
||||
int ctH = 0;
|
||||
|
||||
const std::vector<App::Property*>& props = getPropertyData();
|
||||
for (std::vector<App::Property*>::const_iterator pt = props.begin(); pt != props.end(); ++pt) {
|
||||
Fem::PropertyFemMesh* prop = static_cast<Fem::PropertyFemMesh*>(*pt);
|
||||
SMESH_Mesh* mesh = const_cast<SMESH_Mesh*>(prop->getValue().getSMesh());
|
||||
ctN += mesh->NbNodes();
|
||||
ctE += mesh->NbEdges();
|
||||
ctF += mesh->NbFaces();
|
||||
ctP += mesh->NbPolygons();
|
||||
ctV += mesh->NbVolumes();
|
||||
ctH += mesh->NbPolyhedrons();
|
||||
}
|
||||
|
||||
QString str = QObject::tr("[Nodes: %1, Edges: %2, Faces: %3, Polygons: %4, Volumes: %5, Polyhedrons: %6]")
|
||||
.arg(ctN).arg(ctE).arg(ctF).arg(ctP).arg(ctV).arg(ctH);
|
||||
return QVariant(str);
|
||||
}
|
||||
|
||||
QVariant PropertyFemMeshItem::toolTip(const App::Property* prop) const
|
||||
{
|
||||
return value(prop);
|
||||
}
|
||||
|
||||
void PropertyFemMeshItem::setValue(const QVariant& value)
|
||||
{
|
||||
}
|
||||
|
||||
QWidget* PropertyFemMeshItem::createEditor(QWidget* parent, const QObject* receiver, const char* method) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PropertyFemMeshItem::setEditorData(QWidget *editor, const QVariant& data) const
|
||||
{
|
||||
}
|
||||
|
||||
QVariant PropertyFemMeshItem::editorData(QWidget *editor) const
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
int PropertyFemMeshItem::countNodes() const
|
||||
{
|
||||
int ctN = 0;
|
||||
const std::vector<App::Property*>& props = getPropertyData();
|
||||
for (std::vector<App::Property*>::const_iterator pt = props.begin(); pt != props.end(); ++pt) {
|
||||
Fem::PropertyFemMesh* prop = static_cast<Fem::PropertyFemMesh*>(*pt);
|
||||
SMESH_Mesh* mesh = const_cast<SMESH_Mesh*>(prop->getValue().getSMesh());
|
||||
ctN += mesh->NbNodes();
|
||||
}
|
||||
|
||||
return ctN;
|
||||
}
|
||||
|
||||
int PropertyFemMeshItem::countEdges() const
|
||||
{
|
||||
int ctE = 0;
|
||||
const std::vector<App::Property*>& props = getPropertyData();
|
||||
for (std::vector<App::Property*>::const_iterator pt = props.begin(); pt != props.end(); ++pt) {
|
||||
Fem::PropertyFemMesh* prop = static_cast<Fem::PropertyFemMesh*>(*pt);
|
||||
SMESH_Mesh* mesh = const_cast<SMESH_Mesh*>(prop->getValue().getSMesh());
|
||||
ctE += mesh->NbEdges();
|
||||
}
|
||||
|
||||
return ctE;
|
||||
}
|
||||
|
||||
int PropertyFemMeshItem::countFaces() const
|
||||
{
|
||||
int ctF = 0;
|
||||
const std::vector<App::Property*>& props = getPropertyData();
|
||||
for (std::vector<App::Property*>::const_iterator pt = props.begin(); pt != props.end(); ++pt) {
|
||||
Fem::PropertyFemMesh* prop = static_cast<Fem::PropertyFemMesh*>(*pt);
|
||||
SMESH_Mesh* mesh = const_cast<SMESH_Mesh*>(prop->getValue().getSMesh());
|
||||
ctF += mesh->NbFaces();
|
||||
}
|
||||
|
||||
return ctF;
|
||||
}
|
||||
|
||||
int PropertyFemMeshItem::countPolygons() const
|
||||
{
|
||||
int ctP = 0;
|
||||
const std::vector<App::Property*>& props = getPropertyData();
|
||||
for (std::vector<App::Property*>::const_iterator pt = props.begin(); pt != props.end(); ++pt) {
|
||||
Fem::PropertyFemMesh* prop = static_cast<Fem::PropertyFemMesh*>(*pt);
|
||||
SMESH_Mesh* mesh = const_cast<SMESH_Mesh*>(prop->getValue().getSMesh());
|
||||
ctP += mesh->NbPolygons();
|
||||
}
|
||||
|
||||
return ctP;
|
||||
}
|
||||
|
||||
int PropertyFemMeshItem::countVolumes() const
|
||||
{
|
||||
int ctV = 0;
|
||||
const std::vector<App::Property*>& props = getPropertyData();
|
||||
for (std::vector<App::Property*>::const_iterator pt = props.begin(); pt != props.end(); ++pt) {
|
||||
Fem::PropertyFemMesh* prop = static_cast<Fem::PropertyFemMesh*>(*pt);
|
||||
SMESH_Mesh* mesh = const_cast<SMESH_Mesh*>(prop->getValue().getSMesh());
|
||||
ctV += mesh->NbVolumes();
|
||||
}
|
||||
|
||||
return ctV;
|
||||
}
|
||||
|
||||
int PropertyFemMeshItem::countPolyhedrons() const
|
||||
{
|
||||
int ctH = 0;
|
||||
const std::vector<App::Property*>& props = getPropertyData();
|
||||
for (std::vector<App::Property*>::const_iterator pt = props.begin(); pt != props.end(); ++pt) {
|
||||
Fem::PropertyFemMesh* prop = static_cast<Fem::PropertyFemMesh*>(*pt);
|
||||
SMESH_Mesh* mesh = const_cast<SMESH_Mesh*>(prop->getValue().getSMesh());
|
||||
ctH += mesh->NbPolyhedrons();
|
||||
}
|
||||
|
||||
return ctH;
|
||||
}
|
||||
|
||||
#include "moc_PropertyFemMeshItem.cpp"
|
78
src/Mod/Fem/Gui/PropertyFemMeshItem.h
Normal file
78
src/Mod/Fem/Gui/PropertyFemMeshItem.h
Normal file
|
@ -0,0 +1,78 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2015 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 FEMGUI_PROPERTY_FEMMESH_ITEM_H
|
||||
#define FEMGUI_PROPERTY_FEMMESH_ITEM_H
|
||||
|
||||
#include <Gui/propertyeditor/PropertyItem.h>
|
||||
|
||||
namespace FemGui {
|
||||
|
||||
/**
|
||||
* Display data of an FEM mesh.
|
||||
* \author Werner Mayer
|
||||
*/
|
||||
class PropertyFemMeshItem : public Gui::PropertyEditor::PropertyItem
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int Nodes READ countNodes)
|
||||
Q_PROPERTY(int Edges READ countEdges)
|
||||
Q_PROPERTY(int Faces READ countFaces)
|
||||
Q_PROPERTY(int Polygons READ countPolygons)
|
||||
Q_PROPERTY(int Volumes READ countVolumes)
|
||||
Q_PROPERTY(int Polyhedrons READ countPolyhedrons)
|
||||
TYPESYSTEM_HEADER();
|
||||
|
||||
virtual QWidget* createEditor(QWidget* parent, const QObject* receiver, const char* method) const;
|
||||
virtual void setEditorData(QWidget *editor, const QVariant& data) const;
|
||||
virtual QVariant editorData(QWidget *editor) const;
|
||||
|
||||
int countNodes() const;
|
||||
int countEdges() const;
|
||||
int countFaces() const;
|
||||
int countPolygons() const;
|
||||
int countVolumes() const;
|
||||
int countPolyhedrons() const;
|
||||
|
||||
protected:
|
||||
virtual QVariant toolTip(const App::Property*) const;
|
||||
virtual QVariant value(const App::Property*) const;
|
||||
virtual void setValue(const QVariant&);
|
||||
|
||||
protected:
|
||||
PropertyFemMeshItem();
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
Gui::PropertyEditor::PropertyIntegerItem* m_n;
|
||||
Gui::PropertyEditor::PropertyIntegerItem* m_e;
|
||||
Gui::PropertyEditor::PropertyIntegerItem* m_f;
|
||||
Gui::PropertyEditor::PropertyIntegerItem* m_p;
|
||||
Gui::PropertyEditor::PropertyIntegerItem* m_v;
|
||||
Gui::PropertyEditor::PropertyIntegerItem* m_h;
|
||||
};
|
||||
|
||||
} // namespace FemGui
|
||||
|
||||
|
||||
#endif // FEMGUI_PROPERTY_FEMMESH_ITEM_H
|
||||
|
Loading…
Reference in New Issue
Block a user