#include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx>
+#include <stdio.h>
+
IMPLEMENT_STANDARD_HANDLE(DDS_DicGroup, MMgt_TShared)
IMPLEMENT_STANDARD_RTTIEXT(DDS_DicGroup, MMgt_TShared)
for( int i=1, n=myKeys.Length(); i<=n && !exist; i++ )
if( myKeys.Value( i )==anID )
{
+#ifdef DEB
cout << "Doubled key:" << anID << endl;
+#endif
exist = true;
}
if( !exist )
#include <TColStd_MapOfReal.hxx>
#include <TColStd_SequenceOfAsciiString.hxx>
+#include <stdio.h>
+
IMPLEMENT_STANDARD_HANDLE(DDS_DicItem, MMgt_TShared)
IMPLEMENT_STANDARD_RTTIEXT(DDS_DicItem, MMgt_TShared)
}
if( updateViewer )
- myGLViewer2d->activateDrawer( object, TRUE, TRUE );
+ {
+ if( myUpdateAll )
+ myGLViewer2d->updateAll();
+ else
+ myGLViewer2d->activateDrawer( object, TRUE, TRUE );
+ }
}
/*!
glEnd();
}
+/*!
+ Draws filled rectangle
+ \param rect - instance of primitive
+ \param fillingColor - color of filling
+*/
+void GLViewer_Drawer::drawFilledRectangle( GLViewer_Rect* rect, QColor color )
+{
+ if( !rect )
+ return;
+
+ float x1 = rect->left();
+ float x2 = rect->right();
+ float y1 = rect->bottom();
+ float y2 = rect->top();
+
+ glColor3f( ( GLfloat )color.red() / 255,
+ ( GLfloat )color.green() / 255,
+ ( GLfloat )color.blue() / 255 );
+ glBegin( GL_POLYGON );
+ glVertex2f( x1, y1 );
+ glVertex2f( x1, y2 );
+ glVertex2f( x2, y2 );
+ glVertex2f( x2, y1 );
+ glEnd();
+}
+
/*!
Saves object to file with format of HPGL
\param hFile - file
}
#endif
-/*!
- Draws rectangle
- \param rect - instance of primitive
- \param lineWidth - width of line
- \param gap - gap of rectangle
- \param color - color of primitive
- \param filled - if it is true, then rectangle will be drawn filled with color "fillingColor"
- \param fillingColor - color of filling
-*/
-void GLViewer_Drawer::drawRectangle( GLViewer_Rect* rect, GLfloat lineWidth, GLfloat gap,
- QColor color, bool filled, QColor fillingColor )
-{
- if( !rect )
- return;
-
- float x1 = rect->left() - gap;
- float x2 = rect->right() + gap;
- float y1 = rect->bottom() - gap;
- float y2 = rect->top() + gap;
-
- if( filled )
- {
- glColor3f( ( GLfloat )fillingColor.red() / 255,
- ( GLfloat )fillingColor.green() / 255,
- ( GLfloat )fillingColor.blue() / 255 );
- glBegin( GL_POLYGON );
- glVertex2f( x1, y1 );
- glVertex2f( x1, y2 );
- glVertex2f( x2, y2 );
- glVertex2f( x2, y1 );
- glEnd();
- }
-
- glColor3f( ( GLfloat )color.red() / 255,
- ( GLfloat )color.green() / 255,
- ( GLfloat )color.blue() / 255 );
- glLineWidth( lineWidth );
-
- glBegin( GL_LINE_LOOP );
- glVertex2f( x1, y1 );
- glVertex2f( x1, y2 );
- glVertex2f( x2, y2 );
- glVertex2f( x2, y1 );
- glEnd();
-}
-
/*!
Draws contour
\param pntList - list of points
//! Draw rectangle with predefined color
static void drawRectangle( GLViewer_Rect* theRect, QColor = Qt::black );
+ //! Draw filled rectangle with predefined color
+ static void drawFilledRectangle( GLViewer_Rect*, QColor = Qt::black );
+
protected:
- //! Draw basic primitives: rectangle, contour, polygon, vertex, cross, arrow
- //* with predefined color
- static void drawRectangle( GLViewer_Rect*, GLfloat, GLfloat = 0, QColor = Qt::black,
- bool = false, QColor = Qt::white );
static void drawContour( GLViewer_Rect*, QColor, GLfloat, GLushort, bool );
static void drawContour( const GLViewer_PntList&, QColor, GLfloat );
static void drawPolygon( GLViewer_Rect*, QColor, GLushort, bool );
#include "GLViewer.h"
#include <QRect>
-#include <QtOpenGL>
+#include <QRectF>
#include <math.h>
//using namespace QGL;
#pragma warning( disable:4251 )
#endif
+#include <QtOpenGL>
+
/*! Struct GLViewer_Pnt
* Substitution of QPoint for OpenGL
*/
GLViewer_Rect( QRect theRect ) {
myLeft = ( float )theRect.left(); myRight = ( float )theRect.right();
myTop = ( float )theRect.top(); myBottom = ( float )theRect.bottom(); }
+ GLViewer_Rect( QRectF theRect ) {
+ myLeft = theRect.left(); myRight = theRect.right();
+ myTop = theRect.top(); myBottom = theRect.bottom(); }
float left() const { return myLeft; }
float right() const { return myRight; }
( int )( myRight - myLeft ),
( int )( myTop - myBottom ) ); }
+ //! \warning This method translate only rect format
+ QRectF toQRectF() { return QRectF( myLeft, myBottom,
+ myRight - myLeft,
+ myTop - myBottom ); }
+
//! On/off empty status
void setIsEmpty( bool on ) { myIsEmpty = on; }
//! Checks empty status
(*it)->moveObject( x, y, true );
}
+/*!
+ Updates horizontal zoom of object
+ \param sender - object to be updated
+ \param zoom - zoom coefficient
+*/
+void GLViewer_Group::updateXZoom( GLViewer_Object* sender, float zoom )
+{
+ OGIterator it = myList.begin();
+ OGIterator end_it = myList.end();
+ for( int i = 0; it != end_it; ++it, i++ )
+ {
+ GLViewer_Object* anObject = *it;
+ if( anObject != sender )
+ anObject->setXZoom( zoom, true, true );
+ }
+}
+
/*!
Updates zoom of object
\param sender - object to be updated
/*! Once = true, if this operation calls only one time for all object*/
void dragingObjects( float x, float y, bool once = false );
//!\warning it is for ouv
+ void updateXZoom( GLViewer_Object* sender, float zoom );
+ //!\warning it is for ouv
void updateZoom( GLViewer_Object* sender, float zoom );
private:
myYScale = 1.0;
myXGap = 0;
myYGap = 0;
+ myXZoom = 1.0;
myZoom = 1.0;
myIsHigh = GL_FALSE;
*/
GLboolean GLViewer_Object::isInside( GLViewer_Rect theRect )
{
- return theRect.toQRect().contains( myRect->toQRect() );
+ return theRect.toQRectF().contains( myRect->toQRectF() );
+}
+
+/*!
+ Sets horizontal zoom factor
+ \param zoom - zoom factor
+*/
+GLboolean GLViewer_Object::setXZoom( GLfloat zoom, bool, bool )
+{
+ if( myXZoom == zoom )
+ return GL_FALSE;
+
+ myXZoom = zoom;
+ return GL_TRUE;
+}
+
+/*!
+ Performs horizontal zoom change by step
+ \param zoomIn - to increase to decrease zoom
+*/
+GLboolean GLViewer_Object::updateXZoom( bool zoomIn )
+{
+ float newZoom;
+ float step = zoomIn ? 1 : -1;
+ double epsilon = 0.001;
+
+ if( myXZoom - 1 > epsilon )
+ newZoom = ( myXZoom * 2 + step ) / 2;
+ else if( 1 - myXZoom > epsilon )
+ newZoom = 2 / ( 2 / myXZoom - step );
+ else
+ newZoom = zoomIn ? 3./2. : 2./3.;
+
+ if( newZoom < 0.01 || newZoom > 100.0 )
+ return GL_FALSE;
+
+ return setXZoom( newZoom, true );
}
/*!
}
/*!
- Performs zoom change by step
+ Performs vertical zoom change by step
\param zoomIn - to increase to decrease zoom
*/
GLboolean GLViewer_Object::updateZoom( bool zoomIn )
//! Returns scale factors
virtual void getScale( GLfloat& xScale, GLfloat& yScale ) const { xScale = myXScale; yScale = myYScale;}
+ //!\warning It is for ouv
+ virtual GLboolean setXZoom( GLfloat zoom, bool recompute, bool fromGroup = false );
+ //!\warning It is for ouv
+ virtual GLfloat getXZoom() const { return myXZoom; }
+ //!\warning It is for ouv
+ virtual GLboolean updateXZoom( bool zoomIn );
+
//!\warning It is for ouv
virtual GLboolean setZoom( GLfloat zoom, bool recompute, bool fromGroup = false );
//!\warning It is for ouv
//! Gap for Y direction of rect
GLfloat myYGap;
+ //!\warning It is for ouv
+ GLfloat myXZoom;
//!\warning It is for ouv
GLfloat myZoom;
aAction = new QtxAction(tr("MNU_DUMP_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_DUMP" ) ),
tr( "MNU_DUMP_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_DUMP_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onDumpView()));
+ connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onDumpView()));
toolMgr()->registerAction( aAction, DumpId );
// FitAll
aAction = new QtxAction(tr("MNU_FITALL"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_FITALL" ) ),
tr( "MNU_FITALL" ), 0, this);
aAction->setStatusTip(tr("DSC_FITALL"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onViewFitAll()));
+ connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onViewFitAll()));
toolMgr()->registerAction( aAction, FitAllId );
// FitRect
aAction = new QtxAction(tr("MNU_FITRECT"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_FITAREA" ) ),
tr( "MNU_FITRECT" ), 0, this);
aAction->setStatusTip(tr("DSC_FITRECT"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onViewFitArea()));
+ connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onViewFitArea()));
toolMgr()->registerAction( aAction, FitRectId );
// FitSelect
aAction = new QtxAction(tr("MNU_FITSELECT"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_FITSELECT" ) ),
tr( "MNU_FITSELECT" ), 0, this);
aAction->setStatusTip(tr("DSC_FITSELECT"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onViewFitSelect()));
+ connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onViewFitSelect()));
toolMgr()->registerAction( aAction, FitSelectId );
// Zoom
aAction = new QtxAction(tr("MNU_ZOOM_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_ZOOM" ) ),
tr( "MNU_ZOOM_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onViewZoom()));
+ connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onViewZoom()));
toolMgr()->registerAction( aAction, ZoomId );
// Panning
aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_PAN" ) ),
tr( "MNU_PAN_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_PAN_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onViewPan()));
+ connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onViewPan()));
toolMgr()->registerAction( aAction, PanId );
// Global Panning
aAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_GLOBALPAN" ) ),
tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onViewGlobalPan()));
+ connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onViewGlobalPan()));
toolMgr()->registerAction( aAction, GlobalPanId );
aAction = new QtxAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_RESET" ) ),
tr( "MNU_RESET_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_RESET_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onViewReset()));
+ connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onViewReset()));
toolMgr()->registerAction( aAction, ResetId );
}
return img;
}
+/*!
+ Saves image to file according to the format
+ \param image - image
+ \param fileName - name of file
+ \param format - string contains name of format (for example, "BMP"(default) or "JPEG", "JPG")
+*/
+bool GLViewer_ViewFrame::dumpViewToFormat( const QImage& img, const QString& fileName, const QString& format )
+{
+ bool ok = SUIT_ViewWindow::dumpViewToFormat( img, fileName, format );
+ if( ok )
+ emit vfViewDumped( img, fileName, format );
+ return ok;
+}
+
/*!
Start panning
*/
signals:
void vfDrawExternal( QPainter* );
void vfViewClosing( QCloseEvent* );
+ void vfViewDumped( const QImage&, const QString&, const QString& );
+
+protected:
+ virtual bool dumpViewToFormat( const QImage&, const QString& fileName, const QString& format );
protected:
GLViewer_Viewer* myViewer;
#include "GLViewer_Grid.h"
#include "GLViewer_Drawer.h"
-// TODO: Porting to Qt4
-//#include <QtxToolTip.h>
+#include <QtxToolTip.h>
#include <QHBoxLayout>
#include <QMouseEvent>
mypFirstPoint = NULL;
mypLastPoint = NULL;
- // TODO: Porting to Qt4
- /*myObjectTip = new QtxToolTip( myGLWidget );///GLViewer_ObjectTip( this );
- myObjectTip->setShowDelayTime( 60000 );
- connect( myObjectTip, SIGNAL( maybeTip( QPoint, QString&, QFont&, QRect&, QRect& ) ),
- this, SLOT( onMaybeTip( QPoint, QString&, QFont&, QRect&, QRect& ) ) );*/
-// myGLWidget->installEventFilter( myObjectTip );
+ myObjectTip = new QtxToolTip( myGLWidget );///GLViewer_ObjectTip( this );
+ myObjectTip->setShowDelayTime( 60000 );
+ connect( myObjectTip, SIGNAL( maybeTip( QPoint, QString&, QFont&, QRect&, QRect& ) ),
+ this, SLOT( onMaybeTip( QPoint, QString&, QFont&, QRect&, QRect& ) ) );
+ //myGLWidget->installEventFilter( myObjectTip );
}
/*!
{
emit vpMouseEvent( e );
+ if( isPulling() )
+ return;
+
if( myIsDragProcess == inDrag )
onDragObject( e );
}
emit vpMouseEvent( e );
+ if( isPulling() )
+ return;
+
if( myIsDragProcess == inDrag )
{
bool isAnyMoved = false;
}
+/*!
+ Returns tue if selection by rect is preformed
+*/
+bool GLViewer_ViewPort2d::isSelectByRect() const
+{
+ return mypFirstPoint && mypLastPoint;
+}
+
/*!
Finishes rectangle selection
*/
theTextReg = QRect( thePoint.x(), thePoint.y() + cur_height,
aSize.width(), aSize.height() );
theRegion = QRect( thePoint.x(), thePoint.y(), 1, 1 );
+
+ QPoint aBottomRightGlobal = mapToGlobal( theTextReg.bottomRight() );
+ int dx = aBottomRightGlobal.x() - QApplication::desktop()->screenGeometry().width();
+ int dy = aBottomRightGlobal.y() - QApplication::desktop()->screenGeometry().height();
+ dx = dx < 0 ? 0 : -dx;
+ dy = dy < 0 ? 0 : -dy;
+ theTextReg.translate( dx, dy );
}
}
}
#include "GLViewer_Widget.h"
#include "GLViewer_Geom.h"
-#include <QtOpenGL>
#include <QColor>
#include <QPaintDevice>
#pragma warning( disable:4251 )
#endif
+#include <QtOpenGL>
+
class GLViewer_Compass;
class GLViewer_Grid;
class GLViewer_Object;
class GLViewer_ViewPort2d: public GLViewer_ViewPort
{
Q_OBJECT
+ friend class GLViewer_Widget;
+public:
//! Dragging states
- enum vpDragState{ noDrag, initDrag, inDrag };
+ enum vpDragState{ noDrag = 0, initDrag, inDrag };
public:
GLViewer_ViewPort2d( QWidget* parent, GLViewer_ViewFrame* theViewFrame = NULL );
void endRotation();
//! Checks of dragging process state
- bool isDragProcess(){ return myIsDragProcess; }
+ int isDragProcess(){ return myIsDragProcess; }
//! On/off compass
void turnCompass( GLboolean on );
//! Pass rect into selector and update
void finishSelectByRect();
+ //! Pass rect into selector and update
+ bool isSelectByRect() const;
+
//! \warnign It is for ouv
bool startPulling( GLViewer_Pnt );
//! \warnign It is for ouv
TransformState state = EnTrain;
QMouseEvent* me = ( QMouseEvent* )e;
- myButtonState = me->modifiers();
+ myButtonState = me->buttons();
if ( e->type() == QEvent::MouseButtonPress )
myButtonState |= me->button(); /* add pressed button */
myMajorBtn = mouseOnlyState;
}
- if ( e->type() == QEvent::MouseButtonRelease && mouseOnlyState == myMajorBtn )
+ if ( e->type() == QEvent::MouseButtonRelease )
{
state = Fin;
}
SketchState state = EnTrain;
QMouseEvent* me = (QMouseEvent*)e;
- myButtonState = me->modifiers();
+ myButtonState = me->buttons();
if ( e->type() == QEvent::MouseButtonPress )
myButtonState |= me->button(); /* add pressed button */
virtual void startOperations( QMouseEvent* ) {}
virtual bool updateOperations( QMouseEvent* ) { return false; }
- virtual void finishOperations( QMouseEvent* ) {}
+ virtual bool finishOperations( QMouseEvent* ) { return false; }
virtual void startOperations( QWheelEvent* ) {}
protected slots:
{
GLViewer_Object* anObject = *it;
GLViewer_Rect* aRect = anObject->getRect();
- if( !anObject->isSelectable() || !anObject->getVisible() )
+ if( !anObject->isScalable() || !anObject->getVisible() )
continue;
if( border->isEmpty() )
transPoint( x, y );
GLViewer_Pnt point( x, y );
- if( e->button() == Qt::LeftButton && !myGLContext->getCurrentObject() && vp->startPulling( point ) )
+ // Try to start pooling if rectangular selection is performed
+ if( e->button() == Qt::LeftButton && !vp->isSelectByRect() &&
+ !vp->isDragProcess() && vp->startPulling( point ) )
+ {
+ vp->finishSelectByRect();
return;
+ }
+ // Start rectangular selection if pulling was not started
if( e->button() == Qt::LeftButton && !(vp->currentBlock() & BS_Selection) && !myGLContext->getCurrentObject() )
vp->startSelectByRect( e->x(), e->y() );
}
{
GLViewer_ViewPort2d* vp = ( GLViewer_ViewPort2d* )((GLViewer_ViewFrame*)getActiveView())->getViewPort();
+ float x = e->pos().x();
+ float y = e->pos().y();
+ transPoint( x, y );
+ GLViewer_Pnt point( x, y );
+
if( vp->isPulling() )
{
- float x = e->pos().x();
- float y = e->pos().y();
- transPoint( x, y );
-
- vp->drawPulling( GLViewer_Pnt( x, y ) );
+ vp->drawPulling( point );
updateAll();
return true;
}
+ /*if( vp->isDragProcess() == GLViewer_ViewPort2d::inDrag )
+ return true;*/
+
+ if( e->button() == Qt::LeftButton )
+ {
+ if( !vp->isSelectByRect() && !vp->isDragProcess() && vp->startPulling( point ) )
+ {
+ vp->finishSelectByRect();
+ return true;
+ }
+ }
+
if( !myGLContext->getCurrentObject() )
{
vp->drawSelectByRect( e->x(), e->y() );
}
/*!
- Completes started operation on mouse event
+ Completes started operation on mouse event, Returns true if operation is considered
+ as completely finished and there is no point in performing other actions after finish
+ the operation.
*/
-void GLViewer_Viewer2d::finishOperations( QMouseEvent* e )
+bool GLViewer_Viewer2d::finishOperations( QMouseEvent* e )
{
GLViewer_ViewPort2d* vp = ( GLViewer_ViewPort2d* )((GLViewer_ViewFrame*)getActiveView())->getViewPort();
{
vp->finishPulling();
updateAll();
- return;
+ // Although operation is finished, FALSE is returned because base class try to
+ // perform selection in this case. In the other case it is impossible to perform
+ // selection of pulled port
+ return false;
}
if( !myGLContext->getCurrentObject() )
{
bool append = bool ( e->modifiers() & GLViewer_Selector::appendKey() );
getSelector()->select( aSelRect, append );
+ return true;
}
}
+
+ return false;
}
/*!
for( myGLContext->InitSelected(); myGLContext->MoreSelected(); myGLContext->NextSelected() )
{
GLViewer_Object* anObject = myGLContext->SelectedObject();
- update = anObject->updateZoom( zoomIn ) || update;
+ if( e->modifiers() & Qt::ControlModifier )
+ update = anObject->updateXZoom( zoomIn ) || update;
+ else
+ update = anObject->updateZoom( zoomIn ) || update;
}
emit wheelZoomChange( zoomIn );
//! Updates started operations on mouse event
virtual bool updateOperations( QMouseEvent* );
//! Completes started operations on mouse event
- virtual void finishOperations( QMouseEvent* );
+ virtual bool finishOperations( QMouseEvent* );
//! Starts any operations on mouse wheel event
virtual void startOperations( QWheelEvent* );
if( w < 1 ) w = 1;
glViewport( 0, 0, w, h);
+ myViewPort->initResize( w, h );
+
if( myStart )
{
myWidth = w;
myHeight = h;
+ myViewPort->fitAll();
myStart = GL_FALSE;
}
- myViewPort->initResize( w, h );
-
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
GLfloat w_c = w / 2., h_c = h / 2.;
#include "GLViewer.h"
+#ifdef WIN32
+#pragma warning( disable:4251 )
+#endif
+
#include <QtOpenGL>
class QFile;
-
class GLViewer_ViewPort2d;
class GLViewer_CoordSystem;
#include <PyConsole_Console.h>
#endif
+#ifdef WIN32
+#include<shlwapi.h>
+#endif
+
#include "LightApp_Application.h"
#include "LightApp_Module.h"
#include "LightApp_DataModel.h"
#include <QMenu>
#include <QProcess>
-#include <utilities.h>
-
#define FIRST_HELP_ID 1000000
#ifndef DISABLE_SALOMEOBJECT
if ( icon.isNull() )
{
icon = modIcon;
- INFOS ( "****************************************************************" << std::endl
+#ifdef DEB
+ cout "****************************************************************" << std::endl
<< "* Icon for " << (*it).toLatin1().constData() << " not found. Using the default one." << std::endl
- << "****************************************************************" << std::endl );
+ << "****************************************************************" << std::endl ;
+#endif
}
icon = Qtx::scaleIcon( icon, iconSize );
modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
//! If there's the one and only module --> activate it automatically
//! TODO: Possible improvement - default module can be taken from preferences
- return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
+ return aModuleNames.count() > 1 ? QString( "" ) : ( aModuleNames.count() ? aModuleNames.first() : "" );
}
/*!On new window slot.*/
QString quote("\"");
anApp.prepend( quote );
anApp.append( quote );
+
+ if ( anApp.isEmpty() || anApp == "\"\"" )
+ {
+ // try to find default browser
+ HRESULT hr;
+ static const int aLen = MAX_PATH + 100;
+ TCHAR szExe[ aLen ];
+ DWORD cchExe = sizeof( TCHAR ) * aLen;
+ if ( SUCCEEDED(hr = AssocQueryString(0, ASSOCSTR_COMMAND,
+ TEXT(".html"), TEXT("open"), szExe, &cchExe)))
+ {
+ anApp = szExe;
+ }
+ }
#endif
QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
aTitle += QString( " - [%1]" ).arg( sName );
}
+ QStringList anInfoList;
+ modules( anInfoList, false );
+
+ LightApp_Module* aModule = ( LightApp_Module* )activeModule();
+ if( aModule && anInfoList.count() == 1 ) // to avoid a conflict between different modules
+ aTitle = aModule->updateDesktopTitle( aTitle );
+
desktop()->setWindowTitle( aTitle );
}
if ( !isLibFound )
{
- INFOS( "****************************************************************" << std::endl
+#ifdef DEB
+ cout "****************************************************************" << std::endl
<< "* Warning: library " << lib.toLatin1().constData() << " cannot be found" << std::endl
<< "* Module " << moduleTitle.toLatin1().constData() << " will not be available in GUI mode" << std::endl
- << "****************************************************************" << std::endl );
+ << "****************************************************************" << std::endl ;
+#endif
}
else if ( !isPythonModule )
return true;
SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
QString* d = ( QString* )ce->data();
if( SUIT_MessageBox::question(0, tr("WRN_WARNING"),
- d ? *d : "",
+ d ? *d : QString( "" ),
SUIT_MessageBox::Yes | SUIT_MessageBox::No,
SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
showPreferences( tr( "PREF_APP" ) );
*/
QString LightApp_Dialog::objectText( const int theId ) const
{
- return myObjects.contains( theId ) ? myObjects[ theId ].myEdit->text() : "";
+ return myObjects.contains( theId ) ? myObjects[ theId ].myEdit->text() : QString( "" );
}
/*!
/*! Constructor.*/
LightApp_Driver::LightApp_Driver()
-: myIsTemp( false )
+: myIsTemp( false ),
+ myCurrPos( 0 ),
+ myCurrBuff( 0 ),
+ myCurrFileIndex( 0 ),
+ myCurrIFile( 0 ),
+ mySizeToBeWritten( 0 ),
+ myFileSizes( 0 ),
+ myFileNameSizes( 0 ),
+ myCurrOFile( 0 ),
+ myNbFilles( 0 )
{
}
/*! Destructor.*/
LightApp_Driver::~LightApp_Driver()
{
+ delete myFileSizes;
+ delete myFileNameSizes;
}
using namespace std;
aFileBufferSize += 4; //Add 4 bytes: a length of the module name
aFileBufferSize += strlen(aModuleName[i])+1;
std::string aName(aModuleName[i]);
- PutFilesToStream(aName, aBuffer[i], aBufferSize[i], isMultiFile);
+ //PutFilesToStream(aName, aBuffer[i], aBufferSize[i], isMultiFile);
aFileBufferSize += 8; //Add 8 bytes: a length of the buffer
aFileBufferSize += aBufferSize[i];
i++;
aCurrentPos += aBufferSize;
// Put buffer to aListOfFiles and set to myMap
- ListOfFiles aListOfFiles = PutStreamToFiles(aBuffer, aBufferSize, isMultiFile);
+ //ListOfFiles aListOfFiles = PutStreamToFiles(aBuffer, aBufferSize, isMultiFile);
+ ListOfFiles aListOfFiles;
SetListOfFiles(aModuleName, aListOfFiles);
delete[] aModuleName;
myMap[aName] = theListOfFiles;
}
-/*!
- Converts files which was created from module <theModuleName> into a byte sequence unsigned char
-*/
-void LightApp_Driver::PutFilesToStream( const std::string& theModuleName, unsigned char*& theBuffer,
- long& theBufferSize, bool theNamesOnly )
-{
- ListOfFiles aFiles = myMap[theModuleName];
- // aFiles must contain temporary directory name in its first item
- // and names of files (relatively the temporary directory) in the others
-
- int i, aLength = aFiles.size() - 1;
- if(aLength <= 0) {
- theBufferSize = 0;
- theBuffer = new unsigned char[theBufferSize];
- return;
- }
- //Get a temporary directory for saved a file
- TCollection_AsciiString aTmpDir(const_cast<char*>(aFiles[0].c_str()));
-
- long aBufferSize = 0;
- long aCurrentPos;
- int aNbFiles = 0;
- int* aFileNameSize= new int[aLength];
- long* aFileSize= new long[aLength];
-
- //Determine the required size of the buffer
- TCollection_AsciiString aFileName;
- for (i = 0; i < aLength; i++) {
- char* aFName = const_cast<char*>(aFiles[i+1].c_str());
- aFileName = aFName;
- //Check if the file exists
- if (!theNamesOnly) { // mpv 15.01.2003: if only file names must be stroed, then size of files is zero
- TCollection_AsciiString aFullPath = aTmpDir + aFileName;
- OSD_Path anOSDPath(aFullPath);
- OSD_File anOSDFile(anOSDPath);
- if(!anOSDFile.Exists()) continue;
-#ifdef WIN32
- ifstream aFile(aFullPath.ToCString(), ios::binary);
-#else
- ifstream aFile(aFullPath.ToCString());
-#endif
- aFile.seekg(0, ios::end);
- aFileSize[i] = aFile.tellg();
- aBufferSize += aFileSize[i]; //Add a space to store the file
- }
- aFileNameSize[i] = strlen(aFName) + 1;
- aBufferSize += aFileNameSize[i]; //Add a space to store the file name
- aBufferSize += (theNamesOnly)?4:12; //Add 4 bytes: a length of the file name,
- // 8 bytes: length of the file itself
- aNbFiles++;
- }
-
- aBufferSize += 4; //4 bytes for a number of the files that will be written to the stream;
- theBuffer = new unsigned char[aBufferSize];
- if(theBuffer == NULL) {
- theBufferSize = 0;
- theBuffer = 0;
- return;
- }
- //Initialize 4 bytes of the buffer by 0
- memset(theBuffer, 0, 4);
- //Copy the number of files that will be written to the stream
- memcpy(theBuffer, &aNbFiles, ((sizeof(int) > 4) ? 4 : sizeof(int)));
-
- aCurrentPos = 4;
-
- for(i = 0; i < aLength; i++) {
- ifstream *aFile;
- if (!theNamesOnly) { // mpv 15.01.2003: we don't open any file if theNamesOnly = true
- TCollection_AsciiString aName(const_cast<char*>(aFiles[i+1].c_str()));
- TCollection_AsciiString aFullPath = aTmpDir + aName;
- OSD_Path anOSDPath(aFullPath);
- OSD_File anOSDFile(anOSDPath);
- if(!anOSDFile.Exists()) continue;
-#ifdef WIN32
- aFile = new ifstream(aFullPath.ToCString(), ios::binary);
-#else
- aFile = new ifstream(aFullPath.ToCString());
-#endif
- }
- //Initialize 4 bytes of the buffer by 0
- memset((theBuffer + aCurrentPos), 0, 4);
- //Copy the length of the file name to the buffer
- memcpy((theBuffer + aCurrentPos), (aFileNameSize + i), ((sizeof(int) > 4) ? 4 : sizeof(int)));
- aCurrentPos += 4;
-
- //Copy the file name to the buffer
- char* aFName = const_cast<char*>(aFiles[i+1].c_str());
- memcpy((theBuffer + aCurrentPos), aFName, aFileNameSize[i]);
- aCurrentPos += aFileNameSize[i];
-
- if (!theNamesOnly) { // mpv 15.01.2003: we don't copy file content to the buffer if !theNamesOnly
- //Initialize 8 bytes of the buffer by 0
- memset((theBuffer + aCurrentPos), 0, 8);
- //Copy the length of the file to the buffer
- memcpy((theBuffer + aCurrentPos), (aFileSize + i), ((sizeof(long) > 8) ? 8 : sizeof(long)));
- aCurrentPos += 8;
-
- aFile->seekg(0, ios::beg);
- aFile->read((char *)(theBuffer + aCurrentPos), aFileSize[i]);
- aFile->close();
- delete(aFile);
- aCurrentPos += aFileSize[i];
- }
- }
- delete[] aFileNameSize;
- delete[] aFileSize;
-
- theBufferSize = aBufferSize;
-}
-
-/*!
- Converts a byte sequence <theBuffer> to files and return list of them
-*/
-LightApp_Driver::ListOfFiles LightApp_Driver::PutStreamToFiles( const unsigned char* theBuffer,
- const long theBufferSize, bool theNamesOnly )
-{
- if(theBufferSize == 0 || theBuffer == 0)
- return ListOfFiles();
-
- // 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<char*>(aDir.c_str()));
-
- long aFileSize, aCurrentPos = 4;
- int i, aFileNameSize, aNbFiles = 0;
-
- //Copy the number of files in the stream
- memcpy(&aNbFiles, theBuffer, sizeof(int));
-
- const int n = aNbFiles + 1;
- ListOfFiles aFiles(n);
- aFiles[0] = aDir;
-
- for(i = 0; i < aNbFiles; i++) {
- //Put a length of the file name to aFileNameSize
- memcpy(&aFileNameSize, (theBuffer + aCurrentPos), ((sizeof(int) > 4) ? 4 : sizeof(int)));
- aCurrentPos += 4;
-
- char *aFileName = new char[aFileNameSize];
- //Put a file name to aFileName
- memcpy(aFileName, (theBuffer + aCurrentPos), aFileNameSize);
- aCurrentPos += aFileNameSize;
-
- //Put a length of the file to aFileSize
- if (!theNamesOnly) {
- memcpy(&aFileSize, (theBuffer + aCurrentPos), ((sizeof(long) > 8) ? 8 : sizeof(long)));
- aCurrentPos += 8;
-
- TCollection_AsciiString aFullPath = aTmpDir + aFileName;
-
-#ifdef WIN32
- ofstream aFile(aFullPath.ToCString(), ios::out | ios::binary);
-#else
- ofstream aFile(aFullPath.ToCString());
-#endif
-
- aFile.write((char *)(theBuffer+aCurrentPos), aFileSize);
- aFile.close();
- aCurrentPos += aFileSize;
- }
- std::string aStrFileName(aFileName);
- aFiles[i+1] = aStrFileName;
- delete[] aFileName;
- }
- return aFiles;
-}
-
/*!
Remove files. First item in <theFiles> is a directory with slash at the end.
Other items are names of files. If <IsDirDeleted> is true,
return aDirString.ToCString();
}
+//=============================================================================
+// Function : PutFilesToFirstStream
+// Purpose :
+//=============================================================================
+bool LightApp_Driver::PutFilesToFirstStream( const std::string& theModuleName, unsigned char*& theBuffer,
+ long& theBufferSize, bool theNamesOnly )
+{
+ myCurrPos = 0;
+ myCurrBuff = 0;
+ myCurrFileIndex = 0;
+ myCurrIFile = 0;
+ mySizeToBeWritten = 0;
+ if ( myFileSizes )
+ {
+ delete[] myFileSizes;
+ myFileSizes = 0;
+ }
+ if ( myFileNameSizes )
+ {
+ delete[] myFileNameSizes;
+ myFileNameSizes = 0;
+ }
+
+ ListOfFiles aFiles = myMap[theModuleName];
+ // aFiles must contain temporary directory name in its first item
+ // and names of files (relatively the temporary directory) in the others
+
+ int i, aLength = aFiles.size() - 1;
+ if(aLength <= 0) {
+ theBufferSize = 0;
+ theBuffer = new unsigned char[theBufferSize];
+ return true;
+ }
+ //Get a temporary directory for saved a file
+ TCollection_AsciiString aTmpDir(const_cast<char*>(aFiles[0].c_str()));
+
+ int aNbFiles = 0;
+ myFileNameSizes = new size_t[aLength];
+ myFileSizes = new size_t[aLength];
+
+ //Determine the required size of the buffer
+ TCollection_AsciiString aFileName;
+ for (i = 0; i < aLength; i++)
+ {
+ char* aFName = const_cast<char*>(aFiles[i+1].c_str());
+ aFileName = aFName;
+ //Check if the file exists
+ if (!theNamesOnly)
+ {
+ TCollection_AsciiString aFullPath = aTmpDir + aFileName;
+ OSD_Path anOSDPath(aFullPath);
+ OSD_File anOSDFile(anOSDPath);
+ if(!anOSDFile.Exists())
+ continue;
+#ifdef WNT
+ ifstream aFile(aFullPath.ToCString(), ios::binary);
+#else
+ ifstream aFile(aFullPath.ToCString());
+#endif
+ aFile.seekg(0, ios::end);
+ myFileSizes[i] = aFile.tellg();
+ mySizeToBeWritten += myFileSizes[i]; //Add a space to store the file
+ }
+ myFileNameSizes[i] = strlen(aFName) + 1;
+ mySizeToBeWritten += myFileNameSizes[i]; //Add a space to store the file name
+ mySizeToBeWritten += (theNamesOnly)?4:12; //Add 4 bytes: a length of the file name,
+ // 8 bytes: length of the file itself
+ aNbFiles++;
+ }
+
+ mySizeToBeWritten += 4; //4 bytes for a number of the files that will be written to the stream;
+
+ size_t aCurrSize = mySizeToBeWritten <= GetMaxBuffSize() ? mySizeToBeWritten : GetMaxBuffSize();
+ theBuffer = new unsigned char[ aCurrSize ];
+ myCurrBuff = theBuffer;
+
+ //Initialize 4 bytes of the buffer by 0
+ memset( theBuffer, 0, 4);
+ //Copy the number of files that will be written to the stream
+ memcpy( theBuffer, &aNbFiles, ((sizeof(int) > 4) ? 4 : sizeof(int)));
+
+ myCurrPos = 4;
+ int aCurrnetBuff = 0;
+
+ for ( myCurrFileIndex = 0; myCurrFileIndex < aLength; myCurrFileIndex++ )
+ {
+ if (!theNamesOnly)
+ { // mpv 15.01.2003: we don't open any file if theNamesOnly = true
+ TCollection_AsciiString aName(const_cast<char*>(aFiles[myCurrFileIndex+1].c_str()));
+ TCollection_AsciiString aFullPath = aTmpDir + aName;
+ OSD_Path anOSDPath(aFullPath);
+ OSD_File anOSDFile(anOSDPath);
+ if(!anOSDFile.Exists()) continue;
+#ifdef WNT
+ myCurrIFile = new ifstream(aFullPath.ToCString(), ios::binary);
+#else
+ myCurrIFile = new ifstream(aFullPath.ToCString());
+#endif
+ }
+
+ //Initialize 4 bytes of the buffer by 0
+ memset( (theBuffer + myCurrPos), 0, 4);
+
+ //Copy the length of the file name to the buffer
+ memcpy((theBuffer + myCurrPos), (myFileNameSizes + myCurrFileIndex), ((sizeof(int) > 4) ? 4 : sizeof(int)));
+ myCurrPos += 4;
+
+ //Copy the file name to the buffer
+ char* aFName = const_cast<char*>(aFiles[myCurrFileIndex+1].c_str());
+ memcpy( myCurrBuff + myCurrPos, aFName, myFileNameSizes[ myCurrFileIndex ] );
+ myCurrPos += myFileNameSizes[myCurrFileIndex];
+
+ if (!theNamesOnly) // mpv 15.01.2003: we don't copy file content to the buffer if !theNamesOnly
+ {
+ //Initialize 8 bytes of the buffer by 0
+ memset( myCurrBuff + myCurrPos, 0, 8 );
+
+ //Copy the length of the file to the buffer
+ memcpy( myCurrBuff + myCurrPos,
+ (unsigned char*)(myFileSizes + myCurrFileIndex), ((sizeof(long) > 8) ? 8 : sizeof(long)));
+ myCurrPos += 8;
+
+ // old code for small files
+ if ( aCurrSize < GetMaxBuffSize() )
+ {
+ myCurrIFile->seekg(0, ios::beg);
+ myCurrIFile->read((char *)(theBuffer + myCurrPos), myFileSizes[myCurrFileIndex]);
+ myCurrIFile->close();
+ delete(myCurrIFile);
+ myCurrIFile = 0;
+ myCurrPos += myFileSizes[myCurrFileIndex];
+ mySizeToBeWritten = 0;
+ }
+ else // new code for big files
+ {
+ myCurrIFile->seekg(0, ios::beg);
+ int aPos = myCurrIFile->tellg();
+ size_t aSizeToRead = GetMaxBuffSize() - myCurrPos;
+ if ( aSizeToRead > myFileSizes[myCurrFileIndex] - myCurrIFile->tellg() )
+ aSizeToRead = myFileSizes[myCurrFileIndex] - myCurrIFile->tellg();
+ myCurrIFile->read((char *)(theBuffer + myCurrPos), aSizeToRead );
+ mySizeToBeWritten -= aSizeToRead - myCurrPos;
+ myCurrPos += aSizeToRead;
+ if ( myCurrPos == GetMaxBuffSize() )
+ {
+ myCurrPos = 0;
+ break;
+ }
+ else // file was saved complitelly
+ {
+ myCurrIFile->close();
+ delete(myCurrIFile);
+ myCurrIFile = 0;
+ }
+ if ( myCurrIFile )
+ aPos = myCurrIFile->tellg();
+ }
+ }
+ }
+
+ if ( aCurrSize < GetMaxBuffSize() )
+ theBufferSize = myCurrPos;
+ else
+ theBufferSize = GetMaxBuffSize();
+
+ return aCurrSize < GetMaxBuffSize();
+}
+
+//=============================================================================
+// Function : HasUnsavedData
+// Purpose :
+//=============================================================================
+bool LightApp_Driver::HasUnsavedData() const
+{
+ return myCurrIFile && mySizeToBeWritten;
+}
+
+//=============================================================================
+// Function : PutFilesToNextStream
+// Purpose :
+//=============================================================================
+bool LightApp_Driver::PutFilesToNextStream( const std::string& theModuleName, unsigned char*& theBuffer,
+ long& theBufferSize, bool theNamesOnly )
+{
+ if ( theNamesOnly || !HasUnsavedData() )
+ return true;
+
+ ListOfFiles aFiles = myMap[ theModuleName ];
+ int aLength = aFiles.size() - 1;
+ if ( aLength <= 0 )
+ return true;
+
+ TCollection_AsciiString aTmpDir(const_cast<char*>(aFiles[0].c_str()));
+
+ size_t aCurrSize = mySizeToBeWritten <= GetMaxBuffSize() ? mySizeToBeWritten : GetMaxBuffSize();
+
+ for ( ; myCurrFileIndex < aLength; myCurrFileIndex++ )
+ {
+ TCollection_AsciiString aName(const_cast<char*>(aFiles[myCurrFileIndex+1].c_str()));
+ TCollection_AsciiString aFullPath = aTmpDir + aName;
+ OSD_Path anOSDPath(aFullPath);
+ OSD_File anOSDFile(anOSDPath);
+ if(!anOSDFile.Exists())
+ continue;
+
+ if ( !myCurrIFile )
+ {
+#ifdef WNT
+ myCurrIFile = new ifstream( aFullPath.ToCString(), ios::binary );
+#else
+ myCurrIFile = new ifstream( aFullPath.ToCString() );
+#endif
+
+ myCurrIFile->seekg(0, ios::beg);
+
+ ////////////
+ //Initialize 4 bytes of the buffer by 0
+ memset( (myCurrBuff + myCurrPos), 0, 4);
+ //Copy the length of the file name to the buffer
+ memcpy((myCurrBuff + myCurrPos), ( myFileNameSizes + myCurrFileIndex ), ((sizeof(int) > 4) ? 4 : sizeof(int)));
+ myCurrPos += 4;
+
+ //Copy the file name to the buffer
+ char* aFName = const_cast<char*>(aFiles[myCurrFileIndex+1].c_str());
+ memcpy( myCurrBuff + myCurrPos, aFName, myFileNameSizes[ myCurrFileIndex ] );
+ myCurrPos += myFileNameSizes[myCurrFileIndex];
+ /////////////
+
+ //Initialize 8 bytes of the buffer by 0
+ memset( myCurrBuff + myCurrPos, 0, 8 );
+
+ //Copy the length of the file to the buffer
+ memcpy( myCurrBuff + myCurrPos,
+ (unsigned char*)(myFileSizes + myCurrFileIndex), ((sizeof(long) > 8) ? 8 : sizeof(long)));
+ myCurrPos += 8;
+ }
+
+ // old code for small files
+ if ( aCurrSize < GetMaxBuffSize() )
+ {
+ //myCurrIFile->seekg(0, ios::beg);
+ size_t aSizeToRead = myFileSizes[myCurrFileIndex] - myCurrIFile->tellg();
+ myCurrIFile->read((char *)(theBuffer + myCurrPos), aSizeToRead );
+ myCurrIFile->close();
+ delete(myCurrIFile);
+ myCurrIFile = 0;
+ myCurrPos += aSizeToRead;
+ mySizeToBeWritten = 0;
+ }
+ else // new code for big files
+ {
+ int aPos = myCurrIFile->tellg();
+ size_t aFileSize = myFileSizes[myCurrFileIndex];
+ size_t aSizeToRead = GetMaxBuffSize() - myCurrPos;
+ if ( aSizeToRead > myFileSizes[myCurrFileIndex] - myCurrIFile->tellg() )
+ aSizeToRead = myFileSizes[myCurrFileIndex] - myCurrIFile->tellg();
+ myCurrIFile->read((char *)(theBuffer + myCurrPos), aSizeToRead );
+ mySizeToBeWritten -= aSizeToRead - myCurrPos;
+ myCurrPos += aSizeToRead;
+ if ( myCurrPos == GetMaxBuffSize() )
+ {
+ myCurrPos = 0;
+ break;
+ }
+ else // file was saved complitelly
+ {
+ myCurrIFile->close();
+ delete(myCurrIFile);
+ myCurrIFile = 0;
+ }
+ if ( myCurrIFile )
+ aPos = myCurrIFile->tellg();
+ }
+ }
+
+ if ( aCurrSize < GetMaxBuffSize() )
+ theBufferSize = myCurrPos - 1;
+ else
+ theBufferSize = GetMaxBuffSize();
+
+ return aCurrSize < GetMaxBuffSize();
+}
+
+//=============================================================================
+// Function : PutFirstStreamToFiles
+// Purpose :
+//=============================================================================
+void LightApp_Driver::PutFirstStreamToFiles( ListOfFiles& theListOfFiles,
+ const unsigned char* theBuffer,
+ const long theBufferSize,
+ bool theNamesOnly )
+{
+ theListOfFiles.resize( 0 );
+ myCurrPos = 0;
+ myCurrOFile = 0;
+ mySizeToBeWritten = 0;
+
+ if ( theBufferSize == 0 || theBuffer == 0 )
+ return;
+
+ delete[] myFileSizes;
+ delete[] myFileNameSizes;
+
+ // 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<char*>(aDir.c_str()));
+
+ myCurrPos = 4;
+
+ //Copy the number of files in the stream
+ memcpy(&myNbFilles, theBuffer, sizeof(int));
+
+ const int n = myNbFilles + 1;
+ theListOfFiles.resize( n );
+ myFileSizes = new size_t[ n ];
+ myFileNameSizes = new size_t[ n ];
+ theListOfFiles[ 0 ] = aDir;
+ myFileSizes[ 0 ] = 0;
+ myFileNameSizes[ 0 ] = 0;
+
+ for( myCurrFileIndex = 1; myCurrFileIndex <= myNbFilles; myCurrFileIndex++)
+ {
+ //Put a length of the file name to myFileNameSizes[ myCurrFileIndex ]
+ memcpy(&myFileNameSizes[ myCurrFileIndex ], (theBuffer + myCurrPos), ((sizeof(int) > 4) ? 4 : sizeof(int)));
+ myCurrPos += 4;
+
+ char *aFileName = new char[ myFileNameSizes[ myCurrFileIndex ] ];
+ //Put a file name to aFileName
+ memcpy(aFileName, (theBuffer + myCurrPos), myFileNameSizes[ myCurrFileIndex ]);
+ myCurrPos += myFileNameSizes[ myCurrFileIndex ];
+
+ //Put a length of the file to myFileSizes
+ if (!theNamesOnly)
+ {
+ memcpy(&myFileSizes[ myCurrFileIndex ], (theBuffer + myCurrPos), ((sizeof(long) > 8) ? 8 : sizeof(long)));
+ myCurrPos += 8;
+
+ TCollection_AsciiString aFullPath = aTmpDir + aFileName;
+
+#ifdef WNT
+ myCurrOFile = new ofstream(aFullPath.ToCString(), ios::out | ios::binary);
+#else
+ myCurrOFile = new ofstream(aFullPath.ToCString());
+#endif
+
+ std::string aStrFileName( aFileName );
+ theListOfFiles[ myCurrFileIndex ] = aStrFileName;
+ delete[] aFileName;
+
+ if ( myFileSizes[ myCurrFileIndex ] <= theBufferSize - myCurrPos )
+ {
+ // old code
+ myCurrOFile->write((char *)(theBuffer+myCurrPos), myFileSizes[ myCurrFileIndex ] );
+ myCurrOFile->close();
+ delete myCurrOFile;
+ myCurrOFile = 0;
+ myCurrPos += myFileSizes[ myCurrFileIndex ];
+ myFileSizes[ myCurrFileIndex ] = 0;
+ }
+ else
+ {
+ // old code for big files
+ size_t aSize = theBufferSize - myCurrPos;
+ myCurrOFile->write((char *)( theBuffer + myCurrPos ), aSize );
+ myFileSizes[ myCurrFileIndex ] -= aSize;
+ myCurrPos = 0;
+ break;
+ }
+ }
+ }
+}
+
+//=============================================================================
+// Function : PutNextStreamToFiles
+// Purpose :
+//=============================================================================
+void LightApp_Driver::PutNextStreamToFiles( ListOfFiles& theListOfFiles,
+ const unsigned char* theBuffer,
+ const long theBufferSize,
+ bool theNamesOnly )
+{
+ if ( theNamesOnly )
+ return;
+
+ std::string aDir = GetTmpDir();
+
+ //Get a temporary directory for saving a file
+ TCollection_AsciiString aTmpDir(const_cast<char*>(aDir.c_str()));
+
+ if ( !myNbFilles )
+ return;
+
+ for( ; myCurrFileIndex <= myNbFilles; myCurrFileIndex++)
+ {
+ if ( !myCurrOFile )
+ {
+ //Put a length of the file name to myFileNameSizes
+ //int myFileNameSizes;
+ memcpy(&myFileNameSizes[ myCurrFileIndex ], (theBuffer + myCurrPos), ((sizeof(int) > 4) ? 4 : sizeof(int)));
+ myCurrPos += 4;
+
+ char *aFileName = new char[ myFileNameSizes[ myCurrFileIndex ] ];
+ //Put a file name to aFileName
+ memcpy(aFileName, (theBuffer + myCurrPos), myFileNameSizes[ myCurrFileIndex ]);
+ myCurrPos += myFileNameSizes[ myCurrFileIndex ];
+
+ std::string aStrFileName( aFileName );
+ theListOfFiles[ myCurrFileIndex ] = aStrFileName;
+
+ //Put a length of the file to myFileSizes
+ if ( theNamesOnly )
+ {
+ delete[] aFileName;
+ continue;
+ }
+
+ memcpy(&myFileSizes[ myCurrFileIndex ], (theBuffer + myCurrPos), ((sizeof(long) > 8) ? 8 : sizeof(long)));
+ myCurrPos += 8;
+
+ TCollection_AsciiString aFullPath = aTmpDir + aFileName;
+
+#ifdef WNT
+ myCurrOFile = new ofstream(aFullPath.ToCString(), ios::out | ios::binary);
+#else
+ myCurrOFile = new ofstream(aFullPath.ToCString());
+#endif
+
+ delete[] aFileName;
+
+ } //if ( !myCurrOFile )
+
+ if ( myFileSizes[ myCurrFileIndex ] <= theBufferSize - myCurrPos )
+ {
+ // old code
+ myCurrOFile->write((char *)(theBuffer+myCurrPos), myFileSizes[ myCurrFileIndex ] );
+ myCurrOFile->close();
+ delete myCurrOFile;
+ myCurrOFile = 0;
+ myCurrPos += myFileSizes[ myCurrFileIndex ];
+ myFileSizes[ myCurrFileIndex ] = 0;
+ }
+ else
+ {
+ // old code for big files
+ size_t aFileSize = myFileSizes[ myCurrFileIndex ];
+ size_t aSize = theBufferSize - myCurrPos;
+ myCurrOFile->write((char *)( theBuffer + myCurrPos ), aSize );
+ myFileSizes[ myCurrFileIndex ] -= aSize;
+ myCurrPos = 0;
+ break;
+ }
+ } // for
+}
#include "vector"
#include "map"
+#include <OSD_File.hxx>
+
#ifdef WIN32
#pragma warning( disable:4251 )
#endif
virtual void ClearDriverContents();
protected:
+ /*
void PutFilesToStream(const std::string& theModuleName, unsigned char*& theBuffer,
long& theBufferSize, bool theNamesOnly = false);
ListOfFiles PutStreamToFiles(const unsigned char* theBuffer,
const long theBufferSize, bool theNamesOnly = false);
+ */
+
+ // New save
+ bool PutFilesToFirstStream( const std::string& theModuleName, unsigned char*& theBuffer,
+ long& theBufferSize, bool theNamesOnly = false );
+ bool PutFilesToNextStream( const std::string& theModuleName, unsigned char*& theBuffer,
+ long& theBufferSize, bool theNamesOnly = false );
+ bool HasUnsavedData() const;
+
+ // New read
+ void PutFirstStreamToFiles( ListOfFiles& theListOfFiles, const unsigned char* theBuffer,
+ const long theBufferSize, bool theNamesOnly = false);
+ void PutNextStreamToFiles( ListOfFiles& theListOfFiles, const unsigned char* theBuffer,
+ const long theBufferSize, bool theNamesOnly = false);
+
+ inline static size_t GetMaxBuffSize();
std::string GetTmpDir();
std::string GetDirFromPath(const std::string& thePath);
private:
bool myIsTemp;
+
+ // reading/writing
+ int myCurrFileIndex;
+
+ // writing
+ size_t myCurrPos;
+ unsigned char* myCurrBuff;
+ ifstream* myCurrIFile;
+ size_t mySizeToBeWritten;
+ size_t* myFileSizes;
+ size_t* myFileNameSizes;
+
+ // reading
+ ofstream* myCurrOFile;
+ long myNbFilles;
};
+inline size_t LightApp_Driver::GetMaxBuffSize()
+{
+ static size_t aValue = 0;
+ if ( !aValue )
+ {
+ char* aVar = getenv( "HDF_BUFFER_SIZE" );
+ if ( aVar )
+ aValue = (size_t)atol( aVar );
+ else
+ aValue = 50000000;
+ }
+
+ return aValue;
+}
+
#endif
//
#include "LightApp_HDFDriver.h"
+#include "HDFexplorer.hxx"
#include "HDFOI.hxx"
// OCCT Includes
for (it = myMap.begin(); it != myMap.end(); ++it, ++tag) {
std::string aName (it->first);
char* aModuleName = const_cast<char*>(aName.c_str());
- unsigned char* aBuffer;
- long aBufferSize;
- PutFilesToStream(aName, aBuffer, aBufferSize, isMultiFile);
-
- //Handle(SALOMEDSImpl_SComponent) sco = itcomponent.Value();
- //TCollection_AsciiString scoid = sco->GetID();
- //hdf_sco_group = new HDFgroup(scoid.ToCString(), hdf_group_datacomponent);
TCollection_AsciiString entry ("0:1:");
entry += TCollection_AsciiString(tag);
hdf_sco_group = new HDFgroup (entry.ToCString(), hdf_group_datacomponent);
hdf_sco_group->CreateOnDisk();
- aHDFSize[0] = aBufferSize;
+ unsigned char* aBuffer;
+ long aBufferSize;
+
+ /*while( LightApp_Driver::HasUnsavedData() )
+ PutFilesToNextStream( aName, aBuffer, aBufferSize, isMultiFile );*/
- hdf_dataset = new HDFdataset ("FILE_STREAM", hdf_sco_group, HDF_STRING, aHDFSize, 1);
+ // first data set
+ TCollection_AsciiString aBaseName( (Standard_CString)"FILE_STREAM" );
+ PutFilesToFirstStream( aName, aBuffer, aBufferSize, isMultiFile );
+ aHDFSize[0] = aBufferSize;
+ hdf_dataset = new HDFdataset( aBaseName.ToCString(), hdf_sco_group, HDF_STRING, aHDFSize, 1);
hdf_dataset->CreateOnDisk();
hdf_dataset->WriteOnDisk(aBuffer); //Save the stream in the HDF file
hdf_dataset->CloseOnDisk();
hdf_dataset = 0; //will be deleted by hdf_sco_group destructor
+ // other data sets
+ int anIndex = 0;
+ while( LightApp_Driver::HasUnsavedData() )
+ {
+ anIndex++;
+ TCollection_AsciiString aDataSetName =
+ aBaseName + TCollection_AsciiString( anIndex );
+ PutFilesToNextStream( aName, aBuffer, aBufferSize, isMultiFile );
+ aHDFSize[0] = aBufferSize;
+ hdf_dataset = new HDFdataset( aDataSetName.ToCString(), hdf_sco_group, HDF_STRING, aHDFSize, 1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk(aBuffer); //Save the stream in the HDF file
+ hdf_dataset->CloseOnDisk();
+ hdf_dataset = 0; //will be deleted by hdf_sco_group destructor
+ }
+
// store multifile state
aHDFSize[0] = 2;
hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group, HDF_STRING, aHDFSize, 1);
hdf_sco_group->OpenOnDisk();
// Read component data
- unsigned char* aStreamFile = NULL;
- int aStreamSize = 0;
- if (hdf_sco_group->ExistInternalObject("FILE_STREAM")) {
- HDFdataset *hdf_dataset = new HDFdataset("FILE_STREAM", hdf_sco_group);
- hdf_dataset->OpenOnDisk();
- aStreamSize = hdf_dataset->GetSize();
- aStreamFile = new unsigned char[aStreamSize];
- if (aStreamFile == NULL) {
- isError = true;
- } else {
- hdf_dataset->ReadFromDisk(aStreamFile);
+ // read first file stream
+ TCollection_AsciiString aBaseName( (Standard_CString)"FILE_STREAM" );
+ ListOfFiles aListOfFiles;
+ for ( int ds = 0; true; ds++ ) {
+ unsigned char* aStreamFile = NULL;
+ int aStreamSize = 0;
+
+ TCollection_AsciiString aDataSetName = aBaseName;
+ if ( ds > 0 )
+ aDataSetName = aBaseName + TCollection_AsciiString( ds );
+
+ if ( hdf_sco_group->ExistInternalObject( aDataSetName.ToCString() ) ) {
+ HDFdataset *hdf_dataset = new HDFdataset( aDataSetName.ToCString(), hdf_sco_group );
+ hdf_dataset->OpenOnDisk();
+ aStreamSize = hdf_dataset->GetSize();
+ aStreamFile = new unsigned char[aStreamSize];
+ if (aStreamFile == NULL) {
+ isError = true;
+ } else {
+ hdf_dataset->ReadFromDisk(aStreamFile);
+ }
+
+ hdf_dataset->CloseOnDisk();
+ hdf_dataset = 0;
+ }
+ else
+ break;
+
+ if ( aStreamFile != NULL )
+ {
+ if ( ds == 0 )
+ PutFirstStreamToFiles( aListOfFiles, aStreamFile, aStreamSize, isMultiFile );
+ else
+ PutNextStreamToFiles( aListOfFiles, aStreamFile, aStreamSize, isMultiFile );
+ delete [] aStreamFile;
}
+ } // for ( int i = 0; true; i++ )
- hdf_dataset->CloseOnDisk();
- hdf_dataset = 0;
- }
+ char* aCompDataType = (char*)(mapEntryName[name].c_str());
+ SetListOfFiles( aCompDataType, aListOfFiles );
HDFdataset *multifile_hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group);
multifile_hdf_dataset->OpenOnDisk();
isASCII = (ASCIIfileState[0] == 'A') ? true : false;
- if (aStreamFile != NULL) {
- // Put buffer to aListOfFiles and set to myMap
- ListOfFiles aListOfFiles = PutStreamToFiles(aStreamFile, aStreamSize, isMultiFile);
- char* aCompDataType = (char*)(mapEntryName[name].c_str());
- SetListOfFiles(aCompDataType, aListOfFiles);
-
- delete [] aStreamFile;
- }
-
hdf_sco_group->CloseOnDisk();
}
}
{
return myOperations.contains( id ) ? myOperations[id] : 0;
}
+
+/*!
+ * \brief Virtual public method called to custom update of the desktop title
+ * \param theTitle - current desktop title
+ * \return Modified desktop title
+*/
+QString LightApp_Module::updateDesktopTitle( const QString& theTitle )
+{
+ return theTitle;
+}
virtual LightApp_Displayer* displayer();
virtual LightApp_Selection* createSelection() const;
+ virtual QString updateDesktopTitle( const QString& );
+ // Custom update desktop title
+
public slots:
virtual bool activateModule( SUIT_Study* );
virtual bool deactivateModule( SUIT_Study* );
select 'subobjects' with given indexes
*/
void LightApp_SelectionMgr::selectObjects( const Handle(SALOME_InteractiveObject)& IObject,
- TColStd_IndexedMapOfInteger theIndex, bool append )
+ const TColStd_IndexedMapOfInteger& theIndex, bool append )
{
SUIT_DataOwnerPtrList aList;
bool modeShift );
void selectObjects( const Handle(SALOME_InteractiveObject)& IObject,
- TColStd_IndexedMapOfInteger theIndex, bool append );
+ const TColStd_IndexedMapOfInteger& theIndex, bool append );
void selectObjects( MapIOOfMapOfInteger theMapIO, bool append );
void selectedSubOwners( MapEntryOfMapOfInteger& theMap );
#ifndef DISABLE_SALOMEOBJECT
#include "SALOME_Actor.h"
#include "SALOME_ListIteratorOfListIO.hxx"
+ #include "LightApp_DataSubOwner.h"
#endif
return myIds;
}
+/*!
+ Sets dataowners ids list.
+*/
+void
+LightApp_SVTKDataOwner
+::SetIds( const TColStd_IndexedMapOfInteger& theIds )
+{
+ myIds = theIds;
+}
+
/*!
Gets selection mode.
*/
for(; anIter.More(); anIter.Next()){
Handle(SALOME_InteractiveObject) anIO = anIter.Value();
if(anIO->hasEntry())
- aList.append(new LightApp_SVTKDataOwner(anIO,aViewMgr->getDesktop()));
+ {
+ LightApp_SVTKDataOwner* anOwner =
+ new LightApp_SVTKDataOwner( anIO, aViewMgr->getDesktop() );
+ TColStd_IndexedMapOfInteger anIndex;
+ aSelector->GetIndex( anIO, anIndex );
+ anOwner->SetIds( anIndex );
+ aList.append( anOwner );
+ }
}
}
}
anAppendList.Append(anIO);
aSelector->AddOrRemoveIndex(anIO,anOwner->GetIds(),false);
- }else if(const LightApp_DataOwner* anOwner = dynamic_cast<const LightApp_DataOwner*>(aDataOwner)){
+ }else if(const LightApp_DataSubOwner* anOwner = dynamic_cast<const LightApp_DataSubOwner*>(aDataOwner)){
Handle(SALOME_InteractiveObject) anIO =
- new SALOME_InteractiveObject(anOwner->entry().toLatin1(),"");
+ new SALOME_InteractiveObject(anOwner->entry().toLatin1(),"");
aSelector->AddIObject(anIO);
anAppendList.Append(anIO);
+ TColStd_IndexedMapOfInteger aMap;
+ aMap.Add( anOwner->index() );
+ aSelector->AddOrRemoveIndex( anIO,aMap, false );
}
}
// To remove IOs, which is not selected.
#include <QObject>
+#ifdef WIN32
+#pragma warning( disable:4251 )
+#endif
+
class SUIT_Desktop;
#ifndef DISABLE_VTKVIEWER
/*!Gets dataowners ids list.*/
const TColStd_IndexedMapOfInteger& GetIds() const;
+ /*!Sets dataowners ids list.*/
+ void SetIds( const TColStd_IndexedMapOfInteger& );
+
/*!Gets selection mode.*/
Selection_Mode GetMode() const;
Plot2d_ViewModel.h \
Plot2d_ViewWindow.h \
Plot2d_SetupCurveDlg.h \
+ Plot2d_SetupCurvesDlg.h \
Plot2d_ToolTip.h
dist_libPlot2d_la_SOURCES = \
Plot2d_ViewModel.cxx \
Plot2d_ViewWindow.cxx \
Plot2d_SetupCurveDlg.cxx \
+ Plot2d_SetupCurvesDlg.cxx \
Plot2d_ToolTip.cxx
MOC_FILES = \
Plot2d_ViewModel_moc.cxx \
Plot2d_ViewWindow_moc.cxx \
Plot2d_SetupCurveDlg_moc.cxx \
+ Plot2d_SetupCurvesDlg_moc.cxx \
Plot2d_ToolTip_moc.cxx
nodist_libPlot2d_la_SOURCES = $(MOC_FILES)
resources/plot2d_points.png \
resources/plot2d_settings.png \
resources/plot2d_splines.png \
- resources/plot2d_zoom.png
+ resources/plot2d_zoom.png \
+ resources/plot2d_curves_settings.png \
+ resources/plot2d_minus.png
nodist_salomeres_DATA = \
Plot2d_images.qm \
myMarker( Plot2d::Circle ),
myLine( Plot2d::Solid ),
myLineWidth( 0 ),
- myYAxis( QwtPlot::yLeft )
+ myYAxis( QwtPlot::yLeft ),
+ myNbMarkers( 1 )
{
}
myLine = curve.getLine();
myLineWidth = curve.getLineWidth();
myPoints = curve.getPointList();
+ myNbMarkers = curve.getNbMarkers();
}
/*!
myLine = curve.getLine();
myLineWidth = curve.getLineWidth();
myPoints = curve.getPointList();
+ myNbMarkers = curve.getNbMarkers();
return *this;
}
return myMarker;
}
+/*!
+ Sets number of markers per step ( and resets AutoAssign flag ).
+*/
+void Plot2d_Curve::setNbMarkers( const int nbMarkers )
+{
+ myNbMarkers = nbMarkers;
+ myAutoAssign = false;
+}
+
+/*!
+ Gets number of markers per step ( and resets AutoAssign flag ).
+*/
+int Plot2d_Curve::getNbMarkers() const
+{
+ return myNbMarkers;
+}
+
/*!
Sets curve's line type and width ( and resets AutoAssign flag )
NOTE : A line width of 0 will produce a 1 pixel wide line using a fast algorithm for diagonals.
return aMinX;
}
+/*!
+ Gets curve's maxiaml abscissa
+*/
+double Plot2d_Curve::getMaxX() const
+{
+ QList<Plot2d_Point>::const_iterator aIt;
+ double aMaxX = -1e150;
+ //int aCurrent = 0;
+ for(aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt) {
+ if ( (*aIt).x > aMaxX )
+ aMaxX = (*aIt).x;
+ }
+ return aMaxX;
+}
+
/*!
Gets curve's minimal ordinate
*/
return aMinY;
}
+/*!
+ Gets curve's maximal ordinate
+*/
+double Plot2d_Curve::getMaxY() const
+{
+ QList<Plot2d_Point>::const_iterator aIt;
+ double aMaxY = -1e150;
+ //int aCurrent = 0;
+ for(aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt) {
+ if ( (*aIt).y > aMaxY )
+ aMaxY = (*aIt).y;
+ }
+ return aMaxY;
+}
+
/*!
Changes text assigned to point of curve
\param ind -- index of point
void setMarker( Plot2d::MarkerType );
Plot2d::MarkerType getMarker() const;
+ void setNbMarkers( const int );
+ int getNbMarkers() const;
+
void setLine( Plot2d::LineType, const int = 0 );
Plot2d::LineType getLine() const;
int getLineWidth() const;
// non-positive X/Y coordinate
double getMinX() const;
double getMinY() const;
+ // Protection against QwtCurve::drawLines() bug in Qwt 0.4.x:
+ // sometimes it crashes (FPE) if draws curve with big abciss or ordinate cooridates
+ // after curve with small values
+ double getMaxX() const;
+ double getMaxY() const;
protected:
bool myAutoAssign;
QString myVerUnits;
QColor myColor;
Plot2d::MarkerType myMarker;
+ int myNbMarkers;
Plot2d::LineType myLine;
int myLineWidth;
QwtPlot::Axis myYAxis;
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// 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
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// SALOME Plot2d : implementation of desktop and GUI kernel
+//
+// File : Plot2d_SetupCurvesDlg.cxx
+// Author : Sergey LITONIN
+
+#include "Plot2d_SetupCurvesDlg.h"
+#include <QtxGroupBox.h>
+#include <qtablewidget.h>
+#include <qtoolbutton.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+#include <qlayout.h>
+#include <qpushbutton.h>
+#include <qfontmetrics.h>
+#include <qcolordialog.h>
+
+#include <qpen.h>
+#include <qwt_symbol.h>
+#include <Plot2d_Curve.h>
+#include <SUIT_MessageBox.h>
+#include <qheaderview.h>
+#include <qcombobox.h>
+#include <qset.h>
+#include "Plot2d.h"
+#include <qevent.h>
+#include <qpainter.h>
+
+#define PIXMAP_COL 0
+#define TEXT_COL 1
+#define MARKER_COL 2
+#define COLOR_COL 3
+#define NB_MARKERS_COL 4
+
+
+/*!
+ \class Plot2d_SetupCurvesDlg::PixmapWg
+ \internal
+ \brief This class is derived from QWidget is intended for drawing curves symbol
+ inside its area. It contains QwtSymbol as its internal field and delegates paint
+ event to it for drawing
+*/
+class Plot2d_SetupCurvesDlg::PixmapWg : public QWidget
+{
+public:
+ PixmapWg( QWidget* theParent );
+ virtual ~PixmapWg();
+
+ void setColor( const QColor& );
+ void setMarkerType( const int );
+
+protected:
+ virtual void paintEvent( QPaintEvent * event );
+
+private:
+ QwtSymbol mySymbol;
+};
+
+Plot2d_SetupCurvesDlg::PixmapWg::PixmapWg( QWidget* theParent )
+: QWidget( theParent )
+{
+ mySymbol.setSize( QSize( 8, 8 ) );
+ mySymbol.setStyle( QwtSymbol::NoSymbol );
+}
+
+Plot2d_SetupCurvesDlg::PixmapWg::~PixmapWg()
+{
+
+}
+
+//=============================================================================
+// Function : setColor
+// Purpose :
+//=============================================================================
+void Plot2d_SetupCurvesDlg::PixmapWg::setColor( const QColor& theColor )
+{
+ mySymbol.setBrush( QBrush( theColor ) );
+ mySymbol.setPen( QPen( theColor ) );
+}
+
+//=============================================================================
+// Function : setMarkerType
+// Purpose :
+//=============================================================================
+void Plot2d_SetupCurvesDlg::PixmapWg::setMarkerType( const int theType )
+{
+ QwtSymbol::Style aStyle = QwtSymbol::NoSymbol;
+ switch( theType )
+ {
+ case Plot2d::Circle : aStyle = QwtSymbol::Ellipse; break;
+ case Plot2d::Rectangle: aStyle = QwtSymbol::Rect; break;
+ case Plot2d::Diamond : aStyle = QwtSymbol::Diamond; break;
+ case Plot2d::DTriangle: aStyle = QwtSymbol::DTriangle; break;
+ case Plot2d::UTriangle: aStyle = QwtSymbol::UTriangle; break;
+ case Plot2d::LTriangle: aStyle = QwtSymbol::LTriangle; break;
+ case Plot2d::RTriangle: aStyle = QwtSymbol::RTriangle; break;
+ case Plot2d::Cross : aStyle = QwtSymbol::Cross; break;
+ case Plot2d::XCross : aStyle = QwtSymbol::XCross; break;
+ }
+
+ mySymbol.setStyle( aStyle );
+}
+
+//=============================================================================
+// Function : paint
+// Purpose :
+//=============================================================================
+void Plot2d_SetupCurvesDlg::PixmapWg::paintEvent( QPaintEvent* event )
+{
+ QRect r = event->rect();
+ /*int rm, lm, tm, bm;
+ if ( r.width() > 8 )
+ {
+ rm = ( r.width() - 8 ) / 2;
+ lm = r.width() - 8 - rm;
+ }
+ if ( r.height() > 8 )
+ {
+ tm = ( r.height() - 8 ) / 2;
+ bm = r.height() - 8 - tm;
+ }
+
+ r.setLeft( r.left() + lm );
+ r.setRight( r.right() - rm );
+ r.setTop( r.top() + tm );
+ r.setBottom( r.bottom() - bm );*/
+
+ QPainter p( this );
+ mySymbol.draw( &p, r.center() );
+}
+
+/*!
+ \brief Constructor
+ \param theParent parent widget
+*/
+Plot2d_SetupCurvesDlg::Plot2d_SetupCurvesDlg( QWidget* theParent )
+: QtxDialog( theParent, true, false, QtxDialog::OKCancel )
+{
+ SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+ setWindowTitle( tr( "SETUP_CURVES" ) );
+
+ QFrame* aMainFrame = mainFrame();
+ myGrp = new QtxGroupBox( aMainFrame );
+ myGrp->setTitle( tr( "PARAMETERS" ) );
+ QVBoxLayout* aLay = new QVBoxLayout( myGrp );
+ aLay->setMargin( 0 );
+
+ // Create table
+
+ myTable = new QTableWidget( myGrp );
+ aLay->addWidget( myTable );
+
+ myTable->setRowCount( 0 );
+ myTable->setColumnCount( 5 );
+
+ QStringList aLabels;
+ aLabels.append( tr( "FIG" ) );
+ aLabels.append( tr( "TEXT" ) );
+ aLabels.append( tr( "MARKER" ) );
+ aLabels.append( tr( "COLOR" ) );
+ aLabels.append( tr( "NB_MARKERS" ) );
+ myTable->setHorizontalHeaderLabels( aLabels );
+ myTable->verticalHeader()->hide();
+ myTable->setSelectionMode( QTableWidget::NoSelection );
+
+ QComboBox* aCombo = new QComboBox( 0 );
+ myTable->verticalHeader()->setDefaultSectionSize( aCombo->sizeHint().height() );
+ delete aCombo;
+
+ //myTable->setLeftMargin( 0 );
+ int l, t, r, b;
+ myTable->getContentsMargins ( &l, &t, &r, &b );
+ myTable->setContentsMargins ( 0, t, r, b );
+
+ myTable->horizontalHeader()->setResizeMode( PIXMAP_COL, QHeaderView::Fixed );
+ myTable->horizontalHeader()->setResizeMode( TEXT_COL, QHeaderView::Fixed );
+ myTable->horizontalHeader()->setResizeMode( MARKER_COL, QHeaderView::Fixed );
+ myTable->horizontalHeader()->setResizeMode( COLOR_COL, QHeaderView::Fixed );
+ myTable->horizontalHeader()->setResizeMode( NB_MARKERS_COL, QHeaderView::Fixed );
+ myTable->horizontalHeader()->setHighlightSections( false );
+
+ // Minus button
+ QPixmap minusPix = aResMgr->loadPixmap( "Plot2d", tr( "ICON_MINUS" ) );
+ myRemoveBtn = new QToolButton( 0 );
+ myRemoveBtn->setIcon( minusPix );
+ myRemoveBtn->setFixedSize( minusPix.size() /*+ QSize( 2, 2 )*/ );
+ myGrp->insertTitleWidget( myRemoveBtn );
+
+ QVBoxLayout* aMainLay = new QVBoxLayout( aMainFrame );
+ aMainLay->setMargin( 5 );
+ aMainLay->addWidget( myGrp );
+
+ connect( myRemoveBtn, SIGNAL( clicked() ), SLOT( onRemove() ) );
+ connect( myTable, SIGNAL( valueChanged( int, int ) ), SLOT( onValueChanged( int, int ) ) );
+
+ setButtonPosition( Right, Cancel );
+}
+
+/*!
+ \brief Destructor
+*/
+Plot2d_SetupCurvesDlg::~Plot2d_SetupCurvesDlg()
+{
+}
+
+/*!
+ \brief Insert combo-box widget in specified cell
+ \param theRow row
+ \param theCol column
+ \param theItems list of combo-box items
+ \param theCurrItem current combo-box item
+*/
+void Plot2d_SetupCurvesDlg::setCombo( const int theRow,
+ const int theCol,
+ const QStringList& theItems,
+ const int theCurrItem,
+ const int theWidth )
+{
+ QComboBox* aCombo = new QComboBox( myTable );
+ aCombo->addItems( theItems );
+ aCombo->setCurrentIndex( theCurrItem );
+ if ( theWidth > 0 )
+ aCombo->setFixedWidth( theWidth );
+ myTable->setCellWidget( theRow, theCol, aCombo );
+ connect( aCombo, SIGNAL( activated( int ) ), SLOT( onMarkerType() ) );
+}
+
+/*!
+ \brief Sets text in specified cell
+ \param theRow row
+ \param theCol column
+ \param theText text
+*/
+void Plot2d_SetupCurvesDlg::setText( const int theRow,
+ const int theCol,
+ const QString& theText )
+{
+ QTableWidgetItem* anItem = myTable->item( theRow, theCol );
+ if ( !anItem )
+ {
+ anItem = new QTableWidgetItem( theText );
+ myTable->setItem( theRow, theCol, anItem );
+ }
+ else
+ anItem->setText( theText );
+}
+
+//=============================================================================
+// Function : SetParameters
+// Purpose :
+//=============================================================================
+void Plot2d_SetupCurvesDlg::SetParameters( const QVector< int >& theMarker,
+ const QVector< QString >& theText,
+ const QVector< QColor >& theColor,
+ const QVector< int >& theNbMarkers )
+{
+ int nbRows = qMax( qMax( theMarker.size(), theText.size()),
+ qMax( theColor.size(), theNbMarkers.size() ) );
+
+ myTable->setRowCount( nbRows );
+
+ const QStringList& aMarkers = getMarkers();
+
+ QFontMetrics fm( myTable->font() );
+ int aTextLength = 0;
+
+ // calculate width of combo-box
+ QStringList::const_iterator anIter;
+ int strWidth = 0;
+ for ( anIter = aMarkers.begin(); anIter != aMarkers.end(); ++anIter )
+ strWidth = qMax( strWidth, fm.width( *anIter ) );
+ strWidth += 20;
+
+ for ( int i = 0; i < nbRows; i++ )
+ {
+ // Pixmap
+ PixmapWg* aPixWg = new PixmapWg( myTable ) ;
+ myTable->setCellWidget( i, PIXMAP_COL, aPixWg );
+
+ // Marker type
+ setCombo( i, MARKER_COL, aMarkers, theMarker[ i ]/*, strWidth*/ );
+
+ // Text
+
+ setText( i, TEXT_COL, theText[ i ] );
+ aTextLength = qMax( aTextLength, fm.width( theText[ i ] ) );
+
+ // Color
+ QPushButton* aBtn = new QPushButton( myTable );
+ myTable->setCellWidget( i, COLOR_COL, aBtn );
+ setColor( aBtn, theColor[ i ] );
+ connect( aBtn, SIGNAL( clicked() ), SLOT( onColorBtn() ) );
+
+ // Nb markers
+ setText( i, NB_MARKERS_COL, QString( "%1" ).arg( theNbMarkers[ i ] ) );
+ }
+
+ myTable->setColumnWidth( PIXMAP_COL, 24 );
+ myTable->setColumnWidth( TEXT_COL, aTextLength + 10 );
+ myTable->setColumnWidth( MARKER_COL, strWidth + 10 );
+ myTable->setColumnWidth( COLOR_COL, fm.width( tr( "COLOR" ) ) + 10 );
+ myTable->setColumnWidth( NB_MARKERS_COL, fm.width( tr( "NB_MARKERS" ) ) + 10 );
+ int aWidth = myTable->columnWidth( PIXMAP_COL ) + myTable->columnWidth( TEXT_COL )+
+ myTable->columnWidth( MARKER_COL ) + myTable->columnWidth( COLOR_COL ) +
+ myTable->columnWidth( NB_MARKERS_COL );
+
+ QFrame* aWg = (QFrame*)myTable->viewport()->parentWidget();
+
+ int fw = aWg->frameWidth();
+ int lw = aWg->lineWidth();
+ int mlw = aWg->midLineWidth();
+ aWg->setFixedWidth( aWidth + 2 * fw );
+
+ myRemovedIndexes.clear();
+
+ updatePixmap( -1 );
+}
+
+//=============================================================================
+// Function : GetParameters
+// Purpose :
+//=============================================================================
+void Plot2d_SetupCurvesDlg::GetParameters( QVector< int >& theMarkers,
+ QVector< QString >& theTexts,
+ QVector< QColor >& theColors,
+ QVector< int >& theNbMarkers ) const
+{
+ int nbRows = myTable->rowCount();
+
+ theMarkers.resize( nbRows );
+ theTexts.resize( nbRows );
+ theColors.resize( nbRows );
+ theNbMarkers.resize( nbRows );
+
+ for ( int i = 0; i < nbRows; i++ )
+ {
+ // Marker type
+ QComboBox* aCombo = dynamic_cast<QComboBox*>( myTable->cellWidget( i, MARKER_COL ) );
+ theMarkers[ i ] = aCombo ? aCombo->currentIndex() : -1;
+
+ // Text
+ QTableWidgetItem* it = myTable->item( i, TEXT_COL );
+ theTexts[ i ] = it ? it->text() : "";
+
+ // Color
+ QColor aColor;
+ QPushButton* aBtn = dynamic_cast< QPushButton* >( myTable->cellWidget( i, COLOR_COL ) );
+ if ( aBtn )
+ aColor = aBtn->palette().color( aBtn->backgroundRole() );
+
+ theColors[ i ] = aColor;
+
+ // Nb markers
+ it = myTable->item( i, NB_MARKERS_COL );
+ QString aStr = it ? it->text() : "";
+ bool isOk = false;
+ int nbMarkers = aStr.toInt( &isOk );
+ if ( isOk )
+ theNbMarkers[ i ] = nbMarkers;
+ else
+ theNbMarkers[ i ] = -1;
+ }
+}
+
+//=============================================================================
+// Function : GetRemovedIndexes
+// Purpose :
+//=============================================================================
+const QList< int >& Plot2d_SetupCurvesDlg::GetRemovedIndexes() const
+{
+ return myRemovedIndexes;
+}
+
+//=============================================================================
+// Function : acceptData
+// Purpose :
+//=============================================================================
+bool Plot2d_SetupCurvesDlg::acceptData() const
+{
+ ((Plot2d_SetupCurvesDlg*)this)->setButtonFocus( OK );
+ int nbRows = myTable->rowCount();
+ for ( int i = 0; i < nbRows; i++ )
+ {
+ QTableWidgetItem* it = myTable->item( i, NB_MARKERS_COL );
+ QString aStr = it ? it->text() : "";
+ bool isOk = false;
+ int nbMarkers = aStr.toInt( &isOk );
+ if ( !isOk || nbMarkers<= 0 )
+ {
+ SUIT_MessageBox::information( (QWidget*)this, tr( "PLOT2D_INSUFFICIENT_DATA" ),
+ tr( "PLOT2D_ENTER_VALID_DATA" ), tr( "BUT_OK" ) );
+ return false;
+ }
+ }
+
+ return true;
+}
+
+//=============================================================================
+// Function : getMarkers
+// Purpose :
+//=============================================================================
+const QStringList& Plot2d_SetupCurvesDlg::getMarkers() const
+{
+ static QStringList aList;
+
+ if ( aList.isEmpty() )
+ {
+ aList.append( tr( "NONE_MARKER_LBL" ) );
+ aList.append( tr( "CIRCLE_MARKER_LBL" ) );
+ aList.append( tr( "RECTANGLE_MARKER_LBL" ) );
+ aList.append( tr( "DIAMOND_MARKER_LBL" ) );
+ aList.append( tr( "DTRIANGLE_MARKER_LBL" ) );
+ aList.append( tr( "UTRIANGLE_MARKER_LBL" ) );
+ aList.append( tr( "LTRIANGLE_MARKER_LBL" ) );
+ aList.append( tr( "RTRIANGLE_MARKER_LBL" ) );
+ aList.append( tr( "CROSS_MARKER_LBL" ) );
+ aList.append( tr( "XCROSS_MARKER_LBL" ) );
+ }
+
+ return aList;
+}
+
+//=============================================================================
+// Function : onRemove
+// Purpose :
+//=============================================================================
+void Plot2d_SetupCurvesDlg::onRemove( )
+{
+ QList< int > toRemove;
+
+ int aCurrRow = myTable->currentRow();
+ int aCurrCol = myTable->currentColumn();
+
+ // get selected rows
+ QSet< int > aSelRows;
+ QList<QTableWidgetSelectionRange> aRegs = myTable->selectedRanges();
+ QList<QTableWidgetSelectionRange>::iterator selIter;
+ for ( selIter = aRegs.begin(); selIter != aRegs.end(); ++selIter )
+ {
+ const QTableWidgetSelectionRange& aReg = *selIter;
+ for ( int i = aReg.topRow(), n = aReg.bottomRow(); i < n; i++ )
+ aSelRows.insert( i );
+ }
+
+ int i, n;
+ for ( i = 0, n = myTable->rowCount(); i < n; i++ )
+ {
+ if ( aSelRows.contains( i ) || aCurrRow == i )
+ toRemove.append( i );
+ }
+
+ if ( !toRemove.count() )
+ return;
+
+ int nbRemoved = 0;
+ QList< int >::iterator anIter;
+ for ( anIter = toRemove.begin(); anIter != toRemove.end(); ++anIter )
+ {
+ int aRow = *anIter - nbRemoved;
+ myTable->removeRow( aRow );
+ myRemovedIndexes.append( aRow );
+ nbRemoved++;
+ }
+
+ int nbRows = myTable->rowCount();
+ if ( aCurrRow < nbRows && aCurrRow >= 0 && aCurrCol >= 0 )
+ myTable->setCurrentCell( aCurrRow, aCurrCol );
+ else if ( nbRows > 0 && aCurrCol >= 0 )
+ myTable->setCurrentCell( nbRows - 1, aCurrCol );
+}
+
+//=============================================================================
+// Function : onColorBtn
+// Purpose :
+//=============================================================================
+void Plot2d_SetupCurvesDlg::onColorBtn()
+{
+ QObject* aSender = (QObject*)sender();
+ if ( !aSender )
+ return;
+
+ QPushButton* aBtn = dynamic_cast< QPushButton* >( aSender );
+ if ( !aBtn )
+ return;
+
+ QColor anOldColor = aBtn->palette().color( aBtn->backgroundRole() );
+ QColor aNewColor = QColorDialog::getColor( anOldColor, this );
+ if ( !aNewColor.isValid() )
+ return;
+
+ setColor( aBtn, aNewColor );
+
+ for ( int i = 0, n = myTable->rowCount(); i < n; i++ )
+ {
+ QWidget* aWg = myTable->cellWidget( i, COLOR_COL );
+ if ( aWg == aBtn )
+ {
+ updatePixmap( i );
+ break;
+ }
+ }
+}
+
+//=============================================================================
+// Function : onColorBtn
+// Purpose :
+//=============================================================================
+void Plot2d_SetupCurvesDlg::onMarkerType()
+{
+ QObject* aSender = (QObject*)sender();
+ if ( !aSender )
+ return;
+
+ QComboBox* aCombo = dynamic_cast< QComboBox* >( aSender );
+ if ( !aCombo )
+ return;
+
+ for ( int i = 0, n = myTable->rowCount(); i < n; i++ )
+ {
+ QWidget* aWg = myTable->cellWidget( i, MARKER_COL );
+ if ( aWg == aCombo )
+ {
+ updatePixmap( i );
+ break;
+ }
+ }
+}
+
+//=============================================================================
+// Function : updatePixmap
+// Purpose :
+//=============================================================================
+void Plot2d_SetupCurvesDlg::updatePixmap( const int theRow )
+{
+ QList< int > aRows;
+ if ( theRow < 0 )
+ {
+ for ( int i = 0, n = myTable->rowCount(); i < n; i++ )
+ aRows.append( i );
+ }
+ else
+ aRows.append( theRow );
+
+ QList< int >::iterator anIter;
+ for ( anIter = aRows.begin(); anIter != aRows.end(); ++anIter )
+ {
+ int r = *anIter;
+ PixmapWg* aWg = dynamic_cast<PixmapWg*>( myTable->cellWidget( r, PIXMAP_COL ) );
+ if ( aWg )
+ {
+ // Marker type
+ QComboBox* aCombo = dynamic_cast<QComboBox*>( myTable->cellWidget( r, MARKER_COL ) );
+ int aMType = aCombo ? aCombo->currentIndex() : Plot2d::None;
+ aWg->setMarkerType( aMType );
+
+ // Color
+ QColor aColor;
+ QPushButton* aBtn = dynamic_cast< QPushButton* >( myTable->cellWidget( r, COLOR_COL ) );
+ if ( aBtn )
+ {
+ aColor = aBtn->palette().color( aBtn->backgroundRole() );
+ aWg->setColor( aColor );
+ }
+
+ aWg->repaint();
+ }
+ }
+}
+
+//=============================================================================
+// Function : onValueChanged
+// Purpose :
+//=============================================================================
+void Plot2d_SetupCurvesDlg::onValueChanged( int theRow, int theCol )
+{
+ if ( theCol == COLOR_COL || theCol == MARKER_COL )
+ updatePixmap( theRow );
+}
+
+//=============================================================================
+// Function : setColor
+// Purpose :
+//=============================================================================
+void Plot2d_SetupCurvesDlg::setColor( QPushButton* theBtn, const QColor& theColor ) const
+{
+ QPalette aPal = theBtn->palette();
+ aPal.setColor( theBtn->backgroundRole(), theColor );
+ theBtn->setPalette( aPal );
+
+ /*theBtn->setPaletteBackgroundColor( theColor );
+
+ QPalette aPalette = theBtn->palette();
+ aPalette.setColor( QColorGroup::Midlight, theColor );
+ theBtn->setPalette( aPalette );*/
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// 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
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// SALOME Plot2d : implementation of desktop and GUI kernel
+//
+// File : Plot2d_SetupCurvesDlg.h
+// Author : Sergey LITONIN
+
+#ifndef PLOT2D_SETUPCURVESDLG_H
+#define PLOT2D_SETUPCURVESDLG_H
+
+#include "Plot2d.h"
+#include <QtxDialog.h>
+#include <qvector.h>
+#include <qlist.h>
+
+class QtxGroupBox;
+class QTableWidget;
+class QwtLegend;
+class QToolButton;
+
+#if defined WIN32
+#pragma warning( disable: 4251 )
+#endif
+
+/*!
+ \class Plot2d_SetupCurvesDlg
+ Dialog box for setup Plot2d curves parameters
+*/
+
+class PLOT2D_EXPORT Plot2d_SetupCurvesDlg : public QtxDialog
+{
+ Q_OBJECT
+
+ class PixmapWg;
+
+public:
+ Plot2d_SetupCurvesDlg( QWidget* theParent = 0 );
+ virtual ~Plot2d_SetupCurvesDlg();
+
+ void SetParameters( const QVector< int >& theMarker,
+ const QVector< QString >& theText,
+ const QVector< QColor >& theColor,
+ const QVector< int >& theNbMarkers );
+
+ void GetParameters( QVector< int >& theMarker,
+ QVector< QString >& theText,
+ QVector< QColor >& theColor,
+ QVector< int >& theNbMarkers ) const;
+
+ const QList< int >& GetRemovedIndexes() const;
+
+protected:
+
+ virtual bool acceptData() const;
+
+private slots:
+
+ void onRemove();
+ void onColorBtn();
+ void onValueChanged( int, int );
+ void onMarkerType();
+
+private:
+
+ const QStringList& getMarkers() const;
+ void updatePixmap( const int theRow );
+ void setColor( QPushButton* theBtn, const QColor& theColor ) const;
+ void setCombo( const int theRow,
+ const int theCol,
+ const QStringList& theItems,
+ const int theCurrItem = 0,
+ const int theWidth = -1 );
+ void setText( const int theRow,
+ const int theCol,
+ const QString& theText );
+private:
+
+ QtxGroupBox* myGrp;
+ QTableWidget* myTable;
+ QToolButton* myRemoveBtn;
+ QList< int > myRemovedIndexes;
+};
+
+#endif
+
+
+
+
+
#include "Plot2d_Prs.h"
#include "Plot2d_Curve.h"
+#include "Plot2d_SetupCurvesDlg.h"
#include "Plot2d_FitDataDlg.h"
#include "Plot2d_ViewWindow.h"
#include "Plot2d_SetupViewDlg.h"
#include <qwt_math.h>
#include <qwt_plot_canvas.h>
#include <qwt_scale_div.h>
-#include <qwt_plot_curve.h>
#include <qwt_plot_grid.h>
#include <qwt_scale_engine.h>
#include <qwt_plot_zoomer.h>
#include <qprinter.h>
#include <qwt_legend.h>
+#include <qwt_painter.h>
#define DEFAULT_LINE_WIDTH 0 // (default) line width
#define DEFAULT_MARKER_SIZE 9 // default marker size
"................................"};
+QString Plot2d_ViewFrame::myPrefTitle = "";
+QString Plot2d_ViewFrame::myPrefXTitle = "";
+QString Plot2d_ViewFrame::myPrefYTitle = "";
+
+bool Plot2d_ViewFrame::myPrefTitleChangedByUser = false;
+bool Plot2d_ViewFrame::myXPrefTitleChangedByUser = false;
+bool Plot2d_ViewFrame::myYPrefTitleChangedByUser = false;
+
/*!
Constructor
*/
myXGridMinorEnabled( false ), myYGridMinorEnabled( false ), myY2GridMinorEnabled( false ),
myXGridMaxMajor( 8 ), myYGridMaxMajor( 8 ), myY2GridMaxMajor( 8 ),
myXGridMaxMinor( 5 ), myYGridMaxMinor( 5 ), myY2GridMaxMinor( 5 ),
- myXMode( 0 ), myYMode( 0 ), mySecondY( false )
+ myXMode( 0 ), myYMode( 0 ), mySecondY( false ),
+ myTitleAutoUpdate( true ), myXTitleAutoUpdate( true ), myYTitleAutoUpdate( true ),
+ myTitleChangedByUser( false ), myXTitleChangedByUser( false ), myYTitleChangedByUser( false )
{
setObjectName( title );
/* Plot 2d View */
getCurves( clist );
for ( int i = 0; i < (int)clist.count(); i++ ) {
updateCurve( clist.at( i ), false );
+ emit curveDisplayed( clist.at( i ) );
}
myPlot->replot();
}
*/
void Plot2d_ViewFrame::EraseAll()
{
+ CurveDict::iterator it = myPlot->getCurves().begin();
+ for ( ; it != myPlot->getCurves().end(); it++ )
+ emit curveErased( it.value() );
+
myPlot->clear();
myPlot->getCurves().clear();
myPlot->replot();
int newYMode = resMgr->integerValue( "Plot2d", "VerScaleMode", myYMode );
newYMode = qMax( 0, qMin( 1, newYMode ) );
setVerScaleMode( newYMode, false );
+
+ myTitle = myPrefTitle;
+ myXTitle = myPrefXTitle;
+ myYTitle = myPrefYTitle;
}
/*!
}
resMgr->setValue( "Plot2d", "VerScaleMode", myYMode );
+
+ if ( myTitleChangedByUser )
+ {
+ myPrefTitle = myTitle;
+ myPrefTitleChangedByUser = true;
+ }
+ if ( myXTitleChangedByUser )
+ {
+ myPrefXTitle = myXTitle;
+ myXPrefTitleChangedByUser = true;
+ }
+ if ( myYTitleChangedByUser )
+ {
+ myPrefYTitle = myYTitle;
+ myYPrefTitleChangedByUser = true;
+ }
}
/*!
updateCurve( curve, update );
}
else {
- QwtPlotCurve* aPCurve = new QwtPlotCurve( curve->getVerTitle() );
+ QwtPlotCurve* aPCurve = new Plot2d_PlotCurve( curve->getVerTitle() );
aPCurve->attach( myPlot );
//myPlot->setCurveYAxis(curveKey, curve->getYAxis());
curve->setColor( color );
curve->setLine( Plot2d::qwt2plotLine( typeLine ) );
curve->setMarker( Plot2d::qwt2plotMarker( typeMarker ) );
+ myPlot->setCurveNbMarkers( curve, 1 );
}
else {
Qt::PenStyle ps = Plot2d::plot2qwtLine( curve->getLine() );
QBrush( curve->getColor() ),
QPen( curve->getColor() ),
QSize( myMarkerSize, myMarkerSize ) ) );
+ myPlot->setCurveNbMarkers( curve, curve->getNbMarkers() );
}
setCurveType( aPCurve, myCurveType );
aPCurve->setData( curve->horData(), curve->verData(), curve->nbPoints() );
updateTitles();
if ( update )
myPlot->replot();
+
+ emit curveDisplayed( curve );
}
/*!
updateTitles();
if ( update )
myPlot->replot();
+ emit curveErased( curve );
}
}
QPen( curve->getColor() ),
QSize( myMarkerSize, myMarkerSize ) ) );
aPCurve->setData( curve->horData(), curve->verData(), curve->nbPoints() );
+ Plot2d_PlotCurve* aPlot2dCurve = dynamic_cast< Plot2d_PlotCurve* >( aPCurve );
+ if ( aPlot2dCurve )
+ aPlot2dCurve->setNbMarkers( curve->getNbMarkers() );
}
aPCurve->setTitle( curve->getVerTitle() );
aPCurve->setVisible( true );
myY2GridMinorEnabled, myPlot->axisMaxMinor( QwtPlot::yRight ) );
if ( dlg->exec() == QDialog::Accepted ) {
// horizontal axis title
+ bool isTileChanged = dlg->getXTitle() != myXTitle;
setTitle( dlg->isXTitleEnabled(), dlg->getXTitle(), XTitle, false );
+ if ( isTileChanged )
+ myXTitleChangedByUser = true;
+
// vertical left axis title
+ isTileChanged = dlg->getYTitle() != myYTitle;
setTitle( dlg->isYTitleEnabled(), dlg->getYTitle(), YTitle, false );
+ if ( isTileChanged )
+ myYTitleChangedByUser = true;
+
if (mySecondY) // vertical right axis title
setTitle( dlg->isY2TitleEnabled(), dlg->getY2Title(), Y2Title, false );
// main title
+ isTileChanged = dlg->getMainTitle() != myTitle;
setTitle( dlg->isMainTitleEnabled(), dlg->getMainTitle(), MainTitle, true );
+ if ( isTileChanged )
+ myTitleChangedByUser = true;
+
// curve type
if ( myCurveType != dlg->getCurveType() ) {
setCurveType( dlg->getCurveType(), false );
delete dlg;
}
+/*!
+ "Curves settings" toolbar action slot
+*/
+void Plot2d_ViewFrame::onCurvesSettings()
+{
+ Plot2d_SetupCurvesDlg* aDlg = new Plot2d_SetupCurvesDlg( this );
+
+ // Initialize dialog with legend
+ int nbCurves = myPlot->getCurves().count();
+ if ( nbCurves == 0 )
+ return;
+
+ QVector< int > aMarkers( nbCurves );
+ QVector< QString > aTexts( nbCurves );
+ QVector< QColor > aColors( nbCurves );
+ QVector< int > nbMarkers( nbCurves );
+
+ QList< Plot2d_Curve* > aCurves;
+
+ CurveDict::iterator it = myPlot->getCurves().begin();
+ int i = 0;
+ for ( i = 0; it != myPlot->getCurves().end(); it++, i++ )
+ {
+ Plot2d_Curve* aCurve = it.value();
+ if ( !aCurve )
+ return;
+
+ int aMarkerType = aCurve->getMarker();
+ QString aText = aCurve->getHorTitle();
+ if ( aText.isEmpty() )
+ aText = aCurve->getVerTitle();
+ QColor aColor = aCurve->getColor();
+ int nbMarker = aCurve->getNbMarkers();
+
+ aMarkers[ i ] = aMarkerType;
+ aTexts[ i ] = aText;
+ aColors[ i ] = aColor;
+ nbMarkers[ i ] = nbMarker;
+
+ aCurves.append( aCurve );
+ }
+
+ aDlg->SetParameters( aMarkers, aTexts, aColors, nbMarkers );
+
+ if ( aDlg->exec() != QDialog::Accepted )
+ return;
+
+ // Note: Indexes retrieved from dialog do not correspond to the real indexes of
+ // plot 2d curves. They correspond to the user actions. For example, if user removes
+ // first curve in dialog\92s table two times. Then contents of list of indexes is
+ // equal (1, 1) although first and second curves must be removed.
+ const QList< int >& toRemove = aDlg->GetRemovedIndexes();
+ QList< int >::const_iterator aRemIter;
+ for ( aRemIter = toRemove.begin(); aRemIter != toRemove.end(); ++aRemIter )
+ {
+ int anIndex = *aRemIter;
+ if ( anIndex >= 0 && anIndex < (int)aCurves.count() )
+ {
+ Plot2d_Curve* aCurve = aCurves[ anIndex ];
+ aCurves.removeAt( anIndex );
+ eraseCurve( aCurve );
+ }
+ }
+
+ QMap< int, Plot2d_Curve* > anIndexToCurve;
+ QList< Plot2d_Curve* >::iterator aCurvIter;
+ for ( i = 0, aCurvIter = aCurves.begin(); aCurvIter != aCurves.end(); ++aCurvIter, ++i )
+ {
+ anIndexToCurve[ i ] = *aCurvIter;
+ }
+
+ aDlg->GetParameters( aMarkers, aTexts, aColors, nbMarkers );
+
+ int n;
+ for ( i = 0, n = aMarkers.size(); i < n; i++ )
+ {
+ Plot2d_Curve* aCurve = anIndexToCurve[ i ];
+ aCurve->setAutoAssign( false );
+
+ // old values
+ Plot2d::MarkerType anOldMarker = aCurve->getMarker();
+ QString anOldText = aCurve->getHorTitle();
+ bool isHorTitle = true;
+ if ( anOldText.isEmpty() )
+ {
+ anOldText = aCurve->getVerTitle();
+ isHorTitle = false;
+ }
+ QColor anOldColor = aCurve->getColor();
+ int anOldNbMarker = aCurve->getNbMarkers();
+
+ // new values
+
+ Plot2d::MarkerType aMarker = (Plot2d::MarkerType)aMarkers[ i ];
+ QString aText = aTexts[ i ];
+ QColor aColor = aColors[ i ];
+ int nbMarker = nbMarkers[ i ];
+
+ bool toUpdate = false;
+
+ if ( anOldMarker != aMarker )
+ {
+ aCurve->setMarker( aMarker );
+ toUpdate = true;
+ }
+ if ( anOldText != aText )
+ {
+ if ( isHorTitle )
+ aCurve->setHorTitle( aText );
+ else
+ aCurve->setVerTitle( aText );
+ toUpdate = true;
+ }
+ if ( anOldColor != aColor )
+ {
+ aCurve->setColor( aColor );
+ toUpdate = true;
+ }
+ if ( anOldNbMarker != nbMarker )
+ {
+ aCurve->setNbMarkers( nbMarker );
+ toUpdate = true;
+ }
+
+ if ( toUpdate )
+ updateCurve( aCurve, false );
+ }
+
+ Repaint();
+
+ delete aDlg;
+}
+
/*!
"Fit Data" command slot
*/
~Plot2d_QwtPlotZoomer() {};
};
+
+/*!
+ Constructor
+*/
+Plot2d_PlotCurve::Plot2d_PlotCurve( const QString& title )
+: QwtPlotCurve( title ),
+ myNbMarkers( 1 )
+{
+}
+
+Plot2d_PlotCurve::~Plot2d_PlotCurve()
+{
+}
+
+/*!
+ Sets number of markers for steps. If number of markers is equal to 1 then
+ markers are displayed for steps only. If number of markers is equal to 3
+ (for example) then markers are displayed for steps and two markers are
+ displayed between side by side steps.
+*/
+void Plot2d_PlotCurve::setNbMarkers( const int theNbMarkers )
+{
+ myNbMarkers = theNbMarkers;
+}
+
+/*!
+ Gets number of markers for steps. If number of markers is equal to 1 then
+ markers are displayed for steps only. If number of markers is equal to 3
+ (for example) then markers are displayed for steps and two markers are
+ displayed between side by side steps.
+*/
+int Plot2d_PlotCurve::nbMarkers() const
+{
+ return myNbMarkers;
+}
+
+/*!
+ Draws curve's markers
+*/
+void Plot2d_PlotCurve::drawSymbols( QPainter *p, const QwtSymbol &symbol,
+ const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+ int from, int to ) const
+{
+ p->setBrush( symbol.brush() );
+ p->setPen( symbol.pen() );
+
+ QRect rect;
+ rect.setSize( QwtPainter::metricsMap().screenToLayout( symbol.size() ) );
+
+ if ( to > from && testPaintAttribute( PaintFiltered ) )
+ {
+ QwtPlotCurve::drawSymbols( p, symbol, xMap, yMap, from, to );
+ }
+ else
+ {
+ for ( int i = from; i <= to; i++ )
+ {
+ const int u = xMap.transform(x(i));
+ const int v = yMap.transform(y(i));
+
+ rect.moveCenter( QPoint( u, v ) );
+ symbol.draw( p, rect );
+
+ // draw markers between current and previous step
+ if ( myNbMarkers > 1 && i >= 1 )
+ {
+ int u_1 = xMap.transform( x( i - 1 ) );
+ int v_1 = yMap.transform( y( i - 1 ) );
+
+ if ( u_1 == u )
+ continue;
+
+ double k = ( (double)( v_1 - v ) ) / ( u_1 - u );
+ double b = v - k * u;
+ double step = ( (double)( u - u_1 ) ) / myNbMarkers;
+ for ( int ind = 1; ind < myNbMarkers; ind++ )
+ {
+ int X = (int)( u_1 + step * ind );
+ int Y = (int)( k * X + b );
+
+ rect.moveCenter( QPoint( X, Y ) );
+ symbol.draw( p, rect );
+ }
+ }
+ }
+ }
+}
+
/*!
Constructor
*/
return 0;
}
+/*!
+ Sets number of markers for steps. If number of markers is equal to 1 then
+ markers are displayed for steps only. If number of markers is equal to 3
+ (for example) then markers are displayed for steps and two markers are
+ displayed between side by side steps.
+*/
+bool Plot2d_Plot2d::setCurveNbMarkers( Plot2d_Curve* curve, const int nb )
+{
+ Plot2d_PlotCurve* aPlotCurve =
+ dynamic_cast<Plot2d_PlotCurve*>( myCurves.key( curve, 0 ) );
+ if ( aPlotCurve )
+ {
+ aPlotCurve->setNbMarkers( nb );
+ return true;
+ }
+ else
+ return false;
+}
+
+
+/*!
+ Gets number of markers for steps. If number of markers is equal to 1 then
+ markers are displayed for steps only. If number of markers is equal to 3
+ (for example) then markers are displayed for steps and two markers are
+ displayed between side by side steps.
+*/
+int Plot2d_Plot2d::curveNbMarkers( Plot2d_Curve* curve ) const
+{
+ Plot2d_PlotCurve* aPlotCurve =
+ dynamic_cast<Plot2d_PlotCurve*>( myCurves.key( curve, 0 ) );
+ return aPlotCurve ? aPlotCurve->nbMarkers() : 0;
+}
+
/*!
Checks if marker belongs to any enitity
*/
if ( ce->type() == FITALL_EVENT )
fitAll();
}
+
+/*!
+ Verifies whether plot title must be generated automatically using curves titles
+*/
+bool Plot2d_ViewFrame::isTitleChangedByUser( const ObjectType type )
+{
+ switch ( type )
+ {
+ case MainTitle:
+ return myPrefTitleChangedByUser || myTitleChangedByUser;
+ case XTitle:
+ return myXPrefTitleChangedByUser || myXTitleChangedByUser;
+ case YTitle:
+ return myYPrefTitleChangedByUser || myYTitleChangedByUser;
+ default:
+ return false;
+ }
+}
+
+/*!
+ Verifies whether plot title must be generated automatically using curves titles
+*/
+void Plot2d_ViewFrame::forgetLocalUserChanges( const ObjectType type )
+{
+ switch ( type )
+ {
+ case MainTitle:
+ myTitleChangedByUser = false;
+ break;
+ case XTitle:
+ myXTitleChangedByUser = false;
+ break;
+ case YTitle:
+ myYTitleChangedByUser = false;
+ break;
+ default:
+ break;
+ }
+}
+
+/*!
+ Sets flag for automatic updates of titles in accordance with current set of curves
+ ( updateTitles method). You should call setAutoUpdateTitle( ObjType, false )
+ if your application set titles itself and they can not be updated automatically.
+ By default titles are updated automatically.
+*/
+
+void Plot2d_ViewFrame::setAutoUpdateTitle( const ObjectType type, const bool upd )
+{
+ switch ( type )
+ {
+ case MainTitle:
+ myTitleAutoUpdate = upd;
+ break;
+ case XTitle:
+ myXTitleAutoUpdate = upd;
+ break;
+ case YTitle:
+ myYTitleAutoUpdate = upd;
+ break;
+ default:
+ break;
+ }
+}
+
+/*!
+ Gets flag for automatic updates of titles in accordance with current set of curves
+ ( updateTitles method)
+*/
+bool Plot2d_ViewFrame::getAutoUpdateTitle( const ObjectType type ) const
+{
+ switch ( type )
+ {
+ case MainTitle:
+ return myTitleAutoUpdate;
+ case XTitle:
+ return myXTitleAutoUpdate;
+ case YTitle:
+ return myYTitleAutoUpdate;
+ default:
+ return true;
+ }
+}
+
#include <QMultiHash>
#include <QList>
#include <qwt_symbol.h>
+#include <qwt_plot_curve.h>
class Plot2d_Plot2d;
class Plot2d_Prs;
void setTitle( bool enabled, const QString& title, ObjectType type, bool update = true );
QString getTitle( ObjectType type ) const;
+ bool isTitleChangedByUser( const ObjectType type );
+ void forgetLocalUserChanges( const ObjectType type );
+
void setFont( const QFont& font, ObjectType type, bool update = true );
void setHorScaleMode( const int mode, bool update = true );
int getHorScaleMode() const { return myXMode; }
void incrementalPan ( const int incrX, const int incrY );
void incrementalZoom( const int incrX, const int incrY );
+ void setAutoUpdateTitle( const ObjectType type, const bool upd );
+ bool getAutoUpdateTitle( const ObjectType type ) const;
+
protected:
int testOperation( const QMouseEvent& );
void readPreferences();
void onViewFitArea();
void onViewGlobalPan();
void onSettings();
+ void onCurvesSettings();
void onFitData();
void onChangeBackground();
void onPanLeft();
void vpCurveChanged();
void contextMenuRequested( QContextMenuEvent *e );
void legendClicked( QwtPlotItem* );
+ void curveDisplayed( Plot2d_Curve* );
+ void curveErased( Plot2d_Curve* );
protected:
Plot2d_Plot2d* myPlot;
int myXMode, myYMode;
double myXDistance, myYDistance, myYDistance2;
bool mySecondY;
+
+ bool myTitleAutoUpdate, myXTitleAutoUpdate, myYTitleAutoUpdate;
+ bool myTitleChangedByUser, myXTitleChangedByUser, myYTitleChangedByUser;
+
+ static QString myPrefTitle;
+ static QString myPrefXTitle;
+ static QString myPrefYTitle;
+
+ static bool myPrefTitleChangedByUser;
+ static bool myXPrefTitleChangedByUser;
+ static bool myYPrefTitleChangedByUser;
};
class Plot2d_Plot2d : public QwtPlot
CurveDict& getCurves() { return myCurves; }
Plot2d_Curve* getClosestCurve( QPoint p, double& distance, int& index );
+ long insertCurve( const QString &title,
+ int xAxis = xBottom,
+ int yAxis = yLeft );
+
+ bool setCurveNbMarkers( Plot2d_Curve* curve, const int nb );
+ int curveNbMarkers( Plot2d_Curve* curve ) const;
+
public slots:
virtual void polish();
QwtPlotZoomer* myPlotZoomer;
};
+//! The class is derived from QwtPlotCurve.
+/*!
+ The class is derived from QwtPlotCurve. Its main purpose is redefining
+ drawSymbols virtual method in order to provide possibility to change
+ number of markers between steps.
+*/
+
+class Plot2d_PlotCurve : public QwtPlotCurve
+{
+public:
+ Plot2d_PlotCurve( const QString &title );
+ virtual ~Plot2d_PlotCurve();
+
+ void setNbMarkers( const int );
+ int nbMarkers() const;
+
+protected:
+
+ virtual void drawSymbols(QPainter *p, const QwtSymbol &,
+ const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+ int from, int to) const;
+
+private:
+ int myNbMarkers;
+};
+
#endif
// settings
thePopup->addAction( mgr->action( CurvSettingsId ) );
+ thePopup->addAction( mgr->action( CurvesSettingsId ) );
}
/*!
connect( aAction, SIGNAL( triggered( bool ) ), myViewFrame, SLOT( onSettings() ) );
mgr->registerAction( aAction, CurvSettingsId );
+ // 8. Curves Settings
+ aAction = new QtxAction( tr( "TOT_CURVES_SETTINGS"),
+ aResMgr->loadPixmap("Plot2d", tr("ICON_CURVES_SETTINGS")),
+ tr("MEN_CURVES_SETTINGS"), 0, this);
+ aAction->setStatusTip( tr( "PRP_CURVES_SETTINGS") );
+ connect( aAction, SIGNAL( activated() ), myViewFrame, SLOT( onCurvesSettings() ) );
+ mgr->registerAction( aAction, CurvesSettingsId );
+
// 9. Clone
aAction = new QtxAction( tr( "MNU_CLONE_VIEW" ),
aResMgr->loadPixmap( "Plot2d", tr( "ICON_PLOT2D_CLONE_VIEW" ) ),
mgr->append( toolMgr()->separator(), myToolBar );
mgr->append( LegendId, myToolBar );
mgr->append( CurvSettingsId, myToolBar );
+ mgr->append( CurvesSettingsId, myToolBar );
mgr->append( CloneId, myToolBar );
}
#include <SUIT_ViewWindow.h>
#include <QMap>
-
#ifdef WIN32
#pragma warning( disable:4251 )
#endif
PModeYLinearId, PModeYLogarithmicId,
CurvPointsId, CurvLinesId, CurvSplinesId,
LegendId,
- CurvSettingsId,
+ CurvSettingsId, CurvesSettingsId,
CloneId };
public:
<source>ICON_PLOT2D_SHOW_LEGEND</source>
<translation>plot2d_legend.png</translation>
</message>
+ <message>
+ <source>ICON_CURVES_SETTINGS</source>
+ <translation>plot2d_curves_settings.png</translation>
+ </message>
+ <message>
+ <source>ICON_MINUS</source>
+ <translation>plot2d_minus.png</translation>
+ </message>
</context>
</TS>
<source>MEN_PLOT2D_SETTINGS</source>
<translation>&Settings</translation>
</message>
+ <message>
+ <source>TOT_CURVES_SETTINGS</source>
+ <translation>Curves settings</translation>
+ </message>
+ <message>
+ <source>MEN_CURVES_SETTINGS</source>
+ <translation>Curves settings</translation>
+ </message>
+ <message>
+ <source>PRP_CURVES_SETTINGS</source>
+ <translation>Setups curves properties</translation>
+ </message>
<message>
<source>CIRCLE_MARKER_LBL</source>
<translation>Circle</translation>
<translation>Plot2d scene:%M - viewer:%V</translation>
</message>
</context>
+<context>
+ <name>Plot2d_SetupCurvesDlg</name>
+ <message>
+ <source>SETUP_CURVES</source>
+ <translation>Setup curves</translation>
+ </message>
+ <message>
+ <source>PARAMETERS</source>
+ <translation>Parameters</translation>
+ </message>
+ <message>
+ <source>FIG</source>
+ <translation>Fig</translation>
+ </message>
+ <message>
+ <source>MARKER</source>
+ <translation>Marker</translation>
+ </message>
+ <message>
+ <source>TEXT</source>
+ <translation>Text</translation>
+ </message>
+ <message>
+ <source>COLOR</source>
+ <translation>Color</translation>
+ </message>
+ <message>
+ <source>NB_MARKERS</source>
+ <translation>Nb markers</translation>
+ </message>
+</context>
</TS>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
QtxWorkspace.h \
QtxWorkspaceAction.h \
QtxWorkstack.h \
- QtxWorkstackAction.h
-
+ QtxWorkstackAction.h \
+ QtxListBox.h
#VSR: not yet migrated to Qt4 files
# \
- QtxListBox.h \
QtxTable.h
# Libraries targets
QtxWorkspace.cxx \
QtxWorkspaceAction.cxx \
QtxWorkstack.cxx \
- QtxWorkstackAction.cxx
+ QtxWorkstackAction.cxx \
+ QtxListBox.cxx
#VSR: not yet migrated to Qt4 files
# \
- QtxListBox.cxx \
QtxTable.cxx
#VSR: already migrated to Qt4 files
QtxWorkspace_moc.cxx \
QtxWorkspaceAction_moc.cxx \
QtxWorkstack_moc.cxx \
- QtxWorkstackAction_moc.cxx
+ QtxWorkstackAction_moc.cxx \
+ QtxListBox_moc.cxx
#VSR: not yet migrated to Qt4 files
# \
- QtxListBox_moc.cxx \
QtxTable_moc.cxx
nodist_libqtx_la_SOURCES = $(MOC_FILES)
#include <qpixmap.h>
#include <qlineedit.h>
+#ifdef WIN32
+#pragma warning ( disable: 4251 )
+#endif
+
+#include <qevent.h>
+#include <qscrollbar.h>
+
/*!
Constructor
*/
-QtxListBox::QtxListBox( QWidget* parent, const char* name, WFlags f )
-: QListBox( parent, name, f ),
+QtxListBox::QtxListBox( QWidget* parent )
+: QListWidget( parent ),
myEditor( 0 ),
myEditIndex( -1 ),
myEditState( false ),
myEditDefault( true ),
myModifEnabled( true )
{
- connect( this, SIGNAL( contentsMoving( int, int ) ),
- this, SLOT( onContentsMoving( int, int ) ) );
+ QScrollBar* hsb = horizontalScrollBar();
+ if ( hsb )
+ connect( hsb, SIGNAL( valueChanged( int ) ), SLOT( onContentsMoving() ) );
+
+ QScrollBar* vsb = horizontalScrollBar();
+ if ( vsb )
+ connect( vsb, SIGNAL( valueChanged( int ) ), SLOT( onContentsMoving() ) );
}
/*!
/*!
\return current edited item
*/
-QListBoxItem* QtxListBox::editedItem() const
+QListWidgetItem* QtxListBox::editedItem() const
{
return item( editedIndex() );
}
ensureItemVisible( myEditIndex );
- ed->setText( text( myEditIndex ) );
+ ed->setText( item( myEditIndex )->text() );
updateEditor();
ed->show();
Starts edition of item
\param item - item to be edited
*/
-void QtxListBox::startEdition( const QListBoxItem* item )
+void QtxListBox::startEdition( const QListWidgetItem* item )
{
- startEdition( index( item ) );
+ startEdition( row( item ) );
}
/*!
if ( action )
{
- int cur = currentItem();
+ int cur = currentRow();
+ /*qt4
if ( pixmap( idx ) )
changeItem( *pixmap( idx ), ed->text(), idx );
else
changeItem( ed->text(), idx );
+ */
+ item( idx )->setText( ed->text() );
- setCurrentItem( cur );
+ setCurrentRow( cur );
emit itemEdited( idx );
emit itemEdited( item( idx ) );
if ( idx < 0 )
return;
- if ( itemVisible( idx ) )
- return;
+ //qt4 if ( itemVisible( idx ) )
+ //qt4 return;
- setTopItem( idx );
+ //qt4 setTopItem( idx );
}
/*!
Ensures that the item is visible.
\param item - item to be made visible
*/
-void QtxListBox::ensureItemVisible( const QListBoxItem* item )
+void QtxListBox::ensureItemVisible( const QListWidgetItem* item )
{
- ensureItemVisible( index( item ) );
+ ensureItemVisible( row( item ) );
}
/*!
void QtxListBox::clearValidator()
{
if ( editor() )
- editor()->clearValidator();
+ editor()->setValidator( 0 );
}
/*!
*/
void QtxListBox::moveItem( const int idx, const int step )
{
- QListBoxItem* i = item( idx );
+ QListWidgetItem* i = item( idx );
if ( !i || step == 0 )
return;
- QListBoxItem* cur = item( currentItem() );
+ QListWidgetItem* cur = currentItem();
- takeItem( i );
- insertItem( i, QMAX( 0, idx + step ) );
+ takeItem( idx );
+ insertItem( qMax( 0, idx + step ), i );
- setCurrentItem( index( cur ) );
+ setCurrentItem( cur );
- int pos = index( i );
+ int pos = row( i );
if ( myEditIndex == idx )
myEditIndex = pos;
if ( !isEditEnabled() )
return;
- int idx = i < 0 ? currentItem() : i;
+ int idx = i < 0 ? currentRow() : i;
idx = idx < 0 ? count() : idx;
- idx = QMIN( (int)count(), idx );
+ idx = qMin( (int)count(), idx );
- insertItem( "", idx );
- setCurrentItem( idx );
+ insertItem( idx, "" );
+ setCurrentRow( idx );
startEdition( idx );
}
if ( !isEditEnabled() )
return;
- int idx = i < 0 ? currentItem() : i;
+ int idx = i < 0 ? currentRow() : i;
if ( idx < 0 )
return;
if ( editedIndex() == idx )
endEdition( defaultEditAction() );
- removeItem( idx );
+ takeItem( idx );
updateEditor();
}
*/
void QtxListBox::setContentsPos( int x, int y )
{
- QListBox::setContentsPos( x, y );
+ //qt4 QListWidget::setContentsPos( x, y );
updateEditor();
}
if ( e->type() == QEvent::KeyPress )
{
QKeyEvent* ke = (QKeyEvent*)e;
- if ( ke->key() == Key_Escape )
+ if ( ke->key() == Qt::Key_Escape )
endEdition( false );
- else if ( ke->key() == Key_Enter || ke->key() == Key_Return )
+ else if ( ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Return )
endEdition( true );
}
}
- return QListBox::eventFilter( o, e );
+ return QListWidget::eventFilter( o, e );
}
/*!
*/
void QtxListBox::keyPressEvent( QKeyEvent* e )
{
- if ( e->key() == Key_Up && e->state() & ControlButton && isModificationEnabled() )
- moveItem( currentItem(), -1 );
- else if ( e->key() == Key_Down && e->state() & ControlButton && isModificationEnabled() )
- moveItem( currentItem(), 1 );
- else if ( e->key() == Key_Home && e->state() & ControlButton && isModificationEnabled() )
- moveItemToTop( currentItem() );
- else if ( e->key() == Key_End && e->state() & ControlButton && isModificationEnabled() )
- moveItemToBottom( currentItem() );
- else if ( e->key() == Key_Insert && e->state() & ControlButton )
- createItem( currentItem() );
- else if ( e->key() == Key_Delete && e->state() & ControlButton )
- deleteItem( currentItem() );
+ if ( e->key() == Qt::Key_Up && e->modifiers() & Qt::ControlModifier && isModificationEnabled() )
+ moveItem( currentRow(), -1 );
+ else if ( e->key() == Qt::Key_Down && e->modifiers() & Qt::ControlModifier && isModificationEnabled() )
+ moveItem( currentRow(), 1 );
+ else if ( e->key() == Qt::Key_Home && e->modifiers() & Qt::ControlModifier && isModificationEnabled() )
+ moveItemToTop( currentRow() );
+ else if ( e->key() == Qt::Key_End && e->modifiers() & Qt::ControlModifier && isModificationEnabled() )
+ moveItemToBottom( currentRow() );
+ else if ( e->key() == Qt::Key_Insert && e->modifiers() & Qt::ControlModifier )
+ createItem( currentRow() );
+ else if ( e->key() == Qt::Key_Delete && e->modifiers() & Qt::ControlModifier )
+ deleteItem( currentRow() );
else
- QListBox::keyPressEvent( e );
+ QListWidget::keyPressEvent( e );
}
/*!
Custom resize event handler
*/
-void QtxListBox::viewportResizeEvent( QResizeEvent* e )
+void QtxListBox::resizeEvent( QResizeEvent* e )
{
- QListBox::viewportResizeEvent( e );
+ QListWidget::resizeEvent( e );
updateEditor();
}
if ( isEditEnabled() )
startEdition( itemAt( e->pos() ) );
else
- QListBox::mouseDoubleClickEvent( e );
+ QListWidget::mouseDoubleClickEvent( e );
}
/*!
Updates editor on contents moving
*/
-void QtxListBox::onContentsMoving( int, int )
+void QtxListBox::onContentsMoving()
{
updateEditor();
}
return;
myEditor = new QLineEdit( viewport() );
+ myEditor->setBackgroundRole( QPalette::Window );
- myEditor->setLineWidth( 1 );
- myEditor->setMidLineWidth( 0 );
- myEditor->setFrameStyle( QFrame::Box | QFrame::Plain );
+ //qt4 myEditor->setLineWidth( 1 );
+ //qt4 myEditor->setMidLineWidth( 0 );
+ //qt4 myEditor->setFrameStyle( QFrame::Box | QFrame::Plain );
myEditor->installEventFilter( this );
myEditor->hide();
- addChild( myEditor );
+ //qt4 addChild( myEditor );
}
/*!
if ( !editedItem() || !editor() )
return;
- QRect r = itemRect( editedItem() );
+ QRect r = visualItemRect( editedItem() );
if ( !r.isValid() )
return;
- int m = editor()->lineWidth();
- r.addCoords( m, 0, 0, 0 );
-
- const QPixmap* pix = pixmap( editedIndex() );
- if ( pix )
- r.addCoords( pix->width() + 2, 0, 0, 0 );
+ //int m = /*editor()->lineWidth()*/ 1;
+ r.setLeft( r.left() + 1 );
+
+ QListWidgetItem* it = item( editedIndex() );
+ if ( it )
+ {
+ const QIcon pix = it->icon();
+ if ( !pix.isNull() )
+ {
+ QSize s = pix.actualSize( QSize( 100, 100 ) );
+ r.setLeft( s.width() + 2 );
+ }
+ }
editor()->setGeometry( r );
}
Q_OBJECT
public:
- QtxListBox( QWidget* = 0, const char* = 0, Qt::WindowFlags = 0 );
+ QtxListBox( QWidget* = 0 );
virtual ~QtxListBox();
bool isEditEnabled() const;
virtual void setContentsPos( int, int );
private slots:
- void onContentsMoving( int, int );
+ void onContentsMoving();
protected:
virtual void keyPressEvent( QKeyEvent* );
- virtual void viewportResizeEvent( QResizeEvent* );
+ virtual void resizeEvent( QResizeEvent* ); //qt4 viewportResizeEvent
virtual void mouseDoubleClickEvent( QMouseEvent* );
-
+
private:
QLineEdit* editor() const;
void createEditor();
if ( !myList.contains( wid ) )
return;
+ bool wasActive = wid == workstack()->activeWindow();
+
if ( myBar->indexOf( widgetId( wid ) ) != -1 )
myBar->removeTab( myBar->indexOf( widgetId( wid ) ) );
myChild.remove( wid );
if ( del )
+ {
delete child( wid );
+ if ( myList.isEmpty() )
+ wasActive = false;
+ }
if ( isNull() )
deleteLater();
else
updateState();
+
+ if ( wasActive )
+ emit activated( activeWidget() );
}
/*!
if ( !widget() )
return;
- disconnect( widget(), SIGNAL( destroyed( QObject* ) ), this, SLOT( onDestroyed( QObject* ) ) );
+ if( widget() )
+ disconnect( widget(), SIGNAL( destroyed( QObject* ) ), this, SLOT( onDestroyed( QObject* ) ) );
widget()->hide();
widget()->removeEventFilter( this );
*/
QtxWorkstackTabBar::QtxWorkstackTabBar( QWidget* parent )
: QTabBar( parent ),
+ myActive( false ),
myId( -1 )
{
setDrawBase( true );
*/
void STD_Application::closeApplication()
{
- if ( desktop() )
- savePreferences();
SUIT_Study* study = activeStudy();
if ( study )
afterCloseDoc();
}
+ if ( desktop() )
+ savePreferences();
+
setDesktop( 0 );
SUIT_Application::closeApplication();
putInfo( tr( "INF_DOC_SAVING" ) + aName );
isOk = study->saveDocumentAs( aName );
- putInfo( isOk ? tr( "INF_DOC_SAVED" ).arg( aName ) : "" );
+ putInfo( isOk ? tr( "INF_DOC_SAVED" ).arg( aName ) : QString( "" ) );
QApplication::restoreOverrideCursor();
myResizeOnExpandItem = on;
}
+/*!
+ Ensures that object obj is visible, scrolling the list view vertically
+ if necessary and opening (expanding) any parent items if this is required to show the item.
+*/
+void SUIT_DataBrowser::ensureItemVisible( const SUIT_DataObject* obj )
+{
+ SUIT_ProxyModel* m = qobject_cast<SUIT_ProxyModel*>( model() );
+ if ( m ) {
+ QModelIndex index = m->index( obj );
+ if( index.isValid() )
+ treeView()->scrollTo( index );
+ }
+}
+
/*!
\brief Initialize object browser.
\param root root data object
void setAutoSizeColumns( const bool on );
void setResizeOnExpandItem( const bool on );
+ void ensureItemVisible( const SUIT_DataObject* );
+
protected:
virtual void contextMenuEvent( QContextMenuEvent* );
// now we get the list of all extension masks and remove all which does not contain wildcard symbols
QStringList extList = aPattern.split( "|", QString::SkipEmptyParts );
+
+ // This protection is added for GUITHARE application, (*.FORT21 fort21) filter.
+ // When user selects \93fort21\94 file name then extension should not be added
+ if ( extList.contains( QFileInfo( fname ).baseName() ) )
+ return fileName;
+
for ( int i = extList.count() - 1; i >= 0; i-- ) {
if ( !extList[i].contains( "." ) )
extList.removeAt( i );
virtual bool event( QEvent* );
QLineEdit* lineEdit() const;
virtual bool acceptData();
- QString addExtension( const QString& ) const;
+ virtual QString addExtension( const QString& ) const;
bool processPath( const QString& );
void addFilter( const QString& );
static bool hasWildCards( const QString& );
#include <QList>
#include <QCursor>
+#ifdef WIN32
+#pragma warning( disable:4251 )
+#endif
+
/*! \brief Class used for management cursors.*/
class SUIT_EXPORT SUIT_OverrideCursor
{
* Provide selection manager. Manipulate by selection filters, modes, data owners.
*/
-/*!constructor. initialize myIterations and myIsSelChangeEnabled.*/
+/*!constructor. initialize myIterations, myIsSelChangeEnabled and myIsSynchronizationEnabled.*/
SUIT_SelectionMgr::SUIT_SelectionMgr( const bool Feedback, QObject* p )
: QObject( p ),
myIterations( Feedback ? 1 : 0 ),
myAutoDelFilter( false ),
-myIsSelChangeEnabled( true )
+myIsSelChangeEnabled( true ),
+myIsSynchronizationEnabled( true )
{
}
SUIT_DataOwnerPtrList newOwners;
filterOwners( owners, newOwners );
- for ( int i = 0; i < myIterations; i++ )
+ if ( myIsSynchronizationEnabled )
{
- for ( SelectorList::iterator it = mySelectors.begin(); it != mySelectors.end(); ++it )
+ for ( int i = 0; i < myIterations; i++ )
{
- // Temporary action(to avoid selection of the objects which don't pass the filters):
- //if ( *it != sel )
- (*it)->setSelected( newOwners );
+ for ( SelectorList::iterator it = mySelectors.begin(); it != mySelectors.end(); ++it )
+ {
+ // Temporary action(to avoid selection of the objects which don't pass the filters):
+ //if ( *it != sel )
+ (*it)->setSelected( newOwners );
+ }
}
}
+ else
+ sel->setSelected( newOwners );
+
myIsSelChangeEnabled = true;
+ myLastSelectionSource = sel->type();
+
emit selectionChanged();
}
out.append( *it );
}
}
+
+/*! Gets type of last selector where selection has been changed.
+*/
+QString SUIT_SelectionMgr::lastSelectionSource() const
+{
+ return myLastSelectionSource;
+}
+
+/*! Verifies whether synchronization between selectors is enabled.
+*/
+bool SUIT_SelectionMgr::isSynchronizationEnabled() const
+{
+ return myIsSynchronizationEnabled;
+}
+
+/*! Enable or disable synchronization between selectors.
+*/
+void SUIT_SelectionMgr::setSynchronizationEnabled( const bool on )
+{
+ myIsSynchronizationEnabled = on;
+}
bool isSynchronizing() const;
+ QString lastSelectionSource() const;
+ bool isSynchronizationEnabled() const;
+ void setSynchronizationEnabled( const bool );
+
signals:
void selectionChanged();
int myIterations;
bool myAutoDelFilter;
bool myIsSelChangeEnabled;
+ bool myIsSynchronizationEnabled;
+ QString myLastSelectionSource;
friend class SUIT_Selector;
};
*/
QString SUIT_ViewManager::getType() const
{
- return (!myViewModel)? "": myViewModel->getType();
+ return (!myViewModel)? QString( "" ): myViewModel->getType();
}
/*!
#include <vtkInteractorStyle.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkPassThroughFilter.h>
+#include <vtkUnstructuredGrid.h>
#include <TColStd_MapOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
}
+bool IsThisActorPicked(SALOME_Actor *theActor, vtkActor *anAct) {
+ if( anAct == theActor ) return true;
+ if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( anAct ) )
+ return ( anActor->hasIO() && theActor->hasIO() &&
+ theActor->getIO()->isSame( anActor->getIO() ) );
+ return false;
+}
vtkStandardNewMacro(SALOME_Actor);
myPointPicker->Pick( x, y, z, aRenderer );
int aVtkId = myPointPicker->GetPointId();
- if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) ) {
+ if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true )
+ && IsThisActorPicked(this, myPointPicker->GetActor())) { // RKV
int anObjId = GetNodeObjId( aVtkId );
myIsPreselected = (anObjId >= 0);
if(myIsPreselected){
myCellPicker->Pick( x, y, z, aRenderer );
int aVtkId = myCellPicker->GetCellId();
- if ( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) && hasIO() ) {
+ if ( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) && hasIO()
+ && IsThisActorPicked(this, myCellPicker->GetActor())) { // RKV
int anObjId = GetElemObjId (aVtkId );
if ( anObjId >= 0 ) {
myIsPreselected = CheckDimensionId(aSelectionMode,this,anObjId);
myCellPicker->Pick( x, y, z, aRenderer );
int aVtkId = myCellPicker->GetCellId();
- if ( aVtkId >= 0 && mySelector->IsValid( this, aVtkId )) {
+ if ( aVtkId >= 0 && mySelector->IsValid( this, aVtkId )
+ && IsThisActorPicked(this, myCellPicker->GetActor())) { // RKV
int anObjId = GetElemObjId( aVtkId );
if ( anObjId >= 0 ) {
int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId);
myPointPicker->Pick( x, y, z, aRenderer );
int aVtkId = myPointPicker->GetPointId();
- if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) ) {
+ if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true )
+ && IsThisActorPicked(this, myPointPicker->GetActor())) { // RKV
int anObjId = GetNodeObjId( aVtkId );
if( anObjId >= 0 ) {
mySelector->AddOrRemoveIndex( myIO, anObjId, anIsShift );
myCellPicker->Pick( x, y, z, aRenderer );
int aVtkId = myCellPicker->GetCellId();
- if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) ) {
+ if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId )
+ && IsThisActorPicked(this, myCellPicker->GetActor())) { // RKV
int anObjId = GetElemObjId( aVtkId );
if( anObjId >= 0 ) {
if ( CheckDimensionId(aSelectionMode,this,anObjId) ) {
myCellPicker->Pick( x, y, z, aRenderer );
int aVtkId = myCellPicker->GetCellId();
- if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) ) {
+ if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId )
+ && IsThisActorPicked(this, myCellPicker->GetActor())) { // RKV
int anObjId = GetElemObjId( aVtkId );
if( anObjId >= 0 ) {
int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId);
vtkIdType anEnd = aVectorIds.size();
for(vtkIdType anId = 0; anId < anEnd; anId++ ) {
int aPointId = aVectorIds[anId];
- if( aPointId >= 0 && mySelector->IsValid( this, aPointId, true ) ) {
+ if( aPointId >= 0 && mySelector->IsValid( this, aPointId, true )
+ && IsThisActorPicked(this, myPointRectPicker->GetActor())) { // RKV
int anObjId = GetNodeObjId( aPointId );
anIndexes.Add( anObjId );
}
vtkIdType anEnd = aVectorIds.size();
for(vtkIdType anId = 0; anId < anEnd; anId++ ) {
int aCellId = aVectorIds[anId];
- if ( !mySelector->IsValid( this, aCellId ) )
+ if ( !mySelector->IsValid( this, aCellId )
+ && !IsThisActorPicked(this, myCellRectPicker->GetActor())) // RKV
continue;
int anObjId = GetElemObjId( aCellId );
{
myHighlightActor->SetProperty(theProperty);
}
+
+
+void
+SALOME_Actor
+::MapCells(const TColStd_IndexedMapOfInteger& theMapIndex,
+ vtkUnstructuredGrid* theUG)
+{
+ int aNbOfParts = theMapIndex.Extent();
+ for(int ind = 1; ind <= aNbOfParts; ind++){
+ int aPartId = theMapIndex( ind );
+ if(vtkCell* aCell = GetElemCell(aPartId))
+ theUG->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
+ }
+}
class vtkOutlineSource;
class vtkInteractorStyle;
class vtkRenderWindowInteractor;
+class vtkUnstructuredGrid;
class SVTK_Actor;
class SVTK_RectPicker;
void
SetHighlightProperty(vtkProperty* theProperty);
+ virtual void MapCells(const TColStd_IndexedMapOfInteger& theMapIndex,
+ vtkUnstructuredGrid* theUG);
+
protected:
//----------------------------------------------------------------------------
vtkRenderWindowInteractor* myInteractor;
vtkDataSet *aSourceDataSet = theMapActor->GetInput();
CopyPoints(GetSource(),aSourceDataSet);
- int aNbOfParts = theMapIndex.Extent();
- for(int ind = 1; ind <= aNbOfParts; ind++){
- int aPartId = theMapIndex( ind );
- if(vtkCell* aCell = theMapActor->GetElemCell(aPartId))
- myUnstructuredGrid->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
- }
+ theMapActor->MapCells(theMapIndex,myUnstructuredGrid.GetPointer());
UnShrink();
if(theMapActor->IsShrunk()){
{
vtkFloatingPointType tmp=-1000;
if (!theY){
- for (int i=0; i<4; i++){
+ int i=0;
+ for (; i<4; i++){
tmp = aArray1[i]; aArray1[i] = aArray2[i]; aArray2[i] = tmp;
}
#ifndef WIN32
- for(int i=0;i<2; i++){
+ for(i=0;i<2; i++){
#else
for(i=0;i<2; i++){
#endif
::SetInput(vtkDataSet* theDataSet)
{
myMapper->SetInput(theDataSet);
- InitPipeLine(myMapper);
+ SetMapper(myMapper);
}
/*!
mySelectionEvent->myIsCtrl = Interactor->GetControlKey();
mySelectionEvent->myIsShift = Interactor->GetShiftKey();
+ mySelectionEvent->myKeyCode = Interactor->GetKeyCode();
mySelectionEvent->myLastX = mySelectionEvent->myX;
mySelectionEvent->myLastY = mySelectionEvent->myY;
//----------------------------------------------------------------------------
+/* RKV void
+ SelectVisiblePoints(int theSelection[4],
+ vtkRenderer *theRenderer,
+ vtkDataSet *theInput,
+ SVTK_RectPicker::TVectorIds& theVisibleIds,
+ SVTK_RectPicker::TVectorIds& theInVisibleIds,
+ vtkFloatingPointType theTolerance) */
void
SelectVisiblePoints(int theSelection[4],
vtkRenderer *theRenderer,
vtkDataSet *theInput,
SVTK_RectPicker::TVectorIds& theVisibleIds,
SVTK_RectPicker::TVectorIds& theInVisibleIds,
- vtkFloatingPointType theTolerance)
+ vtkFloatingPointType theTolerance,
+ bool isThrough) // RKV
{
theVisibleIds.clear();
theInVisibleIds.clear();
GetCompositePerspectiveTransformMatrix( theRenderer->GetTiledAspectRatio(), 0, 1 ) );
// We grab the z-buffer for the selection region all at once and probe the resulting array.
- float *aZPtr = theRenderer->GetRenderWindow()->
- GetZbufferData(theSelection[0], theSelection[1], theSelection[2], theSelection[3]);
+// RKV float *aZPtr = theRenderer->GetRenderWindow()->
+// RKV GetZbufferData(theSelection[0], theSelection[1], theSelection[2], theSelection[3]);
+ // RKV : Begin
+ float *aZPtr = 0;
+ if (!isThrough) // Use Z-Buffer if only visible points should be taken
+ aZPtr = theRenderer->GetRenderWindow()->
+ GetZbufferData(theSelection[0], theSelection[1], theSelection[2], theSelection[3]);
+ // RKV : End
//cout<<"theSelection = {"<<theSelection[0]<<", "<<theSelection[1]<<", "<<theSelection[2]<<", "<<theSelection[3]<<"}\n";
aDX[1] >= theSelection[1] && aDX[1] <= theSelection[3])
{
//cout<<"aPntId "<<aPntId<<"; aDX = {"<<aDX[0]<<", "<<aDX[1]<<", "<<aDX[2]<<"}\n";
- int aDX0 = int(aDX[0]);
- int aDX1 = int(aDX[1]);
-
- int aRet = Check(aZPtr,theSelection,theTolerance,aDX[2],aDX0,aDX1);
+ static int aMaxRadius = 5;
+ int aDX0 = 0;
+ int aDX1 = 0;
+ int aRet = 0;
+ int aRadius = 1;
+
+ if (isThrough) goto ADD_VISIBLE; // RKV
+
+ aDX0 = int(aDX[0]);
+ aDX1 = int(aDX[1]);
+
+ aRet = Check(aZPtr,theSelection,theTolerance,aDX[2],aDX0,aDX1);
if(aRet > 0)
goto ADD_VISIBLE;
if(aRet < 0)
goto ADD_INVISIBLE;
- static int aMaxRadius = 5;
- for(int aRadius = 1; aRadius < aMaxRadius; aRadius++){
+ for(aRadius = 1; aRadius < aMaxRadius; aRadius++){
int aStartDX[2] = {aDX0 - aRadius, aDX1 - aRadius};
for(int i = 0; i <= aRadius; i++){
int aRet = Check(aZPtr,theSelection,theTolerance,aDX[2],aStartDX[0]++,aStartDX[1]);
vtkRenderer *theRenderer,
vtkDataSet *theInput,
SVTK_RectPicker::TVectorIds& theVectorIds,
- vtkFloatingPointType theTolerance)
+// RKV vtkFloatingPointType theTolerance)
+ vtkFloatingPointType theTolerance, bool isThrough) // RKV
{
theVectorIds.clear();
theInput,
aVisiblePntIds,
anInVisiblePntIds,
- theTolerance);
+// RKV theTolerance);
+ theTolerance, isThrough); // RKV
typedef std::set<vtkIdType> TIdsSet;
TIdsSet aVisibleIds(aVisiblePntIds.begin(),aVisiblePntIds.end());
{
this->Tolerance = 0.005;
this->PickPoints = 1;
+ this->myIsThrough = false; // RKV : The old behaviour by default
}
SVTK_RectPicker
aMapper->GetInput(),
aVisibleIds,
anInVisibleIds,
- this->Tolerance);
+// RKV this->Tolerance);
+ this->Tolerance, IsThrough()); // RKV
if ( aVisibleIds.empty() ) {
myPointIdsMap.erase(myPointIdsMap.find(anActor));
}
theRenderer,
aMapper->GetInput(),
aVectorIds,
- this->Tolerance);
+// RKV this->Tolerance);
+ this->Tolerance, IsThrough()); // RKV
if ( aVectorIds.empty() ) {
myCellIdsMap.erase(myCellIdsMap.find(anActor));
}
const TVectorIdsMap&
GetCellIdsMap() const;
+ bool IsThrough() { return myIsThrough;} // RKV
+ void SetIsThrough(bool val) { myIsThrough = val;} // RKV
+
protected:
SVTK_RectPicker();
~SVTK_RectPicker();
TVectorIdsMap myPointIdsMap;
TVectorIdsMap myCellIdsMap;
+ bool myIsThrough; // RKV : Will the picker take all elements throuth selected
+ // volume inclung invizible elements
+
private:
virtual
int
QVTK_RenderWindowInteractor
::mouseMoveEvent( QMouseEvent* event )
{
+ int keyCode = 0;
+ if ( event->modifiers() & Qt::AltModifier )
+ keyCode = Qt::Key_Alt;
+
GetDevice()->SetEventInformationFlipY(event->x(),
event->y(),
event->modifiers() & Qt::ControlModifier,
- event->modifiers() & Qt::ShiftModifier);
+ event->modifiers() & Qt::ShiftModifier,
+ keyCode);
GetDevice()->MouseMoveEvent();
}
QVTK_RenderWindowInteractor
::mousePressEvent( QMouseEvent* event )
{
+ int keyCode = 0;
+ if ( event->modifiers() & Qt::AltModifier )
+ keyCode = Qt::Key_Alt;
+
GetDevice()->SetEventInformationFlipY(event->x(),
event->y(),
event->modifiers() & Qt::ControlModifier,
- event->modifiers() & Qt::ShiftModifier);
+ event->modifiers() & Qt::ShiftModifier,
+ keyCode);
if( event->button() & Qt::LeftButton )
GetDevice()->LeftButtonPressEvent();
else if( event->button() & Qt::MidButton )
QVTK_RenderWindowInteractor
::mouseReleaseEvent( QMouseEvent *event )
{
+ int keyCode = 0;
+ if ( event->modifiers() & Qt::AltModifier )
+ keyCode = Qt::Key_Alt;
+
GetDevice()->SetEventInformationFlipY(event->x(),
event->y(),
event->modifiers() & Qt::ControlModifier,
- event->modifiers() & Qt::ShiftModifier);
+ event->modifiers() & Qt::ShiftModifier,
+ keyCode);
if( event->button() & Qt::LeftButton )
GetDevice()->LeftButtonReleaseEvent();
class Handle(VTKViewer_Filter);
class SALOME_Actor;
-class SVTK_SelectionEvent;
+struct SVTK_SelectionEvent;
class vtkRenderer;
class Handle(SALOME_InteractiveObject);
//if(!anObj.IsNull() && anObj->hasEntry() && aStudy)
// ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this);
if(forced)
- aRenderer->RemoveActor(anAct);
+ // RKV : aRenderer->RemoveActor(anAct);
+ anAct->RemoveFromRender(aRenderer); // RKV
else{
// just erase actor
anAct->SetVisibility( false );
if ( hover )
drawHoverRect(p, opt->rect, opt->palette.color( QPalette::Window ), aRad, Style_Tools::All, true);
else {
+ QColor light = opt->palette.color( QPalette::Base );
+ light.setAlpha( 255 );
Style_Tools::shadowRect( p, opt->rect, aRad, LINE_GR_MARGIN, SHADOW,
- Style_Tools::All, opt->palette.color( QPalette::Base ), // getColor( Style_Model::fld_light_clr ),
+ Style_Tools::All, light, // getColor( Style_Model::fld_light_clr ),
getColor( Style_Model::fld_dark_clr ), aBrdTopCol, aBrdBotCol,
getBoolValue( Style_Model::all_antialized ), false );
}
VTKViewer_ViewManager.h \
VTKViewer_ViewModel.h \
VTKViewer_ViewWindow.h \
- VTKViewer_Functor.h
+ VTKViewer_Functor.h \
+ VTKViewer_MergeFilter.h \
+ VTKViewer_PassThroughFilter.h
dist_libVTKViewer_la_SOURCES = \
VTKViewer_CellLocationsArray.cxx \
VTKViewer_ViewManager.cxx \
VTKViewer_ViewModel.cxx \
VTKViewer_ConvexTool.cxx \
- VTKViewer_ViewWindow.cxx
+ VTKViewer_ViewWindow.cxx \
+ VTKViewer_MergeFilter.cxx \
+ VTKViewer_PassThroughFilter.cxx
MOC_FILES = \
VTKViewer_RenderWindow_moc.cxx \
myIsResolveCoincidentTopology(true),
myStoreMapping(false),
myGeomFilter(VTKViewer_GeometryFilter::New()),
- myTransformFilter(VTKViewer_TransformFilter::New())
+ myTransformFilter(VTKViewer_TransformFilter::New()),
+ myOpacity( 1. )
{
vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor,
myPolygonOffsetUnits);
vtkIdType VTKViewer_GeometryFilter::GetElemObjId( int theVtkID )
{
- if( myVTK2ObjIds.empty() || theVtkID > (int)myVTK2ObjIds.size() )
+// RKV if( myVTK2ObjIds.empty() || theVtkID > (int)myVTK2ObjIds.size() )
+ if( myVTK2ObjIds.empty() || theVtkID >= (int)myVTK2ObjIds.size() ) // RKV
return -1;
#if defined __GNUC_2__
return myVTK2ObjIds[theVtkID];
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// 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
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#include "VTKViewer_MergeFilter.h"
+
+#include <vtkCellData.h>
+#include <vtkInformation.h>
+#include <vtkInformationVector.h>
+#include <vtkObjectFactory.h>
+#include <vtkPointData.h>
+#include <vtkPolyData.h>
+#include <vtkRectilinearGrid.h>
+#include <vtkStreamingDemandDrivenPipeline.h>
+#include <vtkStructuredGrid.h>
+#include <vtkStructuredPoints.h>
+#include <vtkUnstructuredGrid.h>
+
+vtkCxxRevisionMacro(VTKViewer_MergeFilter, "$Revision$");
+vtkStandardNewMacro(VTKViewer_MergeFilter);
+
+class vtkFieldNode
+{
+public:
+ vtkFieldNode(const char* name, vtkDataSet* ptr=0)
+ {
+ int length = static_cast<int>(strlen(name));
+ if (length > 0)
+ {
+ this->Name = new char[length+1];
+ strcpy(this->Name, name);
+ }
+ else
+ {
+ this->Name = 0;
+ }
+ this->Ptr = ptr;
+ this->Next = 0;
+ }
+ ~vtkFieldNode()
+ {
+ delete[] this->Name;
+ }
+
+ const char* GetName()
+ {
+ return Name;
+ }
+ vtkDataSet* Ptr;
+ vtkFieldNode* Next;
+private:
+ vtkFieldNode(const vtkFieldNode&) {}
+ void operator=(const vtkFieldNode&) {}
+ char* Name;
+};
+
+class vtkFieldList
+{
+public:
+ vtkFieldList()
+ {
+ this->First = 0;
+ this->Last = 0;
+ }
+ ~vtkFieldList()
+ {
+ vtkFieldNode* node = this->First;
+ vtkFieldNode* next;
+ while(node)
+ {
+ next = node->Next;
+ delete node;
+ node = next;
+ }
+ }
+
+
+ void Add(const char* name, vtkDataSet* ptr)
+ {
+ vtkFieldNode* newNode = new vtkFieldNode(name, ptr);
+ if (!this->First)
+ {
+ this->First = newNode;
+ this->Last = newNode;
+ }
+ else
+ {
+ this->Last->Next = newNode;
+ this->Last = newNode;
+ }
+ }
+
+ friend class vtkFieldListIterator;
+
+private:
+ vtkFieldNode* First;
+ vtkFieldNode* Last;
+};
+
+class vtkFieldListIterator
+{
+public:
+ vtkFieldListIterator(vtkFieldList* list)
+ {
+ this->List = list;
+ this->Position = 0;
+ }
+ void Begin()
+ {
+ this->Position = this->List->First;
+ }
+ void Next()
+ {
+ if (this->Position)
+ {
+ this->Position = this->Position->Next;
+ }
+ }
+ int End()
+ {
+ return this->Position ? 0 : 1;
+ }
+ vtkFieldNode* Get()
+ {
+ return this->Position;
+ }
+
+private:
+ vtkFieldNode* Position;
+ vtkFieldList* List;
+};
+
+//------------------------------------------------------------------------------
+
+// Create object with no input or output.
+VTKViewer_MergeFilter::VTKViewer_MergeFilter()
+{
+ this->FieldList = new vtkFieldList;
+ this->SetNumberOfInputPorts(6);
+}
+
+VTKViewer_MergeFilter::~VTKViewer_MergeFilter()
+{
+ delete this->FieldList;
+}
+
+vtkDataSet* VTKViewer_MergeFilter::GetGeometry()
+{
+ if (this->GetNumberOfInputConnections(0) < 1)
+ {
+ return NULL;
+ }
+ return vtkDataSet::SafeDownCast(
+ this->GetExecutive()->GetInputData(0, 0));
+}
+
+void VTKViewer_MergeFilter::SetScalars(vtkDataSet *input)
+{
+ this->SetInput(1, input);
+}
+vtkDataSet *VTKViewer_MergeFilter::GetScalars()
+{
+ if (this->GetNumberOfInputConnections(1) < 1)
+ {
+ return NULL;
+ }
+ return vtkDataSet::SafeDownCast(
+ this->GetExecutive()->GetInputData(1, 0));
+}
+
+void VTKViewer_MergeFilter::SetVectors(vtkDataSet *input)
+{
+ this->SetInput(2, input);
+}
+vtkDataSet *VTKViewer_MergeFilter::GetVectors()
+{
+ if (this->GetNumberOfInputConnections(2) < 1)
+ {
+ return NULL;
+ }
+ return vtkDataSet::SafeDownCast(
+ this->GetExecutive()->GetInputData(2, 0));
+}
+
+void VTKViewer_MergeFilter::SetNormals(vtkDataSet *input)
+{
+ this->SetInput(3, input);
+}
+vtkDataSet *VTKViewer_MergeFilter::GetNormals()
+{
+ if (this->GetNumberOfInputConnections(3) < 1)
+ {
+ return NULL;
+ }
+ return vtkDataSet::SafeDownCast(
+ this->GetExecutive()->GetInputData(3, 0));
+}
+
+void VTKViewer_MergeFilter::SetTCoords(vtkDataSet *input)
+{
+ this->SetInput(4, input);
+}
+vtkDataSet *VTKViewer_MergeFilter::GetTCoords()
+{
+ if (this->GetNumberOfInputConnections(4) < 1)
+ {
+ return NULL;
+ }
+ return vtkDataSet::SafeDownCast(
+ this->GetExecutive()->GetInputData(4, 0));
+}
+
+void VTKViewer_MergeFilter::SetTensors(vtkDataSet *input)
+{
+ this->SetInput(5, input);
+}
+vtkDataSet *VTKViewer_MergeFilter::GetTensors()
+{
+ if (this->GetNumberOfInputConnections(5) < 1)
+ {
+ return NULL;
+ }
+ return vtkDataSet::SafeDownCast(
+ this->GetExecutive()->GetInputData(5, 0));
+}
+
+void VTKViewer_MergeFilter::AddField(const char* name, vtkDataSet* input)
+{
+ this->FieldList->Add(name, input);
+}
+
+int VTKViewer_MergeFilter::RequestData(
+ vtkInformation *vtkNotUsed(request),
+ vtkInformationVector **inputVector,
+ vtkInformationVector *outputVector)
+{
+ // get the info objects
+ vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
+ vtkInformation *outInfo = outputVector->GetInformationObject(0);
+ vtkInformation *scalarsInfo = inputVector[1]->GetInformationObject(0);
+ vtkInformation *vectorsInfo = inputVector[2]->GetInformationObject(0);
+ vtkInformation *normalsInfo = inputVector[3]->GetInformationObject(0);
+ vtkInformation *tCoordsInfo = inputVector[4]->GetInformationObject(0);
+ vtkInformation *tensorsInfo = inputVector[5]->GetInformationObject(0);
+
+ // get the input and ouptut
+ vtkDataSet *input = vtkDataSet::SafeDownCast(
+ inInfo->Get(vtkDataObject::DATA_OBJECT()));
+ vtkDataSet *output = vtkDataSet::SafeDownCast(
+ outInfo->Get(vtkDataObject::DATA_OBJECT()));
+ vtkDataSet *scalarsData = 0;
+ vtkDataSet *vectorsData = 0;
+ vtkDataSet *normalsData = 0;
+ vtkDataSet *tCoordsData = 0;
+ vtkDataSet *tensorsData = 0;
+ if (scalarsInfo)
+ {
+ scalarsData = vtkDataSet::SafeDownCast(
+ scalarsInfo->Get(vtkDataObject::DATA_OBJECT()));
+ }
+ if (vectorsInfo)
+ {
+ vectorsData = vtkDataSet::SafeDownCast(
+ vectorsInfo->Get(vtkDataObject::DATA_OBJECT()));
+ }
+ if (normalsInfo)
+ {
+ normalsData = vtkDataSet::SafeDownCast(
+ normalsInfo->Get(vtkDataObject::DATA_OBJECT()));
+ }
+ if (tCoordsInfo)
+ {
+ tCoordsData = vtkDataSet::SafeDownCast(
+ tCoordsInfo->Get(vtkDataObject::DATA_OBJECT()));
+ }
+ if (tensorsInfo)
+ {
+ tensorsData = vtkDataSet::SafeDownCast(
+ tensorsInfo->Get(vtkDataObject::DATA_OBJECT()));
+ }
+
+ vtkIdType numPts, numScalars=0, numVectors=0, numNormals=0, numTCoords=0;
+ vtkIdType numTensors=0;
+ vtkIdType numCells, numCellScalars=0, numCellVectors=0, numCellNormals=0;
+ vtkIdType numCellTCoords=0, numCellTensors=0;
+ vtkPointData *pd;
+ vtkDataArray *scalars = NULL;
+ vtkDataArray *vectors = NULL;
+ vtkDataArray *normals = NULL;
+ vtkDataArray *tcoords = NULL;
+ vtkDataArray *tensors = NULL;
+ vtkCellData *cd;
+ vtkDataArray *cellScalars = NULL;
+ vtkDataArray *cellVectors = NULL;
+ vtkDataArray *cellNormals = NULL;
+ vtkDataArray *cellTCoords = NULL;
+ vtkDataArray *cellTensors = NULL;
+ vtkPointData *outputPD = output->GetPointData();
+ vtkCellData *outputCD = output->GetCellData();
+
+ vtkDebugMacro(<<"Merging data!");
+
+ // geometry needs to be copied
+ output->CopyStructure(input);
+ if ( (numPts = input->GetNumberOfPoints()) < 1 )
+ {
+ vtkWarningMacro(<<"Nothing to merge!");
+ }
+ numCells = input->GetNumberOfCells();
+
+ if ( scalarsData )
+ {
+ pd = scalarsData->GetPointData();
+ scalars = pd->GetScalars();
+ if ( scalars != NULL )
+ {
+ numScalars = scalars->GetNumberOfTuples();
+ }
+ cd = scalarsData->GetCellData();
+ cellScalars = cd->GetScalars();
+ if ( cellScalars != NULL )
+ {
+ numCellScalars = cellScalars->GetNumberOfTuples();
+ }
+ }
+
+ if ( vectorsData )
+ {
+ pd = vectorsData->GetPointData();
+ vectors = pd->GetVectors();
+ if ( vectors != NULL )
+ {
+ numVectors= vectors->GetNumberOfTuples();
+ }
+ cd = vectorsData->GetCellData();
+ cellVectors = cd->GetVectors();
+ if ( cellVectors != NULL )
+ {
+ numCellVectors = cellVectors->GetNumberOfTuples();
+ }
+ }
+
+ if ( normalsData )
+ {
+ pd = normalsData->GetPointData();
+ normals = pd->GetNormals();
+ if ( normals != NULL )
+ {
+ numNormals= normals->GetNumberOfTuples();
+ }
+ cd = normalsData->GetCellData();
+ cellNormals = cd->GetNormals();
+ if ( cellNormals != NULL )
+ {
+ numCellNormals = cellNormals->GetNumberOfTuples();
+ }
+ }
+
+ if ( tCoordsData )
+ {
+ pd = tCoordsData->GetPointData();
+ tcoords = pd->GetTCoords();
+ if ( tcoords != NULL )
+ {
+ numTCoords= tcoords->GetNumberOfTuples();
+ }
+ cd = tCoordsData->GetCellData();
+ cellTCoords = cd->GetTCoords();
+ if ( cellTCoords != NULL )
+ {
+ numCellTCoords = cellTCoords->GetNumberOfTuples();
+ }
+ }
+
+ if ( tensorsData )
+ {
+ pd = tensorsData->GetPointData();
+ tensors = pd->GetTensors();
+ if ( tensors != NULL )
+ {
+ numTensors = tensors->GetNumberOfTuples();
+ }
+ cd = tensorsData->GetCellData();
+ cellTensors = cd->GetTensors();
+ if ( cellTensors != NULL )
+ {
+ numCellTensors = cellTensors->GetNumberOfTuples();
+ }
+ }
+
+ // merge data only if it is consistent
+ if ( numPts == numScalars )
+ {
+ outputPD->SetScalars(scalars);
+ }
+ if ( numCells == numCellScalars )
+ {
+ outputCD->SetScalars(cellScalars);
+ }
+
+ if ( numPts == numVectors )
+ {
+ outputPD->SetVectors(vectors);
+ }
+ if ( numCells == numCellVectors )
+ {
+ outputCD->SetVectors(cellVectors);
+ }
+
+ if ( numPts == numNormals )
+ {
+ outputPD->SetNormals(normals);
+ }
+ if ( numCells == numCellNormals )
+ {
+ outputCD->SetNormals(cellNormals);
+ }
+
+ if ( numPts == numTCoords )
+ {
+ outputPD->SetTCoords(tcoords);
+ }
+ if ( numCells == numCellTCoords )
+ {
+ outputCD->SetTCoords(cellTCoords);
+ }
+
+ if ( numPts == numTensors )
+ {
+ outputPD->SetTensors(tensors);
+ }
+ if ( numCells == numCellTensors )
+ {
+ outputCD->SetTensors(cellTensors);
+ }
+
+ vtkFieldListIterator it(this->FieldList);
+ vtkDataArray* da;
+ const char* name;
+ vtkIdType num;
+ for(it.Begin(); !it.End() ; it.Next())
+ {
+ pd = it.Get()->Ptr->GetPointData();
+ cd = it.Get()->Ptr->GetCellData();
+ name = it.Get()->GetName();
+ if ( (da=pd->GetArray(name)) )
+ {
+ num = da->GetNumberOfTuples();
+ if (num == numPts)
+ {
+ outputPD->AddArray(da);
+ }
+ }
+ if ( (da=cd->GetArray(name)) )
+ {
+ num = da->GetNumberOfTuples();
+// RKV: Fixed to be able to pass through celldata arrays given by AddField()
+// RKV if (num == numPts)
+ if (num == numCells) // RKV
+ {
+ outputCD->AddArray(da);
+ }
+ }
+ }
+
+ return 1;
+}
+
+//----------------------------------------------------------------------------
+// Trick: Abstract data types that may or may not be the same type
+// (structured/unstructured), but the points/cells match up.
+// Output/Geometry may be structured while ScalarInput may be
+// unstructured (but really have same triagulation/topology as geometry).
+// Just request all the input. Always generate all of the output (todo).
+int VTKViewer_MergeFilter::RequestUpdateExtent(
+ vtkInformation *vtkNotUsed(request),
+ vtkInformationVector **inputVector,
+ vtkInformationVector *vtkNotUsed(outputVector))
+{
+ vtkInformation *inputInfo;
+ int idx;
+
+ for (idx = 0; idx < 6; ++idx)
+ {
+ inputInfo = inputVector[idx]->GetInformationObject(0);
+ if (inputInfo)
+ {
+ inputInfo->Set(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER(),
+ 0);
+ inputInfo->Set(vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_PIECES(),
+ 1);
+ inputInfo->Set(vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_GHOST_LEVELS(),
+ 0);
+ inputInfo->Set(vtkStreamingDemandDrivenPipeline::EXACT_EXTENT(), 1);
+ }
+ }
+ return 1;
+}
+
+int VTKViewer_MergeFilter::FillInputPortInformation(int port, vtkInformation *info)
+{
+ int retval = this->Superclass::FillInputPortInformation(port, info);
+ if (port > 0)
+ {
+ info->Set(vtkAlgorithm::INPUT_IS_OPTIONAL(), 1);
+ }
+ return retval;
+}
+
+void VTKViewer_MergeFilter::PrintSelf(ostream& os, vtkIndent indent)
+{
+ this->Superclass::PrintSelf(os,indent);
+
+}
+
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// 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
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef __VTKViewer_MergeFilter_h
+#define __VTKViewer_MergeFilter_h
+
+#include "VTKViewer.h" // RKV
+#include "vtkDataSetAlgorithm.h"
+
+class vtkFieldList;
+
+// .NAME VTKViewer_MergeFilter - extract separate components of data from different datasets
+// .SECTION Description
+// VTKViewer_MergeFilter is a filter that extracts separate components of data from
+// different datasets and merges them into a single dataset. The output from
+// this filter is of the same type as the input (i.e., vtkDataSet.) It treats
+// both cell and point data set attributes.
+
+// RKV: The source is vtkMergeFilter.
+// RKV: Fixed to be able to pass through celldata arrays given by AddField()
+
+//RKV class VTK_GRAPHICS_EXPORT VTKViewer_MergeFilter : public vtkDataSetToDataSetFilter
+class VTKVIEWER_EXPORT VTKViewer_MergeFilter : public vtkDataSetAlgorithm // RKV
+{
+public:
+ static VTKViewer_MergeFilter *New();
+ vtkTypeRevisionMacro(VTKViewer_MergeFilter,vtkDataSetAlgorithm);
+ void PrintSelf(ostream& os, vtkIndent indent);
+
+ // Description:
+ // Specify object from which to extract geometry information.
+ void SetGeometry(vtkDataSet *input) {this->SetInput(input);};
+ vtkDataSet *GetGeometry();
+
+ // Description:
+ // Specify object from which to extract scalar information.
+ void SetScalars(vtkDataSet *);
+ vtkDataSet *GetScalars();
+
+ // Description:
+ // Set / get the object from which to extract vector information.
+ void SetVectors(vtkDataSet *);
+ vtkDataSet *GetVectors();
+
+ // Description:
+ // Set / get the object from which to extract normal information.
+ void SetNormals(vtkDataSet *);
+ vtkDataSet *GetNormals();
+
+ // Description:
+ // Set / get the object from which to extract texture coordinates
+ // information.
+ void SetTCoords(vtkDataSet *);
+ vtkDataSet *GetTCoords();
+
+ // Description:
+ // Set / get the object from which to extract tensor data.
+ void SetTensors(vtkDataSet *);
+ vtkDataSet *GetTensors();
+
+ // Description:
+ // Set the object from which to extract a field and the name
+ // of the field
+ void AddField(const char* name, vtkDataSet* input);
+
+protected:
+ VTKViewer_MergeFilter();
+ ~VTKViewer_MergeFilter();
+
+ // Usual data generation method
+ int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
+ int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
+ int FillInputPortInformation(int port, vtkInformation *info);
+
+ vtkFieldList* FieldList;
+private:
+ VTKViewer_MergeFilter(const VTKViewer_MergeFilter&); // Not implemented.
+ void operator=(const VTKViewer_MergeFilter&); // Not implemented.
+ };
+
+#endif
+
+
{
if ( myVTK2ObjIds.empty() || theVtkID > (int)myVTK2ObjIds.size() )
return -1;
- return myVTK2ObjIds.at(theVtkID);
+ return myVTK2ObjIds[theVtkID];
}
}
return false;
-
- /*
- vtkFloatingPointType aBounds[6];
- int aCount = ComputeVisiblePropBounds(theRenderer,aBounds);
- printf("aNewBndBox[0] = %f, aNewBndBox[1] = %f,\naNewBndBox[2] = %f, aNewBndBox[3] = %f,\naNewBndBox[4] = %f, aNewBndBox[5] = %f\n",
- aBounds[0],aBounds[1],aBounds[2],aBounds[3],aBounds[4],aBounds[5]);
- printf("aCount = %d\n",aCount);
-
- if(aCount){
- static vtkFloatingPointType MIN_DISTANCE = 1.0 / VTK_LARGE_FLOAT;
-
- vtkFloatingPointType aLength = aBounds[1]-aBounds[0];
- aLength = max((aBounds[3]-aBounds[2]),aLength);
- aLength = max((aBounds[5]-aBounds[4]),aLength);
-
- if(aLength < MIN_DISTANCE)
- return false;
-
- vtkFloatingPointType aWidth =
- sqrt((aBounds[1]-aBounds[0])*(aBounds[1]-aBounds[0]) +
- (aBounds[3]-aBounds[2])*(aBounds[3]-aBounds[2]) +
- (aBounds[5]-aBounds[4])*(aBounds[5]-aBounds[4]));
-
- if(aWidth < MIN_DISTANCE)
- return false;
-
- theCenter[0] = (aBounds[0] + aBounds[1])/2.0;
- theCenter[1] = (aBounds[2] + aBounds[3])/2.0;
- theCenter[2] = (aBounds[4] + aBounds[5])/2.0;
- return true;
- }
- return false;*/
}