Skip to content

Commit

Permalink
fix QT5 and QT6 include
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
mosfet80 committed Jun 29, 2023
1 parent 53e1067 commit 154cbe2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 160 deletions.
2 changes: 1 addition & 1 deletion cMake/FreeCAD_Helpers/SetupShibokenAndPyside.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ macro(SetupShibokenAndPyside)
if(FREECAD_QT_MAJOR_VERSION EQUAL 5)
set(SHIBOKEN_MAJOR_VERSION 2)
set(PYSIDE_MAJOR_VERSION 2)
else()
elseif(FREECAD_QT_MAJOR_VERSION EQUAL 6)
set(SHIBOKEN_MAJOR_VERSION ${FREECAD_QT_MAJOR_VERSION})
set(PYSIDE_MAJOR_VERSION ${FREECAD_QT_MAJOR_VERSION})
endif()
Expand Down
6 changes: 3 additions & 3 deletions src/Mod/Sandbox/App/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ include_directories(
${ZLIB_INCLUDE_DIR}
)

if (BUILD_QT5)
if (FREECAD_QT_MAJOR_VERSION EQUAL 5)
include_directories(
${Qt5Core_INCLUDE_DIRS}
)
else()
else(FREECAD_QT_MAJOR_VERSION EQUAL 6)
include_directories(
${QT_INCLUDE_DIR}
${Qt6Core_INCLUDE_DIRS}
)
endif()

Expand Down
152 changes: 4 additions & 148 deletions src/Mod/Sandbox/Gui/Overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,7 @@ class MyPaintable : public Gui::GLGraphicsItem
p.drawText(200,200,QString::fromLatin1("Render to QtGLFramebufferObject"));
p.end();
#endif
//img = fbo->toImage();
//img = QtGLWidget::convertToGLFormat(img);
}
//fbo->bind();
//glEnable(GL_DEPTH_TEST);
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//glDepthRange(0.1,1.0);
//glEnable(GL_LINE_SMOOTH);
//SoGLRenderAction a(SbViewportRegion(128,128));
//a.apply(v->getSceneManager()->getSceneGraph());
//fbo->release();
//img = fbo->toImage();
//img = QtGLWidget::convertToGLFormat(img);

view->getSoRenderManager()->scheduleRedraw();
}
Expand All @@ -113,33 +101,6 @@ class MyPaintable : public Gui::GLGraphicsItem
glColor4d(0.0,0.0,1.0,0.0f);
glRasterPos2d(0,0);

//http://wiki.delphigl.com/index.php/Multisampling
//glDrawPixels(img.width(),img.height(),GL_RGBA,GL_UNSIGNED_BYTE,img.bits());
/*
fbo->bind();
GLuint* buf = new GLuint[size[0]*size[1]];
glReadPixels(0, 0, size[0], size[1], GL_RGBA, GL_UNSIGNED_BYTE, buf);
fbo->release();
glDrawPixels(size[0],size[1],GL_RGBA,GL_UNSIGNED_BYTE,buf);
delete [] buf;
*/
/*
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, fbo->texture());
glBegin(GL_QUADS);
glTexCoord2f(0.0,0.0);
glVertex2f(-1.0,-1.0);
glTexCoord2f(0.0,1.0);
glVertex2f(-1.0,1.0);
glTexCoord2f(1.0,1.0);
glVertex2f(1.0,1.0);
glTexCoord2f(1.0,0.0);
glVertex2f(1.0,-1.0);
glEnd();
glDisable(GL_TEXTURE_2D);
*/


glPopAttrib();
glPopMatrix();
}
Expand Down Expand Up @@ -208,28 +169,6 @@ void initializeGL()

void resizeGL(int width, int height)
{
#if 0
fbObject->bind();

glDisable(GL_TEXTURE_2D);
glEnable(GL_LIGHTING);
glEnable(GL_DEPTH_TEST);

glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (width <= height) {
glOrtho(0.0, 20.0, 0.0, 20.0 * GLfloat(height) / GLfloat(width),
-10.0, 10.0);
} else {
glOrtho(0.0, 20.0 * GLfloat(width) / GLfloat(height), 0.0, 20.0,
-10.0, 10.0);
}
glMatrixMode(GL_MODELVIEW);
drawTeapots();

fbObject->release();
#else
(void)width;
(void)height;
fbObject->bind();
Expand All @@ -243,7 +182,6 @@ void resizeGL(int width, int height)
SoGLRenderAction gl(SbViewportRegion(fbObject->size().width(),fbObject->size().height()));
gl.apply(view->getSoRenderManager()->getSceneGraph());
fbObject->release();
#endif
}

void paintGL()
Expand Down Expand Up @@ -360,17 +298,6 @@ void paintGL()
const SbViewportRegion vp = view->getSoRenderManager()->getViewportRegion();
SbVec2s size = vp.getViewportSizePixels();


//glDisable(GL_LIGHTING);
//glViewport(0, 0, size[0], size[1]);
//glMatrixMode(GL_PROJECTION);
//glLoadIdentity();
//glMatrixMode(GL_MODELVIEW);
//glLoadIdentity();
//glDisable(GL_DEPTH_TEST);

//glClear(GL_COLOR_BUFFER_BIT);

glMatrixMode(GL_PROJECTION);
glOrtho(0, size[0], size[1], 0, 0, 100);
glMatrixMode(GL_MODELVIEW);
Expand All @@ -395,81 +322,21 @@ void paintGL()
glLineWidth(1.0);
glDisable(GL_LINE_STIPPLE);
glDisable(GL_BLEND);

//glEnable(GL_LIGHTING);
//glEnable(GL_DEPTH_TEST);
}

};


void paintSelection()
{
#if 0
SoAnnotation* hudRoot = new SoAnnotation;
hudRoot->ref();

SoOrthographicCamera* hudCam = new SoOrthographicCamera();
hudCam->viewportMapping = SoCamera::LEAVE_ALONE;
// Set the position in the window.
// [0, 0] is in the center of the screen.
//
SoTranslation* hudTrans = new SoTranslation;
hudTrans->translation.setValue(-1.0f, -1.0f, 0.0f);

QImage image(100,100,QImage::Format_ARGB32_Premultiplied);
image.fill(0x00000000);
SoSFImage sfimage;
Gui::BitmapFactory().convert(image, sfimage);
SoImage* hudImage = new SoImage();
hudImage->image = sfimage;

// Assemble the parts...
//
hudRoot->addChild(hudCam);
hudRoot->addChild(hudTrans);
hudRoot->addChild(hudImage);

Gui::View3DInventorViewer* viewer = this->getViewer();
static_cast<SoGroup*>(viewer->getSceneGraph())->addChild(hudRoot);

QWidget* gl = viewer->getGLWidget();
DrawingPlane pln(hudImage->image, viewer, gl);
gl->installEventFilter(&pln);
QEventLoop loop;
QObject::connect(&pln, SIGNAL(emitSelection()), &loop, SLOT(quit()));
loop.exec();
static_cast<SoGroup*>(viewer->getSceneGraph())->removeChild(hudRoot);
#endif

}

// ---------------------------------------
#include <Gui/NavigationStyle.h>
#include <Gui/View3DInventor.h>
#include <Gui/View3DInventorViewer.h>
#if 0
void MeshSelection::prepareFreehandSelection(bool add)
{
// a rubberband to select a rectangle area of the meshes
Gui::View3DInventorViewer* viewer = this->getViewer();
if (viewer) {
stopInteractiveCallback(viewer);
startInteractiveCallback(viewer, selectGLCallback);
// set cross cursor
DrawingPlane* brush = new DrawingPlane();
//brush->setColor(1.0f,0.0f,0.0f);
//brush->setLineWidth(3.0f);
viewer->navigationStyle()->startSelection(brush);
SoQtCursor::CustomCursor custom;
custom.dim.setValue(16, 16);
custom.hotspot.setValue(7, 7);
custom.bitmap = cross_bitmap;
custom.mask = cross_mask_bitmap;
viewer->setComponentCursor(SoQtCursor(&custom));
this->addToSelection = add;
}
}
#endif

DrawingPlane::DrawingPlane()
{
//image.fill(qRgba(255, 255, 255, 0));
Expand Down Expand Up @@ -628,23 +495,12 @@ void DrawingPlane::drawLineTo(const QPoint &endPoint)
return;
#if !defined(HAVE_QT5_OPENGL)
QPainter painter(fbo);

Check failure on line 497 in src/Mod/Sandbox/Gui/Overlay.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

no matching constructor for initialization of 'QPainter'

Check failure on line 497 in src/Mod/Sandbox/Gui/Overlay.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

no matching constructor for initialization of 'QPainter' [clang-diagnostic-error]
//QPainter painter(_pcView3D->getGLWidget());
painter.setPen(QPen(myPenColor, myPenWidth, Qt::SolidLine, Qt::RoundCap,
Qt::RoundJoin));
//painter.setOpacity(0.5);
//painter.drawLine(lastPoint.x(), fbo->height()-lastPoint.y(), endPoint.x(), fbo->height()-endPoint.y());

painter.drawLine(lastPoint.x(), lastPoint.y(), endPoint.x(), endPoint.y());

//_pcView3D->scheduleRedraw();
lastPoint = endPoint;
#endif
}
//Gui::Document* doc = Gui::Application::Instance->activeDocument();
//Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventor*>(doc->getActiveView())->getViewer();
////view->addGraphicsItem(new MyPaintable(view));
////view->addGraphicsItem(new Teapots(view));
//view->addGraphicsItem(new Rubberband(view));
//....
//Gui::Document* doc = Gui::Application::Instance->activeDocument();
//Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventor*>(doc->getActiveView())->getViewer();
//view->clearGraphicsItems();

Check warning on line 506 in src/Mod/Sandbox/Gui/Overlay.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

<-- trailing whitespace
18 changes: 10 additions & 8 deletions src/Tools/RegExp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@ project(RegExp)
set(APP_VERSION "1.0")

cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR)
if(FREECAD_QT_MAJOR_VERSION EQUAL 5)
${Qt5Core_INCLUDE_DIRS}
QT5_WRAP_CPP(RegExp_MOC_SRCS regexpdialog.h )
QT5_WRAP_UI(RegExp_UIC_HDRS regexpdialog.ui)

elseif(FREECAD_QT_MAJOR_VERSION EQUAL 6)
${Qt6Core_INCLUDE_DIRS}
QT6_WRAP_CPP(RegExp_MOC_SRCS regexpdialog.h )
QT6_WRAP_UI(RegExp_UIC_HDRS regexpdialog.ui)
endif()

find_package(Qt5)

include_directories(
${QT_INCLUDE_DIR}
Expand All @@ -16,13 +25,6 @@ link_directories(${QT_LIBRARY_DIR})

add_definitions(-D_UNICODE)

QT5_WRAP_CPP(RegExp_MOC_SRCS
regexpdialog.h
)

QT5_WRAP_UI(RegExp_UIC_HDRS
regexpdialog.ui
)

SET(RegExp_SRCS
${RegExp_UIC_HDRS}
Expand Down

0 comments on commit 154cbe2

Please sign in to comment.