}
}
+void OCCViewer_ViewFrame::setBackgroundImage( const QString& theFilename,const Aspect_FillMethod& theFillMethod)
+{
+ if (myPopupRequestedView)
+ myPopupRequestedView->setBackgroundImage(theFilename,theFillMethod);
+ else {
+ foreach (OCCViewer_ViewWindow* aView, myViews) {
+ if (aView->isVisible())
+ aView->setBackgroundImage(theFilename,theFillMethod);
+ }
+ }
+}
void OCCViewer_ViewFrame::onViewFitAll()
{
return getView(MAIN_VIEW)->backgroundColor();
}
+QString OCCViewer_ViewFrame::backgroundImageFilename() const
+{
+ if (myPopupRequestedView)
+ return myPopupRequestedView->backgroundImageFilename();
+
+ foreach (OCCViewer_ViewWindow* aView, myViews) {
+ if (aView->isVisible())
+ return aView->backgroundImageFilename();
+ }
+ return getView(MAIN_VIEW)->backgroundImageFilename();
+}
+
void OCCViewer_ViewFrame::onContextMenuRequested(QContextMenuEvent*)
{
myPopupRequestedView = dynamic_cast<OCCViewer_ViewWindow*>(sender());
virtual QColor backgroundColor() const;
virtual void setBackgroundColor( const QColor& );
+ virtual QString backgroundImageFilename() const;
+ virtual void setBackgroundImage( const QString& theFilename , const Aspect_FillMethod& theFillMethod);
+
virtual void setDropDownButtons( bool );
public slots:
// 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 "OCCViewer_ViewModel.h"
#include "OCCViewer_ViewWindow.h"
#include <QPainter>
#include <QApplication>
#include <QColorDialog>
+#include <QFileDialog>
#include <QPalette>
#include <QKeyEvent>
#include <QMenu>
{
thePopup->addAction( tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) );
thePopup->addAction( tr( "MEN_CHANGE_BACKGROUD" ), this, SLOT( onChangeBgColor() ) );
+ QMenu * changeImageMenu=thePopup->addMenu( tr( "MEN_CHANGE_IMAGE" ));
+ changeImageMenu->addAction( tr( "CENTERED") , this, SLOT( onChangeBgImageCentered() ) );
+ changeImageMenu->addAction( tr( "TILED") , this, SLOT( onChangeBgImageTiled() ) );
+ changeImageMenu->addAction( tr( "STRETCHED") , this, SLOT( onChangeBgImageStretched() ) );
thePopup->addSeparator();
OCCViewer_ViewWindow* aView = dynamic_cast<OCCViewer_ViewWindow*>(myViewManager->getActiveView());
if ( !aView )
return;
+
QColor selColor = QColorDialog::getColor( aView->backgroundColor(), aView );
if ( selColor.isValid() )
aView->setBackgroundColor(selColor);
}
+/*!
+ SLOT: called if background image is to be changed changed, passes new image to view port in centered mode
+*/
+void OCCViewer_Viewer::onChangeBgImageCentered()
+{
+ OCCViewer_ViewWindow* aView = dynamic_cast<OCCViewer_ViewWindow*>(myViewManager->getActiveView());
+ if ( !aView )
+ return;
+
+ QString selFile = QFileDialog::getOpenFileName(aView,tr( "SELECT_IMAGE"),aView->backgroundImageFilename(), tr("OCC_BG_IMAGE_FILES"));
+ if ( ! selFile.isEmpty() )
+ aView->setBackgroundImage(selFile,Aspect_FM_CENTERED);
+}
+
+/*!
+ SLOT: called if background image is to be changed changed, passes new image to view port in tiled mode
+*/
+void OCCViewer_Viewer::onChangeBgImageTiled()
+{
+ OCCViewer_ViewWindow* aView = dynamic_cast<OCCViewer_ViewWindow*>(myViewManager->getActiveView());
+ if ( !aView )
+ return;
+
+ QString selFile = QFileDialog::getOpenFileName(aView,tr( "SELECT_IMAGE"),aView->backgroundImageFilename(), tr("OCC_BG_IMAGE_FILES"));
+ if ( ! selFile.isEmpty() )
+ aView->setBackgroundImage(selFile,Aspect_FM_TILED);
+}
+
+/*!
+ SLOT: called if background image is to be changed changed, passes new image to view port in stretched mode
+*/
+void OCCViewer_Viewer::onChangeBgImageStretched()
+{
+ OCCViewer_ViewWindow* aView = dynamic_cast<OCCViewer_ViewWindow*>(myViewManager->getActiveView());
+ if ( !aView )
+ return;
+
+ QString selFile = QFileDialog::getOpenFileName(aView,tr( "SELECT_IMAGE"),aView->backgroundImageFilename(), tr("OCC_BG_IMAGE_FILES"));
+ if ( ! selFile.isEmpty() )
+ aView->setBackgroundImage(selFile,Aspect_FM_STRETCH);
+}
/*!
Updates OCC 3D viewer
*/
void onDumpView();
void onChangeBgColor();
+ void onChangeBgImageCentered();
+ void onChangeBgImageTiled();
+ void onChangeBgImageStretched();
private:
Handle(V3d_Viewer) myV3dViewer;
#include <SUIT_ViewManager.h>
#include <QColor>
+#include <QString>
#include <QRect>
#include <QPaintEvent>
#include <QResizeEvent>
myDegenerated( true ),
myAnimate( false ),
myBusy( true ),
- myIsAdvancedZoomingEnabled( false )
+ myIsAdvancedZoomingEnabled( false ),
+ myBackgroundImageFilename( "" )
{
// VSR: 01/07/2010 commented to avoid SIGSEGV at SALOME exit
//selectVisualId();
}
}
+/*!
+ Returns the background image fileName[ virtual public ]
+*/
+QString OCCViewer_ViewPort3d::backgroundImageFilename() const
+{
+ return myBackgroundImageFilename;
+}
+
+/*!
+ Sets the background image [ virtual public ]
+*/
+void OCCViewer_ViewPort3d::setBackgroundImage( const QString& fileName,const Aspect_FillMethod& theFillMethod)
+{
+ myBackgroundImageFilename=fileName;
+ if ( !activeView().IsNull() ) {
+ activeView()->SetBackgroundImage( (Standard_CString)fileName.toLatin1().constData(),theFillMethod,true);
+ }
+}
+
/*!
Set animation mode
\param theDegenerated - degenerated mode
#include <V3d_View.hxx>
class QColor;
+class QString;
class QRect;
class Handle(V3d_Viewer);
virtual void setBackgroundColor( const QColor& color);
virtual QColor backgroundColor() const;
+ virtual QString backgroundImageFilename() const;
+ virtual void setBackgroundImage( const QString& fileName , const Aspect_FillMethod& theFillMethod);
+
// void setActive( V3d_TypeOfView );
virtual bool syncronize( const OCCViewer_ViewPort3d* );
bool myBusy;
double myScale;
bool myIsAdvancedZoomingEnabled;
+ QString myBackgroundImageFilename;
};
#ifdef WIN32
if ( myViewPort ) myViewPort->setBackgroundColor( theColor );
}
+QString OCCViewer_ViewWindow::backgroundImageFilename() const
+{
+ return myViewPort ? myViewPort->backgroundImageFilename() : "";
+}
+
+void OCCViewer_ViewWindow::setBackgroundImage( const QString& theFileName,const Aspect_FillMethod& theFillMethod)
+{
+ if ( myViewPort ) myViewPort->setBackgroundImage( theFileName ,theFillMethod);
+}
+
/*!
Clears view aspects
*/
virtual QColor backgroundColor() const;
virtual void setBackgroundColor( const QColor& );
+ virtual QString backgroundImageFilename() const;
+ virtual void setBackgroundImage( const QString& ,const Aspect_FillMethod& theFillMethod);
+
virtual const viewAspectList& getViewAspects();
virtual void appendViewAspect( const viewAspect& );
virtual void updateViewAspects( const viewAspectList& );
<source>OCC_IMAGE_FILES</source>
<translation>Images Files (*.bmp *.png *.jpg *.jpeg)</translation>
</message>
+ <message>
+ <source>OCC_BG_IMAGE_FILES</source>
+ <translation>Images Files (*.bmp *.gif *.pix *.xwd *.rgb *.rs)</translation>
+ </message>
<message>
<source>DSC_MAXIMIZE_VIEW</source>
<translation>Maximize view</translation>
<source>MEN_CHANGE_BACKGROUD</source>
<translation>Change Background...</translation>
</message>
+ <message>
+ <source>MEN_CHANGE_IMAGE</source>
+ <translation>Set/Change Background Image...</translation>
+ </message>
+ <message>
+ <source>SELECT_IMAGE</source>
+ <translation>Select image...</translation>
+ </message>
+ <message>
+ <source>CENTERED</source>
+ <translation>in centered mode</translation>
+ </message>
+ <message>
+ <source>TILED</source>
+ <translation>in tiled mode</translation>
+ </message>
+ <message>
+ <source>STRETCHED</source>
+ <translation>in stretched mode</translation>
+ </message>
</context>
<context>
<name>OCCViewer_AxialScaleDlg</name>
<source>MEN_CHANGE_BACKGROUD</source>
<translation>Changer l'arrière-plan</translation>
</message>
+ <message>
+ <source>MEN_CHANGE_IMAGE</source>
+ <translation>Régler/Changer l''image d'arrière-plan...</translation>
+ </message>
+ <message>
+ <source>SELECT_IMAGE</source>
+ <translation>Sélectionner l'image</translation>
+ </message>
+ <message>
+ <source>CENTERED</source>
+ <translation>en mode centré</translation>
+ </message>
+ <message>
+ <source>TILED</source>
+ <translation>en mode pavé</translation>
+ </message>
+ <message>
+ <source>STRETCHED</source>
+ <translation>en mode étiré</translation>
+ </message>
</context>
<context>
<name>OCCViewer_AxialScaleDlg</name>