+ implement global draw styles

+ use double precision in XML file
+ fix crash with in SoBrepFaceSet

git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5083 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
wmayer 2011-11-01 13:52:38 +00:00
parent b2748ea427
commit a65d4fdda6
4 changed files with 100 additions and 22 deletions

View File

@ -177,6 +177,8 @@ ZipWriter::ZipWriter(const char* FileName)
//FIXME: Check whether this is correct
ZipStream.imbue(std::locale::classic());
#endif
ZipStream.precision(12);
ZipStream.setf(ios::fixed,ios::floatfield);
}
ZipWriter::ZipWriter(std::ostream& os)
@ -188,6 +190,8 @@ ZipWriter::ZipWriter(std::ostream& os)
//FIXME: Check whether this is correct
ZipStream.imbue(std::locale::classic());
#endif
ZipStream.precision(12);
ZipStream.setf(ios::fixed,ios::floatfield);
}
void ZipWriter::writeFiles(void)

View File

@ -502,6 +502,73 @@ bool StdCmdToggleClipPlane::isActive(void)
}
}
DEF_STD_CMD_ACL(StdCmdDrawStyle);
StdCmdDrawStyle::StdCmdDrawStyle()
: Command("Std_DrawStyle")
{
sGroup = QT_TR_NOOP("Standard-View");
sMenuText = QT_TR_NOOP("Draw style");
sToolTipText = QT_TR_NOOP("Draw style");
sStatusTip = QT_TR_NOOP("Draw style");
eType = Alter3DView;
}
Gui::Action * StdCmdDrawStyle::createAction(void)
{
Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow());
pcAction->setDropDownMenu(true);
applyCommandData(pcAction);
QAction* a0 = pcAction->addAction(QString());
QAction* a1 = pcAction->addAction(QString());
_pcAction = pcAction;
languageChange();
return pcAction;
}
void StdCmdDrawStyle::languageChange()
{
Command::languageChange();
if (!_pcAction)
return;
Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(_pcAction);
QList<QAction*> a = pcAction->actions();
a[0]->setText(QCoreApplication::translate(
"Std_DrawStyle", "As is", 0,
QCoreApplication::CodecForTr));
a[0]->setToolTip(QCoreApplication::translate(
"Std_DrawStyle", "Normal mode", 0,
QCoreApplication::CodecForTr));
a[1]->setText(QCoreApplication::translate(
"Std_DrawStyle", "Wireframe", 0,
QCoreApplication::CodecForTr));
a[1]->setToolTip(QCoreApplication::translate(
"Std_DrawStyle", "Wireframe mode", 0,
QCoreApplication::CodecForTr));
}
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);
}
}
bool StdCmdDrawStyle::isActive(void)
{
return Gui::Application::Instance->activeDocument();
}
//===========================================================================
// Std_ToggleVisibility
//===========================================================================
@ -1991,6 +2058,7 @@ void CreateViewStdCommands(void)
rcCmdMgr.addCommand(new StdOrthographicCamera());
rcCmdMgr.addCommand(new StdPerspectiveCamera());
rcCmdMgr.addCommand(new StdCmdToggleClipPlane());
rcCmdMgr.addCommand(new StdCmdDrawStyle());
rcCmdMgr.addCommand(new StdCmdFreezeViews());
rcCmdMgr.addCommand(new StdViewZoomIn());
rcCmdMgr.addCommand(new StdViewZoomOut());

View File

@ -166,7 +166,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
Gui::MenuItem* view = new Gui::MenuItem( menuBar );
view->setCommand("&View");
*view << "Std_ViewCreate" << "Std_OrthographicCamera" << "Std_PerspectiveCamera" << "Separator"
<< stdviews << "Std_FreezeViews" << "Separator" << view3d << zoom
<< stdviews << "Std_FreezeViews" << "Separator" << view3d << "Std_DrawStyle" << zoom
<< "Std_ViewDockUndockFullscreen" << "Std_AxisCross" << "Std_ToggleClipPlane"
<< "Std_TextureMapping" << "Separator" << visu
<< "Std_ToggleVisibility" << "Std_ToggleNavigation"

View File

@ -424,13 +424,15 @@ void SoBrepFaceSet::renderShape(const SoGLCoordinateElement * const vertexlist,
materials->send(*matindices++, TRUE);
}
if (nbind == PER_VERTEX || nbind == PER_FACE) {
currnormal = normals++;
glNormal3fv((const GLfloat*)currnormal);
}
else if (nbind == PER_VERTEX_INDEXED || nbind == PER_FACE_INDEXED) {
currnormal = &normals[*normalindices++];
glNormal3fv((const GLfloat*)currnormal);
if (normals) {
if (nbind == PER_VERTEX || nbind == PER_FACE) {
currnormal = normals++;
glNormal3fv((const GLfloat*)currnormal);
}
else if (nbind == PER_VERTEX_INDEXED || nbind == PER_FACE_INDEXED) {
currnormal = &normals[*normalindices++];
glNormal3fv((const GLfloat*)currnormal);
}
}
if (texture) {
@ -447,13 +449,15 @@ void SoBrepFaceSet::renderShape(const SoGLCoordinateElement * const vertexlist,
else if (mbind == PER_VERTEX_INDEXED)
materials->send(*matindices++, TRUE);
if (nbind == PER_VERTEX) {
currnormal = normals++;
glNormal3fv((const GLfloat*)currnormal);
}
else if (nbind == PER_VERTEX_INDEXED) {
currnormal = &normals[*normalindices++];
glNormal3fv((const GLfloat*)currnormal);
if (normals) {
if (nbind == PER_VERTEX) {
currnormal = normals++;
glNormal3fv((const GLfloat*)currnormal);
}
else if (nbind == PER_VERTEX_INDEXED) {
currnormal = &normals[*normalindices++];
glNormal3fv((const GLfloat*)currnormal);
}
}
if (texture) {
@ -470,13 +474,15 @@ void SoBrepFaceSet::renderShape(const SoGLCoordinateElement * const vertexlist,
else if (mbind == PER_VERTEX_INDEXED)
materials->send(*matindices++, TRUE);
if (nbind == PER_VERTEX) {
currnormal = normals++;
glNormal3fv((const GLfloat*)currnormal);
}
else if (nbind == PER_VERTEX_INDEXED) {
currnormal = &normals[*normalindices++];
glNormal3fv((const GLfloat*)currnormal);
if (normals) {
if (nbind == PER_VERTEX) {
currnormal = normals++;
glNormal3fv((const GLfloat*)currnormal);
}
else if (nbind == PER_VERTEX_INDEXED) {
currnormal = &normals[*normalindices++];
glNormal3fv((const GLfloat*)currnormal);
}
}
if (texture) {