Implement manual alignment utility
This commit is contained in:
@@ -1407,6 +1407,7 @@ void Application::initTypes(void)
|
||||
Gui::BaseView ::init();
|
||||
Gui::MDIView ::init();
|
||||
Gui::View3DInventor ::init();
|
||||
Gui::AbstractSplitView ::init();
|
||||
Gui::SplitView3DInventor ::init();
|
||||
// View Provider
|
||||
Gui::ViewProvider ::init();
|
||||
|
||||
@@ -125,6 +125,7 @@ set(Gui_MOC_HDRS
|
||||
HelpView.h
|
||||
InputVector.h
|
||||
MainWindow.h
|
||||
ManualAlignment.h
|
||||
MDIView.h
|
||||
NetworkRetriever.h
|
||||
OnlineDocumentation.h
|
||||
@@ -627,7 +628,7 @@ SET(Inventor_CPP_SRCS
|
||||
SoFCInteractiveElement.cpp
|
||||
SoFCOffscreenRenderer.cpp
|
||||
SoFCSelection.cpp
|
||||
SoFCUnifiedSelection.cpp
|
||||
SoFCUnifiedSelection.cpp
|
||||
SoFCSelectionAction.cpp
|
||||
SoFCVectorizeSVGAction.cpp
|
||||
SoFCVectorizeU3DAction.cpp
|
||||
@@ -647,7 +648,7 @@ SET(Inventor_SRCS
|
||||
SoFCInteractiveElement.h
|
||||
SoFCOffscreenRenderer.h
|
||||
SoFCSelection.h
|
||||
SoFCUnifiedSelection.h
|
||||
SoFCUnifiedSelection.h
|
||||
SoFCSelectionAction.h
|
||||
SoFCVectorizeSVGAction.h
|
||||
SoFCVectorizeU3DAction.h
|
||||
@@ -743,6 +744,7 @@ SET(FreeCADGui_CPP_SRCS
|
||||
Thumbnail.cpp
|
||||
Utilities.cpp
|
||||
WaitCursor.cpp
|
||||
ManualAlignment.cpp
|
||||
)
|
||||
SET(FreeCADGui_SRCS
|
||||
Application.h
|
||||
@@ -763,6 +765,7 @@ SET(FreeCADGui_SRCS
|
||||
Thumbnail.h
|
||||
Utilities.h
|
||||
WaitCursor.h
|
||||
ManualAlignment.h
|
||||
)
|
||||
|
||||
SET(FreeCADGui_SRCS
|
||||
|
||||
@@ -50,11 +50,13 @@
|
||||
#include "DlgProjectUtility.h"
|
||||
#include "Transform.h"
|
||||
#include "Placement.h"
|
||||
#include "ManualAlignment.h"
|
||||
#include "WaitCursor.h"
|
||||
#include "ViewProvider.h"
|
||||
#include <Gui/View3DInventor.h>
|
||||
#include <Gui/View3DInventorViewer.h>
|
||||
#include "MergeDocuments.h"
|
||||
#include "NavigationStyle.h"
|
||||
|
||||
using namespace Gui;
|
||||
|
||||
@@ -1013,6 +1015,63 @@ bool StdCmdPlacement::isActive(void)
|
||||
return (Gui::Control().activeDialog()==0);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// Std_Alignment
|
||||
//===========================================================================
|
||||
DEF_STD_CMD_A(StdCmdAlignment);
|
||||
|
||||
StdCmdAlignment::StdCmdAlignment()
|
||||
: Command("Std_Alignment")
|
||||
{
|
||||
sGroup = QT_TR_NOOP("Edit");
|
||||
sMenuText = QT_TR_NOOP("Alignment...");
|
||||
sToolTipText = QT_TR_NOOP("Align the selected objects");
|
||||
sStatusTip = QT_TR_NOOP("Align the selected objects");
|
||||
sWhatsThis = "Std_Alignment";
|
||||
}
|
||||
|
||||
void StdCmdAlignment::activated(int iMsg)
|
||||
{
|
||||
std::vector<App::DocumentObject*> sel = Gui::Selection().getObjectsOfType
|
||||
(App::GeoFeature::getClassTypeId());
|
||||
ManualAlignment* align = ManualAlignment::instance();
|
||||
QObject::connect(align, SIGNAL(emitCanceled()), align, SLOT(deleteLater()));
|
||||
QObject::connect(align, SIGNAL(emitFinished()), align, SLOT(deleteLater()));
|
||||
|
||||
// Get the fixed and moving meshes
|
||||
FixedGroup fixedGroup;
|
||||
std::map<int, MovableGroup> groupMap;
|
||||
fixedGroup.addView(sel[0]);
|
||||
groupMap[0].addView(sel[1]);
|
||||
|
||||
// add the fixed group
|
||||
align->setFixedGroup(fixedGroup);
|
||||
|
||||
// create the model of movable groups
|
||||
MovableGroupModel model;
|
||||
model.addGroups(groupMap);
|
||||
align->setModel(model);
|
||||
Base::Type style = Base::Type::fromName("Gui::CADNavigationStyle");
|
||||
Gui::Document* doc = Application::Instance->activeDocument();
|
||||
if (doc) {
|
||||
View3DInventor* mdi = qobject_cast<View3DInventor*>(doc->getActiveView());
|
||||
if (mdi) {
|
||||
style = mdi->getViewer()->navigationStyle()->getTypeId();
|
||||
}
|
||||
}
|
||||
|
||||
align->setMinPoints(1);
|
||||
align->startAlignment(style);
|
||||
Gui::Selection().clearSelection();
|
||||
}
|
||||
|
||||
bool StdCmdAlignment::isActive(void)
|
||||
{
|
||||
if (ManualAlignment::hasInstance())
|
||||
return false;
|
||||
return Gui::Selection().countObjectsOfType(App::GeoFeature::getClassTypeId()) == 2;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// Std_Edit
|
||||
//===========================================================================
|
||||
@@ -1085,6 +1144,7 @@ void CreateDocCommands(void)
|
||||
rcCmdMgr.addCommand(new StdCmdRefresh());
|
||||
rcCmdMgr.addCommand(new StdCmdTransform());
|
||||
rcCmdMgr.addCommand(new StdCmdPlacement());
|
||||
rcCmdMgr.addCommand(new StdCmdAlignment());
|
||||
rcCmdMgr.addCommand(new StdCmdEdit());
|
||||
}
|
||||
|
||||
|
||||
1244
src/Gui/ManualAlignment.cpp
Normal file
1244
src/Gui/ManualAlignment.cpp
Normal file
File diff suppressed because it is too large
Load Diff
257
src/Gui/ManualAlignment.h
Normal file
257
src/Gui/ManualAlignment.h
Normal file
@@ -0,0 +1,257 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2012 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef GUI_MANUALALIGNMENT_H
|
||||
#define GUI_MANUALALIGNMENT_H
|
||||
|
||||
#include <Base/Placement.h>
|
||||
#include <Base/Vector3D.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/ViewProviderDocumentObject.h>
|
||||
#include <boost/signals.hpp>
|
||||
|
||||
class SbVec3f;
|
||||
class SoPickedPoint;
|
||||
class SoEventCallback;
|
||||
|
||||
namespace Gui {
|
||||
class Document;
|
||||
class AlignmentView;
|
||||
class View3DInventorViewer;
|
||||
|
||||
/**
|
||||
* The AlignemntGroup class is the base for fixed and movable groups.
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class GuiExport AlignmentGroup
|
||||
{
|
||||
protected:
|
||||
AlignmentGroup();
|
||||
~AlignmentGroup();
|
||||
|
||||
public:
|
||||
/**
|
||||
* Add a mesh to the group.
|
||||
*/
|
||||
void addView(App::DocumentObject*);
|
||||
std::vector<App::DocumentObject*> getViews() const;
|
||||
/**
|
||||
* Checks for the view provider of one of the added views.
|
||||
*/
|
||||
bool hasView(Gui::ViewProviderDocumentObject*) const;
|
||||
/**
|
||||
* Remove a previously added view by its view provider.
|
||||
*/
|
||||
void removeView(Gui::ViewProviderDocumentObject*);
|
||||
/**
|
||||
* Add the group and therefore all its added view providers to the Inventor tree.
|
||||
*/
|
||||
void addToViewer(Gui::View3DInventorViewer*) const;
|
||||
/**
|
||||
* Remove all the view providers from the Inventor tree.
|
||||
*/
|
||||
void removeFromViewer(Gui::View3DInventorViewer*) const;
|
||||
void setRandomColor();
|
||||
/**
|
||||
* Returns the document of the added views.
|
||||
*/
|
||||
Gui::Document* getDocument() const;
|
||||
/**
|
||||
* Add a point to an array of picked points.
|
||||
*/
|
||||
void addPoint(const Base::Vector3d&);
|
||||
/**
|
||||
* Remove last point from array of picked points.
|
||||
*/
|
||||
void removeLastPoint();
|
||||
/**
|
||||
* Count the number of picked points.
|
||||
*/
|
||||
int countPoints() const;
|
||||
/**
|
||||
* Return an array of picked points.
|
||||
*/
|
||||
const std::vector<Base::Vector3d>& getPoints() const;
|
||||
/**
|
||||
* Clear all picked points.
|
||||
*/
|
||||
void clearPoints();
|
||||
/**
|
||||
* Set or unset the alignable mode for the added views. If a view is not alignable it also not pickable.
|
||||
*/
|
||||
void setAlignable(bool);
|
||||
void moveTo(AlignmentGroup&);
|
||||
/**
|
||||
* Clear the list of added views.
|
||||
*/
|
||||
void clear();
|
||||
/**
|
||||
* Checks whether the list of added views is empty or not.
|
||||
*/
|
||||
bool isEmpty() const;
|
||||
/**
|
||||
* Return the number of added views.
|
||||
*/
|
||||
int count() const;
|
||||
|
||||
protected:
|
||||
std::vector<Base::Vector3d> _pickedPoints;
|
||||
std::vector<Gui::ViewProviderDocumentObject*> _views;
|
||||
};
|
||||
|
||||
/**
|
||||
* The FixedGroup class can be used for a fixed group of views.
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class GuiExport MovableGroup : public AlignmentGroup
|
||||
{
|
||||
public:
|
||||
MovableGroup();
|
||||
~MovableGroup();
|
||||
};
|
||||
|
||||
/**
|
||||
* The FixedGroup class can be used for a fixed group of views.
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class GuiExport FixedGroup : public AlignmentGroup
|
||||
{
|
||||
public:
|
||||
FixedGroup();
|
||||
~FixedGroup();
|
||||
};
|
||||
|
||||
/**
|
||||
* The MovableGroupModel class keeps an array of movable groups.
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class GuiExport MovableGroupModel
|
||||
{
|
||||
public:
|
||||
MovableGroupModel();
|
||||
~MovableGroupModel();
|
||||
|
||||
void addGroup(const MovableGroup&);
|
||||
void addGroups(const std::map<int, MovableGroup>&);
|
||||
MovableGroup& activeGroup();
|
||||
const MovableGroup& activeGroup() const;
|
||||
void continueAlignment();
|
||||
void clear();
|
||||
bool isEmpty() const;
|
||||
int count() const;
|
||||
|
||||
protected:
|
||||
void removeActiveGroup();
|
||||
|
||||
private:
|
||||
std::vector<MovableGroup> _groups;
|
||||
};
|
||||
|
||||
/**
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class GuiExport ManualAlignment : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
protected:
|
||||
ManualAlignment();
|
||||
~ManualAlignment();
|
||||
|
||||
public:
|
||||
static ManualAlignment* instance();
|
||||
static void destruct();
|
||||
static bool hasInstance();
|
||||
|
||||
void setMinPoints(int minPoints);
|
||||
void setFixedGroup(const FixedGroup&);
|
||||
void setModel(const MovableGroupModel&);
|
||||
void clearAll();
|
||||
|
||||
void setViewingDirections(const Base::Vector3d& view1, const Base::Vector3d& up1,
|
||||
const Base::Vector3d& view2, const Base::Vector3d& up2);
|
||||
void startAlignment(Base::Type mousemodel);
|
||||
void finish();
|
||||
void align();
|
||||
bool canAlign() const;
|
||||
void cancel();
|
||||
|
||||
const Base::Placement & getTransform() const
|
||||
{ return myTransform; }
|
||||
void alignObject(App::DocumentObject*);
|
||||
|
||||
// Observer stuff
|
||||
/// Checks if the given object is about to be removed
|
||||
void slotDeletedDocument(const Gui::Document& Doc);
|
||||
/// Checks if the given document is about to be closed
|
||||
void slotDeletedObject(const Gui::ViewProvider& Obj);
|
||||
|
||||
protected:
|
||||
bool computeAlignment(const std::vector<Base::Vector3d>& unnavPts, const std::vector<Base::Vector3d>& navigPts);
|
||||
void continueAlignment();
|
||||
void showInstructions();
|
||||
/** @name Probe picking */
|
||||
//@{
|
||||
static void probePickedCallback(void * ud, SoEventCallback * n);
|
||||
void applyPickedProbe(Gui::ViewProviderDocumentObject*, const SoPickedPoint* pnt);
|
||||
//@}
|
||||
|
||||
protected Q_SLOTS:
|
||||
void reset();
|
||||
void onAlign();
|
||||
void onRemoveLastPointMoveable();
|
||||
void onRemoveLastPointFixed();
|
||||
void onClear();
|
||||
void onCancel();
|
||||
|
||||
Q_SIGNALS:
|
||||
void emitCanceled();
|
||||
void emitFinished();
|
||||
|
||||
private:
|
||||
SoNode* pickedPointsSubGraph(const SbVec3f& p, const SbVec3f& n, int id);
|
||||
void closeViewer();
|
||||
|
||||
static ManualAlignment* _instance;
|
||||
|
||||
typedef boost::BOOST_SIGNALS_NAMESPACE::connection Connection;
|
||||
Connection connectApplicationDeletedDocument;
|
||||
Connection connectDocumentDeletedObject;
|
||||
|
||||
FixedGroup myFixedGroup;
|
||||
MovableGroupModel myAlignModel;
|
||||
QPointer<Gui::AlignmentView> myViewer;
|
||||
Gui::Document* myDocument;
|
||||
int myPickPoints;
|
||||
Base::Placement myTransform;
|
||||
|
||||
class Private;
|
||||
Private* d;
|
||||
};
|
||||
|
||||
} // namespace Gui
|
||||
|
||||
|
||||
#endif // GUI_MANUALALIGNMENT_H
|
||||
|
||||
@@ -24,20 +24,34 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# ifdef FC_OS_WIN32
|
||||
# include <windows.h>
|
||||
# endif
|
||||
# ifdef FC_OS_MACOSX
|
||||
# include <OpenGL/gl.h>
|
||||
# else
|
||||
# include <GL/gl.h>
|
||||
# endif
|
||||
# include <Inventor/actions/SoGetBoundingBoxAction.h>
|
||||
# include <Inventor/actions/SoGLRenderAction.h>
|
||||
# include <Inventor/bundles/SoMaterialBundle.h>
|
||||
# include <Inventor/bundles/SoTextureCoordinateBundle.h>
|
||||
# include <Inventor/elements/SoLazyElement.h>
|
||||
# include <Inventor/elements/SoViewportRegionElement.h>
|
||||
# include <Inventor/elements/SoViewVolumeElement.h>
|
||||
# include <Inventor/elements/SoModelMatrixElement.h>
|
||||
# include <Inventor/nodes/SoBaseColor.h>
|
||||
# include <Inventor/nodes/SoShape.h>
|
||||
# include <Inventor/nodes/SoScale.h>
|
||||
# include <Inventor/nodes/SoCone.h>
|
||||
# include <Inventor/nodes/SoCoordinate3.h>
|
||||
# include <Inventor/nodes/SoCube.h>
|
||||
# include <Inventor/nodes/SoFontStyle.h>
|
||||
# include <Inventor/nodes/SoLineSet.h>
|
||||
# include <Inventor/nodes/SoSeparator.h>
|
||||
# include <Inventor/nodes/SoText2.h>
|
||||
# include <Inventor/nodes/SoTranslation.h>
|
||||
# include <Inventor/nodekits/SoShapeKit.h>
|
||||
# include <Inventor/elements/SoViewportRegionElement.h>
|
||||
# include <Inventor/elements/SoViewVolumeElement.h>
|
||||
# include <Inventor/elements/SoModelMatrixElement.h>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -217,3 +231,129 @@ SoAxisCrossKit::createAxes()
|
||||
set("zAxis.pickStyle", "style UNPICKABLE");
|
||||
set("zHead.pickStyle", "style UNPICKABLE");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
SO_NODE_SOURCE(SoRegPoint);
|
||||
|
||||
void SoRegPoint::initClass()
|
||||
{
|
||||
SO_NODE_INIT_CLASS(SoRegPoint, SoShape, "Shape");
|
||||
}
|
||||
|
||||
SoRegPoint::SoRegPoint()
|
||||
{
|
||||
SO_NODE_CONSTRUCTOR(SoRegPoint);
|
||||
|
||||
SO_NODE_ADD_FIELD(base, (SbVec3f(0,0,0)));
|
||||
SO_NODE_ADD_FIELD(normal, (SbVec3f(1,1,1)));
|
||||
SO_NODE_ADD_FIELD(length, (3.0));
|
||||
SO_NODE_ADD_FIELD(color, (1.0f, 0.447059f, 0.337255f));
|
||||
SO_NODE_ADD_FIELD(text, (""));
|
||||
|
||||
root = new SoSeparator();
|
||||
root->ref();
|
||||
|
||||
// translation
|
||||
SoTranslation* move = new SoTranslation();
|
||||
move->translation.setValue(base.getValue() + normal.getValue() * length.getValue());
|
||||
root->addChild(move);
|
||||
|
||||
// sub-group
|
||||
SoBaseColor* col = new SoBaseColor();
|
||||
col->rgb.setValue(this->color.getValue());
|
||||
|
||||
SoFontStyle* font = new SoFontStyle;
|
||||
font->size = 14;
|
||||
|
||||
SoSeparator* sub = new SoSeparator();
|
||||
sub->addChild(col);
|
||||
sub->addChild(font);
|
||||
sub->addChild(new SoText2());
|
||||
root->addChild(sub);
|
||||
}
|
||||
|
||||
SoRegPoint::~SoRegPoint()
|
||||
{
|
||||
root->unref();
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the probe with text label and a bullet at the base point.
|
||||
*/
|
||||
void SoRegPoint::GLRender(SoGLRenderAction *action)
|
||||
{
|
||||
if (shouldGLRender(action))
|
||||
{
|
||||
SoState* state = action->getState();
|
||||
state->push();
|
||||
SoMaterialBundle mb(action);
|
||||
SoTextureCoordinateBundle tb(action, TRUE, FALSE);
|
||||
SoLazyElement::setLightModel(state, SoLazyElement::BASE_COLOR);
|
||||
mb.sendFirst(); // make sure we have the correct material
|
||||
|
||||
SbVec3f p1 = base.getValue();
|
||||
SbVec3f p2 = p1 + normal.getValue() * length.getValue();
|
||||
|
||||
glLineWidth(1.0f);
|
||||
glColor3fv(color.getValue().getValue());
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex3d(p1[0], p1[1], p1[2]);
|
||||
glVertex3d(p2[0], p2[1], p2[2]);
|
||||
glEnd();
|
||||
glPointSize(5.0f);
|
||||
glBegin(GL_POINTS);
|
||||
glVertex3fv(p1.getValue());
|
||||
glEnd();
|
||||
glPointSize(2.0f);
|
||||
glBegin(GL_POINTS);
|
||||
glVertex3fv(p2.getValue());
|
||||
glEnd();
|
||||
|
||||
root->GLRender(action);
|
||||
state->pop();
|
||||
}
|
||||
}
|
||||
|
||||
void SoRegPoint::generatePrimitives(SoAction* action)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the bounding box of the probe to \a box and its center to \a center.
|
||||
*/
|
||||
void SoRegPoint::computeBBox(SoAction *action, SbBox3f &box, SbVec3f ¢er)
|
||||
{
|
||||
root->doAction(action);
|
||||
if (action->getTypeId().isDerivedFrom(SoGetBoundingBoxAction::getClassTypeId()))
|
||||
static_cast<SoGetBoundingBoxAction*>(action)->resetCenter();
|
||||
|
||||
SbVec3f p1 = base.getValue();
|
||||
SbVec3f p2 = p1 + normal.getValue() * length.getValue();
|
||||
|
||||
box.extendBy(p1);
|
||||
box.extendBy(p2);
|
||||
|
||||
center = box.getCenter();
|
||||
}
|
||||
|
||||
void SoRegPoint::notify(SoNotList * node)
|
||||
{
|
||||
SoField * f = node->getLastField();
|
||||
if (f == &this->base || f == &this->normal || f == &this->length) {
|
||||
SoTranslation* move = static_cast<SoTranslation*>(root->getChild(0));
|
||||
move->translation.setValue(base.getValue() + normal.getValue() * length.getValue());
|
||||
}
|
||||
else if (f == &this->color) {
|
||||
SoSeparator* sub = static_cast<SoSeparator*>(root->getChild(1));
|
||||
SoBaseColor* col = static_cast<SoBaseColor*>(sub->getChild(0));
|
||||
col->rgb = this->color.getValue();
|
||||
}
|
||||
else if (f == &this->text) {
|
||||
SoSeparator* sub = static_cast<SoSeparator*>(root->getChild(1));
|
||||
SoText2* label = static_cast<SoText2*>(sub->getChild(2));
|
||||
label->string = this->text.getValue();
|
||||
}
|
||||
|
||||
SoShape::notify(node);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#include <Inventor/nodekits/SoSubKit.h>
|
||||
#include <Inventor/nodekits/SoBaseKit.h>
|
||||
#include <Inventor/fields/SoSFFloat.h>
|
||||
#include <Inventor/fields/SoSFColor.h>
|
||||
#include <Inventor/fields/SoSFString.h>
|
||||
|
||||
class SbViewport;
|
||||
class SoState;
|
||||
@@ -84,6 +86,33 @@ private:
|
||||
virtual ~SoAxisCrossKit();
|
||||
};
|
||||
|
||||
class GuiExport SoRegPoint : public SoShape {
|
||||
typedef SoShape inherited;
|
||||
|
||||
SO_NODE_HEADER(SoRegPoint);
|
||||
|
||||
public:
|
||||
static void initClass();
|
||||
SoRegPoint();
|
||||
|
||||
void notify(SoNotList * node);
|
||||
|
||||
SoSFVec3f base;
|
||||
SoSFVec3f normal;
|
||||
SoSFFloat length;
|
||||
SoSFColor color;
|
||||
SoSFString text;
|
||||
|
||||
protected:
|
||||
virtual ~SoRegPoint();
|
||||
virtual void GLRender(SoGLRenderAction *action);
|
||||
virtual void computeBBox(SoAction *action, SbBox3f &box, SbVec3f ¢er);
|
||||
virtual void generatePrimitives(SoAction *action);
|
||||
|
||||
private:
|
||||
SoSeparator* root;
|
||||
};
|
||||
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_SOSHAPESCALE_H
|
||||
|
||||
@@ -95,6 +95,7 @@ void Gui::SoFCDB::init()
|
||||
TranslateManip ::initClass();
|
||||
SoShapeScale ::initClass();
|
||||
SoAxisCrossKit ::initClass();
|
||||
SoRegPoint ::initClass();
|
||||
SoDrawingGrid ::initClass();
|
||||
|
||||
PropertyItem ::init();
|
||||
|
||||
@@ -41,42 +41,29 @@
|
||||
|
||||
using namespace Gui;
|
||||
|
||||
TYPESYSTEM_SOURCE_ABSTRACT(Gui::SplitView3DInventor,Gui::MDIView);
|
||||
TYPESYSTEM_SOURCE_ABSTRACT(Gui::AbstractSplitView,Gui::MDIView);
|
||||
|
||||
SplitView3DInventor::SplitView3DInventor(int views, Gui::Document* pcDocument, QWidget* parent, Qt::WFlags wflags)
|
||||
AbstractSplitView::AbstractSplitView(Gui::Document* pcDocument, QWidget* parent, Qt::WFlags wflags)
|
||||
: MDIView(pcDocument,parent, wflags)
|
||||
{
|
||||
// important for highlighting
|
||||
setMouseTracking(true);
|
||||
|
||||
}
|
||||
|
||||
AbstractSplitView::~AbstractSplitView()
|
||||
{
|
||||
hGrp->Detach(this);
|
||||
for (std::vector<View3DInventorViewer*>::iterator it = _viewer.begin(); it != _viewer.end(); ++it) {
|
||||
delete *it;
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractSplitView::setupSettings()
|
||||
{
|
||||
// attach Parameter Observer
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
|
||||
hGrp->Attach(this);
|
||||
|
||||
QSplitter* mainSplitter=0;
|
||||
|
||||
if (views <= 3) {
|
||||
mainSplitter = new QSplitter(Qt::Horizontal, this);
|
||||
_viewer.push_back(new View3DInventorViewer(mainSplitter));
|
||||
_viewer.push_back(new View3DInventorViewer(mainSplitter));
|
||||
if (views==3)
|
||||
_viewer.push_back(new View3DInventorViewer(mainSplitter));
|
||||
}
|
||||
else {
|
||||
mainSplitter = new QSplitter(Qt::Vertical, this);
|
||||
QSplitter *topSplitter = new QSplitter(Qt::Horizontal, mainSplitter);
|
||||
QSplitter *botSplitter = new QSplitter(Qt::Horizontal, mainSplitter);
|
||||
_viewer.push_back(new View3DInventorViewer(topSplitter));
|
||||
_viewer.push_back(new View3DInventorViewer(topSplitter));
|
||||
for (int i=2;i<views;i++)
|
||||
_viewer.push_back(new View3DInventorViewer(botSplitter));
|
||||
topSplitter->setOpaqueResize( true );
|
||||
botSplitter->setOpaqueResize( true );
|
||||
}
|
||||
|
||||
mainSplitter->show();
|
||||
setCentralWidget(mainSplitter);
|
||||
|
||||
// apply the user settings
|
||||
OnChange(*hGrp,"EyeDistance");
|
||||
OnChange(*hGrp,"CornerCoordSystem");
|
||||
@@ -100,21 +87,13 @@ SplitView3DInventor::SplitView3DInventor(int views, Gui::Document* pcDocument, Q
|
||||
OnChange(*hGrp,"NavigationStyle");
|
||||
}
|
||||
|
||||
SplitView3DInventor::~SplitView3DInventor()
|
||||
{
|
||||
hGrp->Detach(this);
|
||||
for (std::vector<View3DInventorViewer*>::iterator it = _viewer.begin(); it != _viewer.end(); ++it) {
|
||||
delete *it;
|
||||
}
|
||||
}
|
||||
|
||||
View3DInventorViewer* SplitView3DInventor::getViewer(unsigned int n) const
|
||||
View3DInventorViewer* AbstractSplitView::getViewer(unsigned int n) const
|
||||
{
|
||||
return (_viewer.size() > n ? _viewer[n] : 0);
|
||||
}
|
||||
|
||||
/// Observer message from the ParameterGrp
|
||||
void SplitView3DInventor::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::MessageType Reason)
|
||||
void AbstractSplitView::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::MessageType Reason)
|
||||
{
|
||||
const ParameterGrp& rGrp = static_cast<ParameterGrp&>(rCaller);
|
||||
if (strcmp(Reason,"HeadlightColor") == 0) {
|
||||
@@ -266,17 +245,17 @@ void SplitView3DInventor::OnChange(ParameterGrp::SubjectType &rCaller,ParameterG
|
||||
}
|
||||
}
|
||||
|
||||
void SplitView3DInventor::onUpdate(void)
|
||||
void AbstractSplitView::onUpdate(void)
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
const char *SplitView3DInventor::getName(void) const
|
||||
const char *AbstractSplitView::getName(void) const
|
||||
{
|
||||
return "SplitView3DInventor";
|
||||
}
|
||||
|
||||
bool SplitView3DInventor::onMsg(const char* pMsg, const char** ppReturn)
|
||||
bool AbstractSplitView::onMsg(const char* pMsg, const char** ppReturn)
|
||||
{
|
||||
if (strcmp("ViewFit",pMsg) == 0 ) {
|
||||
for (std::vector<View3DInventorViewer*>::iterator it = _viewer.begin(); it != _viewer.end(); ++it)
|
||||
@@ -346,7 +325,7 @@ bool SplitView3DInventor::onMsg(const char* pMsg, const char** ppReturn)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SplitView3DInventor::onHasMsg(const char* pMsg) const
|
||||
bool AbstractSplitView::onHasMsg(const char* pMsg) const
|
||||
{
|
||||
if (strcmp("ViewFit",pMsg) == 0) {
|
||||
return true;
|
||||
@@ -375,7 +354,46 @@ bool SplitView3DInventor::onHasMsg(const char* pMsg) const
|
||||
return false;
|
||||
}
|
||||
|
||||
void SplitView3DInventor::setCursor(const QCursor& aCursor)
|
||||
void AbstractSplitView::setCursor(const QCursor& aCursor)
|
||||
{
|
||||
//_viewer->getWidget()->setCursor(aCursor);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------
|
||||
|
||||
TYPESYSTEM_SOURCE_ABSTRACT(Gui::SplitView3DInventor, Gui::AbstractSplitView);
|
||||
|
||||
SplitView3DInventor::SplitView3DInventor(int views, Gui::Document* pcDocument, QWidget* parent, Qt::WFlags wflags)
|
||||
: AbstractSplitView(pcDocument,parent, wflags)
|
||||
{
|
||||
QSplitter* mainSplitter=0;
|
||||
|
||||
if (views <= 3) {
|
||||
mainSplitter = new QSplitter(Qt::Horizontal, this);
|
||||
_viewer.push_back(new View3DInventorViewer(mainSplitter));
|
||||
_viewer.push_back(new View3DInventorViewer(mainSplitter));
|
||||
if (views==3)
|
||||
_viewer.push_back(new View3DInventorViewer(mainSplitter));
|
||||
}
|
||||
else {
|
||||
mainSplitter = new QSplitter(Qt::Vertical, this);
|
||||
QSplitter *topSplitter = new QSplitter(Qt::Horizontal, mainSplitter);
|
||||
QSplitter *botSplitter = new QSplitter(Qt::Horizontal, mainSplitter);
|
||||
_viewer.push_back(new View3DInventorViewer(topSplitter));
|
||||
_viewer.push_back(new View3DInventorViewer(topSplitter));
|
||||
for (int i=2;i<views;i++)
|
||||
_viewer.push_back(new View3DInventorViewer(botSplitter));
|
||||
topSplitter->setOpaqueResize( true );
|
||||
botSplitter->setOpaqueResize( true );
|
||||
}
|
||||
|
||||
mainSplitter->show();
|
||||
setCentralWidget(mainSplitter);
|
||||
|
||||
// apply the user settings
|
||||
setupSettings();
|
||||
}
|
||||
|
||||
SplitView3DInventor::~SplitView3DInventor()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -36,13 +36,13 @@ class View3DInventorViewer;
|
||||
/** The SplitView3DInventor class allows to create a window with two or more Inventor views.
|
||||
* \author Werner Mayer
|
||||
*/
|
||||
class GuiExport SplitView3DInventor : public MDIView,public ParameterGrp::ObserverType
|
||||
class GuiExport AbstractSplitView : public MDIView, public ParameterGrp::ObserverType
|
||||
{
|
||||
TYPESYSTEM_HEADER();
|
||||
|
||||
public:
|
||||
SplitView3DInventor(int views, Gui::Document* pcDocument, QWidget* parent, Qt::WFlags wflags=0);
|
||||
~SplitView3DInventor();
|
||||
AbstractSplitView(Gui::Document* pcDocument, QWidget* parent, Qt::WFlags wflags=0);
|
||||
~AbstractSplitView();
|
||||
|
||||
virtual const char *getName(void) const;
|
||||
|
||||
@@ -56,14 +56,27 @@ public:
|
||||
|
||||
void setCursor(const QCursor&);
|
||||
|
||||
protected:
|
||||
void setupSettings();
|
||||
|
||||
protected:
|
||||
/// handle to the viewer parameter group
|
||||
ParameterGrp::handle hGrp;
|
||||
|
||||
private:
|
||||
std::vector<View3DInventorViewer*> _viewer;
|
||||
};
|
||||
|
||||
/** The SplitView3DInventor class allows to create a window with two or more Inventor views.
|
||||
* \author Werner Mayer
|
||||
*/
|
||||
class GuiExport SplitView3DInventor : public AbstractSplitView
|
||||
{
|
||||
TYPESYSTEM_HEADER();
|
||||
|
||||
public:
|
||||
SplitView3DInventor(int views, Gui::Document* pcDocument, QWidget* parent, Qt::WFlags wflags=0);
|
||||
~SplitView3DInventor();
|
||||
};
|
||||
|
||||
} // namespace Gui
|
||||
|
||||
#endif //GUI_SPLITVIEW3DINVENTOR_H
|
||||
|
||||
@@ -441,7 +441,8 @@ MenuItem* StdWorkbench::setupMenuBar() const
|
||||
edit->setCommand("&Edit");
|
||||
*edit << "Std_Undo" << "Std_Redo" << "Separator" << "Std_Cut" << "Std_Copy"
|
||||
<< "Std_Paste" << "Std_DuplicateSelection" << "Separator"
|
||||
<< "Std_Refresh" << "Std_SelectAll" << "Std_Delete" << "Std_Placement"
|
||||
<< "Std_Refresh" << "Std_SelectAll" << "Std_Delete"
|
||||
<< "Std_Placement" << "Std_Alignment"
|
||||
<< "Std_Edit" << "Separator" << "Std_DlgPreferences";
|
||||
|
||||
// Standard views
|
||||
|
||||
@@ -132,7 +132,8 @@ Gui::MenuItem* Workbench::setupMenuBar() const
|
||||
edit->setCommand("&Edit");
|
||||
*edit << "Std_Undo" << "Std_Redo" << "Separator" << "Std_Cut" << "Std_Copy"
|
||||
<< "Std_Paste" << "Std_DuplicateSelection" << "Separator"
|
||||
<< "Std_Refresh" << "Std_SelectAll" << "Std_Delete" << "Std_Placement"
|
||||
<< "Std_Refresh" << "Std_SelectAll" << "Std_Delete"
|
||||
<< "Std_Placement" << "Std_Alignment"
|
||||
<< "Separator" << "Std_DlgPreferences";
|
||||
|
||||
// Standard views
|
||||
|
||||
Reference in New Issue
Block a user