#include "SUIT_ViewManager.h"
#include "QtxActionToolMgr.h"
+#include "QtxMultiAction.h"
+// KERNEL includes
+#include <Basics_OCCTVersion.hxx>
+
+// OCC includes
#include <V3d_View.hxx>
+// QT includes
+#include <QImage>
#include <QAction>
- void OCCViewer_Utilities::setViewer2DMode( OCCViewer_Viewer* theViewer,
+Handle(Image_PixMap) OCCViewer_Utilities::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;
+}
+
+ OCCViewer_ViewWindow::Mode2dType OCCViewer_Utilities::setViewer2DMode
+ ( OCCViewer_Viewer* theViewer,
const OCCViewer_ViewWindow::Mode2dType& theMode )
{
+ OCCViewer_ViewWindow::Mode2dType anOldMode = OCCViewer_ViewWindow::No2dMode;
OCCViewer_ViewFrame* aFrame = dynamic_cast<OCCViewer_ViewFrame*>
( theViewer->getViewManager()->getActiveView() );
OCCViewer_ViewWindow* aView = aFrame ? aFrame->getView( OCCViewer_ViewFrame::MAIN_VIEW ) : 0;