From ab8a8cd37184753af60e7ee3b76eb074d83fe97b Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 7 May 2013 15:35:51 +0200 Subject: [PATCH] Remove unneeded code --- src/Mod/Mesh/Gui/RemoveComponents.cpp | 207 +------------------------- src/Mod/Mesh/Gui/RemoveComponents.h | 47 ------ 2 files changed, 3 insertions(+), 251 deletions(-) diff --git a/src/Mod/Mesh/Gui/RemoveComponents.cpp b/src/Mod/Mesh/Gui/RemoveComponents.cpp index a66e3f500..a9d869e69 100644 --- a/src/Mod/Mesh/Gui/RemoveComponents.cpp +++ b/src/Mod/Mesh/Gui/RemoveComponents.cpp @@ -23,46 +23,14 @@ #include "PreCompiled.h" -#ifndef _PreComp_ -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include +#ifndef _PreComp_ +# include #endif #include "RemoveComponents.h" #include "ui_RemoveComponents.h" -#include "ViewProvider.h" -#include -#include -#include -#include -#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include using namespace MeshGui; @@ -186,175 +154,6 @@ void RemoveComponents::reject() // deselect all meshes meshSel.clearSelection(); } - -void RemoveComponents::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(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(viewer->getSceneGraph())->removeChild(hudRoot); -#endif -} - -// --------------------------------------- - -DrawingPlane::DrawingPlane(SoSFImage& data, SoQtViewer* s, QWidget* view) - : QObject(), data(data), glView(view), soqt(s), image(view->size(), QImage::Format_ARGB32) -{ - image.fill(qRgba(255, 255, 255, 0)); - - myPenWidth = 50; - - QRgb p = qRgba(255,255,0,0); - int q = ((p << 16) & 0xff0000) | ((p >> 16) & 0xff) | (p & 0xff00ff00); - int r = qRed(q); - int g = qGreen(q); - int b = qBlue(q); - myPenColor = qRgb(r,g,b);//Qt::yellow; - myRadius = 5.0f; -} - -DrawingPlane::~DrawingPlane() -{ -} - -void DrawingPlane::changeRadius(double radius) -{ - this->myRadius = (double)radius; -} - -void DrawingPlane::mousePressEvent(QMouseEvent *event) -{ - // Calculate the given radius from mm into px - const SbViewportRegion& vp = soqt->getViewportRegion(); - float fRatio = vp.getViewportAspectRatio(); - const SbVec2s& sp = vp.getViewportSizePixels(); - float dX, dY; vp.getViewportSize().getValue(dX, dY); - SbViewVolume vv = soqt->getCamera()->getViewVolume(fRatio); - - SbVec3f p1(0,0,0); - SbVec3f p2(0,this->myRadius,0); - vv.projectToScreen(p1, p1); - vv.projectToScreen(p2, p2); - - if (fRatio > 1.0f) { - p1[0] = (p1[0] - 0.5f*dX) / fRatio + 0.5f*dX; - p2[0] = (p2[0] - 0.5f*dX) / fRatio + 0.5f*dX; - } - else if (fRatio < 1.0f) { - p1[1] = (p1[1] - 0.5f*dY) * fRatio + 0.5f*dY; - p2[1] = (p2[1] - 0.5f*dY) * fRatio + 0.5f*dY; - } - - int x1 = p1[0] * sp[0]; - int y1 = p1[1] * sp[1]; - int x2 = p2[0] * sp[0]; - int y2 = p2[1] * sp[1]; - - //myPenWidth = 2*abs(y1-y2); - - if (event->button() == Qt::LeftButton) { - lastPoint = event->pos(); - scribbling = true; - } -} - -void DrawingPlane::mouseMoveEvent(QMouseEvent *event) -{ - if ((event->buttons() & Qt::LeftButton) && scribbling) { - const QPoint& pos = event->pos(); - drawLineTo(pos); - - // filter out some points - if (selection.isEmpty()) { - selection << pos; - } - else { - const QPoint& top = selection.last(); - if (abs(top.x()-pos.x()) > 20 || - abs(top.y()-pos.y()) > 20) - selection << pos; - } - } -} - -void DrawingPlane::mouseReleaseEvent(QMouseEvent *event) -{ - if (event->button() == Qt::LeftButton && scribbling) { - drawLineTo(event->pos()); - scribbling = false; - /*emit*/ emitSelection(); - } -} - -bool DrawingPlane::eventFilter(QObject* o, QEvent* e) -{ - if (o == glView) { - if (e->type() == QEvent::Resize) - resizeEvent(static_cast(e)); - else if (e->type() == QEvent::MouseButtonPress) - mousePressEvent(static_cast(e)); - else if (e->type() == QEvent::MouseButtonRelease) - mouseReleaseEvent(static_cast(e)); - else if (e->type() == QEvent::MouseMove) - mouseMoveEvent(static_cast(e)); - } - - return false; -} - -void DrawingPlane::resizeEvent(QResizeEvent *event) -{ - QImage img(event->size(), QImage::Format_ARGB32); - img.fill(qRgba(255, 255, 255, 0)); - image = img; -} - -void DrawingPlane::drawLineTo(const QPoint &endPoint) -{ - QPainter painter(&image); - painter.setPen(QPen(myPenColor, myPenWidth, Qt::SolidLine, Qt::RoundCap, - Qt::RoundJoin)); - painter.setOpacity(0.5); - painter.drawLine(lastPoint.x(), image.height()-lastPoint.y(), endPoint.x(), image.height()-endPoint.y()); - - QImage img = image;//QGLWidget::convertToGLFormat(image); - int nc = img.numBytes() / ( img.width() * img.height() ); - data.setValue(SbVec2s(img.width(), img.height()), nc, img.bits()); - soqt->scheduleRedraw(); - lastPoint = endPoint; -} // ------------------------------------------------- diff --git a/src/Mod/Mesh/Gui/RemoveComponents.h b/src/Mod/Mesh/Gui/RemoveComponents.h index 96f25a131..57801811a 100644 --- a/src/Mod/Mesh/Gui/RemoveComponents.h +++ b/src/Mod/Mesh/Gui/RemoveComponents.h @@ -29,55 +29,9 @@ #include #include "MeshSelection.h" -// forward declarations -class SoNode; -class SoQtViewer; -class SoSFImage; -namespace App { class DocumentObject; } -namespace Gui { class View3DInventorViewer; } -namespace Gui { class Document; } -namespace Mesh { class Feature; } - namespace MeshGui { -class ViewProviderMesh; class Ui_RemoveComponents; -class DrawingPlane : public QObject -{ - Q_OBJECT - -public: - DrawingPlane(SoSFImage&, SoQtViewer*, QWidget* view); - virtual ~DrawingPlane(); - -protected: - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void resizeEvent(QResizeEvent *event); - bool eventFilter(QObject* o, QEvent* e); - -protected Q_SLOTS: - void changeRadius(double); - -Q_SIGNALS: - void emitSelection(); - -private: - void drawLineTo(const QPoint &endPoint); - - bool scribbling; - int myPenWidth; - float myRadius; - QColor myPenColor; - QPoint lastPoint; - QList selection; - QImage image; - SoSFImage& data; - SoQtViewer* soqt; - QWidget* glView; -}; - /** * Non-modal dialog to de/select components, regions, the complete or single faces * of a mesh and delete them. @@ -110,7 +64,6 @@ public Q_SLOTS: protected: void changeEvent(QEvent *e); - void paintSelection(); private: Ui_RemoveComponents* ui;