| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| | #include <QAction>
|
| | #include <QMenu>
|
| | #include <sstream>
|
| |
|
| | #include <Inventor/nodes/SoBaseColor.h>
|
| | #include <Inventor/nodes/SoCoordinate3.h>
|
| | #include <Inventor/nodes/SoDrawStyle.h>
|
| | #include <Inventor/nodes/SoLineSet.h>
|
| | #include <Inventor/nodes/SoMarkerSet.h>
|
| | #include <Inventor/nodes/SoSeparator.h>
|
| |
|
| | #include <App/Application.h>
|
| | #include <App/Document.h>
|
| | #include <Gui/Inventor/MarkerBitmaps.h>
|
| | #include <Mod/Robot/App/TrajectoryObject.h>
|
| |
|
| | #include "ViewProviderTrajectory.h"
|
| |
|
| |
|
| | using namespace Gui;
|
| | using namespace RobotGui;
|
| | using namespace Robot;
|
| |
|
| | PROPERTY_SOURCE(RobotGui::ViewProviderTrajectory, Gui::ViewProviderGeometryObject)
|
| |
|
| | ViewProviderTrajectory::ViewProviderTrajectory()
|
| | {
|
| |
|
| | pcTrajectoryRoot = new Gui::SoFCSelection();
|
| | pcTrajectoryRoot->preselectionMode = Gui::SoFCSelection::OFF;
|
| | pcTrajectoryRoot->selectionMode = Gui::SoFCSelection::SEL_OFF;
|
| |
|
| | pcTrajectoryRoot->ref();
|
| |
|
| | pcCoords = new SoCoordinate3();
|
| | pcCoords->ref();
|
| | pcDrawStyle = new SoDrawStyle();
|
| | pcDrawStyle->ref();
|
| | pcDrawStyle->style = SoDrawStyle::LINES;
|
| | pcDrawStyle->lineWidth = 2;
|
| |
|
| | pcLines = new SoLineSet;
|
| | pcLines->ref();
|
| | }
|
| |
|
| | ViewProviderTrajectory::~ViewProviderTrajectory()
|
| | {
|
| | pcTrajectoryRoot->unref();
|
| | pcCoords->unref();
|
| | pcDrawStyle->unref();
|
| | pcLines->unref();
|
| | }
|
| |
|
| | void ViewProviderTrajectory::attach(App::DocumentObject* pcObj)
|
| | {
|
| | ViewProviderGeometryObject::attach(pcObj);
|
| |
|
| |
|
| | SoSeparator* linesep = new SoSeparator;
|
| | SoBaseColor* basecol = new SoBaseColor;
|
| | basecol->rgb.setValue(1.0f, 0.5f, 0.0f);
|
| | linesep->addChild(basecol);
|
| | linesep->addChild(pcCoords);
|
| | linesep->addChild(pcLines);
|
| |
|
| |
|
| | SoBaseColor* markcol = new SoBaseColor;
|
| | markcol->rgb.setValue(1.0f, 1.0f, 0.0f);
|
| | SoMarkerSet* marker = new SoMarkerSet;
|
| | marker->markerIndex = Gui::Inventor::MarkerBitmaps::getMarkerIndex(
|
| | "CROSS",
|
| | App::GetApplication()
|
| | .GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")
|
| | ->GetInt("MarkerSize", 5)
|
| | );
|
| | linesep->addChild(markcol);
|
| | linesep->addChild(marker);
|
| |
|
| | pcTrajectoryRoot->addChild(linesep);
|
| |
|
| | addDisplayMaskMode(pcTrajectoryRoot, "Waypoints");
|
| | pcTrajectoryRoot->objectName = pcObj->getNameInDocument();
|
| | pcTrajectoryRoot->documentName = pcObj->getDocument()->getName();
|
| | pcTrajectoryRoot->subElementName = "Main";
|
| | }
|
| |
|
| | void ViewProviderTrajectory::setDisplayMode(const char* ModeName)
|
| | {
|
| | if (strcmp("Waypoints", ModeName) == 0) {
|
| | setDisplayMaskMode("Waypoints");
|
| | }
|
| | ViewProviderGeometryObject::setDisplayMode(ModeName);
|
| | }
|
| |
|
| | std::vector<std::string> ViewProviderTrajectory::getDisplayModes() const
|
| | {
|
| | std::vector<std::string> StrList;
|
| | StrList.emplace_back("Waypoints");
|
| | return StrList;
|
| | }
|
| |
|
| | void ViewProviderTrajectory::updateData(const App::Property* prop)
|
| | {
|
| | Robot::TrajectoryObject* pcTracObj = static_cast<Robot::TrajectoryObject*>(pcObject);
|
| | if (prop == &pcTracObj->Trajectory) {
|
| | const Trajectory& trak = pcTracObj->Trajectory.getValue();
|
| |
|
| | pcCoords->point.deleteValues(0);
|
| | pcCoords->point.setNum(trak.getSize());
|
| |
|
| | for (unsigned int i = 0; i < trak.getSize(); ++i) {
|
| | Base::Vector3d pos = trak.getWaypoint(i).EndPos.getPosition();
|
| | pcCoords->point.set1Value(i, pos.x, pos.y, pos.z);
|
| | }
|
| | pcLines->numVertices.set1Value(0, trak.getSize());
|
| | }
|
| | }
|
| |
|
| | void ViewProviderTrajectory::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
|
| | {
|
| | QAction* act = menu->addAction(QObject::tr("Modify"), receiver, member);
|
| | act->setData(QVariant((int)ViewProvider::Default));
|
| | }
|
| |
|