SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
SET(${PROJECT_NAME_UC}_VERSION
${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
-SET(${PROJECT_NAME_UC}_VERSION_DEV 0)
+SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
# Common CMake macros
# ===================
ImageComposer
)
-# CAF package (not compilable while TDocStd_Application::Formats is removed)
-IF(CAS_VERSION_STR VERSION_LESS "7.0.1")
- LIST(APPEND _${PROJECT_NAME}_exposed_targets
- caf)
-ENDIF()
-
IF(SALOME_USE_OCCVIEWER OR SALOME_USE_VTKVIEWER OR SALOME_USE_GLVIEWER)
LIST(APPEND _${PROJECT_NAME}_exposed_targets
OpenGLUtils)
#include <QStringList>
#include <Resource_Manager.hxx>
-#include <TColStd_SequenceOfExtendedString.hxx>
+#include <TColStd_SequenceOfAsciiString.hxx>
/*!
\brief Create new instance of CAF_Application.
\return file filters for open/save document dialog box
*/
-QString CAF_Application::getFileFilter() const
+QString CAF_Application::getFileFilter( bool open ) const
{
if ( stdApp().IsNull() )
return QString();
- TColStd_SequenceOfExtendedString formats;
- stdApp()->Formats( formats );
+ TColStd_SequenceOfAsciiString formats;
+ if ( open )
+ stdApp()->ReadingFormats( formats );
+ else
+ stdApp()->WritingFormats( formats );
QStringList allWC;
QMap<QString, QStringList> wildCards;
Handle(TDocStd_Application) stdApp() const;
- virtual QString getFileFilter() const;
+ virtual QString getFileFilter( bool ) const;
public slots:
virtual void onHelpAbout();
#include <TDF_Delta.hxx>
#include <TDF_ListIteratorOfDeltaList.hxx>
-
+#include <TColStd_SequenceOfAsciiString.hxx>
#include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx>
{
try {
OCC_CATCH_SIGNALS;
- TColStd_SequenceOfExtendedString formats;
- app->stdApp()->Formats( formats );
+ TColStd_SequenceOfAsciiString formats;
+ app->stdApp()->WritingFormats( formats );
+ if ( formats.IsEmpty() )
+ app->stdApp()->ReadingFormats( formats );
if ( !formats.IsEmpty() )
app->stdApp()->NewDocument( formats.First(), myStdDoc );
}
if ( !modLibrary.isEmpty() )
{
modLibrary = SUIT_Tools::file( modLibrary.trimmed() );
-#ifdef WIN32
+#if defined(WIN32)
QString libExt = QString( "dll" );
+#elif defined(__APPLE__)
+ QString libExt = QString( "dylib" );
#else
QString libExt = QString( "so" );
#endif
ADD_SUBDIRECTORY(SUIT)
ADD_SUBDIRECTORY(SUITApp)
ADD_SUBDIRECTORY(STD)
-# CAF package (not compilable while TDocStd_Application::Formats is removed)
-IF(CAS_VERSION_STR VERSION_LESS "7.0.1")
- ADD_SUBDIRECTORY(CAF)
-ENDIF()
+ADD_SUBDIRECTORY(CAF)
ADD_SUBDIRECTORY(CAM)
ADD_SUBDIRECTORY(LogWindow)
ADD_SUBDIRECTORY(Prs)
# libraries to link to
SET(_link_LIBRARIES ${QT_LIBRARIES} ${CAS_KERNEL} ${OPENGL_LIBRARIES} qtx suit)
-IF(NOT WIN32)
+IF(NOT (WIN32 OR APPLE))
LIST(APPEND _link_LIBRARIES Xmu)
ENDIF()
// Qt includes
#include <QColor>
-
-#ifndef WIN32
+#if !defined(WIN32) && !defined(__APPLE__)
#include <GL/glx.h>
#endif
GLfloat xa, xb, ya, yb, l;
GLfloat rsin, rcos, r, ra, rb;
// GLboolean update;
- GLboolean selected = myIsSel;
+ // GLboolean selected = myIsSel;
myIsSel = GL_FALSE;
#include <Quantity_NameOfColor.hxx>
#include <Quantity_Color.hxx>
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
class GLViewer_Viewer2d;
#include <QPainter>
#include <QFile>
-#ifndef WIN32
+#if defined(__APPLE__)
+#include <OpenGL/CGLCurrent.h>
+#elif !defined(WIN32)
#include <GL/glx.h>
#endif
aFindFont.myIsUndl = theFont->underline();
aFindFont.myPointSize = theFont->pointSize();
-#ifdef WIN32
+#if defined(WIN32)
HGLRC ctx = ::wglGetCurrentContext();
if ( !ctx )
return aList;
aList = listBase;
GLViewer_TexFont::BitmapFontCache[aFindFont] = aList;
}
+#elif defined(__APPLE__)
+ CGLContextObj ctx = ::CGLGetCurrentContext();
+ if ( !ctx )
+ return aList;
+
+ aFindFont.myViewPortId = (long)ctx;
+
+ if ( GLViewer_TexFont::BitmapFontCache.contains( aFindFont ) )
+ aList = GLViewer_TexFont::BitmapFontCache[aFindFont];
+ else
+ {
+ GLuint listBase = 0;
+ QMap<GLViewer_TexFindId, GLuint>::iterator it = GLViewer_TexFont::BitmapFontCache.begin();
+ for ( ; it != GLViewer_TexFont::BitmapFontCache.end(); ++it )
+ {
+ if ( it.key().myViewPortId == (long)ctx && it.value() > listBase )
+ listBase = it.value();
+ }
+ listBase += 256;
+
+ //HDC glHdc = ::wglGetCurrentDC();
+ //::SelectObject( glHdc, theFont->handle() );
+ //if ( !::wglUseFontBitmaps( glHdc, 0, 256, listBase ) )
+ // listBase = 0;
+ aList = listBase;
+ GLViewer_TexFont::BitmapFontCache[aFindFont] = aList;
+ }
#else //X Window
Display* aDisp = glXGetCurrentDisplay();
if( !aDisp )
class QFile;
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
#include "GLViewer.h"
#include "GLViewer_Defs.h"
bool myIsUndl;
//! Font Size
int myPointSize;
- //! View POrt ID
- int myViewPortId;
+ //! View Port ID
+ long myViewPortId;
//! Overloaded operator for using struct as MAP key
bool operator < (const GLViewer_TexFindId theStruct) const
{
#include "GLViewer.h"
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#include <OpenGL/glu.h>
+#else
#include <GL/gl.h>
#include <GL/glu.h>
+#endif
#ifdef WIN32
#pragma warning( disable:4251 )
*/
QByteArray GLViewer_MimeData::encodedData( const char* theObjectType ) const
{
- if( theObjectType == "GLViewer_Objects" )
- return myByteArray;
-
- return QByteArray();
+ if ( theObjectType && strcmp( theObjectType, "GLViewer_Objects" ) == 0 )
+ return myByteArray;
+
+ return QByteArray();
}
#include "GLViewer.h"
#include "GLViewer_Geom.h"
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
#include <QString>
#include "GLViewer.h"
#include "GLViewer_Defs.h"
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
#include <QFont>
#include <QString>
//
#include "GLViewer_Tools.h"
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
#include <iostream>
#include <string.h>
#include <stdlib.h>
-#if !defined WIN32
+#if !defined WIN32 && !defined __APPLE__
#include <QX11Info>
#include <GL/glx.h>
#include <X11/Xlib.h>
*/
void GLViewer_ViewPort::selectVisualId( ViewType type )
{
-#if !defined WIN32
+#if !defined WIN32 && !defined __APPLE__
XVisualInfo* pVisualInfo;
if ( QX11Info::display() )
{
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#include <OpenGL/glu.h>
+#else
#include <GL/gl.h>
#include <GL/glu.h>
+#endif
#include "GLViewer_ViewPort.h"
#include "GLViewer_Widget.h"
#include <TColStd_SequenceOfInteger.hxx>
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
class GLViewer_Object;
class GLViewer_ViewFrame;
}
/*!Gets file filter.
- *\retval QString "(*.bin)"
+ *\retval QString "(*.hdf)"
*/
-QString LightApp_Application::getFileFilter() const
+QString LightApp_Application::getFileFilter( bool /*open*/) const
{
- //return "(*.bin)";
- // HDF persistence
return "(*.hdf)";
}
bool isPythonLightModule = lib.contains("SalomePyQtGUILight");
QStringList paths;
-#ifdef WIN32
+#if defined(WIN32)
paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
+#elif defined(__APPLE__)
+ paths = QString(::getenv( "DYLD_LIBRARY_PATH" )).split( ":", QString::SkipEmptyParts );
#else
paths = QString(::getenv( "LD_LIBRARY_PATH" )).split( ":", QString::SkipEmptyParts );
#endif
LightApp_Preferences* preferences() const;
- virtual QString getFileFilter() const;
+ virtual QString getFileFilter( bool ) const;
virtual QString getFileName( bool open, const QString& initial, const QString& filters,
const QString& caption, QWidget* parent );
<!-- External HELP browser settings -->
<parameter name="winapplication" value="C:\Program Files\Internet Explorer\iexplore.exe" />
<parameter name="use_external_browser" value="false" />
- <parameter name="application" value="/usr/bin/mozilla" />
+ <parameter name="application" value="/usr/bin/firefox" />
<parameter name="parameters" value="" />
</section>
<section name="add_help">
<name>@default</name>
<message>
<source>EXTERNAL_BROWSER_CANNOT_SHOW_PAGE</source>
- <translation>External browser "%1" can not show help page "%2". Do you want to change it in preferences?</translation>
+ <translation>External browser "%1" can not show help page "%2". Do you want to change the browser's settings in preferences?</translation>
</message>
<message>
<source>ABOUT_COPYRIGHT</source>
<name>@default</name>
<message>
<source>EXTERNAL_BROWSER_CANNOT_SHOW_PAGE</source>
- <translation>Le navigateur externe "%1" ne peut pas trouver la page d'aide "%2". Voulez-vous le modifierdans les préférences ?</translation>
+ <translation>Le navigateur externe "%1" ne peut pas trouver la page d'aide "%2". Voulez-vous modifier les settings du navigateur externe dans les préférences ?</translation>
</message>
<message>
<source>ABOUT_COPYRIGHT</source>
return false;
AIS_StatusOfDetection status = AIS_SOD_Error;
- status = myAISContext->MoveTo (x, y, view);
-
+ status = myAISContext->MoveTo ( x, y, view, Standard_True );
return ( status != AIS_SOD_Error && status != AIS_SOD_AllBad );
}
bool hadSelection = ( myNumSelected > 0 );
/* select and send notifications */
- return checkSelection ( myAISContext->Select(), hadSelection, false );
+ return checkSelection ( myAISContext->Select( Standard_True ), hadSelection, false );
}
/*!
bool hadSelection = ( myNumSelected > 0 );
/* select and send notifications */
- return checkSelection ( myAISContext->Select(left, top, right, bottom, view),
- hadSelection, false );
+ return checkSelection ( myAISContext->Select( left, top, right, bottom, view, Standard_True ),
+ hadSelection, false );
}
/*!
return false;
/* select and send notifications */
- return checkSelection ( myAISContext->ShiftSelect(), hadSelection, true );
+ return checkSelection ( myAISContext->ShiftSelect( Standard_True ), hadSelection, true );
}
/*!
return false;
/* select and send notifications */
- return checkSelection ( myAISContext->ShiftSelect(left,top,right,bottom, view),
- hadSelection, true );
+ return checkSelection ( myAISContext->ShiftSelect( left, top, right, bottom, view, Standard_True ),
+ hadSelection, true );
}
thePlane->SetToUpdate();
thePlane->UpdateSelection();
- myViewer->getAISContext()->Update( thePlane );
+ myViewer->getAISContext()->Update( thePlane , Standard_True );
}
break;
thePlane->SetToUpdate();
thePlane->UpdateSelection();
- myViewer->getAISContext()->Update( thePlane );
+ myViewer->getAISContext()->Update( thePlane , Standard_True );
}
break;
}
Handle(AIS_InteractiveContext) anAISContext = myViewer->getAISContext();
// check detection of plane
- anAISContext->MoveTo( theEvent->x(), theEvent->y(), aView3D );
+ anAISContext->MoveTo( theEvent->x(), theEvent->y(), aView3D , Standard_True );
if ( !anAISContext->HasDetected() )
{
// process mouse click on the object
if ( myIsClickable )
{
- myViewer->getAISContext()->SetSelected( Handle(AIS_InteractiveObject)::DownCast(aPlane) );
+ myViewer->getAISContext()->SetSelected( Handle(AIS_InteractiveObject)::DownCast(aPlane) , Standard_True );
emit planeClicked( aPlane );
}
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
#include "OCCViewer_Trihedron.h"
#include <PrsMgr_PresentationManager3d.hxx>
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
# include <GL/glx.h>
#endif
bool ok = false;
GLuint aList = glGenLists( 256 );
-#ifdef WIN32
+#if defined(WIN32)
HGLRC hglrc = wglGetCurrentContext();
if( hglrc )
{
SelectObject( hdc, oldFont );
DeleteObject( font );
}
-#else // X Window
+#elif !defined(__APPLE__) // X Window
Display* dpy = glXGetCurrentDisplay();
if( dpy )
{
#endif
#include <Aspect_DisplayConnection.hxx>
-#ifdef WIN32
+#if defined(WIN32)
#include <WNT_Window.hxx>
+#elif defined(__APPLE__)
+#include <Cocoa_Window.hxx>
#else
#include <Xw_Window.hxx>
#endif
WId winId )
{
Aspect_Handle aWindowHandle = (Aspect_Handle)winId;
-#ifdef WIN32
+#if defined(WIN32)
Handle(WNT_Window) viewWindow = new WNT_Window( aWindowHandle );
+#elif defined(__APPLE__)
+ Handle(Cocoa_Window) viewWindow = new Cocoa_Window( (NSView*)winId );
#else
Handle(Aspect_DisplayConnection) aDispConnection = view->Viewer()->Driver()->GetDisplayConnection();
Handle(Xw_Window) viewWindow = new Xw_Window( aDispConnection, aWindowHandle );
if (aGraphicDriver.IsNull())
{
Handle(Aspect_DisplayConnection) aDisplayConnection;
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
aDisplayConnection = new Aspect_DisplayConnection( displayName );
#else
aDisplayConnection = new Aspect_DisplayConnection();
#endif
}
-#if OCC_VERSION_LARGE > 0x07000000
+#if OCC_VERSION_LARGE > 0x07010000
return new V3d_Viewer( aGraphicDriver, name, domain, viewSize, viewProjection,
- Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT,
+ Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD,
computedMode, defaultComputedMode );
+
+#elif OCC_VERSION_LARGE > 0x07000000
+ return new V3d_Viewer( aGraphicDriver, name, domain, viewSize, viewProjection,
+ Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT,
+ computedMode, defaultComputedMode );
#else
return new V3d_Viewer( aGraphicDriver, name, domain, viewSize, viewProjection,
Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT,
// init selector
myAISContext = new AIS_InteractiveContext( myV3dViewer );
-#if OCC_VERSION_LARGE > 0x07000000
-
+#if OCC_VERSION_LARGE > 0x07010000
+ myAISContext->HighlightStyle(Prs3d_TypeOfHighlight_LocalSelected)->SetColor( Quantity_NOC_WHITE );
+ myAISContext->HighlightStyle(Prs3d_TypeOfHighlight_Selected)->SetColor( Quantity_NOC_WHITE );
+#elif OCC_VERSION_LARGE > 0x07000000
const Handle(Graphic3d_HighlightStyle)& sStyle = myAISContext->SelectionStyle();
- sStyle->SetColor( Quantity_NOC_WHITE );
-#else
+ sStyle->SetColor( Quantity_NOC_WHITE );
+#else
myAISContext->SelectionColor( Quantity_NOC_WHITE );
-#endif
+#endif
// display isoline on planar faces (box for ex.)
myAISContext->IsoOnPlane( true );
}
Handle(V3d_View) aView3d = aView->getViewPort()->getView();
if ( !aView3d.IsNull() ) {
- myAISContext->MoveTo(theEvent->x(), theEvent->y(), aView3d);
+ myAISContext->MoveTo( theEvent->x(), theEvent->y(), aView3d, Standard_True );
}
}
}
if ( !isPreselectionEnabled() ) {
Handle(V3d_View) aView3d = aView->getViewPort()->getView();
if ( !aView3d.IsNull() ) {
- myAISContext->MoveTo(myEndPnt.x(), myEndPnt.y(), aView3d);
+ myAISContext->MoveTo( myEndPnt.x(), myEndPnt.y(), aView3d, Standard_True );
}
}
if (aHasShift && myMultiSelectionEnabled)
- myAISContext->ShiftSelect();
- else
- myAISContext->Select();
+ myAISContext->ShiftSelect( Standard_True );
+ else
+ myAISContext->Select( Standard_True );
}
else
{
if ( !isPreselectionEnabled() ) {
Handle(V3d_View) aView3d = aView->getViewPort()->getView();
if ( !aView3d.IsNull() ) {
- myAISContext->MoveTo(myCurPnt.x(), myCurPnt.y(), aView3d);
+ myAISContext->MoveTo(myCurPnt.x(), myCurPnt.y(), aView3d, Standard_True );
}
}
if (aHasShift && myMultiSelectionEnabled)
- myAISContext->ShiftSelect();
+ myAISContext->ShiftSelect( Standard_True );
else
- myAISContext->Select();
+ myAISContext->Select( Standard_True );
emit selectionChanged();
myAISContext->Deactivate( myTrihedron );
}
else {
- myAISContext->Erase( myTrihedron );
+ myAISContext->Erase( myTrihedron , Standard_True );
}
}
void getSelectedObjects(AIS_ListOfInteractive& theList);
void setObjectsSelected(const AIS_ListOfInteractive& theList);
- void setSelected(const Handle(AIS_InteractiveObject)& theIO) { myAISContext->SetSelected(theIO);}
+ void setSelected(const Handle(AIS_InteractiveObject)& theIO) { myAISContext->SetSelected(theIO,Standard_True);}
void performSelectionChanged();
// emit signal selectionChanged
#include <stdlib.h>
-#if !defined WIN32
+#if !defined WIN32 && !defined __APPLE__
#include <QX11Info>
#include <GL/glx.h>
#include <X11/Xlib.h>
*/
void OCCViewer_ViewPort::selectVisualId()
{
-#if !defined WIN32
+#if !defined WIN32 && !defined __APPLE__
XVisualInfo* pVisualInfo;
if ( QX11Info::display() )
{
/* update */
tgtView->Update();
tgtView->SetImmediateUpdate( Standard_True );
+#if OCC_VERSION_LARGE <= 0x07000000
tgtView->ZFitAll();
+#endif
return true;
}
+#if OCC_VERSION_LARGE <= 0x07000000
/*!
Returns Z-size of this view. [ public ]
*/
if ( !myPerspView.IsNull() )
myPerspView->SetZSize( zsize );*/
}
+#endif
/*!
Get axial scale to the view
void OCCViewer_ViewPort3d::endRotation()
{
if ( !activeView().IsNull() ) {
+#if OCC_VERSION_LARGE <= 0x07000000
activeView()->ZFitAll( 1.0 );
-#if OCC_VERSION_LARGE <= 0x06070100
activeView()->SetZSize( 0.0 );
#endif
activeView()->Update();
#if OCC_VERSION_LARGE > 0x06070100
activeView()->FitAll( margin, upd );
+#if OCC_VERSION_LARGE <= 0x07000000
if(withZ)
activeView()->ZFitAll();
-#else
+#endif
+#else
activeView()->FitAll( margin, withZ, upd );
-#endif
activeView()->SetZSize(0.);
+#endif
emit vpTransformed( this );
}
aView3d->SetViewMapping( aRefView3d->ViewMapping() );
aView3d->SetViewOrientation( aRefView3d->ViewOrientation() );
#endif
+#if OCC_VERSION_LARGE <= 0x07000000
aView3d->ZFitAll();
+#endif
aView3d->SetImmediateUpdate( Standard_True );
aView3d->Update();
blockSignals( blocked );
// void setActive( V3d_TypeOfView );
virtual bool syncronize( const OCCViewer_ViewPort3d* );
+#if OCC_VERSION_LARGE <= 0x07000000
double getZSize() const;
void setZSize( double );
+#endif
void getAxialScale( double&, double&, double& );
if ( state != Fin )
p.drawPolyline( *mypPoints );
}*/
- if ( mypPolyRB )
- {
+ if ( mypPolyRB ) {
+ if ( state == Fin ) {
+ mypPolyRB->clearGeometry();
+ mypPolyRB->hide();
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+ QApplication::syncX();
+#endif
+ mypViewWindow->activateSketching( OCCViewer_ViewWindow::NoSketching );
+ } else {
mypPolyRB->setUpdatesEnabled ( false );
if ( !mypPolyRB->isVisible() )
- mypPolyRB->show();
+ mypPolyRB->show();
//if ( state != Debut )
// mypPolyRB->repaint();
-
+
if ( state != Fin && points->count() )
- mypPolyRB->initGeometry( QPolygon(*points) << myCurr );
+ mypPolyRB->initGeometry( QPolygon(*points) << myCurr );
//mypPolyRB->addNode( myCurr );
-
+
//if ( state != Fin )
// mypPolyRB->repaint();
mypPolyRB->setUpdatesEnabled ( true );
//mypPolyRB->repaint();
}
-
- if ( state == Fin )
- {
- if ( mypPolyRB )
- {
- mypPolyRB->clearGeometry();
- mypPolyRB->hide();
- }
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- QApplication::syncX();
-#endif
- mypViewWindow->activateSketching( OCCViewer_ViewWindow::NoSketching );
}
}
//# include <QWindowsStyle>
//#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
// To avoid conflict between KeyPress from the X.h (define KeyPress 2)
// and QEvent::KeyPress (qevent.h)
int x1 = (int)( aEvent->x() + width()*delta/100 );
int y1 = (int)( aEvent->y() + height()*delta/100 );
myViewPort->zoom( x, y, x1, y1 );
+#if OCC_VERSION_LARGE <= 0x07000000
myViewPort->getView()->ZFitAll();
+#endif
emit vpTransformationFinished ( ZOOMVIEW );
}
}
if ( theEvent->button() == Qt::LeftButton )
{
Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
- ic->Select();
+ ic->Select( Standard_True );
for ( ic->InitSelected(); ic->MoreSelected(); ic->NextSelected() )
{
TopoDS_Shape aShape = ic->SelectedShape();
}
if ( ic->NbSelected() == 0 ) myCurrPointType = myPrevPointType;
if ( mySetRotationPointDlg ) mySetRotationPointDlg->toggleChange();
- ic->CloseAllContexts();
+ ic->CloseAllContexts( Standard_True );
myOperation = NOTHING;
myViewPort->setCursor( myCursor );
myCursorIsHand = false;
if ( myRotationPointSelection )
{
Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
- ic->CloseAllContexts();
+ ic->CloseAllContexts( Standard_True );
myOperation = NOTHING;
myViewPort->setCursor( myCursor );
myCursorIsHand = false;
if ( myRotationPointSelection )
{
Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
- ic->CloseAllContexts();
+ ic->CloseAllContexts( Standard_True );
myOperation = NOTHING;
myViewPort->setCursor( myCursor );
myCursorIsHand = false;
case PANVIEW:
case ZOOMVIEW:
+#if OCC_VERSION_LARGE <= 0x07000000
myViewPort->getView()->ZFitAll();
+#endif
resetState();
break;
#endif
getViewPort()->setAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );
-
+#if OCC_VERSION_LARGE <= 0x07000000
aDestView->ZFitAll();
+#endif
aDestView->SetImmediateUpdate( Standard_True );
aDestView->Redraw();
# ifndef GLX_GLXEXT_LEGACY
# define GLX_GLXEXT_LEGACY
# endif
+#ifdef __APPLE__
+#import <mach-o/dyld.h>
+#import <stdlib.h>
+#import <string.h>
+void * glXGetProcAddressARB (const GLubyte *name)
+
+{
+ NSSymbol symbol;
+ char *symbolName;
+ symbolName = (char *)malloc (strlen ((const char *)name) + 2); // 1
+ strcpy(symbolName + 1, (const char *)name); // 2
+ symbolName[0] = '_'; // 3
+ symbol = NULL;
+ if (NSIsSymbolNameDefined (symbolName)) // 4
+ symbol = NSLookupAndBindSymbol (symbolName);
+ free (symbolName); // 5
+ return symbol ? NSAddressOfSymbol (symbol) : NULL; // 6
+}
+#else
# include <GL/glx.h>
+#endif
# include <dlfcn.h>
#else
# include <wingdi.h>
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
class OPENGLUTILS_EXPORT OpenGLUtils_FrameBuffer
{
Q_ARG( pqServerManagerModelItem* , NULL ) );
}
- publishExistingSources();
+ //publishExistingSources();
myPVWidgetsFlag = true;
}
}
QtxSlider.h
QtxSplash.h
QtxToolBar.h
+ QtxToolButton.h
QtxToolTip.h
QtxTreeView.h
QtxValidator.h
QtxSlider.cxx
QtxSplash.cxx
QtxToolBar.cxx
+ QtxToolButton.cxx
QtxToolTip.cxx
QtxTranslator.cxx
QtxTreeView.cxx
name = QString( "lib" ) + name;
#endif
-#ifdef WIN32
+#if defined(WIN32)
QString libExt( "dll" );
+#elif defined(__APPLE__)
+ QString libExt( "dylib" );
#else
QString libExt( "so" );
#endif
- if ( ext.toLower() != QString( "so" ) && ext.toLower() != QString( "dll" ) )
+ if ( ext.toLower() != QString( "so" ) && ext.toLower() != QString( "dll" ) && ext.toLower() != QString( "dylib" ) )
{
if ( !name.isEmpty() && !ext.isEmpty() )
name += QString( "." );
return font;
}
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
#include <X11/Xlib.h>
#include <GL/glx.h>
: QToolButton( parent )
{
setCheckable( false );
- setPopupMode( MenuButtonPopup ); // VSR 11/10/2010 temporarily roolback from InstantPopup (regressions)
+ setPopupMode( InstantPopup );
QMenu* pm = new QMenu( this );
QGridLayout* grid = new QGridLayout( pm );
}
/*!
- * \brief Append a title to the and of the menu
- * \param [in] text - title text
- */
-void QtxMenu::appendGroupTitle( const QString& text )
+ \brief Append group title to the end of the menu.
+ \param text group title's text
+*/
+void QtxMenu::addGroup( const QString& text )
+{
+ Title* aTitle = new Title( this );
+ aTitle->setText( text );
+
+ QWidgetAction* anAction = new QWidgetAction( this );
+ anAction->setDefaultWidget( aTitle );
+
+ addAction( anAction );
+}
+
+/*!
+ \brief Append group title to the end of the menu.
+ \param icon group title's icon
+ \param text group title's text
+*/
+void QtxMenu::addGroup( const QIcon& icon, const QString& text )
{
Title* aTitle = new Title( this );
aTitle->setText( text );
+ aTitle->setIcon( icon );
QWidgetAction* anAction = new QWidgetAction( this );
anAction->setDefaultWidget( aTitle );
virtual void setTitleMode( const TitleMode );
virtual void setTitleAlignment( const Qt::Alignment );
- virtual void appendGroupTitle( const QString& );
+ virtual void addGroup( const QString& );
+ virtual void addGroup( const QIcon&, const QString& );
public slots:
virtual void setVisible( bool );
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// 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 "QtxToolButton.h"
+#include "QtxMenu.h"
+
+#include <QKeyEvent>
+#include <QWheelEvent>
+
+namespace
+{
+ bool isSeparator( QAction* a )
+ {
+ return a->property( "separator" ).toBool();
+ }
+ void setSeparator( QAction* a )
+ {
+ a->setProperty( "separator", true );
+ }
+}
+
+/*!
+ \class QtxToolButton
+ \brief Drop-down tool button that behaves like a drop-down combo-box.
+
+ In contrast to the standard combo box, QtxToolButton can show drop-down
+ menu containing groups of items where each group has a separate title.
+*/
+
+/*!
+ \brief Constructor.
+ \param parent Parent widget.
+*/
+QtxToolButton::QtxToolButton( QWidget* parent )
+ : QToolButton( parent )
+{
+ setMenu( new QtxMenu( this ) );
+ setPopupMode( InstantPopup );
+ setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
+ connect( this, SIGNAL( triggered( QAction* ) ), this, SLOT( actionTriggered( QAction* ) ) );
+}
+
+/*!
+ \brief Destructor.
+*/
+QtxToolButton::~QtxToolButton()
+{
+}
+
+/*!
+ \brief Add an item with the given \a text, and containing the specified \a userData.
+ The item is appended to the list of existing items.
+ \param text Item's text.
+ \param userData Item's data.
+ \return Index of just added item.
+*/
+int QtxToolButton::addItem( const QString& text, const QVariant& userData )
+{
+ QAction* action = menu()->addAction( text );
+ action->setData( userData );
+ bool currentChanged = false;
+ if ( !menu()->defaultAction() ) {
+ menu()->setDefaultAction( action );
+ currentChanged = true;
+ }
+ internalUpdate();
+ if ( currentChanged ) emitCurrentChanged( false, true );
+ return count()-1;
+}
+
+/*!
+ \brief Add an item with the given \a icon and \a text, and containing the specified
+ \a userData. The item is appended to the list of existing items.
+ \param text Item's text.
+ \param icon Item's icon.
+ \param userData Item's data.
+ \return Index of just added item.
+*/
+int QtxToolButton::addItem( const QIcon& icon, const QString& text, const QVariant& userData )
+{
+ QAction* action = menu()->addAction( icon, text );
+ action->setData( userData );
+ bool currentChanged = false;
+ if ( !menu()->defaultAction() ) {
+ menu()->setDefaultAction( action );
+ currentChanged = true;
+ }
+ internalUpdate();
+ if ( currentChanged ) emitCurrentChanged( false, true );
+ return count()-1;
+}
+
+/*!
+ \brief Add items with given \a texts. Each item is appended to the list of existing
+ items in turn.
+ \param texts Items being added.
+*/
+void QtxToolButton::addItems( const QStringList& texts )
+{
+ Q_FOREACH( QString text, texts )
+ menu()->addAction( text );
+ bool currentChanged = false;
+ if ( !menu()->defaultAction() && menu()->actions().count() > 0 ) {
+ menu()->setDefaultAction( menu()->actions()[0] );
+ currentChanged = true;
+ }
+ if ( currentChanged ) emitCurrentChanged( false, true );
+ internalUpdate();
+}
+
+/*!
+ \brief Add separator to the end of the items list.
+ \param text Separator's text.
+ \return Index of just added item.
+*/
+int QtxToolButton::addSeparator( const QString& text )
+{
+ (qobject_cast<QtxMenu*>(menu()))->addGroup( text );
+ setSeparator( actionAt( count()-1 ) );
+ return count()-1;
+}
+
+/*!
+ \brief Add separator to the end of the items list.
+ \param icon Separator's icon.
+ \param text Separator's text.
+ \return Index of just added item.
+*/
+int QtxToolButton::addSeparator( const QIcon& icon, const QString& text )
+{
+ (qobject_cast<QtxMenu*>(menu()))->addGroup( icon, text );
+ setSeparator( actionAt( count()-1 ) );
+ return count()-1;
+}
+
+/*!
+ \brief Remove item with given \a index.
+ \param index Index of item to be removed.
+*/
+void QtxToolButton::removeItem( int index )
+{
+ QAction* action = actionAt( index );
+ if ( !action ) return;
+ QAction* current = menu()->defaultAction();
+ menu()->removeAction( action );
+ bool currentChanged = false;
+ if ( action == current ) {
+ for ( int i = index; i < count(); i++ ) {
+ QAction* a = actionAt( i );
+ if ( a && !isSeparator( a ) ) {
+ menu()->setDefaultAction( a );
+ currentChanged = true;
+ break;
+ }
+ }
+ for ( int i = index-1; i >= 0; i-- ) {
+ QAction* a = actionAt( i );
+ if ( a && !isSeparator( a ) ) {
+ menu()->setDefaultAction( a );
+ currentChanged = true;
+ break;
+ }
+ }
+ }
+ internalUpdate();
+ if ( currentChanged ) emitCurrentChanged( false, true );
+}
+
+/*!
+ \brief Get the number of items.
+ \return Number of items.
+*/
+int QtxToolButton::count() const
+{
+ return menu()->actions().count();
+}
+
+/*!
+ \brief Get data of the current item.
+ \return Current item's data (invalid QVariant if list of items is empty
+ or current item doesn't have data).
+*/
+QVariant QtxToolButton::currentData() const
+{
+ QAction* action = menu()->defaultAction();
+ return action == 0 ? QVariant() : action->data();
+}
+
+/*!
+ \brief Get index of current item.
+ \return Current item's index; -1 if list of items is empty or if there's no
+ current item.
+*/
+int QtxToolButton::currentIndex() const
+{
+ QAction* action = menu()->defaultAction();
+ return action == 0 ? -1 : menu()->actions().indexOf( action );
+}
+
+/*!
+ \brief Get text of current item.
+ \return Current item's text; null sting if list of items is empty or
+ if there's no current item.
+*/
+QString QtxToolButton::currentText() const
+{
+ QAction* action = menu()->defaultAction();
+ return action == 0 ? QString() : action->text();
+}
+
+/*!
+ \brief Get custom data of the item at given \a index.
+ \param index Item's index.
+ \return Item's data (invalid QVariant if index is out of range).
+*/
+QVariant QtxToolButton::itemData( int index ) const
+{
+ QAction* action = actionAt( index );
+ return action == 0 ? QVariant() : action->data();
+}
+
+/*!
+ \brief Get icon of the item at given \a index.
+ \param index Item's index.
+ \return Item's icon.
+*/
+QIcon QtxToolButton::itemIcon( int index ) const
+{
+ QAction* action = actionAt( index );
+ return action == 0 ? QIcon() : action->icon();
+}
+
+/*!
+ \brief Get text of the item at given \a index.
+ \param index Item's index.
+ \return Item's text.
+*/
+QString QtxToolButton::itemText( int index ) const
+{
+ QAction* action = actionAt( index );
+ return action == 0 ? QString() : action->text();
+}
+
+/*!
+ \brief Set custom data of the item at given \a index.
+ \param index Item's index.
+ \param value Item's data.
+*/
+void QtxToolButton::setItemData( int index, const QVariant& value )
+{
+ QAction* action = actionAt( index );
+ if ( action ) action->setData( value );
+}
+
+/*!
+ \brief Set icon of the item at given \a index.
+ \param index Item's index.
+ \param icon Item's icon.
+*/
+void QtxToolButton::setItemIcon( int index, const QIcon& icon )
+{
+ QAction* action = actionAt( index );
+ if ( action ) action->setIcon( icon );
+ internalUpdate();
+}
+
+/*!
+ \brief Set text of the item at given \a index.
+ \param index Item's index.
+ \param text Item's text.
+*/
+void QtxToolButton::setItemText( int index, const QString& text )
+{
+ QAction* action = actionAt( index );
+ bool currentChanged = false;
+ if ( action ) {
+ currentChanged = menu()->defaultAction() == action && action->text() != text;
+ action->setText( text );
+ }
+ internalUpdate();
+ if ( currentChanged )
+ emit currentTextChanged( text );
+}
+
+/*!
+ \brief Search item with given \a text.
+ \param Item's text.
+ \return Item's index; -1 if item is not found.
+*/
+int QtxToolButton::findText( const QString& text )
+{
+ int index = -1;
+ for ( int i = 0; i < count() && index == -1; i++ ) {
+ QAction* action = actionAt( i );
+ if ( isSeparator( action ) ) continue;
+ if ( action->text() == text ) index = i;
+ }
+ return index;
+}
+
+/*!
+ \brief Clear widget.
+*/
+void QtxToolButton::clear()
+{
+ QAction* action = menu()->defaultAction();
+ menu()->clear();
+ internalUpdate();
+ if ( action ) emitCurrentChanged( false, true );
+}
+
+/*!
+ \brief Set current item by given \a index.
+ \param index Item's index.
+*/
+void QtxToolButton::setCurrentIndex( int index )
+{
+ bool currentChanged = false;
+ if ( index == -1 ) {
+ currentChanged = currentIndex() != -1;
+ menu()->setDefaultAction( 0 );
+ }
+ else if ( index >= count() )
+ return;
+ else {
+ QAction* action = actionAt( index );
+ if ( !isSeparator( action ) ) {
+ currentChanged = currentIndex() != index;
+ menu()->setDefaultAction( action );
+ }
+ }
+ internalUpdate();
+ if ( currentChanged ) emitCurrentChanged( false, true );
+}
+
+/*!
+ \brief Set current item by given \a text.
+ \param index Item's index.
+*/
+void QtxToolButton::setCurrentText( const QString& text )
+{
+ int index = findText( text );
+ if ( index != -1 )
+ setCurrentIndex( index );
+}
+
+/*!
+ \brief Reimplemented from QToolButton::keyPressEvent().
+ Process key press event.
+ \param e Key press event.
+*/
+void QtxToolButton::keyPressEvent( QKeyEvent* e )
+{
+ Move move = NoMove;
+ switch ( e->key() ) {
+ case Qt::Key_Up:
+ case Qt::Key_PageUp:
+ move = ( e->modifiers() & Qt::ControlModifier ) ? MoveFirst : MoveUp;
+ break;
+ case Qt::Key_Down:
+ if ( e->modifiers() & Qt::AltModifier ) {
+ showMenu();
+ return;
+ }
+ case Qt::Key_PageDown:
+ move = ( e->modifiers() & Qt::ControlModifier ) ? MoveLast : MoveDown;
+ break;
+ case Qt::Key_Home:
+ move = MoveFirst;
+ break;
+ case Qt::Key_End:
+ move = MoveLast;
+ break;
+ case Qt::Key_F4:
+ if ( !e->modifiers() ) {
+ showMenu();
+ return;
+ }
+ break;
+ case Qt::Key_Space:
+ showMenu();
+ return;
+ case Qt::Key_Enter:
+ case Qt::Key_Return:
+ case Qt::Key_Escape:
+ e->ignore();
+ break;
+ case Qt::Key_Select:
+ showMenu();
+ return;
+ case Qt::Key_Left:
+ move = ( e->modifiers() & Qt::ControlModifier ) ? MoveFirst : MoveUp;
+ break;
+ case Qt::Key_Right:
+ move = ( e->modifiers() & Qt::ControlModifier ) ? MoveLast : MoveDown;
+ break;
+ default:
+ e->ignore();
+ break;
+ }
+ moveIndex( move );
+}
+
+/*!
+ \brief Reimplemented from QToolButton::wheelEvent().
+ Process mouse wheel event.
+ \param e Mouse wheel event.
+*/
+void QtxToolButton::wheelEvent( QWheelEvent* e )
+{
+ Move move = NoMove;
+ if ( e->delta() > 0 )
+ move = ( e->modifiers() & Qt::ControlModifier ) ? MoveFirst : MoveUp;
+ else if ( e->delta() < 0 )
+ move = ( e->modifiers() & Qt::ControlModifier ) ? MoveLast : MoveDown;
+ moveIndex( move );
+}
+
+/*!
+ \brief Called when menu action is triggered.
+ \internal
+*/
+void QtxToolButton::actionTriggered( QAction* action )
+{
+ if ( action && !isSeparator( action ) ) {
+ int index = currentIndex();
+ menu()->setDefaultAction( action );
+ internalUpdate();
+ int newIndex = currentIndex();
+ emitCurrentChanged( true, index != newIndex );
+ }
+}
+
+/*!
+ \brief Update content of the widget.
+ \internal
+*/
+void QtxToolButton::internalUpdate()
+{
+ QAction* action = menu()->defaultAction();
+ setText( action == 0 ? "" : action->text() );
+ setIcon( action == 0 ? QIcon() : action->icon() );
+}
+
+/*!
+ \brief Get menu action at given index.
+ \internal
+*/
+QAction* QtxToolButton::actionAt( int index ) const
+{
+ return ( index >=0 && index < count() ) ? menu()->actions()[index] : 0;
+}
+
+/*!
+ \brief Move current index.
+ \internal
+*/
+void QtxToolButton::moveIndex( Move move )
+{
+ int index = currentIndex();
+ int newIndex = index;
+ switch ( move ) {
+ case MoveUp:
+ case MoveFirst:
+ for ( int i = index-1; i >= 0; i-- ) {
+ QAction* a = actionAt( i );
+ if ( a && !isSeparator( a ) ) {
+ newIndex = i;
+ if ( move == MoveUp )
+ break;
+ }
+ }
+ break;
+ case MoveDown:
+ case MoveLast:
+ for ( int i = index+1; i < count(); i++ ) {
+ QAction* a = actionAt( i );
+ if ( a && !isSeparator( a ) ) {
+ newIndex = i;
+ if ( move == MoveDown )
+ break;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ if ( newIndex != index ) {
+ menu()->setDefaultAction( actionAt( newIndex ) );
+ internalUpdate();
+ emitCurrentChanged( true, true );
+ }
+}
+
+/*!
+ \brief Emit `currentChanged()` signal.
+ \internal
+*/
+void QtxToolButton::emitCurrentChanged( bool activate, bool changed )
+{
+ QAction* action = menu()->defaultAction();
+ int index = action == 0 ? -1 : menu()->actions().indexOf( action );
+ QString text = action == 0 ? QString() : action->text();
+ if ( activate ) {
+ emit activated( index );
+ emit activated( text );
+ }
+ if ( changed ) {
+ emit currentIndexChanged( index );
+ emit currentIndexChanged( text );
+ emit currentTextChanged( text );
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// 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 QTXTOOLBUTTON_H
+#define QTXTOOLBUTTON_H
+
+#include "Qtx.h"
+
+#include <QStringList>
+#include <QToolButton>
+#include <QVariant>
+
+class QTX_EXPORT QtxToolButton : public QToolButton
+{
+ Q_OBJECT
+
+ enum Move { NoMove=0, MoveUp, MoveDown, MoveFirst, MoveLast };
+
+public:
+ QtxToolButton( QWidget* = 0 );
+ virtual ~QtxToolButton();
+
+ int addItem( const QString&, const QVariant& = QVariant() );
+ int addItem( const QIcon&, const QString&, const QVariant& = QVariant() );
+ void addItems( const QStringList& );
+
+ int addSeparator( const QString& = QString() );
+ int addSeparator( const QIcon&, const QString& );
+
+ void removeItem( int );
+
+ int count() const;
+
+ QVariant currentData() const;
+ int currentIndex() const;
+ QString currentText() const;
+
+ QVariant itemData( int ) const;
+ QIcon itemIcon( int ) const;
+ QString itemText( int ) const;
+
+ void setItemData( int, const QVariant& );
+ void setItemIcon( int, const QIcon& );
+ void setItemText( int, const QString& );
+
+ int findText( const QString& );
+
+public slots:
+ void clear();
+
+ void setCurrentIndex( int );
+ void setCurrentText( const QString& );
+
+protected:
+ void keyPressEvent( QKeyEvent* );
+ void wheelEvent( QWheelEvent* );
+
+signals:
+ void activated( int );
+ void activated( const QString& );
+ void currentIndexChanged( int );
+ void currentIndexChanged( const QString& );
+ void currentTextChanged( const QString& );
+
+private slots:
+ void actionTriggered( QAction* );
+
+private:
+ void internalUpdate();
+ QAction* actionAt( int ) const;
+ void moveIndex( Move );
+ void emitCurrentChanged( bool, bool );
+};
+
+#endif // QTXTOOLBUTTON_H
if ( st->isSearchWrapped() ) fl = fl | WebPage::FindWrapsAroundDocument;
return myView->findText( text, fl );
#else
- myView->findText( text, fl, [this](bool found) { return found; });
+ bool textFound;
+ myView->findText( text, fl, [&](bool found) { textFound = found; });
+ return textFound;
#endif
}
if ( st->isSearchWrapped() ) fl = fl | WebPage::FindWrapsAroundDocument;
return myView->findText( text, fl );
#else
- myView->findText( text, fl, [this](bool found) { return found; });
+ bool textFound;
+ myView->findText( text, fl, [&](bool found) { textFound = found; });
+ return textFound;
#endif
}
QGridLayout* l = new QGridLayout( this );
l->addWidget( new QLabel( QtxWebBrowser::tr( "You are opening the file" ), this ),
- 0, 0, 1, 4 );
+ 0, 0, 1, 4 );
l->addWidget( myFileName, 1, 1, 1, 3 );
l->addWidget( new QLabel( QtxWebBrowser::tr( "Please choose the action to be done" ), this ),
- 3, 0, 1, 4 );
+ 3, 0, 1, 4 );
l->addWidget( rbOpen, 4, 1, 1, 1 );
l->addWidget( myBrowse, 4, 2, 1, 1 );
l->addWidget( rbSave, 5, 1, 1, 3 );
myFindPanel = new QtxSearchTool( frame, myWebView,
#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0)
- QtxSearchTool::Basic | QtxSearchTool::Case | QtxSearchTool::Wrap,
+ QtxSearchTool::Basic | QtxSearchTool::Case | QtxSearchTool::Wrap,
#else
- QtxSearchTool::Basic | QtxSearchTool::Case,
-#endif
- Qt::Horizontal );
+ QtxSearchTool::Basic | QtxSearchTool::Case,
+#endif
+ Qt::Horizontal );
myFindPanel->setFrameStyle( QFrame::NoFrame | QFrame::Plain );
myFindPanel->setActivators( QtxSearchTool::SlashKey );
myFindPanel->setSearcher( new Searcher( myWebView ) );
QMenu* fileMenu = menuBar()->addMenu( tr( "&File" ) );
fileMenu->addAction( QPixmap( ":/images/open.png" ), tr( "&Open..." ),
- this, SLOT( open() ),
- QKeySequence( QKeySequence::Open ) );
+ this, SLOT( open() ),
+ QKeySequence( QKeySequence::Open ) );
fileMenu->addSeparator();
fileMenu->addAction( myWebView->pageAction( WebPage::Back ) );
fileMenu->addAction( myWebView->pageAction( WebPage::Forward ) );
fileMenu->addAction( myWebView->pageAction( WebPage::Reload ) );
fileMenu->addSeparator();
fileMenu->addAction( tr( "&Find in text..." ),
- myFindPanel, SLOT( find() ),
- QKeySequence( QKeySequence::Find ) );
+ myFindPanel, SLOT( find() ),
+ QKeySequence( QKeySequence::Find ) );
fileMenu->addAction( tr( "&Find next" ),
- myFindPanel, SLOT( findNext() ),
- QKeySequence( QKeySequence::FindNext ) );
+ myFindPanel, SLOT( findNext() ),
+ QKeySequence( QKeySequence::FindNext ) );
fileMenu->addAction( tr( "&Find previous" ),
- myFindPanel, SLOT( findPrevious() ),
- QKeySequence( QKeySequence::FindPrevious ) );
+ myFindPanel, SLOT( findPrevious() ),
+ QKeySequence( QKeySequence::FindPrevious ) );
fileMenu->addSeparator();
fileMenu->addAction( QPixmap( ":/images/close.png" ), tr( "&Close" ),
- this, SLOT( close() ) );
+ this, SLOT( close() ) );
QMenu* helpMenu = menuBar()->addMenu( tr( "&Help" ) );
helpMenu->addAction( tr( "&About..." ),
- this, SLOT( about() ) );
+ this, SLOT( about() ) );
QVBoxLayout* main = new QVBoxLayout( frame );
main->addWidget( myWebView );
connect( myWebView, SIGNAL( loadFinished( bool ) ), SLOT( finished( bool ) ) );
connect( myWebView->pageAction( WebPage::DownloadLinkToDisk ), SIGNAL( triggered() ),
- SLOT( linkAction() ) );
+ SLOT( linkAction() ) );
#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0)
//QtWebKit case:
connect( myWebView, SIGNAL( linkClicked( QUrl ) ), SLOT( linkClicked( QUrl ) ) );
connect( myWebView->page(), SIGNAL( linkHovered( QString, QString, QString ) ),
- SLOT( linkHovered( QString, QString, QString ) ) );
+ SLOT( linkHovered( QString, QString, QString ) ) );
disconnect( myWebView->pageAction( WebPage::OpenLink ), 0, 0, 0 );
connect( myWebView->pageAction( WebPage::OpenLink ), SIGNAL( triggered() ),
- SLOT( linkAction() ) );
+ SLOT( linkAction() ) );
#else
//QtWebEngine (Qt-5.6.0) case:
connect( myWebView->page(), SIGNAL( linkHovered( QString ) ),
- SLOT( linkHovered( QString ) ) );
+ SLOT( linkHovered( QString ) ) );
disconnect( myWebView->pageAction( WebPage::OpenLinkInThisWindow ), 0, 0, 0 );
connect( myWebView->pageAction( WebPage::OpenLinkInThisWindow ), SIGNAL( triggered() ),
- SLOT( linkAction() ) );
+ SLOT( linkAction() ) );
#endif
setCentralWidget( frame );
setFocusProxy( myWebView );
void QtxWebBrowser::about()
{
QMessageBox::about( this, tr( "About %1" ).arg( tr( "Help Browser" ) ),
- QString( "SALOME %1" ).arg( tr( "Help Browser" ) ) );
+ QString( "SALOME %1" ).arg( tr( "Help Browser" ) ) );
}
/*!
myResourceMgr->setValue( resSection, actionParam, defAction );
myResourceMgr->setValue( resSection, repeatParam, defRepeat );
if ( defAction == Downloader::mOpen )
- myResourceMgr->setValue( resSection, programParam, defProgram );
+ myResourceMgr->setValue( resSection, programParam, defProgram );
}
}
switch( defAction ) {
void QtxWebBrowser::saveLink( const QString& fileName )
{
QString newFileName = QFileDialog::getSaveFileName( this, tr( "Save file" ), fileName,
- QString( "*.%1" ).arg( QFileInfo( fileName ).suffix() ) );
+ QString( "*.%1" ).arg( QFileInfo( fileName ).suffix() ) );
if ( !newFileName.isEmpty() &&
QFileInfo( newFileName ).canonicalFilePath() != QFileInfo( fileName ).canonicalFilePath() ) {
QFile toFile( newFileName );
QFile fromFile( fileName );
- if ( toFile.exists() && !toFile.remove() || !fromFile.copy( newFileName ) )
+ if (( toFile.exists() && !toFile.remove() ) ||
+ ( !fromFile.copy( newFileName ) ))
QMessageBox::warning( this, tr( "Error"), tr( "Can't save file:\n%1" ).arg( newFileName ) );
}
}
case ViewLeft:
aVTKViewWindow->onLeftView(); break;
default:
- PyErr_Format(PyExc_ValueError,"setView%: wrong parameter value; must be between %d and %d", ViewFront, ViewLeft );
+ PyErr_Format(PyExc_ValueError,"setView: wrong parameter value; must be between %d and %d", ViewFront, ViewLeft );
break;
}
}
# --- rules ---
-ADD_LIBRARY(SalomePyQt ${SalomePyQt_SOURCES})
+ADD_LIBRARY(SalomePyQt MODULE ${SalomePyQt_SOURCES})
TARGET_LINK_LIBRARIES(SalomePyQt ${_link_LIBRARIES})
INSTALL(TARGETS SalomePyQt DESTINATION ${SALOME_INSTALL_LIBS})
void STD_Application::onOpenDoc()
{
// It is preferrable to use OS-specific file dialog box here !!!
- QString aName = getFileName( true, QString(), getFileFilter(), QString(), 0 );
+ QString aName = getFileName( true, QString(), getFileFilter( true ), QString(), 0 );
if ( aName.isNull() )
return;
bool isOk = false;
while ( !isOk )
{
- QString aName = getFileName( false, study->studyName(), getFileFilter(), QString(), 0 );
+ QString aName = getFileName( false, study->studyName(), getFileFilter( false ), QString(), 0 );
if ( aName.isNull() )
return false;
delete popup;
}
+/*!\retval QString - return file extension(s).*/
+QString STD_Application::getFileFilter( bool /*open*/ ) const
+{
+ return QString();
+}
+
/*!\retval QString - return file name from dialog.*/
QString STD_Application::getFileName( bool open, const QString& initial, const QString& filters,
const QString& caption, QWidget* parent )
UserID
};
- public:
+public:
STD_Application();
virtual ~STD_Application();
void viewManagers( const QString&, ViewManagerList& ) const;
virtual int viewManagerId (const SUIT_ViewManager* ) const;
- virtual QString getFileFilter() const { return QString(); }
+ virtual QString getFileFilter( bool open ) const;
virtual QString getFileName( bool open, const QString& initial, const QString& filters,
- const QString& caption, QWidget* parent );
+ const QString& caption, QWidget* parent );
QString getDirectory( const QString& initial, const QString& caption, QWidget* parent );
virtual void start();
class SUIT_EXPORT SUIT_FileValidator
{
-public:
+ public:
SUIT_FileValidator( QWidget* = 0 );
-
+ virtual ~SUIT_FileValidator() {}
+
virtual bool canOpen( const QString&, bool = true );
virtual bool canSave( const QString&, bool = true );
#include <QRegExp>
#include <QString>
#include <QStringList>
+#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
+#include <QSurfaceFormat>
+#endif
#include <stdlib.h>
}
}
+#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
+ // initialization of the X11 visual on Linux
+ QSurfaceFormat format;
+ format.setDepthBufferSize(16);
+ format.setStencilBufferSize(1);
+ format.setProfile(QSurfaceFormat::CompatibilityProfile);
+ QSurfaceFormat::setDefaultFormat(format);
+#endif
+
// add <qtdir>/plugins directory to the pluins search path for image plugins
QString qtdir = Qtx::qtDir( "plugins" );
if ( !qtdir.isEmpty() )
*/
SUITApp_Application::SUITApp_Application( int& argc, char** argv, SUIT_ExceptionHandler* hand )
// TODO (QT5 PORTING) Below is a temporary solution, to allow compiling with Qt 5
-#if !defined(WIN32) && (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
+#if !defined(WIN32) && !defined(__APPLE__) && (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
// san: Opening an X display and choosing a visual most suitable for 3D visualization
// in order to make SALOME viewers work with non-native X servers
: QApplication( (Display*)Qtx::getDisplay(), argc, argv, Qtx::getVisual() ),
// QT Includes
// Put Qt includes before the X11 includes which #define the symbol None
// (see SVTK_SpaceMouse.h) to avoid the compilation error.
-#ifndef WIN32
+#if !defined(WIN32) && !defined(__APPLE__)
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <xcb/xcb.h>
#endif
myRenderWindow->Delete();
myRenderWindow->DoubleBufferOn();
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
myRenderWindow->SetDisplayId((void*)QX11Info::display());
#endif
myRenderWindow->SetWindowId((void*)winId());
QVTK_RenderWindowInteractor
::~QVTK_RenderWindowInteractor()
{
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
SVTK_SpaceMouseX* aSpaceMouse = SVTK_SpaceMouseX::getInstance();
if ( aSpaceMouse && aSpaceMouse->isSpaceMouseOn() )
{
QWidget::focusInEvent( event );
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
// register set space mouse events receiver
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
SVTK_SpaceMouseX* aSpaceMouse = SVTK_SpaceMouseX::getInstance();
{
QWidget::focusOutEvent( event );
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
// unregister set space mouse events receiver
SVTK_SpaceMouseX* aSpaceMouse = SVTK_SpaceMouseX::getInstance();
// TODO (QT5 PORTING) Below is a temporary solution, to allow compiling with Qt 5
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
-#ifdef WIN32
+#if defined(WIN32)
/*!
To handle native Win32 events (from such devices as SpaceMouse)
return QWidget::winEvent( msg, result);
}
-#else
-
+#elif !defined(__APPLE__)
/*!
To handle native X11 events (from such devices as SpaceMouse)
*/
bool QVTK_RenderWindowInteractor
::nativeEvent(const QByteArray& eventType, void* message, long* result)
{
-#ifdef WIN32
+#if defined(WIN32)
// TODO: WIN32-related implementation
-#else
+#elif !defined(__APPLE__)
if ( eventType == "xcb_generic_event_t" )
{
xcb_generic_event_t* ev = static_cast<xcb_generic_event_t *>(message);
//! To handle native events (from such devices as SpaceMouse)
// TODO (QT5 PORTING) Below is a temporary solution, to allow compiling with Qt 5
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
-#ifdef WIN32
+#if defined(WIN32)
virtual bool winEvent( MSG*, long* );
-#else
+#elif !defined(__APPLE__)
virtual bool x11Event( XEvent *e );
#endif
#else
#include <QtGlobal>
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
#include <X11/X.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
SVTK_SpaceMouseX::SVTK_SpaceMouseX()
: SVTK_SpaceMouse()
{
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
win = InputFocus;
#endif
}
return myInstance;
}
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
static int errorCallback( Display *display, XErrorEvent *Error )
{
SVTK_SpaceMouseXCB::SVTK_SpaceMouseXCB()
: SVTK_SpaceMouse()
{
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
win = InputFocus;
#endif
}
/*!
Initialization
*/
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
int SVTK_SpaceMouseXCB::initialize( xcb_connection_t *connection, xcb_window_t window )
{
// make request
#include <QtGlobal>
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
extern "C"
{
#include <X11/X.h>
#include <xcb/xcb.h>
#endif
}
-
#endif
class SVTK_SpaceMouse
// access to SpaceMouse utility class
static SVTK_SpaceMouseX* getInstance();
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
int initialize ( Display*, Window );
int setWindow ( Display*, Window );
int translateEvent ( Display*, XEvent*, MoveEvent*, double, double );
static SVTK_SpaceMouseX* myInstance;
};
+
#else
+
class SVTK_SpaceMouseXCB: public SVTK_SpaceMouse
{
// access to SpaceMouse utility class
static SVTK_SpaceMouseXCB* getInstance();
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
int initialize ( xcb_connection_t*, xcb_window_t );
int setWindow ( xcb_connection_t*, xcb_window_t );
int translateEvent ( xcb_connection_t*, xcb_client_message_event_t*, MoveEvent*, double, double );
static SVTK_SpaceMouseXCB* myInstance;
};
+
#endif
#endif
#include <OpenGLUtils_FrameBuffer.h>
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
namespace SVTK
{
objectBrowserColumnsVisibility();
}
-/*!Gets file filter.
- *\retval QString "(*.hdf)"
- */
-QString SalomeApp_Application::getFileFilter() const
-{
- return "(*.hdf)";
-}
-
/*!Create window.*/
QWidget* SalomeApp_Application::createWindow( const int flag )
{
PyConsole_Interp* SalomeApp_Application::createPyInterp()
{
- return new SalomeApp_PyInterp();
+ return new SalomeApp_PyInterp;
}
#endif // DISABLE_PYCONSOLE
virtual void updateObjectBrowser( const bool = true );
- virtual QString getFileFilter() const;
-
virtual void start();
virtual void contextMenuPopup( const QString&, QMenu*, QString& );
\brief Constructor
*/
SalomeApp_PyInterp::SalomeApp_PyInterp()
- : PyConsole_Interp(), myFirstRun( true ), myFirstInitStudy( false )
+ : myFirstRun( true ), myFirstInitStudy( false )
{
}
//aFatherDO->insertChild(suit_obj, pos);
aFatherDO->updateItem();
- /* Define visibility state */
- bool isComponent = dynamic_cast<SalomeApp_ModuleObject*>( suit_obj ) != 0;
- if ( suit_obj && !isComponent && myStudy->visibilityState( theID.c_str() ) == Qtx::UnpresentableState ) {
- QString moduleTitle = ((CAM_Application*)myStudy->application())->moduleTitle(suit_obj->componentDataType());
- if (!moduleTitle.isEmpty()) {
- LightApp_Displayer* aDisplayer = LightApp_Displayer::FindDisplayer(moduleTitle,false);
- if (aDisplayer) {
- if(aDisplayer->canBeDisplayed(theID.c_str())) {
- myStudy->setVisibilityState( theID.c_str(), Qtx::HiddenState ); //hide the just added object
- //MESSAGE("Object with entry : "<< theID <<" CAN be displayed !!!");
- }
- else
- MESSAGE("Object with entry : "<< theID <<" CAN'T be displayed !!!");
- }
- }
- }
+ /* Define visibility state */
+ bool isComponent = dynamic_cast<SalomeApp_ModuleObject*>( suit_obj ) != 0;
+ if ( suit_obj && !isComponent && myStudy->visibilityState( theID.c_str() ) == Qtx::UnpresentableState ) {
+ QString moduleTitle = ((CAM_Application*)myStudy->application())->moduleTitle(suit_obj->componentDataType());
+ if (!moduleTitle.isEmpty()) {
+ LightApp_Displayer* aDisplayer = LightApp_Displayer::FindDisplayer(moduleTitle,false);
+ if (aDisplayer) {
+ if(aDisplayer->canBeDisplayed(theID.c_str())) {
+ myStudy->setVisibilityState( theID.c_str(), Qtx::HiddenState ); //hide the just added object
+ //MESSAGE("Object with entry : "<< theID <<" CAN be displayed !!!");
+ }
+ //else
+ //MESSAGE("Object with entry : "<< theID <<" CAN'T be displayed !!!");
+ }
+ }
+ }
} // END: work with tree nodes structure
else { // BEGIN: work with study structure
EntryMapIter it = entry2SuitObject.find( theID );
myStudy->setVisibilityState( theID.c_str(), Qtx::HiddenState );
//MESSAGE("Object with entry : "<< theID <<" CAN be displayed !!!");
}
- else
- MESSAGE("Object with entry : "<< theID <<" CAN'T be displayed !!!");
+ //else
+ //MESSAGE("Object with entry : "<< theID <<" CAN'T be displayed !!!");
}
}
}
#ifndef DISABLE_PYCONSOLE
case 6: //NoteBook variables were modified
{
- myStudy->onNoteBookVarUpdate( QString( theID.c_str() ) );
- break;
+ myStudy->onNoteBookVarUpdate( QString( theID.c_str() ) );
+ break;
}
#endif
default:MESSAGE("Unknown event: " << event);break;
#include <QWaitCondition>
#include <QRegExp>
#include <QTextStream>
+#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
+#include <QSurfaceFormat>
+#endif
/*! - read arguments, define list of server to launch with their arguments.
* - wait for naming service
#endif
QString fname = QFileInfo( _fname ).fileName();
if ( exp.exactMatch( fname ) ) {
- long fid = Qtx::versionToId( exp.cap( 1 ) );
- if ( fid > 0 ) id = fid;
+ long fid = Qtx::versionToId( exp.cap( 1 ) );
+ if ( fid > 0 ) id = fid;
}
}
return id;
public:
SALOME_QApplication( int& argc, char** argv )
// TODO (QT5 PORTING) Below is a temporary solution, to allow compiling with Qt 5
-#if !defined WIN32 && QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+#if !defined(WIN32) && !defined(__APPLE__) && (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
// san: Opening an X display and choosing a visual most suitable for 3D visualization
// in order to make SALOME viewers work with non-native X servers
: QApplication( (Display*)Qtx::getDisplay(), argc, argv, Qtx::getVisual() ),
QLocale::setDefault( QLocale::system() );
}
}
+
+#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
+ // initialization of the X11 visual on Linux
+ QSurfaceFormat format;
+ format.setDepthBufferSize(16);
+ format.setStencilBufferSize(1);
+ format.setProfile(QSurfaceFormat::CompatibilityProfile);
+ QSurfaceFormat::setDefaultFormat(format);
+#endif
// Create Qt application instance;
// this should be done the very first!
SALOME::StatSession stat = session->GetStatSession();
shutdownSession = stat.state == SALOME::shutdown;
if ( shutdownSession ) {
- _SessionMutex.lock(); // lock mutex before leaving loop - it will be unlocked later
- break;
+ _SessionMutex.lock(); // lock mutex before leaving loop - it will be unlocked later
+ break;
}
// SUIT_Session creation
_argCopy.reserve(_argc);
for (int iarg=0; iarg <_argc; iarg++)
{
- SCRUTE(iarg);
- SCRUTE(_argv[iarg]);
+ //SCRUTE(iarg);
+ //SCRUTE(_argv[iarg]);
_argCopy.push_back(_argv[iarg]);
switch (argState)
{
}
case 1: // looking for server type
{
- // Temporary solution
- // Issue 21337 - no more SalomeApp_Engine_i activation here
- // TODO: To be removed as soon as any trace of SalomeAppEngine
- // has been eliminated from KERNEL scripts
- if (strcmp(_argv[iarg], "SalomeAppEngine")==0){
- argState = 0;
- iarg += 2; // skipping "()"
- break;
- }
- // Temporary solution
+ // Temporary solution
+ // Issue 21337 - no more SalomeApp_Engine_i activation here
+ // TODO: To be removed as soon as any trace of SalomeAppEngine
+ // has been eliminated from KERNEL scripts
+ if (strcmp(_argv[iarg], "SalomeAppEngine")==0){
+ argState = 0;
+ iarg += 2; // skipping "()"
+ break;
+ }
+ // Temporary solution
for (int i=0; i<Session_ServerThread::NB_SRV_TYP; i++)
if (strcmp(_argv[iarg],Session_ServerThread::_serverTypes[i])==0)
// avoid adding it when treating another face
process = midPoints.insert( face->GetPointId(p2) ).second; break;
case 1: // the edge is shared by two cells
- process = ( cellIdsTmp->GetId(0) == cellId ); break;
+ process = ( cellIdsTmp->GetId(0) < cellId ); break;
default: // the edge is shared by >2 cells
- process = ( cellIdsTmp->GetId(0) != cellId ); break;
+ process = ( cellIdsTmp->GetId(0) < cellId ); break;
}
if ( process )
{
# ifndef GLX_GLXEXT_LEGACY
# define GLX_GLXEXT_LEGACY
# endif
+#ifdef __APPLE__
+#import <mach-o/dyld.h>
+#import <stdlib.h>
+#import <string.h>
+void * glXGetProcAddressARB (const GLubyte *name)
+
+{
+ NSSymbol symbol;
+ char *symbolName;
+ symbolName = (char *)malloc (strlen ((const char *)name) + 2); // 1
+ strcpy(symbolName + 1, (const char *)name); // 2
+ symbolName[0] = '_'; // 3
+ symbol = NULL;
+ if (NSIsSymbolNameDefined (symbolName)) // 4
+ symbol = NSLookupAndBindSymbol (symbolName);
+ free (symbolName); // 5
+ return symbol ? NSAddressOfSymbol (symbol) : NULL; // 6
+}
+#else
# include <GL/glx.h>
+#endif
# include <dlfcn.h>
#else
# include <wingdi.h>
virtual
void
get( TVertex& theVertex, vtkIdType thePointId, vtkIdType theCellId ) = 0;
+
+ virtual ~TColorFunctorBase() {}
};
//-----------------------------------------------------------------------------
#include <map>
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
#include <vtkSmartPointer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRendererCollection.h>
#include <vtkCamera.h>
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
#include <QX11Info>
#include <vtkXOpenGLRenderWindow.h>
#endif
setAttribute( Qt::WA_DeleteOnClose );
myRW = vtkRenderWindow::New();
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
myRW->SetDisplayId((void*)(QX11Info::display()));
#endif
myRW->SetWindowId((void*)winId());
PyConsole_Editor::PyConsole_Editor( QWidget* parent )
: QTextEdit( parent )
{
- PyConsole_Interp* interp = new PyConsole_Interp();
+ PyConsole_Interp *interp(new PyConsole_Interp);
interp->initialize();
- init( interp );
+ myInterp=interp;
+ init();
}
/*!
PyConsole_Interp* interp )
: QTextEdit( parent )
{
- init( interp );
+ myInterp.takeRef(interp);
+ init();
}
-void PyConsole_Editor::init( PyConsole_Interp* interp )
+void PyConsole_Editor::init()
{
- myInterp = interp;
myCmdInHistory = -1;
myEventLoop = 0;
myShowBanner = true;
*/
PyConsole_Editor::~PyConsole_Editor()
{
- myInterp = 0;
}
/*!
\brief Get Python interpreter
*/
-PyConsole_Interp* PyConsole_Editor::getInterp() const
+PyConsole_Interp *PyConsole_Editor::getInterp() const
{
- return myInterp;
+ return myInterp.iAmATrollConstCast();
}
/*!
#include "PyConsole.h"
+#include "PyInterp_RefCounterObj.h"
+
#include <QTextEdit>
#include <QQueue>
virtual QString getLogFileName();
private:
- void init( PyConsole_Interp* );
+ void init();
void multilinePaste( const QString& );
void multiLineProcessNextLine();
QString banner() const;
inline int promptSize() const { return myPrompt.size(); }
- PyConsole_Interp* myInterp; //!< python interpreter
- QString myCommandBuffer; //!< python command buffer
- QString myCurrentCommand; //!< currently being printed command
- QString myPrompt; //!< current command line prompt
- int myCmdInHistory; //!< current history command index
- QString myLogFile; //!< current output log
- QStringList myHistory; //!< commands history buffer
- QEventLoop* myEventLoop; //!< internal event loop
- bool myShowBanner; //!< 'show banner' flag
- QStringList myQueue; //!< python commands queue
- bool myIsSync; //!< synchronous mode flag
- bool myIsSuppressOutput; //!< suppress output flag
- bool myMultiLinePaste; //!< true when pasting several lines
- QQueue<QString> myMultiLineContent; //!< queue of lines being pasted
- bool myAutoCompletion; //!< auto-completion mode flag
- bool myTabMode; //!< flag that is \c true when editor performs completion
- QString myComplBeforePoint; //!< string on which the dir() command is executed
- QString myComplAfterPoint; //!< string on which the results of the dir() are matched
- int myComplCursorPos; //!< cursor position when <TAB> is hit
+ PyInterp_Auto<PyConsole_Interp> myInterp; //!< python interpreter
+ QString myCommandBuffer; //!< python command buffer
+ QString myCurrentCommand; //!< currently being printed command
+ QString myPrompt; //!< current command line prompt
+ int myCmdInHistory; //!< current history command index
+ QString myLogFile; //!< current output log
+ QStringList myHistory; //!< commands history buffer
+ QEventLoop* myEventLoop; //!< internal event loop
+ bool myShowBanner; //!< 'show banner' flag
+ QStringList myQueue; //!< python commands queue
+ bool myIsSync; //!< synchronous mode flag
+ bool myIsSuppressOutput; //!< suppress output flag
+ bool myMultiLinePaste; //!< true when pasting several lines
+ QQueue<QString> myMultiLineContent; //!< queue of lines being pasted
+ bool myAutoCompletion; //!< auto-completion mode flag
+ bool myTabMode; //!< flag that is \c true when editor performs completion
+ QString myComplBeforePoint; //!< string on which the dir() command is executed
+ QString myComplAfterPoint; //!< string on which the results of the dir() are matched
+ int myComplCursorPos; //!< cursor position when <TAB> is hit
friend void PyConsole_CallbackStdout( void*, char* );
friend void PyConsole_CallbackStderr( void*, char* );
public:
PyConsole_Interp();
- ~PyConsole_Interp();
virtual int afterRun();
virtual int beforeRun();
+protected:
+
+ ~PyConsole_Interp();
+
private:
bool runDirCommand( const QString&, const QString&, QStringList&, QString& );
bool runDirAndExtract( const QString&, const QString&, QStringList&, bool = true ) const;
# sources / to compile
SET(PyConsolePy_SOURCES ${_sip_SOURCES})
-message("PyConsolePy_SOURCES = ${PyConsolePy_SOURCES}")
# --- rules ---
{
protected:
enum Option { snEditor,
- snHighlightCurrentLine,
- snTextWrapping,
- snCenterCursorOnScroll,
- snLineNumberArea,
- snVerticalEdge,
- snNumberColumns,
- snTabSpaceVisible,
- snTabSize,
- snFont };
+ snHighlightCurrentLine,
+ snTextWrapping,
+ snCenterCursorOnScroll,
+ snLineNumberArea,
+ snVerticalEdge,
+ snNumberColumns,
+ snTabSpaceVisible,
+ snTabSize,
+ snFont };
public:
static PyEditor_Settings* settings();
static void setSettings( PyEditor_Settings* );
PyEditor_Settings();
+ virtual ~PyEditor_Settings() {}
void setHighlightCurrentLine( bool );
bool highlightCurrentLine() const;
PyInterp_Interp.h
PyInterp_Request.h
PyInterp_Utils.h
+ PyInterp_RefCounterObj.h
)
# header files / to install
#include "PyInterp.h" // !!! WARNING !!! THIS INCLUDE MUST BE THE VERY FIRST !!!
#include "PyInterp_Utils.h"
+#include "PyInterp_RefCounterObj.h"
#include <list>
#include <string>
* (only there namespace is made available when importing in another context).
* See also class PyConsole_Interp.
*/
-class PYINTERP_EXPORT PyInterp_Interp
+class PYINTERP_EXPORT PyInterp_Interp : public PyInterp_RefCounterObj
{
public:
static int _argc;
static char* _argv[];
- PyInterp_Interp();
- virtual ~PyInterp_Interp();
-
void initialize();
void destroy();
virtual int run(const char *command);
- virtual void initStudy() {};
+ virtual void initStudy() {}
std::string getBanner() const;
void setverrcb(PyOutChanged*, void*);
const char* getPrevious();
const char* getNext();
+protected:
+
+ PyInterp_Interp();
+ virtual ~PyInterp_Interp();
+
protected:
/** Redirection of stdout and stderr */
PyObject* _vout;
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// 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
+//
+// File : PyInterp_RefCounterObj.h
+// Author : Anthony Geay (EDF R&D)
+
+#ifndef PYINTERP_REFCOUNTEROBJ_H
+#define PYINTERP_REFCOUNTEROBJ_H
+
+#include "PyInterp.h"
+
+template<class T>
+class PyInterp_Auto
+{
+public:
+ PyInterp_Auto(const PyInterp_Auto& other):_ptr(0) { referPtr(other._ptr); }
+ PyInterp_Auto(T *ptr=0):_ptr(ptr) { }
+ ~PyInterp_Auto() { destroyPtr(); }
+ bool isNull() const { return _ptr==0; }
+ bool isNotNull() const { return !isNull(); }
+ void nullify() { destroyPtr(); _ptr=0; }
+ bool operator==(const PyInterp_Auto& other) const { return _ptr==other._ptr; }
+ bool operator==(const T *other) const { return _ptr==other; }
+ PyInterp_Auto &operator=(const PyInterp_Auto<T>& other) { if(_ptr!=other._ptr) { destroyPtr(); referPtr(other._ptr); } return *this; }
+ PyInterp_Auto &operator=(T *ptr) { if(_ptr!=ptr) { destroyPtr(); _ptr=ptr; } return *this; }
+ void takeRef(T *ptr) { if(_ptr!=ptr) { destroyPtr(); _ptr=ptr; if(_ptr) _ptr->incrRef(); } }
+ T *operator->() { return _ptr ; }
+ const T *operator->() const { return _ptr; }
+ T& operator*() { return *_ptr; }
+ const T& operator*() const { return *_ptr; }
+ operator T *() { return _ptr; }
+ operator const T *() const { return _ptr; }
+ T *retn() { if(_ptr) _ptr->incrRef(); return _ptr; }
+ T *iAmATrollConstCast() const { return _ptr; }
+ private:
+ void referPtr(T *ptr) { _ptr=ptr; if(_ptr) _ptr->incrRef(); }
+ void destroyPtr() { if(_ptr) _ptr->decrRef(); }
+ private:
+ T *_ptr;
+};
+
+class PYINTERP_EXPORT PyInterp_RefCounterObj
+{
+ protected:
+ PyInterp_RefCounterObj():_cnt(1) { }
+ PyInterp_RefCounterObj(const PyInterp_RefCounterObj& other):_cnt(1) { }
+ public:
+ bool decrRef() const
+ {
+ bool ret=((--_cnt)==0);
+ if(ret)
+ delete this;
+ return ret;
+ }
+ void incrRef() const { _cnt++; }
+ int getRCValue() const { return _cnt; }
+ // copies using operator= should not copy the ref counter of \a other
+ PyInterp_RefCounterObj& operator=(const PyInterp_RefCounterObj& other) { return *this; }
+ protected:
+ virtual ~PyInterp_RefCounterObj() { }
+ private:
+ mutable int _cnt;
+};
+
+#endif // PYINTERP_REFCOUNTEROBJ_H