|
1 | 1 | /*----------------------------------------------------------------------------*/ |
2 | | -/* |
3 | | - * \file GroupManager.cpp |
4 | | - * |
5 | | - * \author Eric Brière de l'Isle |
6 | | - * |
7 | | - * \date 18/10/2012 |
8 | | - */ |
9 | | -/*----------------------------------------------------------------------------*/ |
10 | 2 | // pythonerie à mettre au début (pour permettre ifndef Py_PYTHON_H dans GroupManager.h) |
11 | 3 | #include <set> |
12 | 4 | /*----------------------------------------------------------------------------*/ |
|
54 | 46 | #include "Mesh/MeshModificationBySepa.h" |
55 | 47 | #include "Mesh/MeshModificationByProjectionOnP0.h" |
56 | 48 | #include "Mesh/CommandClearGroupName.h" |
57 | | - |
| 49 | +#include "Mesh/CommandChangeGroupName.h" |
58 | 50 | #include "SysCoord/SysCoord.h" |
59 | 51 |
|
60 | 52 | #include "Smoothing/SurfacicSmoothing.h" |
@@ -120,7 +112,6 @@ Internal::M3DCommandResult* GroupManager::clearGroup(int dim, const std::string& |
120 | 112 | Internal::M3DCommandResult* cmdResult = |
121 | 113 | new Internal::M3DCommandResult (*command); |
122 | 114 | return cmdResult; |
123 | | - |
124 | 115 | } |
125 | 116 | /*----------------------------------------------------------------------------*/ |
126 | 117 | bool GroupManager::getPropagate() |
@@ -158,6 +149,26 @@ std::string GroupManager::getDefaultName(int dim) const |
158 | 149 | } |
159 | 150 | } |
160 | 151 | /*----------------------------------------------------------------------------*/ |
| 152 | +Internal::M3DCommandResult* |
| 153 | +GroupManager::changeGroupName(const std::string& oldName, const std::string& newName, int dim) |
| 154 | +{ |
| 155 | + Mesh::CommandChangeGroupName* command = |
| 156 | + new Mesh::CommandChangeGroupName(getContext(), oldName, newName, dim); |
| 157 | + |
| 158 | + // trace dans le script |
| 159 | + TkUtil::UTF8String cmd (TkUtil::Charset::UTF_8); |
| 160 | + cmd << getContextAlias() << "." << "getGroupManager().changeGroupName (\""<<oldName<<"\", \""<<newName<<"\", "<<(short)dim<<")"; |
| 161 | + command->setScriptCommand(cmd); |
| 162 | + |
| 163 | + // on passe au gestionnaire de commandes qui exécute la commande en // ou non |
| 164 | + // et la stocke dans le gestionnaire de undo-redo si c'est une réussite |
| 165 | + getCommandManager().addCommand(command, Utils::Command::DO); |
| 166 | + |
| 167 | + Internal::M3DCommandResult* cmdResult = |
| 168 | + new Internal::M3DCommandResult (*command); |
| 169 | + return cmdResult; |
| 170 | +} |
| 171 | +/*----------------------------------------------------------------------------*/ |
161 | 172 | Group3D* GroupManager::getGroup3D(const std::string& gr_name, const bool exceptionIfNotFound) const |
162 | 173 | { |
163 | 174 | std::string name(gr_name.empty()?getDefaultName(3):gr_name); |
@@ -2275,13 +2286,13 @@ void GroupManager::setLevel(std::vector<std::string>& vg, int dim, int level) |
2275 | 2286 |
|
2276 | 2287 | } |
2277 | 2288 | /*----------------------------------------------------------------------------*/ |
2278 | | -GroupEntity* GroupManager::getGroup(const std::string& name, const int dim) const |
| 2289 | +GroupEntity* GroupManager::getGroup(const std::string& name, const int dim, const bool exceptionIfNotFound) const |
2279 | 2290 | { |
2280 | 2291 | switch(dim){ |
2281 | | - case(3): return getGroup3D(name); |
2282 | | - case(2): return getGroup2D(name); |
2283 | | - case(1): return getGroup1D(name); |
2284 | | - case(0): return getGroup0D(name); |
| 2292 | + case(3): return getGroup3D(name, exceptionIfNotFound); |
| 2293 | + case(2): return getGroup2D(name, exceptionIfNotFound); |
| 2294 | + case(1): return getGroup1D(name, exceptionIfNotFound); |
| 2295 | + case(0): return getGroup0D(name, exceptionIfNotFound); |
2285 | 2296 | default: { |
2286 | 2297 | throw TkUtil::Exception (TkUtil::UTF8String ("dimension non prévue pour GroupManager::getGroup", TkUtil::Charset::UTF_8)); |
2287 | 2298 | } |
|
0 commit comments