Revert "License conversion from Flora to Apache 2.0"
[platform/core/uifw/dali-core.git] / dali / internal / event / dynamics / dynamics-slider-joint-impl.cpp
1 //
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://floralicense.org/license/
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 // CLASS HEADER
18 #include <dali/internal/event/dynamics/dynamics-slider-joint-impl.h>
19
20 // EXTERNAL HEADERS
21
22 // INTERNAL HEADERS
23 #include <dali/integration-api/debug.h>
24 #include <dali/internal/event/common/stage-impl.h>
25 #include <dali/internal/update/dynamics/scene-graph-dynamics-slider-joint.h>
26 #include <dali/internal/event/dynamics/dynamics-body-impl.h>
27 #include <dali/internal/event/dynamics/dynamics-world-impl.h>
28
29 namespace Dali
30 {
31
32 namespace Internal
33 {
34
35 DynamicsSliderJoint::DynamicsSliderJoint(DynamicsWorldPtr world,
36                                          DynamicsBodyPtr bodyA, DynamicsBodyPtr bodyB,
37                                          const Vector3& pointA, const Vector3& pointB, const Vector3& axis,
38                                          const float translationLowerLimit, const float translationUpperLimit,
39                                          const Radian& rotationLowerLimit, const Radian& rotationUpperLimit )
40 : DynamicsJoint(Dali::DynamicsJoint::SLIDER),
41   mTranslationLowerLimit(1.0f),
42   mTranslationUpperLimit(-1.0f),
43   mRotationLowerLimit(0.0f),
44   mRotationUpperLimit(0.0f)
45 {
46   DALI_LOG_INFO(Debug::Filter::gDynamics, Debug::Verbose, "%s - (\"%s\", \"%s\")\n",
47                 __PRETTY_FUNCTION__, bodyA->GetName().c_str(), (bodyB) ? bodyB->GetName().c_str() : "FIXED" );
48
49   SceneGraph::DynamicsSliderJoint* joint( new SceneGraph::DynamicsSliderJoint( *(world->GetSceneObject()) ) );
50   mDynamicsJoint = joint;
51
52   SceneGraph::DynamicsBody* bA(bodyA->GetSceneObject());
53   SceneGraph::DynamicsBody* bB(!bodyB ? NULL : bodyB->GetSceneObject() );
54
55   Stage::GetCurrent().QueueMessage( InitializeDynamicsSliderJointMessage(*joint, *bA, bB, pointA, pointB, axis) );
56
57   SetTranslationLowerLimit(translationLowerLimit);
58   SetTranslationUpperLimit(translationUpperLimit);
59   SetRotationLowerLimit(rotationLowerLimit);
60   SetRotationUpperLimit(rotationUpperLimit);
61 }
62
63 DynamicsSliderJoint::~DynamicsSliderJoint()
64 {
65   DALI_LOG_INFO(Debug::Filter::gDynamics, Debug::Verbose, "%s\n", __PRETTY_FUNCTION__);
66 }
67
68 float DynamicsSliderJoint::GetTranslationLowerLimit() const
69 {
70   return mTranslationLowerLimit;
71 }
72
73 void DynamicsSliderJoint::SetTranslationLowerLimit( const float limit )
74 {
75   if( mTranslationLowerLimit != limit )
76   {
77     mTranslationLowerLimit = limit;
78
79     Stage::GetCurrent().QueueMessage( SetTranslationLowerLimitMessage( *(GetSceneObject()), limit ) );
80   }
81 }
82
83 float DynamicsSliderJoint::GetTranslationUpperLimit() const
84 {
85   return mTranslationUpperLimit;
86 }
87
88 void DynamicsSliderJoint::SetTranslationUpperLimit( const float limit )
89 {
90   if( mTranslationUpperLimit != limit )
91   {
92     mTranslationUpperLimit = limit;
93
94     Stage::GetCurrent().QueueMessage( SetTranslationUpperLimitMessage( *(GetSceneObject()), limit ) );
95   }
96 }
97
98 Radian DynamicsSliderJoint::GetRotationLowerLimit() const
99 {
100   return mRotationLowerLimit;
101 }
102
103 void DynamicsSliderJoint::SetRotationLowerLimit( const Radian& limit )
104 {
105   if( mRotationLowerLimit != limit )
106   {
107     mRotationLowerLimit = limit;
108
109     Stage::GetCurrent().QueueMessage( SetRotationLowerLimitMessage( *(GetSceneObject()), limit ) );
110   }
111 }
112
113 Radian DynamicsSliderJoint::GetRotationUpperLimit() const
114 {
115   return mRotationUpperLimit;
116 }
117
118 void DynamicsSliderJoint::SetRotationUpperLimit( const Radian& limit )
119 {
120   if( mRotationUpperLimit != limit )
121   {
122     mRotationUpperLimit = limit;
123
124     Stage::GetCurrent().QueueMessage( SetRotationUpperLimitMessage( *(GetSceneObject()), limit ) );
125   }
126 }
127
128 SceneGraph::DynamicsSliderJoint* DynamicsSliderJoint::GetSceneObject() const
129 {
130   return static_cast<SceneGraph::DynamicsSliderJoint*>(DynamicsJoint::GetSceneObject());
131 }
132
133
134 } // namespace Internal
135
136 } // namespace Dali