#include <QLabel>
#include <QHBoxLayout>
#include <QToolButton>
#include <QPushButton>
#include "coordinate3dwidget.h"
#include"my_interface.h"
//class MainWindow;
Coordinate3dWidget
::Coordinate3dWidget(QWidget *parent
):{
pos_cam
->setObjectName
(QString::fromUtf8("pos_cam"));
pos_cam
->setGeometry
(QRect(10,
50,
191,
71));
pos_cam->setTitle("Position");
sbx_cam
->setObjectName
(QString::fromUtf8("sbx_cam"));
sbx_cam
->setGeometry
(QRect(10,
40,
51,
22));
sbx_cam->setRange(-5000, 5000);
lx_cam
->setObjectName
(QString::fromUtf8("lx_cam"));
lx_cam
->setGeometry
(QRect(10,
20,
46,
13));
sby_cam
->setObjectName
(QString::fromUtf8("sby_cam"));
sby_cam
->setGeometry
(QRect(70,
40,
51,
22));
sby_cam->setRange(-5000, 5000);
ly_cam
->setObjectName
(QString::fromUtf8("ly_cam"));
ly_cam
->setGeometry
(QRect(70,
20,
46,
13));
sbz_cam
->setObjectName
(QString::fromUtf8("sbz_cam"));
sbz_cam
->setGeometry
(QRect(130,
40,
51,
22));
sbz_cam->setRange(-5000, 5000);
lz_cam
->setObjectName
(QString::fromUtf8("lz_cam"));
lz_cam
->setGeometry
(QRect(130,
20,
46,
13));
connect(sbx_cam, SIGNAL(/*valueChanged*/editingFinished()), this, SLOT(onCoordinateChanged()));
connect(sby_cam, SIGNAL(/*valueChanged*/editingFinished()), this, SLOT(onCoordinateChanged()));
connect(sbz_cam, SIGNAL(/*valueChanged*/editingFinished()), this, SLOT(onCoordinateChanged()));
}
void Coordinate3dWidget::setNewCoordinate(const Ogre::Vector3 &coordinate)
{
blockSignals(true);
sbx_cam->setValue(coordinate.x);
sby_cam->setValue(coordinate.y);
sbz_cam->setValue(coordinate.z);
blockSignals(false);
}
void Coordinate3dWidget::onCoordinateChanged()
{
Ogre::Vector3 newCoord(sbx_cam->value(),
sby_cam->value(),
sbz_cam->value());
emit coordinateChanged(newCoord);
}
#include <QLabel>
#include <QHBoxLayout>
#include <QToolButton>
#include <QPushButton>
#include "coordinate3dwidget.h"
#include"my_interface.h"
//class MainWindow;
Coordinate3dWidget::Coordinate3dWidget(QWidget *parent):
QWidget(parent)
{
pos_cam = new QGroupBox(this);
pos_cam->setObjectName(QString::fromUtf8("pos_cam"));
pos_cam->setGeometry(QRect(10, 50, 191, 71));
pos_cam->setTitle("Position");
sbx_cam = new QDoubleSpinBox(pos_cam);
sbx_cam->setObjectName(QString::fromUtf8("sbx_cam"));
sbx_cam->setGeometry(QRect(10, 40, 51, 22));
sbx_cam->setRange(-5000, 5000);
lx_cam = new QLabel(pos_cam);
lx_cam->setObjectName(QString::fromUtf8("lx_cam"));
lx_cam->setGeometry(QRect(10, 20, 46, 13));
lx_cam->setText(QApplication::translate("MainWindow", "X :", 0, QApplication::UnicodeUTF8));
sby_cam = new QDoubleSpinBox(pos_cam);
sby_cam->setObjectName(QString::fromUtf8("sby_cam"));
sby_cam->setGeometry(QRect(70, 40, 51, 22));
sby_cam->setRange(-5000, 5000);
ly_cam = new QLabel(pos_cam);
ly_cam->setObjectName(QString::fromUtf8("ly_cam"));
ly_cam->setGeometry(QRect(70, 20, 46, 13));
ly_cam->setText(QApplication::translate("MainWindow", "Y :", 0, QApplication::UnicodeUTF8));
sbz_cam = new QDoubleSpinBox(pos_cam);
sbz_cam->setObjectName(QString::fromUtf8("sbz_cam"));
sbz_cam->setGeometry(QRect(130, 40, 51, 22));
sbz_cam->setRange(-5000, 5000);
lz_cam = new QLabel(pos_cam);
lz_cam->setObjectName(QString::fromUtf8("lz_cam"));
lz_cam->setGeometry(QRect(130, 20, 46, 13));
lz_cam->setText(QApplication::translate("MainWindow", "Z :", 0, QApplication::UnicodeUTF8));
connect(sbx_cam, SIGNAL(/*valueChanged*/editingFinished()), this, SLOT(onCoordinateChanged()));
connect(sby_cam, SIGNAL(/*valueChanged*/editingFinished()), this, SLOT(onCoordinateChanged()));
connect(sbz_cam, SIGNAL(/*valueChanged*/editingFinished()), this, SLOT(onCoordinateChanged()));
}
void Coordinate3dWidget::setNewCoordinate(const Ogre::Vector3 &coordinate)
{
blockSignals(true);
sbx_cam->setValue(coordinate.x);
sby_cam->setValue(coordinate.y);
sbz_cam->setValue(coordinate.z);
blockSignals(false);
}
void Coordinate3dWidget::onCoordinateChanged()
{
Ogre::Vector3 newCoord(sbx_cam->value(),
sby_cam->value(),
sbz_cam->value());
emit coordinateChanged(newCoord);
}
To copy to clipboard, switch view to plain text mode
and in my mainwindow
MainWindow::MainWindow()
{
ogreWidget = new OgreWidget(this);
setCentralWidget(ogreWidget);
createDockWidget();
}
void MainWindow::createDockWidget()
{
page_14 = new Coordinate3dWidget;
page_14
->setGeometry
(QRect(0,
0,
211,
250));
connect(page_14, SIGNAL(coordinateChanged(const Ogre::Vector3&)),
ogreWidget, SLOT(setCameraPosition(const Ogre::Vector3&)));
connect(ogreWidget, SIGNAL(cameraPositionChanged(const Ogre::Vector3&)),
page_14, SLOT(setNewCoordinate(const Ogre::Vector3&)));
MainWindow::MainWindow()
{
ogreWidget = new OgreWidget(this);
setCentralWidget(ogreWidget);
createDockWidget();
}
void MainWindow::createDockWidget()
{
page_14 = new Coordinate3dWidget;
page_14->setGeometry(QRect(0, 0, 211, 250));
connect(page_14, SIGNAL(coordinateChanged(const Ogre::Vector3&)),
ogreWidget, SLOT(setCameraPosition(const Ogre::Vector3&)));
connect(ogreWidget, SIGNAL(cameraPositionChanged(const Ogre::Vector3&)),
page_14, SLOT(setNewCoordinate(const Ogre::Vector3&)));
To copy to clipboard, switch view to plain text mode
in my class OgreWidget i defined slot
in setCameraPosition: when i entre the numbers in the three boxes i must execute this slot to add object in the position entred
void QOgreWidget::setCameraPosition(const Ogre::Vector3 &pos)
{
CamNode= mSceneMgr->getRootSceneNode()->createChildSceneNode();
ent_cam = mSceneMgr->createEntity( Ogre::SceneManager:: PT_CUBE);
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create("green", "General");
material->getTechnique( 0 )->getPass( 0 )->setAmbient(1, 1, 0);
ent_cam->setMaterial(material);
mSceneMgr->getRootSceneNode()->createChildSceneNode();
CamNode->setPosition(pos);
CamNode->attachObject(ent_cam);
}
in setCameraPosition: when i entre the numbers in the three boxes i must execute this slot to add object in the position entred
void QOgreWidget::setCameraPosition(const Ogre::Vector3 &pos)
{
CamNode= mSceneMgr->getRootSceneNode()->createChildSceneNode();
ent_cam = mSceneMgr->createEntity( Ogre::SceneManager:: PT_CUBE);
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create("green", "General");
material->getTechnique( 0 )->getPass( 0 )->setAmbient(1, 1, 0);
ent_cam->setMaterial(material);
mSceneMgr->getRootSceneNode()->createChildSceneNode();
CamNode->setPosition(pos);
CamNode->attachObject(ent_cam);
}
To copy to clipboard, switch view to plain text mode
Bookmarks