fix Coverity issues
This commit is contained in:
parent
8cc3ee64e8
commit
0824c5fd3c
|
@ -99,7 +99,7 @@ private:
|
|||
Gui::PropertyView * prop;
|
||||
QTreeView * tree;
|
||||
Gui::TaskView::TaskView * taskPanel;
|
||||
Gui::ProjectWidget * projectView;
|
||||
//Gui::ProjectWidget * projectView;
|
||||
};
|
||||
|
||||
} // namespace DockWnd
|
||||
|
|
|
@ -217,7 +217,14 @@ private:
|
|||
};
|
||||
|
||||
StdCmdFreezeViews::StdCmdFreezeViews()
|
||||
: Command("Std_FreezeViews"), maxViews(50), savedViews(0)
|
||||
: Command("Std_FreezeViews")
|
||||
, maxViews(50)
|
||||
, savedViews(0)
|
||||
, offset(0)
|
||||
, saveView(0)
|
||||
, freezeView(0)
|
||||
, clearView(0)
|
||||
, separator(0)
|
||||
{
|
||||
sGroup = QT_TR_NOOP("Standard-View");
|
||||
sMenuText = QT_TR_NOOP("Freeze display");
|
||||
|
@ -812,7 +819,7 @@ void StdCmdToggleSelectability::activated(int iMsg)
|
|||
|
||||
for (std::vector<App::DocumentObject*>::const_iterator ft=sel.begin();ft!=sel.end();++ft) {
|
||||
ViewProvider *pr = pcDoc->getViewProviderByName((*ft)->getNameInDocument());
|
||||
if (pr->isDerivedFrom(ViewProviderGeometryObject::getClassTypeId())){
|
||||
if (pr && pr->isDerivedFrom(ViewProviderGeometryObject::getClassTypeId())){
|
||||
if (static_cast<ViewProviderGeometryObject*>(pr)->Selectable.getValue())
|
||||
doCommand(Gui,"Gui.getDocument(\"%s\").getObject(\"%s\").Selectable=False"
|
||||
, (*it)->getName(), (*ft)->getNameInDocument());
|
||||
|
|
|
@ -38,7 +38,9 @@ VertexProperty::VertexProperty() :
|
|||
text(new QGraphicsTextItem()),
|
||||
row(0),
|
||||
column(0),
|
||||
topoSortIndex(0),
|
||||
lastVisibleState(VisibilityState::None),
|
||||
lastFeatureState(FeatureState::None),
|
||||
dagVisible(true)
|
||||
{
|
||||
//set z values.
|
||||
|
@ -107,4 +109,4 @@ void Gui::DAG::eraseRecord(const ViewProviderDocumentObject* VPDObjectIn, GraphL
|
|||
List::iterator it = list.find(VPDObjectIn);
|
||||
assert(it != list.end());
|
||||
containerIn.get<GraphLinkRecord::ByVPDObject>().erase(it);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,8 +58,9 @@ std::list<DlgPreferencesImp::TGroupPages> DlgPreferencesImp::_pages;
|
|||
* The dialog will by default be modeless, unless you set 'modal' to
|
||||
* true to construct a modal dialog.
|
||||
*/
|
||||
DlgPreferencesImp::DlgPreferencesImp( QWidget* parent, Qt::WindowFlags fl )
|
||||
: QDialog(parent, fl), ui(new Ui_DlgPreferences), canEmbedScrollArea(true)
|
||||
DlgPreferencesImp::DlgPreferencesImp(QWidget* parent, Qt::WindowFlags fl)
|
||||
: QDialog(parent, fl), ui(new Ui_DlgPreferences),
|
||||
invalidParameter(false), canEmbedScrollArea(true)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ using namespace Gui::Dialog;
|
|||
|
||||
|
||||
DownloadDialog::DownloadDialog(const QUrl& url, QWidget *parent)
|
||||
: QDialog(parent), url(url)
|
||||
: QDialog(parent), url(url), file(0), httpGetId(0), httpRequestAborted(false)
|
||||
{
|
||||
statusLabel = new QLabel(url.toString());
|
||||
progressBar = new QProgressBar(this);
|
||||
|
|
|
@ -28,14 +28,16 @@ using namespace Gui;
|
|||
*/
|
||||
|
||||
ExpressionCompleter::ExpressionCompleter(const App::Document * currentDoc, const App::DocumentObject * currentDocObj, QObject *parent)
|
||||
: QCompleter(parent)
|
||||
: QCompleter(parent), prefixStart(0)
|
||||
{
|
||||
QStandardItemModel* model = new QStandardItemModel(this);
|
||||
|
||||
std::vector<App::Document*> docs = App::GetApplication().getDocuments();
|
||||
std::vector<App::Document*>::const_iterator di = docs.begin();
|
||||
|
||||
std::vector<DocumentObject*> deps = currentDocObj->getInList();
|
||||
std::vector<DocumentObject*> deps;
|
||||
if (currentDocObj)
|
||||
deps = currentDocObj->getInList();
|
||||
std::set<const DocumentObject*> forbidden;
|
||||
|
||||
for (std::vector<DocumentObject*>::const_iterator it = deps.begin(); it != deps.end(); ++it)
|
||||
|
|
|
@ -35,7 +35,7 @@ using namespace Gui;
|
|||
|
||||
TYPESYSTEM_SOURCE_ABSTRACT(Gui::GLGraphicsItem, Base::BaseClass);
|
||||
|
||||
GLPainter::GLPainter() : viewer(0), logicOp(false), lineStipple(false)
|
||||
GLPainter::GLPainter() : viewer(0), width(0), height(0), logicOp(false), lineStipple(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -208,13 +208,23 @@ Rubberband::Rubberband(View3DInventorViewer* v) : viewer(v)
|
|||
x_old = y_old = x_new = y_new = 0;
|
||||
working = false;
|
||||
stipple = true;
|
||||
|
||||
rgb_r = 1.0f;
|
||||
rgb_g = 1.0f;
|
||||
rgb_b = 1.0f;
|
||||
rgb_a = 1.0f;
|
||||
}
|
||||
|
||||
Rubberband::Rubberband()
|
||||
Rubberband::Rubberband() : viewer(0)
|
||||
{
|
||||
x_old = y_old = x_new = y_new = 0;
|
||||
working = false;
|
||||
stipple = true;
|
||||
|
||||
rgb_r = 1.0f;
|
||||
rgb_g = 1.0f;
|
||||
rgb_b = 1.0f;
|
||||
rgb_a = 1.0f;
|
||||
}
|
||||
|
||||
Rubberband::~Rubberband()
|
||||
|
@ -309,7 +319,7 @@ Polyline::Polyline(View3DInventorViewer* v) : viewer(v)
|
|||
rgb_a = 1.0f;
|
||||
}
|
||||
|
||||
Polyline::Polyline()
|
||||
Polyline::Polyline() : viewer(0)
|
||||
{
|
||||
x_new = y_new = 0;
|
||||
working = false;
|
||||
|
|
|
@ -52,6 +52,7 @@ MacroManager::MacroManager()
|
|||
recordGui(true),
|
||||
guiAsComment(true),
|
||||
scriptToPyConsole(true),
|
||||
localEnv(true),
|
||||
pyConsole(0),
|
||||
pyDebugger(new PythonDebugger())
|
||||
{
|
||||
|
@ -203,7 +204,7 @@ namespace Gui {
|
|||
class PythonRedirector
|
||||
{
|
||||
public:
|
||||
PythonRedirector(const char* type, PyObject* obj) : std_out(type), out(obj)
|
||||
PythonRedirector(const char* type, PyObject* obj) : std_out(type), out(obj), old(0)
|
||||
{
|
||||
if (out) {
|
||||
Base::PyGILStateLocker lock;
|
||||
|
|
|
@ -97,7 +97,7 @@ private:
|
|||
};
|
||||
}
|
||||
|
||||
MergeDocuments::MergeDocuments(App::Document* doc) : appdoc(doc)
|
||||
MergeDocuments::MergeDocuments(App::Document* doc) : stream(0), appdoc(doc)
|
||||
{
|
||||
connectExport = doc->signalExportObjects.connect
|
||||
(boost::bind(&MergeDocuments::exportObject, this, _1, _2));
|
||||
|
|
|
@ -47,6 +47,10 @@ using namespace Gui;
|
|||
|
||||
AbstractMouseSelection::AbstractMouseSelection() : _pcView3D(0)
|
||||
{
|
||||
m_iXold = 0;
|
||||
m_iYold = 0;
|
||||
m_iXnew = 0;
|
||||
m_iYnew = 0;
|
||||
m_bInner = true;
|
||||
}
|
||||
|
||||
|
@ -245,6 +249,7 @@ static const char* cursor_cut_scissors[]= {
|
|||
|
||||
PolyPickerSelection::PolyPickerSelection()
|
||||
{
|
||||
lastConfirmed = false;
|
||||
}
|
||||
|
||||
void PolyPickerSelection::setColor(float r, float g, float b, float a)
|
||||
|
|
|
@ -63,10 +63,12 @@ struct NavigationStyleP {
|
|||
NavigationStyleP()
|
||||
{
|
||||
this->animationsteps = 0;
|
||||
this->animationdelta = 0;
|
||||
this->sensitivity = 2.0f;
|
||||
this->resetcursorpos = false;
|
||||
this->dragPointFound = false;
|
||||
this->dragAtCursor = false;
|
||||
this->animsensor = 0;
|
||||
}
|
||||
static void viewAnimationCB(void * data, SoSensor * sensor);
|
||||
};
|
||||
|
|
|
@ -100,7 +100,13 @@ struct PythonConsoleP
|
|||
PythonConsoleP()
|
||||
{
|
||||
type = Normal;
|
||||
_stdoutPy = 0;
|
||||
_stderrPy = 0;
|
||||
_stdinPy = 0;
|
||||
_stdin = 0;
|
||||
interpreter = 0;
|
||||
callTipsList = 0;
|
||||
interactive = false;
|
||||
colormap[QLatin1String("Text")] = Qt::black;
|
||||
colormap[QLatin1String("Bookmark")] = Qt::cyan;
|
||||
colormap[QLatin1String("Breakpoint")] = Qt::red;
|
||||
|
@ -367,7 +373,6 @@ PythonConsole::PythonConsole(QWidget *parent)
|
|||
: TextEdit(parent), WindowParameter( "Editor" ), _sourceDrain(NULL)
|
||||
{
|
||||
d = new PythonConsoleP();
|
||||
d->interactive = false;
|
||||
|
||||
// create an instance of InteractiveInterpreter
|
||||
try {
|
||||
|
|
|
@ -104,7 +104,7 @@ void PythonDebugModule::init_module(void)
|
|||
PythonDebugStdout::init_type();
|
||||
PythonDebugStderr::init_type();
|
||||
PythonDebugExcept::init_type();
|
||||
static PythonDebugModule* mod = new PythonDebugModule();
|
||||
static PythonDebugModule* mod = new PythonDebugModule();
|
||||
Q_UNUSED(mod);
|
||||
}
|
||||
|
||||
|
@ -352,6 +352,9 @@ struct PythonDebuggerP {
|
|||
PythonDebuggerP(PythonDebugger* that) :
|
||||
init(false), trystop(false), running(false)
|
||||
{
|
||||
out_o = 0;
|
||||
err_o = 0;
|
||||
exc_o = 0;
|
||||
Base::PyGILStateLocker lock;
|
||||
out_n = new PythonDebugStdout();
|
||||
err_n = new PythonDebugStderr();
|
||||
|
@ -433,20 +436,20 @@ void PythonDebugger::runFile(const QString& fn)
|
|||
module = PyImport_AddModule("__main__");
|
||||
dict = PyModule_GetDict(module);
|
||||
dict = PyDict_Copy(dict);
|
||||
if (PyDict_GetItemString(dict, "__file__") == NULL) {
|
||||
PyObject *f = PyString_FromString((const char*)pxFileName);
|
||||
if (f == NULL) {
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
if (PyDict_SetItemString(dict, "__file__", f) < 0) {
|
||||
Py_DECREF(f);
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
Py_DECREF(f);
|
||||
}
|
||||
|
||||
if (PyDict_GetItemString(dict, "__file__") == NULL) {
|
||||
PyObject *f = PyString_FromString((const char*)pxFileName);
|
||||
if (f == NULL) {
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
if (PyDict_SetItemString(dict, "__file__", f) < 0) {
|
||||
Py_DECREF(f);
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
Py_DECREF(f);
|
||||
}
|
||||
|
||||
PyObject *result = PyRun_File(fp, (const char*)pxFileName, Py_file_input, dict, dict);
|
||||
fclose(fp);
|
||||
Py_DECREF(dict);
|
||||
|
@ -570,54 +573,54 @@ int PythonDebugger::tracer_callback(PyObject *obj, PyFrameObject *frame, int wha
|
|||
PyErr_SetInterrupt();
|
||||
QCoreApplication::processEvents();
|
||||
//int no;
|
||||
|
||||
//no = frame->f_tstate->recursion_depth;
|
||||
//std::string funcname = PyString_AsString(frame->f_code->co_name);
|
||||
QString file = QString::fromUtf8(PyString_AsString(frame->f_code->co_filename));
|
||||
switch (what) {
|
||||
case PyTrace_CALL:
|
||||
self->depth++;
|
||||
return 0;
|
||||
case PyTrace_RETURN:
|
||||
if (self->depth > 0)
|
||||
self->depth--;
|
||||
return 0;
|
||||
case PyTrace_LINE:
|
||||
{
|
||||
//PyObject *str;
|
||||
//str = PyObject_Str(frame->f_code->co_filename);
|
||||
//no = frame->f_lineno;
|
||||
int line = PyCode_Addr2Line(frame->f_code, frame->f_lasti);
|
||||
//if (str) {
|
||||
// Base::Console().Message("PROFILING: %s:%d\n", PyString_AsString(str), frame->f_lineno);
|
||||
// Py_DECREF(str);
|
||||
//}
|
||||
// For testing only
|
||||
if (!dbg->d->trystop) {
|
||||
Breakpoint bp = dbg->getBreakpoint(file);
|
||||
if (bp.checkLine(line)) {
|
||||
dbg->showDebugMarker(file, line);
|
||||
|
||||
//no = frame->f_tstate->recursion_depth;
|
||||
//std::string funcname = PyString_AsString(frame->f_code->co_name);
|
||||
QString file = QString::fromUtf8(PyString_AsString(frame->f_code->co_filename));
|
||||
switch (what) {
|
||||
case PyTrace_CALL:
|
||||
self->depth++;
|
||||
return 0;
|
||||
case PyTrace_RETURN:
|
||||
if (self->depth > 0)
|
||||
self->depth--;
|
||||
return 0;
|
||||
case PyTrace_LINE:
|
||||
{
|
||||
//PyObject *str;
|
||||
//str = PyObject_Str(frame->f_code->co_filename);
|
||||
//no = frame->f_lineno;
|
||||
int line = PyCode_Addr2Line(frame->f_code, frame->f_lasti);
|
||||
//if (str) {
|
||||
// Base::Console().Message("PROFILING: %s:%d\n", PyString_AsString(str), frame->f_lineno);
|
||||
// Py_DECREF(str);
|
||||
//}
|
||||
// For testing only
|
||||
if (!dbg->d->trystop) {
|
||||
Breakpoint bp = dbg->getBreakpoint(file);
|
||||
if (bp.checkLine(line)) {
|
||||
dbg->showDebugMarker(file, line);
|
||||
QEventLoop loop;
|
||||
QObject::connect(dbg, SIGNAL(signalNextStep()), &loop, SLOT(quit()));
|
||||
loop.exec();
|
||||
dbg->hideDebugMarker(file);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
case PyTrace_EXCEPTION:
|
||||
return 0;
|
||||
case PyTrace_C_CALL:
|
||||
return 0;
|
||||
case PyTrace_C_EXCEPTION:
|
||||
return 0;
|
||||
case PyTrace_C_RETURN:
|
||||
return 0;
|
||||
default:
|
||||
/* ignore PyTrace_EXCEPTION */
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
case PyTrace_EXCEPTION:
|
||||
return 0;
|
||||
case PyTrace_C_CALL:
|
||||
return 0;
|
||||
case PyTrace_C_EXCEPTION:
|
||||
return 0;
|
||||
case PyTrace_C_RETURN:
|
||||
return 0;
|
||||
default:
|
||||
/* ignore PyTrace_EXCEPTION */
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "moc_PythonDebugger.cpp"
|
||||
|
|
|
@ -976,12 +976,17 @@ void SelectionSingleton::slotDeletedObject(const App::DocumentObject& Obj)
|
|||
*/
|
||||
SelectionSingleton::SelectionSingleton()
|
||||
{
|
||||
hx = 0;
|
||||
hy = 0;
|
||||
hz = 0;
|
||||
ActiveGate = 0;
|
||||
App::GetApplication().signalDeletedObject.connect(boost::bind(&Gui::SelectionSingleton::slotDeletedObject, this, _1));
|
||||
CurrentPreselection.pDocName = 0;
|
||||
CurrentPreselection.pObjectName = 0;
|
||||
CurrentPreselection.pSubName = 0;
|
||||
|
||||
CurrentPreselection.x = 0.0;
|
||||
CurrentPreselection.y = 0.0;
|
||||
CurrentPreselection.z = 0.0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -362,10 +362,10 @@ bool SelectionFilter::parse(void)
|
|||
TopBlock = 0;
|
||||
SelectionParser::SelectionFilter_delete_buffer (my_string_buffer);
|
||||
|
||||
if(Errors == "")
|
||||
if (Errors.empty()) {
|
||||
return true;
|
||||
else{
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
delete Ast;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -199,19 +199,19 @@ SoGroup* TDragger::buildGeometry()
|
|||
|
||||
void TDragger::startCB(void *, SoDragger *d)
|
||||
{
|
||||
TDragger *sudoThis = dynamic_cast<TDragger *>(d);
|
||||
TDragger *sudoThis = static_cast<TDragger *>(d);
|
||||
sudoThis->dragStart();
|
||||
}
|
||||
|
||||
void TDragger::motionCB(void *, SoDragger *d)
|
||||
{
|
||||
TDragger *sudoThis = dynamic_cast<TDragger *>(d);
|
||||
TDragger *sudoThis = static_cast<TDragger *>(d);
|
||||
sudoThis->drag();
|
||||
}
|
||||
|
||||
void TDragger::finishCB(void *, SoDragger *d)
|
||||
{
|
||||
TDragger *sudoThis = dynamic_cast<TDragger *>(d);
|
||||
TDragger *sudoThis = static_cast<TDragger *>(d);
|
||||
sudoThis->dragFinish();
|
||||
}
|
||||
|
||||
|
@ -471,19 +471,19 @@ SoGroup* RDragger::buildGeometry()
|
|||
|
||||
void RDragger::startCB(void *, SoDragger *d)
|
||||
{
|
||||
RDragger *sudoThis = dynamic_cast<RDragger *>(d);
|
||||
RDragger *sudoThis = static_cast<RDragger *>(d);
|
||||
sudoThis->dragStart();
|
||||
}
|
||||
|
||||
void RDragger::motionCB(void *, SoDragger *d)
|
||||
{
|
||||
RDragger *sudoThis = dynamic_cast<RDragger *>(d);
|
||||
RDragger *sudoThis = static_cast<RDragger *>(d);
|
||||
sudoThis->drag();
|
||||
}
|
||||
|
||||
void RDragger::finishCB(void *, SoDragger *d)
|
||||
{
|
||||
RDragger *sudoThis = dynamic_cast<RDragger *>(d);
|
||||
RDragger *sudoThis = static_cast<RDragger *>(d);
|
||||
sudoThis->dragFinish();
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ public:
|
|||
{
|
||||
if (bar->customize())
|
||||
bar->Notify(0);
|
||||
this->deleteLater();
|
||||
this->deleteLater();
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -108,6 +108,11 @@ SoFCColorBar::SoFCColorBar()
|
|||
{
|
||||
SO_NODE_CONSTRUCTOR(SoFCColorBar);
|
||||
|
||||
_fMaxX = 0;
|
||||
_fMinX = 0;
|
||||
_fMaxY = 0;
|
||||
_fMinY = 0;
|
||||
|
||||
// SoEventCallback * cb = new SoEventCallback;
|
||||
// cb->addEventCallback(SoMouseButtonEvent::getClassTypeId(), eventCallback, this);
|
||||
// insertChild(cb, 0);
|
||||
|
@ -250,9 +255,9 @@ void SoFCColorBar::handleEvent (SoHandleEventAction *action)
|
|||
if (e->getState() == SoButtonEvent::DOWN) {
|
||||
// double click event
|
||||
if (_timer.restart() < QApplication::doubleClickInterval()) {
|
||||
QApplication::postEvent(
|
||||
new SoFCColorBarProxyObject(this),
|
||||
new QEvent(QEvent::User));
|
||||
QApplication::postEvent(
|
||||
new SoFCColorBarProxyObject(this),
|
||||
new QEvent(QEvent::User));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -274,9 +279,9 @@ void SoFCColorBar::handleEvent (SoHandleEventAction *action)
|
|||
QAction* action = menu.exec(QCursor::pos());
|
||||
|
||||
if (action == option) {
|
||||
QApplication::postEvent(
|
||||
new SoFCColorBarProxyObject(this),
|
||||
new QEvent(QEvent::User));
|
||||
QApplication::postEvent(
|
||||
new SoFCColorBarProxyObject(this),
|
||||
new QEvent(QEvent::User));
|
||||
}
|
||||
else if (action) {
|
||||
int id = action->data().toInt();
|
||||
|
|
|
@ -406,6 +406,7 @@ void SoQtOffscreenRenderer::init(const SbViewportRegion & vpr,
|
|||
this->pixelbuffer = NULL; // constructed later
|
||||
this->framebuffer = NULL;
|
||||
this->numSamples = -1;
|
||||
this->cache_context = 0;
|
||||
this->pbuffer = QGLPixelBuffer::hasOpenGLPbuffers();
|
||||
}
|
||||
|
||||
|
@ -503,29 +504,29 @@ SoQtOffscreenRenderer::getGLRenderAction(void) const
|
|||
{
|
||||
return PRIVATE(this)->renderaction;
|
||||
}
|
||||
|
||||
void
|
||||
SoQtOffscreenRenderer::setNumPasses(const int num)
|
||||
{
|
||||
PRIVATE(this)->numSamples = num;
|
||||
}
|
||||
|
||||
int
|
||||
SoQtOffscreenRenderer::getNumPasses(void) const
|
||||
{
|
||||
return PRIVATE(this)->numSamples;
|
||||
}
|
||||
|
||||
void
|
||||
SoQtOffscreenRenderer::setPbufferEnable(SbBool enable)
|
||||
{
|
||||
PRIVATE(this)->pbuffer = enable;
|
||||
}
|
||||
|
||||
SbBool
|
||||
SoQtOffscreenRenderer::getPbufferEnable(void) const
|
||||
|
||||
void
|
||||
SoQtOffscreenRenderer::setNumPasses(const int num)
|
||||
{
|
||||
return PRIVATE(this)->pbuffer;
|
||||
PRIVATE(this)->numSamples = num;
|
||||
}
|
||||
|
||||
int
|
||||
SoQtOffscreenRenderer::getNumPasses(void) const
|
||||
{
|
||||
return PRIVATE(this)->numSamples;
|
||||
}
|
||||
|
||||
void
|
||||
SoQtOffscreenRenderer::setPbufferEnable(SbBool enable)
|
||||
{
|
||||
PRIVATE(this)->pbuffer = enable;
|
||||
}
|
||||
|
||||
SbBool
|
||||
SoQtOffscreenRenderer::getPbufferEnable(void) const
|
||||
{
|
||||
return PRIVATE(this)->pbuffer;
|
||||
}
|
||||
|
||||
// *************************************************************************
|
||||
|
|
|
@ -24,30 +24,30 @@
|
|||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <cassert>
|
||||
# include <cassert>
|
||||
# include <float.h>
|
||||
# include <Inventor/actions/SoSearchAction.h>
|
||||
# include <Inventor/actions/SoGetBoundingBoxAction.h>
|
||||
# include <Inventor/actions/SoSearchAction.h>
|
||||
# include <Inventor/actions/SoGetBoundingBoxAction.h>
|
||||
# include <Inventor/nodes/SoCallback.h>
|
||||
# include <Inventor/nodes/SoComplexity.h>
|
||||
# include <Inventor/nodes/SoCube.h>
|
||||
# include <Inventor/nodes/SoCamera.h>
|
||||
# include <Inventor/nodes/SoCube.h>
|
||||
# include <Inventor/nodes/SoCamera.h>
|
||||
# include <Inventor/nodes/SoCoordinate3.h>
|
||||
# include <Inventor/nodes/SoCoordinate4.h>
|
||||
# include <Inventor/nodes/SoFont.h>
|
||||
# include <Inventor/nodes/SoMatrixTransform.h>
|
||||
# include <Inventor/nodes/SoMatrixTransform.h>
|
||||
# include <Inventor/nodes/SoProfile.h>
|
||||
# include <Inventor/nodes/SoProfileCoordinate2.h>
|
||||
# include <Inventor/nodes/SoProfileCoordinate3.h>
|
||||
# include <Inventor/nodes/SoSwitch.h>
|
||||
# include <Inventor/nodes/SoTransformation.h>
|
||||
# include <Inventor/nodes/SoIndexedLineSet.h>
|
||||
# include <Inventor/nodes/SoIndexedFaceSet.h>
|
||||
# include <Inventor/nodes/SoPointSet.h>
|
||||
# include <Inventor/nodes/SoDrawStyle.h>
|
||||
# include <Inventor/nodes/SoComplexity.h>
|
||||
# include <Inventor/nodes/SoLightModel.h>
|
||||
# include <Inventor/nodes/SoBaseColor.h>
|
||||
# include <Inventor/nodes/SoIndexedLineSet.h>
|
||||
# include <Inventor/nodes/SoIndexedFaceSet.h>
|
||||
# include <Inventor/nodes/SoPointSet.h>
|
||||
# include <Inventor/nodes/SoDrawStyle.h>
|
||||
# include <Inventor/nodes/SoComplexity.h>
|
||||
# include <Inventor/nodes/SoLightModel.h>
|
||||
# include <Inventor/nodes/SoBaseColor.h>
|
||||
#endif
|
||||
|
||||
#include <Base/Console.h>
|
||||
|
@ -820,385 +820,399 @@ SbBool SoVisibleFaceAction::isHandled() const
|
|||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
namespace Gui {
|
||||
class SoBoxSelectionRenderActionP {
|
||||
public:
|
||||
SoBoxSelectionRenderActionP(SoBoxSelectionRenderAction * master)
|
||||
: master(master) { }
|
||||
|
||||
SoBoxSelectionRenderAction * master;
|
||||
SoSearchAction * searchaction;
|
||||
SoSearchAction * selectsearch;
|
||||
SoSearchAction * camerasearch;
|
||||
SoGetBoundingBoxAction * bboxaction;
|
||||
SoBaseColor * basecolor;
|
||||
SoTempPath * postprocpath;
|
||||
SoPath * highlightPath;
|
||||
SoSeparator * localRoot;
|
||||
SoMatrixTransform * xform;
|
||||
SoCube * cube;
|
||||
SoDrawStyle * drawstyle;
|
||||
SoColorPacker colorpacker;
|
||||
|
||||
void initBoxGraph();
|
||||
void updateBbox(const SoPath * path);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#undef PRIVATE
|
||||
#define PRIVATE(p) ((p)->pimpl)
|
||||
#undef PUBLIC
|
||||
#define PUBLIC(p) ((p)->master)
|
||||
|
||||
// used to initialize the internal storage class with variables
|
||||
void
|
||||
SoBoxSelectionRenderActionP::initBoxGraph()
|
||||
{
|
||||
this->localRoot = new SoSeparator;
|
||||
this->localRoot->ref();
|
||||
this->localRoot->renderCaching = SoSeparator::OFF;
|
||||
this->localRoot->boundingBoxCaching = SoSeparator::OFF;
|
||||
|
||||
this->xform = new SoMatrixTransform;
|
||||
this->cube = new SoCube;
|
||||
|
||||
this->drawstyle = new SoDrawStyle;
|
||||
this->drawstyle->style = SoDrawStyleElement::LINES;
|
||||
this->basecolor = new SoBaseColor;
|
||||
|
||||
SoLightModel * lightmodel = new SoLightModel;
|
||||
lightmodel->model = SoLightModel::BASE_COLOR;
|
||||
|
||||
SoComplexity * complexity = new SoComplexity;
|
||||
complexity->textureQuality = 0.0f;
|
||||
complexity->type = SoComplexityTypeElement::BOUNDING_BOX;
|
||||
|
||||
this->localRoot->addChild(this->drawstyle);
|
||||
this->localRoot->addChild(this->basecolor);
|
||||
|
||||
this->localRoot->addChild(lightmodel);
|
||||
this->localRoot->addChild(complexity);
|
||||
|
||||
this->localRoot->addChild(this->xform);
|
||||
this->localRoot->addChild(this->cube);
|
||||
}
|
||||
|
||||
|
||||
// used to render shape and non-shape nodes (usually SoGroup or SoSeparator).
|
||||
void
|
||||
SoBoxSelectionRenderActionP::updateBbox(const SoPath * path)
|
||||
{
|
||||
if (this->camerasearch == NULL) {
|
||||
this->camerasearch = new SoSearchAction;
|
||||
}
|
||||
|
||||
// find camera used to render node
|
||||
this->camerasearch->setFind(SoSearchAction::TYPE);
|
||||
this->camerasearch->setInterest(SoSearchAction::LAST);
|
||||
this->camerasearch->setType(SoCamera::getClassTypeId());
|
||||
this->camerasearch->apply((SoPath*) path);
|
||||
|
||||
if (!this->camerasearch->getPath()) {
|
||||
// if there is no camera there is no point rendering the bbox
|
||||
return;
|
||||
}
|
||||
this->localRoot->insertChild(this->camerasearch->getPath()->getTail(), 0);
|
||||
this->camerasearch->reset();
|
||||
|
||||
if (this->bboxaction == NULL) {
|
||||
this->bboxaction = new SoGetBoundingBoxAction(SbViewportRegion(100, 100));
|
||||
}
|
||||
this->bboxaction->setViewportRegion(PUBLIC(this)->getViewportRegion());
|
||||
this->bboxaction->apply((SoPath*) path);
|
||||
|
||||
SbXfBox3f & box = this->bboxaction->getXfBoundingBox();
|
||||
|
||||
if (!box.isEmpty()) {
|
||||
// set cube size
|
||||
float x, y, z;
|
||||
box.getSize(x, y, z);
|
||||
this->cube->width = x;
|
||||
this->cube->height = y;
|
||||
this->cube->depth = z;
|
||||
|
||||
SbMatrix transform = box.getTransform();
|
||||
|
||||
// get center (in the local bbox coordinate system)
|
||||
SbVec3f center = box.SbBox3f::getCenter();
|
||||
|
||||
// if center != (0,0,0), move the cube
|
||||
if (center != SbVec3f(0.0f, 0.0f, 0.0f)) {
|
||||
SbMatrix t;
|
||||
t.setTranslate(center);
|
||||
transform.multLeft(t);
|
||||
}
|
||||
this->xform->matrix = transform;
|
||||
|
||||
PUBLIC(this)->SoGLRenderAction::apply(this->localRoot);
|
||||
}
|
||||
// remove camera
|
||||
this->localRoot->removeChild(0);
|
||||
}
|
||||
|
||||
SO_ACTION_SOURCE(SoBoxSelectionRenderAction);
|
||||
|
||||
// Overridden from parent class.
|
||||
void
|
||||
SoBoxSelectionRenderAction::initClass(void)
|
||||
{
|
||||
SO_ACTION_INIT_CLASS(SoBoxSelectionRenderAction, SoGLRenderAction);
|
||||
}
|
||||
|
||||
SoBoxSelectionRenderAction::SoBoxSelectionRenderAction(void)
|
||||
: inherited(SbViewportRegion())
|
||||
{
|
||||
this->constructorCommon();
|
||||
}
|
||||
|
||||
SoBoxSelectionRenderAction::SoBoxSelectionRenderAction(const SbViewportRegion & viewportregion)
|
||||
: inherited(viewportregion)
|
||||
{
|
||||
this->constructorCommon();
|
||||
}
|
||||
|
||||
//
|
||||
// private. called by both constructors
|
||||
//
|
||||
void
|
||||
SoBoxSelectionRenderAction::constructorCommon(void)
|
||||
{
|
||||
SO_ACTION_CONSTRUCTOR(SoBoxSelectionRenderAction);
|
||||
|
||||
PRIVATE(this) = new SoBoxSelectionRenderActionP(this);
|
||||
|
||||
// Initialize local variables
|
||||
PRIVATE(this)->initBoxGraph();
|
||||
|
||||
|
||||
namespace Gui {
|
||||
class SoBoxSelectionRenderActionP {
|
||||
public:
|
||||
SoBoxSelectionRenderActionP(SoBoxSelectionRenderAction * master)
|
||||
: master(master)
|
||||
, searchaction(0)
|
||||
, selectsearch(0)
|
||||
, camerasearch(0)
|
||||
, bboxaction(0)
|
||||
, basecolor(0)
|
||||
, postprocpath(0)
|
||||
, highlightPath(0)
|
||||
, localRoot(0)
|
||||
, xform(0)
|
||||
, cube(0)
|
||||
, drawstyle(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SoBoxSelectionRenderAction * master;
|
||||
SoSearchAction * searchaction;
|
||||
SoSearchAction * selectsearch;
|
||||
SoSearchAction * camerasearch;
|
||||
SoGetBoundingBoxAction * bboxaction;
|
||||
SoBaseColor * basecolor;
|
||||
SoTempPath * postprocpath;
|
||||
SoPath * highlightPath;
|
||||
SoSeparator * localRoot;
|
||||
SoMatrixTransform * xform;
|
||||
SoCube * cube;
|
||||
SoDrawStyle * drawstyle;
|
||||
SoColorPacker colorpacker;
|
||||
|
||||
void initBoxGraph();
|
||||
void updateBbox(const SoPath * path);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#undef PRIVATE
|
||||
#define PRIVATE(p) ((p)->pimpl)
|
||||
#undef PUBLIC
|
||||
#define PUBLIC(p) ((p)->master)
|
||||
|
||||
// used to initialize the internal storage class with variables
|
||||
void
|
||||
SoBoxSelectionRenderActionP::initBoxGraph()
|
||||
{
|
||||
this->localRoot = new SoSeparator;
|
||||
this->localRoot->ref();
|
||||
this->localRoot->renderCaching = SoSeparator::OFF;
|
||||
this->localRoot->boundingBoxCaching = SoSeparator::OFF;
|
||||
|
||||
this->xform = new SoMatrixTransform;
|
||||
this->cube = new SoCube;
|
||||
|
||||
this->drawstyle = new SoDrawStyle;
|
||||
this->drawstyle->style = SoDrawStyleElement::LINES;
|
||||
this->basecolor = new SoBaseColor;
|
||||
|
||||
SoLightModel * lightmodel = new SoLightModel;
|
||||
lightmodel->model = SoLightModel::BASE_COLOR;
|
||||
|
||||
SoComplexity * complexity = new SoComplexity;
|
||||
complexity->textureQuality = 0.0f;
|
||||
complexity->type = SoComplexityTypeElement::BOUNDING_BOX;
|
||||
|
||||
this->localRoot->addChild(this->drawstyle);
|
||||
this->localRoot->addChild(this->basecolor);
|
||||
|
||||
this->localRoot->addChild(lightmodel);
|
||||
this->localRoot->addChild(complexity);
|
||||
|
||||
this->localRoot->addChild(this->xform);
|
||||
this->localRoot->addChild(this->cube);
|
||||
}
|
||||
|
||||
|
||||
// used to render shape and non-shape nodes (usually SoGroup or SoSeparator).
|
||||
void
|
||||
SoBoxSelectionRenderActionP::updateBbox(const SoPath * path)
|
||||
{
|
||||
if (this->camerasearch == NULL) {
|
||||
this->camerasearch = new SoSearchAction;
|
||||
}
|
||||
|
||||
// find camera used to render node
|
||||
this->camerasearch->setFind(SoSearchAction::TYPE);
|
||||
this->camerasearch->setInterest(SoSearchAction::LAST);
|
||||
this->camerasearch->setType(SoCamera::getClassTypeId());
|
||||
this->camerasearch->apply((SoPath*) path);
|
||||
|
||||
if (!this->camerasearch->getPath()) {
|
||||
// if there is no camera there is no point rendering the bbox
|
||||
return;
|
||||
}
|
||||
this->localRoot->insertChild(this->camerasearch->getPath()->getTail(), 0);
|
||||
this->camerasearch->reset();
|
||||
|
||||
if (this->bboxaction == NULL) {
|
||||
this->bboxaction = new SoGetBoundingBoxAction(SbViewportRegion(100, 100));
|
||||
}
|
||||
this->bboxaction->setViewportRegion(PUBLIC(this)->getViewportRegion());
|
||||
this->bboxaction->apply((SoPath*) path);
|
||||
|
||||
SbXfBox3f & box = this->bboxaction->getXfBoundingBox();
|
||||
|
||||
if (!box.isEmpty()) {
|
||||
// set cube size
|
||||
float x, y, z;
|
||||
box.getSize(x, y, z);
|
||||
this->cube->width = x;
|
||||
this->cube->height = y;
|
||||
this->cube->depth = z;
|
||||
|
||||
SbMatrix transform = box.getTransform();
|
||||
|
||||
// get center (in the local bbox coordinate system)
|
||||
SbVec3f center = box.SbBox3f::getCenter();
|
||||
|
||||
// if center != (0,0,0), move the cube
|
||||
if (center != SbVec3f(0.0f, 0.0f, 0.0f)) {
|
||||
SbMatrix t;
|
||||
t.setTranslate(center);
|
||||
transform.multLeft(t);
|
||||
}
|
||||
this->xform->matrix = transform;
|
||||
|
||||
PUBLIC(this)->SoGLRenderAction::apply(this->localRoot);
|
||||
}
|
||||
// remove camera
|
||||
this->localRoot->removeChild(0);
|
||||
}
|
||||
|
||||
SO_ACTION_SOURCE(SoBoxSelectionRenderAction);
|
||||
|
||||
// Overridden from parent class.
|
||||
void
|
||||
SoBoxSelectionRenderAction::initClass(void)
|
||||
{
|
||||
SO_ACTION_INIT_CLASS(SoBoxSelectionRenderAction, SoGLRenderAction);
|
||||
}
|
||||
|
||||
SoBoxSelectionRenderAction::SoBoxSelectionRenderAction(void)
|
||||
: inherited(SbViewportRegion())
|
||||
{
|
||||
this->constructorCommon();
|
||||
}
|
||||
|
||||
SoBoxSelectionRenderAction::SoBoxSelectionRenderAction(const SbViewportRegion & viewportregion)
|
||||
: inherited(viewportregion)
|
||||
{
|
||||
this->constructorCommon();
|
||||
}
|
||||
|
||||
//
|
||||
// private. called by both constructors
|
||||
//
|
||||
void
|
||||
SoBoxSelectionRenderAction::constructorCommon(void)
|
||||
{
|
||||
SO_ACTION_CONSTRUCTOR(SoBoxSelectionRenderAction);
|
||||
|
||||
PRIVATE(this) = new SoBoxSelectionRenderActionP(this);
|
||||
|
||||
// Initialize local variables
|
||||
PRIVATE(this)->initBoxGraph();
|
||||
|
||||
this->hlVisible = true;
|
||||
|
||||
PRIVATE(this)->basecolor->rgb.setValue(1.0f, 0.0f, 0.0f);
|
||||
PRIVATE(this)->drawstyle->linePattern = 0xffff;
|
||||
PRIVATE(this)->drawstyle->lineWidth = 1.0f;
|
||||
PRIVATE(this)->searchaction = NULL;
|
||||
PRIVATE(this)->selectsearch = NULL;
|
||||
PRIVATE(this)->camerasearch = NULL;
|
||||
PRIVATE(this)->bboxaction = NULL;
|
||||
|
||||
// SoBase-derived objects should be dynamically allocated.
|
||||
PRIVATE(this)->postprocpath = new SoTempPath(32);
|
||||
PRIVATE(this)->postprocpath->ref();
|
||||
PRIVATE(this)->highlightPath = 0;
|
||||
}
|
||||
|
||||
SoBoxSelectionRenderAction::~SoBoxSelectionRenderAction(void)
|
||||
{
|
||||
PRIVATE(this)->postprocpath->unref();
|
||||
PRIVATE(this)->localRoot->unref();
|
||||
|
||||
delete PRIVATE(this)->searchaction;
|
||||
delete PRIVATE(this)->selectsearch;
|
||||
delete PRIVATE(this)->camerasearch;
|
||||
delete PRIVATE(this)->bboxaction;
|
||||
delete PRIVATE(this);
|
||||
}
|
||||
|
||||
void
|
||||
SoBoxSelectionRenderAction::apply(SoNode * node)
|
||||
{
|
||||
SoGLRenderAction::apply(node);
|
||||
if (this->hlVisible) {
|
||||
if (PRIVATE(this)->searchaction == NULL) {
|
||||
PRIVATE(this)->searchaction = new SoSearchAction;
|
||||
}
|
||||
PRIVATE(this)->searchaction->setType(SoFCSelection::getClassTypeId());
|
||||
PRIVATE(this)->searchaction->setInterest(SoSearchAction::ALL);
|
||||
PRIVATE(this)->searchaction->apply(node);
|
||||
const SoPathList & pathlist = PRIVATE(this)->searchaction->getPaths();
|
||||
if (pathlist.getLength() > 0) {
|
||||
for (int i = 0; i < pathlist.getLength(); i++ ) {
|
||||
SoPath * path = pathlist[i];
|
||||
assert(path);
|
||||
SoFCSelection * selection = (SoFCSelection *) path->getTail();
|
||||
assert(selection->getTypeId().isDerivedFrom(SoFCSelection::getClassTypeId()));
|
||||
if (selection->selected.getValue() && selection->style.getValue() == SoFCSelection::BOX) {
|
||||
PRIVATE(this)->basecolor->rgb.setValue(selection->colorSelection.getValue());
|
||||
if (PRIVATE(this)->selectsearch == NULL) {
|
||||
PRIVATE(this)->selectsearch = new SoSearchAction;
|
||||
}
|
||||
PRIVATE(this)->selectsearch->setType(SoShape::getClassTypeId());
|
||||
PRIVATE(this)->selectsearch->setInterest(SoSearchAction::FIRST);
|
||||
PRIVATE(this)->selectsearch->apply(selection);
|
||||
SoPath* shapepath = PRIVATE(this)->selectsearch->getPath();
|
||||
if (shapepath) {
|
||||
SoPathList list;
|
||||
list.append(shapepath);
|
||||
this->drawBoxes(path, &list);
|
||||
}
|
||||
PRIVATE(this)->selectsearch->reset();
|
||||
}
|
||||
else if (selection->isHighlighted() &&
|
||||
selection->selected.getValue() == SoFCSelection::NOTSELECTED &&
|
||||
selection->style.getValue() == SoFCSelection::BOX) {
|
||||
PRIVATE(this)->basecolor->rgb.setValue(selection->colorHighlight.getValue());
|
||||
|
||||
if (PRIVATE(this)->selectsearch == NULL) {
|
||||
PRIVATE(this)->selectsearch = new SoSearchAction;
|
||||
}
|
||||
PRIVATE(this)->selectsearch->setType(SoShape::getClassTypeId());
|
||||
PRIVATE(this)->selectsearch->setInterest(SoSearchAction::FIRST);
|
||||
PRIVATE(this)->selectsearch->apply(selection);
|
||||
SoPath* shapepath = PRIVATE(this)->selectsearch->getPath();
|
||||
if (shapepath) {
|
||||
SoPathList list;
|
||||
list.append(shapepath);
|
||||
PRIVATE(this)->highlightPath = path;
|
||||
PRIVATE(this)->highlightPath->ref();
|
||||
this->drawBoxes(path, &list);
|
||||
}
|
||||
PRIVATE(this)->selectsearch->reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
PRIVATE(this)->searchaction->reset();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SoBoxSelectionRenderAction::apply(SoPath * path)
|
||||
{
|
||||
SoGLRenderAction::apply(path);
|
||||
SoNode* node = path->getTail();
|
||||
if (node && node->getTypeId() == SoFCSelection::getClassTypeId()) {
|
||||
SoFCSelection * selection = (SoFCSelection *) node;
|
||||
|
||||
// This happens when dehighlighting the current shape
|
||||
if (PRIVATE(this)->highlightPath == path) {
|
||||
PRIVATE(this)->highlightPath->unref();
|
||||
PRIVATE(this)->highlightPath = 0;
|
||||
// FIXME: Doing a redraw to remove the shown bounding box causes
|
||||
// some problems when moving the mouse from one shape to another
|
||||
// because this will destroy the box immediately
|
||||
selection->touch(); // force a redraw when dehighlighting
|
||||
}
|
||||
else if (selection->isHighlighted() &&
|
||||
selection->selected.getValue() == SoFCSelection::NOTSELECTED &&
|
||||
selection->style.getValue() == SoFCSelection::BOX) {
|
||||
PRIVATE(this)->basecolor->rgb.setValue(selection->colorHighlight.getValue());
|
||||
|
||||
if (PRIVATE(this)->selectsearch == NULL) {
|
||||
PRIVATE(this)->selectsearch = new SoSearchAction;
|
||||
}
|
||||
PRIVATE(this)->selectsearch->setType(SoShape::getClassTypeId());
|
||||
PRIVATE(this)->selectsearch->setInterest(SoSearchAction::FIRST);
|
||||
PRIVATE(this)->selectsearch->apply(selection);
|
||||
SoPath* shapepath = PRIVATE(this)->selectsearch->getPath();
|
||||
if (shapepath) {
|
||||
SoPathList list;
|
||||
list.append(shapepath);
|
||||
PRIVATE(this)->highlightPath = path;
|
||||
PRIVATE(this)->highlightPath->ref();
|
||||
this->drawBoxes(path, &list);
|
||||
}
|
||||
PRIVATE(this)->selectsearch->reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SoBoxSelectionRenderAction::apply(const SoPathList & pathlist,
|
||||
SbBool obeysrules)
|
||||
{
|
||||
SoGLRenderAction::apply(pathlist, obeysrules);
|
||||
}
|
||||
|
||||
void
|
||||
SoBoxSelectionRenderAction::setColor(const SbColor & color)
|
||||
{
|
||||
PRIVATE(this)->basecolor->rgb = color;
|
||||
}
|
||||
|
||||
const SbColor &
|
||||
SoBoxSelectionRenderAction::getColor(void)
|
||||
{
|
||||
return PRIVATE(this)->basecolor->rgb[0];
|
||||
}
|
||||
|
||||
void
|
||||
SoBoxSelectionRenderAction::setLinePattern(unsigned short pattern)
|
||||
{
|
||||
PRIVATE(this)->drawstyle->linePattern = pattern;
|
||||
}
|
||||
|
||||
unsigned short
|
||||
SoBoxSelectionRenderAction::getLinePattern(void) const
|
||||
{
|
||||
return PRIVATE(this)->drawstyle->linePattern.getValue();
|
||||
}
|
||||
|
||||
void
|
||||
SoBoxSelectionRenderAction::setLineWidth(const float width)
|
||||
{
|
||||
PRIVATE(this)->drawstyle->lineWidth = width;
|
||||
}
|
||||
|
||||
float
|
||||
SoBoxSelectionRenderAction::getLineWidth(void) const
|
||||
{
|
||||
return PRIVATE(this)->drawstyle->lineWidth.getValue();
|
||||
}
|
||||
|
||||
void
|
||||
SoBoxSelectionRenderAction::drawBoxes(SoPath * pathtothis, const SoPathList * pathlist)
|
||||
{
|
||||
int i;
|
||||
int thispos = ((SoFullPath *)pathtothis)->getLength()-1;
|
||||
assert(thispos >= 0);
|
||||
PRIVATE(this)->postprocpath->truncate(0); // reset
|
||||
|
||||
for (i = 0; i < thispos; i++)
|
||||
PRIVATE(this)->postprocpath->append(pathtothis->getNode(i));
|
||||
|
||||
// we need to disable accumulation buffer antialiasing while
|
||||
// rendering selected objects
|
||||
int oldnumpasses = this->getNumPasses();
|
||||
this->setNumPasses(1);
|
||||
|
||||
SoState * thestate = this->getState();
|
||||
thestate->push();
|
||||
|
||||
for (i = 0; i < pathlist->getLength(); i++) {
|
||||
SoFullPath * path = (SoFullPath *)(*pathlist)[i];
|
||||
|
||||
for (int j = 0; j < path->getLength(); j++) {
|
||||
PRIVATE(this)->postprocpath->append(path->getNode(j));
|
||||
}
|
||||
|
||||
// Previously SoGLRenderAction was used to draw the bounding boxes
|
||||
// of shapes in selection paths, by overriding renderstyle state
|
||||
// elements to lines drawstyle and simply doing:
|
||||
//
|
||||
// SoGLRenderAction::apply(PRIVATE(this)->postprocpath); // Bug
|
||||
//
|
||||
// This could have the unwanted side effect of rendering
|
||||
// non-selected shapes, as they could be part of the path (due to
|
||||
// being placed below SoGroup nodes (instead of SoSeparator
|
||||
// nodes)) up to the selected shape.
|
||||
//
|
||||
//
|
||||
// A better approach turned out to be to soup up and draw only the
|
||||
// bounding boxes of the selected shapes:
|
||||
PRIVATE(this)->updateBbox(PRIVATE(this)->postprocpath);
|
||||
|
||||
// Remove temporary path from path buffer
|
||||
PRIVATE(this)->postprocpath->truncate(thispos);
|
||||
}
|
||||
|
||||
this->setNumPasses(oldnumpasses);
|
||||
thestate->pop();
|
||||
}
|
||||
|
||||
|
||||
#undef PRIVATE
|
||||
#undef PUBLIC
|
||||
|
||||
PRIVATE(this)->basecolor->rgb.setValue(1.0f, 0.0f, 0.0f);
|
||||
PRIVATE(this)->drawstyle->linePattern = 0xffff;
|
||||
PRIVATE(this)->drawstyle->lineWidth = 1.0f;
|
||||
PRIVATE(this)->searchaction = NULL;
|
||||
PRIVATE(this)->selectsearch = NULL;
|
||||
PRIVATE(this)->camerasearch = NULL;
|
||||
PRIVATE(this)->bboxaction = NULL;
|
||||
|
||||
// SoBase-derived objects should be dynamically allocated.
|
||||
PRIVATE(this)->postprocpath = new SoTempPath(32);
|
||||
PRIVATE(this)->postprocpath->ref();
|
||||
PRIVATE(this)->highlightPath = 0;
|
||||
}
|
||||
|
||||
SoBoxSelectionRenderAction::~SoBoxSelectionRenderAction(void)
|
||||
{
|
||||
PRIVATE(this)->postprocpath->unref();
|
||||
PRIVATE(this)->localRoot->unref();
|
||||
|
||||
delete PRIVATE(this)->searchaction;
|
||||
delete PRIVATE(this)->selectsearch;
|
||||
delete PRIVATE(this)->camerasearch;
|
||||
delete PRIVATE(this)->bboxaction;
|
||||
delete PRIVATE(this);
|
||||
}
|
||||
|
||||
void
|
||||
SoBoxSelectionRenderAction::apply(SoNode * node)
|
||||
{
|
||||
SoGLRenderAction::apply(node);
|
||||
if (this->hlVisible) {
|
||||
if (PRIVATE(this)->searchaction == NULL) {
|
||||
PRIVATE(this)->searchaction = new SoSearchAction;
|
||||
}
|
||||
PRIVATE(this)->searchaction->setType(SoFCSelection::getClassTypeId());
|
||||
PRIVATE(this)->searchaction->setInterest(SoSearchAction::ALL);
|
||||
PRIVATE(this)->searchaction->apply(node);
|
||||
const SoPathList & pathlist = PRIVATE(this)->searchaction->getPaths();
|
||||
if (pathlist.getLength() > 0) {
|
||||
for (int i = 0; i < pathlist.getLength(); i++ ) {
|
||||
SoPath * path = pathlist[i];
|
||||
assert(path);
|
||||
SoFCSelection * selection = (SoFCSelection *) path->getTail();
|
||||
assert(selection->getTypeId().isDerivedFrom(SoFCSelection::getClassTypeId()));
|
||||
if (selection->selected.getValue() && selection->style.getValue() == SoFCSelection::BOX) {
|
||||
PRIVATE(this)->basecolor->rgb.setValue(selection->colorSelection.getValue());
|
||||
if (PRIVATE(this)->selectsearch == NULL) {
|
||||
PRIVATE(this)->selectsearch = new SoSearchAction;
|
||||
}
|
||||
PRIVATE(this)->selectsearch->setType(SoShape::getClassTypeId());
|
||||
PRIVATE(this)->selectsearch->setInterest(SoSearchAction::FIRST);
|
||||
PRIVATE(this)->selectsearch->apply(selection);
|
||||
SoPath* shapepath = PRIVATE(this)->selectsearch->getPath();
|
||||
if (shapepath) {
|
||||
SoPathList list;
|
||||
list.append(shapepath);
|
||||
this->drawBoxes(path, &list);
|
||||
}
|
||||
PRIVATE(this)->selectsearch->reset();
|
||||
}
|
||||
else if (selection->isHighlighted() &&
|
||||
selection->selected.getValue() == SoFCSelection::NOTSELECTED &&
|
||||
selection->style.getValue() == SoFCSelection::BOX) {
|
||||
PRIVATE(this)->basecolor->rgb.setValue(selection->colorHighlight.getValue());
|
||||
|
||||
if (PRIVATE(this)->selectsearch == NULL) {
|
||||
PRIVATE(this)->selectsearch = new SoSearchAction;
|
||||
}
|
||||
PRIVATE(this)->selectsearch->setType(SoShape::getClassTypeId());
|
||||
PRIVATE(this)->selectsearch->setInterest(SoSearchAction::FIRST);
|
||||
PRIVATE(this)->selectsearch->apply(selection);
|
||||
SoPath* shapepath = PRIVATE(this)->selectsearch->getPath();
|
||||
if (shapepath) {
|
||||
SoPathList list;
|
||||
list.append(shapepath);
|
||||
PRIVATE(this)->highlightPath = path;
|
||||
PRIVATE(this)->highlightPath->ref();
|
||||
this->drawBoxes(path, &list);
|
||||
}
|
||||
PRIVATE(this)->selectsearch->reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
PRIVATE(this)->searchaction->reset();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SoBoxSelectionRenderAction::apply(SoPath * path)
|
||||
{
|
||||
SoGLRenderAction::apply(path);
|
||||
SoNode* node = path->getTail();
|
||||
if (node && node->getTypeId() == SoFCSelection::getClassTypeId()) {
|
||||
SoFCSelection * selection = (SoFCSelection *) node;
|
||||
|
||||
// This happens when dehighlighting the current shape
|
||||
if (PRIVATE(this)->highlightPath == path) {
|
||||
PRIVATE(this)->highlightPath->unref();
|
||||
PRIVATE(this)->highlightPath = 0;
|
||||
// FIXME: Doing a redraw to remove the shown bounding box causes
|
||||
// some problems when moving the mouse from one shape to another
|
||||
// because this will destroy the box immediately
|
||||
selection->touch(); // force a redraw when dehighlighting
|
||||
}
|
||||
else if (selection->isHighlighted() &&
|
||||
selection->selected.getValue() == SoFCSelection::NOTSELECTED &&
|
||||
selection->style.getValue() == SoFCSelection::BOX) {
|
||||
PRIVATE(this)->basecolor->rgb.setValue(selection->colorHighlight.getValue());
|
||||
|
||||
if (PRIVATE(this)->selectsearch == NULL) {
|
||||
PRIVATE(this)->selectsearch = new SoSearchAction;
|
||||
}
|
||||
PRIVATE(this)->selectsearch->setType(SoShape::getClassTypeId());
|
||||
PRIVATE(this)->selectsearch->setInterest(SoSearchAction::FIRST);
|
||||
PRIVATE(this)->selectsearch->apply(selection);
|
||||
SoPath* shapepath = PRIVATE(this)->selectsearch->getPath();
|
||||
if (shapepath) {
|
||||
SoPathList list;
|
||||
list.append(shapepath);
|
||||
PRIVATE(this)->highlightPath = path;
|
||||
PRIVATE(this)->highlightPath->ref();
|
||||
this->drawBoxes(path, &list);
|
||||
}
|
||||
PRIVATE(this)->selectsearch->reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SoBoxSelectionRenderAction::apply(const SoPathList & pathlist,
|
||||
SbBool obeysrules)
|
||||
{
|
||||
SoGLRenderAction::apply(pathlist, obeysrules);
|
||||
}
|
||||
|
||||
void
|
||||
SoBoxSelectionRenderAction::setColor(const SbColor & color)
|
||||
{
|
||||
PRIVATE(this)->basecolor->rgb = color;
|
||||
}
|
||||
|
||||
const SbColor &
|
||||
SoBoxSelectionRenderAction::getColor(void)
|
||||
{
|
||||
return PRIVATE(this)->basecolor->rgb[0];
|
||||
}
|
||||
|
||||
void
|
||||
SoBoxSelectionRenderAction::setLinePattern(unsigned short pattern)
|
||||
{
|
||||
PRIVATE(this)->drawstyle->linePattern = pattern;
|
||||
}
|
||||
|
||||
unsigned short
|
||||
SoBoxSelectionRenderAction::getLinePattern(void) const
|
||||
{
|
||||
return PRIVATE(this)->drawstyle->linePattern.getValue();
|
||||
}
|
||||
|
||||
void
|
||||
SoBoxSelectionRenderAction::setLineWidth(const float width)
|
||||
{
|
||||
PRIVATE(this)->drawstyle->lineWidth = width;
|
||||
}
|
||||
|
||||
float
|
||||
SoBoxSelectionRenderAction::getLineWidth(void) const
|
||||
{
|
||||
return PRIVATE(this)->drawstyle->lineWidth.getValue();
|
||||
}
|
||||
|
||||
void
|
||||
SoBoxSelectionRenderAction::drawBoxes(SoPath * pathtothis, const SoPathList * pathlist)
|
||||
{
|
||||
int i;
|
||||
int thispos = ((SoFullPath *)pathtothis)->getLength()-1;
|
||||
assert(thispos >= 0);
|
||||
PRIVATE(this)->postprocpath->truncate(0); // reset
|
||||
|
||||
for (i = 0; i < thispos; i++)
|
||||
PRIVATE(this)->postprocpath->append(pathtothis->getNode(i));
|
||||
|
||||
// we need to disable accumulation buffer antialiasing while
|
||||
// rendering selected objects
|
||||
int oldnumpasses = this->getNumPasses();
|
||||
this->setNumPasses(1);
|
||||
|
||||
SoState * thestate = this->getState();
|
||||
thestate->push();
|
||||
|
||||
for (i = 0; i < pathlist->getLength(); i++) {
|
||||
SoFullPath * path = (SoFullPath *)(*pathlist)[i];
|
||||
|
||||
for (int j = 0; j < path->getLength(); j++) {
|
||||
PRIVATE(this)->postprocpath->append(path->getNode(j));
|
||||
}
|
||||
|
||||
// Previously SoGLRenderAction was used to draw the bounding boxes
|
||||
// of shapes in selection paths, by overriding renderstyle state
|
||||
// elements to lines drawstyle and simply doing:
|
||||
//
|
||||
// SoGLRenderAction::apply(PRIVATE(this)->postprocpath); // Bug
|
||||
//
|
||||
// This could have the unwanted side effect of rendering
|
||||
// non-selected shapes, as they could be part of the path (due to
|
||||
// being placed below SoGroup nodes (instead of SoSeparator
|
||||
// nodes)) up to the selected shape.
|
||||
//
|
||||
//
|
||||
// A better approach turned out to be to soup up and draw only the
|
||||
// bounding boxes of the selected shapes:
|
||||
PRIVATE(this)->updateBbox(PRIVATE(this)->postprocpath);
|
||||
|
||||
// Remove temporary path from path buffer
|
||||
PRIVATE(this)->postprocpath->truncate(thispos);
|
||||
}
|
||||
|
||||
this->setNumPasses(oldnumpasses);
|
||||
thestate->pop();
|
||||
}
|
||||
|
||||
|
||||
#undef PRIVATE
|
||||
#undef PUBLIC
|
||||
|
|
|
@ -57,7 +57,9 @@ class SoVectorizePoint : public SoVectorizeItem {
|
|||
public:
|
||||
SoVectorizePoint(void) {
|
||||
this->type = POINT;
|
||||
this->vidx = 0;
|
||||
this->size = 1.0f;
|
||||
this->col = 0;
|
||||
}
|
||||
int vidx; // index to BSPtree coordinate
|
||||
float size; // Coin size (pixels)
|
||||
|
@ -90,6 +92,9 @@ class SoVectorizeText : public SoVectorizeItem {
|
|||
public:
|
||||
SoVectorizeText(void) {
|
||||
this->type = TEXT;
|
||||
this->fontsize = 10;
|
||||
this->col = 0;
|
||||
this->justification = LEFT;
|
||||
}
|
||||
|
||||
enum Justification {
|
||||
|
|
|
@ -58,7 +58,9 @@ class SoVectorizePoint : public SoVectorizeItem {
|
|||
public:
|
||||
SoVectorizePoint(void) {
|
||||
this->type = POINT;
|
||||
this->vidx = 0;
|
||||
this->size = 1.0f;
|
||||
this->col = 0;
|
||||
}
|
||||
int vidx; // index to BSPtree coordinate
|
||||
float size; // Coin size (pixels)
|
||||
|
@ -91,6 +93,9 @@ class SoVectorizeText : public SoVectorizeItem {
|
|||
public:
|
||||
SoVectorizeText(void) {
|
||||
this->type = TEXT;
|
||||
this->fontsize = 10;
|
||||
this->col = 0;
|
||||
this->justification = LEFT;
|
||||
}
|
||||
|
||||
enum Justification {
|
||||
|
|
|
@ -111,24 +111,24 @@ SoGestureSwipeEvent::SoGestureSwipeEvent(QSwipeGesture *qwsipe, QWidget *widget)
|
|||
switch (qwsipe->verticalDirection()){
|
||||
case QSwipeGesture::Up :
|
||||
vertDir = +1;
|
||||
break;
|
||||
break;
|
||||
case QSwipeGesture::Down :
|
||||
vertDir = -1;
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
vertDir = 0;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
switch (qwsipe->horizontalDirection()){
|
||||
case QSwipeGesture::Right :
|
||||
vertDir = +1;
|
||||
break;
|
||||
horzDir = +1;
|
||||
break;
|
||||
case QSwipeGesture::Left :
|
||||
vertDir = -1;
|
||||
break;
|
||||
horzDir = -1;
|
||||
break;
|
||||
default:
|
||||
vertDir = 0;
|
||||
break;
|
||||
horzDir = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
state = SbGestureState(qwsipe->state());
|
||||
|
|
|
@ -39,9 +39,9 @@ class SoGestureEvent : public SoEvent {
|
|||
public:
|
||||
static void initClass(){
|
||||
SO_EVENT_INIT_CLASS(SoGestureEvent, SoEvent);
|
||||
};
|
||||
SoGestureEvent(){};
|
||||
~SoGestureEvent(){};
|
||||
}
|
||||
SoGestureEvent() : state(SbGSNoGesture) {}
|
||||
~SoGestureEvent(){}
|
||||
SbBool isSoGestureEvent(const SoEvent* ev) const;
|
||||
|
||||
enum SbGestureState {
|
||||
|
@ -59,10 +59,10 @@ class SoGesturePanEvent : public SoGestureEvent {
|
|||
public:
|
||||
static void initClass(){//needs to be called before the class can be used. Initializes type IDs of the class.
|
||||
SO_EVENT_INIT_CLASS(SoGesturePanEvent, SoGestureEvent);
|
||||
};
|
||||
SoGesturePanEvent() {};
|
||||
}
|
||||
SoGesturePanEvent() {}
|
||||
SoGesturePanEvent(QPanGesture *qpan, QWidget *widget);
|
||||
~SoGesturePanEvent(){};
|
||||
~SoGesturePanEvent(){}
|
||||
SbBool isSoGesturePanEvent(const SoEvent* ev) const;
|
||||
|
||||
SbVec2f deltaOffset;
|
||||
|
@ -74,10 +74,13 @@ class SoGesturePinchEvent : public SoGestureEvent {
|
|||
public:
|
||||
static void initClass(){
|
||||
SO_EVENT_INIT_CLASS(SoGesturePinchEvent, SoGestureEvent);
|
||||
};
|
||||
SoGesturePinchEvent(){};
|
||||
}
|
||||
SoGesturePinchEvent() : deltaZoom(0), totalZoom(0),
|
||||
deltaAngle(0), totalAngle(0)
|
||||
{
|
||||
}
|
||||
SoGesturePinchEvent(QPinchGesture* qpinch, QWidget* widget);
|
||||
~SoGesturePinchEvent(){};
|
||||
~SoGesturePinchEvent(){}
|
||||
SbBool isSoGesturePinchEvent(const SoEvent* ev) const;
|
||||
|
||||
SbVec2f startCenter;//in GL pixel coordinates (from bottom left corner of view area)
|
||||
|
@ -95,10 +98,12 @@ class SoGestureSwipeEvent : public SoGestureEvent {
|
|||
public:
|
||||
static void initClass(){
|
||||
SO_EVENT_INIT_CLASS(SoGestureSwipeEvent, SoGestureEvent);
|
||||
};
|
||||
SoGestureSwipeEvent(){};
|
||||
}
|
||||
SoGestureSwipeEvent() : angle(0), vertDir(0), horzDir(0)
|
||||
{
|
||||
}
|
||||
SoGestureSwipeEvent(QSwipeGesture* qwsipe, QWidget *widget);
|
||||
~SoGestureSwipeEvent(){};
|
||||
~SoGestureSwipeEvent(){}
|
||||
SbBool isSoGestureSwipeEvent(const SoEvent* ev) const;
|
||||
|
||||
double angle;
|
||||
|
|
|
@ -35,7 +35,7 @@ EventBase::EventBase(QEvent::Type event) : QInputEvent(static_cast<QEvent::Type>
|
|||
}
|
||||
|
||||
MotionEvent::MotionEvent() : EventBase(static_cast<QEvent::Type>(MotionEventType)),
|
||||
xTrans(0), yTrans(0), zTrans(0), xRot(0), yRot(0), zRot(0)
|
||||
xTrans(0), yTrans(0), zTrans(0), xRot(0), yRot(0), zRot(0), handled(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -69,6 +69,7 @@ TaskSelectLinkProperty::TaskSelectLinkProperty(const char *sFilter,App::Property
|
|||
|
||||
// property have to be set!
|
||||
assert(prop);
|
||||
StartObject = 0;
|
||||
if (prop->getTypeId().isDerivedFrom(App::PropertyLinkSub::getClassTypeId())) {
|
||||
LinkSub = dynamic_cast<App::PropertyLinkSub *>(prop);
|
||||
}
|
||||
|
|
|
@ -86,20 +86,22 @@ TaskWatcherCommands::TaskWatcherCommands(const char* Filter,const char* commands
|
|||
const char* name, const char* pixmap)
|
||||
: TaskWatcher(Filter)
|
||||
{
|
||||
CommandManager &mgr = Gui::Application::Instance->commandManager();
|
||||
Gui::TaskView::TaskBox *tb = new Gui::TaskView::TaskBox
|
||||
(BitmapFactory().pixmap(pixmap), trUtf8(name), true, 0);
|
||||
if (commands) {
|
||||
CommandManager &mgr = Gui::Application::Instance->commandManager();
|
||||
Gui::TaskView::TaskBox *tb = new Gui::TaskView::TaskBox
|
||||
(BitmapFactory().pixmap(pixmap), trUtf8(name), true, 0);
|
||||
|
||||
for (const char** i=commands;*i;i++) {
|
||||
if(!i) break;
|
||||
Command *c = mgr.getCommandByName(*i);
|
||||
if (c) {
|
||||
// handled in TaskBox::actionEvent()
|
||||
c->addTo(tb);
|
||||
for (const char** i=commands;*i;i++) {
|
||||
if(!i) break;
|
||||
Command *c = mgr.getCommandByName(*i);
|
||||
if (c) {
|
||||
// handled in TaskBox::actionEvent()
|
||||
c->addTo(tb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Content.push_back(tb);
|
||||
Content.push_back(tb);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ using namespace Gui;
|
|||
* Constructs a TextEdit which is a child of 'parent'.
|
||||
*/
|
||||
TextEdit::TextEdit(QWidget* parent)
|
||||
: QPlainTextEdit(parent), listBox(0)
|
||||
: QPlainTextEdit(parent), cursorPosition(0), listBox(0)
|
||||
{
|
||||
//Note: Set the correct context to this shortcut as we may use several instances of this
|
||||
//class at a time
|
||||
|
|
|
@ -62,7 +62,7 @@ const int TreeWidget::ObjectType = 1001;
|
|||
|
||||
/* TRANSLATOR Gui::TreeWidget */
|
||||
TreeWidget::TreeWidget(QWidget* parent)
|
||||
: QTreeWidget(parent), fromOutside(false)
|
||||
: QTreeWidget(parent), contextItem(0), fromOutside(false)
|
||||
{
|
||||
this->setDragEnabled(true);
|
||||
this->setAcceptDrops(true);
|
||||
|
|
|
@ -248,11 +248,8 @@ Py::Object View3DInventorViewerPy::seekToPoint(const Py::Tuple& args)
|
|||
catch (const Py::Exception&) {
|
||||
throw;
|
||||
}
|
||||
|
||||
return Py::None();
|
||||
}
|
||||
|
||||
|
||||
Py::Object View3DInventorViewerPy::setFocalDistance(const Py::Tuple& args)
|
||||
{
|
||||
float distance;
|
||||
|
|
Loading…
Reference in New Issue
Block a user