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/SbVec3f.h>
32 #include <Inventor/SbRotation.h>
33 
34 // local
35 #include "../scene3D/Scene.h"
36 #include "Operation.h"
37 #include "../memoryxcontroller/MemoryXController.h"
38 #include "AddOperation.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  */
61  RemoveOperation(const std::shared_ptr<memoryxcontroller::MemoryXController>& memoryXController, const std::shared_ptr<scene3D::Scene>& scene, const std::string& objectId);
62 
63  /**
64  * Returns a new operation which adds the object again.
65  *
66  * @return The operation, which adds the object again.
67  *
68  * @see controller::Operation::createInverseOperation
69  */
70  const OperationPtr createInverseOperation() const override;
71 
72  /**
73  * Returns true, if the SceneObject is mutable.
74  *
75  * @return true, if the SceneObject is mutable; false otherwise.
76  */
77  bool isExecuteable() override;
78 
79  protected:
80  /**
81  * Removes the object from the WorkingMemory.
82  *
83  * @see controller::Operation::executeOnWorkingMemory
84  */
85  void executeOnWorkingMemory() override;
86 
87  /**
88  * Removes the object from the local Scene.
89  *
90  * @see controller::Operation::executeOnScene
91  */
92  void executeOnScene() override;
93 
94  private:
95  RemoveOperation(const std::shared_ptr<memoryxcontroller::MemoryXController>& memoryXController, const std::shared_ptr<scene3D::Scene>& scene, const std::string& objectName, const std::string& objectCollection, const SbVec3f& objectPosition, const SbRotation& objectRotation, const std::string& objectId);
96 
97  std::string objectName;
98  std::string objectCollection;
99  SbVec3f objectPosition;
100  SbRotation objectRotation;
101 
102  };
103 }
104 
controller::RemoveOperation::executeOnScene
void executeOnScene() override
Removes the object from the local Scene.
Definition: RemoveOperation.cpp:82
Operation.h
controller::RemoveOperation::isExecuteable
bool isExecuteable() override
Returns true, if the SceneObject is mutable.
Definition: RemoveOperation.cpp:99
controller::RemoveOperation::createInverseOperation
const OperationPtr createInverseOperation() const override
Returns a new operation which adds the object again.
Definition: RemoveOperation.cpp:54
AddOperation.h
controller
Definition: AddOperation.h:39
controller::RemoveOperation::executeOnWorkingMemory
void executeOnWorkingMemory() override
Removes the object from the WorkingMemory.
Definition: RemoveOperation.cpp:67
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:45
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