OCCViewer_ClipPlane.h
OCCViewer_Trihedron.h
OCCViewer_VService.h
+ OCCViewer_Utilities.h
)
# header files / no moc processing / internal
# --- resources ---
+# resource files / to be processed by rcc
+SET(_rcc_RESOURCES OCCViewer.qrc)
+
# resource files / to be processed by lrelease
SET(_ts_RESOURCES
resources/OCCViewer_images.ts
# sources / moc wrappings
QT4_WRAP_CPP(_moc_SOURCES ${_moc_HEADERS})
+# sources / rcc wrappings
+QT4_ADD_RESOURCES(_rcc_SOURCES ${_rcc_RESOURCES})
+
# sources / static
SET(_other_SOURCES
OCCViewer_AISSelector.cxx
OCCViewer_ViewWindow.cxx
OCCViewer_ViewportInputFilter.cxx
OCCViewer_ClipPlaneInteractor.cxx
+ OCCViewer_Utilities.cxx
)
# sources / to compile
-SET(OCCViewer_SOURCES ${_other_SOURCES} ${_moc_SOURCES})
+SET(OCCViewer_SOURCES ${_other_SOURCES} ${_moc_SOURCES} ${_rcc_SOURCES})
# --- rules ---
--- /dev/null
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource>
+ <file>images/hatch.png</file>
+ </qresource>
+ </RCC>
--- /dev/null
+// Copyright (C) 2014 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
+//
+
+// internal includes
+#include "OCCViewer_Utilities.h"
+
+// KERNEL includes
+#include <Basics_OCCTVersion.hxx>
+
+// OCC Includes
+#include <Image_PixMap.hxx>
+
+// QT includes
+#include <QImage>
+
+/*! Concert QImage to OCCT pixmap*/
+Handle(Image_PixMap)
+imageToPixmap( const QImage& anImage )
+{
+ Handle(Image_PixMap) aPixmap = new Image_PixMap();
+ if ( !anImage.isNull() ) {
+ aPixmap->InitTrash( Image_PixMap::ImgBGRA, anImage.width(), anImage.height() );
+ aPixmap->SetTopDown( Standard_True );
+
+ const uchar* aImageBytes = anImage.bits();
+
+ for ( int aLine = anImage.height() - 1; aLine >= 0; --aLine ) {
+#if OCC_VERSION_LARGE > 0x06070100
+ // convert pixels from ARGB to renderer-compatible RGBA
+ for ( int aByte = 0; aByte < anImage.width(); ++aByte ) {
+ Image_ColorBGRA& aPixmapBytes = aPixmap->ChangeValue<Image_ColorBGRA>(aLine, aByte);
+
+ aPixmapBytes.b() = (Standard_Byte) *aImageBytes++;
+ aPixmapBytes.g() = (Standard_Byte) *aImageBytes++;
+ aPixmapBytes.r() = (Standard_Byte) *aImageBytes++;
+ aPixmapBytes.a() = (Standard_Byte) *aImageBytes++;
+ }
+#else
+ Image_ColorBGRA* aPixmapBytes = aPixmap->EditData<Image_ColorBGRA>().ChangeRow(aLine);
+
+ // convert pixels from ARGB to renderer-compatible RGBA
+ for ( int aByte = 0; aByte < anImage.width(); ++aByte ) {
+ aPixmapBytes->b() = (Standard_Byte) *aImageBytes++;
+ aPixmapBytes->g() = (Standard_Byte) *aImageBytes++;
+ aPixmapBytes->r() = (Standard_Byte) *aImageBytes++;
+ aPixmapBytes->a() = (Standard_Byte) *aImageBytes++;
+ aPixmapBytes++;
+ }
+#endif
+ }
+ }
+ return aPixmap;
+}
--- /dev/null
+// Copyright (C) 2014 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 OCCVIEWER_UTILITIES_H
+#define OCCVIEWER_UTILITIES_H
+
+// internal includes
+#include "OCCViewer.h"
+
+// OCC includes
+#include <Image_PixMap_Handle.hxx>
+
+class QImage;
+
+OCCVIEWER_EXPORT
+extern
+Handle(Image_PixMap)
+imageToPixmap( const QImage& anImage );
+
+#endif
#include "OCCViewer_VService.h"
#include "OCCViewer_ViewPort3d.h"
#include "OCCViewer_ClippingDlg.h"
+#include "OCCViewer_Utilities.h"
#include "SUIT_ViewWindow.h"
#include "SUIT_ViewManager.h"
#include <AIS_ListOfInteractive.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <Graphic3d_Texture2Dmanual.hxx>
+#include <Graphic3d_TextureParams.hxx>
+
#include <Geom_Axis2Placement.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_DatumAspect.hxx>
Handle(Graphic3d_ClipPlane) aGraphic3dPlane = new Graphic3d_ClipPlane( thePlane );
aGraphic3dPlane->SetOn( theIsOn );
aGraphic3dPlane->SetCapping( Standard_True );
+
+ // load capping texture
+ QPixmap px( ":images/hatch.png" );
+ if( !px.isNull() ) {
+ const Handle(Image_PixMap) aPixmap = imageToPixmap( px.toImage() );
+ Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual( aPixmap );
+ if( aTexture->IsDone() ) {
+ aTexture->EnableModulate();
+ aTexture->EnableRepeat();
+ aTexture->GetParams()->SetScale( Graphic3d_Vec2( 0.01, 0.01 ) );
+ aGraphic3dPlane->SetCappingTexture( aTexture );
+ }
+ }
return aGraphic3dPlane;
}
/*!