00001 /*************************************************************************** 00002 * Copyright (c) 2006 Werner Mayer <wmayer[at]users.sourceforge.net> * 00003 * * 00004 * This file is part of the FreeCAD CAx development system. * 00005 * * 00006 * This library is free software; you can redistribute it and/or * 00007 * modify it under the terms of the GNU Library General Public * 00008 * License as published by the Free Software Foundation; either * 00009 * version 2 of the License, or (at your option) any later version. * 00010 * * 00011 * This library is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00014 * GNU Library General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Library General Public * 00017 * License along with this library; see the file COPYING.LIB. If not, * 00018 * write to the Free Software Foundation, Inc., 59 Temple Place, * 00019 * Suite 330, Boston, MA 02111-1307, USA * 00020 * * 00021 ***************************************************************************/ 00022 00023 00024 #include "PreCompiled.h" 00025 00026 #ifndef _PreComp_ 00027 #endif 00028 00029 #include <Mod/Mesh/App/MeshFeature.h> 00030 #include "PropertyEditorMesh.h" 00031 00032 using namespace MeshGui; 00033 using MeshCore::MeshKernel; 00034 00035 00036 TYPESYSTEM_SOURCE(MeshGui::PropertyMeshKernelItem, Gui::PropertyEditor::PropertyItem); 00037 00038 PropertyMeshKernelItem::PropertyMeshKernelItem() 00039 { 00040 m_p = static_cast<Gui::PropertyEditor::PropertyIntegerItem*> 00041 (Gui::PropertyEditor::PropertyIntegerItem::create()); 00042 m_p->setParent(this); 00043 m_p->setPropertyName(QLatin1String("Points")); 00044 m_p->setReadOnly(true); 00045 this->appendChild(m_p); 00046 m_e = static_cast<Gui::PropertyEditor::PropertyIntegerItem*> 00047 (Gui::PropertyEditor::PropertyIntegerItem::create()); 00048 m_e->setParent(this); 00049 m_e->setPropertyName(QLatin1String("Edges")); 00050 m_e->setReadOnly(true); 00051 this->appendChild(m_e); 00052 m_f = static_cast<Gui::PropertyEditor::PropertyIntegerItem*> 00053 (Gui::PropertyEditor::PropertyIntegerItem::create()); 00054 m_f->setParent(this); 00055 m_f->setPropertyName(QLatin1String("Faces")); 00056 m_f->setReadOnly(true); 00057 this->appendChild(m_f); 00058 } 00059 00060 QVariant PropertyMeshKernelItem::value(const App::Property*) const 00061 { 00062 int ctP = 0; 00063 int ctE = 0; 00064 int ctF = 0; 00065 00066 std::vector<App::Property*> props = getPropertyData(); 00067 for ( std::vector<App::Property*>::const_iterator pt = props.begin(); pt != props.end(); ++pt ) { 00068 Mesh::PropertyMeshKernel* pPropMesh = (Mesh::PropertyMeshKernel*)(*pt); 00069 const MeshKernel& rMesh = pPropMesh->getValue().getKernel(); 00070 ctP += (int)rMesh.CountPoints(); 00071 ctE += (int)rMesh.CountEdges(); 00072 ctF += (int)rMesh.CountFacets(); 00073 } 00074 00075 QString str = QObject::tr("[Points: %1, Edges: %2 Faces: %3]").arg(ctP).arg(ctE).arg(ctF); 00076 return QVariant(str); 00077 } 00078 00079 QVariant PropertyMeshKernelItem::toolTip(const App::Property* prop) const 00080 { 00081 return value(prop); 00082 } 00083 00084 void PropertyMeshKernelItem::setValue(const QVariant& value) 00085 { 00086 } 00087 00088 QWidget* PropertyMeshKernelItem::createEditor(QWidget* parent, const QObject* receiver, const char* method) const 00089 { 00090 return 0; 00091 } 00092 00093 void PropertyMeshKernelItem::setEditorData(QWidget *editor, const QVariant& data) const 00094 { 00095 } 00096 00097 QVariant PropertyMeshKernelItem::editorData(QWidget *editor) const 00098 { 00099 return QVariant(); 00100 } 00101 00102 int PropertyMeshKernelItem::countPoints() const 00103 { 00104 int ctP = 0; 00105 std::vector<App::Property*> props = getPropertyData(); 00106 for ( std::vector<App::Property*>::const_iterator pt = props.begin(); pt != props.end(); ++pt ) { 00107 Mesh::PropertyMeshKernel* pPropMesh = (Mesh::PropertyMeshKernel*)(*pt); 00108 const MeshKernel& rMesh = pPropMesh->getValue().getKernel(); 00109 ctP += (int)rMesh.CountPoints(); 00110 } 00111 00112 return ctP; 00113 } 00114 00115 int PropertyMeshKernelItem::countEdges() const 00116 { 00117 int ctE = 0; 00118 std::vector<App::Property*> props = getPropertyData(); 00119 for ( std::vector<App::Property*>::const_iterator pt = props.begin(); pt != props.end(); ++pt ) { 00120 Mesh::PropertyMeshKernel* pPropMesh = (Mesh::PropertyMeshKernel*)(*pt); 00121 const MeshKernel& rMesh = pPropMesh->getValue().getKernel(); 00122 ctE += (int)rMesh.CountEdges(); 00123 } 00124 00125 return ctE; 00126 } 00127 00128 int PropertyMeshKernelItem::countFaces() const 00129 { 00130 int ctF = 0; 00131 std::vector<App::Property*> props = getPropertyData(); 00132 for ( std::vector<App::Property*>::const_iterator pt = props.begin(); pt != props.end(); ++pt ) { 00133 Mesh::PropertyMeshKernel* pPropMesh = (Mesh::PropertyMeshKernel*)(*pt); 00134 const MeshKernel& rMesh = pPropMesh->getValue().getKernel(); 00135 ctF += (int)rMesh.CountFacets(); 00136 } 00137 00138 return ctF; 00139 } 00140 00141 #include "moc_PropertyEditorMesh.cpp"