Remove unneeded code
This commit is contained in:
parent
7c5ff7cec9
commit
ab8a8cd371
|
@ -23,46 +23,14 @@
|
|||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <algorithm>
|
||||
# include <climits>
|
||||
# include <boost/bind.hpp>
|
||||
# include <QEventLoop>
|
||||
# include <QImage>
|
||||
# include <QPushButton>
|
||||
# include <Inventor/SbBox2s.h>
|
||||
# include <Inventor/SoPickedPoint.h>
|
||||
# include <Inventor/details/SoFaceDetail.h>
|
||||
# include <Inventor/events/SoLocation2Event.h>
|
||||
# include <Inventor/events/SoMouseButtonEvent.h>
|
||||
# include <Inventor/nodes/SoAnnotation.h>
|
||||
# include <Inventor/nodes/SoSeparator.h>
|
||||
# include <Inventor/nodes/SoOrthographicCamera.h>
|
||||
# include <Inventor/nodes/SoTranslation.h>
|
||||
# include <Inventor/nodes/SoImage.h>
|
||||
#ifndef _PreComp_
|
||||
# include <QPushButton>
|
||||
#endif
|
||||
|
||||
#include "RemoveComponents.h"
|
||||
#include "ui_RemoveComponents.h"
|
||||
#include "ViewProvider.h"
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <App/Application.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/SoFCSelectionAction.h>
|
||||
#include <Gui/MouseSelection.h>
|
||||
#include <Gui/NavigationStyle.h>
|
||||
#include <Gui/View3DInventor.h>
|
||||
#include <Gui/View3DInventorViewer.h>
|
||||
#include <Mod/Mesh/App/MeshFeature.h>
|
||||
#include <Mod/Mesh/App/Core/Algorithm.h>
|
||||
#include <Mod/Mesh/App/Core/MeshKernel.h>
|
||||
#include <Mod/Mesh/App/Core/Iterator.h>
|
||||
#include <Mod/Mesh/App/Core/TopoAlgorithm.h>
|
||||
#include <Mod/Mesh/App/Core/Tools.h>
|
||||
|
||||
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<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
|
||||
}
|
||||
|
||||
// ---------------------------------------
|
||||
|
||||
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<QResizeEvent*>(e));
|
||||
else if (e->type() == QEvent::MouseButtonPress)
|
||||
mousePressEvent(static_cast<QMouseEvent*>(e));
|
||||
else if (e->type() == QEvent::MouseButtonRelease)
|
||||
mouseReleaseEvent(static_cast<QMouseEvent*>(e));
|
||||
else if (e->type() == QEvent::MouseMove)
|
||||
mouseMoveEvent(static_cast<QMouseEvent*>(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;
|
||||
}
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
|
|
|
@ -29,55 +29,9 @@
|
|||
#include <Gui/TaskView/TaskView.h>
|
||||
#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<QPoint> 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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user