/*Title: mjbWorld
Copyright (c) 1998-2005 Martin John Baker
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program 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 General Public License for more details.
For information about the GNU General Public License see http://www.gnu.org/
To discuss this program http://sourceforge.net/forum/forum.php?forum_id=122133
also see website http://www.euclideanspace.com/
translated to C++ by Ed Sinjiashvili (slorcim@sf.net)
*/
#include <qobjectlist.h>
#include "transformGroupBean.h"
#include "vetoPropertyChange.h"
#include "d_button.h"
#include "sfvec3f.h"
#include "mfint32.h"
#include "mfvec3f.h"
#include "sfrotation.h"
#include "mfparam.h"
#include "sfvec3fEditor.h"
#include "sfrotationEditor.h"
#include "sftransform.h"
#include "sceneBean.h"
#include "sftransformEditor.h"
#include "behaviorBean.h"
namespace mjbModel
{
int transformGroupBean::TOOL_CONVERTTOJOINT = 1;
QString transformGroupBean::PAR_ROTATION = "rotation";
QString transformGroupBean::PAR_CENTRE = "center";
QString transformGroupBean::PAR_SCALE = "scale";
QString transformGroupBean::PAR_SCALEORIENTATION = "scaleOrientation";
QString transformGroupBean::PAR_TRANSLATION = "translation";
QString transformGroupBean::PAR_TRANSFORM = "transform";
QString transformGroupBean::PAR_MATRIX = "matrix";
sfvec3f& transformGroupBean::defaultCenter()
{
static sfvec3f d(0.0, 0.0, 0.0);
return d;
}
sfrotation& transformGroupBean::defaultRotation()
{
static sfrotation d(0,0,1,0.0);
return d;
}
sfvec3f& transformGroupBean::defaultScale()
{
static sfvec3f d(1.0,1.0,1.0);
return d;
}
sfrotation& transformGroupBean::defaultScaleOrientation()
{
static sfrotation d(0,0,1,0.0);
return d;
}
sfvec3f& transformGroupBean::defaultTranslation()
{
static sfvec3f d(0.0,0.0,0.0);
return d;
}
transformGroupBean::~transformGroupBean ()
{
delete vetos;
}
transformGroupBean::transformGroupBean ()
: groupBean (),
matrix (0), matrix1 (0), matrix2 (0),
matrix3 (0), matrix4 (0),
top (0), bottom (0), mult (0)
{
vetos = new vetoPropertyChange;
// sets up children params
params_->insert(new sfparam(sfparam::EXPOSEDFIELD,
sfvec3f::Factory (),
PAR_CENTRE, &defaultCenter()));
params_->insert(new sfparam(sfparam::EXPOSEDFIELD,
sfrotation::Factory (),
PAR_ROTATION,&defaultRotation()));
params_->insert(new sfparam(sfparam::EXPOSEDFIELD,
sfvec3f::Factory (),
PAR_SCALE, &defaultScale()));
params_->insert(new sfparam(sfparam::EXPOSEDFIELD,
sfrotation::Factory (),
PAR_SCALEORIENTATION, &defaultScaleOrientation()));
params_->insert(new sfparam(sfparam::EXPOSEDFIELD,
sfvec3f::Factory (),
PAR_TRANSLATION, &defaultTranslation()));
applyTemp = false;
}
void transformGroupBean::setDefaultTranslation(sfvec3f* /*d*/)
{
sfparam* par = params_->findSFParam(PAR_TRANSLATION);
par->setDefault(new sfvec3f(1000.0,1000.0,1000.0));
}
void transformGroupBean::setTrans(sfvec3f* shift, mfint32* instance)
{
set(PAR_TRANSLATION,shift,instance);
//Console.WriteLine("transformGroupBean::setTranslation("+shift+","+instance+")");
int inst =0;
if (instance!=0)
if(instance->howmany()>0) inst=instance->getLastValue();
setMatrix(calcTransform(inst, 0, 0, 0, 0, 0),inst);
// Console.WriteLine("tranformGroupBean::setTranslation("+instance+") veto " + pve->getPropertyChangeEvent());
}
void transformGroupBean::setTranslationAndRotation(sfparam* shift, sfparam* rot,
nodeBean* /*callback*/)
{
//Console.WriteLine("transformgroupBean.setTranslationAndRotation("+shift+","+callback.generateUniqueName()+") this="+generateUniqueName());
if (shift!=0)
{
sfparam* par = params_->findSFParam(PAR_TRANSLATION);
vector<mjbModel::Property*>* vecs = shift->getArray();
par->setArray(vecs);
if (vecs==0)
{
// if array is 0
// FIXME: try/catch
// try {
//Console.WriteLine("transformgroupBean.setTranslation("+shift+") vecs==0");
vetos->fireVetoableChange(PAR_TRANSLATION,0,shift); // if translation==shift veto is not fired
/*
} catch (ConstraintException pve){
if (callback is kinematicsBean) {
((kinematicsBean)callback).veto(0,pve.Message);
}
}
*/
}
else
{
// if array is not 0
//Console.WriteLine("transformgroupBean.setTranslation("+shift+") vecs!=0 this="+generateUniqueName());
// int[] instance = new int[1];
for (int i=0;i < (int)vecs->size ();i++)
{
// instance[0]=i;
//Console.WriteLine(" >transformgroupBean.setTranslation("+shift+") i="+i+" this="+generateUniqueName());
setMatrix(calcTransform(i,0,0,0,0,0),i); // setMatrix updates Java3D scenegraph
if ( (*vecs)[i] !=0)
{
// FIXME: try/catch
// try {
//Console.WriteLine("transformgroupBean.setTranslation vecs["+i+"]"+vecs[i]);
vetos->fireVetoableChange(PAR_TRANSLATION,0, (*vecs)[i]); // if translation==shift veto is not fired
//Console.WriteLine("transformgroupBean.setTranslation veto not fired");
/*
} catch (ConstraintException pve){
//Console.WriteLine("transformgroupBean.setTranslation veto fired");
if (callback is kinematicsBean) {
((kinematicsBean)callback).veto(i,pve.Message);
}
}
*/
}
}
}
}
if (rot!=0)
{
vector<mjbModel::Property*>* vecs = rot->getArray();
sfparam* par2 = params_->findSFParam(PAR_ROTATION);
par2->setArray(vecs);
if (vecs==0)
{
// FIXME: try/catch
// try {
//Console.WriteLine("transformgroupBean.setRotation("+shift+") vecs==0");
vetos->fireVetoableChange(PAR_ROTATION,0,rot); // if translation==shift veto is not fired
/*
} catch (ConstraintException pve){
if (callback is kinematicsBean) {
((kinematicsBean)callback).veto(0,pve.Message);
}
}
*/
}
fanxbl957
- 粉丝: 2926
- 资源: 1188
最新资源
- 基于springboot的私人健身与教练预约管理系统源码(java毕业设计完整源码+LW).zip
- 基于springboot的校园在线拍卖系统源码(java毕业设计完整源码).zip
- 基于PCA主成分分析的BP神经网络回归预测MATLAB代码 代码注释清楚 先对数据集进行主成分分析,自主根据贡献率选择主成分;同时计算KMO验证值;用PCA以后数据进行BP神经网络回归预测
- meilisearch linux x64
- 基于springboot的学生成绩管理系统源码(java毕业设计完整源码+LW).zip
- 粒子群算法PSO优化随机森林RFR的回归预测MATLAB代码 代码注释清楚,可以读取EXCEL数据,使用自己数据集 很方便,初学者容易上手
- 基于springboot的医院信管系统源码(java毕业设计完整源码+LW).zip
- Python入门基础知识与学习方法指南
- 数据库课设项目(基于若依的实体店销售系统项目)
- 信息系统应用安全第5部分-代码安全检测
- 玩转V90扭矩控制功能 102105报文怎样降低扭矩限制.mp4
- 双馈风机风电场经串补并网次同步振荡 谐振仿真模型,附参考文献 DFIG-SSO SSR simulink仿真 包含模型中红体字提到的参考文献 可运行,振荡程度可自调,运行结果很理想 可选择ma
- 最短工期问题及其解决方法
- Microsoft Teams 应用场景概览.pdf
- osg3.6.5,osgEarth3.2 ,MSVC2017,纯qt实现加载osg模型至qt软件界面
- Phase-Shift-T:基于MATLAB Simulink的移相变压器仿真模型,可实现-25°、-15°……25°的移相 变压器副边实现36脉波不控整流,变压器网侧电压、阈侧电压以及移相角度可直
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈