-
Notifications
You must be signed in to change notification settings - Fork 26
Trik Studio 3D Visualization #1526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 12 commits
78e8957
861d908
21156a0
3d6e534
710e851
ac8c00e
53a413d
cc7c592
7a87218
21400ba
65e7037
64df440
5ef1af1
8688514
c738a8f
441910c
8b6149b
40b7ffd
169906c
d0b13f5
5131260
b3c21e3
0d5d1f1
c2c4e10
5989474
45e25cf
6437234
57566f2
56f96e2
33286dd
3d94758
f8d9ce5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ | |
| #include "twoDModel/engine/twoDModelDisplayWidget.h" | ||
|
|
||
| #include "twoDModel/twoDModelDeclSpec.h" | ||
| #include "plugins/robots/common/twoDModel/src/engine/trajectory/connectionToVizualizator.h" | ||
|
|
||
| class QComboBox; | ||
| class QPushButton; | ||
|
|
@@ -47,6 +48,10 @@ class ControllerInterface; | |
|
|
||
| namespace twoDModel { | ||
|
|
||
| //namespace trajectory { | ||
| //class ConnectionToVizualizator; | ||
| //} | ||
|
|
||
| namespace model { | ||
| class Model; | ||
| class RobotModel; | ||
|
|
@@ -108,6 +113,7 @@ class TWO_D_MODEL_EXPORT TwoDModelWidget : public QWidget | |
| QDomDocument generateWorldModelWithBlobsXml() const; | ||
| QDomDocument generateWorldModelXml() const; | ||
| QDomDocument generateBlobsXml() const; | ||
| ConnectionToVizualizator *mConnToVizualizator; | ||
|
||
|
|
||
| public slots: | ||
| void zoomIn() override; | ||
|
|
@@ -129,6 +135,9 @@ public slots: | |
| /// Emitted when user has stopped intepretation from the 2D model window. | ||
| void stopButtonPressed(); | ||
|
|
||
| /// Emitted when user has stopped intepretation from the remote vizualizator | ||
| void restartRequested(); | ||
|
|
||
| protected: | ||
| void changeEvent(QEvent *e) override; | ||
| void showEvent(QShowEvent *e) override; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ | |
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
|
|
@@ -17,6 +17,7 @@ | |
| #include <qrutils/graphicsUtils/abstractItem.h> | ||
|
|
||
| #include "twoDModel/engine/model/robotModel.h" | ||
| #include "src/engine/trajectory/trajectorySaver.h" | ||
| #include "twoDModel/engine/model/constants.h" | ||
| #include "twoDModel/engine/model/worldModel.h" | ||
| #include "src/engine/view/scene/twoDModelScene.h" | ||
|
|
@@ -32,6 +33,7 @@ | |
| #include "parts/box2DItem.h" | ||
|
|
||
| using namespace twoDModel::model::physics; | ||
|
|
||
| using namespace parts; | ||
| using namespace mathUtils; | ||
|
|
||
|
|
@@ -44,6 +46,7 @@ Box2DPhysicsEngine::Box2DPhysicsEngine (const WorldModel &worldModel | |
| , mWorld(new b2World(b2Vec2(0, 0))) | ||
| , mPrevPosition(b2Vec2(0, 0)) | ||
| , mPrevAngle(0) | ||
| , mTrajSaver(new TrajectorySaver(nullptr)) | ||
|
||
| { | ||
| connect(&worldModel, &model::WorldModel::wallAdded, | ||
| this, [this](const QSharedPointer<QGraphicsItem> &i) {itemAdded(i.data());}); | ||
|
|
@@ -53,6 +56,10 @@ Box2DPhysicsEngine::Box2DPhysicsEngine (const WorldModel &worldModel | |
| this, [this](const QSharedPointer<QGraphicsItem> &i) {itemAdded(i.data());}); | ||
| connect(&worldModel, &model::WorldModel::itemRemoved, | ||
| this, [this](const QSharedPointer<QGraphicsItem> &i) {itemRemoved(i.data());}); | ||
|
|
||
| connect(this, &Box2DPhysicsEngine::trajectoryPosOrAngleChanged, mTrajSaver, &TrajectorySaver::saveItemPosOrAngle); | ||
| connect(this, &Box2DPhysicsEngine::trajectoryItemDragged, mTrajSaver, &TrajectorySaver::onItemDragged); | ||
| connect(this, &Box2DPhysicsEngine::sendNextFrame, mTrajSaver, &TrajectorySaver::sendFrame); | ||
| } | ||
|
|
||
| Box2DPhysicsEngine::~Box2DPhysicsEngine(){ | ||
|
|
@@ -145,6 +152,16 @@ void Box2DPhysicsEngine::addRobot(model::RobotModel * const robot) | |
| }); | ||
|
|
||
| connect(robot, &model::RobotModel::deserialized, this, &Box2DPhysicsEngine::onMouseReleased); | ||
|
|
||
|
|
||
| connect(robot, &RobotModel::trajectorySoundStateChanged, mTrajSaver, &TrajectorySaver::saveBeepState); | ||
| connect(robot, &RobotModel::trajectoryMarkerColorChanged, mTrajSaver, &TrajectorySaver::saveMarkerState); | ||
| connect(robot, &RobotModel::trajectoryPosOrAngleChanged, mTrajSaver, &TrajectorySaver::saveItemPosOrAngle); | ||
| connect(robot, &RobotModel::trajectoryOnitemDragged, mTrajSaver, &TrajectorySaver::onItemDragged); | ||
|
|
||
| connect(robot, &RobotModel::trajectorySave, mTrajSaver, &TrajectorySaver::saveToFile); | ||
| // connect(robot, &RobotModel::OnStartPlaying, mTrajSaver, &TrajectorySaver::OnStartInterpretation); | ||
| connect(robot, &RobotModel::onStopPlaying, mTrajSaver, &TrajectorySaver::onStopInterpretation); | ||
| }); | ||
| } | ||
|
|
||
|
|
@@ -353,7 +370,10 @@ void Box2DPhysicsEngine::nextFrame() | |
| item->setPos(scenePos - item->boundingRect().center()); | ||
| item->setRotation(angleToScene(mBox2DDynamicItems[item]->getRotation())); | ||
| } | ||
| auto *abstractItem = dynamic_cast<graphicsUtils::AbstractItem *>(item); | ||
|
||
| emit trajectoryPosOrAngleChanged(abstractItem->id(), abstractItem->pos(), abstractItem->rotation()); | ||
| } | ||
| emit sendNextFrame(); | ||
| } | ||
|
|
||
| void Box2DPhysicsEngine::clearForcesAndStop() | ||
|
|
@@ -364,6 +384,7 @@ void Box2DPhysicsEngine::clearForcesAndStop() | |
| body->SetLinearVelocity({0, 0}); | ||
| body->SetAngularVelocity(0); | ||
| } | ||
| //emit trajectorySave(); | ||
| } | ||
|
|
||
| bool Box2DPhysicsEngine::isRobotStuck() const | ||
|
|
@@ -428,6 +449,7 @@ void Box2DPhysicsEngine::onItemDragged(graphicsUtils::AbstractItem *item) | |
| bItem->setRotation(0); | ||
| bItem->moveToPosition(positionToBox2D(localScenePos + localCenter)); | ||
| bItem->setRotation(angleToBox2D(localRotation)); | ||
| emit trajectoryItemDragged(item->id(), item->pos(), item->rotation()); | ||
| } | ||
| } else { | ||
| b2Vec2 pos = positionToBox2D(collidingPolygon.boundingRect().center()); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Зачем этот
#include?