diff --git a/CMakeLists.txt b/CMakeLists.txt index 270c4aa..f88f4bd 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ cmake_minimum_required(VERSION 3.24.0) cmake_policy(SET CMP0005 NEW) cmake_policy(SET CMP0048 NEW) # manages project version -project(QtMeshEditor VERSION 1.8.7 LANGUAGES CXX) +project(QtMeshEditor VERSION 1.8.8 LANGUAGES CXX) message(STATUS "Building QtMeshEditor version ${PROJECT_VERSION}") set(QTMESHEDITOR_VERSION_STRING "\"${PROJECT_VERSION}\"") diff --git a/src/SkeletonDebug.cpp b/src/SkeletonDebug.cpp index 5d1756f..b8c896b 100755 --- a/src/SkeletonDebug.cpp +++ b/src/SkeletonDebug.cpp @@ -1,29 +1,3 @@ -/*///////////////////////////////////////////////////////////////////////////////// -/// A QtMeshEditor file -/// -/// Copyright (c) HogPog Team (www.hogpog.com.br) -/// -/// The MIT License -/// -/// Permission is hereby granted, free of charge, to any person obtaining a copy -/// of this software and associated documentation files (the "Software"), to deal -/// in the Software without restriction, including without limitation the rights -/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -/// copies of the Software, and to permit persons to whom the Software is -/// furnished to do so, subject to the following conditions: -/// -/// The above copyright notice and this permission notice shall be included in -/// all copies or substantial portions of the Software. -/// -/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -/// THE SOFTWARE. -////////////////////////////////////////////////////////////////////////////////*/ - #include "SkeletonDebug.h" #include diff --git a/src/SkeletonDebug.h b/src/SkeletonDebug.h index 9d7f4f6..028c745 100755 --- a/src/SkeletonDebug.h +++ b/src/SkeletonDebug.h @@ -1,29 +1,3 @@ -/*///////////////////////////////////////////////////////////////////////////////// -/// A QtMeshEditor file -/// -/// Copyright (c) HogPog Team (www.hogpog.com.br) -/// -/// The MIT License -/// -/// Permission is hereby granted, free of charge, to any person obtaining a copy -/// of this software and associated documentation files (the "Software"), to deal -/// in the Software without restriction, including without limitation the rights -/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -/// copies of the Software, and to permit persons to whom the Software is -/// furnished to do so, subject to the following conditions: -/// -/// The above copyright notice and this permission notice shall be included in -/// all copies or substantial portions of the Software. -/// -/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -/// THE SOFTWARE. -////////////////////////////////////////////////////////////////////////////////*/ - #ifndef SKELETONDEBUG_H_INCLUDED #define SKELETONDEBUG_H_INCLUDED diff --git a/src/SkeletonDebug_test.cpp b/src/SkeletonDebug_test.cpp new file mode 100644 index 0000000..fa4976f --- /dev/null +++ b/src/SkeletonDebug_test.cpp @@ -0,0 +1,71 @@ +#include +#include "Manager.h" +#include "mainwindow.h" +#include "SkeletonDebug.h" + +class SkeletonDebugTests : public ::testing::Test { +protected: + std::unique_ptr skeletonDebug; + + void SetUp() override { + QStringList validUri{"./media/models/robot.mesh"}; + Manager::getSingleton()->getMainWindow()->importMeshs(validUri); + Ogre::Entity* entity = Manager::getSingleton()->getEntities().last(); + Ogre::SceneManager* sceneManager = Manager::getSingleton()->getSceneMgr(); + skeletonDebug = std::make_unique(entity,sceneManager); + } + +}; + +TEST_F(SkeletonDebugTests, ShowAxesTest) +{ + // Initially, axes should not be shown + EXPECT_FALSE(skeletonDebug->axesShown()); + + // Show axes + skeletonDebug->showAxes(true); + EXPECT_TRUE(skeletonDebug->axesShown()); + + // Hide axes + skeletonDebug->showAxes(false); + EXPECT_FALSE(skeletonDebug->axesShown()); +} + +TEST_F(SkeletonDebugTests, ShowNamesTest) +{ + // Initially, names should not be shown + EXPECT_FALSE(skeletonDebug->namesShown()); + + // Show names + skeletonDebug->showNames(true); + EXPECT_TRUE(skeletonDebug->namesShown()); + + // Hide names + skeletonDebug->showNames(false); + EXPECT_FALSE(skeletonDebug->namesShown()); +} + +TEST_F(SkeletonDebugTests, ShowBonesTest) +{ + // Initially, bones should not be shown + EXPECT_FALSE(skeletonDebug->bonesShown()); + + // Show bones + skeletonDebug->showBones(true); + EXPECT_TRUE(skeletonDebug->bonesShown()); + + // Hide bones + skeletonDebug->showBones(false); + EXPECT_FALSE(skeletonDebug->bonesShown()); +} + +TEST_F(SkeletonDebugTests, SetAndGetAxesScaleTest) +{ + // Set axes scale + skeletonDebug->setAxesScale(0.5f); + EXPECT_FLOAT_EQ(skeletonDebug->getAxesScale(), 0.5f); + + // Set axes scale to a different value + skeletonDebug->setAxesScale(1.0f); + EXPECT_FLOAT_EQ(skeletonDebug->getAxesScale(), 1.0f); +} diff --git a/src/TransformOperator.cpp b/src/TransformOperator.cpp index 3f1c33a..743297e 100755 --- a/src/TransformOperator.cpp +++ b/src/TransformOperator.cpp @@ -20,7 +20,7 @@ //////////////////////////////////////// // Static variable initialisation -TransformOperator* TransformOperator:: m_pSingleton = 0; +TransformOperator* TransformOperator:: m_pSingleton = nullptr; const QPoint TransformOperator::invalidPosition(-1,-1); //////////////////////////////////////// @@ -28,7 +28,7 @@ const QPoint TransformOperator::invalidPosition(-1,-1); TransformOperator* TransformOperator::getSingleton() { - if (m_pSingleton == 0) + if (m_pSingleton == nullptr) { m_pSingleton = new TransformOperator(); } @@ -38,10 +38,10 @@ TransformOperator* TransformOperator::getSingleton() void TransformOperator::kill() { - if (m_pSingleton != 0) + if (m_pSingleton != nullptr) { delete m_pSingleton; - m_pSingleton = 0; + m_pSingleton = nullptr; } } @@ -332,7 +332,7 @@ Ogre::MovableObject* TransformOperator::performRaySelection(const QPoint& pos, b return (queryResultIterator->movable); } - return 0; + return nullptr; } diff --git a/src/TransformOperator.h b/src/TransformOperator.h index 7e00520..37c9374 100755 --- a/src/TransformOperator.h +++ b/src/TransformOperator.h @@ -43,13 +43,15 @@ class TransformOperator : public QObject, public QtMouseListener }; const Ogre::ColourValue& getSelectionBoxColour() const; + + // Made public for testing static void swap(int& x, int& y); + Ogre::Ray rayFromScreenPoint(const QPoint& pos); private: TransformOperator (); ~TransformOperator (); - Ogre::Ray rayFromScreenPoint(const QPoint& pos); Ogre::MovableObject* performRaySelection(const QPoint& pos, bool findGizmo = false); void performBoxSelection(const QPoint& first, const QPoint& second, SelectionMode mode = NEW_SELECT); void updateGizmo(); diff --git a/src/TransformOperator_test.cpp b/src/TransformOperator_test.cpp index 1d9d8f2..ef0431a 100644 --- a/src/TransformOperator_test.cpp +++ b/src/TransformOperator_test.cpp @@ -38,3 +38,10 @@ TEST(TransformOperatorTest, Swap) { EXPECT_EQ(x, 2); EXPECT_EQ(y, 1); } + +TEST(TransformOperatorTest, RayFromScreenPoint) { + TransformOperator* instance = TransformOperator::getSingleton(); + Ogre::Ray ray = instance->rayFromScreenPoint(QPoint(0, 0)); + EXPECT_EQ(ray.getOrigin(), Ogre::Vector3::ZERO); + EXPECT_EQ(ray.getDirection(), Ogre::Vector3::UNIT_Z); +} diff --git a/src/TranslationGizmo.cpp b/src/TranslationGizmo.cpp index ee58f88..c4230fa 100755 --- a/src/TranslationGizmo.cpp +++ b/src/TranslationGizmo.cpp @@ -22,7 +22,6 @@ TranslationGizmo::TranslationGizmo(Ogre::SceneNode* linkNode, const Ogre::String m_pYaxis = pSceneMgr->createManualObject(name + "Y"); m_pZaxis = pSceneMgr->createManualObject(name + "Z"); - //Default Color Ogre::Real solid=1.0f; mXaxisColor = Ogre::ColourValue(solid, 0, 0, solid); @@ -48,7 +47,6 @@ TranslationGizmo::~TranslationGizmo() pSceneMgr->destroyManualObject(m_pXaxis); pSceneMgr->destroyManualObject(m_pYaxis); pSceneMgr->destroyManualObject(m_pZaxis); - } void TranslationGizmo::createXaxis(const Ogre::ColourValue& colour) diff --git a/src/about_test.cpp b/src/about_test.cpp index bcfcb27..d80fd68 100644 --- a/src/about_test.cpp +++ b/src/about_test.cpp @@ -19,6 +19,8 @@ TEST_F(AboutTest, VersionTextIsCorrect) { QApplication app(argc, argv); About aboutDialog; + About aboutDialog2(&aboutDialog); // Also test with a parent widget. QString expectedVersionText = QString("Version: ") + QTMESHEDITOR_VERSION; EXPECT_EQ(aboutDialog.getVersionText(), expectedVersionText); -} \ No newline at end of file + EXPECT_EQ(aboutDialog2.getVersionText(), expectedVersionText); +}