RemoveOperation.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package MemoryX::gui-plugins::SceneEditor
19  * @date 2015
20  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21  * GNU General Public License
22  */
23 
24 #pragma once
25 
26 // std
27 #include <exception>
28 #include <string>
29 
30 // scene3D
31 #include <Inventor/SbRotation.h>
32 #include <Inventor/SbVec3f.h>
33 
34 // local
35 #include "../memoryxcontroller/MemoryXController.h"
36 #include "../scene3D/Scene.h"
37 #include "AddOperation.h"
38 #include "Operation.h"
39 
40 namespace controller
41 {
42  /**
43  * A Operation to remove a object in the scene and the WorkingMemory.
44  *
45  * @see controller::Operation
46  */
47  class RemoveOperation : public Operation
48  {
49  friend class AddOperation;
50 
51  public:
52  /**
53  * Creates a new operation, which removes a object.
54  *
55  * @param memoryXController The MemoryXController to remove the object at.
56  * @param scene The scene to remove the object at.
57  * @param objectId The ID of the object to remove.
58  *
59  * @see controller::Operation::Operation
60  */
62  const std::shared_ptr<memoryxcontroller::MemoryXController>& memoryXController,
63  const std::shared_ptr<scene3D::Scene>& scene,
64  const std::string& objectId);
65 
66  /**
67  * Returns a new operation which adds the object again.
68  *
69  * @return The operation, which adds the object again.
70  *
71  * @see controller::Operation::createInverseOperation
72  */
73  const OperationPtr createInverseOperation() const override;
74 
75  /**
76  * Returns true, if the SceneObject is mutable.
77  *
78  * @return true, if the SceneObject is mutable; false otherwise.
79  */
80  bool isExecuteable() override;
81 
82  protected:
83  /**
84  * Removes the object from the WorkingMemory.
85  *
86  * @see controller::Operation::executeOnWorkingMemory
87  */
88  void executeOnWorkingMemory() override;
89 
90  /**
91  * Removes the object from the local Scene.
92  *
93  * @see controller::Operation::executeOnScene
94  */
95  void executeOnScene() override;
96 
97  private:
99  const std::shared_ptr<memoryxcontroller::MemoryXController>& memoryXController,
100  const std::shared_ptr<scene3D::Scene>& scene,
101  const std::string& objectName,
102  const std::string& objectCollection,
103  const SbVec3f& objectPosition,
104  const SbRotation& objectRotation,
105  const std::string& objectId);
106 
107  std::string objectName;
108  std::string objectCollection;
109  SbVec3f objectPosition;
110  SbRotation objectRotation;
111  };
112 } // namespace controller
controller::RemoveOperation::executeOnScene
void executeOnScene() override
Removes the object from the local Scene.
Definition: RemoveOperation.cpp:103
Operation.h
controller::RemoveOperation::isExecuteable
bool isExecuteable() override
Returns true, if the SceneObject is mutable.
Definition: RemoveOperation.cpp:121
controller::RemoveOperation::createInverseOperation
const OperationPtr createInverseOperation() const override
Returns a new operation which adds the object again.
Definition: RemoveOperation.cpp:66
AddOperation.h
controller
Definition: AddOperation.h:39
controller::RemoveOperation::executeOnWorkingMemory
void executeOnWorkingMemory() override
Removes the object from the WorkingMemory.
Definition: RemoveOperation.cpp:87
controller::OperationPtr
std::shared_ptr< Operation > OperationPtr
Definition: ClassDefinitions.h:54
controller::RemoveOperation::RemoveOperation
RemoveOperation(const std::shared_ptr< memoryxcontroller::MemoryXController > &memoryXController, const std::shared_ptr< scene3D::Scene > &scene, const std::string &objectId)
Creates a new operation, which removes a object.
Definition: RemoveOperation.cpp:53
controller::RemoveOperation
A Operation to remove a object in the scene and the WorkingMemory.
Definition: RemoveOperation.h:47
controller::AddOperation
A Operation to create a new object in the scene and the WorkingMemory.
Definition: AddOperation.h:46
controller::Operation
An abstract class, which offers methods to run operations on the WorkingMemory and the Scene.
Definition: Operation.h:44