implemented
This commit is contained in:
committed by
Yorik van Havre
parent
795bd01f31
commit
3b8176535b
@@ -296,6 +296,7 @@ int ActionGroup::checkedAction() const
|
||||
void ActionGroup::setCheckedAction(int i)
|
||||
{
|
||||
_group->actions()[i]->setChecked(true);
|
||||
this->setIcon(_group->actions()[i]->icon());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
# include <QFile>
|
||||
# include <QMessageBox>
|
||||
# include <QTextStream>
|
||||
# include <boost/bind.hpp>
|
||||
#endif
|
||||
|
||||
#include "Command.h"
|
||||
@@ -524,7 +525,22 @@ bool StdCmdToggleClipPlane::isActive(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
DEF_STD_CMD_ACL(StdCmdDrawStyle);
|
||||
//===========================================================================
|
||||
// StdCmdDrawStyle
|
||||
//===========================================================================
|
||||
class StdCmdDrawStyle : public Gui::Command
|
||||
{
|
||||
public:
|
||||
StdCmdDrawStyle();
|
||||
virtual ~StdCmdDrawStyle(){}
|
||||
virtual void languageChange();
|
||||
virtual const char* className() const {return "StdCmdDrawStyle";}
|
||||
void updateIcon(const Gui::MDIView* view);
|
||||
protected:
|
||||
virtual void activated(int iMsg);
|
||||
virtual bool isActive(void);
|
||||
virtual Gui::Action * createAction(void);
|
||||
};
|
||||
|
||||
StdCmdDrawStyle::StdCmdDrawStyle()
|
||||
: Command("Std_DrawStyle")
|
||||
@@ -534,6 +550,8 @@ StdCmdDrawStyle::StdCmdDrawStyle()
|
||||
sToolTipText = QT_TR_NOOP("Draw style");
|
||||
sStatusTip = QT_TR_NOOP("Draw style");
|
||||
eType = Alter3DView;
|
||||
|
||||
this->getGuiApplication()->signalActivateView.connect(boost::bind(&StdCmdDrawStyle::updateIcon, this, _1));
|
||||
}
|
||||
|
||||
Gui::Action * StdCmdDrawStyle::createAction(void)
|
||||
@@ -542,8 +560,17 @@ Gui::Action * StdCmdDrawStyle::createAction(void)
|
||||
pcAction->setDropDownMenu(true);
|
||||
applyCommandData(pcAction);
|
||||
|
||||
pcAction->addAction(QString());
|
||||
pcAction->addAction(QString());
|
||||
QAction* a0 = pcAction->addAction(QString());
|
||||
a0->setCheckable(true);
|
||||
QAction* a1 = pcAction->addAction(QString());
|
||||
a1->setCheckable(true);
|
||||
QAction* a2 = pcAction->addAction(QString());
|
||||
a2->setCheckable(true);
|
||||
QAction* a3 = pcAction->addAction(QString());
|
||||
a3->setCheckable(true);
|
||||
QAction* a4 = pcAction->addAction(QString());
|
||||
a4->setCheckable(true);
|
||||
|
||||
_pcAction = pcAction;
|
||||
languageChange();
|
||||
return pcAction;
|
||||
@@ -566,23 +593,106 @@ void StdCmdDrawStyle::languageChange()
|
||||
QCoreApplication::CodecForTr));
|
||||
|
||||
a[1]->setText(QCoreApplication::translate(
|
||||
"Std_DrawStyle", "Wireframe", 0,
|
||||
"Std_DrawStyle", "Flat lines", 0,
|
||||
QCoreApplication::CodecForTr));
|
||||
a[1]->setToolTip(QCoreApplication::translate(
|
||||
"Std_DrawStyle", "Flat lines mode", 0,
|
||||
QCoreApplication::CodecForTr));
|
||||
|
||||
a[2]->setText(QCoreApplication::translate(
|
||||
"Std_DrawStyle", "Shaded", 0,
|
||||
QCoreApplication::CodecForTr));
|
||||
a[2]->setToolTip(QCoreApplication::translate(
|
||||
"Std_DrawStyle", "Shaded mode", 0,
|
||||
QCoreApplication::CodecForTr));
|
||||
|
||||
a[3]->setText(QCoreApplication::translate(
|
||||
"Std_DrawStyle", "Wireframe", 0,
|
||||
QCoreApplication::CodecForTr));
|
||||
a[3]->setToolTip(QCoreApplication::translate(
|
||||
"Std_DrawStyle", "Wireframe mode", 0,
|
||||
QCoreApplication::CodecForTr));
|
||||
|
||||
a[4]->setText(QCoreApplication::translate(
|
||||
"Std_DrawStyle", "Points", 0,
|
||||
QCoreApplication::CodecForTr));
|
||||
a[4]->setToolTip(QCoreApplication::translate(
|
||||
"Std_DrawStyle", "Points mode", 0,
|
||||
QCoreApplication::CodecForTr));
|
||||
}
|
||||
|
||||
void StdCmdDrawStyle::updateIcon(const MDIView *view)
|
||||
{
|
||||
const Gui::View3DInventor *view3d = dynamic_cast<const Gui::View3DInventor *>(view);
|
||||
if (!view3d)
|
||||
return;
|
||||
Gui::View3DInventorViewer *viewer = view3d->getViewer();
|
||||
if (!viewer)
|
||||
return;
|
||||
std::string mode(viewer->getOverrideMode());
|
||||
Gui::ActionGroup *actionGroup = dynamic_cast<Gui::ActionGroup *>(_pcAction);
|
||||
if (!actionGroup)
|
||||
return;
|
||||
|
||||
if (mode == "Flat Lines")
|
||||
{
|
||||
actionGroup->setCheckedAction(1);
|
||||
return;
|
||||
}
|
||||
if (mode == "Shaded")
|
||||
{
|
||||
actionGroup->setCheckedAction(2);
|
||||
return;
|
||||
}
|
||||
if (mode == "Wireframe")
|
||||
{
|
||||
actionGroup->setCheckedAction(3);
|
||||
return;
|
||||
}
|
||||
if (mode == "Point")
|
||||
{
|
||||
actionGroup->setCheckedAction(4);
|
||||
return;
|
||||
}
|
||||
actionGroup->setCheckedAction(0);
|
||||
}
|
||||
|
||||
void StdCmdDrawStyle::activated(int iMsg)
|
||||
{
|
||||
View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
|
||||
if (view) {
|
||||
SoQtViewer::DrawStyle style = SoQtViewer::VIEW_AS_IS;
|
||||
if (iMsg == 0)
|
||||
style = SoQtViewer::VIEW_AS_IS;
|
||||
else if (iMsg == 1)
|
||||
style = SoQtViewer::VIEW_LINE;
|
||||
view->getViewer()->setDrawStyle(SoQtViewer::STILL, style);
|
||||
Gui::Document *doc = this->getActiveGuiDocument();
|
||||
std::list<MDIView*> views = doc->getMDIViews();
|
||||
std::list<MDIView*>::iterator viewIt;
|
||||
bool oneChangedSignal(false);
|
||||
for (viewIt = views.begin(); viewIt != views.end(); viewIt++)
|
||||
{
|
||||
View3DInventor* view = qobject_cast<View3DInventor*>(*viewIt);
|
||||
if (view)
|
||||
{
|
||||
View3DInventorViewer* viewer;
|
||||
viewer = view->getViewer();
|
||||
if (viewer)
|
||||
{
|
||||
switch (iMsg)
|
||||
{
|
||||
case 1:
|
||||
(oneChangedSignal) ? viewer->updateOverrideMode("Flat Lines") : viewer->setOverrideMode("Flat Lines");
|
||||
break;
|
||||
case 2:
|
||||
(oneChangedSignal) ? viewer->updateOverrideMode("Shaded") : viewer->setOverrideMode("Shaded");
|
||||
break;
|
||||
case 3:
|
||||
(oneChangedSignal) ? viewer->updateOverrideMode("Wireframe") : viewer->setOverrideMode("Wireframe");
|
||||
break;
|
||||
case 4:
|
||||
(oneChangedSignal) ? viewer->updateOverrideMode("Point") : viewer->setOverrideMode("Point");
|
||||
break;
|
||||
default:
|
||||
(oneChangedSignal) ? viewer->updateOverrideMode("As Is") : viewer->setOverrideMode("As Is");
|
||||
break;
|
||||
}
|
||||
oneChangedSignal = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -893,6 +893,19 @@ void Document::createView(const char* sType)
|
||||
{
|
||||
View3DInventor* view3D = new View3DInventor(this, getMainWindow());
|
||||
|
||||
//get first view override mode and copy
|
||||
std::list<MDIView*> theViews = this->getMDIViews();
|
||||
std::list<MDIView*>::iterator viewIt;
|
||||
for (viewIt = theViews.begin(); viewIt != theViews.end(); ++viewIt)
|
||||
{
|
||||
View3DInventor *tempView = dynamic_cast<View3DInventor *>(*viewIt);
|
||||
if (!tempView)
|
||||
continue;
|
||||
std::string overrideMode = tempView->getViewer()->getOverrideMode();
|
||||
view3D->getViewer()->setOverrideMode(overrideMode);
|
||||
break;
|
||||
}
|
||||
|
||||
// attach the viewprovider
|
||||
std::map<const App::DocumentObject*,ViewProviderDocumentObject*>::const_iterator It1;
|
||||
for (It1=d->_ViewProviderMap.begin();It1!=d->_ViewProviderMap.end();++It1)
|
||||
|
||||
@@ -141,9 +141,9 @@ SOQT_OBJECT_ABSTRACT_SOURCE(View3DInventorViewer);
|
||||
// *************************************************************************
|
||||
|
||||
View3DInventorViewer::View3DInventorViewer (QWidget *parent, const char *name,
|
||||
SbBool embed, Type type, SbBool build)
|
||||
: inherited (parent, name, embed, type, build), editViewProvider(0), navigation(0),
|
||||
framebuffer(0), editing(FALSE), redirected(FALSE), allowredir(FALSE),axisCross(0),axisGroup(0)
|
||||
SbBool embed, Type type, SbBool build)
|
||||
: inherited (parent, name, embed, type, build), editViewProvider(0),navigation(0),
|
||||
editing(FALSE), redirected(FALSE), overrideMode("As Is")
|
||||
{
|
||||
Gui::Selection().Attach(this);
|
||||
|
||||
@@ -360,6 +360,7 @@ void View3DInventorViewer::addViewProvider(ViewProvider* pcProvider)
|
||||
SoSeparator* back = pcProvider->getBackRoot ();
|
||||
if (back) backgroundroot->addChild(back);
|
||||
|
||||
pcProvider->setOverrideMode(this->getOverrideMode());
|
||||
_ViewProviderSet.insert(pcProvider);
|
||||
}
|
||||
|
||||
@@ -412,6 +413,24 @@ SbBool View3DInventorViewer::isEditingViewProvider() const
|
||||
return this->editViewProvider ? true : false;
|
||||
}
|
||||
|
||||
/// display override mode
|
||||
void View3DInventorViewer::setOverrideMode(const std::string &mode)
|
||||
{
|
||||
if (mode == overrideMode)
|
||||
return;
|
||||
overrideMode = mode;
|
||||
for (std::set<ViewProvider*>::iterator it = _ViewProviderSet.begin(); it != _ViewProviderSet.end(); ++it)
|
||||
(*it)->setOverrideMode(mode);
|
||||
}
|
||||
|
||||
/// update override mode. doesn't affect providers
|
||||
void View3DInventorViewer::updateOverrideMode(const std::string &mode)
|
||||
{
|
||||
if (mode == overrideMode)
|
||||
return;
|
||||
overrideMode = mode;
|
||||
}
|
||||
|
||||
void View3DInventorViewer::clearBuffer(void * userdata, SoAction * action)
|
||||
{
|
||||
if (action->isOfType(SoGLRenderAction::getClassTypeId())) {
|
||||
|
||||
@@ -159,6 +159,10 @@ public:
|
||||
SbBool isEditingViewProvider() const;
|
||||
/// reset from edit mode
|
||||
void resetEditingViewProvider();
|
||||
/// display override mode
|
||||
void setOverrideMode(const std::string &mode);
|
||||
void updateOverrideMode(const std::string &mode);
|
||||
std::string getOverrideMode() {return overrideMode;}
|
||||
//@}
|
||||
|
||||
/** @name Making pictures */
|
||||
@@ -359,6 +363,15 @@ private:
|
||||
SbBool redirected;
|
||||
SbBool allowredir;
|
||||
|
||||
void setCursorRepresentation(int mode);
|
||||
|
||||
public:
|
||||
void addFlag(Flag*, FlagLayout::Position);
|
||||
|
||||
private:
|
||||
QPointer<FlagLayout> _flaglayout;
|
||||
std::string overrideMode;
|
||||
|
||||
// friends
|
||||
friend class NavigationStyle;
|
||||
friend class GLPainter;
|
||||
|
||||
@@ -61,7 +61,7 @@ using namespace Gui;
|
||||
PROPERTY_SOURCE_ABSTRACT(Gui::ViewProvider, App::PropertyContainer)
|
||||
|
||||
ViewProvider::ViewProvider()
|
||||
: pcAnnotation(0), pyViewObject(0), _iActualMode(-1), _iEditMode(-1), _updateData(true)
|
||||
: pcAnnotation(0), pyViewObject(0), _iActualMode(-1), _iEditMode(-1), _updateData(true), viewOverrideMode(-1)
|
||||
{
|
||||
pcRoot = new SoSeparator();
|
||||
pcRoot->ref();
|
||||
@@ -261,10 +261,10 @@ void ViewProvider::setDisplayMaskMode( const char* type )
|
||||
{
|
||||
std::map<std::string, int>::const_iterator it = _sDisplayMaskModes.find( type );
|
||||
if (it != _sDisplayMaskModes.end())
|
||||
pcModeSwitch->whichChild = it->second;
|
||||
_iActualMode = it->second;
|
||||
else
|
||||
pcModeSwitch->whichChild = -1;
|
||||
_iActualMode = pcModeSwitch->whichChild.getValue();
|
||||
_iActualMode = -1;
|
||||
setModeSwitch();
|
||||
}
|
||||
|
||||
std::vector<std::string> ViewProvider::getDisplayMaskModes() const
|
||||
@@ -298,7 +298,7 @@ void ViewProvider::hide(void)
|
||||
|
||||
void ViewProvider::show(void)
|
||||
{
|
||||
pcModeSwitch->whichChild = _iActualMode;
|
||||
setModeSwitch();
|
||||
}
|
||||
|
||||
bool ViewProvider::isShow(void) const
|
||||
@@ -316,6 +316,29 @@ bool ViewProvider::isVisible() const
|
||||
return isShow();
|
||||
}
|
||||
|
||||
void ViewProvider::setOverrideMode(const std::string &mode)
|
||||
{
|
||||
if (mode == "As Is")
|
||||
viewOverrideMode = -1;
|
||||
else {
|
||||
std::map<std::string, int>::const_iterator it = _sDisplayMaskModes.find(mode);
|
||||
if (it == _sDisplayMaskModes.end())
|
||||
return; //view style not supported
|
||||
viewOverrideMode = (*it).second;
|
||||
}
|
||||
if (pcModeSwitch->whichChild.getValue() != -1)
|
||||
setModeSwitch();
|
||||
}
|
||||
|
||||
void ViewProvider::setModeSwitch()
|
||||
{
|
||||
if (viewOverrideMode == -1)
|
||||
pcModeSwitch->whichChild = _iActualMode;
|
||||
else
|
||||
if (viewOverrideMode < pcModeSwitch->getNumChildren())
|
||||
pcModeSwitch->whichChild = viewOverrideMode;
|
||||
}
|
||||
|
||||
void ViewProvider::setDefaultMode(int val)
|
||||
{
|
||||
_iActualMode = val;
|
||||
|
||||
@@ -192,6 +192,8 @@ public:
|
||||
virtual bool isShow(void) const;
|
||||
void setVisible(bool);
|
||||
bool isVisible() const;
|
||||
/// Overrides the display mode with mode.
|
||||
void setOverrideMode(const std::string &mode);
|
||||
//@}
|
||||
|
||||
|
||||
@@ -307,8 +309,10 @@ protected:
|
||||
ViewProviderPy* pyViewObject;
|
||||
|
||||
private:
|
||||
void setModeSwitch();
|
||||
int _iActualMode;
|
||||
int _iEditMode;
|
||||
int viewOverrideMode;
|
||||
std::string _sCurrentMode;
|
||||
std::map<std::string, int> _sDisplayMaskModes;
|
||||
bool _updateData;
|
||||
|
||||
Reference in New Issue
Block a user