From: asv Date: Fri, 17 Feb 2006 07:35:39 +0000 (+0000) Subject: Merge with OCC_development..a2 branch X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8b193abc8cc9004cfdd444a6e473d0f71931f725;p=modules%2Fgui.git Merge with OCC_development..a2 branch --- diff --git a/INSTALL b/INSTALL index dcef3b788..2f6965076 100644 --- a/INSTALL +++ b/INSTALL @@ -1,3 +1,3 @@ -This is the version 3.1.0 of SALOMEGUI +This is the version 3.2.0a1 of SALOMEGUI Compatible with : - - KERNEL 3.1.0 + - KERNEL 3.2.0a1 diff --git a/bin/VERSION b/bin/VERSION index fe6986e15..e7134d951 100755 --- a/bin/VERSION +++ b/bin/VERSION @@ -1 +1 @@ -THIS IS SALOME - SALOMEGUI VERSION: 3.1.0 +THIS IS SALOME - SALOMEGUI VERSION: 3.2.0a1 diff --git a/doc/salome/tui/SUIT/doxyfile b/doc/salome/tui/SUIT/doxyfile index 7d82b803d..bb5e49fb6 100755 --- a/doc/salome/tui/SUIT/doxyfile +++ b/doc/salome/tui/SUIT/doxyfile @@ -3,17 +3,17 @@ #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- -PROJECT_NAME = "SALOME v.3.1.0" +PROJECT_NAME = "SALOME v.3.2.0a1" PROJECT_NUMBER = id#1.1 OUTPUT_DIRECTORY = ../ CREATE_SUBDIRS = NO OUTPUT_LANGUAGE = English USE_WINDOWS_ENCODING = NO BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = NO +REPEAT_BRIEF = YES ABBREVIATE_BRIEF = -ALWAYS_DETAILED_SEC = YES -INLINE_INHERITED_MEMB = YES +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO FULL_PATH_NAMES = NO STRIP_FROM_PATH = STRIP_FROM_INC_PATH = @@ -21,7 +21,7 @@ SHORT_NAMES = NO JAVADOC_AUTOBRIEF = YES MULTILINE_CPP_IS_BRIEF = NO DETAILS_AT_TOP = NO -INHERIT_DOCS = YES +INHERIT_DOCS = NO DISTRIBUTE_GROUP_DOC = NO TAB_SIZE = 5 ALIASES = @@ -37,8 +37,8 @@ EXTRACT_PRIVATE = YES EXTRACT_STATIC = YES EXTRACT_LOCAL_CLASSES = YES EXTRACT_LOCAL_METHODS = NO -HIDE_UNDOC_MEMBERS = NO -HIDE_UNDOC_CLASSES = NO +HIDE_UNDOC_MEMBERS = YES +HIDE_UNDOC_CLASSES = YES HIDE_FRIEND_COMPOUNDS = NO HIDE_IN_BODY_DOCS = NO INTERNAL_DOCS = YES diff --git a/src/DDS/DDS_DicGroup.cxx b/src/DDS/DDS_DicGroup.cxx index ac7f4ad6b..6655e4fb7 100644 --- a/src/DDS/DDS_DicGroup.cxx +++ b/src/DDS/DDS_DicGroup.cxx @@ -76,7 +76,10 @@ void DDS_DicGroup::FillDataMap( const LDOM_Element& theComponentData, const LDOM LDOM_NodeList systemList = systems.getElementsByTagName( DDS_Dictionary::KeyWord( "UNIT_SYSTEM" ) ); for ( Standard_Integer i = 0; i < systemList.getLength(); i++ ) { - LDOM_Element aSystem = (const LDOM_Element &)systemList.item( i ); + //const LDOM_Element& aSystem = (const LDOM_Element &)systemList.item( i ); + LDOM_Node aNode = systemList.item( i ); + const LDOM_Element& anElem = (const LDOM_Element&) aNode; + LDOM_Element aSystem(anElem); TCollection_AsciiString aName = aSystem.getAttribute( DDS_Dictionary::KeyWord( "UNIT_SYSTEM_NAME" ) ); TCollection_ExtendedString aLabel = aSystem.getAttribute( DDS_Dictionary::KeyWord( "UNIT_SYSTEM_LABEL" ) ); @@ -103,7 +106,10 @@ void DDS_DicGroup::FillDataMap( const LDOM_Element& theComponentData, const LDOM for ( Standard_Integer i = 0; i < aData.getLength(); i++ ) { - LDOM_Element aQuantity = (const LDOM_Element&)aData.item( i ); + //LDOM_Element aQuantity = (const LDOM_Element&)aData.item( i ); + LDOM_Node aNode = aData.item( i ); + const LDOM_Element& anElem = (const LDOM_Element&) aNode; + LDOM_Element aQuantity(anElem); // 1. Attributes (id,label,units?,format?,required?) TCollection_AsciiString anID = aQuantity.getAttribute( DDS_Dictionary::KeyWord( "DATUM_ID" ) ); diff --git a/src/DDS/DDS_DicItem.cxx b/src/DDS/DDS_DicItem.cxx index 0c8b01c6d..d20408b4c 100644 --- a/src/DDS/DDS_DicItem.cxx +++ b/src/DDS/DDS_DicItem.cxx @@ -506,7 +506,10 @@ void DDS_DicItem::FillDataMap( TCollection_AsciiString theID, const LDOM_Element if ( aListValueID.IsIntegerValue() ) { // Read the text in the element "value" - LDOM_Text aListItemTxt = (const LDOM_Text&)aListItemValue.getFirstChild(); + //LDOM_Text aListItemTxt = (const LDOM_Text&)aListItemValue.getFirstChild(); + LDOM_Node aNode = aListItemValue.getFirstChild(); + const LDOM_Text& aText = (const LDOM_Text&) aNode; + LDOM_Text aListItemTxt(aText); if ( !aListItemTxt.isNull() ) { // adding ID and text value to sequence @@ -533,7 +536,10 @@ void DDS_DicItem::FillDataMap( TCollection_AsciiString theID, const LDOM_Element if ( !aShDescr.isNull() ) { // text is always a sub-node of element, containing it - LDOM_Text aShDescrTxt = (const LDOM_Text&)aShDescr.getFirstChild(); + //LDOM_Text aShDescrTxt = (const LDOM_Text&)aShDescr.getFirstChild(); + LDOM_Node aNode = aShDescr.getFirstChild(); + const LDOM_Text& aText = (const LDOM_Text&) aNode; + LDOM_Text aShDescrTxt(aText); if ( !aShDescrTxt.isNull() ) aShortD = aShDescrTxt.getData(); } @@ -543,7 +549,10 @@ void DDS_DicItem::FillDataMap( TCollection_AsciiString theID, const LDOM_Element if ( !aLDescr.isNull() ) { // text is always a sub-node of element, containing it - LDOM_Text aLDescrTxt = (const LDOM_Text&)aLDescr.getFirstChild(); + //LDOM_Text aLDescrTxt = (const LDOM_Text&)aLDescr.getFirstChild(); + LDOM_Node aNode = aLDescr.getFirstChild(); + const LDOM_Text& aText = (const LDOM_Text&) aNode; + LDOM_Text aLDescrTxt(aText); if ( !aLDescrTxt.isNull() ) aLongD = aLDescrTxt.getData(); } diff --git a/src/GLViewer/GLViewer_Drawer.cxx b/src/GLViewer/GLViewer_Drawer.cxx index 3ebadab54..9a0f3ef6b 100644 --- a/src/GLViewer/GLViewer_Drawer.cxx +++ b/src/GLViewer/GLViewer_Drawer.cxx @@ -39,15 +39,14 @@ #include #define TEXT_GAP 5 +// Two texture components for texmapped fonts: luminance and alpha +#define NB_TEX_COMP 2 +// A font is split into rows each containing 32 characters +#define TEX_ROW_LEN 32 +// Gap in pixels between two character rows in a font texture +#define TEX_ROW_GAP 2 -GLboolean TFLoaded = GL_FALSE; - -GLdouble modelMatrix[16], projMatrix[16]; -GLint viewport[4]; -GLdouble winx, winy, winz; -GLint status; - -GLViewer_TexFont* staticGlFont; +GLfloat modelMatrix[16]; //================================================================ // Class : GLViewer_TexFont @@ -77,24 +76,14 @@ void GLViewer_TexFont::clearTextBases() // Purpose : //======================================================================= GLViewer_TexFont::GLViewer_TexFont() +: myMaxRowWidth( 0 ), myFontHeight( 0 ) { myQFont = QFont::defaultFont(); - QFontMetrics aFM( myQFont ); - myWidths = new int[LastSymbolNumber - FirstSymbolNumber+1]; - myPositions = new int[LastSymbolNumber - FirstSymbolNumber+1]; mySeparator = 2; - for( int k = FirstSymbolNumber, aWidth = 0; k <= LastSymbolNumber; k++ ) - { - myWidths[ k - FirstSymbolNumber ] = aFM.width( k ); - myPositions[ k - FirstSymbolNumber ] = aWidth; - aWidth += myWidths[ k - FirstSymbolNumber ] + 2;//mySeparator; - } - - myTexFontWidth = 0; - myTexFontHeight = 0; myIsResizeable = false; - //myMinMagFilter = GL_NEAREST; - myMinMagFilter = GL_LINEAR_ATTENUATION ; + myMinMagFilter = GL_LINEAR; + + init(); } //====================================================================== @@ -102,24 +91,14 @@ GLViewer_TexFont::GLViewer_TexFont() // Purpose : //======================================================================= GLViewer_TexFont::GLViewer_TexFont( QFont* theFont, int theSeparator, bool theIsResizeable, GLuint theMinMagFilter ) +: myMaxRowWidth( 0 ), myFontHeight( 0 ) { myQFont = *theFont; - QFontMetrics aFM( myQFont ); - myWidths = new int[LastSymbolNumber - FirstSymbolNumber+1]; - myPositions = new int[LastSymbolNumber - FirstSymbolNumber+1]; mySeparator = theSeparator; - for( int k = FirstSymbolNumber, aWidth = 0; k <= LastSymbolNumber; k++ ) - { - myWidths[ k - FirstSymbolNumber ] = aFM.width( k ); - myPositions[ k - FirstSymbolNumber ] = aWidth; - aWidth += myWidths[ k - FirstSymbolNumber ] + 2;//mySeparator; - } - - myTexFontWidth = 0; - myTexFontHeight = 0; myIsResizeable = theIsResizeable; myMinMagFilter = theMinMagFilter; - + + init(); } //====================================================================== @@ -131,17 +110,56 @@ GLViewer_TexFont::~GLViewer_TexFont() delete[] myWidths; delete[] myPositions; } + +//====================================================================== +// Function: init +// Purpose : +//======================================================================= +void GLViewer_TexFont::init() +{ + myNbSymbols = LastSymbolNumber - FirstSymbolNumber + 1; + + // It is unsafe to draw all characters in a single row - + // this leads to problems on some graphic cards with small GL_MAX_TEXTURE_SIZE. + // So splitting the characters into rows each containing 32 characters (or less). + // Assuming contant height of each row (64 pixels) to simplify texture mapping. + // However, this can be improved if necessary. + QFontMetrics aFM( myQFont ); + myFontHeight = aFM.height(); + + myWidths = new int[myNbSymbols]; + myPositions = new int[myNbSymbols]; + + for( int i = 0, k = FirstSymbolNumber, aWidth = 0; i < myNbSymbols; i++, k++ ) + { + // is it time to start a new row? + if ( !( i % TEX_ROW_LEN ) ) + { + if( aWidth > myMaxRowWidth ) + myMaxRowWidth = aWidth; + aWidth = 0; + } + myWidths[i] = aFM.width( k ); + myPositions[i] = aWidth; + aWidth += myWidths[i] + 2; + } + + myTexFontWidth = 0; + myTexFontHeight = 0; +} //====================================================================== // Function: generateTexture // Purpose : //======================================================================= -void GLViewer_TexFont::generateTexture() +bool GLViewer_TexFont::generateTexture() { - QFontMetrics aFM( myQFont ); - GLViewer_TexFindId aFindFont; - aFindFont.myFontString = myQFont.toString(); + aFindFont.myFontFamily = myQFont.family();//myQFont.toString(); + aFindFont.myIsBold = myQFont.bold(); + aFindFont.myIsItal = myQFont.italic(); + aFindFont.myIsUndl = myQFont.underline(); + aFindFont.myPointSize = myQFont.pointSize(); aFindFont.myViewPortId = (int)QGLContext::currentContext(); if( TexFontBase.contains( aFindFont ) ) @@ -153,34 +171,51 @@ void GLViewer_TexFont::generateTexture() } else { - QString aStr; - int pixelsWidth = 0; - int pixelsHight = aFM.height(); - myTexFontWidth = 64; + // Adding some pixels to have a gap between rows + int aRowPixelHeight = myFontHeight + TEX_ROW_GAP; + int aDescent = QFontMetrics( myQFont ).descent(); + + int aNumRows = myNbSymbols / TEX_ROW_LEN; + if ( myNbSymbols % TEX_ROW_LEN ) + aNumRows++; + int pixelsHight = aNumRows * aRowPixelHeight; + + myTexFontWidth = 64; myTexFontHeight = 64; - - pixelsWidth = myWidths[LastSymbolNumber - FirstSymbolNumber] + - myPositions[LastSymbolNumber - FirstSymbolNumber]; - while( myTexFontWidth < pixelsWidth ) - myTexFontWidth = myTexFontWidth * 2; + while( myTexFontWidth < myMaxRowWidth ) + myTexFontWidth <<= 1; while( myTexFontHeight < pixelsHight ) - myTexFontHeight = myTexFontHeight * 2; + myTexFontHeight <<= 1; + + // Checking whether the texture dimensions for the requested font + // do not exceed the maximum size supported by the OpenGL implementation + int maxSize; + glGetIntegerv( GL_MAX_TEXTURE_SIZE, &maxSize ); + if ( myTexFontWidth > maxSize || myTexFontHeight > maxSize ) + return false; QPixmap aPixmap( myTexFontWidth, myTexFontHeight ); aPixmap.fill( QColor( 0, 0, 0) ); QPainter aPainter( &aPixmap ); aPainter.setFont( myQFont ); - for( int l = 0/*, gap = 0*/; l < LastSymbolNumber - FirstSymbolNumber; l++ ) + int row; + for( int l = 0; l < myNbSymbols; l++ ) { + row = l / TEX_ROW_LEN; QString aLetter; aLetter += (char)(FirstSymbolNumber + l); aPainter.setPen( QColor( 255,255,255) ); - aPainter.drawText ( myPositions[l], pixelsHight, aLetter ); + aPainter.drawText( myPositions[l], ( row + 1 ) * aRowPixelHeight - aDescent, aLetter ); } QImage aImage = aPixmap.convertToImage(); - char* pixels = new char[myTexFontWidth * myTexFontHeight * 2]; + + //int qqq = 0; + //if (qqq) + // aImage.save("w:\\work\\CATHARE\\texture.png", "PNG"); + + char* pixels = new char[myTexFontWidth * myTexFontHeight * NB_TEX_COMP]; for( int i = 0; i < myTexFontHeight; i++ ) { @@ -192,13 +227,13 @@ void GLViewer_TexFont::generateTexture() if( aRed != 0 || aGreen != 0 || aBlue != 0 ) { - pixels[i * myTexFontWidth * 2 + j * 2] = (GLubyte)( (aRed + aGreen + aBlue)/3 ); - pixels[i * myTexFontWidth * 2 + j * 2 + 1]= (GLubyte) 255; + pixels[i * myTexFontWidth * NB_TEX_COMP + j * NB_TEX_COMP] = (GLubyte)( (aRed + aGreen + aBlue)/3 ); + pixels[i * myTexFontWidth * NB_TEX_COMP + j * NB_TEX_COMP + 1]= (GLubyte) 255; } else { - pixels[i * myTexFontWidth * 2 + j * 2] = (GLubyte) 0; - pixels[i * myTexFontWidth * 2 + j * 2 + 1]= (GLubyte) 0; + pixels[i * myTexFontWidth * NB_TEX_COMP + j * NB_TEX_COMP] = (GLubyte) 0; + pixels[i * myTexFontWidth * NB_TEX_COMP + j * NB_TEX_COMP + 1]= (GLubyte) 0; } } } @@ -206,11 +241,8 @@ void GLViewer_TexFont::generateTexture() glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glGenTextures(1, &myTexFont); glBindTexture(GL_TEXTURE_2D, myTexFont); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, myMinMagFilter); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, myMinMagFilter); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glTexImage2D(GL_TEXTURE_2D, 0, GL_INTENSITY, @@ -230,33 +262,35 @@ void GLViewer_TexFont::generateTexture() TexFontBase.insert( aFindFont, aTexture ); } + return true; } //====================================================================== // Function: drawString // Purpose : //======================================================================= -void GLViewer_TexFont::drawString( QString theStr, GLdouble theX , GLdouble theY ) +void GLViewer_TexFont::drawString( QString theStr, GLdouble theX , GLdouble theY, GLfloat theScale ) { - double aXScale = 1., aYScale = 1.; - // store attributes - glPushAttrib( GL_ENABLE_BIT | GL_TEXTURE_BIT ); + // Adding some pixels to have a gap between rows + int aRowPixelHeight = myFontHeight + TEX_ROW_GAP; + float aXScale = 1.f, aYScale = 1.f; if ( !myIsResizeable ) { - glGetDoublev (GL_MODELVIEW_MATRIX, modelMatrix); + glGetFloatv (GL_MODELVIEW_MATRIX, modelMatrix); aXScale = modelMatrix[0]; - aYScale = modelMatrix[5]; + aYScale = modelMatrix[5]; + } + else if ( theScale > 0.f ) + { + aXScale = aXScale / theScale; + aYScale = aYScale / theScale; } - glEnable(GL_TEXTURE_2D); - - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, myMinMagFilter); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, myMinMagFilter); + // store attributes + glPushAttrib( GL_ENABLE_BIT | GL_TEXTURE_BIT ); + glEnable(GL_TEXTURE_2D); glPixelTransferi(GL_MAP_COLOR, 0); glAlphaFunc(GL_GEQUAL, 0.05F); @@ -266,27 +300,31 @@ void GLViewer_TexFont::drawString( QString theStr, GLdouble theX , GLdouble theY glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glBindTexture(GL_TEXTURE_2D, myTexFont); - glBegin(GL_QUADS); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - theY = theY - ( myTexFontHeight - QFontMetrics( myQFont ).height() ) / aYScale; + glBegin(GL_QUADS); - double aLettBegin, aLettEnd, aDY = ( myTexFontHeight - 1 ) / aYScale, aDX; + float aLettBeginS, aLettEndS, aLettBeginT, aLettEndT; + float aDY = ( aRowPixelHeight - 1 ) / aYScale, aDX; char aLetter; - int aLettIndex; + int aLettIndex, row; for( int i = 0; i < theStr.length(); i++ ) { aLetter = theStr.data()[i]; aLettIndex = (int)aLetter - FirstSymbolNumber; + row = aLettIndex / TEX_ROW_LEN; - aLettBegin = (double)myPositions[aLettIndex] / ( (double)myTexFontWidth - 1. ); - aLettEnd = aLettBegin + ( (double)myWidths[aLettIndex] - 1. ) / ( (double)myTexFontWidth - 1. ); + aLettBeginS = (float)myPositions[aLettIndex] / ( (float)myTexFontWidth - 1.f ); + aLettEndS = aLettBeginS + ( (float)myWidths[aLettIndex] - 1.f ) / ( (float)myTexFontWidth - 1.f ); + aLettBeginT = ( myTexFontHeight - ( row + 1 ) * aRowPixelHeight ) / ( (float)myTexFontHeight - 1.f ); + aLettEndT = aLettBeginT + ( (float)aRowPixelHeight - 1.f ) / ( (float)myTexFontHeight - 1.f ); - aDX = ( (double)myWidths[aLettIndex] - 1. ) / aXScale; + aDX = ( (float)myWidths[aLettIndex] - 1.f ) / aXScale; - glTexCoord2d( aLettBegin, 0.0 ); glVertex3d( theX, theY, 1.0 ); - glTexCoord2d( aLettBegin, 1.0 ); glVertex3d( theX, theY + aDY, 1.0 ); - glTexCoord2d( aLettEnd, 1.0 ); glVertex3d( theX + aDX, theY + aDY, 1.0 ); - glTexCoord2d( aLettEnd, 0.0 ); glVertex3d( theX + aDX, theY, 1.0 ); + glTexCoord2f( aLettBeginS, aLettBeginT ); glVertex3f( theX, theY, 1.f ); + glTexCoord2f( aLettBeginS, aLettEndT ); glVertex3f( theX, theY + aDY, 1.f ); + glTexCoord2f( aLettEndS, aLettEndT ); glVertex3f( theX + aDX, theY + aDY, 1.f ); + glTexCoord2f( aLettEndS, aLettBeginT ); glVertex3f( theX + aDX, theY, 1.f ); theX += aDX + mySeparator / aXScale; } @@ -326,10 +364,16 @@ int GLViewer_TexFont::getStringHeight() //! function for generation list base for bitmap fonts static GLuint displayListBase( QFont* theFont ) { + if ( !theFont ) + return 0; GLuint aList = 0; //static QMap fontCache; GLViewer_TexFindId aFindFont; - aFindFont.myFontString = theFont->toString(); + aFindFont.myFontFamily = theFont->family();//theFont->toString(); + aFindFont.myIsBold = theFont->bold(); + aFindFont.myIsItal = theFont->italic(); + aFindFont.myIsUndl = theFont->underline(); + aFindFont.myPointSize = theFont->pointSize(); #ifdef WIN32 HGLRC ctx = ::wglGetCurrentContext(); @@ -394,16 +438,17 @@ static GLuint displayListBase( QFont* theFont ) //glXUseXFont( (Font)(theFont->handle()), 0, 256, listBase ); int aFontCont = 0; - char** xFontList = XListFonts( aDisp, aFindFont.myFontString.data(), 1, &aFontCont ); + QString aFontDef = theFont->toString(); + char** xFontList = XListFonts( aDisp, aFontDef.latin1()/*aFindFont.myFontString.data()*/, 1, &aFontCont ); if( !theFont->handle() ) { #ifdef _DEBUG_ - printf( "Can't load font %s. loading default font....\n", aFindFont.myFontString.data() ); + printf( "Can't load font %s. loading default font....\n", aFontDef.latin1()/*aFindFont.myFontString.data()*/ ); #endif QString aFontMask ("-*-*-*-r-*-*-"); - aFontMask += aFindFont.myFontString.section( ',', 1, 1 ); + aFontMask += aFontDef/*aFindFont.myFontString*/.section( ',', 1, 1 ); #ifdef _DEBUG_ - printf( "Height of Default font: %s\n", aFindFont.myFontString.section( ',', 1, 1 ).data() ); + printf( "Height of Default font: %s\n", aFontDef/*aFindFont.myFontString*/.section( ',', 1, 1 ).data() ); #endif aFontMask += "-*-*-*-m-*-*-*"; xFontList = XListFonts( aDisp, aFontMask.data()/*"-*-*-*-r-*-*-12-*-*-*-m-*-*-*"*/, 1, &aFontCont ); @@ -447,6 +492,7 @@ GLViewer_Drawer::GLViewer_Drawer() myObjectType = "GLViewer_Object"; myPriority = 0; myTextFormat = DTF_BITMAP; + myTextScale = 0.125; } //====================================================================== @@ -718,8 +764,14 @@ void GLViewer_Drawer::drawText( const QString& text, GLfloat xPos, GLfloat yPos, if( theFormat != DTF_BITMAP ) { GLViewer_TexFont aTexFont( theFont, theSeparator, theFormat == DTF_TEXTURE_SCALABLE, GL_LINEAR ); - aTexFont.generateTexture(); - aTexFont.drawString( text, xPos, yPos ); + // Font texture was not found or generated --> cannot draw text + if ( !aTexFont.generateTexture() ) + return; + + if ( theFormat == DTF_TEXTURE_SCALABLE ) + aTexFont.drawString( text, xPos, yPos, textScale() ); + else + aTexFont.drawString( text, xPos, yPos ); } else { @@ -760,9 +812,11 @@ void GLViewer_Drawer::drawGLText( QString text, float x, float y, if( smallFont ) aFont.setPointSize( aFont.pointSize() * 0.8 ); + GLfloat scale = textScale() > 0. ? textScale() : 1.; + QFontMetrics aFontMetrics( aFont ); - float width = myTextFormat == DTF_TEXTURE_SCALABLE ? aFontMetrics.width( text ) : aFontMetrics.width( text ) / myXScale; - float height = myTextFormat == DTF_TEXTURE_SCALABLE ? aFontMetrics.height() : aFontMetrics.height() / myYScale; + float width = myTextFormat == DTF_TEXTURE_SCALABLE ? aFontMetrics.width( text ) * scale : aFontMetrics.width( text ) / myXScale; + float height = myTextFormat == DTF_TEXTURE_SCALABLE ? aFontMetrics.height() * scale : aFontMetrics.height() / myYScale; float gap = 5 / myXScale; switch( hPosition ) @@ -784,6 +838,21 @@ void GLViewer_Drawer::drawGLText( QString text, float x, float y, drawText( text, x, y, color, &aFont, 2, myTextFormat ); } +//====================================================================== +// Function: textRect +// Purpose : +//======================================================================= +GLViewer_Rect GLViewer_Drawer::textRect( const QString& text ) const +{ + GLfloat scale = textScale() > 0. ? textScale() : 1.; + + QFontMetrics aFontMetrics( myFont ); + float width = myTextFormat == DTF_TEXTURE_SCALABLE ? aFontMetrics.width( text ) * scale : aFontMetrics.width( text ); + float height = myTextFormat == DTF_TEXTURE_SCALABLE ? aFontMetrics.height() * scale : aFontMetrics.height(); + + return GLViewer_Rect( 0, width, height, 0 ); +} + //====================================================================== // Function: drawRectangle // Purpose : diff --git a/src/GLViewer/GLViewer_Drawer.h b/src/GLViewer/GLViewer_Drawer.h index d773d3bd2..4b66e7b20 100644 --- a/src/GLViewer/GLViewer_Drawer.h +++ b/src/GLViewer/GLViewer_Drawer.h @@ -68,15 +68,33 @@ struct GLVIEWER_API GLViewer_TexIdStored */ struct GLVIEWER_API GLViewer_TexFindId { - //! Font description - QString myFontString; + //! Font family description + QString myFontFamily; + //! Bold parameter + bool myIsBold; + //! Italic parameter + bool myIsItal; + //! Underline parameter + bool myIsUndl; + //! Font Size + int myPointSize; //! View POrt ID int myViewPortId; //! Overloaded operator for using struct as MAP key bool operator < (const GLViewer_TexFindId theStruct) const { - if ( myViewPortId != theStruct.myViewPortId ) return myViewPortId < theStruct.myViewPortId; - else return myFontString < theStruct.myFontString; + if ( myViewPortId != theStruct.myViewPortId ) + return myViewPortId < theStruct.myViewPortId; + else if ( myPointSize != theStruct.myPointSize ) + return myPointSize < theStruct.myPointSize; + else if ( myIsBold != theStruct.myIsBold ) + return myIsBold < theStruct.myIsBold; + else if ( myIsItal != theStruct.myIsItal ) + return myIsItal < theStruct.myIsItal; + else if ( myIsUndl != theStruct.myIsUndl ) + return myIsUndl < theStruct.myIsUndl; + else + return myFontFamily < theStruct.myFontFamily; } }; @@ -111,9 +129,12 @@ public: ~GLViewer_TexFont(); //! Generating font texture - void generateTexture(); + bool generateTexture(); //! Drawing string theStr in point with coords theX and theY - void drawString( QString theStr, GLdouble theX = 0.0, GLdouble theY = 0.0 ); + void drawString( QString theStr, + GLdouble theX = 0.0, + GLdouble theY = 0.0, + GLfloat theScale = 1.0 ); //! Returns separator between letters int getSeparator(){ return mySeparator; } @@ -132,8 +153,14 @@ public: static QMap TexFontBase; //! Map for strorage generated bitmaps fonts static QMap BitmapFontCache; + +private: + //! Initializes font parameters + void init(); -protected: +private: + //! Number of characters in the font texture + int myNbSymbols; //! Array of letter width int* myWidths; //! Array of letter positions in texture @@ -152,6 +179,10 @@ protected: bool myIsResizeable; //! Min/mag filter GLuint myMinMagFilter; + //! Font height + int myFontHeight; + //! Diagnostic information + int myMaxRowWidth; }; /*************************************************************************** @@ -360,11 +391,24 @@ public: /*! *\param format - the default text displaying format */ - inline void setTextFormat( DisplayTextFormat format ) { myTextFormat = format; } + inline void setTextFormat( const DisplayTextFormat format ) { myTextFormat = format; } //! Returns a default text displaying format used by drawGLText method inline DisplayTextFormat textFormat() const { return myTextFormat; } + //! Sets a text string displaying scale factor (used only with text format DTF_TEXTURE_SCALABLE) + /*! + *\param factor - scale factor + */ + inline void setTextScale( const GLfloat factor ) { myTextScale = factor; } + + //! Returns a text string displaying scale factor + inline GLfloat textScale() const { return myTextScale; } + + //! Returns a rectangle of text (without viewer scale) + GLViewer_Rect textRect( const QString& ) const; + + //! Draw rectangle with predefined color static void drawRectangle( GLViewer_Rect* theRect, QColor = Qt::black ); @@ -405,6 +449,10 @@ protected: QFont myFont; //! Default text displaying format for drawGLText() method DisplayTextFormat myTextFormat; + + //! Scale factor for text string draw, by default 0.125 + //! (used only with text format DTF_TEXTURE_SCALABLE) + GLfloat myTextScale; }; #ifdef WNT diff --git a/src/GLViewer/GLViewer_Object.cxx b/src/GLViewer/GLViewer_Object.cxx index d2aaf4e97..f5972674b 100644 --- a/src/GLViewer/GLViewer_Object.cxx +++ b/src/GLViewer/GLViewer_Object.cxx @@ -283,6 +283,9 @@ bool GLViewer_Object::initializeFromByteCopy( QByteArray theArray ) void GLViewer_Object::setGroup( GLViewer_Group* theGroup ) { + if ( myGroup == theGroup ) + return; + if( myGroup ) myGroup->removeObject( this ); diff --git a/src/GLViewer/GLViewer_Object.h b/src/GLViewer/GLViewer_Object.h index 39c9d9883..6cd21b294 100644 --- a/src/GLViewer/GLViewer_Object.h +++ b/src/GLViewer/GLViewer_Object.h @@ -185,7 +185,7 @@ public: virtual bool finishMove() { return true; } //! Returns visible object status - bool getVisible() const { return myIsVisible; } + virtual bool getVisible() const { return myIsVisible; } //! Installs visible object status virtual void setVisible( bool theStatus ) { myIsVisible = theStatus; } diff --git a/src/GLViewer/GLViewer_ViewPort.cxx b/src/GLViewer/GLViewer_ViewPort.cxx index 973342f84..78767afa1 100644 --- a/src/GLViewer/GLViewer_ViewPort.cxx +++ b/src/GLViewer/GLViewer_ViewPort.cxx @@ -31,7 +31,7 @@ //#include -#if !defined WNT +#if !(defined WNT) && !(defined QT_CLEAN_NAMESPACE) #define QT_CLEAN_NAMESPACE /* avoid definition of INT32 and INT8 */ #endif diff --git a/src/GLViewer/GLViewer_Viewer2d.cxx b/src/GLViewer/GLViewer_Viewer2d.cxx index c7a1d297d..f98f5e2ae 100644 --- a/src/GLViewer/GLViewer_Viewer2d.cxx +++ b/src/GLViewer/GLViewer_Viewer2d.cxx @@ -969,6 +969,8 @@ void GLViewer_Viewer2d::startOperations( QWheelEvent* e ) update = anObject->updateZoom( zoomIn ) || update; } + emit wheelZoomChange( zoomIn ); + if( update ) updateAll(); } diff --git a/src/GLViewer/GLViewer_Viewer2d.h b/src/GLViewer/GLViewer_Viewer2d.h index 94a5bd254..21840335f 100644 --- a/src/GLViewer/GLViewer_Viewer2d.h +++ b/src/GLViewer/GLViewer_Viewer2d.h @@ -180,6 +180,11 @@ public: //! Repaints view \param theView. If \param theView = NULL repaints all views. void repaintView( GLViewer_ViewFrame* theView = NULL, bool makeCurrent = false ); +signals: + //! Signal needs for optimum recompute of zoom depending objects + //! Warning: use recompute without update viewer + void wheelZoomChange( bool ); + public slots: //void onSketchDelObject(); //void onSketchUndoLast(); diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 50f5fe543..0ebc91d89 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1108,7 +1108,8 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType if( vm ) { vm->setBackgroundColor( resMgr->colorValue( "VTKViewer", "background", vm->backgroundColor() ) ); - vm->setTrihedronSize( resMgr->integerValue( "VTKViewer", "trihedron_size", vm->trihedronSize() ) ); + vm->setTrihedronSize( resMgr->integerValue( "VTKViewer", "trihedron_size", vm->trihedronSize() ), + resMgr->booleanValue( "VTKViewer", "relative_size", vm->trihedronRelative() ) ); new LightApp_VTKSelector( vm, mySelMgr ); } } @@ -1210,6 +1211,8 @@ void LightApp_Application::onDesktopActivated() QString LightApp_Application::getFileFilter() const { return "(*.bin)"; + // HDF persistence not yet completed - to be uncommented later + //return "(*.hdf)"; } /*! Gets file name*/ @@ -1639,6 +1642,7 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString if ( sec == QString( "VTKViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )) ) { int sz = resMgr->integerValue( "VTKViewer", "trihedron_size", -1 ); + bool isRelative = resMgr->booleanValue( "VTKViewer", "relative_size", true ); QPtrList lst; viewManagers( SVTK_Viewer::Type(), lst ); for ( QPtrListIterator it( lst ); it.current() && sz >= 0; ++it ) @@ -1650,7 +1654,7 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString SVTK_Viewer* vtkVM = dynamic_cast( vm ); if( vtkVM ) { - vtkVM->setTrihedronSize( sz ); + vtkVM->setTrihedronSize( sz, isRelative ); vtkVM->Repaint(); } } diff --git a/src/LightApp/LightApp_Driver.cxx b/src/LightApp/LightApp_Driver.cxx index 5b56e03b7..122890390 100644 --- a/src/LightApp/LightApp_Driver.cxx +++ b/src/LightApp/LightApp_Driver.cxx @@ -38,6 +38,7 @@ /*! Constructor.*/ LightApp_Driver::LightApp_Driver() +: myIsTemp( false ) { } @@ -354,6 +355,10 @@ LightApp_Driver::ListOfFiles LightApp_Driver::PutStreamToFiles( const unsigned c // Create a temporary directory for the component's data files std::string aDir = GetTmpDir(); + // Remember that the files are in a temporary location that should be deleted + // when a study is closed + SetIsTemporary( true ); + //Get a temporary directory for saving a file TCollection_AsciiString aTmpDir(const_cast(aDir.c_str())); @@ -430,9 +435,17 @@ void LightApp_Driver::RemoveFiles( const ListOfFiles& theFiles, const bool IsDir if(IsDirDeleted) { OSD_Path aPath(aDirName); OSD_Directory aDir(aPath); - OSD_FileIterator anIterator(aPath, '*'); - - if(aDir.Exists() && !anIterator.More()) aDir.Remove(); + // san -- Using a special code block below is essential - it ensures that + // OSD_FileIterator instance is destroyed by the moment when + // OSD_Directory::Remove() is called. + // Otherwise, the directory remains locked (at least on Windows) + // by the iterator and cannot be removed. + { + OSD_FileIterator anIterator(aPath, '*'); + if(!aDir.Exists() || anIterator.More()) + return; + } + aDir.Remove(); } } @@ -461,9 +474,13 @@ void LightApp_Driver::ClearDriverContents() for ( it = myMap.begin(); it != myMap.end(); ++it ) { const char* aModuleName = const_cast(it->first.c_str()); - RemoveTemporaryFiles( aModuleName, false ); + // If the driver contains temporary files - + // remove them along with the temporary directory + RemoveTemporaryFiles( aModuleName, IsTemporary() ); } - myMap.clear(); + myMap.clear(); + // Reset the "temporary" flag + SetIsTemporary( false ); } //============================================================================ @@ -523,7 +540,12 @@ std::string LightApp_Driver::GetTmpDir() aDir = OSD_Directory(aPath); } - OSD_Protection aProtection(OSD_RW, OSD_RWX, OSD_RX, OSD_RX); +#ifdef WIN32 + // Workaround for OSD_Protection bug on Windows + OSD_Protection aProtection(OSD_RWXD, OSD_RWXD, OSD_RWXD, OSD_RWXD); +#else + OSD_Protection aProtection(OSD_RX, OSD_RWXD, OSD_RX, OSD_RX); +#endif aDir.Build(aProtection); myTmpDir = aTmpDir.ToCString(); diff --git a/src/LightApp/LightApp_Driver.h b/src/LightApp/LightApp_Driver.h index 022ce16ec..f995ce27d 100644 --- a/src/LightApp/LightApp_Driver.h +++ b/src/LightApp/LightApp_Driver.h @@ -40,9 +40,9 @@ public: typedef std::vector ListOfFiles; - bool SaveDatasInFile (const char* theFileName, bool isMultiFile ); - bool ReadDatasFromFile (const char* theFileName, bool isMultiFile ); - virtual std::string GetTmpDir (const char* theURL, const bool isMultiFile); + virtual bool SaveDatasInFile (const char* theFileName, bool isMultiFile); + virtual bool ReadDatasFromFile (const char* theFileName, bool isMultiFile); + virtual std::string GetTmpDir (const char* theURL, const bool isMultiFile); ListOfFiles GetListOfFiles (const char* theModuleName); virtual void SetListOfFiles (const char* theModuleName, const ListOfFiles theListOfFiles); @@ -51,7 +51,7 @@ public: virtual void ClearDriverContents(); -private: +protected: void PutFilesToStream(const std::string& theModuleName, unsigned char*& theBuffer, long& theBufferSize, bool theNamesOnly = false); ListOfFiles PutStreamToFiles(const unsigned char* theBuffer, @@ -60,10 +60,16 @@ private: std::string GetTmpDir(); std::string GetDirFromPath(const std::string& thePath); -private: + void SetIsTemporary( bool theFlag ) { myIsTemp = theFlag; } + bool IsTemporary() const { return myIsTemp; } + +protected: typedef std::map MapOfListOfFiles; MapOfListOfFiles myMap; std::string myTmpDir; + +private: + bool myIsTemp; }; #endif diff --git a/src/LightApp/LightApp_Study.cxx b/src/LightApp/LightApp_Study.cxx index b32f4945e..a2e5e4ba9 100644 --- a/src/LightApp/LightApp_Study.cxx +++ b/src/LightApp/LightApp_Study.cxx @@ -23,7 +23,8 @@ #include "LightApp_DataModel.h" #include "LightApp_DataObject.h" #include "LightApp_RootObject.h" -#include "LightApp_Driver.h" +// HDF persistence not yet completed +//#include "LightApp_HDFDriver.h" #include "SUIT_ResourceMgr.h" #include "SUIT_DataObjectIterator.h" @@ -50,6 +51,8 @@ LightApp_Study::LightApp_Study( SUIT_Application* app ) : CAM_Study( app ) { + // HDF persistence not yet completed + //myDriver = new LightApp_HDFDriver(); myDriver = new LightApp_Driver(); } @@ -229,16 +232,14 @@ bool LightApp_Study::saveDocument() //================================================================ void LightApp_Study::closeDocument(bool permanently) { - // Remove temporary files - ModelList aList; - dataModels( aList ); - myDriver->ClearDriverContents(); - // Inform everybody that this study is going to close when it's most safe to, // i.e. in the very beginning emit closed( this ); CAM_Study::closeDocument(permanently); + + // Remove temporary files + myDriver->ClearDriverContents(); } //================================================================ @@ -323,8 +324,8 @@ bool LightApp_Study::isSaved() const } //======================================================================= -// name : saveModuleData -/*! Purpose : Create SComponent for module, necessary for SalomeApp study */ +// name : addComponent +/*! Purpose : Create SComponent for module, necessary for SalomeApp study */ //======================================================================= void LightApp_Study::addComponent(const CAM_DataModel* dm) { @@ -463,7 +464,7 @@ void LightApp_Study::RemoveTemporaryFiles (const char* theModuleName, const bool } //================================================================ -// Function : RemoveTemporaryFiles +// Function : components /*! Purpose : to be used by modules*/ //================================================================ void LightApp_Study::components( QStringList& comp ) const @@ -477,4 +478,3 @@ void LightApp_Study::components( QStringList& comp ) const comp.append( obj->entry() ); } } - diff --git a/src/LightApp/Makefile.in b/src/LightApp/Makefile.in index 092b071f7..3ffef0449 100755 --- a/src/LightApp/Makefile.in +++ b/src/LightApp/Makefile.in @@ -41,6 +41,7 @@ EXPORT_HEADERS= LightApp.h \ LightApp_UpdateFlags.h \ LightApp_VTKSelector.h \ LightApp_WidgetContainer.h +# LightApp_HDFDriver.h \ # .po files to transform in .qm PO_FILES = LightApp_images.po \ @@ -75,6 +76,7 @@ LIB_SRC= LightApp_AboutDlg.cxx \ LightApp_PreferencesDlg.cxx \ LightApp_VTKSelector.cxx \ LightApp_WidgetContainer.cxx +# LightApp_HDFDriver.cxx \ LIB_MOC = LightApp_AboutDlg.h \ LightApp_Application.h \ @@ -105,9 +107,11 @@ RESOURCES_FILES = icon_about.png \ LightApp.ini \ LightApp.xml -CPPFLAGS+=$(PYTHON_INCLUDES) $(QT_INCLUDES) $(QWT_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) +CPPFLAGS+=$(PYTHON_INCLUDES) $(QT_INCLUDES) $(QWT_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) + #$(HDF5_INCLUDES) LDFLAGS+=$(PYTHON_LIBS) $(QT_MT_LIBS) -LIBS+= -lsuit -lstd -lCAM -lObjBrowser -lLogWindow $(CAS_KERNEL) -lGLViewer -lOCCViewer -lVTKViewer -lSalomeObject -lSOCC -lSVTK -lSPlot2d -lSUPERVGraph -lPyInterp -lPythonConsole +LIBS+= -lsuit -lstd -lCAM -lObjBrowser -lLogWindow $(CAS_KERNEL) -lGLViewer -lOCCViewer -lVTKViewer -lSalomeObject -lSOCC -lSVTK -lSPlot2d -lSUPERVGraph -lPyInterp -lPythonConsole + #$(HDF5_LIBS) -lSalomeHDFPersistCopy @CONCLUDE@ diff --git a/src/LightApp/resources/LightApp_msg_en.po b/src/LightApp/resources/LightApp_msg_en.po index 5c3215335..c5b364d56 100644 --- a/src/LightApp/resources/LightApp_msg_en.po +++ b/src/LightApp/resources/LightApp_msg_en.po @@ -256,6 +256,15 @@ msgstr "Auto size for first column" msgid "LightApp_PreferencesDlg::CAPTION" msgstr "Preferences" +msgid "LightApp_PreferencesDlg::DEFAULT_BTN_TEXT" +msgstr "Defaults" + +msgid "LightApp_PreferencesDlg::WARNING" +msgstr "Warning" + +msgid "LightApp_PreferencesDlg::DEFAULT_QUESTION" +msgstr "Do you want to retrieve default preferences?" + //======================================================================================= msgid "LightApp_Module::TOP_DISPLAY" diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index 443ee295f..35f4b5888 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -593,6 +593,7 @@ void Plot2d_ViewFrame::displayCurve( Plot2d_Curve* curve, bool update ) { if ( !curve ) return; + // san -- Protection against QwtCurve bug in Qwt 0.4.x: // it crashes if switched to X/Y logarithmic mode, when one or more points have // non-positive X/Y coordinate @@ -601,7 +602,6 @@ void Plot2d_ViewFrame::displayCurve( Plot2d_Curve* curve, bool update ) if ( myYMode && curve->getMinY() <= 0. ) setVerScaleMode( 0, false ); - if ( hasCurve( curve ) ) { updateCurve( curve, update ); } @@ -1330,10 +1330,8 @@ void Plot2d_ViewFrame::setHorScaleMode( const int mode, bool update ) } myXMode = mode; - if ( myXMode == 0 ) // linear - myPlot->changeAxisOptions( QwtPlot::xBottom, QwtAutoScale::Logarithmic, false ); - else // logarithmic - myPlot->changeAxisOptions( QwtPlot::xBottom, QwtAutoScale::Logarithmic, true ); + + myPlot->changeAxisOptions( QwtPlot::xBottom, QwtAutoScale::Logarithmic, myXMode != 0 ); if ( update ) fitAll(); @@ -1353,16 +1351,10 @@ void Plot2d_ViewFrame::setVerScaleMode( const int mode, bool update ) } myYMode = mode; - if ( myYMode == 0 ) { // linear - myPlot->changeAxisOptions( QwtPlot::yLeft, QwtAutoScale::Logarithmic, false ); - if (mySecondY) - myPlot->changeAxisOptions( QwtPlot::yRight, QwtAutoScale::Logarithmic, false ); - } - else { // logarithmic - myPlot->changeAxisOptions( QwtPlot::yLeft, QwtAutoScale::Logarithmic, true ); - if (mySecondY) - myPlot->changeAxisOptions( QwtPlot::yRight, QwtAutoScale::Logarithmic, true ); - } + myPlot->changeAxisOptions( QwtPlot::yLeft, QwtAutoScale::Logarithmic, myYMode != 0 ); + if (mySecondY) + myPlot->changeAxisOptions( QwtPlot::yRight, QwtAutoScale::Logarithmic, myYMode != 0 ); + if ( update ) fitAll(); emit vpModeVerChanged(); diff --git a/src/Plot2d/resources/Plot2d_msg_en.po b/src/Plot2d/resources/Plot2d_msg_en.po index a646152b5..aeb44afb7 100755 --- a/src/Plot2d/resources/Plot2d_msg_en.po +++ b/src/Plot2d/resources/Plot2d_msg_en.po @@ -150,7 +150,7 @@ msgstr "Error" msgid "BUT_OK" msgstr "Ok" -# ------------------------------------ +#------------------------------------- # Plot2d_SetupViewDlg # ------------------------------------ msgid "TLT_SETUP_PLOT2D_VIEW" diff --git a/src/Qtx/Makefile.in b/src/Qtx/Makefile.in index aa682b59d..02f58984b 100755 --- a/src/Qtx/Makefile.in +++ b/src/Qtx/Makefile.in @@ -1,4 +1,5 @@ -# File : Makefile.in # Author : Vladimir Klyachin (OCN) +# File : Makefile.in +# Author : Vladimir Klyachin (OCN) # Module : suit # $Header$ diff --git a/src/Qtx/QtxColorScale.h b/src/Qtx/QtxColorScale.h index 1037fd621..fa81c0d1a 100755 --- a/src/Qtx/QtxColorScale.h +++ b/src/Qtx/QtxColorScale.h @@ -152,7 +152,9 @@ private: QSize calculateSize( const bool, const int, const bool, const bool, const bool ) const; - friend class Dock; +#if QT_VER == 3 + friend class QtxColorScale::Dock; +#endif private: double myMin; diff --git a/src/Qtx/QtxDirListEditor.cxx b/src/Qtx/QtxDirListEditor.cxx index 0532cd77f..9ddfd7c3d 100644 --- a/src/Qtx/QtxDirListEditor.cxx +++ b/src/Qtx/QtxDirListEditor.cxx @@ -206,6 +206,18 @@ QtxDirListEditor::~QtxDirListEditor() */ void QtxDirListEditor::getPathList(QStringList& list) { + // Finish the path editing + if (myEdit) { + validate(true); + + myEdit->deleteLater(); + myBtn->deleteLater(); + myEdit = 0; + myBtn = 0; + myEdited = false; + myDirList->setFocus(); + } + list.clear(); for (unsigned i = 0; i < myDirList->count()-1; i++) list.append(myDirList->text(i)); @@ -224,11 +236,11 @@ void QtxDirListEditor::setPathList(const QStringList& list) { /*! Validates entered path, returns true if OK */ -bool QtxDirListEditor::validate() +bool QtxDirListEditor::validate( const bool quietMode ) { if ( myEdited ) { - QString dirPath = QFileInfo( myEdit->text().stripWhiteSpace() ).absFilePath(); + QString dirPath = QFileInfo( myEdit->text().stripWhiteSpace() ).filePath(); /* #ifndef WNT if ( dirPath.startsWith( "~") ) { @@ -285,20 +297,21 @@ bool QtxDirListEditor::validate() if (found) { if (found != myLastSelected) { // it is forbidden to add directory more then once - QMessageBox::critical(this, - tr("Error"), - tr("Directory already specified."), - tr("Ok")); + if ( !quietMode ) + QMessageBox::critical(this, + tr("Error"), + tr("Directory already specified."), + tr("Ok")); myEdit->setFocus(); return false; } } else { if (!dir.exists()) { - if ( QMessageBox::information(this, - tr("Warning"), - tr("%1\n\nThe directory doesn't exist.\nAdd directory anyway?").arg(dir.absPath()), - tr("Yes"), tr("No"), QString::null, 1, 1) == 1) { + if ( !quietMode && QMessageBox::information(this, + tr("Warning"), + tr("%1\n\nThe directory doesn't exist.\nAdd directory anyway?").arg(dir.absPath()), + tr("Yes"), tr("No"), QString::null, 1, 1) == 1) { myEdit->setFocus(); return false; } diff --git a/src/Qtx/QtxDirListEditor.h b/src/Qtx/QtxDirListEditor.h index 95e84228e..7851fc83a 100644 --- a/src/Qtx/QtxDirListEditor.h +++ b/src/Qtx/QtxDirListEditor.h @@ -74,7 +74,7 @@ protected: * \brief Validates entered path * \retval bool - returns status (true if OK) */ - bool validate(); + bool validate( const bool quietMode = false ); /*! * \brief Appends/changes path diff --git a/src/Qtx/QtxListResourceEdit.cxx b/src/Qtx/QtxListResourceEdit.cxx index 60a5fbe4c..038e189b7 100644 --- a/src/Qtx/QtxListResourceEdit.cxx +++ b/src/Qtx/QtxListResourceEdit.cxx @@ -39,6 +39,7 @@ #include #include #include +#include #include "QtxIntSpinBox.h" #include "QtxDblSpinBox.h" @@ -1130,6 +1131,9 @@ void QtxListResourceEdit::FontItem::setFamily( const QString& f ) if( deffam.canCast( QVariant::String ) ) curtext = deffam.toString(); } + + if ( curtext.isEmpty() ) + curtext = (QApplication::font()).family(); int idx = -1; for ( int i = 0; i < (int)myFamilies->count() && idx < 0; i++ ) diff --git a/src/STD/STD_Application.cxx b/src/STD/STD_Application.cxx index 3e955e6c9..a3ab1739e 100755 --- a/src/STD/STD_Application.cxx +++ b/src/STD/STD_Application.cxx @@ -93,7 +93,17 @@ void STD_Application::closeApplication() { if ( desktop() ) savePreferences(); + SUIT_Study* study = activeStudy(); + + if ( study ){ + study->closeDocument(); + + setActiveStudy( 0 ); + delete study; + } + setDesktop( 0 ); + SUIT_Application::closeApplication(); } @@ -112,18 +122,6 @@ void STD_Application::onDesktopClosing( SUIT_Desktop*, QCloseEvent* e ) return; } - SUIT_Study* study = activeStudy(); - - if ( study ) - study->closeDocument(); - - setActiveStudy( 0 ); - delete study; - - savePreferences(); - - setDesktop( 0 ); - closeApplication(); } diff --git a/src/SUIT/SUIT_Application.h b/src/SUIT/SUIT_Application.h index 43f6f29ed..b630177e6 100755 --- a/src/SUIT/SUIT_Application.h +++ b/src/SUIT/SUIT_Application.h @@ -56,10 +56,12 @@ public: //! Returns main widget (Desktop) of the application (if it exists) virtual SUIT_Desktop* desktop(); - /*! Returns FALSE if applic ation can not be closed (because of non saved data for example). + /*! Returns FALSE if application can not be closed (because of non saved data for example). This method called by SUIT_Session whin closing of application was requested. */ virtual bool isPossibleToClose(); + /*! Performs some finalization of life cycle of this application. + For instance, the application can force its documents(s) to close. */ virtual void closeApplication(); //! Returns active Study. If Application supports wirking with several studies this method should be redefined diff --git a/src/SVTK/SVTK_MainWindow.cxx b/src/SVTK/SVTK_MainWindow.cxx index ad01609bc..145aa9aa5 100644 --- a/src/SVTK/SVTK_MainWindow.cxx +++ b/src/SVTK/SVTK_MainWindow.cxx @@ -265,9 +265,9 @@ SVTK_MainWindow //---------------------------------------------------------------------------- void SVTK_MainWindow -::SetTrihedronSize( const int theSize ) +::SetTrihedronSize( const int theSize, const bool theRelative ) { - GetRenderer()->SetTrihedronSize(theSize); + GetRenderer()->SetTrihedronSize(theSize, theRelative); Repaint(); } diff --git a/src/SVTK/SVTK_MainWindow.h b/src/SVTK/SVTK_MainWindow.h index 758093797..45f525f28 100644 --- a/src/SVTK/SVTK_MainWindow.h +++ b/src/SVTK/SVTK_MainWindow.h @@ -150,7 +150,7 @@ public: //! Redirect the request to #SVTK_Renderer::SetTrihedronSize void - SetTrihedronSize(const int theSize); + SetTrihedronSize(const int theSize, const bool theRelative = true); //! Redirect the request to #SVTK_Renderer::AdjustActors void diff --git a/src/SVTK/SVTK_Renderer.cxx b/src/SVTK/SVTK_Renderer.cxx index cad43a139..8302903a3 100644 --- a/src/SVTK/SVTK_Renderer.cxx +++ b/src/SVTK/SVTK_Renderer.cxx @@ -74,7 +74,8 @@ SVTK_Renderer myTransform(VTKViewer_Transform::New()), myCubeAxes(SVTK_CubeAxesActor2D::New()), myTrihedron(SVTK_Trihedron::New()), - myTrihedronSize(105) + myTrihedronSize(105), + myIsTrihedronRelative(true) { myDevice->Delete(); myTransform->Delete(); @@ -363,8 +364,13 @@ SVTK_Renderer // if the new trihedron size have sufficient difference, then apply the value double aSize = myTrihedron->GetSize(); - ComputeTrihedronSize(GetDevice(),aSize,aSize,myTrihedronSize); - myTrihedron->SetSize(aSize); + if ( IsTrihedronRelative() ) + { + ComputeTrihedronSize(GetDevice(),aSize,aSize,myTrihedronSize); + myTrihedron->SetSize(aSize); + } + else + myTrihedron->SetSize( myTrihedronSize ); // iterate through displayed objects and set size if necessary vtkActorCollection* anActors = GetDevice()->GetActors(); @@ -418,10 +424,11 @@ SVTK_Renderer void SVTK_Renderer -::SetTrihedronSize(int theSize) +::SetTrihedronSize(int theSize, const bool theRelative) { - if(myTrihedronSize != theSize){ + if(myTrihedronSize != theSize || myIsTrihedronRelative != theRelative){ myTrihedronSize = theSize; + myIsTrihedronRelative = theRelative; AdjustActors(); } } @@ -433,6 +440,12 @@ SVTK_Renderer return myTrihedronSize; } +bool +SVTK_Renderer +::IsTrihedronRelative() const +{ + return myIsTrihedronRelative; +} //---------------------------------------------------------------------------- VTKViewer_Trihedron* diff --git a/src/SVTK/SVTK_Renderer.h b/src/SVTK/SVTK_Renderer.h index 5f486543c..5532ea852 100644 --- a/src/SVTK/SVTK_Renderer.h +++ b/src/SVTK/SVTK_Renderer.h @@ -127,12 +127,16 @@ class SVTK_EXPORT SVTK_Renderer : public vtkObject //! Set size of the trihedron in percents from bounding box of the scene void - SetTrihedronSize(int theSize); + SetTrihedronSize(int theSize, const bool theRelative = true); //! Get size of the trihedron in percents from bounding box of the scene int GetTrihedronSize() const; + //! Shows if the size of the trihedron is relative + bool + IsTrihedronRelative() const; + //---------------------------------------------------------------------------- //! Get trihedron control VTKViewer_Trihedron* @@ -238,7 +242,8 @@ class SVTK_EXPORT SVTK_Renderer : public vtkObject //---------------------------------------------------------------------------- vtkSmartPointer myCubeAxes; vtkSmartPointer myTrihedron; - int myTrihedronSize; + int myTrihedronSize; + bool myIsTrihedronRelative; float myBndBox[6]; }; diff --git a/src/SVTK/SVTK_ViewModel.cxx b/src/SVTK/SVTK_ViewModel.cxx index 08c2169d5..03b8ca4a1 100644 --- a/src/SVTK/SVTK_ViewModel.cxx +++ b/src/SVTK/SVTK_ViewModel.cxx @@ -63,6 +63,7 @@ SVTK_Viewer::SVTK_Viewer() { myTrihedronSize = 105; + myTrihedronRelative = true; } //========================================================== @@ -88,7 +89,7 @@ SVTK_Viewer for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ if(SUIT_ViewWindow* aViewWindow = aViews.at(i)){ if(TViewWindow* aView = dynamic_cast(aViewWindow)){ - aView->getMainWindow()->SetBackgroundColor(theColor); + aView->setBackgroundColor(theColor); } } } @@ -97,15 +98,15 @@ SVTK_Viewer } //========================================================== -SUIT_ViewWindow* +SUIT_ViewWindow* SVTK_Viewer:: createView( SUIT_Desktop* theDesktop ) { - SVTK_ViewWindow* aViewWindow = new SVTK_ViewWindow(theDesktop); + TViewWindow* aViewWindow = new TViewWindow(theDesktop); aViewWindow->Initialize(this); - + aViewWindow->setBackgroundColor( backgroundColor() ); - aViewWindow->SetTrihedronSize( trihedronSize() ); + aViewWindow->SetTrihedronSize( trihedronSize(), trihedronRelative() ); return aViewWindow; } @@ -115,23 +116,23 @@ int SVTK_Viewer::trihedronSize() const return myTrihedronSize; } -void SVTK_Viewer::setTrihedronSize( const int sz ) +bool SVTK_Viewer::trihedronRelative() const { - myTrihedronSize = sz; - - SUIT_ViewManager* vm = getViewManager(); - if ( !vm ) - return; - - QPtrVector vec = vm->getViews(); - for ( int i = 0; i < vec.count(); i++ ) - { - SUIT_ViewWindow* win = vec.at( i ); - if ( !win || !win->inherits( "SVTK_ViewWindow" ) ) - continue; + return myTrihedronRelative; +} - SVTK_ViewWindow* vw = (SVTK_ViewWindow*)win; - vw->SetTrihedronSize( sz ); +void SVTK_Viewer::setTrihedronSize( const int theSize, const bool theRelative ) +{ + myTrihedronSize = theSize; + myTrihedronRelative = theRelative; + + if (SUIT_ViewManager* aViewManager = getViewManager()) { + QPtrVector aViews = aViewManager->getViews(); + for (int i = 0; i < aViews.count(); i++) { + if (TViewWindow* aView = dynamic_cast(aViews.at(i))) { + aView->SetTrihedronSize(theSize, theRelative); + } + } } } @@ -164,7 +165,7 @@ SVTK_Viewer thePopup->insertSeparator(); if(TViewWindow* aView = dynamic_cast(myViewManager->getActiveView())){ - if ( !aView->getView()->GetMainWindow()->getToolBar()->isVisible() ){ + if ( !aView->getMainWindow()->getToolBar()->isVisible() ){ thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_SHOW_TOOLBAR" ), this, SLOT( onShowToolbar() ) ); } } @@ -233,7 +234,7 @@ SVTK_Viewer QPtrVector aViews = myViewManager->getViews(); for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ if(TViewWindow* aView = dynamic_cast(aViews.at(i))){ - aView->getView()->GetMainWindow()->getToolBar()->show(); + aView->getMainWindow()->getToolBar()->show(); } } } @@ -415,10 +416,11 @@ SVTK_Viewer { QPtrVector aViews = myViewManager->getViews(); for(int i = 0, iEnd = aViews.size(); i < iEnd; i++) - if(SVTK_ViewWindow* aViewWindow = dynamic_cast(aViews.at(i))) - if(SVTK_View* aView = aViewWindow->getView()) - if(!aView->isVisible( io )) - return false; + if(SUIT_ViewWindow* aViewWindow = aViews.at(i)) + if(TViewWindow* aViewWnd = dynamic_cast(aViewWindow)) + if(SVTK_View* aView = aViewWnd->getView()) + if(!aView->isVisible( io )) + return false; return true; } @@ -431,7 +433,7 @@ SVTK_Viewer // if (theUpdateTrihedron) onAdjustTrihedron(); QPtrVector aViews = myViewManager->getViews(); for(int i = 0, iEnd = aViews.size(); i < iEnd; i++) - if(SVTK_ViewWindow* aViewWindow = dynamic_cast(aViews.at(i))) + if(TViewWindow* aViewWindow = dynamic_cast(aViews.at(i))) if(SVTK_View* aView = aViewWindow->getView()) aView->Repaint(); } diff --git a/src/SVTK/SVTK_ViewModel.h b/src/SVTK/SVTK_ViewModel.h index 5875d465e..21ca80007 100644 --- a/src/SVTK/SVTK_ViewModel.h +++ b/src/SVTK/SVTK_ViewModel.h @@ -65,8 +65,11 @@ public: //! Get size of trihedron of the viewer (see #SVTK_Renderer::SetTrihedronSize) int trihedronSize() const; + //! Shows if the size of trihedron relative (see #SVTK_Renderer::SetTrihedronSize) + bool trihedronRelative() const; + //! Set size of trihedron of the viewer (see #SVTK_Renderer::SetTrihedronSize) - void setTrihedronSize( const int ); + void setTrihedronSize( const int, const bool = true ); public: void enableSelection(bool isEnabled); @@ -115,6 +118,7 @@ protected slots: private: QColor myBgColor; int myTrihedronSize; + bool myTrihedronRelative; bool mySelectionEnabled; bool myMultiSelectionEnabled; }; diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index 4175e3e82..69e5eae4a 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -41,7 +41,6 @@ #include "SUIT_Accel.h" #include "VTKViewer_Utilities.h" -#include "VTKViewer_Transform.h" #include "SVTK_View.h" #include "SVTK_MainWindow.h" @@ -433,9 +432,9 @@ SVTK_ViewWindow void SVTK_ViewWindow -::SetTrihedronSize(const int theSize) +::SetTrihedronSize(const int theSize, const bool theRelative) { - myMainWindow->SetTrihedronSize(theSize); + myMainWindow->SetTrihedronSize(theSize, theRelative); } /*! If parameter theIsForcedUpdate is true, recalculate parameters for diff --git a/src/SVTK/SVTK_ViewWindow.h b/src/SVTK/SVTK_ViewWindow.h index 8b7d8fad4..51e50ac45 100755 --- a/src/SVTK/SVTK_ViewWindow.h +++ b/src/SVTK/SVTK_ViewWindow.h @@ -219,7 +219,7 @@ class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow //! Redirect the request to #SVTK_Renderer::SetTrihedronSize virtual void - SetTrihedronSize( const int ); + SetTrihedronSize( const int, const bool = true ); //! Redirect the request to #SVTK_Renderer::SetSelectionProp virtual diff --git a/src/SalomeApp/SalomeApp_Study.cxx b/src/SalomeApp/SalomeApp_Study.cxx index dc3df93ff..fadef3a66 100644 --- a/src/SalomeApp/SalomeApp_Study.cxx +++ b/src/SalomeApp/SalomeApp_Study.cxx @@ -213,7 +213,8 @@ bool SalomeApp_Study::saveDocumentAs( const QString& theFileName ) res = isAscii ? SalomeApp_Application::studyMgr()->SaveAsASCII( theFileName.latin1(), studyDS(), isMultiFile ) : SalomeApp_Application::studyMgr()->SaveAs ( theFileName.latin1(), studyDS(), isMultiFile ) && - CAM_Study::saveDocumentAs( theFileName ) && saveStudyData(theFileName); + CAM_Study::saveDocumentAs( theFileName ) && //SRN: BugID IPAL9377, removed usage of uninitialized variable + saveStudyData(theFileName); if ( res ) emit saved( this ); diff --git a/src/SalomeApp/resources/SalomeApp.xml b/src/SalomeApp/resources/SalomeApp.xml index 4c290584a..8644a5a14 100644 --- a/src/SalomeApp/resources/SalomeApp.xml +++ b/src/SalomeApp/resources/SalomeApp.xml @@ -179,6 +179,7 @@
+ diff --git a/src/VTKViewer/VTKViewer_AppendFilter.cxx b/src/VTKViewer/VTKViewer_AppendFilter.cxx index dce05c44e..222d2f1ab 100644 --- a/src/VTKViewer/VTKViewer_AppendFilter.cxx +++ b/src/VTKViewer/VTKViewer_AppendFilter.cxx @@ -28,38 +28,15 @@ #include "VTKViewer_AppendFilter.h" -#include "VTKViewer_ConvexTool.h" - -#include -#include +#include #include -#include -#include -#include +#include +#include #include #include -#include -#include -#include -#include -#include #include -#include -#include -#include - -#include -#include -using namespace std; - -#ifdef _DEBUG_ -//static int MYDEBUG = 0; -//static int MYDEBUGWITHFILES = 0; -#else -//static int MYDEBUG = 0; -//static int MYDEBUGWITHFILES = 0; -#endif +#include #if defined __GNUC__ #if __GNUC__ == 2 @@ -73,7 +50,7 @@ vtkStandardNewMacro(VTKViewer_AppendFilter); VTKViewer_AppendFilter ::VTKViewer_AppendFilter() { - myDoMappingFlag=false; + myDoMappingFlag = false; } VTKViewer_AppendFilter @@ -84,7 +61,12 @@ void VTKViewer_AppendFilter ::SetDoMappingFlag(const bool theFlag) { - myDoMappingFlag=theFlag; + if(myDoMappingFlag == theFlag) + return; + + myDoMappingFlag = theFlag; + + this->Modified(); } bool @@ -98,7 +80,12 @@ void VTKViewer_AppendFilter ::SetPoints(vtkPoints* thePoints) { + if(GetPoints() == thePoints) + return; + myPoints = thePoints; + + this->Modified(); } vtkPoints* @@ -112,28 +99,16 @@ void VTKViewer_AppendFilter ::Execute() { - if (myPoints.GetPointer()) { + if(myPoints.GetPointer()) MakeOutput(); - } - else { - vtkAppendFilter::Execute(); - } - if (myDoMappingFlag){ + else + Superclass::Execute(); + + if(myDoMappingFlag) DoMapping(); - } } -void -VTKViewer_AppendFilter -::Reset() -{ - myNodeIds.clear(); - myCellIds.clear(); - myNodeRanges.clear(); - myCellRanges.clear(); - myNodeMapObjIDVtkID.clear(); - myCellMapObjIDVtkID.clear(); -} + //================================================================== // function: DoMapping // purpose : @@ -142,165 +117,140 @@ void VTKViewer_AppendFilter ::DoMapping() { - int i, j, i1, i2, iNodeCnt, iCellCnt; - IteratorOfDataMapOfIntegerInteger aMapIt; - vtkIdType aNbPnts, aNbCells, aId; - vtkDataSet *pDS; - // - Reset(); - // - iNodeCnt=0; - iCellCnt=0; - for (i=0; iGetNumberOfPoints(); - i1=myNodeIds.size(); - i2=i1+aNbPnts-1; - myNodeRanges.push_back(i1); - myNodeRanges.push_back(i2); - // - for(j=0; jGetNumberOfCells(); - i1=myCellIds.size(); - i2=i1+aNbCells-1; - myCellRanges.push_back(i1); - myCellRanges.push_back(i2); - for(j=0; jNumberOfInputs; ++aDataSetId){ + vtkDataSet* aDataSet = (vtkDataSet *)(this->Inputs[aDataSetId]); + // Do mapping of the nodes + if(!myPoints.GetPointer()){ + vtkIdType aNbPnts = aDataSet->GetNumberOfPoints(); + myNodeRanges.push_back(aPntStartId + aNbPnts); + aPntStartId += aNbPnts; } + // Do mapping of the cells + vtkIdType aNbCells = aDataSet->GetNumberOfCells(); + myCellRanges.push_back(aCellStartId + aNbCells); + aCellStartId += aNbCells; } } //--------------------------------------------------------------- +namespace +{ + inline + vtkIdType + GetOutputID(vtkIdType theInputID, + vtkIdType theInputDataSetID, + const VTKViewer_AppendFilter::TVectorIds& theRanges) + { + theInputID = theInputDataSetID = -1; + + vtkIdType aNbInputs = theRanges.size(); + if(theInputDataSetID < 0 || theInputDataSetID >= aNbInputs) + return -1; + + vtkIdType aStartId = theRanges[theInputDataSetID]; + return aStartId + theInputID; + } +} + vtkIdType VTKViewer_AppendFilter -::GetPointOutputID(vtkIdType theInputID) +::GetPointOutputID(vtkIdType theInputID, + vtkIdType theInputDataSetID) { - if (myPoints.GetPointer()) { + if(myPoints.GetPointer()) return theInputID; - } - // - int aVtkID=-1; - IteratorOfDataMapOfIntegerInteger aMapIt; - // - aMapIt=myNodeMapObjIDVtkID.find(theInputID); - if (aMapIt!=myNodeMapObjIDVtkID.end()) { - // found - PairOfDataMapOfIntegerInteger& aPair=(*aMapIt); - aVtkID=aPair.second; - } - return aVtkID; + + return GetOutputID(theInputID,theInputDataSetID,myNodeRanges); } //--------------------------------------------------------------- vtkIdType VTKViewer_AppendFilter -::GetCellOutputID(vtkIdType theInputID) +::GetCellOutputID(vtkIdType theInputID, + vtkIdType theInputDataSetID) { - int aVtkID=-1; - IteratorOfDataMapOfIntegerInteger aMapIt; - // - aMapIt=myCellMapObjIDVtkID.find(theInputID); - if (aMapIt!=myCellMapObjIDVtkID.end()) { - // found - PairOfDataMapOfIntegerInteger& aPair=(*aMapIt); - aVtkID=aPair.second; - } - return aVtkID; + if(myPoints.GetPointer()) + return theInputID; + + return GetOutputID(theInputID,theInputDataSetID,myCellRanges); } //--------------------------------------------------------------- -vtkIdType +namespace +{ + void + GetInputID(vtkIdType theOutputID, + vtkIdType& theInputID, + vtkIdType& theStartID, + vtkIdType& theInputDataSetID, + const VTKViewer_AppendFilter::TVectorIds& theRanges) + { + theInputID = theStartID = theInputDataSetID = -1; + + if(theRanges.empty()) + return; + + const vtkIdType& aRangeEnd = theRanges.back(); + if(theOutputID < 0 || theOutputID >= aRangeEnd) + return; + + vtkIdType aStartId = 0; + vtkIdType aNbInputs = theRanges.size(); + for(vtkIdType aDataSetId = 0; aDataSetId < aNbInputs; ++aDataSetId){ + vtkIdType aRange = theRanges[aDataSetId]; + if(aRange > theOutputID){ + theInputID = theOutputID - aStartId; + theInputDataSetID = aDataSetId; + theStartID = aStartId; + break; + } + aStartId = aRange; + } + } +} + +void VTKViewer_AppendFilter -::GetPointInputID(vtkIdType theOutputID, +::GetPointInputID(vtkIdType theOutputID, + vtkIdType& theInputID, + vtkIdType& theStartID, vtkIdType& theInputDataSetID) { - if (myPoints.GetPointer()) { - theInputDataSetID=0; - return theOutputID; - } - // - int aNb, aNbRanges, aRetID, i, i1, i2, j; - // - aRetID=-1; - theInputDataSetID=-1; - // - aNb=myNodeIds.size(); - if (theOutputID<0 || theOutputID>=aNb) { - return aRetID; - } - // - aRetID=(int)myNodeIds[theOutputID]; - // - aNbRanges=myNodeRanges.size()/2; - for (i=0; i=i1 && theOutputID<=i2) { - theInputDataSetID=i; - } + if(myPoints.GetPointer()) { + theStartID = theInputDataSetID = 0; + theInputID = theOutputID; + return; } - // - return aRetID; + + ::GetInputID(theOutputID, + theInputID, + theStartID, + theInputDataSetID, + myNodeRanges); } //--------------------------------------------------------------- -vtkIdType +void VTKViewer_AppendFilter -::GetCellInputID(vtkIdType theOutputID, +::GetCellInputID(vtkIdType theOutputID, + vtkIdType& theInputID, + vtkIdType& theStartID, vtkIdType& theInputDataSetID) { - int aNb, aNbRanges, aRetID, i, i1, i2, j; - // - aRetID=-1; - theInputDataSetID=-1; - // - aNb=myCellIds.size(); - if (theOutputID<0 || theOutputID>=aNb) { - return aRetID; - } - // - aRetID=(int)myCellIds[theOutputID]; - // - aNbRanges=myCellRanges.size()/2; - for (i=0; i=i1 && theOutputID<=i2) { - theInputDataSetID=i; - } - } - // - return aRetID; + ::GetInputID(theOutputID, + theInputID, + theStartID, + theInputDataSetID, + myCellRanges); } diff --git a/src/VTKViewer/VTKViewer_AppendFilter.h b/src/VTKViewer/VTKViewer_AppendFilter.h index f9c6b245a..ceaa3d323 100644 --- a/src/VTKViewer/VTKViewer_AppendFilter.h +++ b/src/VTKViewer/VTKViewer_AppendFilter.h @@ -36,19 +36,27 @@ public: GetPoints(); vtkIdType - GetPointOutputID(vtkIdType theInputID); + GetPointOutputID(vtkIdType theInputID, + vtkIdType theInputDataSetID); vtkIdType - GetCellOutputID(vtkIdType theInputID); + GetCellOutputID(vtkIdType theInputID, + vtkIdType theInputDataSetID); - vtkIdType - GetPointInputID(vtkIdType theOutputID, - vtkIdType& theInputDataSetID); + void + GetPointInputID(vtkIdType theOutputID, + vtkIdType& theInputID, + vtkIdType& theStartID, + vtkIdType& theInputDataSetID); - vtkIdType - GetCellInputID(vtkIdType theOutputID, + void + GetCellInputID(vtkIdType theOutputID, + vtkIdType& theInputID, + vtkIdType& theStartID, vtkIdType& theInputDataSetID); + typedef std::vector TVectorIds; + protected: /*! \fn VTKViewer_AppendFilter(); * \brief Constructor @@ -69,23 +77,10 @@ protected: void MakeOutput(); - // + bool myDoMappingFlag; + TVectorIds myNodeRanges; + TVectorIds myCellRanges; vtkSmartPointer myPoints; - -private: - typedef std::vector TVectorId; - typedef std::vector VectorInt; - typedef std::map DataMapOfIntegerInteger; - typedef DataMapOfIntegerInteger::iterator IteratorOfDataMapOfIntegerInteger; - typedef DataMapOfIntegerInteger::value_type PairOfDataMapOfIntegerInteger; -private: - bool myDoMappingFlag; - TVectorId myNodeIds; - TVectorId myCellIds; - VectorInt myNodeRanges; - VectorInt myCellRanges; - DataMapOfIntegerInteger myNodeMapObjIDVtkID; - DataMapOfIntegerInteger myCellMapObjIDVtkID; }; #endif