~ubuntu-branches/ubuntu/maverick/freecad/maverick

« back to all changes in this revision

Viewing changes to src/Mod/Mesh/Gui/ViewProviderTransform.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Teemu Ikonen
  • Date: 2009-07-16 18:37:41 UTC
  • Revision ID: james.westby@ubuntu.com-20090716183741-oww9kcxqrk991i1n
Tags: upstream-0.8.2237
ImportĀ upstreamĀ versionĀ 0.8.2237

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (c) 2004 Werner Mayer <werner.wm.mayer@gmx.de>              *
 
3
 *                                                                         *
 
4
 *   This file is part of the FreeCAD CAx development system.              *
 
5
 *                                                                         *
 
6
 *   This library is free software; you can redistribute it and/or         *
 
7
 *   modify it under the terms of the GNU Library General Public           *
 
8
 *   License as published by the Free Software Foundation; either          *
 
9
 *   version 2 of the License, or (at your option) any later version.      *
 
10
 *                                                                         *
 
11
 *   This library  is distributed in the hope that it will be useful,      *
 
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
14
 *   GNU Library General Public License for more details.                  *
 
15
 *                                                                         *
 
16
 *   You should have received a copy of the GNU Library General Public     *
 
17
 *   License along with this library; see the file COPYING.LIB. If not,    *
 
18
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
 
19
 *   Suite 330, Boston, MA  02111-1307, USA                                *
 
20
 *                                                                         *
 
21
 ***************************************************************************/
 
22
 
 
23
 
 
24
#include "PreCompiled.h"
 
25
 
 
26
#ifndef _PreComp_
 
27
# include <Inventor/nodes/SoDrawStyle.h>
 
28
# include <Inventor/nodes/SoMaterial.h>
 
29
# include <Inventor/nodes/SoNormalBinding.h>
 
30
# include <Inventor/nodes/SoIndexedFaceSet.h>
 
31
# include <Inventor/manips/SoTransformerManip.h>
 
32
#endif
 
33
 
 
34
/// Here the FreeCAD includes sorted by Base,App,Gui......
 
35
#include <Base/Console.h>
 
36
#include <Base/Parameter.h>
 
37
#include <Base/Exception.h>
 
38
#include <App/Application.h>
 
39
#include <Gui/Selection.h>
 
40
#include <Gui/SoFCSelection.h>
 
41
#include <Base/Sequencer.h>
 
42
 
 
43
#include "ViewProvider.h"
 
44
#include "ViewProviderTransform.h"
 
45
 
 
46
#include <Mod/Mesh/App/MeshFeature.h>
 
47
#include <Mod/Mesh/App/Mesh.h>
 
48
#include <Mod/Mesh/App/Core/Iterator.h>
 
49
 
 
50
using namespace MeshGui;
 
51
using Mesh::Feature;
 
52
 
 
53
 
 
54
PROPERTY_SOURCE(MeshGui::ViewProviderMeshTransform, MeshGui::ViewProviderMesh)
 
55
 
 
56
 
 
57
ViewProviderMeshTransform::ViewProviderMeshTransform()
 
58
{
 
59
  pcTransformerDragger = new SoTransformerManip();
 
60
  pcTransformerDragger->ref();
 
61
}
 
62
 
 
63
ViewProviderMeshTransform::~ViewProviderMeshTransform()
 
64
{
 
65
  pcTransformerDragger->unref();
 
66
}
 
67
 
 
68
void ViewProviderMeshTransform::attach(App::DocumentObject *pcFeat)
 
69
{
 
70
  // creats the standard viewing modes
 
71
  ViewProviderMesh::attach(pcFeat);
 
72
 
 
73
  SoSeparator* pcEditRoot = new SoSeparator();
 
74
 
 
75
  // flat shaded (Normal) ------------------------------------------
 
76
  SoDrawStyle *pcFlatStyle = new SoDrawStyle();
 
77
  pcFlatStyle->style = SoDrawStyle::FILLED;
 
78
  SoNormalBinding* pcBinding = new SoNormalBinding();
 
79
        pcBinding->value=SoNormalBinding::PER_FACE;
 
80
 
 
81
  pcEditRoot->addChild(pcTransformerDragger);
 
82
  pcEditRoot->addChild(pcFlatStyle);
 
83
  pcEditRoot->addChild(pcShapeMaterial);
 
84
  pcEditRoot->addChild(pcBinding);
 
85
  pcEditRoot->addChild(pcHighlight);
 
86
 
 
87
  // adding to the switch
 
88
  addDisplayMaskMode(pcEditRoot, "Edit");
 
89
}
 
90
 
 
91
void ViewProviderMeshTransform::updateData(const App::Property* prop)
 
92
{
 
93
  ViewProviderMesh::updateData(prop);
 
94
}
 
95
 
 
96
void ViewProviderMeshTransform::setDisplayMode(const char* ModeName)
 
97
{
 
98
  if ( strcmp("Transform",ModeName) == 0 )
 
99
    setDisplayMaskMode("Edit");
 
100
  ViewProviderMesh::setDisplayMode(ModeName);
 
101
}
 
102
 
 
103
const char* ViewProviderMeshTransform::getDefaultDisplayMode() const
 
104
{
 
105
  return "Transform";
 
106
}
 
107
 
 
108
std::vector<std::string> ViewProviderMeshTransform::getDisplayModes(void) const
 
109
{
 
110
  std::vector<std::string> StrList = ViewProviderMesh::getDisplayModes();
 
111
  StrList.push_back("Transform");
 
112
  return StrList;
 
113
}
 
114
 
 
115