-/***************************************************************************
-** Class: GLViewer_Object
-** Descr: OpenGL Object
-** Module: GLViewer
-** Created: UI team, 03.09.02
-****************************************************************************/
-
-//#include <GLViewerAfx.h>
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
#include "GLViewer_Object.h"
#include "GLViewer_Drawer.h"
#include "GLViewer_AspectLine.h"
-#include "GLViewer_Geom.h"
#include "GLViewer_Text.h"
#include "GLViewer_Group.h"
-//#include <cmath>
-//using namespace std;
+#include <SUIT_DataOwner.h>
+/*!
+ Default constructor
+*/
GLViewer_Object::GLViewer_Object()
{
myXScale = 1.0;
myGroup = NULL;
}
+/*!
+ Destructor
+*/
GLViewer_Object::~GLViewer_Object()
{
if( myRect )
delete myAspectLine;
}
+/*!
+ \return priority of object
+*/
int GLViewer_Object::getPriority() const
{
return myDrawer ? myDrawer->getPriority() : 0;
}
+/*!
+ \return true if object is inside rectangle
+ \param theRect - rectangle
+*/
GLboolean GLViewer_Object::isInside( GLViewer_Rect theRect )
{
return theRect.toQRect().contains( myRect->toQRect() );
}
+/*!
+ Sets zoom factor
+ \param zoom - zoom factor
+*/
GLboolean GLViewer_Object::setZoom( GLfloat zoom, bool, bool )
{
if( myZoom == zoom )
return GL_TRUE;
}
+/*!
+ Performs zoom change by step
+ \param zoomIn - to increase to decrease zoom
+*/
GLboolean GLViewer_Object::updateZoom( bool zoomIn )
{
float newZoom;
return setZoom( newZoom, true );
}
+/*!
+ Codes object as byte copy
+ \return byte array
+*/
QByteArray GLViewer_Object::getByteCopy()
{
int i = 0;
int anISize = sizeof( int );
- const char* aTypeStr = myType.data();
- const char* aToolTipStr = myToolTipText.data();
+ const char* aTypeStr = myType.toLatin1().constData();
+ const char* aToolTipStr = myToolTipText.toUtf8().constData();
int aTypeLength = myType.length();
int aToolTipLength = myToolTipText.length();
int sizeOf8Float = sizeof( aRectData );
- QByteArray aResult( 2*anISize + sizeOf8Float +
- aTypeLength + aToolTipLength +
- aGLText.size() + aAspect.size() );
+ QByteArray aResult;
+ aResult.resize( 2*anISize + sizeOf8Float +
+ aTypeLength + aToolTipLength +
+ aGLText.size() + aAspect.size() );
// puts 8 float values into the byte array
char* aPointer = (char*)&aRectData;
for( i = 0; i < sizeOf8Float; i++, aPointer++ )
int aCurPos = 2*anISize + sizeOf8Float + aTypeLength + aToolTipLength;
// adds aspect byte array
- for( i = aCurPos; i < aCurPos + aAspect.size(); i++ )
+ for ( i = aCurPos; i < (int)( aCurPos + aAspect.size() ); i++ )
aResult[i] = aAspect[i - aCurPos];
aCurPos = aCurPos + aAspect.size();
// adds GL text byte array
- for( i = aCurPos; i < aCurPos + aGLText.size(); i++ )
+ for ( i = aCurPos; i < (int)( aCurPos + aGLText.size() ); i++ )
aResult[i] = aGLText[i - aCurPos];
aCurPos += aGLText.size();
aPointer = (char*)&myOwner;
- for( i = 0; i < sizeof( GLViewer_Owner* ); i++, aPointer++ )
+ for( i = 0; i < sizeof( SUIT_DataOwner* ); i++, aPointer++ )
aResult[ aCurPos + i ] = *aPointer;
return aResult;
}
+/*!
+ Initialize object by byte array
+ \param theArray - byte array
+*/
bool GLViewer_Object::initializeFromByteCopy( QByteArray theArray )
{
int i = 0;
GLViewer_AspectLine* aAspectLine = new GLViewer_AspectLine();
int aGLAspLineSize = (aAspectLine->getByteCopy()).size();
- QByteArray aGLTextArray, aAspect( aGLAspLineSize );
+ QByteArray aGLTextArray, aAspect;
+ aGLTextArray.resize( aGLAspLineSize );
+ aAspect.resize( aGLAspLineSize );
if( aSize < 2*anISize + 8*aFSize + aGLTextMinSize + aGLAspLineSize )
return false;
return true;
}
+/*!
+ Sets object's group
+ \param theGroup - group
+*/
void GLViewer_Object::setGroup( GLViewer_Group* theGroup )
{
+ if ( myGroup == theGroup )
+ return;
+
if( myGroup )
myGroup->removeObject( this );
myGroup->addObject( this );
}
+/*!
+ \return object's group
+*/
GLViewer_Group* GLViewer_Object::getGroup() const
{
return myGroup;