00001 /*************************************************************************** 00002 * Copyright (c) 2004 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 # include <Inventor/nodes/SoDrawStyle.h> 00028 # include <Inventor/nodes/SoMaterial.h> 00029 # include <Inventor/nodes/SoNormalBinding.h> 00030 # include <Inventor/nodes/SoIndexedFaceSet.h> 00031 # include <Inventor/nodes/SoSeparator.h> 00032 # include <Inventor/manips/SoTransformerManip.h> 00033 #endif 00034 00036 #include <Base/Console.h> 00037 #include <Base/Parameter.h> 00038 #include <Base/Exception.h> 00039 #include <App/Application.h> 00040 #include <Gui/Selection.h> 00041 #include <Gui/SoFCSelection.h> 00042 #include <Base/Sequencer.h> 00043 00044 #include "ViewProvider.h" 00045 #include "ViewProviderTransform.h" 00046 00047 #include <Mod/Mesh/App/MeshFeature.h> 00048 #include <Mod/Mesh/App/Mesh.h> 00049 #include <Mod/Mesh/App/Core/Iterator.h> 00050 00051 using namespace MeshGui; 00052 using Mesh::Feature; 00053 00054 00055 PROPERTY_SOURCE(MeshGui::ViewProviderMeshTransform, MeshGui::ViewProviderMesh) 00056 00057 00058 ViewProviderMeshTransform::ViewProviderMeshTransform() 00059 { 00060 pcTransformerDragger = new SoTransformerManip(); 00061 pcTransformerDragger->ref(); 00062 } 00063 00064 ViewProviderMeshTransform::~ViewProviderMeshTransform() 00065 { 00066 pcTransformerDragger->unref(); 00067 } 00068 00069 void ViewProviderMeshTransform::attach(App::DocumentObject *pcFeat) 00070 { 00071 // creats the standard viewing modes 00072 ViewProviderMesh::attach(pcFeat); 00073 00074 SoSeparator* pcEditRoot = new SoSeparator(); 00075 00076 // flat shaded (Normal) ------------------------------------------ 00077 SoDrawStyle *pcFlatStyle = new SoDrawStyle(); 00078 pcFlatStyle->style = SoDrawStyle::FILLED; 00079 SoNormalBinding* pcBinding = new SoNormalBinding(); 00080 pcBinding->value=SoNormalBinding::PER_FACE; 00081 00082 pcEditRoot->addChild(pcTransformerDragger); 00083 pcEditRoot->addChild(pcFlatStyle); 00084 pcEditRoot->addChild(pcShapeMaterial); 00085 pcEditRoot->addChild(pcBinding); 00086 pcEditRoot->addChild(pcHighlight); 00087 00088 // adding to the switch 00089 addDisplayMaskMode(pcEditRoot, "Edit"); 00090 } 00091 00092 void ViewProviderMeshTransform::updateData(const App::Property* prop) 00093 { 00094 ViewProviderMesh::updateData(prop); 00095 } 00096 00097 void ViewProviderMeshTransform::setDisplayMode(const char* ModeName) 00098 { 00099 if ( strcmp("Transform",ModeName) == 0 ) 00100 setDisplayMaskMode("Edit"); 00101 ViewProviderMesh::setDisplayMode(ModeName); 00102 } 00103 00104 const char* ViewProviderMeshTransform::getDefaultDisplayMode() const 00105 { 00106 return "Transform"; 00107 } 00108 00109 std::vector<std::string> ViewProviderMeshTransform::getDisplayModes(void) const 00110 { 00111 std::vector<std::string> StrList = ViewProviderMesh::getDisplayModes(); 00112 StrList.push_back("Transform"); 00113 return StrList; 00114 } 00115 00116