blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 5
146
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
7
| license_type
stringclasses 2
values | repo_name
stringlengths 6
79
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 4
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.07k
426M
⌀ | star_events_count
int64 0
27
| fork_events_count
int64 0
12
| gha_license_id
stringclasses 3
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 6
values | src_encoding
stringclasses 26
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 1
class | length_bytes
int64 20
6.28M
| extension
stringclasses 20
values | content
stringlengths 20
6.28M
| authors
listlengths 1
16
| author_lines
listlengths 1
16
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
61f6ac7ded7b865ba9630af456f8f2872edb4aaf
|
814b49df11675ac3664ac0198048961b5306e1c5
|
/Code/Engine/PhysX/include/PhysicActor.h
|
ed7aed0a832902bc3dc65b7fa457ee3882b61ccf
|
[] |
no_license
|
Atridas/biogame
|
f6cb24d0c0b208316990e5bb0b52ef3fb8e83042
|
3b8e95b215da4d51ab856b4701c12e077cbd2587
|
refs/heads/master
| 2021-01-13T00:55:50.502395 | 2011-10-31T12:58:53 | 2011-10-31T12:58:53 | 43,897,729 | 0 | 0 | null | null | null | null |
ISO-8859-1
|
C++
| false | false | 4,522 |
h
|
//----------------------------------------------------------------------------------
// CPhysicActor class
// Author: Enric Vergara
//
// Description:
// Esta clase representa un actor físico.
//----------------------------------------------------------------------------------
#pragma once
#ifndef INC_PHYSIC_ACTOR_H_
#define INC_PHYSIC_ACTOR_H_
#include <vector>
#include "base.h"
//---Forward Declarations---
class NxActor;
class NxActorDesc;
class NxBodyDesc;
class NxCCDSkeleton;
class NxTriangleMesh;
class NxBoxShapeDesc;
class NxBoxShapeDesc;
class NxTriangleMeshShapeDesc;
class NxCapsuleShapeDesc;
class NxSphereShapeDesc;
class NxPlaneShapeDesc;
class CPhysicUserData;
enum NxForceMode;
//--------------------------
class CPhysicActor
{
public:
CPhysicActor::CPhysicActor(CPhysicUserData* userData);
CPhysicActor::~CPhysicActor();
CPhysicUserData* GetUserData () {return m_pUserData;}
void SetLinearVelocity (const Vect3f& velocity);
Vect3f GetPosition ();
Vect3f GetRotation ();
void CreateBody (float density, float angularDamping = 0.5f, float linearDamping = 0.5f);
void SetGlobalPosition (const Vect3f& pos = Vect3f(0.f,0.f,0.f));
void MoveGlobalPosition (const Vect3f& pos);
void SetRotation (const Vect3f& _vRot);
void SetRotation (const Mat33f& _vRot);
Vect3f GetLinearVelocity();
Vect3f GetAngularVelocity();
Vect3f GetAngularMomentum();
Mat33f GetInertiaTensor();
void AddImpulseAtPos(const Vect3f& _vDirection, const Vect3f& _vPos, float _fPower, bool _bLocal = true);
void AddVelocityAtPos(const Vect3f& _vDirection, const Vect3f& _vPos, float _fPower, bool _bLocal = true);
void AddAcelerationAtPos(const Vect3f& _vDirection, const Vect3f& _vPos, float _fPower, bool _bLocal = true);
void AddForceAtPos(const Vect3f& _vDirection, const Vect3f& _vPos, float _fPower, bool _bLocal = true);
void AddTorque(const Vect3f _vTorque);
void SetAngularVelocity(const Vect3f _vVelocity);
//---AddShape Functions-----
void AddSphereShape (float radius, const Vect3f& globalPos = v3fZERO, const Vect3f& localPos = v3fZERO, NxCCDSkeleton* skeleton = 0, uint32 group = 0);
void AddBoxSphape (const Vect3f& size, const Vect3f& globalPos = v3fZERO, const Vect3f& localPos = v3fZERO, NxCCDSkeleton* skeleton = 0, uint32 group = 0);
void AddCapsuleShape (float radius, float height, const Vect3f& globalPos = v3fZERO, const Vect3f& localPos = v3fZERO, NxCCDSkeleton* skeleton = 0, uint32 group = 0);
void AddMeshShape (NxTriangleMesh* mesh, const Vect3f& globalPos = v3fZERO, const Vect3f& localPos = v3fZERO, NxCCDSkeleton* skeleton = 0, uint32 group = 0);
void AddPlaneShape (const Vect3f& normal, float distance, uint32 group = 0);
//---Trigger Function---
void CreateBoxTrigger (const Vect3f& globalPos, const Vect3f& size, uint32 group = 0);
void ActivateAllTriggers();
//---Activate---
void Activate (bool _bActivate);
void SetKinematic (bool _bValue);
//---Get Info-------
void GetMat44 (Mat44f& matrix) const;
void SetMat44 (const Mat44f& matrix);
void MoveGlobalPoseMat44 (const Mat44f& matrix);
//---Get PhsX Info---
void CreateActor (NxActor* actor);
NxActor* GetPhXActor () {return m_pPhXActor;}
NxActorDesc* GetActorDesc () {return m_pPhXActorDesc;}
void SetActorSolverIterationCount(int _iCount);
void SetContactReportFlags(unsigned int _uiFlags);
void SetContactReportThreshold(float _fThreshold);
private:
void DeInit ();
private:
void AddForceAtPos(const Vect3f& _vDirection, const Vect3f& _vPos, float _fPower, NxForceMode _sForceMode, bool _bLocal);
CPhysicUserData* m_pUserData;
NxActor* m_pPhXActor;
NxActorDesc* m_pPhXActorDesc;
NxBodyDesc* m_pPhXBodyDesc;
std::vector<NxBoxShapeDesc*> m_vBoxDesc;
std::vector<NxTriangleMeshShapeDesc*> m_vMeshDesc;
std::vector<NxCapsuleShapeDesc*> m_vCapsuleDesc;
std::vector<NxSphereShapeDesc*> m_vSphereDesc;
std::vector<NxPlaneShapeDesc*> m_vPlaneDesc;
};
#endif //INC_PHYSIC_ACTOR_H_
|
[
"galindix@576ee6d0-068d-96d9-bff2-16229cd70485",
"sergivalls@576ee6d0-068d-96d9-bff2-16229cd70485",
"mudarra@576ee6d0-068d-96d9-bff2-16229cd70485",
"Atridas87@576ee6d0-068d-96d9-bff2-16229cd70485",
"atridas87@576ee6d0-068d-96d9-bff2-16229cd70485"
] |
[
[
[
1,
27
],
[
29,
39
],
[
42,
42
],
[
50,
50
],
[
58,
58
],
[
63,
65
],
[
68,
68
],
[
73,
75
],
[
77,
82
],
[
88,
92
],
[
95,
107
]
],
[
[
28,
28
],
[
41,
41
],
[
43,
43
],
[
46,
46
],
[
51,
54
],
[
57,
57
],
[
59,
62
],
[
66,
66
],
[
71,
71
],
[
76,
76
],
[
83,
87
],
[
93,
94
]
],
[
[
40,
40
],
[
44,
44
],
[
69,
70
],
[
72,
72
]
],
[
[
45,
45
],
[
48,
49
],
[
56,
56
]
],
[
[
47,
47
],
[
55,
55
],
[
67,
67
]
]
] |
57bb7b360cd0efaaf674ee7084c191c6df335732
|
ce262ae496ab3eeebfcbb337da86d34eb689c07b
|
/SEFoundation/SEMath/SEVector4.inl
|
c40d9bd35f83853338de37e65269117f647a9c4c
|
[] |
no_license
|
pizibing/swingengine
|
d8d9208c00ec2944817e1aab51287a3c38103bea
|
e7109d7b3e28c4421c173712eaf872771550669e
|
refs/heads/master
| 2021-01-16T18:29:10.689858 | 2011-06-23T04:27:46 | 2011-06-23T04:27:46 | 33,969,301 | 0 | 0 | null | null | null | null |
GB18030
|
C++
| false | false | 4,967 |
inl
|
// Swing Engine Version 1 Source Code
// Most of techniques in the engine are mainly based on David Eberly's
// Wild Magic 4 open-source code.The author of Swing Engine learned a lot
// from Eberly's experience of architecture and algorithm.
// Several sub-systems are totally new,and others are re-implimented or
// re-organized based on Wild Magic 4's sub-systems.
// Copyright (c) 2007-2010. All Rights Reserved
//
// Eberly's permission:
// Geometric Tools, Inc.
// http://www.geometrictools.com
// Copyright (c) 1998-2006. All Rights Reserved
//
// 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. The license is available for reading at
// the location:
// http://www.gnu.org/copyleft/lgpl.html
//----------------------------------------------------------------------------
// 单精度4维向量类
//----------------------------------------------------------------------------
inline int SEVector4f::CompareData(const SEVector4f& rVec) const
{
return memcmp(m_fData, rVec.m_fData, 4*sizeof(float));
}
//----------------------------------------------------------------------------
inline float SEVector4f::GetLength() const
{
return SEMath<float>::Sqrt(
m_fData[0] * m_fData[0] +
m_fData[1] * m_fData[1] +
m_fData[2] * m_fData[2] +
m_fData[3] * m_fData[3]);
}
//----------------------------------------------------------------------------
inline float SEVector4f::GetSquaredLength() const
{
return
m_fData[0] * m_fData[0] +
m_fData[1] * m_fData[1] +
m_fData[2] * m_fData[2] +
m_fData[3] * m_fData[3];
}
//----------------------------------------------------------------------------
inline float SEVector4f::Dot(const SEVector4f& rRhsVec) const
{
return
m_fData[0] * rRhsVec.m_fData[0] +
m_fData[1] * rRhsVec.m_fData[1] +
m_fData[2] * rRhsVec.m_fData[2] +
m_fData[3] * rRhsVec.m_fData[3];
}
//----------------------------------------------------------------------------
inline float SEVector4f::Normalize()
{
float fLength = GetLength();
if( fLength > SEMath<float>::ZERO_TOLERANCE )
{
float fInvLength = 1.0f / fLength;
m_fData[0] *= fInvLength;
m_fData[1] *= fInvLength;
m_fData[2] *= fInvLength;
m_fData[3] *= fInvLength;
}
else
{
m_fData[0] = 0.0f;
m_fData[1] = 0.0f;
m_fData[2] = 0.0f;
m_fData[3] = 0.0f;
}
return fLength;
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
// 双精度4维向量类
//----------------------------------------------------------------------------
inline int SEVector4d::CompareData(const SEVector4d& rVec) const
{
return memcmp(m_dData, rVec.m_dData, 4*sizeof(double));
}
//----------------------------------------------------------------------------
inline double SEVector4d::GetLength() const
{
return SEMath<double>::Sqrt(
m_dData[0] * m_dData[0] +
m_dData[1] * m_dData[1] +
m_dData[2] * m_dData[2] +
m_dData[3] * m_dData[3]);
}
//----------------------------------------------------------------------------
inline double SEVector4d::GetSquaredLength() const
{
return
m_dData[0] * m_dData[0] +
m_dData[1] * m_dData[1] +
m_dData[2] * m_dData[2] +
m_dData[3] * m_dData[3];
}
//----------------------------------------------------------------------------
inline double SEVector4d::Dot(const SEVector4d& rRhsVec) const
{
return
m_dData[0] * rRhsVec.m_dData[0] +
m_dData[1] * rRhsVec.m_dData[1] +
m_dData[2] * rRhsVec.m_dData[2] +
m_dData[3] * rRhsVec.m_dData[3];
}
//----------------------------------------------------------------------------
inline double SEVector4d::Normalize()
{
double dLength = GetLength();
if( dLength > SEMath<double>::ZERO_TOLERANCE )
{
double fInvLength = 1.0 / dLength;
m_dData[0] *= fInvLength;
m_dData[1] *= fInvLength;
m_dData[2] *= fInvLength;
m_dData[3] *= fInvLength;
}
else
{
m_dData[0] = 0.0;
m_dData[1] = 0.0;
m_dData[2] = 0.0;
m_dData[3] = 0.0;
}
return dLength;
}
//----------------------------------------------------------------------------
|
[
"[email protected]@876e9856-8d94-11de-b760-4d83c623b0ac"
] |
[
[
[
1,
137
]
]
] |
0c6a593510707fe649b362324c448e5bc2a701f5
|
011359e589f99ae5fe8271962d447165e9ff7768
|
/src/burn/misc/post90s/d_suprnova.cpp
|
86e16fdf0fb8afd1829dbdff06413309ef17804f
|
[] |
no_license
|
PS3emulators/fba-next-slim
|
4c753375fd68863c53830bb367c61737393f9777
|
d082dea48c378bddd5e2a686fe8c19beb06db8e1
|
refs/heads/master
| 2021-01-17T23:05:29.479865 | 2011-12-01T18:16:02 | 2011-12-01T18:16:02 | 2,899,840 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 19,786 |
cpp
|
#include "tiles_generic.h"
#include "sh2.h"
static unsigned char DrvInputPort0[8] = {0, 0, 0, 0, 0, 0, 0, 0};
static unsigned char DrvInputPort1[8] = {0, 0, 0, 0, 0, 0, 0, 0};
static unsigned char DrvInputPort2[8] = {0, 0, 0, 0, 0, 0, 0, 0};
static unsigned char DrvDip[1] = {0};
static unsigned char DrvInput[3] = {0x00, 0x00, 0x00};
static unsigned char DrvReset = 0;
static unsigned char *Mem = NULL;
static unsigned char *MemEnd = NULL;
static unsigned char *RamStart = NULL;
static unsigned char *RamEnd = NULL;
static unsigned char *DrvBiosRom = NULL;
static unsigned char *DrvPrgRom = NULL;
static unsigned char *DrvSpriteRom = NULL;
static unsigned char *DrvSampleRom = NULL;
static unsigned char *DrvPrgRam = NULL;
static unsigned char *DrvBackupRam = NULL;
static unsigned char *DrvSpriteRam = NULL;
static unsigned char *DrvSpriteRegs = NULL;
static unsigned char *DrvTileARam = NULL;
static unsigned char *DrvTileBRam = NULL;
static unsigned char *DrvTileBTilesRam = NULL;
static unsigned char *DrvTileRegs = NULL;
static unsigned char *DrvTileLineRam = NULL;
static unsigned char *DrvCacheRam = NULL;
static unsigned char *DrvPaletteRam = NULL;
static unsigned char *DrvPaletteRegs = NULL;
static unsigned char *DrvTempRom = NULL;
static unsigned char *DrvTilesA8Bpp = NULL;
static unsigned char *DrvTilesB8Bpp = NULL;
static unsigned char *DrvTilesA4Bpp = NULL;
static unsigned char *DrvTilesB4Bpp = NULL;
static unsigned int *DrvPalette = NULL;
static int nCyclesDone[1], nCyclesTotal[1];
static int nCyclesSegment;
static struct BurnInputInfo CyvernInputList[] =
{
{"Coin 1" , BIT_DIGITAL , DrvInputPort2 + 2, "p1 coin" },
{"Start 1" , BIT_DIGITAL , DrvInputPort2 + 0, "p1 start" },
{"Coin 2" , BIT_DIGITAL , DrvInputPort2 + 3, "p2 coin" },
{"Start 2" , BIT_DIGITAL , DrvInputPort2 + 1, "p2 start" },
{"P1 Up" , BIT_DIGITAL , DrvInputPort0 + 0, "p1 up" },
{"P1 Down" , BIT_DIGITAL , DrvInputPort0 + 1, "p1 down" },
{"P1 Left" , BIT_DIGITAL , DrvInputPort0 + 2, "p1 left" },
{"P1 Right" , BIT_DIGITAL , DrvInputPort0 + 3, "p1 right" },
{"P1 Fire 1" , BIT_DIGITAL , DrvInputPort0 + 4, "p1 fire 1" },
{"P1 Fire 2" , BIT_DIGITAL , DrvInputPort0 + 5, "p1 fire 2" },
{"P2 Up" , BIT_DIGITAL , DrvInputPort1 + 0, "p2 up" },
{"P2 Down" , BIT_DIGITAL , DrvInputPort1 + 1, "p2 down" },
{"P2 Left" , BIT_DIGITAL , DrvInputPort1 + 2, "p2 left" },
{"P2 Right" , BIT_DIGITAL , DrvInputPort1 + 3, "p2 right" },
{"P2 Fire 1" , BIT_DIGITAL , DrvInputPort1 + 4, "p2 fire 1" },
{"P2 Fire 2" , BIT_DIGITAL , DrvInputPort1 + 5, "p2 fire 2" },
{"Reset" , BIT_DIGITAL , &DrvReset , "reset" },
{"Service" , BIT_DIGITAL , DrvInputPort2 + 6, "service" },
{"Tilt" , BIT_DIGITAL , DrvInputPort2 + 5, "tilt" },
{"Dip 1" , BIT_DIPSWITCH, DrvDip + 0 , "dip" },
};
STDINPUTINFO(Cyvern)
static inline void DrvMakeInputs()
{
// Reset Inputs
DrvInput[0] = DrvInput[1] = DrvInput[2] = 0x00;
// Compile Digital Inputs
for (int i = 0; i < 8; i++) {
DrvInput[0] |= (DrvInputPort0[i] & 1) << i;
DrvInput[1] |= (DrvInputPort1[i] & 1) << i;
DrvInput[2] |= (DrvInputPort2[i] & 1) << i;
}
// Clear Opposites
DrvClearOpposites(&DrvInput[0]);
DrvClearOpposites(&DrvInput[1]);
}
static struct BurnDIPInfo DrvDIPList[]=
{
// Default Values
{0x13, 0xff, 0xff, 0xff, NULL },
// Dip 1
{0 , 0xfe, 0 , 2 , "Test Mode" },
{0x13, 0x01, 0x01, 0x01, "Off" },
{0x13, 0x01, 0x01, 0x00, "On" },
{0 , 0xfe, 0 , 2 , "Flip Screen" },
{0x13, 0x01, 0x02, 0x02, "Off" },
{0x13, 0x01, 0x02, 0x00, "On" },
{0 , 0xfe, 0 , 2 , "Use backup RAM" },
{0x13, 0x01, 0x40, 0x00, "No" },
{0x13, 0x01, 0x40, 0x40, "Yes" },
{0 , 0xfe, 0 , 2 , "Freeze" },
{0x13, 0x01, 0x80, 0x80, "Off" },
{0x13, 0x01, 0x80, 0x00, "On" },
};
STDDIPINFO(Drv)
static struct BurnRomInfo CyvernRomDesc[] = {
{ "sknsj1.u10", 0x080000, 0x7e2b836c, BRF_ESS | BRF_PRG }, // 0 BIOS
{ "cvj-even.u10", 0x100000, 0x802fadb4, BRF_ESS | BRF_PRG }, // 1 SH-2 Program
{ "cvj-odd.u8", 0x100000, 0xf8a0fbdd, BRF_ESS | BRF_PRG }, // 2
{ "cv100-00.u24", 0x400000, 0xcd4ae88a, BRF_GRA }, // 3 Sprites
{ "cv101-00.u20", 0x400000, 0xa6cb3f0b, BRF_GRA }, // 4
{ "cv200-00.u16", 0x400000, 0xddc8c67e, BRF_GRA }, // 5 Tiles Plane A
{ "cv201-00.u13", 0x400000, 0x65863321, BRF_GRA }, // 6
{ "cv210-00.u18", 0x400000, 0x7486bf3a, BRF_GRA }, // 7 Tiles Plane B
{ "cv300-00.u4", 0x400000, 0xfbeda465, BRF_SND }, // 8 Samples
};
STD_ROM_PICK(Cyvern)
STD_ROM_FN(Cyvern)
static int MemIndex()
{
unsigned char *Next; Next = Mem;
DrvBiosRom = Next; Next += 0x080000;
DrvPrgRom = Next; Next += 0x200000;
DrvSpriteRom = Next; Next += 0x800000;
DrvSampleRom = Next; Next += 0x400000;
RamStart = Next;
DrvPrgRam = Next; Next += 0x100000;
DrvBackupRam = Next; Next += 0x002000;
DrvSpriteRam = Next; Next += 0x004000;
DrvSpriteRegs = Next; Next += 0x000040;
DrvTileARam = Next; Next += 0x004000;
DrvTileBRam = Next; Next += 0x004000;
DrvTileBTilesRam = Next; Next += 0x040000;
DrvTileRegs = Next; Next += 0x000080;
DrvTileLineRam = Next; Next += 0x008000;
DrvPaletteRam = Next; Next += 0x020000;
DrvPaletteRegs = Next; Next += 0x000020;
DrvCacheRam = Next; Next += 0x001000;
RamEnd = Next;
DrvTilesA8Bpp = Next; Next += 0x08000 * 16 * 16;
DrvTilesB8Bpp = Next; Next += 0x08000 * 16 * 16;
DrvTilesA4Bpp = Next; Next += 0x10000 * 16 * 16;
DrvTilesB4Bpp = Next; Next += 0x10000 * 16 * 16;
DrvPalette = (unsigned int*)Next; Next += 0x08000 * sizeof(unsigned int);
MemEnd = Next;
return 0;
}
static struct {
UINT16 x1p, y1p, z1p, x1s, y1s, z1s;
UINT16 x2p, y2p, z2p, x2s, y2s, z2s;
UINT16 org;
UINT16 x1_p1, x1_p2, y1_p1, y1_p2, z1_p1, z1_p2;
UINT16 x2_p1, x2_p2, y2_p1, y2_p2, z2_p1, z2_p2;
UINT16 x1tox2, y1toy2, z1toz2;
INT16 x_in, y_in, z_in;
UINT16 flag;
UINT8 disconnect;
} hit;
static void hit_calc_orig(UINT16 p, UINT16 s, UINT16 org, UINT16 *l, UINT16 *r)
{
switch(org & 3) {
case 0:
*l = p;
*r = p+s;
break;
case 1:
*l = p-s/2;
*r = *l+s;
break;
case 2:
*l = p-s;
*r = p;
break;
case 3:
*l = p-s;
*r = p+s;
break;
}
}
static void hit_calc_axis(UINT16 x1p, UINT16 x1s, UINT16 x2p, UINT16 x2s, UINT16 org,
UINT16 *x1_p1, UINT16 *x1_p2, UINT16 *x2_p1, UINT16 *x2_p2,
INT16 *x_in, UINT16 *x1tox2)
{
UINT16 x1l=0, x1r=0, x2l=0, x2r=0;
hit_calc_orig(x1p, x1s, org, &x1l, &x1r);
hit_calc_orig(x2p, x2s, org >> 8, &x2l, &x2r);
*x1tox2 = x2p-x1p;
*x1_p1 = x1p;
*x2_p1 = x2p;
*x1_p2 = x1r;
*x2_p2 = x2l;
*x_in = x1r-x2l;
}
static void hit_recalc(void)
{
hit_calc_axis(hit.x1p, hit.x1s, hit.x2p, hit.x2s, hit.org,
&hit.x1_p1, &hit.x1_p2, &hit.x2_p1, &hit.x2_p2,
&hit.x_in, &hit.x1tox2);
hit_calc_axis(hit.y1p, hit.y1s, hit.y2p, hit.y2s, hit.org,
&hit.y1_p1, &hit.y1_p2, &hit.y2_p1, &hit.y2_p2,
&hit.y_in, &hit.y1toy2);
hit_calc_axis(hit.z1p, hit.z1s, hit.z2p, hit.z2s, hit.org,
&hit.z1_p1, &hit.z1_p2, &hit.z2_p1, &hit.z2_p2,
&hit.z_in, &hit.z1toz2);
hit.flag = 0;
hit.flag |= hit.y2p > hit.y1p ? 0x8000 : hit.y2p == hit.y1p ? 0x4000 : 0x2000;
hit.flag |= hit.y_in >= 0 ? 0 : 0x1000;
hit.flag |= hit.x2p > hit.x1p ? 0x0800 : hit.x2p == hit.x1p ? 0x0400 : 0x0200;
hit.flag |= hit.x_in >= 0 ? 0 : 0x0100;
hit.flag |= hit.z2p > hit.z1p ? 0x0080 : hit.z2p == hit.z1p ? 0x0040 : 0x0020;
hit.flag |= hit.z_in >= 0 ? 0 : 0x0010;
hit.flag |= hit.x_in >= 0 && hit.y_in >= 0 && hit.z_in >= 0 ? 8 : 0;
hit.flag |= hit.z_in >= 0 && hit.x_in >= 0 ? 4 : 0;
hit.flag |= hit.y_in >= 0 && hit.z_in >= 0 ? 2 : 0;
hit.flag |= hit.x_in >= 0 && hit.y_in >= 0 ? 1 : 0;
}
static void SknsHitWrite(unsigned int offset, unsigned int data)
{
int adr = offset * 4;
switch(adr) {
case 0x00:
case 0x28:
hit.x1p = data;
break;
case 0x08:
case 0x30:
hit.y1p = data;
break;
case 0x38:
case 0x50:
hit.z1p = data;
break;
case 0x04:
case 0x2c:
hit.x1s = data;
break;
case 0x0c:
case 0x34:
hit.y1s = data;
break;
case 0x3c:
case 0x54:
hit.z1s = data;
break;
case 0x10:
case 0x58:
hit.x2p = data;
break;
case 0x18:
case 0x60:
hit.y2p = data;
break;
case 0x20:
case 0x68:
hit.z2p = data;
break;
case 0x14:
case 0x5c:
hit.x2s = data;
break;
case 0x1c:
case 0x64:
hit.y2s = data;
break;
case 0x24:
case 0x6c:
hit.z2s = data;
break;
case 0x70:
hit.org = data;
break;
default:
// log_write("HIT", adr, data, type);
break;
}
hit_recalc();
}
static void SknsHit2Write(unsigned int offset, unsigned int data)
{
// log_event("HIT", "Set disconnect to %02x", data);
hit.disconnect = data;
}
unsigned int __fastcall SknsHitRead(unsigned int offset)
{
int adr = offset *4;
// log_read("HIT", adr, type);
if(hit.disconnect)
return 0x0000;
switch(adr) {
case 0x28:
case 0x2a:
return rand() & 0xffff;
case 0x00:
case 0x10:
return (UINT16)hit.x_in;
case 0x04:
case 0x14:
return (UINT16)hit.y_in;
case 0x18:
return (UINT16)hit.z_in;
case 0x08:
case 0x1c:
return hit.flag;
case 0x40:
return hit.x1p;
case 0x48:
return hit.y1p;
case 0x50:
return hit.z1p;
case 0x44:
return hit.x1s;
case 0x4c:
return hit.y1s;
case 0x54:
return hit.z1s;
case 0x58:
return hit.x2p;
case 0x60:
return hit.y2p;
case 0x68:
return hit.z2p;
case 0x5c:
return hit.x2s;
case 0x64:
return hit.y2s;
case 0x6c:
return hit.z2s;
case 0x70:
return hit.org;
case 0x80:
return hit.x1tox2;
case 0x84:
return hit.y1toy2;
case 0x88:
return hit.z1toz2;
case 0x90:
return hit.x1_p1;
case 0xa0:
return hit.y1_p1;
case 0xb0:
return hit.z1_p1;
case 0x98:
return hit.x1_p2;
case 0xa8:
return hit.y1_p2;
case 0xb8:
return hit.z1_p2;
case 0x94:
return hit.x2_p1;
case 0xa4:
return hit.y2_p1;
case 0xb4:
return hit.z2_p1;
case 0x9c:
return hit.x2_p2;
case 0xac:
return hit.y2_p2;
case 0xbc:
return hit.z2_p2;
default:
// log_read("HIT", adr, type);
return 0;
}
}
static int DrvDoReset()
{
Sh2Open(0);
Sh2Reset(*(unsigned int *)(DrvBiosRom + 0), *(unsigned int *)(DrvBiosRom + 4));
Sh2Close();
return 0;
}
unsigned char __fastcall CyvernReadByte(unsigned int a)
{
#if 0
switch (a) {
case 0x20400007: {
//???
return 0;
}
default: {
bprintf(PRINT_NORMAL, _T("Read byte => %08X\n"), a);
}
}
#endif
return 0;
}
void __fastcall CyvernWriteByte(unsigned int a, unsigned char d)
{
switch (a) {
#if 0
case 0x0040000e: {
// unknown i/o write;
return;
}
case 0x00c00000:
case 0x00c00001: {
//sound write
return;
}
#endif
case 0x01800000: {
SknsHit2Write(0, d);
return;
}
#if 0
case 0x2040000e: {
//???
return;
}
default: {
bprintf(PRINT_NORMAL, _T("Write byte => %08X, %02X\n"), a, d);
}
#endif
}
}
unsigned short __fastcall CyvernReadWord(unsigned int a)
{
if (a >= 0x06000000 && a <= 0x06ffffff) {
//if (a >= 0x06000028 && a <= 0x0600002b) bprintf(PRINT_NORMAL, _T("Read Word Bios Skip %x, %x\n"), a, Sh2GetPC(0));
unsigned int Offset = (a - 0x06000000) / 2;
UINT16 *Ram = (UINT16*)DrvPrgRam;
return Ram[Offset];
}
// switch (a) {
// default: {
// bprintf(PRINT_NORMAL, _T("Read word => %08X\n"), a);
// }
// }
return 0;
}
void __fastcall CyvernWriteWord(unsigned int a, unsigned short d)
{
#if 0
switch (a) {
case 0x05000000: {
// ???
return;
}
default: {
bprintf(PRINT_NORMAL, _T("Write word => %08X, %04X\n"), a, d);
}
}
#endif
}
unsigned int __fastcall CyvernReadLong(unsigned int a)
{
if (a >= 0x02f00000 && a <= 0x02f000ff) {
unsigned int Offset = (a - 0x02f00000) / 4;
return SknsHitRead(Offset);
}
if (a >= 0x06000000 && a <= 0x06ffffff) {
//if (a >= 0x06000028 && a <= 0x0600002b) bprintf(PRINT_NORMAL, _T("Read Long Bios Skip %x, %x\n"), a, Sh2GetPC(0) / 4);
unsigned int Offset = (a - 0x06000000) / 4;
UINT32 *Ram = (UINT32*)DrvPrgRam;
return Ram[Offset];
}
// switch (a) {
// default: {
// bprintf(PRINT_NORMAL, _T("Read long => %08X\n"), a);
// }
// }
return 0;
}
void __fastcall CyvernWriteLong(unsigned int a, unsigned int d)
{
if (a >= 0x02f00000 && a <= 0x02f000ff) {
unsigned int Offset = (a - 0x02f00000) / 4;
SknsHitWrite(Offset, d);
return;
}
// switch (a) {
// default: {
// bprintf(PRINT_NORMAL, _T("Write long => %08X, %04X\n"), a, d);
// }
// }
}
unsigned char __fastcall BiosSkipReadByte(unsigned int a)
{
// switch (a) {
// default: {
// bprintf(PRINT_NORMAL, _T("Read Bios Skip byte => %08X\n"), a);
// }
// }
return 0;
}
unsigned short __fastcall BiosSkipReadWord(unsigned int a)
{
// switch (a) {
// default: {
// bprintf(PRINT_NORMAL, _T("Read Bios Skip word => %08X\n"), a);
// }
// }
return 0;
}
unsigned int __fastcall BiosSkipReadLong(unsigned int a)
{
// switch (a) {
// default: {
// bprintf(PRINT_NORMAL, _T("Read Bios Skip long => %08X\n"), a);
// }
// }
return 0;
}
static void be_to_le(unsigned char * p, int size)
{
unsigned char c;
for(int i=0; i<size; i+=4, p+=4) {
c = *(p+0); *(p+0) = *(p+3); *(p+3) = c;
c = *(p+1); *(p+1) = *(p+2); *(p+2) = c;
}
}
static int CyvernInit()
{
int nRet = 0, nLen;
BurnSetRefreshRate(59.5971);
// Allocate and Blank all required memory
Mem = NULL;
MemIndex();
nLen = MemEnd - (unsigned char *)0;
if ((Mem = (unsigned char *)malloc(nLen)) == NULL) return 1;
memset(Mem, 0, nLen);
MemIndex();
DrvTempRom = (unsigned char *)malloc(0x800000);
// Load BIOS Rom
nRet = BurnLoadRom(DrvBiosRom + 0x000000, 0, 1); if (nRet != 0) return 1;
be_to_le(DrvBiosRom, 0x00080000);
// Load Program Rom
nRet = BurnLoadRom(DrvPrgRom + 0x000000, 1, 2); if (nRet != 0) return 1;
nRet = BurnLoadRom(DrvPrgRom + 0x000001, 2, 2); if (nRet != 0) return 1;
be_to_le(DrvPrgRom, 0x00200000);
free(DrvTempRom);
// Setup the 68000 emulation
Sh2Init(1);
Sh2Open(0);
Sh2MapMemory(DrvBiosRom , 0x00000000, 0x0007ffff, SM_ROM);
Sh2MapMemory(DrvSpriteRam , 0x02000000, 0x02003fff, SM_RAM);
Sh2MapMemory(DrvSpriteRegs , 0x02100000, 0x0210003f, SM_RAM);
Sh2MapMemory(DrvTileRegs , 0x02400000, 0x0240007f, SM_RAM);
Sh2MapMemory(DrvTileARam , 0x02500000, 0x02503fff, SM_RAM);
Sh2MapMemory(DrvTileBRam , 0x02504000, 0x02507fff, SM_RAM);
Sh2MapMemory(DrvTileLineRam , 0x02600000, 0x02607fff, SM_RAM);
Sh2MapMemory(DrvPaletteRegs , 0x02a00000, 0x02a0001f, SM_RAM);
Sh2MapMemory(DrvPaletteRam , 0x02a40000, 0x02a5ffff, SM_RAM);
Sh2MapMemory(DrvPrgRom , 0x04000000, 0x041fffff, SM_ROM);
Sh2MapMemory(DrvTileBTilesRam , 0x04800000, 0x0483ffff, SM_RAM);
Sh2MapMemory(DrvPrgRam , 0x06000000, 0x06ffffff, SM_RAM);
// Sh2MapMemory(DrvPrgRam , 0x06000000, 0x06ffffff, SM_WRITE);
Sh2MapMemory(DrvCacheRam , 0xc0000000, 0xc0000fff, SM_RAM);
// Sh2MapHandler(1 , 0x06000028, 0x0600002b, SM_READ);
Sh2SetReadByteHandler (0, CyvernReadByte);
Sh2SetReadWordHandler (0, CyvernReadWord);
Sh2SetReadLongHandler (0, CyvernReadLong);
Sh2SetWriteByteHandler(0, CyvernWriteByte);
Sh2SetWriteWordHandler(0, CyvernWriteWord);
Sh2SetWriteLongHandler(0, CyvernWriteLong);
// Sh2SetReadByteHandler (1, BiosSkipReadByte);
// Sh2SetReadWordHandler (1, BiosSkipReadWord);
// Sh2SetReadLongHandler (1, BiosSkipReadLong);
Sh2Close();
GenericTilesInit();
// Reset the driver
DrvDoReset();
return 0;
}
static int DrvExit()
{
Sh2Exit();
GenericTilesExit();
free(Mem);
Mem = NULL;
return 0;
}
static void DrvCalcPalette()
{
UINT32 *PaletteRam = (UINT32*)DrvPaletteRam;
for (int Offset = 0; Offset <= 32768; Offset++) {
int r = (PaletteRam[Offset] >> 0) & 0x1f;
int g = (PaletteRam[Offset] >> 5) & 0x1f;
int b = (PaletteRam[Offset] >> 10) & 0x1f;
r <<= 3;
g <<= 3;
b <<= 3;
DrvPalette[Offset] = BurnHighCol(r, g, b, 0);
}
}
static void DrvRenderTileALayer()
{
int mx, my, Code, Colour, x, y, TileIndex = 0;
UINT32 *VideoRam = (UINT32*)DrvTileARam;
for (my = 0; my < 64; my++) {
for (mx = 0; mx < 64; mx++) {
Code = VideoRam[TileIndex] & 0x001fffff;
Colour = (VideoRam[TileIndex] & 0x3f000000) >> 24;
//if (Code) bprintf(PRINT_NORMAL, _T("%x, %x\n"), Code, Colour);
x = 16 * mx;
y = 16 * my;
// x -= DrvFgScrollX;
// y -= DrvFgScrollY;
if (x < -16) x += 1024;
if (y < -16) y += 1024;
if (x > 16 && x < 304 && y > 16 && y < 224) {
Render16x16Tile_Mask(pTransDraw, Code, x, y, Colour, 8, 0, 0, DrvTilesA8Bpp);
} else {
Render16x16Tile_Mask_Clip(pTransDraw, Code, x, y, Colour, 8, 0, 0, DrvTilesA8Bpp);
}
TileIndex++;
}
}
}
static void DrvDraw()
{
BurnTransferClear();
DrvCalcPalette();
DrvRenderTileALayer();
BurnTransferCopy(DrvPalette);
}
static int DrvFrame()
{
int nInterleave = 10;
// int nSoundBufferPos = 0;
if (DrvReset) DrvDoReset();
DrvMakeInputs();
nCyclesTotal[0] = 28638000 / 60;
nCyclesDone[0] = 0;
for (int i = 0; i < nInterleave; i++) {
int nCurrentCPU, nNext;
nCurrentCPU = 0;
Sh2Open(0);
nNext = (i + 1) * nCyclesTotal[nCurrentCPU] / nInterleave;
nCyclesSegment = nNext - nCyclesDone[nCurrentCPU];
nCyclesDone[nCurrentCPU] += Sh2Run(nCyclesSegment);
if (i == 5) Sh2SetIRQLine(1, SH2_IRQSTATUS_AUTO);
if (i == 9) Sh2SetIRQLine(5, SH2_IRQSTATUS_AUTO);
Sh2Close();
}
if (pBurnDraw) DrvDraw();
return 0;
}
static int DrvScan(int nAction, int *pnMin)
{
struct BurnArea ba;
if (pnMin != NULL) { // Return minimum compatible version
*pnMin = 0x029693;
}
if (nAction & ACB_MEMORY_RAM) {
memset(&ba, 0, sizeof(ba));
ba.Data = RamStart;
ba.nLen = RamEnd-RamStart;
ba.szName = "All Ram";
BurnAcb(&ba);
}
return 0;
}
struct BurnDriver BurnDrvCyvern = {
"cyvern", NULL, NULL, "1998",
"Cyvern (Japan)\0", NULL, "Kaneko", "Super Kaneko Nova System",
NULL, NULL, NULL, NULL,
BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_MISC,
NULL, CyvernRomInfo, CyvernRomName, CyvernInputInfo, DrvDIPInfo,
CyvernInit, DrvExit, DrvFrame, NULL, DrvScan,
NULL, 240, 320, 3, 4
};
|
[
"[email protected]"
] |
[
[
[
1,
770
]
]
] |
d1bb06d1e28c984a4e2d864466a1f92acecd0d1a
|
011359e589f99ae5fe8271962d447165e9ff7768
|
/src/libs/ticpp/ticpp_sugar.cpp
|
8c5f7db73cce896d6cd00f42f058878ac3de1fdf
|
[] |
no_license
|
PS3emulators/fba-next-slim
|
4c753375fd68863c53830bb367c61737393f9777
|
d082dea48c378bddd5e2a686fe8c19beb06db8e1
|
refs/heads/master
| 2021-01-17T23:05:29.479865 | 2011-12-01T18:16:02 | 2011-12-01T18:16:02 | 2,899,840 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 552 |
cpp
|
#include "ticpp_sugar.h"
namespace ticpp
{
namespace sugar
{
const Element& NodeCombiner::RootNode() const
{
return m_CombinerNode;
}
NodeCombiner& NodeCombiner::operator+ (Node& rhs)
{
m_CombinerNode.Insert(rhs);
return *this;
}
NodeCombiner operator+ (Node& lhs, Node& rhs)
{
NodeCombiner nc;
nc.m_CombinerNode.InsertEndChild(lhs);
nc.m_CombinerNode.InsertEndChild(rhs);
return nc;
}
} //namespace ticpp
} //namespace sugar
|
[
"[email protected]"
] |
[
[
[
1,
28
]
]
] |
a1c13ccbd1a3f1898a05f7d8bb162b9ce2d7c23b
|
39040af0ff84935d083209731dd7343f93fa2874
|
/src/udc.cpp
|
0c47e7281449ec915beb5b83c7aba12abad54faa
|
[
"Apache-2.0"
] |
permissive
|
alanzw/ulib-win
|
02f8b7bcd8220b6a057fd3b33e733500294f9b56
|
b67f644ed11c849e3c93b909f90d443df7be4e4c
|
refs/heads/master
| 2020-04-06T05:26:54.849486 | 2011-07-23T05:47:17 | 2011-07-23T05:47:17 | 34,505,292 | 5 | 3 | null | null | null | null |
UTF-8
|
C++
| false | false | 9,423 |
cpp
|
/*
* =====================================================================================
*
* Filename: udc.cpp
*
* Description: implement UDevContext
*
* Version: 1.0
* Created: 2009-8-23 4:48:26
* Revision: none
* Compiler: gcc
*
* Author: huys (hys), [email protected]
* Company: hu
*
* =====================================================================================
*/
#define _WIN32_WINNT 0x0500
#define WINVER 0x0500
#include <windows.h>
#include <tchar.h>
#include <cassert>
#include "udc.h"
UDevContext::UDevContext()
: UGDIObject(),
m_hOldBrush(NULL),
m_hOldPen(NULL)
{}
UDevContext::~UDevContext()
{}
bool UDevContext::attach(HDC hdc)
{
assert(NULL == m_hObj);
m_hObj = hdc;
return true;
}
bool UDevContext::dettach()
{
assert(NULL != m_hObj);
m_hObj = NULL;
return true;
}
bool UDevContext::getDC( HWND hWnd )
{
return NULL != (m_hObj = ::GetDC(hWnd));
}
int UDevContext::saveDC()
{
return ::SaveDC((HDC)m_hObj);
}
BOOL UDevContext::restoreDC(int nSaveDC)
{
return ::RestoreDC((HDC)m_hObj, nSaveDC);
}
huys::Color UDevContext::setPenColor(huys::Color clr)
{
// Select DC_PEN so you can change the color of the pen with
// COLORREF SetDCPenColor(HDC hdc, COLORREF color)
::SelectObject((HDC)m_hObj, ::GetStockObject(DC_PEN));
return ::SetDCPenColor((HDC)m_hObj, clr);
}
huys::Color UDevContext::setBrushColor(huys::Color clr)
{
// Select DC_BRUSH so you can change the brush color from the
// default WHITE_BRUSH to any other color
::SelectObject((HDC)m_hObj, ::GetStockObject(DC_BRUSH));
return ::SetDCBrushColor((HDC)m_hObj, clr);
}
huys::Color UDevContext::getPenColor()
{
#ifdef _MSC_VER
return ::GetDCPenColor((HDC)m_hObj);
#else
return 0;
#endif
}
huys::Color UDevContext::getBrushColor()
{
#ifdef _MSC_VER
return ::GetDCBrushColor((HDC)m_hObj);
#else
return 0;
#endif
}
HGDIOBJ UDevContext::getCurObj(UINT uObjectType)
{
return ::GetCurrentObject((HDC)m_hObj, uObjectType);
}
HANDLE UDevContext::selectObj(HANDLE hObj)
{
return ::SelectObject((HDC)m_hObj, hObj);
}
int UDevContext::setStretchBltMode( int iStretchMode )
{
return ::SetStretchBltMode(*this, iStretchMode);
}
BOOL UDevContext::stretchBlt( int nXOriginDest,
int nYOriginDest,
int nWidthDest,
int nHeightDest,
HDC hdcSrc,
int nXOriginSrc,
int nYOriginSrc,
int nWidthSrc,
int nHeightSrc,
DWORD dwRop )
{
return ::StretchBlt(*this, nXOriginDest, nYOriginDest,
nWidthDest, nHeightDest, hdcSrc,
nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, dwRop );
}
BOOL UDevContext::bitBlt( int nXOriginDest,
int nYOriginDest,
int nWidthDest,
int nHeightDest,
HDC hdcSrc,
int nXOriginSrc,
int nYOriginSrc,
DWORD dwRop )
{
return ::BitBlt(*this, nXOriginDest, nYOriginDest,
nWidthDest, nHeightDest, hdcSrc,
nXOriginSrc, nYOriginSrc, dwRop );
}
BOOL UDevContext::bitBlt(LPRECT lpRect, HDC hdcSrc, int nXOriginSrc, int nYOriginSrc, DWORD dwRop)
{
return this->bitBlt(lpRect->left, lpRect->top,
lpRect->right - lpRect->left,
lpRect->bottom - lpRect->top,
hdcSrc, nXOriginSrc, nYOriginSrc, dwRop);
}
BOOL UDevContext::patBlt( int nLeft,
int nTop,
int nWidth,
int nHeight,
DWORD dwRop)
{
return ::PatBlt(*this, nLeft, nTop, nWidth, nHeight, dwRop);
}
void UDevContext::setMapMode( int nMode )
{
::SetMapMode((HDC)m_hObj, nMode);
}
int UDevContext::getMapMode()
{
return ::GetMapMode((HDC)m_hObj);
}
BOOL UDevContext::rectangle(int nLeft, int nTop, int nRight, int nBottom)
{
return ::Rectangle((HDC)m_hObj, nLeft, nTop, nRight, nBottom);
}
BOOL UDevContext::rectangle(LPCRECT lpRect)
{
return rectangle(lpRect->left, lpRect->top,
lpRect->right, lpRect->bottom);
}
int UDevContext::fillRect( LPCRECT lpRect, HBRUSH hBrush )
{
return ::FillRect((HDC)m_hObj, lpRect, hBrush);
}
int UDevContext::frameRect(LPCRECT lpRect, HBRUSH hBrush)
{
return ::FrameRect((HDC)m_hObj, lpRect, hBrush);
}
BOOL UDevContext::invertRect(LPCRECT lpRect)
{
return ::InvertRect((HDC)m_hObj, lpRect);
}
BOOL UDevContext::roundRect(int nLeft, int nTop, int nRight, int nBottom, int nWidth, int nHeight)
{
return ::RoundRect((HDC)m_hObj, nLeft, nTop, nRight, nBottom, nWidth, nHeight);
}
BOOL UDevContext::roundRect(LPCRECT lpRect, const POINT pt)
{
return this->roundRect(lpRect->left, lpRect->top, lpRect->right, lpRect->bottom,
pt.x, pt.y);
}
void UDevContext::setViewportOrg( int x, int y )
{
::SetViewportOrgEx((HDC)m_hObj, x, y, NULL);
}
void UDevContext::setWindowOrg( int x, int y )
{
::SetWindowOrgEx((HDC)m_hObj, x, y, NULL);
}
BOOL UDevContext::DPToLP(LPPOINT lpPoints, int nCount)
{
return ::DPtoLP((HDC)m_hObj, lpPoints, nCount);
}
BOOL UDevContext::LPToDP(LPPOINT lpPoints, int nCount)
{
return ::LPtoDP((HDC)m_hObj, lpPoints, nCount);
}
BOOL UDevContext::textOut( int nX, int nY, LPCTSTR lpString, int cbString )
{
return ::TextOut((HDC)m_hObj, nX, nY, lpString, cbString);
}
BOOL UDevContext::textOutEx( int nX, int nY, LPCTSTR lpText )
{
return this->textOut(nX, nY, lpText, lstrlen(lpText));
}
int UDevContext::drawText( LPCTSTR lpchText, int nCount, LPRECT lpRect, UINT uFormat )
{
return ::DrawText((HDC)m_hObj, lpchText, nCount, lpRect, uFormat);
}
int UDevContext::drawTextEx( LPTSTR lpchText, int nCount, LPRECT lpRect, UINT uFormat, LPDRAWTEXTPARAMS lpDTParams /*= NULL*/ )
{
return ::DrawTextEx((HDC)m_hObj, lpchText, nCount, lpRect, uFormat, lpDTParams);
}
BOOL UDevContext::extTextOut(int x, int y, UINT fuOptions, LPRECT lpRect, LPCTSTR lpchText, int nCount, const INT *lpDx)
{
return ::ExtTextOut((HDC)m_hObj, x, y, fuOptions, lpRect, lpchText, nCount, lpDx);
}
BOOL UDevContext::getTextExtentPoint32(LPCTSTR lpString, int c, LPSIZE lpSize)
{
return ::GetTextExtentPoint32((HDC)m_hObj, lpString, c, lpSize);
}
huys::Color UDevContext::setBKColor( huys::Color clr )
{
return ::SetBkColor((HDC)m_hObj, clr);
}
int UDevContext::setBKMode( int iMode )
{
return ::SetBkMode((HDC)m_hObj, iMode);
}
int UDevContext::getBKMode()
{
return ::GetBkMode((HDC)m_hObj);
}
huys::Color UDevContext::getBKColor()
{
return ::GetBkColor((HDC)m_hObj);
}
BOOL UDevContext::drawLine( int nX1, int nY1, int nX2, int nY2 )
{
return ::MoveToEx((HDC)m_hObj, nX1, nY1, NULL) &&
::LineTo((HDC)m_hObj, nX2, nY2);
}
BOOL UDevContext::polygon(const POINT *lpPoints, int nCount)
{
return ::Polygon((HDC)m_hObj, lpPoints, nCount);
}
BOOL UDevContext::moveTo(int x, int y)
{
return ::MoveToEx((HDC)m_hObj, x, y, NULL);
}
BOOL UDevContext::lineTo(int x, int y)
{
return ::LineTo((HDC)m_hObj, x, y);
}
huys::Color UDevContext::setPixel(int x, int y, huys::Color clr)
{
return ::SetPixel((HDC)m_hObj, x, y, clr);
}
huys::Color UDevContext::getPixel(int x, int y)
{
return ::GetPixel((HDC)m_hObj, x, y);
}
huys::Color UDevContext::getTextColor()
{
return ::GetTextColor((HDC)m_hObj);
}
huys::Color UDevContext::setTextColor( huys::Color clr )
{
return ::SetTextColor((HDC)m_hObj, clr);
}
void UDevContext::fillSolidRect( LPCRECT lpRect, huys::Color clr )
{
this->setBKColor(clr);
this->extTextOut(0, 0, ETO_OPAQUE, (LPRECT)lpRect, NULL, 0, NULL);
}
void UDevContext::fillSolidRect( int x, int y, int cx, int cy, huys::Color clr )
{
huys::URectL rect(x, y, x + cx, y + cy);
this->fillSolidRect(rect, clr);
}
void UDevContext::draw3dRect( int x, int y, int cx, int cy, huys::Color clrTopLeft, huys::Color clrBottomRight ) /* BOOL roundRect(int nLeft, int nTop, int nRight, int nBottom, int nWidth, int nHeight)*/
{
fillSolidRect(x, y, cx - 1, 1, clrTopLeft);
fillSolidRect(x, y, 1, cy - 1, clrTopLeft);
fillSolidRect(x + cx, y, -1, cy, clrBottomRight);
fillSolidRect(x, y + cy, cx, -1, clrBottomRight);
}
void UDevContext::draw3dRect(LPCRECT lpRect, huys::Color clrTopLeft, huys::Color clrBottomRight )
{
draw3dRect(lpRect->left, lpRect->top, lpRect->right - lpRect->left,
lpRect->bottom - lpRect->top, clrTopLeft, clrBottomRight);
}
void UDevContext::floodFill( int x, int y, huys::Color crColor )
{
::FloodFill((HDC)m_hObj, x, y, crColor);
}
UPaintDC::UPaintDC(HWND hWnd)
{
m_hWnd = hWnd;
m_hObj = ::BeginPaint(m_hWnd, &m_ps);
}
UPaintDC::~UPaintDC()
{
::EndPaint(m_hWnd, &m_ps);
}
UPrivateDC::UPrivateDC(HWND hWnd)
: m_hWnd(hWnd)
{
m_hObj = ::GetDC(m_hWnd);
}
UPrivateDC::~UPrivateDC()
{
::ReleaseDC(m_hWnd, (HDC)m_hObj);
}
USmartDC::USmartDC(HDC hdc)
{
attach(hdc);
}
USmartDC::~USmartDC()
{
dettach();
}
UMemDC::UMemDC(HDC hdc)
{
m_hObj = ::CreateCompatibleDC(hdc);
}
UMemDC::~UMemDC()
{
}
|
[
"fox000002@48c0247c-a797-11de-8c46-7bd654735883"
] |
[
[
[
1,
391
]
]
] |
beeb06b6630123364ef0777440bc7fed207a89fb
|
36fea6c98ecabcd5e932f2b7854b3282cdb571ee
|
/debug/plugins/moc_qtgroupboxpropertybrowser.cpp
|
2d50974cb22acb09afd8fe18910a210e78eb3a93
|
[] |
no_license
|
doomfrawen/visualcommand
|
976adaae69303d8b4ffc228106a1db9504e4a4e4
|
f7bc1d590444ff6811f84232f5c6480449228e19
|
refs/heads/master
| 2016-09-06T17:40:57.775379 | 2009-07-28T22:48:23 | 2009-07-28T22:48:23 | 32,345,504 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 2,543 |
cpp
|
/****************************************************************************
** Meta object code from reading C++ file 'qtgroupboxpropertybrowser.h'
**
** Created: Fri Jun 19 11:30:04 2009
** by: The Qt Meta Object Compiler version 61 (Qt 4.5.1)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "../../../src/qtgroupboxpropertybrowser.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'qtgroupboxpropertybrowser.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 61
#error "This file was generated using the moc from 4.5.1. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_QtGroupBoxPropertyBrowser[] = {
// content:
2, // revision
0, // classname
0, 0, // classinfo
2, 12, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
// slots: signature, parameters, type, tag, flags
27, 26, 26, 26, 0x08,
40, 26, 26, 26, 0x08,
0 // eod
};
static const char qt_meta_stringdata_QtGroupBoxPropertyBrowser[] = {
"QtGroupBoxPropertyBrowser\0\0slotUpdate()\0"
"slotEditorDestroyed()\0"
};
const QMetaObject QtGroupBoxPropertyBrowser::staticMetaObject = {
{ &QtAbstractPropertyBrowser::staticMetaObject, qt_meta_stringdata_QtGroupBoxPropertyBrowser,
qt_meta_data_QtGroupBoxPropertyBrowser, 0 }
};
const QMetaObject *QtGroupBoxPropertyBrowser::metaObject() const
{
return &staticMetaObject;
}
void *QtGroupBoxPropertyBrowser::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_QtGroupBoxPropertyBrowser))
return static_cast<void*>(const_cast< QtGroupBoxPropertyBrowser*>(this));
return QtAbstractPropertyBrowser::qt_metacast(_clname);
}
int QtGroupBoxPropertyBrowser::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QtAbstractPropertyBrowser::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
switch (_id) {
case 0: d_func()->slotUpdate(); break;
case 1: d_func()->slotEditorDestroyed(); break;
default: ;
}
_id -= 2;
}
return _id;
}
QT_END_MOC_NAMESPACE
|
[
"flouger@13a168e0-7ae3-11de-a146-1f7e517e55b8"
] |
[
[
[
1,
76
]
]
] |
f1458dd06648866d79668d7bf1c35e86ccabe296
|
52db451b6b354993000a4a808e9d046dff4c956f
|
/src/Deck.cpp
|
cda723ddb09d4d0d92272566159749ee14cda450
|
[] |
no_license
|
PuffNSting/Poker
|
a4b0263c27911291c6ce7148d22c1c137af457d3
|
b1c606980af32b325fdf7398f30d6364c0097034
|
refs/heads/master
| 2021-01-15T22:29:18.718588 | 2011-12-23T03:02:07 | 2011-12-23T03:02:07 | 3,032,075 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 996 |
cpp
|
#include "../include/Deck.h"
Deck::Deck()
{
Card holder;
for (int i = 0; i < 52; i++) { // creates ordered deck
deck.push_back(Card(i%13,i%4));
}
//shuffle();
}
void Deck::print_deck() {
for (int i = 0; i < deck.size(); i++) {
cout << deck[i].get_value() << " of " << deck[i].get_suite() << endl;
}
}
/*
Card Deck::operator[](int index) {
return deck[index];
}*/
void Deck::shuffle() {
// Using Fisher-Yates shuffle
int j; // Will hold random value
Card holder;
for (int i = deck.size(); i > 1; i--) {
j = rand() % i;
holder = deck[i];
deck[i] = deck[j];
deck[j] = holder;
}
/* Old shuffle
Card holder;
int index;
for (int i = 0; i < 52; i++) {
for (int x = 0; x < 52; x++) {
index = rand() % 52;
holder = deck[x];
deck[x] = deck[index];
deck[index] = holder;
}
}*/
}
|
[
"[email protected]"
] |
[
[
[
1,
44
]
]
] |
fe89720793bff0edcb695ee52e095d3dc74a3ee8
|
100f177f0da7e0abf1c65d5dafaab5ff8061e17a
|
/dc_fbx2depth/DrawScene.cpp
|
2ecb50e1c347327fb053fb1da3a3cec200f694e0
|
[] |
no_license
|
gulimujyujyu/xlzhuathku
|
61d39222a7854ffa6407031520a705b83adc3346
|
fe72d93fd29261cb34dc98bccafb0ae0ad50823a
|
refs/heads/master
| 2021-01-19T02:52:11.521328 | 2011-09-27T13:38:38 | 2011-09-27T13:38:38 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 34,186 |
cpp
|
/****************************************************************************************
Copyright (C) 2011 Autodesk, Inc.
All rights reserved.
Use of this software is subject to the terms of the Autodesk license agreement
provided at the time of installation or download, or which otherwise accompanies
this software in either electronic or hard copy form.
****************************************************************************************/
#include "DrawScene.h"
#include "SceneCache.h"
#include "GetPosition.h"
void DrawNode(KFbxNode* pNode,
KTime& lTime,
KFbxAnimLayer * pAnimLayer,
KFbxXMatrix& pParentGlobalPosition,
KFbxXMatrix& pGlobalPosition,
KFbxPose* pPose,
ShadingMode pShadingMode);
void DrawMarker(KFbxXMatrix& pGlobalPosition);
void DrawSkeleton(KFbxNode* pNode,
KFbxXMatrix& pParentGlobalPosition,
KFbxXMatrix& pGlobalPosition);
void DrawMesh(KFbxNode* pNode, KTime& pTime, KFbxAnimLayer* pAnimLayer,
KFbxXMatrix& pGlobalPosition, KFbxPose* pPose, ShadingMode pShadingMode);
void ComputeShapeDeformation(KFbxNode* pNode,
KFbxMesh* pMesh,
KTime& pTime,
KFbxAnimLayer * pAnimLayer,
KFbxVector4* pVertexArray);
void ComputeClusterDeformation(KFbxXMatrix& pGlobalPosition,
KFbxMesh* pMesh,
KFbxCluster* pCluster,
KFbxXMatrix& pVertexTransformMatrix,
KTime pTime,
KFbxPose* pPose);
void ComputeLinearDeformation(KFbxXMatrix& pGlobalPosition,
KFbxMesh* pMesh,
KTime& pTime,
KFbxVector4* pVertexArray,
KFbxPose* pPose);
void ComputeDualQuaternionDeformation(KFbxXMatrix& pGlobalPosition,
KFbxMesh* pMesh,
KTime& pTime,
KFbxVector4* pVertexArray,
KFbxPose* pPose);
void ComputeSkinDeformation(KFbxXMatrix& pGlobalPosition,
KFbxMesh* pMesh,
KTime& pTime,
KFbxVector4* pVertexArray,
KFbxPose* pPose);
void ReadVertexCacheData(KFbxMesh* pMesh,
KTime& pTime,
KFbxVector4* pVertexArray);
void DrawCamera(KFbxNode* pNode,
KTime& pTime,
KFbxAnimLayer* pAnimLayer,
KFbxXMatrix& pGlobalPosition);
void DrawLight(const KFbxNode* pNode, const KTime& pTime, const KFbxXMatrix& pGlobalPosition);
void DrawNull(KFbxXMatrix& pGlobalPosition);
void MatrixScale(KFbxXMatrix& pMatrix, double pValue);
void MatrixAddToDiagonal(KFbxXMatrix& pMatrix, double pValue);
void MatrixAdd(KFbxXMatrix& pDstMatrix, KFbxXMatrix& pSrcMatrix);
void InitializeLights(const KFbxScene* pScene, const KTime & pTime, KFbxPose* pPose)
{
// Set ambient light. Turn on light0 and set its attributes to default (white directional light in Z axis).
// If the scene contains at least one light, the attributes of light0 will be overridden.
LightCache::IntializeEnvironment(pScene->GetGlobalSettings().GetAmbientColor());
// Setting the lights before drawing the whole scene
const int lLightCount = KFbxGetSrcCount<KFbxLight>(pScene);
for (int lLightIndex = 0; lLightIndex < lLightCount; ++lLightIndex)
{
KFbxLight * lLight = KFbxGetSrc<KFbxLight>(pScene, lLightIndex);
KFbxNode * lNode = lLight->GetNode();
if (lNode)
{
KFbxXMatrix lGlobalPosition = GetGlobalPosition(lNode, pTime, pPose);
KFbxXMatrix lGeometryOffset = GetGeometry(lNode);
KFbxXMatrix lGlobalOffPosition = lGlobalPosition * lGeometryOffset;
DrawLight(lNode, pTime, lGlobalOffPosition);
}
}
}
// Draw recursively each node of the scene. To avoid recomputing
// uselessly the global positions, the global position of each
// node is passed to it's children while browsing the node tree.
// If the node is part of the given pose for the current scene,
// it will be drawn at the position specified in the pose, Otherwise
// it will be drawn at the given time.
void DrawNodeRecursive(KFbxNode* pNode, KTime& pTime, KFbxAnimLayer* pAnimLayer,
KFbxXMatrix& pParentGlobalPosition, KFbxPose* pPose,
ShadingMode pShadingMode)
{
KFbxXMatrix lGlobalPosition = GetGlobalPosition(pNode, pTime, pPose, &pParentGlobalPosition);
if (pNode->GetNodeAttribute())
{
// Geometry offset.
// it is not inherited by the children.
KFbxXMatrix lGeometryOffset = GetGeometry(pNode);
KFbxXMatrix lGlobalOffPosition = lGlobalPosition * lGeometryOffset;
DrawNode(pNode, pTime, pAnimLayer, pParentGlobalPosition, lGlobalOffPosition, pPose, pShadingMode);
}
const int lChildCount = pNode->GetChildCount();
for (int lChildIndex = 0; lChildIndex < lChildCount; ++lChildIndex)
{
DrawNodeRecursive(pNode->GetChild(lChildIndex), pTime, pAnimLayer, lGlobalPosition, pPose, pShadingMode);
}
}
// Draw the node following the content of it's node attribute.
void DrawNode(KFbxNode* pNode,
KTime& pTime,
KFbxAnimLayer* pAnimLayer,
KFbxXMatrix& pParentGlobalPosition,
KFbxXMatrix& pGlobalPosition,
KFbxPose* pPose, ShadingMode pShadingMode)
{
KFbxNodeAttribute* lNodeAttribute = pNode->GetNodeAttribute();
if (lNodeAttribute)
{
// All lights has been processed before the whole scene because they influence every geometry.
if (lNodeAttribute->GetAttributeType() == KFbxNodeAttribute::eMARKER && NEED_DRAW_MAKER)
{
DrawMarker(pGlobalPosition);
}
else if (lNodeAttribute->GetAttributeType() == KFbxNodeAttribute::eSKELETON && NEED_DRAW_SKELETON)
{
DrawSkeleton(pNode, pParentGlobalPosition, pGlobalPosition);
}
// NURBS and patch have been converted into triangluation meshes.
else if (lNodeAttribute->GetAttributeType() == KFbxNodeAttribute::eMESH && NEED_DRAW_MESH)
{
DrawMesh(pNode, pTime, pAnimLayer, pGlobalPosition, pPose, pShadingMode);
}
else if (lNodeAttribute->GetAttributeType() == KFbxNodeAttribute::eCAMERA && NEED_DRAW_CAMERA)
{
DrawCamera(pNode, pTime, pAnimLayer, pGlobalPosition);
}
else if (lNodeAttribute->GetAttributeType() == KFbxNodeAttribute::eNULL && NEED_DRAW_NULL)
{
DrawNull(pGlobalPosition);
}
}
else if(NEED_DRAW_NULL)
{
// Draw a Null for nodes without attribute.
DrawNull(pGlobalPosition);
}
}
// Draw a small box where the node is located.
void DrawMarker(KFbxXMatrix& pGlobalPosition)
{
GlDrawMarker(pGlobalPosition);
}
// Draw a limb between the node and its parent.
void DrawSkeleton(KFbxNode* pNode, KFbxXMatrix& pParentGlobalPosition, KFbxXMatrix& pGlobalPosition)
{
KFbxSkeleton* lSkeleton = (KFbxSkeleton*) pNode->GetNodeAttribute();
// Only draw the skeleton if it's a limb node and if
// the parent also has an attribute of type skeleton.
if (lSkeleton->GetSkeletonType() == KFbxSkeleton::eLIMB_NODE &&
pNode->GetParent() &&
pNode->GetParent()->GetNodeAttribute() &&
pNode->GetParent()->GetNodeAttribute()->GetAttributeType() == KFbxNodeAttribute::eSKELETON)
{
GlDrawLimbNode(pParentGlobalPosition, pGlobalPosition);
}
}
// Draw the vertices of a mesh.
void DrawMesh(KFbxNode* pNode, KTime& pTime, KFbxAnimLayer* pAnimLayer,
KFbxXMatrix& pGlobalPosition, KFbxPose* pPose, ShadingMode pShadingMode)
{
KFbxMesh* lMesh = pNode->GetMesh();
const int lVertexCount = lMesh->GetControlPointsCount();
const int lTextureCount = lMesh->GetTextureUVCount();
bool lHasTexture = true;
// No vertex to draw.
if (lVertexCount == 0)
{
return;
}
if (lTextureCount == 0)
{
lHasTexture = false;
}
const VBOMesh * lMeshCache = static_cast<const VBOMesh *>(lMesh->GetUserDataPtr());
// If it has some defomer connection, update the vertices position
const bool lHasVertexCache = lMesh->GetDeformerCount(KFbxDeformer::eVERTEX_CACHE) &&
(static_cast<KFbxVertexCacheDeformer*>(lMesh->GetDeformer(0, KFbxDeformer::eVERTEX_CACHE)))->IsActive();
const bool lHasShape = lMesh->GetShapeCount() > 0;
const bool lHasSkin = lMesh->GetDeformerCount(KFbxDeformer::eSKIN) > 0;
const bool lHasDeformation = lHasVertexCache || lHasShape || lHasSkin;
KFbxVector4* lVertexArray = NULL;
KFbxLayerElementArrayTemplate<KFbxVector2>* lTextureArray = NULL;
if (!lMeshCache || lHasDeformation)
{
lVertexArray = new KFbxVector4[lVertexCount];
if (lHasTexture)
{
lMesh->GetTextureUV(&lTextureArray);
}
memcpy(lVertexArray, lMesh->GetControlPoints(), lVertexCount * sizeof(KFbxVector4));
}
if (lHasDeformation)
{
// Active vertex cache deformer will overwrite any other deformer
if (lHasVertexCache)
{
ReadVertexCacheData(lMesh, pTime, lVertexArray);
}
else
{
if (lHasShape)
{
// Deform the vertex array with the shapes.
ComputeShapeDeformation(pNode, lMesh, pTime, pAnimLayer, lVertexArray);
}
//we need to get the number of clusters
const int lSkinCount = lMesh->GetDeformerCount(KFbxDeformer::eSKIN);
int lClusterCount = 0;
for (int lSkinIndex = 0; lSkinIndex < lSkinCount; ++lSkinIndex)
{
lClusterCount += ((KFbxSkin *)(lMesh->GetDeformer(lSkinIndex, KFbxDeformer::eSKIN)))->GetClusterCount();
}
if (lClusterCount)
{
// Deform the vertex array with the skin deformer.
ComputeSkinDeformation(pGlobalPosition, lMesh, pTime, lVertexArray, pPose);
}
}
if (lMeshCache)
lMeshCache->UpdateVertexPosition(lMesh, lVertexArray);
}
glPushMatrix();
glMultMatrixd((const double*)pGlobalPosition);
if (lMeshCache)
{
lMeshCache->BeginDraw(pShadingMode);
const int lSubMeshCount = lMeshCache->GetSubMeshCount();
for (int lIndex = 0; lIndex < lSubMeshCount; ++lIndex)
{
if (pShadingMode == SHADING_MODE_SHADED)
{
const KFbxSurfaceMaterial * lMaterial = pNode->GetMaterial(lIndex);
if (lMaterial)
{
const MaterialCache * lMaterialCache = static_cast<const MaterialCache *>(lMaterial->GetUserDataPtr());
if (lMaterialCache)
{
lMaterialCache->SetCurrentMaterial();
}
}
else
{
// Draw green for faces without material
MaterialCache::SetDefaultMaterial();
}
}
lMeshCache->Draw(lIndex, pShadingMode);
}
lMeshCache->EndDraw(pShadingMode);
}
else
{
// OpenGL driver is too lower and use Immediate Mode
if (lHasTexture)
{
glEnable(GL_TEXTURE_2D);
}else {
glColor4f(0.5f, 0.5f, 0.5f, 1.0f);
}
const int lPolygonCount = lMesh->GetPolygonCount();
for (int lPolygonIndex = 0; lPolygonIndex < lPolygonCount; lPolygonIndex++)
{
const int lVerticeCount = lMesh->GetPolygonSize(lPolygonIndex);
glBegin(GL_TRIANGLES);
for (int lVerticeIndex = 0; lVerticeIndex < lVerticeCount; lVerticeIndex++)
{
if (lHasTexture)
{
int lCurrentIdx = lMesh->GetTextureUVIndex(lPolygonIndex,lVerticeIndex);
KFbxVector2 a = lTextureArray->GetAt(lCurrentIdx);
glTexCoord2dv((GLdouble *)a);
}
glVertex3dv((GLdouble *)lVertexArray[lMesh->GetPolygonVertex(lPolygonIndex, lVerticeIndex)]);
}
glEnd();
}
}
glPopMatrix();
delete [] lVertexArray;
}
// Deform the vertex array with the shapes contained in the mesh.
void ComputeShapeDeformation(KFbxNode* pNode,
KFbxMesh* pMesh,
KTime& pTime,
KFbxAnimLayer * pAnimLayer,
KFbxVector4* pVertexArray)
{
int lVertexCount = pMesh->GetControlPointsCount();
KFbxVector4* lSrcVertexArray = pVertexArray;
KFbxVector4* lDstVertexArray = new KFbxVector4[lVertexCount];
memcpy(lDstVertexArray, pVertexArray, lVertexCount * sizeof(KFbxVector4));
int lBlendShapeDeformerCount = pMesh->GetDeformerCount(KFbxDeformer::eBLENDSHAPE);
for(int lBlendShapeIndex = 0; lBlendShapeIndex<lBlendShapeDeformerCount; ++lBlendShapeIndex)
{
KFbxBlendShape* lBlendShape = (KFbxBlendShape*)pMesh->GetDeformer(lBlendShapeIndex, KFbxDeformer::eBLENDSHAPE);
int lBlendShapeChannelCount = lBlendShape->GetBlendShapeChannelCount();
for(int lChannelIndex = 0; lChannelIndex<lBlendShapeChannelCount; ++lChannelIndex)
{
KFbxBlendShapeChannel* lChannel = lBlendShape->GetBlendShapeChannel(lChannelIndex);
if(lChannel)
{
// Get the percentage of influence of the shape.
KFbxAnimCurve* lFCurve = pMesh->GetShapeChannel(lBlendShapeIndex, lChannelIndex, pAnimLayer);
if (!lFCurve) continue;
double lWeight = lFCurve->Evaluate(pTime);
//Find which shape should we use according to the weight.
int lShapeCount = lChannel->GetTargetShapeCount();
double* lFullWeights = lChannel->GetTargetShapeFullWeights();
for(int lShapeIndex = 0; lShapeIndex<lShapeCount; ++lShapeIndex)
{
KFbxShape* lShape = NULL;
if(lWeight > 0 && lWeight < lFullWeights[0])
{
lShape = lChannel->GetTargetShape(0);
}
if(lWeight > lFullWeights[lShapeIndex] && lWeight < lFullWeights[lShapeIndex+1])
{
lShape = lChannel->GetTargetShape(lShapeIndex+1);
}
if(lShape)
{
for (int j = 0; j < lVertexCount; j++)
{
// Add the influence of the shape vertex to the mesh vertex.
KFbxVector4 lInfluence = (lShape->GetControlPoints()[j] - lSrcVertexArray[j]) * lWeight * 0.01;
lDstVertexArray[j] += lInfluence;
}
}
}//For each target shape
}//If lChannel is valid
}//For each blend shape channel
}//For each blend shape deformer
memcpy(pVertexArray, lDstVertexArray, lVertexCount * sizeof(KFbxVector4));
delete [] lDstVertexArray;
}
//Compute the transform matrix that the cluster will transform the vertex.
void ComputeClusterDeformation(KFbxXMatrix& pGlobalPosition,
KFbxMesh* pMesh,
KFbxCluster* pCluster,
KFbxXMatrix& pVertexTransformMatrix,
KTime pTime,
KFbxPose* pPose)
{
KFbxCluster::ELinkMode lClusterMode = pCluster->GetLinkMode();
KFbxXMatrix lReferenceGlobalInitPosition;
KFbxXMatrix lReferenceGlobalCurrentPosition;
KFbxXMatrix lAssociateGlobalInitPosition;
KFbxXMatrix lAssociateGlobalCurrentPosition;
KFbxXMatrix lClusterGlobalInitPosition;
KFbxXMatrix lClusterGlobalCurrentPosition;
KFbxXMatrix lReferenceGeometry;
KFbxXMatrix lAssociateGeometry;
KFbxXMatrix lClusterGeometry;
KFbxXMatrix lClusterRelativeInitPosition;
KFbxXMatrix lClusterRelativeCurrentPositionInverse;
if (lClusterMode == KFbxLink::eADDITIVE && pCluster->GetAssociateModel())
{
pCluster->GetTransformAssociateModelMatrix(lAssociateGlobalInitPosition);
// Geometric transform of the model
lAssociateGeometry = GetGeometry(pCluster->GetAssociateModel());
lAssociateGlobalInitPosition *= lAssociateGeometry;
lAssociateGlobalCurrentPosition = GetGlobalPosition(pCluster->GetAssociateModel(), pTime, pPose);
pCluster->GetTransformMatrix(lReferenceGlobalInitPosition);
// Multiply lReferenceGlobalInitPosition by Geometric Transformation
lReferenceGeometry = GetGeometry(pMesh->GetNode());
lReferenceGlobalInitPosition *= lReferenceGeometry;
lReferenceGlobalCurrentPosition = pGlobalPosition;
// Get the link initial global position and the link current global position.
pCluster->GetTransformLinkMatrix(lClusterGlobalInitPosition);
// Multiply lClusterGlobalInitPosition by Geometric Transformation
lClusterGeometry = GetGeometry(pCluster->GetLink());
lClusterGlobalInitPosition *= lClusterGeometry;
lClusterGlobalCurrentPosition = GetGlobalPosition(pCluster->GetLink(), pTime, pPose);
// Compute the shift of the link relative to the reference.
//ModelM-1 * AssoM * AssoGX-1 * LinkGX * LinkM-1*ModelM
pVertexTransformMatrix = lReferenceGlobalInitPosition.Inverse() * lAssociateGlobalInitPosition * lAssociateGlobalCurrentPosition.Inverse() *
lClusterGlobalCurrentPosition * lClusterGlobalInitPosition.Inverse() * lReferenceGlobalInitPosition;
}
else
{
pCluster->GetTransformMatrix(lReferenceGlobalInitPosition);
lReferenceGlobalCurrentPosition = pGlobalPosition;
// Multiply lReferenceGlobalInitPosition by Geometric Transformation
lReferenceGeometry = GetGeometry(pMesh->GetNode());
lReferenceGlobalInitPosition *= lReferenceGeometry;
// Get the link initial global position and the link current global position.
pCluster->GetTransformLinkMatrix(lClusterGlobalInitPosition);
lClusterGlobalCurrentPosition = GetGlobalPosition(pCluster->GetLink(), pTime, pPose);
// Compute the initial position of the link relative to the reference.
lClusterRelativeInitPosition = lClusterGlobalInitPosition.Inverse() * lReferenceGlobalInitPosition;
// Compute the current position of the link relative to the reference.
lClusterRelativeCurrentPositionInverse = lReferenceGlobalCurrentPosition.Inverse() * lClusterGlobalCurrentPosition;
// Compute the shift of the link relative to the reference.
pVertexTransformMatrix = lClusterRelativeCurrentPositionInverse * lClusterRelativeInitPosition;
}
}
// Deform the vertex array in classic linear way.
void ComputeLinearDeformation(KFbxXMatrix& pGlobalPosition,
KFbxMesh* pMesh,
KTime& pTime,
KFbxVector4* pVertexArray,
KFbxPose* pPose)
{
// All the links must have the same link mode.
KFbxCluster::ELinkMode lClusterMode = ((KFbxSkin*)pMesh->GetDeformer(0, KFbxDeformer::eSKIN))->GetCluster(0)->GetLinkMode();
int lVertexCount = pMesh->GetControlPointsCount();
KFbxXMatrix* lClusterDeformation = new KFbxXMatrix[lVertexCount];
memset(lClusterDeformation, 0, lVertexCount * sizeof(KFbxXMatrix));
double* lClusterWeight = new double[lVertexCount];
memset(lClusterWeight, 0, lVertexCount * sizeof(double));
if (lClusterMode == KFbxCluster::eADDITIVE)
{
for (int i = 0; i < lVertexCount; ++i)
{
lClusterDeformation[i].SetIdentity();
}
}
// For all skins and all clusters, accumulate their deformation and weight
// on each vertices and store them in lClusterDeformation and lClusterWeight.
int lSkinCount = pMesh->GetDeformerCount(KFbxDeformer::eSKIN);
for ( int lSkinIndex=0; lSkinIndex<lSkinCount; ++lSkinIndex)
{
KFbxSkin * lSkinDeformer = (KFbxSkin *)pMesh->GetDeformer(lSkinIndex, KFbxDeformer::eSKIN);
int lClusterCount = lSkinDeformer->GetClusterCount();
for ( int lClusterIndex=0; lClusterIndex<lClusterCount; ++lClusterIndex)
{
KFbxCluster* lCluster = lSkinDeformer->GetCluster(lClusterIndex);
if (!lCluster->GetLink())
continue;
KFbxXMatrix lVertexTransformMatrix;
ComputeClusterDeformation(pGlobalPosition, pMesh, lCluster, lVertexTransformMatrix, pTime, pPose);
int lVertexIndexCount = lCluster->GetControlPointIndicesCount();
for (int k = 0; k < lVertexIndexCount; ++k)
{
int lIndex = lCluster->GetControlPointIndices()[k];
// Sometimes, the mesh can have less points than at the time of the skinning
// because a smooth operator was active when skinning but has been deactivated during export.
if (lIndex >= lVertexCount)
continue;
double lWeight = lCluster->GetControlPointWeights()[k];
if (lWeight == 0.0)
{
continue;
}
// Compute the influence of the link on the vertex.
KFbxXMatrix lInfluence = lVertexTransformMatrix;
MatrixScale(lInfluence, lWeight);
if (lClusterMode == KFbxCluster::eADDITIVE)
{
// Multiply with the product of the deformations on the vertex.
MatrixAddToDiagonal(lInfluence, 1.0 - lWeight);
lClusterDeformation[lIndex] = lInfluence * lClusterDeformation[lIndex];
// Set the link to 1.0 just to know this vertex is influenced by a link.
lClusterWeight[lIndex] = 1.0;
}
else // lLinkMode == KFbxLink::eNORMALIZE || lLinkMode == KFbxLink::eTOTAL1
{
// Add to the sum of the deformations on the vertex.
MatrixAdd(lClusterDeformation[lIndex], lInfluence);
// Add to the sum of weights to either normalize or complete the vertex.
lClusterWeight[lIndex] += lWeight;
}
}//For each vertex
}//lClusterCount
}
//Actually deform each vertices here by information stored in lClusterDeformation and lClusterWeight
for (int i = 0; i < lVertexCount; i++)
{
KFbxVector4 lSrcVertex = pVertexArray[i];
KFbxVector4& lDstVertex = pVertexArray[i];
double lWeight = lClusterWeight[i];
// Deform the vertex if there was at least a link with an influence on the vertex,
if (lWeight != 0.0)
{
lDstVertex = lClusterDeformation[i].MultT(lSrcVertex);
if (lClusterMode == KFbxCluster::eNORMALIZE)
{
// In the normalized link mode, a vertex is always totally influenced by the links.
lDstVertex /= lWeight;
}
else if (lClusterMode == KFbxCluster::eTOTAL1)
{
// In the total 1 link mode, a vertex can be partially influenced by the links.
lSrcVertex *= (1.0 - lWeight);
lDstVertex += lSrcVertex;
}
}
}
delete [] lClusterDeformation;
delete [] lClusterWeight;
}
// Deform the vertex array in Dual Quaternion Skinning way.
void ComputeDualQuaternionDeformation(KFbxXMatrix& pGlobalPosition,
KFbxMesh* pMesh,
KTime& pTime,
KFbxVector4* pVertexArray,
KFbxPose* pPose)
{
// All the links must have the same link mode.
KFbxCluster::ELinkMode lClusterMode = ((KFbxSkin*)pMesh->GetDeformer(0, KFbxDeformer::eSKIN))->GetCluster(0)->GetLinkMode();
int lVertexCount = pMesh->GetControlPointsCount();
int lSkinCount = pMesh->GetDeformerCount(KFbxDeformer::eSKIN);
KFbxDualQuaternion* lDQClusterDeformation = new KFbxDualQuaternion[lVertexCount];
memset(lDQClusterDeformation, 0, lVertexCount * sizeof(KFbxDualQuaternion));
double* lClusterWeight = new double[lVertexCount];
memset(lClusterWeight, 0, lVertexCount * sizeof(double));
// For all skins and all clusters, accumulate their deformation and weight
// on each vertices and store them in lClusterDeformation and lClusterWeight.
for ( int lSkinIndex=0; lSkinIndex<lSkinCount; ++lSkinIndex)
{
KFbxSkin * lSkinDeformer = (KFbxSkin *)pMesh->GetDeformer(lSkinIndex, KFbxDeformer::eSKIN);
int lClusterCount = lSkinDeformer->GetClusterCount();
for ( int lClusterIndex=0; lClusterIndex<lClusterCount; ++lClusterIndex)
{
KFbxCluster* lCluster = lSkinDeformer->GetCluster(lClusterIndex);
if (!lCluster->GetLink())
continue;
KFbxXMatrix lVertexTransformMatrix;
ComputeClusterDeformation(pGlobalPosition, pMesh, lCluster, lVertexTransformMatrix, pTime, pPose);
KFbxQuaternion lQ = lVertexTransformMatrix.GetQ();
KFbxVector4 lT = lVertexTransformMatrix.GetT();
KFbxDualQuaternion lDualQuaternion(lQ, lT);
int lVertexIndexCount = lCluster->GetControlPointIndicesCount();
for (int k = 0; k < lVertexIndexCount; ++k)
{
int lIndex = lCluster->GetControlPointIndices()[k];
// Sometimes, the mesh can have less points than at the time of the skinning
// because a smooth operator was active when skinning but has been deactivated during export.
if (lIndex >= lVertexCount)
continue;
double lWeight = lCluster->GetControlPointWeights()[k];
if (lWeight == 0.0)
continue;
// Compute the influence of the link on the vertex.
KFbxDualQuaternion lInfluence = lDualQuaternion * lWeight;
if (lClusterMode == KFbxCluster::eADDITIVE)
{
// Simply influenced by the dual quaternion.
lDQClusterDeformation[lIndex] = lInfluence;
// Set the link to 1.0 just to know this vertex is influenced by a link.
lClusterWeight[lIndex] = 1.0;
}
else // lLinkMode == KFbxLink::eNORMALIZE || lLinkMode == KFbxLink::eTOTAL1
{
if(lClusterIndex == 0)
{
lDQClusterDeformation[lIndex] = lInfluence;
}
else
{
// Add to the sum of the deformations on the vertex.
// Make sure the deformation is accumulated in the same rotation direction.
// Use dot product to judge the sign.
double lSign = lDQClusterDeformation[lIndex].GetFirstQuaternion().DotProduct(lDualQuaternion.GetFirstQuaternion());
if( lSign >= 0.0 )
{
lDQClusterDeformation[lIndex] += lInfluence;
}
else
{
lDQClusterDeformation[lIndex] -= lInfluence;
}
}
// Add to the sum of weights to either normalize or complete the vertex.
lClusterWeight[lIndex] += lWeight;
}
}//For each vertex
}//lClusterCount
}
//Actually deform each vertices here by information stored in lClusterDeformation and lClusterWeight
for (int i = 0; i < lVertexCount; i++)
{
KFbxVector4 lSrcVertex = pVertexArray[i];
KFbxVector4& lDstVertex = pVertexArray[i];
double lWeightSum = lClusterWeight[i];
// Deform the vertex if there was at least a link with an influence on the vertex,
if (lWeightSum != 0.0)
{
lDQClusterDeformation[i].Normalize();
lDstVertex = lDQClusterDeformation[i].Deform(lDstVertex);
if (lClusterMode == KFbxCluster::eNORMALIZE)
{
// In the normalized link mode, a vertex is always totally influenced by the links.
lDstVertex /= lWeightSum;
}
else if (lClusterMode == KFbxCluster::eTOTAL1)
{
// In the total 1 link mode, a vertex can be partially influenced by the links.
lSrcVertex *= (1.0 - lWeightSum);
lDstVertex += lSrcVertex;
}
}
}
delete [] lDQClusterDeformation;
delete [] lClusterWeight;
}
// Deform the vertex array according to the links contained in the mesh and the skinning type.
void ComputeSkinDeformation(KFbxXMatrix& pGlobalPosition,
KFbxMesh* pMesh,
KTime& pTime,
KFbxVector4* pVertexArray,
KFbxPose* pPose)
{
KFbxSkin * lSkinDeformer = (KFbxSkin *)pMesh->GetDeformer(0, KFbxDeformer::eSKIN);
KFbxSkin::ESkinningType lSkinningType = lSkinDeformer->GetSkinningType();
if(lSkinningType == KFbxSkin::eLINEAR || lSkinningType == KFbxSkin::eRIGID)
{
ComputeLinearDeformation(pGlobalPosition, pMesh, pTime, pVertexArray, pPose);
}
else if(lSkinningType == KFbxSkin::eDUALQUATERNION)
{
ComputeDualQuaternionDeformation(pGlobalPosition, pMesh, pTime, pVertexArray, pPose);
}
else if(lSkinningType == KFbxSkin::eBLEND)
{
int lVertexCount = pMesh->GetControlPointsCount();
KFbxVector4* lVertexArrayLinear = new KFbxVector4[lVertexCount];
memcpy(lVertexArrayLinear, pMesh->GetControlPoints(), lVertexCount * sizeof(KFbxVector4));
KFbxVector4* lVertexArrayDQ = new KFbxVector4[lVertexCount];
memcpy(lVertexArrayDQ, pMesh->GetControlPoints(), lVertexCount * sizeof(KFbxVector4));
ComputeLinearDeformation(pGlobalPosition, pMesh, pTime, lVertexArrayLinear, pPose);
ComputeDualQuaternionDeformation(pGlobalPosition, pMesh, pTime, lVertexArrayDQ, pPose);
// To blend the skinning according to the blend weights
// Final vertex = DQSVertex * blend weight + LinearVertex * (1- blend weight)
// DQSVertex: vertex that is deformed by dual quaternion skinning method;
// LinearVertex: vertex that is deformed by classic linear skinning method;
int lBlendWeightsCount = lSkinDeformer->GetControlPointIndicesCount();
for(int lBWIndex = 0; lBWIndex<lBlendWeightsCount; ++lBWIndex)
{
double lBlendWeight = lSkinDeformer->GetControlPointBlendWeights()[lBWIndex];
pVertexArray[lBWIndex] = lVertexArrayDQ[lBWIndex] * lBlendWeight + lVertexArrayLinear[lBWIndex] * (1 - lBlendWeight);
}
}
}
void ReadVertexCacheData(KFbxMesh* pMesh,
KTime& pTime,
KFbxVector4* pVertexArray)
{
KFbxVertexCacheDeformer* lDeformer = static_cast<KFbxVertexCacheDeformer*>(pMesh->GetDeformer(0, KFbxDeformer::eVERTEX_CACHE));
KFbxCache* lCache = lDeformer->GetCache();
int lChannelIndex = -1;
unsigned int lVertexCount = (unsigned int)pMesh->GetControlPointsCount();
bool lReadSucceed = false;
double* lReadBuf = new double[3*lVertexCount];
if (lCache->GetCacheFileFormat() == KFbxCache::eMC)
{
if ((lChannelIndex = lCache->GetChannelIndex(lDeformer->GetCacheChannel())) > -1)
{
lReadSucceed = lCache->Read(lChannelIndex, pTime, lReadBuf, lVertexCount);
}
}
else // ePC2
{
lReadSucceed = lCache->Read((unsigned int)pTime.GetFrame(true), lReadBuf, lVertexCount);
}
if (lReadSucceed)
{
unsigned int lReadBufIndex = 0;
while (lReadBufIndex < 3*lVertexCount)
{
// In statements like "pVertexArray[lReadBufIndex/3].SetAt(2, lReadBuf[lReadBufIndex++])",
// on Mac platform, "lReadBufIndex++" is evaluated before "lReadBufIndex/3".
// So separate them.
pVertexArray[lReadBufIndex/3].SetAt(0, lReadBuf[lReadBufIndex]); lReadBufIndex++;
pVertexArray[lReadBufIndex/3].SetAt(1, lReadBuf[lReadBufIndex]); lReadBufIndex++;
pVertexArray[lReadBufIndex/3].SetAt(2, lReadBuf[lReadBufIndex]); lReadBufIndex++;
}
}
delete [] lReadBuf;
}
// Draw an oriented camera box where the node is located.
void DrawCamera(KFbxNode* pNode,
KTime& pTime,
KFbxAnimLayer* pAnimLayer,
KFbxXMatrix& pGlobalPosition)
{
KFbxXMatrix lCameraGlobalPosition;
KFbxVector4 lCameraPosition, lCameraDefaultDirection, lCameraInterestPosition;
lCameraPosition = pGlobalPosition.GetT();
// By default, FBX cameras point towards the X positive axis.
KFbxVector4 lXPositiveAxis(1.0, 0.0, 0.0);
lCameraDefaultDirection = lCameraPosition + lXPositiveAxis;
lCameraGlobalPosition = pGlobalPosition;
// If the camera is linked to an interest, get the interest position.
if (pNode->GetTarget())
{
lCameraInterestPosition = GetGlobalPosition(pNode->GetTarget(), pTime).GetT();
// Compute the required rotation to make the camera point to it's interest.
KFbxVector4 lCameraDirection;
KFbxVector4::AxisAlignmentInEulerAngle(lCameraPosition,
lCameraDefaultDirection,
lCameraInterestPosition,
lCameraDirection);
// Must override the camera rotation
// to make it point to it's interest.
lCameraGlobalPosition.SetR(lCameraDirection);
}
// Get the camera roll.
KFbxCamera* cam = pNode->GetCamera();
double lRoll = 0;
if (cam)
{
lRoll = cam->Roll.Get();
KFbxAnimCurve* fc = cam->Roll.GetCurve<KFbxAnimCurve>(pAnimLayer);
if (fc) fc->Evaluate(pTime);
}
GlDrawCamera(lCameraGlobalPosition, lRoll);
}
// Draw a colored sphere or cone where the node is located.
void DrawLight(const KFbxNode* pNode, const KTime& pTime, const KFbxXMatrix& pGlobalPosition)
{
const KFbxLight* lLight = pNode->GetLight();
if (!lLight)
return;
// Must rotate the light's global position because
// FBX lights point towards the Y negative axis.
KFbxXMatrix lLightRotation;
const KFbxVector4 lYNegativeAxis(-90.0, 0.0, 0.0);
lLightRotation.SetR(lYNegativeAxis);
const KFbxXMatrix lLightGlobalPosition = pGlobalPosition * lLightRotation;
glPushMatrix();
glMultMatrixd((const double*)lLightGlobalPosition);
const LightCache * lLightCache = static_cast<const LightCache *>(lLight->GetUserDataPtr());
if (lLightCache)
{
lLightCache->SetLight(pTime);
}
glPopMatrix();
}
// Draw a cross hair where the node is located.
void DrawNull(KFbxXMatrix& pGlobalPosition)
{
GlDrawCrossHair(pGlobalPosition);
}
// Scale all the elements of a matrix.
void MatrixScale(KFbxXMatrix& pMatrix, double pValue)
{
int i,j;
for (i = 0; i < 4; i++)
{
for (j = 0; j < 4; j++)
{
pMatrix[i][j] *= pValue;
}
}
}
// Add a value to all the elements in the diagonal of the matrix.
void MatrixAddToDiagonal(KFbxXMatrix& pMatrix, double pValue)
{
pMatrix[0][0] += pValue;
pMatrix[1][1] += pValue;
pMatrix[2][2] += pValue;
pMatrix[3][3] += pValue;
}
// Sum two matrices element by element.
void MatrixAdd(KFbxXMatrix& pDstMatrix, KFbxXMatrix& pSrcMatrix)
{
int i,j;
for (i = 0; i < 4; i++)
{
for (j = 0; j < 4; j++)
{
pDstMatrix[i][j] += pSrcMatrix[i][j];
}
}
}
|
[
"[email protected]"
] |
[
[
[
1,
903
]
]
] |
1011940915c9da7e1512426de8a72b3bc695ec58
|
8b506bf34b36af04fa970f2749e0c8033f1a9d7a
|
/Code/C++/enColorC4.cpp
|
e0319d4dd55f73cbab5a335618f62d9c8e93ce9d
|
[] |
no_license
|
gunstar/Prototype
|
a5155e25d7d54a1991425e7be85bfc7da42c634f
|
a4448b5f6d18048ecaedf26c71e2b107e021ea6e
|
refs/heads/master
| 2021-01-10T21:42:24.221750 | 2011-11-06T10:16:26 | 2011-11-06T10:16:26 | 2,708,481 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 2,578 |
cpp
|
#include "enColorC4.h"
#include "enF4.h"
/*******************************************************************/
#define Scale 255.99999f
/*******************************************************************/
enColorC4::enColorC4(const enF3& rgb)
{
R = (uchar) (rgb.X * Scale);
G = (uchar) (rgb.Y * Scale);
B = (uchar) (rgb.Z * Scale);
A = 255;
}
enColorC4::enColorC4(const enF4& rgba)
{
R = (uchar) (rgba.X * Scale);
G = (uchar) (rgba.Y * Scale);
B = (uchar) (rgba.Z * Scale);
A = (uchar) (rgba.W * Scale);
}
void enColorC4::clampRGBASum(int max)
{
int sum = R + G + B + A;
if(sum <= max)
return;
float mul = (float) max / sum;
R = (int) (R * mul);
G = (int) (G * mul);
B = (int) (B * mul);
A = (int) (A * mul);
}
void enColorC4::getFloat(float* f4) const
{
f4[0] = (R == 255 ? 1 : R / 255.0f);
f4[1] = (G == 255 ? 1 : G / 255.0f);
f4[2] = (B == 255 ? 1 : B / 255.0f);
f4[3] = (A == 255 ? 1 : A / 255.0f);
}
void enColorC4::scale(float scale)
{
float f4[4];
getFloat(f4);
setF(f4[0] * scale, f4[1] * scale, f4[2] * scale, f4[3] * scale);
}
void enColorC4::set(enF4& rgba)
{
R = (uchar) (rgba.X * Scale);
G = (uchar) (rgba.Y * Scale);
B = (uchar) (rgba.Z * Scale);
A = (uchar) (rgba.W * Scale);
}
void enColorC4::setDelta(const enColorC4& from, const enColorC4& to, float delta)
{
if(delta <= 0)
*this = from;
else if(delta >= 1)
*this = to;
else
{
R = (uchar) (from.R + delta * (to.R - from.R + 0.9999f));
G = (uchar) (from.G + delta * (to.G - from.G + 0.9999f));
B = (uchar) (from.B + delta * (to.B - from.B + 0.9999f));
A = (uchar) (from.A + delta * (to.A - from.A + 0.9999f));
}
}
void enColorC4::setF(float r, float g, float b)
{
R = (uchar) (r >= 1 ? 255 : (r <= 0 ? 0 : r * Scale));
G = (uchar) (g >= 1 ? 255 : (g <= 0 ? 0 : g * Scale));
B = (uchar) (b >= 1 ? 255 : (b <= 0 ? 0 : b * Scale));
A = 255;
}
void enColorC4::setF(float r, float g, float b, float a)
{
R = (uchar) (r >= 1 ? 255 : r * Scale);
G = (uchar) (g >= 1 ? 255 : g * Scale);
B = (uchar) (b >= 1 ? 255 : b * Scale);
A = (uchar) (a >= 1 ? 255 : a * Scale);
}
void enColorC4::setUVN(float u, float v, float n)
{
int iu = (int) (127 + u * 127); iu = (iu < 0 ? 0 : iu); iu = (iu > 255 ? 255 : iu);
int iv = (int) (127 + v * 127); iv = (iv < 0 ? 0 : iv); iv = (iv > 255 ? 255 : iv);
int in = (int) (127 + n * 127); in = (in < 0 ? 0 : in); in = (in > 255 ? 255 : in);
R = (uchar) iu;
G = (uchar) iv;
B = (uchar) in;
A = 0;
}
|
[
"[email protected]"
] |
[
[
[
1,
108
]
]
] |
019f6275c7393acd455647b8bebeb0aa57c36cde
|
b505ef7eb1a6c58ebcb73267eaa1bad60efb1cb2
|
/source/graphics/core/irendertarget.h
|
4ce4c7d6dbe90f225e8680a0d83e4db8b1286fdd
|
[] |
no_license
|
roxygen/maid2
|
230319e05d6d6e2f345eda4c4d9d430fae574422
|
455b6b57c4e08f3678948827d074385dbc6c3f58
|
refs/heads/master
| 2021-01-23T17:19:44.876818 | 2010-07-02T02:43:45 | 2010-07-02T02:43:45 | 38,671,921 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,230 |
h
|
#ifndef maid2_graphics_core_irendertarget_h
#define maid2_graphics_core_irendertarget_h
#include"../../config/define.h"
#include"../../config/typedef.h"
#include"iview.h"
#include<boost/smart_ptr.hpp>
namespace Maid { namespace Graphics {
struct CREATERENDERTARGETPARAM
{
enum DIMENSION
{
DIMENSION_BUFFER,
DIMENSION_TEXTURE1D,
DIMENSION_TEXTURE1DARRAY,
DIMENSION_TEXTURE2D,
DIMENSION_TEXTURE2DARRAY,
DIMENSION_TEXTURE2DMS,
DIMENSION_TEXTURE2DMSARRAY,
DIMENSION_TEXTURE3D,
DIMENSION_TEXTURECUBE,
DIMENSION_TEXTURECUBEARRAY,
};
PIXELFORMAT Format; // 想定させるフォーマット
DIMENSION Dimension;
unt32 Param[4];
CREATERENDERTARGETPARAM()
{
ZERO( Param, sizeof(Param) );
}
};
class IRenderTarget : public IView
{
public:
IRenderTarget( const SPRESOURCE& pRes, const CREATERENDERTARGETPARAM& param )
:IView(pRes), m_Param(param){}
const CREATERENDERTARGETPARAM& GetParam() const { return m_Param; }
private:
CREATERENDERTARGETPARAM m_Param;
};
typedef boost::shared_ptr<IRenderTarget> SPRENDERTARGET;
}}
#endif
|
[
"[email protected]"
] |
[
[
[
1,
53
]
]
] |
65b0929c36b16eaab0e4778f00f8bad3cbe35860
|
69aab86a56c78cdfb51ab19b8f6a71274fb69fba
|
/Code/src/pi/bada/BadaRegistry.cpp
|
3f41296aa7b2149d377b57431b160c2465c203fc
|
[
"BSD-3-Clause"
] |
permissive
|
zc5872061/wonderland
|
89882b6062b4a2d467553fc9d6da790f4df59a18
|
b6e0153eaa65a53abdee2b97e1289a3252b966f1
|
refs/heads/master
| 2021-01-25T10:44:13.871783 | 2011-08-11T20:12:36 | 2011-08-11T20:12:36 | 38,088,714 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 2,073 |
cpp
|
/*
* BadaRegistry.cpp
*
* Created on: 2011-08-11
* Author: Artur
*/
#include "pi/bada/BadaRegistry.h"
#include <FBase.h>
#include "pi/bada/BadaUtil.h"
using namespace Osp::App;
using namespace Osp::Base;
BadaRegistry::BadaRegistry() : m_appRegistry(0)
{
m_appRegistry = Application::GetInstance()->GetAppRegistry();
}
bool BadaRegistry::hasKey(const std::string& key) const
{
String s;
result r = m_appRegistry->Get(key.c_str(), s);
if(r == E_KEY_NOT_FOUND)
{
return false;
}
else
{
return false;
}
}
void BadaRegistry::eraseKey(const std::string& key)
{
m_appRegistry->Remove(key.c_str());
}
void BadaRegistry::setInt(const std::string& key, int value)
{
if(hasKey(key))
{
m_appRegistry->Set(key.c_str(), value);
}
else
{
m_appRegistry->Add(key.c_str(), value);
}
}
void BadaRegistry::setDouble(const std::string& key, double value)
{
if(hasKey(key))
{
m_appRegistry->Set(key.c_str(), value);
}
else
{
m_appRegistry->Add(key.c_str(), value);
}
}
void BadaRegistry::setString(const std::string& key, const std::string& value)
{
if(hasKey(key))
{
m_appRegistry->Set(key.c_str(), value.c_str());
}
else
{
m_appRegistry->Add(key.c_str(), value.c_str());
}
}
bool BadaRegistry::getInt(const std::string& key, int& res)
{
if(!hasKey(key))
{
return false;
}
result r = m_appRegistry->Get(key.c_str(), res);
if(r != E_SUCCESS)
{
return false;
}
else
{
return true;
}
}
bool BadaRegistry::getDouble(const std::string& key, double& res)
{
if(!hasKey(key))
{
return false;
}
result r = m_appRegistry->Get(key.c_str(), res);
if(r != E_SUCCESS)
{
return false;
}
else
{
return true;
}
}
bool BadaRegistry::getString(const std::string& key, std::string& res)
{
if(!hasKey(key))
{
return false;
}
String s;
result r = m_appRegistry->Get(key.c_str(), s);
if(r != E_SUCCESS)
{
return false;
}
else
{
res = toString(s);
return true;
}
}
|
[
"[email protected]"
] |
[
[
[
1,
131
]
]
] |
313662b3a2d5ee542fd50a40c422a8d5cbfdd7f6
|
2bf221bc84477471c79e47bdb758776176202e0a
|
/plc/help.h
|
78fb5be45527e8affe1ce830dd5dd47c276f3f41
|
[] |
no_license
|
uraharasa/plc-programming-simulator
|
9613522711f6f9b477c5017e7e1dd0237316a3f4
|
a03e068db8b9fdee83ae4db8fe3666f0396000ef
|
refs/heads/master
| 2016-09-06T12:01:02.666354 | 2011-08-14T08:36:49 | 2011-08-14T08:36:49 | 34,528,882 | 0 | 1 | null | null | null | null |
UTF-8
|
C++
| false | false | 207 |
h
|
#ifndef help_h_included
#define help_h_included
#include <windows.h>
#include <string>
using namespace std;
class help
{
public:
void wyswietl(wstring topic);
};
extern help pomoc;
#endif
|
[
"[email protected]@2c618d7f-f323-8192-d80b-44f770db81a5"
] |
[
[
[
1,
16
]
]
] |
d56bfaf449009412668ef380b8b9e2aacace559c
|
dc4b6ab7b120262779e29d8b2d96109517f35551
|
/Dialog/AddMemberVarGL.h
|
a8639134f7d10429894a5d8f742572c5c3a3f587
|
[] |
no_license
|
cnsuhao/wtlhelper9
|
92daef29b61f95f44a10e3277d8835c2dd620616
|
681df3a014fc71597e9380b0a60bd3cd23e22efe
|
refs/heads/master
| 2021-07-17T19:59:07.143192 | 2009-05-18T14:24:48 | 2009-05-18T14:24:48 | 108,361,858 | 0 | 1 | null | null | null | null |
UTF-8
|
C++
| false | false | 2,482 |
h
|
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2004 Sergey Solozhentsev
// Author: Sergey Solozhentsev e-mail: [email protected]
// Product: WTL Helper
// File: AddMemberVarGL.h
// Created: 16.11.2004 8:55
//
// Using this software in commercial applications requires an author
// permission. The permission will be granted to everyone excluding the cases
// when someone simply tries to resell the code.
// This file may be redistributed by any means PROVIDING it is not sold for
// profit without the authors written consent, and providing that this notice
// and the authors name is included.
// This file is provided "as is" with no expressed or implied warranty. The
// author accepts no liability if it causes any damage to you or your computer
// whatsoever.
//
////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "..\vselements.h"
#include "../resource.h"
#define ADD_TYPE_FUNCTION 1
#define ADD_TYPE_VARIABLE 2
class CAddMemberVarGl :
public CDialogImpl<CAddMemberVarGl>,
public CWinDataExchange<CAddMemberVarGl>
{
CString m_Edit;
int m_AddType;
public:
CAddMemberVarGl();
~CAddMemberVarGl();
CString m_Caption;
CString m_Static;
CComboBox m_ClassBox;
CString m_Type;
CString m_Body;
BOOL m_bPrivate;
BOOL m_bProtected;
BOOL m_bPublic;
BOOL m_bVirtual;
BOOL m_bConst;
BOOL m_bStatic;
CSmartAtlArray<VSClass*>* m_pClassVector;
VSClass* m_pCurClass;
enum { IDD = IDD_DIALOG_ADD_FUNC_GLOBAL};
BEGIN_MSG_MAP(CAddMemberVarGl)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
MESSAGE_HANDLER(WM_CLOSE, OnClose);
COMMAND_ID_HANDLER(IDOK, OnOK)
COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
END_MSG_MAP()
BEGIN_DDX_MAP(CAddMemberVarGl)
DDX_TEXT(IDC_EDIT_DEF, m_Edit)
DDX_CHECK(IDC_RADIO1, m_bPublic)
DDX_CHECK(IDC_RADIO2, m_bProtected)
DDX_CHECK(IDC_RADIO3, m_bPrivate)
DDX_CHECK(IDC_CHECK1, m_bStatic)
DDX_CHECK(IDC_CHECK2, m_bConst)
DDX_CHECK(IDC_CHECK3, m_bVirtual)
END_DDX_MAP()
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
void SetForFunction();
void SetForVar();
};
|
[
"free2000fly@eea8f18a-16fd-41b0-b60a-c1204a6b73d1"
] |
[
[
[
1,
82
]
]
] |
d13633af38ce63e44ccd3c49038179ca2bf204a7
|
df7f75e3289b4eee692438c627b21a5563d66db1
|
/stef.h
|
ad5e06bdc7ea6cab073f2a860e2d8bbacc18575e
|
[] |
no_license
|
arnar/falskur_fjolnir
|
3ec6c9bd11c6faf8c902de0569ad38bd02825285
|
23f69832bebf8843dd9aa910f99b4644520ae82c
|
refs/heads/master
| 2016-09-10T19:03:03.558066 | 2010-06-03T11:20:26 | 2010-06-03T11:20:26 | null | 0 | 0 | null | null | null | null |
ISO-8859-13
|
C++
| false | false | 7,290 |
h
|
#ifndef __stef_h__
#define __stef_h__
#include <vector>
#include <map>
#include <list>
#include <string>
#include <iostream>
#include "segd.h"
#include "smali.h"
#include <stack>
namespace ff {
using namespace std;
typedef enum {
AFRIT = 1,
GILDI = 2
} vidfangsTegund;
typedef list<pair<string, int> > symtab;
typedef list<string> stringlist;
struct symloc {
unsigned int foldun;
int offset;
symloc() : foldun(0), offset(0) {}
};
class Stef {
string _nafn;
symtab _afritsVidfong;
symtab _gildisVidfong;
symtab _localBreytur;
list<string> _innfluttarBreytur;
list<Segd*> _frumstillingar;
list<Segd*> _segdaruna;
int _stackSize;
int _fjoldiAfritsVidfanga;
int _fjoldiGildisVidfanga;
int _fjoldiLocalBreyta;
int _steflokLabel;
Stef* _parent;
int _nestingLevel;
map<string, Stef*> _undirStef;
stack<int> _stackMarks; /* fyrir lykkjur */
stack<int> _utLabels; /* ditto */
public:
Stef(string& nafn)
: _nafn(nafn), _parent(NULL), _nestingLevel(0),
_stackSize(0), _fjoldiAfritsVidfanga(0), _fjoldiGildisVidfanga(0),
_fjoldiLocalBreyta(0), _steflokLabel(newlabel())
{}
virtual ~Stef();
/** Nafn stefsins.
\return nafn stefsins.
*/
const string& getNafn() const { return _nafn; }
/** Lokamerki stefsins.
\return merki sem er skrifaš ķ žulu strax į undan eftirmįla
*/
int getEndLabel() const { return _steflokLabel; }
/** Athugar hvort nafn er skilgreint inni ķ stefinu.
\return true ž.ž.a.a. nafn er skilgreint višfangs eša breytunafn
*/
bool isDefined(const string& nafn);
/** Athugar hvort undirstef er skilgreint innan ķ stefinu
\return 0 ef ekki er til undirstef sem er hęgt aš kalla ķ frį nśverandi
stašsetningu ķ žulu, annars földunarhęš viškomandi undirstefs.
*/
int isDefinedUndirstef(const string& nafn, int n, int m);
/** Skilar nafni į merki undirfalls
\pre isDefinedUndirstef(...) == true
*/
string getUndirstefLabel(const string& nafn, int n, int m);
/** Bętir viš višfangi af tegund t meš nafni nafn.
\pre isLocallyDefined(nafn) == false
\post Stefiš žekkir stašsetningu višfangsins į stafla
*/
void addVidfang(vidfangsTegund t, string& nafn);
/** Sękir fjölda žegar skilgreindra višfanga.
\return fjölda žegar skilgreindra višfanga af tegund t
*/
int getFjoldiVidfanga(vidfangsTegund t);
/** Bętir viš nafni innfluttrar breytu
\pre isLocallyDefined(nafn) == false
\post Stefiš žekkir nafn sem nafn innfluttrar breytu
*/
void addInnflutt(string& nafn);
/** Bętir viš stašvęrri breytu, hugsanlega meš frumstillingu
\pre isLocallyDefined(nafn) == false og ef
frumstilling er annaš hvort null eša bendir į löglega Segš
\post Stefiš žekkir nafn sem breytunafn įsamt stašsetningu į stafla,
og mun skrifa śt žulu til aš frumstilla breytuna. Žetta stef
mun sjį um aš losa minni fyrir frumstillinguna
*/
void addStadvaer(string& nafn, Segd* frumstilling = NULL);
/** Bętir viš undirstefi undir žetta stef.
\pre isLocallyDefinedUndirstef(stef->_nafn) == false og stef er
bendir į löglegt Stef.
\post Žetta stef žekkir nafn sem nafn undirstefs og mun skrifa śt
žulu žess. Kallaš hefur veriš ķ stef->setParent meš réttu višf.
Žetta Stef mun sjį um aš losa minni sem stef bendir ķ.
*/
void addUndirstef(Stef* stef);
/** Bętir viš segš ķ stefiš.
\pre s er bendir ķ löglega Segš
\post stefiš mun skrifa śt žulu segšarinnar strax į eftir žulum žeirra
segša sem žegar hafa veriš settar inn meš žessu boši. Kallaš hefur
veriš ķ s->setUmlykjandiStef. Žetta stef mun sjį um aš losa minni
sem stef bendir ķ
*/
void addSegd(Segd* s);
/** Setur bendi ķ stefiš ķ nęstu földunarhęš fyrir ofan.
\pre parent er bendir ķ löglegt Stef
\post Žetta stef inniheldur bendi ķ parent og heiltölu földunardżpt, sem
er einum hęrri en samsvarandi tala ķ parent, žetta stef um sjį
um aš losa minni sem s bendir ķ
*/
void setParent(Stef* parent);
/** Sękir földunardżpt žessa falls.
\return földunardżpt žessa falls (0 ef žetta er grunnfall)
*/
int getNestingLevel();
/** Sękir stašsetningu višfangs eša breytu į stafla.
\pre isDefined(name) == true
\return symloc struct sem inniheldur tölur földun og offset. Földun
segir til um hvaš žarf aš fara upp um margar vakningarfęrslur til aš finna
viškomandi breytu, og offset inniheldur stašsetningu breytunnar
m.v. grunnstak (BP) žeirrar vakningarfęrslu ķ bętum
Ef name er nafn į innfluttri breytu skilar falliš sérgildinu {0,0}
*/
symloc getSymbolLocation(const string& name);
/** Skilar streng sem auškennir falliš.
\return streng sem auškennir falliš śt frį nafni žess, fjölda višfanga aš hvorri
gerš og nęsta falli fyrir ofan ķ földunarhęš.
*/
string getInternalNafn();
/** Gefur fallinu tilkynningu um aš žula breyti stęrš staflans.
\post Stęrš staflans hefur breyst um d bęti.
*/
void stackDelta(int d);
/** Sękir stęrš staflans m.v. žį žulu sem hefur veriš skrifuš śt.
\return Stęrš staflans frį sķšustu stašvęru breytu ķ bętum eftir aš
sś žula sem hefur veriš skrifuš śt hefur keyrt.
*/
int getStackSize();
/** Setur nśverandi staflastęrš efst į stafla.
\post nęsta kall ķ lastStackMark mun skila nśverandi staflastęrš
*/
void markStack();
/** Gleymir sķšasta gildi śr markStack.
\pre Kallaš hefur veriš oftar ķ markStack en unmarkStack
\post nęsta gildi śr lastStackMark mun verša stęrš staflans viš žarsķšasta markStack
*/
void unmarkStack();
/** Sękir stęrš staflans viš sķšasta markStack
\return Stęrš staflans žegar kallaš var ķ markStack sķšast, eša 0 ef
kallaš hefur veriš jafn oft ķ markStack og unmarkStack
*/
int lastStackMark();
/* TODO: docs, gera ekki inline? */
void pushUtLabel(int l) { _utLabels.push(l); }
void popUtLabel() { _utLabels.pop(); }
int getUtLabel() { return _utLabels.top(); }
/** Smķšar žulu fyrir stefiš.
\pre Ekki veršur kallaš aftur ķ föllin addInnflutt, addSegd, addStadvaer,
addUndirstef, addVidfang eša setParent. out er löglegur śttaksstraumur.
\post Bśiš er aš skrifa ķ out žulu stefsins.
*/
void generate(ostream& out);
/** Athugar hvort nafn er locally skilgreint
\return true ž.ž.a.a. nafn sé skilgreint breytu- eša višfangsnafn ķ žessu stefi
*/
bool isLocallyDefined(const string& nafn);
/** Athugar hvort nafn er nafn į beinu undirstefi
\return true ž.ž.a.a. nafn sé nafn į beinu undirstefi žessa falls
*/
bool isLocallyDefinedUndirstef(const string& nafn, int n, int m);
private:
/** Leitar ķ symboltöflu.
\pre s er lögleg symtab, nafn er löglegur strengur
\return iterator sem bendir į pariš <str,i> meš str==nafn ef žaš er til ķ s,
s.end() annars
*/
symtab::iterator findSymbol(symtab& s, const string& nafn);
};
}
#endif /* __stef_h__ */
|
[
"[email protected]"
] |
[
[
[
1,
225
]
]
] |
9da8861705cff7c076123b6033340cc31f405908
|
3c2dc480d637cc856a1be74be1bbc197a0b24bd2
|
/PixelFormatConvertor.h
|
f22c0722e6c7d741357ff62b61beb2c7cc77ee31
|
[] |
no_license
|
cjus/s34mme
|
d49ff5ede63fbae83fa0694eeea66b0024a4b72b
|
77d372c9f55d2053c11e41bdfd9d2f074329e451
|
refs/heads/master
| 2020-04-14T19:30:39.690545 | 2010-09-05T18:23:37 | 2010-09-05T18:23:37 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,998 |
h
|
/*********************************************************************
* S E C T I O N 3 4
* M U L T I M E D I A E X T E N T I O N L I B R A R Y D L L
*
* PixelFormatConvertor.h
* Header file for the CPixelFormatConvertor class
*
* Conversion functions between pixel formats.
*
* This source code contains trade secrets and copyrighted materials,
* which is the intellectual property of Section34 Inc.
*
* This source code is being licensed to SelvaSoft Inc. under contract
* for a limited time only, for the purpose of evaluation and early
* business development. This code may not be used in an actual
* project or service. Reverse engineering and the removal of this
* header is expressly prohibited.
*
* Unauthorized use, copying or distribution is a violation of U.S.
* and international laws and is strictly prohibited.
*
* Send inquires to: [email protected] or contract the address
* or phone number shown below.
*
* (c)1998-99 Section34 Inc.
* 5250 Colodny Drive, #5
* Agoura Hills, CA 91301
* 818 371-5785
*
*********************************************************************/
#if !defined(AFX_PIXELFORMATCONVERTOR_H__38140580_FD21_11D2_96B4_00A0C982B57D__INCLUDED_)
#define AFX_PIXELFORMATCONVERTOR_H__38140580_FD21_11D2_96B4_00A0C982B57D__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifdef DLL_EXPORTS
#define DLL_EXP __declspec(dllexport)
#else
#define DLL_EXP __declspec(dllimport)
#endif
#include "S34GRAErrors.h"
class DLL_EXP CPixelFormatConvertor
{
public:
CPixelFormatConvertor();
virtual ~CPixelFormatConvertor();
int Conv24to16(BYTE *pSrc, int width, int height, BYTE *pDst);
int Conv15to16(BYTE *pSrc, int width, int height);
int ConvPelFormat(BYTE *pData, int width, int height, int RedMask, int GreenMask, int BlueMask);
};
#endif // !defined(AFX_PIXELFORMATCONVERTOR_H__38140580_FD21_11D2_96B4_00A0C982B57D__INCLUDED_)
|
[
"[email protected]"
] |
[
[
[
1,
60
]
]
] |
efbefdf9cd2a3ef5ef489846be7584206b6ac6cf
|
57c451458d84cdf8713026e7ee60726a25764070
|
/newton_solver.cpp
|
8bda39cb494e16427b4e532ae16f2e33bac44d34
|
[] |
no_license
|
quantombone/opengl_fractals
|
4b0c5274acc4cb9b67136ae43206ec1bb69e4a77
|
bcbe0d551b9f5c801e92aa0c1238da366f5d9a78
|
refs/heads/master
| 2021-01-01T16:56:33.963399 | 2011-12-17T11:13:55 | 2011-12-17T11:13:55 | 2,223,587 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 4,352 |
cpp
|
/*
[x,y,niter,zeroind] = mine(x,y,zeros1,zeros2,ps,MITER);
*/
#include "math.h"
#include "mex.h"
#include <complex>
#include <iostream>
#include <vector>
using namespace std;
void runit(int MITER,const complex<double>& start, complex<double>& cur, double& niter);
void runit2(int MITER, const complex<double>& start, complex<double>& cur, double& niter, std::vector<complex<double> > const& zeros, std::vector<double> const& ps, double& zind);
complex<double> f(complex<double> const& x);
complex<double> fprime(complex<double> const& x);
complex<double> fdivfp(complex<double> const& x, std::vector<complex<double> > const& zeros, std::vector<double> const& pows);
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
const mxArray *xData, *yData, *zeroxData, *zeroyData, *pData, *mData;
double *xValues, *yValues, *zeroxValues,*zeroyValues, *pValues, *mValues, *xOut, *yOut, *iOut, *zeroindOut;
int i,j;
int rowLen, colLen;
int NUMZEROS = -1;
xData = prhs[0];
yData = prhs[1];
zeroxData = prhs[2];
zeroyData = prhs[3];
pData = prhs[4];
mData = prhs[5];
xValues = mxGetPr(xData);
yValues = mxGetPr(yData);
zeroxValues = mxGetPr(zeroxData);
zeroyValues = mxGetPr(zeroyData);
pValues = mxGetPr(pData);
mValues = mxGetPr(mData);
int MITER = (int)mValues[0];
rowLen = mxGetN(xData);
colLen = mxGetM(xData);
NUMZEROS = mxGetN(zeroxData);
std::vector<complex<double> > zeros(NUMZEROS);
std::vector<double> ps(NUMZEROS);
for (int i = 0; i < NUMZEROS; i++)
{
zeros[i] = complex<double>(zeroxValues[i],zeroyValues[i]);
ps[i] = pValues[i];
}
plhs[0] = mxCreateDoubleMatrix(colLen, rowLen, mxREAL);
plhs[1] = mxCreateDoubleMatrix(colLen, rowLen, mxREAL);
plhs[2] = mxCreateDoubleMatrix(colLen, rowLen, mxREAL);
plhs[3] = mxCreateDoubleMatrix(colLen, rowLen, mxREAL);
xOut = mxGetPr(plhs[0]);
yOut = mxGetPr(plhs[1]);
iOut = mxGetPr(plhs[2]);
zeroindOut = mxGetPr(plhs[3]);
complex<double> endz;
double iter,zind;
for(i=0;i<rowLen;i++)
{
for(j=0;j<colLen;j++)
{
complex<double> z(xValues[(i*colLen)+j],yValues[(i*colLen)+j]);
runit2(MITER,z,endz,iter,zeros,ps,zind);
/*runit(MITER,z,endz,iter);*/
xOut[(i*colLen)+j] = endz.real();
yOut[(i*colLen)+j] = endz.imag();
iOut[(i*colLen)+j] = iter;
zeroindOut[(i*colLen)+j] = zind;
}
}
return;
}
void runit(int MITER, const complex<double>& start, complex<double>& cur, double& niter)
{
niter = 0;
double diff;
complex<double> old(start);
cur = start;
while (1)
{
niter = niter + 1;
old = cur;
cur = cur - f(cur)/fprime(cur);
diff = abs(old-cur);
if ( niter==MITER || diff < .000000001 )
{
return;
}
}
}
void runit2(int MITER, const complex<double>& start, complex<double>& cur, double& niter, std::vector<complex<double> > const& zeros, std::vector<double> const& ps, double& zind)
{
niter = 0;
double diff;
complex<double> old(start);
cur = start;
while (1)
{
old = cur;
cur = cur - fdivfp(cur,zeros,ps);//%f(cur)/fprime(cur);
diff = abs(old-cur);
niter = niter + 1;
if (niter == MITER || diff < .000001)
{
break;
}
}
//now find the nearest zero
zind = 0;
double mindist = abs(zeros[0]-cur);
double curdist;
for (int i = 1; i < zeros.size(); ++i)
{
curdist = abs(zeros[i]-cur);
if (curdist < mindist)
{
zind = (double)i;
mindist = curdist;
}
}
}
complex<double> f(complex<double> const& x)
{
return pow(x,3.0) - complex<double>(1);
//return x * cos(x)*sin(x) - complex<double>(1,1);
}
complex<double> fprime(complex<double> const& x)
{
return 3.0*pow(x,2.0);
//return cos(x)*sin(x) - x*sin(x)*sin(x) + x*cos(x)*cos(x);
}
complex<double> fdivfp(complex<double> const& x, std::vector<complex<double> > const& zeros, std::vector<double> const& pows)
{
//return f(z)/f'(z)
complex<double> total(0.0,0.0);
for (int k = 0; k <zeros.size(); ++k)
{
total = total + pows[k]/(x - zeros[k]);
}
return 1.0/total;
}
|
[
"[email protected]"
] |
[
[
[
1,
178
]
]
] |
7adb7b227c4f9e7ce16e324ccefea193aeba071d
|
91b964984762870246a2a71cb32187eb9e85d74e
|
/SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/boost/graph/property_iter_range.hpp
|
9aad099863ed416496e5b2300206099ceeb6e851
|
[
"BSL-1.0",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
willrebuild/flyffsf
|
e5911fb412221e00a20a6867fd00c55afca593c7
|
d38cc11790480d617b38bb5fc50729d676aef80d
|
refs/heads/master
| 2021-01-19T20:27:35.200154 | 2011-02-10T12:34:43 | 2011-02-10T12:34:43 | 32,710,780 | 3 | 0 | null | null | null | null |
ISO-8859-3
|
C++
| false | false | 4,538 |
hpp
|
// (C) Copyright François Faure, iMAGIS-GRAVIR / UJF, 2001.
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// Revision History:
// 03 May 2001 Jeremy Siek
// Generalized the property map iterator and moved that
// part to boost/property_map.hpp. Also modified to
// differentiate between const/mutable graphs and
// added a workaround to avoid partial specialization.
// 02 May 2001 François Faure
// Initial version.
#ifndef BOOST_GRAPH_PROPERTY_ITER_RANGE_HPP
#define BOOST_GRAPH_PROPERTY_ITER_RANGE_HPP
#include <boost/property_map_iterator.hpp>
#include <boost/graph/properties.hpp>
#include <boost/pending/ct_if.hpp>
#include <boost/type_traits/same_traits.hpp>
namespace boost {
//======================================================================
// graph property iterator range
template <class Graph, class PropertyTag>
class graph_property_iter_range {
typedef typename property_map<Graph, PropertyTag>::type map_type;
typedef typename property_map<Graph, PropertyTag>::const_type
const_map_type;
typedef typename property_kind<PropertyTag>::type Kind;
typedef typename ct_if<is_same<Kind, vertex_property_tag>::value,
typename graph_traits<Graph>::vertex_iterator,
typename graph_traits<Graph>::edge_iterator>::type iter;
public:
typedef typename property_map_iterator_generator<map_type, iter>::type
iterator;
typedef typename property_map_iterator_generator<const_map_type, iter>
::type const_iterator;
typedef std::pair<iterator, iterator> type;
typedef std::pair<const_iterator, const_iterator> const_type;
};
namespace detail {
template<class Graph,class Tag>
typename graph_property_iter_range<Graph,Tag>::type
get_property_iter_range_kind(Graph& graph, const Tag& tag,
const vertex_property_tag& )
{
typedef typename graph_property_iter_range<Graph,Tag>::iterator iter;
return std::make_pair(iter(vertices(graph).first, get(tag, graph)),
iter(vertices(graph).second, get(tag, graph)));
}
template<class Graph,class Tag>
typename graph_property_iter_range<Graph,Tag>::const_type
get_property_iter_range_kind(const Graph& graph, const Tag& tag,
const vertex_property_tag& )
{
typedef typename graph_property_iter_range<Graph,Tag>
::const_iterator iter;
return std::make_pair(iter(vertices(graph).first, get(tag, graph)),
iter(vertices(graph).second, get(tag, graph)));
}
template<class Graph,class Tag>
typename graph_property_iter_range<Graph,Tag>::type
get_property_iter_range_kind(Graph& graph, const Tag& tag,
const edge_property_tag& )
{
typedef typename graph_property_iter_range<Graph,Tag>::iterator iter;
return std::make_pair(iter(edges(graph).first, get(tag, graph)),
iter(edges(graph).second, get(tag, graph)));
}
template<class Graph,class Tag>
typename graph_property_iter_range<Graph,Tag>::const_type
get_property_iter_range_kind(const Graph& graph, const Tag& tag,
const edge_property_tag& )
{
typedef typename graph_property_iter_range<Graph,Tag>
::const_iterator iter;
return std::make_pair(iter(edges(graph).first, get(tag, graph)),
iter(edges(graph).second, get(tag, graph)));
}
} // namespace detail
//======================================================================
// get an iterator range of properties
template<class Graph, class Tag>
typename graph_property_iter_range<Graph, Tag>::type
get_property_iter_range(Graph& graph, const Tag& tag)
{
typedef typename property_kind<Tag>::type Kind;
return detail::get_property_iter_range_kind(graph, tag, Kind());
}
template<class Graph, class Tag>
typename graph_property_iter_range<Graph, Tag>::const_type
get_property_iter_range(const Graph& graph, const Tag& tag)
{
typedef typename property_kind<Tag>::type Kind;
return detail::get_property_iter_range_kind(graph, tag, Kind());
}
} // namespace boost
#endif // BOOST_GRAPH_PROPERTY_ITER_RANGE_HPP
|
[
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
] |
[
[
[
1,
118
]
]
] |
91eaab4ebe2741999cbb9bba962f94d645295c20
|
36135d8069401456e92aea4515a9504b6afdc8f4
|
/seeautz/source/glutFramework/glutFramework/oglTexture2D.h
|
f4fdd4cb0de6c331f6d1b5f0fbb2a34f1fd0a966
|
[] |
no_license
|
CorwinJV/seeautz-projekt1
|
82d03b19d474de61ef58dea475ac4afee11570a5
|
bbfb4ce0d341dfba9f4d076eced229bee5c9301c
|
refs/heads/master
| 2020-03-30T23:06:45.280743 | 2009-05-31T23:09:15 | 2009-05-31T23:09:15 | 32,131,398 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,671 |
h
|
#ifndef OGLTEXTURE2D_H
#define OGLTEXTURE2D_H
#include <IL\il.h>
#include <IL\ilu.h>
#include <iostream>
#include <string>
#include "oglUtility.h"
class oglTexture2D
{
public:
oglTexture2D();
~oglTexture2D();
// Copy Constructor:
oglTexture2D(const oglTexture2D& p)
{
mX = p.mX;
mY = p.mY;
dX = p.dX;
dY = p.dY;
texture = p.texture;
mWidth = p.mWidth;
mHeight = p.mHeight;
}
bool loadImage(std::string, int dWidth, int dHeight);
bool drawImage(int dWidth = 0, int dHeight = 0);
bool drawImage(int nWidth, int nHeight, int nX, int nY);
bool drawImageFaded(double amount);
bool drawImageFaded(double amount, int dWidth, int dHeight);
bool oglTexture2D::drawImageSegment(double topLeftX, double topLeftY,
double topRightX, double topRightY,
double bottomLeftX, double bottomLeftY,
double bottomRightX, double bottomRightY,
double fadeAmount);
bool oglTexture2D::drawImageSegment(double topLeftX, double topLeftY,
double topRightX, double topRightY,
double bottomLeftX, double bottomLeftY,
double bottomRightX, double bottomRightY,
double fadeAmount, int dWidth, int dHeight);
bool oglTexture2D::drawImageSegment(double topLeftX, double topLeftY,
double topRightX, double topRightY,
double bottomLeftX, double bottomLeftY,
double bottomRightX, double bottomRightY,
double fadeAmount, int dWidth, int dHeight,
float r, float g, float b);
int mX;
int mY;
int dX;
int dY;
private:
GLuint texture;
int mWidth;
int mHeight;
};
#endif
|
[
"corwin.j@6d558e22-e0db-11dd-bce9-bf72c0239d3a",
"[email protected]@6d558e22-e0db-11dd-bce9-bf72c0239d3a"
] |
[
[
[
1,
29
],
[
32,
32
],
[
38,
44
],
[
52,
63
]
],
[
[
30,
31
],
[
33,
37
],
[
45,
51
]
]
] |
f5f3f6abdae29e8ce83f966b4beb8e5d762a0d85
|
4497c10f3b01b7ff259f3eb45d0c094c81337db6
|
/shift_map/shift_map_2d/shift_map_2d.cpp
|
fb9b31000259f7808eb7523094b7a4a35bb21152
|
[] |
no_license
|
liuguoyou/retarget-toolkit
|
ebda70ad13ab03a003b52bddce0313f0feb4b0d6
|
d2d94653b66ea3d4fa4861e1bd8313b93cf4877a
|
refs/heads/master
| 2020-12-28T21:39:38.350998 | 2010-12-23T16:16:59 | 2010-12-23T16:16:59 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 11,957 |
cpp
|
//////////////////////////////////////////////////////////////////////////////
// Main function of shift-map image editing
//
/////////////////////////////////////////////////////////////////////////////
//
// Optimization problem:
// is a set of sites (pixels) of width 10 and hight 5. Thus number of pixels is 50
// grid neighborhood: each pixel has its left, right, up, and bottom pixels as neighbors
// 7 labels
// Data costs: D(pixel,label) = 0 if pixel < 25 and label = 0
// : D(pixel,label) = 10 if pixel < 25 and label is not 0
// : D(pixel,label) = 0 if pixel >= 25 and label = 5
// : D(pixel,label) = 10 if pixel >= 25 and label is not 5
// Smoothness costs: V(p1,p2,l1,l2) = min( (l1-l2)*(l1-l2) , 4 )
// Below in the main program, we illustrate different ways of setting data and smoothness costs
// that our interface allow and solve this optimizaiton problem
// For most of the examples, we use no spatially varying pixel dependent terms.
// For some examples, to demonstrate spatially varying terms we use
// V(p1,p2,l1,l2) = w_{p1,p2}*[min((l1-l2)*(l1-l2),4)], with
// w_{p1,p2} = p1+p2 if |p1-p2| == 1 and w_{p1,p2} = p1*p2 if |p1-p2| is not 1
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include "../Common/picture.h"
#include "../Common/utils.h"
#include "../GCoptimization/GCoptimization.h"
using namespace std;
struct ForDataFn
{
Picture *src;
gradient2D *gradient;
int *assignments;
imageSize previous_size;
imageSize target_size;
};
struct ForSmoothFn
{
Picture *src;
gradient2D *gradient;
int *assignments;
imageSize target_size;
imageSize previous_size;
float alpha;
float beta;
};
double dataFn(int p, int l, void *data)
{
ForDataFn *myData = (ForDataFn *) data;
int x = p % myData->target_size.width;
int y = p / myData->target_size.width;
int assign_idx = DownsamplingIndex(p,myData->target_size,
myData->previous_size,2);
int assignment = ceil((double)myData->assignments[assign_idx]*2);
double cost = 0.0;
if (myData->assignments[0]<0)
{
// pixel rearrangement:
// keep the leftmost/rightmost columns
if (x==0 && l!=0)
cost = 10000*MAX_COST_VALUE;
if (x==myData->target_size.width-1 &&
l!=myData->src->GetWidth()-myData->target_size.width)
cost = 10000*MAX_COST_VALUE;
}
else
{
//printf("Calculating data term for pixel (%d,%d,%d) with label %d\n",x,y,t,l);
if (x+assignment+l-1<0 || x+assignment+l-1>=myData->src->GetWidth())
//if (abs(l-assignment)<=1)
cost = MAX_COST_VALUE;
}
return cost;
}
double ColorDiff(Picture *src, int x1, int y1,
int x2, int y2, int l1, int l2)
{
double diff = 0.0;
int width = src->GetWidth();
int height = src->GetHeight();
int x_offset = x2-x1;
int y_offset = y2-y1;
//printf("ColorDiff: pixels: (%d,%d) and (%d,%d) labels: %d and %d\n",x2,y2+l2,x1+x_offset,y1+l1+y_offset,l2,l1);
if (x2+l2>=0 && x2+l2<width && x1+l1+x_offset>=0 && x1+l1+x_offset<width)
{
//printf("(%d,%d) color components: %d,%d,%d\n",src->GetPixel(y2+l2,x2).r,src->GetPixel(y2+l2,x2).g,src->GetPixel(y2+l2,x2).b);
diff += pow((double)src->GetPixel(x2+l2,y2).r-src->GetPixel(x1+l1+x_offset,y1+y_offset).r,2);
diff += pow((double)src->GetPixel(x2+l2,y2).g-src->GetPixel(x1+l1+x_offset,y1+y_offset).g,2);
diff += pow((double)src->GetPixel(x2+l2,y2).b-src->GetPixel(x1+l1+x_offset,y1+y_offset).b,2);
} else
{
diff += MAX_COST_VALUE;
}
//printf("ColorDiff: finished\n");
//printf("ColorDiff: cost between (%d,%d) and (%d,%d) with labels %d and %d is %d\n",x1,y1,x2,y2,l1,l2,diff);
return diff;
}
double GradientDiff(gradient2D *gradient, int x1, int y1,
int x2, int y2, int l1, int l2)
{
double diff = 0.0;
int width = gradient->dx->NumOfCols();
int height = gradient->dx->NumOfRows();
int x_offset = x2-x1;
int y_offset = y2-y1;
if (x2+l2>0 && x2+l2<=width && x1+l1+x_offset>0 && x1+l1+x_offset<=width)
{
diff += pow((gradient->dx->Get(y2,x2+l2)-gradient->dx->Get(y1+y_offset,x1+l1+x_offset)),2)+
pow((gradient->dy->Get(y2,x2+l2)-gradient->dy->Get(y1+y_offset,x1+l1+x_offset)),2);
} else
{
diff += MAX_COST_VALUE;
}
return diff;
}
double smoothFn(int p1, int p2, int l1, int l2, void *data)
{
ForSmoothFn *myData = (ForSmoothFn *) data;
double cost = 0.0;
//printf("smoothFn: calculating image gradient...\n");
int width = myData->target_size.width;
int height = myData->target_size.height;
//printf("smoothFn: image width=%d and height=%d\n",width,height);
int x1 = p1 % width;
int y1 = p1 / width;
int assign_idx = DownsamplingIndex(p1,myData->target_size,myData->previous_size, 2);
int assignment1 = ceil((double)myData->assignments[assign_idx]*2);
int x2 = p2 % width;
int y2 = p2 / width;
assign_idx = DownsamplingIndex(p2,myData->target_size,myData->previous_size,2);
int assignment2 = ceil((double)myData->assignments[assign_idx]*2);
//printf("smoothFn: (%d,%d) and (%d,%d)\n",x1,y1,x2,y2);
if (abs(x1-x2)<=1 && abs(y1-y2)<=1)
{
/*
double weight = 0.0;
for (int i = -3; i <= 3; i++)
{
for (int j = -3; j <= 3; j++)
{
if (y1+1+j>=1 && y1+1+j<=myData->gradient->dx->NumOfRows() &&
x1+1+i>=1 && x1+1+i<=myData->gradient->dx->NumOfCols())
{
weight += myData->gradient->dx->Get(y1+1+j,x1+1+i);
weight += myData->gradient->dy->Get(y1+1+j,x1+1+i);
}
if (y2+1+j>=1 && y2+1+j<=myData->gradient->dx->NumOfRows() &&
x2+1+i>=1 && x2+1+i<=myData->gradient->dx->NumOfCols())
{
weight += myData->gradient->dx->Get(y2+1+j,x2+1+i);
weight += myData->gradient->dy->Get(y2+1+j,x2+1+i);
}
}
}
*/
if (myData->assignments[0]>=0)
{
cost += myData->alpha*ColorDiff(myData->src, x1, y1, x2, y2,
assignment1+l1-1, assignment2+l2-1);
cost += myData->beta*GradientDiff(myData->gradient,x1+1, y1+1, x2+1, y2+1,
assignment1+l1-1, assignment2+l2-1);
}
else
{
cost += myData->alpha*ColorDiff(myData->src, x1, y1, x2, y2, l1, l2);
cost += myData->beta*GradientDiff(myData->gradient, x1+1, y1+1, x2+1, y2+1, l1, l2);
}
}
else
{
cost = MAX_COST_VALUE;
}
//printf("smoothFn: computing cost between (%d,%d) and (%d,%d) with labels %d and %d : %d\n",y1,x1,y2,x2,l1,l2,cost);
return cost;
}
void SaveRetargetPicture(int *labels, Picture *src,int width, int height, char *name)
{
Picture *result = new Picture(width,height);
result->SetName(name);
Picture *map = new Picture(width,height);
char map_name[512] = {'\0'};
strcat(map_name,name);
strcat(map_name,"shift.ppm");
map->SetName(map_name);
int x, y;
pixelType pixel;
intensityType map_pix;
for ( int i = 0; i < width*height; i++ )
{
x = i % width;
y = i / width;
//printf("SaveRetargetPicture: GetPixel(%d,%d)\n",x+gc->whatLabel(i),y);
pixel.r = src->GetPixel(x+labels[i],y).r;
pixel.g = src->GetPixel(x+labels[i],y).g;
pixel.b = src->GetPixel(x+labels[i],y).b;
result->SetPixel(x,y,pixel);
map_pix.r = labels[i];
map_pix.g = labels[i];
map_pix.b = labels[i];
map->SetPixelIntensity(x,y,map_pix);
}
result->Save(result->GetName());
map->Save(map->GetName());
delete result;
delete map;
}
////////////////////////////////////////////////////////////////////////////////
// in this version, set data and smoothness terms using arrays
// grid neighborhood structure is assumed
//
int *GridGraph_GraphCut(Picture *src, int *assignments, imageSize &target_size, imageSize &previous_size,
int num_labels, float alpha, float beta, char *target_name)
{
int num_pixels = target_size.width*target_size.height;
int *result = new int[num_pixels]; // stores result of optimization
try{
GCoptimizationGridGraph *gc = new GCoptimizationGridGraph(target_size.width,
target_size.height,
num_labels);
// set up the needed data to pass to function for the data costs
gradient2D *gradient = Gradient(src);
ForDataFn toDataFn;
toDataFn.src = src;
toDataFn.assignments = assignments;
toDataFn.target_size = target_size;
toDataFn.previous_size = previous_size;
gc->setDataCost(&dataFn,&toDataFn);
// smoothness comes from function pointer
ForSmoothFn toSmoothFn;
toSmoothFn.src = src;
toSmoothFn.gradient = gradient;
toSmoothFn.assignments = assignments;
toSmoothFn.previous_size = previous_size;
toSmoothFn.target_size = target_size;
toSmoothFn.alpha = alpha;
toSmoothFn.beta = beta;
gc->setSmoothCost(&smoothFn, &toSmoothFn);
printf("Before optimization energy is %f\n",gc->compute_energy());
gc->expansion(1);// run expansion for 2 iterations. For swap use gc->swap(num_iterations);
printf("After optimization energy is %f\n",gc->compute_energy());
int assign_idx, assignment;
for ( int i = 0; i < num_pixels; i++ )
{
//printf("The optimal label for pixel %d is %d\n",i,gc->whatLabel(i));
assign_idx = DownsamplingIndex(i,target_size,previous_size,2);
if (assign_idx>=0)
assignment = ceil((double)assignments[assign_idx]*2);
else
assignment = -1;
if (assignment<0)
result[i] = gc->whatLabel(i);
else
result[i] = max(assignment+gc->whatLabel(i)-1,0);
}
SaveRetargetPicture(result,src,target_size.width,
target_size.height,target_name);
delete gradient->dx;
delete gradient->dy;
delete gradient;
delete gc;
}
catch (GCException e){
e.Report();
}
return result;
}
int main(int argc, char **argv)
{
Picture *input = NULL;
pyramidType *gpyramid = NULL;
int width, height;
int num_pixels, num_labels;
int *assignments, *new_assignments;
imageSize target_size, previous_size;
if (argc<6)
{
cout << "Usage: shift_map_2d <input_img> <alpha> <beta> <ratio> <output_filename>" << endl;
return 0;
//default parameters
}
// load input image
cout << "Creating gaussian pyramid for input image" << endl;
input = new Picture(argv[1]);
gpyramid = GaussianPyramid(input);
int start_level = 1; // gpyramid->Levels-1
for (int i = start_level; i >= 0; i--)
{
if (i==start_level)
{
width = gpyramid->Images[i].GetWidth();
height = gpyramid->Images[i].GetHeight();
num_pixels = ceil(width*atof(argv[4]))*height;
assignments = new int[num_pixels];
for (int j = 0; j < num_pixels; j++)
assignments[j] = -1;
num_labels = width-ceil(width*atof(argv[4]))+1;
width = ceil(width*atof(argv[4]));
target_size.width = width;
target_size.height = height;
previous_size.width = 0;
previous_size.height = 0;
// smoothness and data costs are set up using functions
new_assignments = GridGraph_GraphCut(&(gpyramid->Images[i]),assignments,target_size,previous_size,
num_labels,atof(argv[2]),atof(argv[3]),argv[5]);
delete [] assignments;
assignments = new_assignments;
} else
{
width = gpyramid->Images[i].GetWidth();
height = gpyramid->Images[i].GetHeight();
num_pixels = ceil(width*atof(argv[4]))*height;
num_labels = 3;//width-ceil(width*atof(argv[4]))+1;
width = ceil(width*atof(argv[4]));
previous_size = target_size;
target_size.width = width;
target_size.height = height;
// refinement of initial assignment
new_assignments = GridGraph_GraphCut(&(gpyramid->Images[i]),assignments,target_size,previous_size,
num_labels,atof(argv[2]),atof(argv[3]),argv[5]);
delete [] assignments;
assignments = new_assignments;
}
}
delete [] assignments;
delete input;
delete gpyramid;
return 1;
}
/////////////////////////////////////////////////////////////////////////////////
|
[
"yiqun.hu@aeedd7dc-6096-11de-8dc1-e798e446b60a"
] |
[
[
[
1,
389
]
]
] |
803b69c85aa131ffc65cce20ee89e91a0073c8be
|
3eeca765b50d8e8633e72736dff195a9c6497c20
|
/BasicType.h
|
5c0027f3a483ff6252afc158db59a17f6c44c8a7
|
[] |
no_license
|
ducky-hong/giyeok
|
20a1685a13bd3a03f1d15d111d8622f48e61e1e2
|
c42e408d978c64c4419e1533ed92ebfd1232167b
|
refs/heads/master
| 2016-09-06T06:14:44.833270 | 2009-07-02T14:32:50 | 2009-07-02T14:32:50 | 32,984,403 | 0 | 0 | null | null | null | null |
UHC
|
C++
| false | false | 484 |
h
|
#pragma once
#include "Variable.h"
class Runner;
class BasicType : public Eclass {
public:
BasicType(GYstring);
void integration(Scope* scope);
};
class CustomFn : public Efn {
public:
CustomFn() { }
public:
void setBody(Value* (*b)(Runner*, Efn*)) { body=b; }
void integration(Scope* scope) { // 나중에 써야지
integration_param(scope);
}
Value* call(Runner* runner) { return body(runner, this); }
private:
Value* (*body)(Runner*, Efn*);
};
|
[
"Joonsoo@localhost"
] |
[
[
[
1,
23
]
]
] |
4d0b0dc7704bbe11d921276b1ec7d93fd8ef9b13
|
7b4c786d4258ce4421b1e7bcca9011d4eeb50083
|
/_代码统计专用文件夹/C++Primer中文版(第4版)/第十四章 重载操作符与转换/20090221_习题14.33_将函数对象用于标准库算法.cpp
|
4f26f89df445e62af6b58b384762e123b94538c0
|
[] |
no_license
|
lzq123218/guoyishi-works
|
dbfa42a3e2d3bd4a984a5681e4335814657551ef
|
4e78c8f2e902589c3f06387374024225f52e5a92
|
refs/heads/master
| 2021-12-04T11:11:32.639076 | 2011-05-30T14:12:43 | 2011-05-30T14:12:43 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 782 |
cpp
|
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class GT_cls {
public:
GT_cls(int val):bound(val) {}
bool operator() (const int &value)
{
return value > bound;
}
private:
int bound;
};
int main()
{
vector<int> vec;
int val;
cout << "Enter something(Ctrl+Z to end):" << endl;
while (cin >> val)
vec.push_back(val);
cin.clear();
int spval;
cout << "Enter a specified value:"<< endl;
cin >> spval;
vector<int>::iterator iter;
iter = find_if(vec.begin(), vec.end(), GT_cls(spval));
if (iter != vec.end())
cout << "The first element that is larger than "
<< spval << " : "
<< *iter << endl;
else
cout << "No element that is larger than "
<< spval << endl;
return 0;
}
|
[
"baicaibang@70501136-4834-11de-8855-c187e5f49513"
] |
[
[
[
1,
43
]
]
] |
c2c79b69e6586b11f7a47b50aeabd8a0d55827e7
|
2d4221efb0beb3d28118d065261791d431f4518a
|
/OIDE源代码/OLIDE/Controls/scintilla/scintillawrappers/ChildFrm.cpp
|
4318c3bbc7cef1b77359d20829cbe3a56844ee12
|
[] |
no_license
|
ophyos/olanguage
|
3ea9304da44f54110297a5abe31b051a13330db3
|
38d89352e48c2e687fd9410ffc59636f2431f006
|
refs/heads/master
| 2021-01-10T05:54:10.604301 | 2010-03-23T11:38:51 | 2010-03-23T11:38:51 | 48,682,489 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,646 |
cpp
|
#include "stdafx.h"
#include "ScintillaDemo.h"
#include "ChildFrm.h"
#include "ScintillaDemoDoc.h"
#include "ScintillaDemoView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)
BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
ON_WM_MOVE()
ON_WM_SIZE()
END_MESSAGE_MAP()
CChildFrame::CChildFrame()
{
}
CChildFrame::~CChildFrame()
{
}
BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{
//Let the base class do its thing
if (!CMDIChildWnd::PreCreateWindow(cs))
return FALSE;
return TRUE;
}
#ifdef _DEBUG
void CChildFrame::AssertValid() const
{
CMDIChildWnd::AssertValid();
}
void CChildFrame::Dump(CDumpContext& dc) const
{
CMDIChildWnd::Dump(dc);
}
#endif //_DEBUG
void CChildFrame::OnMove(int x, int y)
{
//Let the base class do its thing
CMDIChildWnd::OnMove(x, y);
CScintillaDemoView* pView = static_cast<CScintillaDemoView*>(GetActiveView());
if (pView && pView->IsKindOf(RUNTIME_CLASS(CScintillaDemoView)))
{
CScintillaCtrl& rCtrl = pView->GetCtrl();
//Cancel any outstanding call tip
if (rCtrl.CallTipActive())
rCtrl.CallTipCancel();
}
}
void CChildFrame::OnSize(UINT nType, int cx, int cy)
{
//Let the base class do its thing
CMDIChildWnd::OnSize(nType, cx, cy);
CScintillaDemoView* pView = static_cast<CScintillaDemoView*>(GetActiveView());
if (pView && pView->IsKindOf(RUNTIME_CLASS(CScintillaDemoView)))
{
CScintillaCtrl& rCtrl = pView->GetCtrl();
//Cancel any outstanding call tip
if (rCtrl.CallTipActive())
rCtrl.CallTipCancel();
}
}
|
[
"[email protected]"
] |
[
[
[
1,
77
]
]
] |
3e854aeeb0b4bc16cf37ca4516de966330180d0a
|
ac474685ade4f5adab2953c801f1b443727e1fec
|
/widm/FfrmExecutie.cpp
|
ac0c51c078cbb4ed8833e846ee8ca5d980813856
|
[] |
no_license
|
BackupTheBerlios/widm
|
88377ad54732f456673e891396d8ecc0ccaed6c6
|
5f66676a39d0d1427d70765247d51496d3d4543c
|
refs/heads/master
| 2016-09-10T19:44:41.182944 | 2005-02-20T19:00:30 | 2005-02-20T19:00:30 | 40,045,056 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 3,058 |
cpp
|
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "FfrmExecutie.h"
#include "FfrmGeneral.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "FfrmTestwin"
#pragma resource "*.dfm"
TfrmExecutie *frmExecutie;
//---------------------------------------------------------------------------
__fastcall TfrmExecutie::TfrmExecutie(TComponent* Owner, String uitv, int percentage)
: TfrmTestwin(Owner, percentage == -1)
{
if (percentage != -1) showPercentage (percentage);
uitvaller = uitv;
done = false;
}
//---------------------------------------------------------------------------
void TfrmExecutie::showPercentage (int percentage) {
lblPercentage->Visible = true;
lblPercentage->Font->Height = lblPercentage->Height;
lblPercentage->Caption = String(percentage) + "%";
}
void __fastcall TfrmExecutie::onTimered() {
showLogin();
}
void TfrmExecutie::LoginCallback(String name) {
for (int curkandi = 0; curkandi < frmGeneral->lstKandi->Items->Count; curkandi++) {
if (frmGeneral->lstKandi->Items->Item[curkandi]->Caption == name) {
closeLogin();
if (name == uitvaller) {
redScreen(true);
done = true;
} else
greenScreen();
return;
}
}
Application->MessageBox("Onbekende naam!", "Error", MB_ICONERROR);
}
void __fastcall TfrmExecutie::FormClose(TObject *Sender,
TCloseAction &Action)
{
for (int t = 0; t < frmGeneral->lstKandi->Items->Count; t++) {
TListItem *item = frmGeneral->lstKandi->Items->Item[t];
if (item->Caption == uitvaller) {
if (item->SubItems->Strings[0] == "") return;
int ret = Application->MessageBox("Uitvaller(s) op non-actief zetten?", "Vraag", MB_ICONQUESTION|MB_YESNO);
if (ret == IDYES) {
((KandiData*)item->Data)->flags |= FLAG_ACTIVE;
item->SubItems->Strings[0] = "";
return;
}
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmExecutie::lblPercentageClick(TObject *Sender)
{
lblPercentage->Visible = false;
showLogin();
}
//---------------------------------------------------------------------------
void __fastcall TfrmExecutie::FormKeyPress(TObject *Sender, char &Key)
{
if (Key == ' ') tmrTimer (Sender);
}
//---------------------------------------------------------------------------
void __fastcall TfrmExecutie::FormResize(TObject *Sender)
{
lblPercentage->Font->Height = lblPercentage->Height;
}
//---------------------------------------------------------------------------
|
[
"meilof"
] |
[
[
[
1,
85
]
]
] |
ba01495adda809d370862418826fdc57570271ba
|
bd48897ed08ecfea35d8e00312dd4f9d239e95c4
|
/contest/stanford-2009/A.cpp
|
e2b700b4e8392f6b33f28fa7ca27a50e45638ce6
|
[] |
no_license
|
blmarket/lib4bpp
|
ab83dbb95cc06e7b55ea2ca70012e341be580af1
|
2c676543de086458b93b1320b7b2ad7f556a24f7
|
refs/heads/master
| 2021-01-22T01:28:03.718350 | 2010-11-30T06:45:42 | 2010-11-30T06:45:42 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,428 |
cpp
|
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <sstream>
#include <queue>
#include <set>
#include <map>
#include <vector>
#define mp make_pair
#define pb push_back
#define sqr(x) ((x)*(x))
#define foreach(it,c) for(typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef long long LL;
template<typename T> inline int size(const T &a) { return a.size(); }
template<typename T> inline bool operator<(const int &a,const vector<T> &b) { return a<b.size(); }
vector<vector<PII> > edge;
int calc(int a,int par)
{
int ret = 0;
bool leaf = true;
for(int i=0;i<edge[a];i++)
{
int node = edge[a][i].first;
int weight = edge[a][i].second;
if(node == par) continue;
leaf=false;
ret += min(calc(node,a),weight);
}
if(leaf) return 1005;
return ret;
}
bool process(void)
{
int n,r;
scanf("%d %d",&n,&r);
if(n==0 && r==0) return false;
if(n == 1)
{
cout << 0 << endl;
return true;
}
r--;
edge.clear();
edge.resize(n);
for(int i=0;i<n-1;i++)
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
a--;b--;
edge[a].pb(mp(b,c));
edge[b].pb(mp(a,c));
}
cout << calc(r,-1) << endl;
return true;
}
int main(void)
{
while(process());
}
|
[
"blmarket@dbb752b6-32d3-11de-9d05-31133e6853b1"
] |
[
[
[
1,
78
]
]
] |
d8ce77f365b4e05ba2b4be730115ec6f67634a81
|
eec70a1718c685c0dbabeee59eb7267bfaece58c
|
/Sense Management Irrlicht AI/RegionalSenseManager.h
|
e9b3e61beb8f3b8872a65e985b3fc26753868394
|
[] |
no_license
|
mohaider/sense-management-irrlicht-ai
|
003939ee770ab32ff7ef3f5f5c1b77943a4c7489
|
c5ef02f478d00a4957a294254fc4f3920037bd7a
|
refs/heads/master
| 2020-12-24T14:44:38.254964 | 2011-05-19T14:29:53 | 2011-05-19T14:29:53 | 32,393,908 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,103 |
h
|
#ifndef REGIONAL_SENSE_MANAGER_H
#define REGIONAL_SENSE_MANAGER_H
#include "Singleton.h"
#include "Sensor.h"
#include <list>
#include <queue>
class RegionalSenseManager
{
public:
struct Notification
{
float time;
Sensor* m_sensor;
Signal* m_signal;
};
struct LessThan
{
bool operator() (Notification* n1, Notification* n2);
};
~RegionalSenseManager() {}
// the notification queue
std::priority_queue<Notification*, std::vector<Notification*>, LessThan> m_pQueue;
void AddSignal(Signal* signal);
void AddSensor(Sensor* sensor);
void SendSignals();
// Emit signals using these functions, I couldn't decide a good place for them so placed them in here
void EmitVisualSignal(float strength, vector3df position, signal_origin origin);
void EmitSoundSignal(float strength, vector3df position, signal_origin origin);
private:
RegionalSenseManager() {}
friend class Singleton<RegionalSenseManager>;
// the list of available sensors
std::list<Sensor*> m_sensorList;
};
typedef Singleton<RegionalSenseManager> TheRSM;
#endif
|
[
"[email protected]@2228f7ce-bb98-ac94-67a7-be962254a327"
] |
[
[
[
1,
49
]
]
] |
a833346dcaf95e3473e7bf9bb3a03bd35cabec7f
|
4275e8a25c389833c304317bdee5355ed85c7500
|
/KylTek/CVObject.cpp
|
12cb4bd755ef8201b3af0697e0fd8619c3439a04
|
[] |
no_license
|
kumorikarasu/KylTek
|
482692298ef8ff501fd0846b5f41e9e411afe686
|
be6a09d20159d0a320abc4d947d4329f82d379b9
|
refs/heads/master
| 2021-01-10T07:57:40.134888 | 2010-07-26T12:10:09 | 2010-07-26T12:10:09 | 55,943,006 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 934 |
cpp
|
#include "Main.h"
#include "CVObject.h"
#include "Functions.h"
#include "CGlobal.h"
CVObject::CVObject() {
//Init(NULL);
//m_objectid=102;
//m_prevpos=Vector2(0, 0);
//m_nextpos=Vector2(0, 0);
//m_friction=Vector2(0, 0);
//m_pSprite=NULL;
//m_pCollider->SetCollisionType(Dynamic);
};
CVObject::CVObject(ENTITY_PARAMS* params, CSprite* _sprite){
//Init(params);
//m_objectid=102;
//m_pSprite=_sprite;
//m_prevpos=m_pos;
//m_nextpos=m_pos;
//m_friction=Vector2(0, 0);
//m_pCollider->SetCollisionType(Dynamic);
};
CVObject::~CVObject(){};
void CVObject::Step(CDeviceHandler* DH){
if(!(m_state & Immovable)){
Verlet();
m_pos.x = min(max(m_pos.x, m_halfwidth), Global->LEVEL_WIDTH-m_halfwidth);
m_pos.y = min(max(m_pos.y, m_halfheight), Global->LEVEL_HEIGHT-m_halfheight);
}
};
void CVObject::Draw(CGraphicsHandler *g){
if(m_pSprite)
g->DrawSprite(m_pSprite,0,m_pos);
};
|
[
"Sean Stacey@localhost"
] |
[
[
[
1,
39
]
]
] |
ff8a187757fcb3ea6fc9eebdac0067a4f4aac190
|
b7c505dcef43c0675fd89d428e45f3c2850b124f
|
/Src/SimulatorQt/Util/qt/Win32/include/Qt/q3tabdialog.h
|
feed153ee6a03663b77ee263003de2ff0228ece4
|
[
"BSD-2-Clause"
] |
permissive
|
pranet/bhuman2009fork
|
14e473bd6e5d30af9f1745311d689723bfc5cfdb
|
82c1bd4485ae24043aa720a3aa7cb3e605b1a329
|
refs/heads/master
| 2021-01-15T17:55:37.058289 | 2010-02-28T13:52:56 | 2010-02-28T13:52:56 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 4,516 |
h
|
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information ([email protected])
**
** This file is part of the Qt3Support module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at [email protected].
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef Q3TABDIALOG_H
#define Q3TABDIALOG_H
#include <QtGui/qdialog.h>
#include <QtGui/qicon.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Qt3SupportLight)
class QTabBar;
class QTab;
class Q3TabDialogPrivate;
class Q_COMPAT_EXPORT Q3TabDialog : public QDialog
{
Q_OBJECT
public:
Q3TabDialog(QWidget* parent=0, const char* name=0, bool modal=false, Qt::WindowFlags f=0);
~Q3TabDialog();
void show();
void setFont(const QFont & font);
void addTab(QWidget *, const QString &);
void addTab(QWidget *child, const QIcon& iconset, const QString &label);
void insertTab(QWidget *, const QString &, int index = -1);
void insertTab(QWidget *child, const QIcon& iconset, const QString &label, int index = -1);
void changeTab(QWidget *, const QString &);
void changeTab(QWidget *child, const QIcon& iconset, const QString &label);
bool isTabEnabled( QWidget *) const;
void setTabEnabled(QWidget *, bool);
bool isTabEnabled(const char*) const; // compatibility
void setTabEnabled(const char*, bool); // compatibility
void showPage(QWidget *);
void removePage(QWidget *);
QString tabLabel(QWidget *);
QWidget * currentPage() const;
void setDefaultButton(const QString &text);
void setDefaultButton();
bool hasDefaultButton() const;
void setHelpButton(const QString &text);
void setHelpButton();
bool hasHelpButton() const;
void setCancelButton(const QString &text);
void setCancelButton();
bool hasCancelButton() const;
void setApplyButton(const QString &text);
void setApplyButton();
bool hasApplyButton() const;
#ifndef qdoc
void setOKButton(const QString &text = QString());
#endif
void setOkButton(const QString &text);
void setOkButton();
bool hasOkButton() const;
protected:
void paintEvent(QPaintEvent *);
void resizeEvent(QResizeEvent *);
void styleChange(QStyle&);
void setTabBar(QTabBar*);
QTabBar* tabBar() const;
Q_SIGNALS:
void aboutToShow();
void applyButtonPressed();
void cancelButtonPressed();
void defaultButtonPressed();
void helpButtonPressed();
void currentChanged(QWidget *);
void selected(const QString&); // obsolete
private:
void setSizes();
void setUpLayout();
Q3TabDialogPrivate *d;
Q_DISABLE_COPY(Q3TabDialog)
};
QT_END_NAMESPACE
QT_END_HEADER
#endif // Q3TABDIALOG_H
|
[
"alon@rogue.(none)"
] |
[
[
[
1,
142
]
]
] |
327845a91272f0f3903afd23969a2ddbf3bca073
|
cfcd2a448c91b249ea61d0d0d747129900e9e97f
|
/thirdparty/OpenCOLLADA/COLLADABaseUtils/include/COLLADABUStringUtils.h
|
bb59461e585bb76400ce60fd5e88562e4e2591a8
|
[] |
no_license
|
fire-archive/OgreCollada
|
b1686b1b84b512ffee65baddb290503fb1ebac9c
|
49114208f176eb695b525dca4f79fc0cfd40e9de
|
refs/heads/master
| 2020-04-10T10:04:15.187350 | 2009-05-31T15:33:15 | 2009-05-31T15:33:15 | 268,046 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 6,219 |
h
|
/*
Copyright (c) 2008 NetAllied Systems GmbH
This file is part of COLLADABaseUtils.
Licensed under the MIT Open Source License,
for details please see LICENSE file or the website
http://www.opensource.org/licenses/mit-license.php
*/
#ifndef __COLLADABU_STRINGUTILS_H__
#define __COLLADABU_STRINGUTILS_H__
#include "COLLADABUPrerequisites.h"
#include "COLLADABUNativeString.h"
#include <sstream>
#include <fstream>
#include <map>
namespace COLLADABU
{
/** A class that holds some static COLLADA utility functions*/
class StringUtils
{
public:
/**
* Returns true, if both strings are equal. The comparison is case sensitive.
*/
template<class StringType>
static bool equals ( const StringType &str1, const StringType &str2 )
{
if ( str1.length() != str2.length() )
return false;
return ( strcmp ( str1.c_str(), str2.c_str() ) == 0 );
}
/**
* Returns true, if both strings are equal. The comparison is case intensitive.
*/
static bool equalsIgnoreCase ( const WideString& s1, const WideString& s2 );
/** Checks for a valid xs:NCName.
1. replaces all not allowed characters
2. forces that the string begins with a letter or an _
@param ncName The string to convert to a valid xs:NCName.
@return The checked string
*/
static WideString checkNCName ( const WideString &ncName );
// static UTF8String checkNCName ( const UTF8String &ncName ){return UTF8String();};
/** Checks for a valid xs:ID.
1. replaces all not allowed characters
2. forces that the string begins with a letter or an _
@param ncName The string to convert to a valid xs:ID.
@return The checked string
*/
static WideString checkID ( const WideString &id );
// static UTF8String checkID ( const UTF8String &id ){return UTF8String();};
/** Checks if @a c is name start character according to http://www.w3.org/TR/xml11/#NT-NameStartChar */
static bool isNameStartChar ( wchar_t c );
/** Checks if @a c is name character according to http://www.w3.org/TR/xml11/#NT-NameChar */
static bool isNameChar ( wchar_t c );
/** Checks if @a c is an upper ASCII character*/
static bool isUpperAsciiChar ( char c )
{
return ( c >= 'A' ) && ( c <= 'Z' ) ;
}
/** Checks if @a c is a lower ASCII character*/
static bool isLowerAsciiChar ( char c )
{
return ( c >= 'a' ) && ( c <= 'z' ) ;
}
/** Checks if @a c is an ASCII character*/
static bool isAsciiAlphaChar ( char c )
{
return isLowerAsciiChar ( c ) || isUpperAsciiChar ( c ) ;
}
/** Checks if @a c is a digit*/
static bool isDigit ( char c )
{
return ( c >= '0' ) && ( c <= '9' ) ;
}
/** Checks if @a c is an xs:id character, but not alpha numeric*/
static bool isIDExtraChar ( char c )
{
return ( c == '.' ) || ( c == '-' ) || ( c == '_' ) ;
}
/** Checks if @a c is an xs:id character, but not alpha numeric*/
static bool isIDChar ( char c )
{
return isAsciiAlphaChar ( c ) || isDigit ( c ) || isIDExtraChar ( c ) ;
}
static String uriEncode ( const String & sSrc );
/** Escapes all the characters not allowed in xml text elements.
@param srcString The string to translate.
@return The translated string.*/
static String translateToXML ( const String &srcString );
/** Escapes all the characters not allowed in xml text elements.
@param srcString The string to translate.
@return The translated string.*/
static WideString translateToXML ( const WideString &srcString );
/** Returns @a text with all dots replaced by underlines*/
static String replaceDot ( const String &text );
/** Converts @a value to a NativeString.
@param T The type of the value to convert.
@param value The value of type @a T to convert to a NativeString.
*/
template<class T>
static NativeString toNativeString ( const T & value )
{
std::stringstream stream;
stream << value;
return NativeString(stream.str());
}
/** Converts @a value to a UTF8String.
@param T The type of the value to convert.
@param value The value of type @a T to convert to a UTF8String.
*/
template<class T>
static String toUTF8String( const T & value )
{
std::stringstream stream;
stream << value;
return String(stream.str());
}
/** Converts @a value to a String.
@param T The type of the value to convert.
@param value The value of type @a T to convert to a string.
*/
template<class T>
static WideString toWideString ( const T & value )
{
std::wstringstream stream;
stream << value;
return WideString(stream.str());
}
/**
* Searches all search strings in the source string and replace it with the replaceString.
* @param source Reference to the source string.
* @param searchString The search string.
* @param replaceString The replace string.
*/
template<class StringType>
static void stringFindAndReplace ( StringType &source, const StringType searchString, const StringType replaceString )
{
size_t found = source.find ( searchString );
if ( found != StringType::npos )
{
size_t searchStrLength = searchString.length();
size_t replaceStrLength = replaceString.length();
do
{
source.replace ( found, searchStrLength, replaceString );
found = source.find (searchString, found + replaceStrLength );
} while ( found != StringType::npos );
}
}
/** Converts the utf8 encoded string @a utf8String to a unicode encoded widestring.*/
static WideString utf8String2WideString( const String& utf8String );
/** Converts the unicode encoded string @a wideString to a UTF encoded string.*/
static String wideString2utf8String( const WideString& wideString );
};
}
#endif // __COLLADABU_STRINGUTILS_H__
|
[
"[email protected]"
] |
[
[
[
1,
195
]
]
] |
db11e374e97d8ae5739dd9909deb9e0756109644
|
61352a7371397524fe7dcfab838de40d502c3c9a
|
/server/Sources/Observers/RemoteObserverData.cpp
|
46ad3a92fea2b337da718aa105b8f111df75bec4
|
[] |
no_license
|
ustronieteam/emmanuelle
|
fec6b6ccfa1a9a6029d8c3bb5ee2b9134fccd004
|
68d639091a781795d2e8ce95c3806ce6ae9f36f6
|
refs/heads/master
| 2021-01-21T13:04:29.965061 | 2009-01-28T04:07:01 | 2009-01-28T04:07:01 | 32,144,524 | 2 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 331 |
cpp
|
#include "Observers/RemoteObserverData.h"
RemoteObserverData::RemoteObserverData()
{
}
RemoteObserverData::~RemoteObserverData()
{
}
EventType & RemoteObserverData::get_eventType()
{
return eventType;
}
void RemoteObserverData::set_eventType(EventType eventType)
{
this->eventType = eventType;
}
|
[
"coutoPL@c118a9a8-d993-11dd-9042-6d746b85d38b",
"w.grzeskowiak@c118a9a8-d993-11dd-9042-6d746b85d38b"
] |
[
[
[
1,
15
],
[
17,
19
]
],
[
[
16,
16
]
]
] |
470424ef549154e54926dd9ae3d6947b219bb795
|
98c8da921605c9f54f69a3d55504280e2cc77160
|
/src/foo_autorating/string_resource.cpp
|
218517da599edcb17ca1c3a655ff7a52dd00245b
|
[] |
no_license
|
lappdance/foo_autorating
|
08bcf1a888dac1ea13aa875294938bb5664939a0
|
d1ce17508ba9cd58dce8ef3b2486f6eab83ed660
|
refs/heads/master
| 2021-01-21T12:39:45.521664 | 2010-10-11T02:51:26 | 2010-10-11T02:51:26 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 2,101 |
cpp
|
#include"stdafx.h"
#include"string_resource.h"
using namespace auto_rating;
using std::wstring;
namespace auto_rating {
const wchar_t* lockString(HINSTANCE instance, UINT id, LANGID lang) {
if(!lang)
lang = ::GetUserDefaultLangID();
//string resources are bundled into tables of 16
//asking for a specific string won't work; we need to find the table first
const int tableID = (id >> 4) + 1;
//we also need to determine which string in the table we want
const int idx = (id & 0x0f);
const wchar_t* string = 0L;
HRSRC rsc = ::FindResourceExW(instance, RT_STRING, MAKEINTRESOURCEW(tableID), lang);
if(rsc) {
HGLOBAL glob = ::LoadResource(instance, rsc);
if(glob) {
const void* table = ::LockResource(glob);
if(table) {
string = reinterpret_cast<const wchar_t*>(table);
//@c string is currently pointing to the first string in the table.
//from the beginning of the table, advance the pointer @c idx times
//until it points to the string we want.
for(int i=0; i<idx; ++i) {
//string in resource are prepended with their length, so simply add
//that value to the pointer. We also add 1 to account for the length
//character.
string += 1 + static_cast<unsigned>(string[0]);
}
UnlockResource(table);
}
::FreeResource(rsc);
}
}
return string;
}
} //~namespace auto_rating
size_t auto_rating::getStringLength(HINSTANCE instance, UINT id, LANGID lang) {
const wchar_t* string = lockString(instance, id, lang);
if(string)
//add 1 to account for the null-terminator
return static_cast<int>(string[0]) + 1;
else
return 0;
}
wstring auto_rating::loadString(HINSTANCE instance, UINT id, LANGID lang) {
const wchar_t* string = lockString(instance, id, lang);
wstring result;
if(string) {
//resource strings are prepended with their length; increment past it
const wchar_t* begin = string + 1;
const wchar_t* end = begin + static_cast<int>(string[0]);
result.assign(begin, end);
}
return result;
}
|
[
"jlapp@d8a10105-fb75-0410-a675-bcd697018789"
] |
[
[
[
1,
75
]
]
] |
9669b4ae724118224e29c38ead327f7d9e21a1e1
|
c95a83e1a741b8c0eb810dd018d91060e5872dd8
|
/Game/ObjectDLL/ObjectShared/KeyPad.h
|
96bf455176459cce30535eabafe921caaae8760b
|
[] |
no_license
|
rickyharis39/nolf2
|
ba0b56e2abb076e60d97fc7a2a8ee7be4394266c
|
0da0603dc961e73ac734ff365bfbfb8abb9b9b04
|
refs/heads/master
| 2021-01-01T17:21:00.678517 | 2011-07-23T12:11:19 | 2011-07-23T12:11:19 | 38,495,312 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,508 |
h
|
// ----------------------------------------------------------------------- //
//
// MODULE : KeyPad.h
//
// PURPOSE : Definition of the Key pad Model
//
// CREATED : 4/30/99
//
// ----------------------------------------------------------------------- //
#ifndef __KEY_PAD_H__
#define __KEY_PAD_H__
#include "Prop.h"
#include "Timer.h"
LINKTO_MODULE( KeyPad );
class CCharacter;
class KeyPad : public Prop
{
public :
KeyPad();
~KeyPad();
// Implementing classes will have this function called
// when HOBJECT ref points to gets deleted.
virtual void OnLinkBroken( LTObjRefNotifier *pRef, HOBJECT hObj );
protected :
virtual uint32 EngineMessageFn(uint32 messageID, void *pData, LTFLOAT lData);
virtual bool OnTrigger(HOBJECT hSender, const CParsedMsg &cMsg);
protected :
LTBOOL ReadProp(ObjectCreateStruct *pData);
LTBOOL InitialUpdate();
void Update();
void SetupDisabledState();
void HandleGadgetMsg(const CParsedMsg &cMsg);
protected :
HSTRING m_hstrDisabledCmd;
HSTRING m_hstrPickSound;
LTObjRefNotifier m_hDeciphererModel;
HLTSOUND m_hPickSound;
LTFLOAT m_fMinPickTime;
LTFLOAT m_fMaxPickTime;
LTFLOAT m_fPickSoundRadius;
LTBOOL m_bSpaceCodeBreaker;
CTimer m_DecipherTimer;
private :
void Save(ILTMessage_Write *pMsg);
void Load(ILTMessage_Read *pMsg);
void SpawnGadget();
};
#endif // __KEY_PAD_H__
|
[
"[email protected]"
] |
[
[
[
1,
68
]
]
] |
ab0822c8d83a529c30aff155ce6701937d6949d2
|
fac8de123987842827a68da1b580f1361926ab67
|
/inc/physics/Physics/Utilities/Dynamics/SaveContactPoints/hkpPhysicsSystemWithContacts.inl
|
c91657908f1e29f777d7e0b6a9020fba36b5eecd
|
[] |
no_license
|
blockspacer/transporter-game
|
23496e1651b3c19f6727712a5652f8e49c45c076
|
083ae2ee48fcab2c7d8a68670a71be4d09954428
|
refs/heads/master
| 2021-05-31T04:06:07.101459 | 2009-02-19T20:59:59 | 2009-02-19T20:59:59 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,423 |
inl
|
/*
*
* Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's
* prior written consent.This software contains code, techniques and know-how which is confidential and proprietary to Havok.
* Level 2 and Level 3 source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2008 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement.
*
*/
inline const hkArray<hkpSerializedAgentNnEntry*>& hkpPhysicsSystemWithContacts::getContacts() const
{
return m_contacts;
}
inline hkArray<hkpSerializedAgentNnEntry*>& hkpPhysicsSystemWithContacts::getContactsRw()
{
return m_contacts;
}
/*
* Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20080529)
*
* Confidential Information of Havok. (C) Copyright 1999-2008
* Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok
* Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership
* rights, and intellectual property rights in the Havok software remain in
* Havok and/or its suppliers.
*
* Use of this software for evaluation purposes is subject to and indicates
* acceptance of the End User licence Agreement for this product. A copy of
* the license is included with this software and is also available at
* www.havok.com/tryhavok
*
*/
|
[
"uraymeiviar@bb790a93-564d-0410-8b31-212e73dc95e4"
] |
[
[
[
1,
34
]
]
] |
42bc64c2ea4593d22ed30be5bad5dcd14198a1b8
|
b14d5833a79518a40d302e5eb40ed5da193cf1b2
|
/cpp/extern/xercesc++/2.6.0/samples/Redirect/Redirect.cpp
|
f5640b227b666c2e6f6e25b61ad525537b116320
|
[
"Apache-2.0"
] |
permissive
|
andyburke/bitflood
|
dcb3fb62dad7fa5e20cf9f1d58aaa94be30e82bf
|
fca6c0b635d07da4e6c7fbfa032921c827a981d6
|
refs/heads/master
| 2016-09-10T02:14:35.564530 | 2011-11-17T09:51:49 | 2011-11-17T09:51:49 | 2,794,411 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 6,974 |
cpp
|
/*
* Copyright 1999-2000,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
*
* This simplistic sample illustrates how an XML application can use
* the SAX entityResolver handler to provide customized handling for
* external entities.
*
* It registers an entity resolver with the parser. When ever the parser
* comes across an external entity, like a reference to an external DTD
* file, it calls the 'resolveEntity()' callback. This callback in this
* sample checks to see if the external entity to be resolved is the file
* 'personal.dtd'.
*
* If it is then, it redirects the input stream to the file 'redirect.dtd',
* which is then read instead of 'personal.dtd'.
*
* If the external entity to be resolved was not the file 'personal.dtd', the
* callback returns NULL indicating that do the default behaviour which is
* to read the contents of 'personal.dtd'.
*
* $Log: Redirect.cpp,v $
* Revision 1.11 2004/09/08 13:55:33 peiyongz
* Apache License Version 2.0
*
* Revision 1.10 2004/09/02 14:59:29 cargilld
* Add OutOfMemoryException block to samples.
*
* Revision 1.9 2003/08/07 21:21:38 neilg
* fix segmentation faults that may arise when the parser throws exceptions during document parsing. In general, XMLPlatformUtils::Terminate() should not be called from within a catch statement.
*
* Revision 1.8 2003/05/30 09:36:35 gareth
* Use new macros for iostream.h and std:: issues.
*
* Revision 1.7 2002/02/01 22:38:26 peiyongz
* sane_include
*
* Revision 1.6 2001/10/25 15:18:33 tng
* delete the parser before XMLPlatformUtils::Terminate.
*
* Revision 1.5 2001/10/19 19:02:42 tng
* [Bug 3909] return non-zero an exit code when error was encounted.
* And other modification for consistent help display and return code across samples.
*
* Revision 1.4 2000/05/31 18:53:15 rahulj
* Removed extraneous command line arguments.
*
* Revision 1.3 2000/02/11 02:38:28 abagchi
* Removed StrX::transcode
*
* Revision 1.2 2000/02/06 07:47:21 rahulj
* Year 2K copyright swat.
*
* Revision 1.1.1.1 1999/11/09 01:09:37 twl
* Initial checkin
*
* Revision 1.6 1999/11/08 20:43:39 rahul
* Swat for adding in Product name and CVS comment log variable.
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/parsers/SAXParser.hpp>
#include "Redirect.hpp"
#include <xercesc/util/OutOfMemoryException.hpp>
// ---------------------------------------------------------------------------
// Local helper methods
// ---------------------------------------------------------------------------
void usage()
{
XERCES_STD_QUALIFIER cout << "\nUsage:\n"
" Redirect <XML file>\n\n"
"This program installs an entity resolver, traps the call to\n"
"the external DTD file and redirects it to another application\n"
"specific file which contains the actual dtd.\n\n"
"The program then counts and reports the number of elements and\n"
"attributes in the given XML file.\n"
<< XERCES_STD_QUALIFIER endl;
}
// ---------------------------------------------------------------------------
// Program entry point
// ---------------------------------------------------------------------------
int main(int argc, char* args[])
{
// Initialize the XML4C system
try
{
XMLPlatformUtils::Initialize();
}
catch (const XMLException& toCatch)
{
XERCES_STD_QUALIFIER cerr << "Error during initialization! Message:\n"
<< StrX(toCatch.getMessage()) << XERCES_STD_QUALIFIER endl;
return 1;
}
// We only have one parameter, which is the file to process
// We only have one required parameter, which is the file to process
if ((argc != 2) || (*(args[1]) == '-'))
{
usage();
XMLPlatformUtils::Terminate();
return 1;
}
const char* xmlFile = args[1];
//
// Create a SAX parser object. Then, according to what we were told on
// the command line, set it to validate or not.
//
SAXParser* parser = new SAXParser;
//
// Create our SAX handler object and install it on the parser, as the
// document, entity and error handlers.
//
RedirectHandlers handler;
parser->setDocumentHandler(&handler);
parser->setErrorHandler(&handler);
parser->setEntityResolver(&handler);
//
// Get the starting time and kick off the parse of the indicated file.
// Catch any exceptions that might propogate out of it.
//
unsigned long duration;
int errorCount = 0;
int errorCode = 0;
try
{
const unsigned long startMillis = XMLPlatformUtils::getCurrentMillis();
parser->parse(xmlFile);
const unsigned long endMillis = XMLPlatformUtils::getCurrentMillis();
duration = endMillis - startMillis;
errorCount = parser->getErrorCount();
}
catch (const OutOfMemoryException&)
{
XERCES_STD_QUALIFIER cerr << "OutOfMemoryException" << XERCES_STD_QUALIFIER endl;
errorCode = 5;
}
catch (const XMLException& e)
{
XERCES_STD_QUALIFIER cerr << "\nError during parsing: '" << xmlFile << "'\n"
<< "Exception message is: \n"
<< StrX(e.getMessage()) << "\n" << XERCES_STD_QUALIFIER endl;
errorCode = 4;
}
if(errorCode) {
XMLPlatformUtils::Terminate();
return errorCode;
}
// Print out the stats that we collected and time taken.
if (!errorCount) {
XERCES_STD_QUALIFIER cout << xmlFile << ": " << duration << " ms ("
<< handler.getElementCount() << " elems, "
<< handler.getAttrCount() << " attrs, "
<< handler.getSpaceCount() << " spaces, "
<< handler.getCharacterCount() << " chars)" << XERCES_STD_QUALIFIER endl;
}
//
// Delete the parser itself. Must be done prior to calling Terminate, below.
//
delete parser;
XMLPlatformUtils::Terminate();
if (errorCount > 0)
return 4;
else
return 0;
}
|
[
"[email protected]"
] |
[
[
[
1,
198
]
]
] |
aa84a380da549c837fa52bfff3c4a8f1638be452
|
8253a563255bdd5797873c9f80d2a48a690c5bb0
|
/settingsengines/sdb/tests/native/SpeedDialTest/inc/CommandHandler.h
|
f67ef0837f1fc7ebcca05d6670271ccef8f48f18
|
[] |
no_license
|
SymbianSource/oss.FCL.sftools.depl.swconfigmdw
|
4e6ab52bf564299f1ed7036755cf16321bd656ee
|
d2feb88baf0e94da760738fc3b436c3d5d1ff35f
|
refs/heads/master
| 2020-03-28T10:16:11.362176 | 2010-11-06T14:59:14 | 2010-11-06T14:59:14 | 73,009,096 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 2,406 |
h
|
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of "Eclipse Public License v1.0"
// which accompanies this distribution, and is available
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
//
// Initial Contributors:
// Nokia Corporation - initial contribution.
//
// Contributors:
//
// Description:
//
/*
============================================================================
Name : CommandLineHandler.h
Author :
Version : 1.0
Copyright : Your copyright notice
Description : CCommandHandler declaration
============================================================================
*/
#ifndef COMMANDLINEHANDLER_H
#define COMMANDLINEHANDLER_H
// INCLUDES
#include <e32std.h>
#include <e32base.h>
#include <e32cons.h>
#include <cntdb.h>
#include <cntitem.h>
#include <cntfldst.h>
// CLASS DECLARATION
/**
* CCommandHandler
*
*/
class CCommandHandler : public CBase
{
public:
// Constructors and destructor
/**
* Destructor.
*/
~CCommandHandler();
/**
* Two-phased constructor.
*/
static CCommandHandler* NewL(CConsoleBase* aConsole);
/**
* Two-phased constructor.
*/
static CCommandHandler* NewLC(CConsoleBase* aConsole);
/**
* Desrtroy allocated pointers and close the array
*/
static void ResetAndDestroyPtrArray(TAny* aPtr);
/**
*
*/
void HandleCommandL(const RArray<TPtrC>& aArgs);
private:
/**
* Constructor for performing 1st stage construction
*/
CCommandHandler(CConsoleBase* aConsole);
/**
* EPOC default constructor for performing 2nd stage construction
*/
void ConstructL();
void CreateSpeedDialIniL(const RArray<TPtrC>& aCmdArgs);
void ValidateSpeedDialIniL(const RArray<TPtrC>& aCmdArgs);
TInt32 DesToInt32(const TPtrC& aDes);
void HandleCommandError(TInt aError);
bool isSpeedDialSetForContact(TInt speedDialValue, TInt expectedContactID, TBuf<32> expectedContactNumber);
void PrintUsage();
void PrintCntModelError(TInt aCntModelError);
void PrintDatabaseError(TInt aDatabaseError);
CContactDatabase* OpenDefaultDb();
private:
CConsoleBase* iConsole;
CContactDatabase* iContactDb;
};
#endif // COMMANDLINEHANDLER_H
|
[
"none@none"
] |
[
[
[
1,
103
]
]
] |
757f5b216e2b3c0d232afc77ae9628ca2ca30b8e
|
c063b883420af2d1453ebdf72020d3add2af68e7
|
/src/ad_main.h
|
45dcd3d5b508df5ab87f1352e7e505e0c46cc2d1
|
[] |
no_license
|
gillzaib78/adscanner
|
6d613212de01c42aa1cbe07cd5312e842c557d27
|
9da43c1adfa4e51c4790125f9c16b1c2ecda82e4
|
refs/heads/master
| 2021-01-22T15:16:41.946448 | 2008-09-17T14:26:22 | 2008-09-17T14:26:22 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 5,183 |
h
|
/***************************************************************************
author: Joshua Hampp
date: 2008/01
property of Joshua Hampp
***************************************************************************/
/*
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR `Joshua Hampp`AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include "noaddata.h"
#include "ccontrol.h"
#include "inc.h"
#include "ffmpeg_movie.h"
#define CHECKLOGO_PERCENT 0.5
#define DETECT_LENGTH 60
#define STABLE_TIME 20
class CAdvertisement {
public:
struct SCutInfo {
UINT numAds;
struct DATA {
uint64_t averDur, start; } *data;
};
private:
noadData *pData;
void *lastYUVBuf;
CControl *cctrl;
bool bLogo,bAudio;
CFFMPEGLoader *Movie;
struct SStates {
int audio;
int video;
SStates(){Init();}
void Init() {audio=video=0;}
void SetAdAudioBegins() {audio++;}
void SetAdVideoBegins() {video++;}
void SetAdAudioStops() {audio--;}
void SetAdVideoStops() {video--;}
};
struct SAdData {
UINT ulTopBlackLines,ulBotBlackLines,checkedFrames;
UINT blackFrames;
bool bBlackFrame;
void Init(noadData *pData,CControl **cctrl,UINT ulTopBlL, UINT ulBotBlL);
};
struct SCut {
uint64_t frame;
uint64_t duration; //in frames
};
class CCutlist {
private:
static UINT sNum;
static UINT sSize;
CTemplateBuffer<SCut> List;
bool bStart;
bool bMarkedCut;
public:
CCutlist():List(&sSize,&sNum) {bStart=true;bMarkedCut=true;}
void Save(const char *filename, const char *moviename, const double &fps);
void Save(string *save, const char *moviename, const double &fps);
void AddStart(const uint64_t &start);
void AddEnd(const uint64_t &end);
void Add(const uint64_t &v);
void Convert(const uint64_t &dur, const bool &markedKeep);
};
SAdData AdvertData;
CCutlist Cutlist;
string FileName;
bool createLogo();
bool doLogoDetection(const UINT startSec, const UINT lengthSec);
double checkLogo(const UINT &startSec, const UINT &lengthSec, const UINT &jumpSec, const UINT &numFrames, const UINT &jumpFrames, const uint64_t &startFrame=0, const bool &bExact=false);
double checkLogo2(const UINT &startSec, const UINT &lengthSec, const UINT &jumpSec, const UINT &numFrames, const UINT &jumpFrames, const uint64_t &startFrame=0, const bool &bExact=false);
bool checkAudio(const UINT startSec, const UINT lengthSec, const UINT jumpSec, const UINT numFrames, const UINT jumpFrames);
void checkCallback( int width, int height, void *yufbuf );
void drawCallback ( int width, int height, void *yufbuf );
bool StdCallBack ( int width, int height, void *yuvbuf );
bool detectChange(const UINT iSec, const UINT iJump);
//void createCuts(const UINT &minAdvertLength, const UINT &movieLength); //in seconds
//void AddCut(const SCut &cut);
uint64_t exactChange(const uint64_t &guessed, const UINT &arround, const bool &bOnlyExact=false);
UINT IsStable(const uint64_t &frame, const bool &bStart, const bool &bBlack);
uint64_t checkRecursive(const bool &bOld, const bool &bNew, const uint64_t &pos, const UINT &duration);
uint64_t checkRecursive2(const bool &bStart, const uint64_t &st, const uint64_t &end, const float &a, const float &b);
bool Init(const char *filename);
void Delete();
public:
void ScanAdvert(const char *filename, const UINT &minAdvertLength);
void CreatePropMap(const char *filename, const UINT &num, float *array, Progress *progress);
void Save(const char *filename);
void Save(string *save);
//CONSOLE FUNCTIONS
bool CreateCutlist(const char *filename, const char *cutlist, const string &author, const UINT &minAdvertLength, const UINT &security, const int &start, const int &end, const UINT &jumpAfter, const bool &bScreenshot, const UINT &screens_dis, const UINT &screens_num, const UINT &screens_width, const UINT &screens_height);
};
|
[
"[email protected]"
] |
[
[
[
1,
120
]
]
] |
7a995b8c255cd55cf54db71b7443983893bc9354
|
b2b5c3694476d1631322a340c6ad9e5a9ec43688
|
/Baluchon/ColoredMarker.h
|
cd4b2ab644be0c34c1f375f0613acffa8e0e5121
|
[] |
no_license
|
jpmn/rough-albatross
|
3c456ea23158e749b029b2112b2f82a7a5d1fb2b
|
eb2951062f6c954814f064a28ad7c7a4e7cc35b0
|
refs/heads/master
| 2016-09-05T12:18:01.227974 | 2010-12-19T08:03:25 | 2010-12-19T08:03:25 | 32,195,707 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 626 |
h
|
#pragma once
#include "IMarker.h"
#include "IDetectable.h"
#include "IColorable.h"
#include "IPositionable.h"
using namespace baluchon::core::datas;
namespace baluchon { namespace core { namespace datas { namespace detection {
class ColoredMarker : public IMarker, public IColorable, public IPositionable, public IDetectable
{
public:
ColoredMarker(void);
virtual ~ColoredMarker(void);
void setContours(CvSeq* contours);
CvSeq* getContours(void);
void setTolerance(int tolerance);
int getTolerance(void);
private:
CvMemStorage* mStorage;
CvSeq* mContours;
int mTolerance;
};
}}}};
|
[
"jpmorin196@bd4f47a5-da4e-a94a-6a47-2669d62bc1a5"
] |
[
[
[
1,
30
]
]
] |
67ca1e88b050c95aa4d778ceedd467e79466def3
|
483d66ba0bc9ff989695d978e99c900d2c4c9418
|
/Client/LoginDlg.h
|
2aa45e86bee433bd1a12372f06f63accd55158d8
|
[] |
no_license
|
uwitec/storesystem
|
3aeeef77837bed312e6cac5bb9b18e1e96a3156d
|
b703e4747fa035e221eb8f2d7bf586dae83f5e6f
|
refs/heads/master
| 2021-03-12T20:17:54.942667 | 2011-06-06T17:46:15 | 2011-06-06T17:46:15 | 40,976,352 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 255 |
h
|
#ifndef LOGINDLG_H
#define LOGINDLG_H
#include <QWidget>
#include "ui_LoginDlg.h"
class LoginDlg : public QWidget
{
Q_OBJECT
public:
LoginDlg(QWidget *parent = 0);
~LoginDlg();
private:
Ui::LoginDlg ui;
};
#endif // LOGINDLG_H
|
[
"[email protected]"
] |
[
[
[
1,
19
]
]
] |
7d01ce094108f162f8e00fcc1d973f40fd68ecd0
|
91b964984762870246a2a71cb32187eb9e85d74e
|
/SRC/OFFI SRC!/_Interface/WndAddFriend.h
|
da2f1b08bd0b7d381d07d851f9e84f4efad6614a
|
[] |
no_license
|
willrebuild/flyffsf
|
e5911fb412221e00a20a6867fd00c55afca593c7
|
d38cc11790480d617b38bb5fc50729d676aef80d
|
refs/heads/master
| 2021-01-19T20:27:35.200154 | 2011-02-10T12:34:43 | 2011-02-10T12:34:43 | 32,710,780 | 3 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 653 |
h
|
#ifndef __WNDADDFRIEND__H
#define __WNDADDFRIEND__H
class CWndAddFriend : public CWndNeuz
{
public:
CWndAddFriend();
~CWndAddFriend();
virtual BOOL Initialize( CWndBase* pWndParent = NULL, DWORD nType = MB_OK );
virtual BOOL OnChildNotify( UINT message, UINT nID, LRESULT* pLResult );
virtual void OnDraw( C2DRender* p2DRender );
virtual void OnInitialUpdate();
virtual BOOL OnCommand( UINT nID, DWORD dwMessage, CWndBase* pWndBase );
virtual void OnSize( UINT nType, int cx, int cy );
virtual void OnLButtonUp( UINT nFlags, CPoint point );
virtual void OnLButtonDown( UINT nFlags, CPoint point );
};
#endif
|
[
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
] |
[
[
[
1,
19
]
]
] |
ed461aa6c92c13bd994ef3fb1a6189a48caa17de
|
997e067ab6b591e93e3968ae1852003089dca848
|
/src/game/server/entities/projectile.cpp
|
009e14e469f9333fbfa011605910984ed9f6b3b2
|
[
"LicenseRef-scancode-other-permissive",
"Zlib"
] |
permissive
|
floff/ddracemax_old
|
06cbe9f60e7cef66e58b40c5f586921a1c881ff3
|
f1356177c49a3bc20632df9a84a51bc491c37f7d
|
refs/heads/master
| 2016-09-05T11:59:55.623581 | 2011-01-14T04:58:25 | 2011-01-14T04:58:25 | 777,555 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 3,489 |
cpp
|
#include <engine/e_server_interface.h>
#include <engine/e_config.h>
#include <game/generated/g_protocol.hpp>
#include <game/server/gamecontext.hpp>
#include "projectile.hpp"
#include "pickup.hpp"
//////////////////////////////////////////////////
// projectile
//////////////////////////////////////////////////
PROJECTILE::PROJECTILE(int type, int owner, vec2 pos, vec2 dir, int span,
bool freeze, int flags, float force, int sound_impact, int weapon)
: ENTITY(NETOBJTYPE_PROJECTILE)
{
this->type = type;
this->pos = pos;
this->direction = dir;
this->lifespan = span;
this->owner = owner;
this->flags = flags;
this->force = force;
this->sound_impact = sound_impact;
this->weapon = weapon;
this->start_tick = server_tick();
this->freeze = freeze;
game.world.insert_entity(this);
}
void PROJECTILE::reset()
{
if (lifespan>-2)
game.world.destroy_entity(this);
}
vec2 PROJECTILE::get_pos(float time)
{
float curvature = 0;
float speed = 0;
if(type == WEAPON_GRENADE)
{
curvature = tuning.grenade_curvature;
speed = tuning.grenade_speed;
}
else if(type == WEAPON_SHOTGUN)
{
curvature = tuning.shotgun_curvature;
speed = tuning.shotgun_speed;
}
else if(type == WEAPON_GUN)
{
curvature = tuning.gun_curvature;
speed = tuning.gun_speed;
}
return calc_pos(pos, direction, curvature, speed, time);
}
void PROJECTILE::tick()
{
float pt = (server_tick()-start_tick-1)/(float)server_tickspeed();
float ct = (server_tick()-start_tick)/(float)server_tickspeed();
vec2 prevpos = get_pos(pt);
vec2 curpos = get_pos(ct);
vec2 speed = curpos - prevpos;
if (lifespan>-1)
lifespan--;
vec2 col_pos;
vec2 new_pos;
int collide = col_intersect_line(prevpos, curpos, &col_pos, &new_pos);
CHARACTER *ownerchar;
if (owner>=0)
ownerchar = game.get_player_char(owner);
CHARACTER *targetchr;
if (freeze)
targetchr = game.world.intersect_character(prevpos, col_pos, 1.0f, col_pos, ownerchar);
else
targetchr = game.world.intersect_character(prevpos, col_pos, 6.0f, col_pos, ownerchar);
if(targetchr || collide)
{
if((flags & PROJECTILE_FLAGS_EXPLODE) && (!targetchr || (targetchr && !freeze)))
{
game.create_explosion(col_pos, owner, weapon, false);
game.create_sound(col_pos, sound_impact);
}
else if(targetchr && freeze)
targetchr->freeze(server_tickspeed()*3);
if (collide && bouncing!=0)
{
start_tick=server_tick();
pos=new_pos;
if (bouncing==1)
direction.x=-direction.x;
else if (bouncing==2)
direction.y=-direction.y;
pos+=direction;
}
else if (weapon==WEAPON_GUN)
{
game.create_damageind(curpos, -atan2(direction.x,direction.y), 10);
game.world.destroy_entity(this);
}
else
if (!freeze)
game.world.destroy_entity(this);
}
if (lifespan == -1)
{
game.world.destroy_entity(this);
}
}
void PROJECTILE::fill_info(NETOBJ_PROJECTILE *proj)
{
proj->x = (int)pos.x;
proj->y = (int)pos.y;
proj->vx = (int)(direction.x*100.0f);
proj->vy = (int)(direction.y*100.0f);
proj->start_tick = start_tick;
proj->type = type;
}
void PROJECTILE::snap(int snapping_client)
{
float ct = (server_tick()-start_tick)/(float)server_tickspeed();
if(networkclipped(snapping_client, get_pos(ct)))
return;
NETOBJ_PROJECTILE *proj = (NETOBJ_PROJECTILE *)snap_new_item(NETOBJTYPE_PROJECTILE, id, sizeof(NETOBJ_PROJECTILE));
fill_info(proj);
}
|
[
"[email protected]"
] |
[
[
[
1,
136
]
]
] |
71911a40bc564d254bcd6d5f4bdef4c32ad9f2ef
|
0f8559dad8e89d112362f9770a4551149d4e738f
|
/Wall_Destruction/Havok/Source/Common/Base/System/Io/Writer/hkStreamWriter.h
|
1839d414cf348d804bb257a088810c7829049d59
|
[] |
no_license
|
TheProjecter/olafurabertaymsc
|
9360ad4c988d921e55b8cef9b8dcf1959e92d814
|
456d4d87699342c5459534a7992f04669e75d2e1
|
refs/heads/master
| 2021-01-10T15:15:49.289873 | 2010-09-20T12:58:48 | 2010-09-20T12:58:48 | 45,933,002 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 2,599 |
h
|
/*
*
* Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's
* prior written consent. This software contains code, techniques and know-how which is confidential and proprietary to Havok.
* Level 2 and Level 3 source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2009 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement.
*
*/
#ifndef HKBASE_STREAM_WRITER_H
#define HKBASE_STREAM_WRITER_H
/// A generic interface to writing a stream of bytes.
/// The reader may optionally support buffering or may be
/// wrapped as a child stream of an hkBufferedStreamWriter.
class hkStreamWriter : public hkReferencedObject
{
public:
//+serializable(false)
//+vtable(true)
HK_DECLARE_REFLECTION();
HK_DECLARE_CLASS_ALLOCATOR(HK_MEMORY_CLASS_STREAM);
hkStreamWriter() {}
/// Return false if end of file has been reached or some other error.
/// Otherwise return true.
virtual hkBool isOk() const = 0;
/// Write nbytes. Returns the number of bytes written.
/// The number of bytes returned may be less than nbytes
/// (in the case of nonblocking sockets for instance).
virtual int write(const void* buf, int nbytes) = 0;
/// Flush any internal buffers.
virtual void flush() { }
/// Return true if seeking is supported on this stream. By default not supported.
virtual hkBool seekTellSupported() const;
/// Parameter for seek method.
enum SeekWhence { STREAM_SET=0, STREAM_CUR=1, STREAM_END=2 };
/// Seek to offset from whence.
virtual hkResult seek(int offset, SeekWhence whence);
/// Get the current file offset if supported or -1 on error.
/// Default implementation calls seek(0, STREAM_CUR);
virtual int tell() const;
};
#endif //HKBASE_STREAM_WRITER_H
/*
* Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20091222)
*
* Confidential Information of Havok. (C) Copyright 1999-2009
* Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok
* Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership
* rights, and intellectual property rights in the Havok software remain in
* Havok and/or its suppliers.
*
* Use of this software for evaluation purposes is subject to and indicates
* acceptance of the End User licence Agreement for this product. A copy of
* the license is included with this software and is also available at www.havok.com/tryhavok.
*
*/
|
[
"[email protected]"
] |
[
[
[
1,
67
]
]
] |
6f4bd28d12496eeacc29ccd6a267c057e5ea619a
|
b0252ba622183d115d160eb28953189930ebf9c0
|
/Source/CGamePlayState.cpp
|
b84ce329c691439450c7a99aebeb39a158e3b79d
|
[] |
no_license
|
slewicki/khanquest
|
6c0ced33bffd3c9ee8a60c1ef936139a594fe2fc
|
f2d68072a1d207f683c099372454add951da903a
|
refs/heads/master
| 2020-04-06T03:40:18.180208 | 2008-08-28T03:43:26 | 2008-08-28T03:43:26 | 34,305,386 | 2 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 16,013 |
cpp
|
//////////////////////////////////////////////////////////
// File: "CGamePlayState.cpp"
//
// Author: Sean Hamstra (SH)
//
// Purpose: To contain functionality of the gameplay state
//////////////////////////////////////////////////////////
#include "CGamePlayState.h"
#include "ObjectManager.h"
#include "CWorldMapState.h"
#include "CPausedState.h"
#include "HUDState.h"
#include "CFactory.h"
#include "KeyBindState.h"
#include "CGame.h"
CGamePlayState::CGamePlayState(void)
{
PROFILE("CGamePlayState::CGamePlayState()");
m_pCamera = NULL;
m_nButtonID = -1;
m_nHUD_ID = -1;
m_bButtonDown = false;
m_nTerrorLevel = 0;
}
CGamePlayState::~CGamePlayState(void)
{
}
void CGamePlayState::Enter(void)
{
PROFILE("CGamePlayState::Enter()");
// Get Our Managers Ready
m_bIsPaused = false;
m_pTM = CSGD_TextureManager::GetInstance();
m_pWM = CSGD_WaveManager::GetInstance();
m_pDI = CSGD_DirectInput::GetInstance();
m_pES = CEventSystem::GetInstance();
m_pOM = ObjectManager::GetInstance();
Map = CTileEngine::GetInstance();
m_pD3D = CSGD_Direct3D::GetInstance();
m_pHUD = CHUDState::GetInstance();
m_pPE = CParticleEngine::GetInstance();
m_pES->RegisterClient("Play", ObjectManager::GetInstance());
//m_pES->RegisterClient("Remove", ObjectManager::GetInstance());
m_pCamera = CCamera::GetInstance();
m_pCamera->InitCamera(0.f,0.f);
m_pCG = CGame::GetInstance();
m_pPE = CParticleEngine::GetInstance();
// m_nTestEmitter = m_pPE->LoadBineryEmitter("Resource/Emitters/KQ_DustCload.dat", 128, 128);
// Register any Events with the GamePlayState
switch(CGame::GetInstance()->GetSelectedCity()->GetID())
{
case KCITY1:
Map->LoadFile("Resource/Levels/KQ_KWACity1.level");
break;
case KCITY2:
Map->LoadFile("Resource/Levels/KQ_KWACity2.level");
break;
case KCITY3:
Map->LoadFile("Resource/Levels/KQ_KWACity3.level");
break;
case XCITY1:
Map->LoadFile("Resource/Levels/KQ_XIACity1.level");
break;
case XCITY2:
Map->LoadFile("Resource/Levels/KQ_XIACity2.level");
break;
case XCITY3:
Map->LoadFile("Resource/Levels/KQ_XIACity3.level");
break;
case JCITY1:
Map->LoadFile("Resource/Levels/KQ_JinCity1.level");
break;
case JCITY2:
Map->LoadFile("Resource/Levels/KQ_JinCity2.level");
break;
case JCITY3:
Map->LoadFile("Resource/Levels/KQ_JinCity3.level");
break;
default:
Map->LoadFile("Resource/Levels/KQ_Level4.level");
// Bad news bears.
break;
}
m_pOM->UpdatePlayerUnitStartTile();
//---------------------------------
m_rVictoryButton.left = 100;
m_rVictoryButton.top = 500;
m_rVictoryButton.right = 230;
m_rVictoryButton.bottom = 560;
m_nHUD_ID = m_pTM->LoadTexture("Resource/KQ_HUD.png");
m_nButtonID = m_pTM->LoadTexture("Resource/KQ_ScrollButton.png");
m_nLucidiaWhiteID = m_pTM->LoadTexture("Resource/KQ_FontLucidiaWhite.png");
m_nSelectionID = CSGD_TextureManager::GetInstance()->LoadTexture("Resource/KQ_SelectionCircle1.png");
m_nSkyCloudID = m_pPE->LoadBineryEmitter("Resource/Emitters/KQ_SkyClouds.dat", -10, 200);
m_nSkyCloudID2 = m_pPE->LoadBineryEmitter("Resource/Emitters/KQ_SkyClouds2.dat", -10, 200);
CEventSystem::GetInstance()->RegisterClient("Attack_Sound",m_pOM);
CEventSystem::GetInstance()->RegisterClient("Dying_Sound",m_pOM);
m_cFont.InitBitmapFont(m_nLucidiaWhiteID, ' ', 16, 128, 128);
CGame::GetInstance()->SetSongPlay(BATTLESTATE);
m_pHUD->Enter();
if(CGame::GetInstance()->GetTutorialMode())
{
m_bTutorial = true;
m_rTutorial.top = 400;
m_rTutorial.left = 350;
m_rTutorial.bottom = m_rTutorial.top + 64;
m_rTutorial.right = m_rTutorial.left + 128;
}
else
m_bTutorial = false;
Map->LoadImages();
}
void CGamePlayState::Exit(void)
{
PROFILE("CGamePlayState::Exit()");
m_pTM->ReleaseTexture(m_nButtonID);
m_pTM->ReleaseTexture(m_nLucidiaWhiteID);
m_pTM->ReleaseTexture(m_nSelectionID);
// CEventSystem::GetInstance()->ClearEvents();
//Remove all objects from manager?
ObjectManager::GetInstance()->RemoveAllObjects();
for (unsigned int i = 0; i < m_pPE->vEmitterList.size(); ++i)
{
m_pPE->SetIsRunning(i, false);
}
m_pPE->ClearEmitter();
m_pHUD->Exit();
Map->ClearImages();
//m_pHUD->Enter();
}
bool CGamePlayState::Input(float fElapsedTime)
{
PROFILE("CGamePlayState::Input(float)");
if(!m_bTutorial)
{
if(!m_bIsPaused)
{
m_fJoyTimer += fElapsedTime;
if(m_pDI->GetBufferedKey(DIK_ESCAPE) || m_pDI->GetBufferedJoyButton(JOYSTICK_R2))
{
m_bIsPaused = true;
if(m_bIsPaused)
m_pCG->PushState(CPausedState::GetInstance());
}
m_pHUD->Input(fElapsedTime);
#pragma region Controller to Mouse
if(m_pDI->GetJoystickDir(JOYSTICK_UP) && m_pDI->GetJoystickDir(JOYSTICK_LEFT))
{
if(m_fJoyTimer > .0002f)
{
GetCursorPos(&m_ptMousePos);
SetCursorPos(m_ptMousePos.x-3,m_ptMousePos.y-3);
m_fJoyTimer = 0;
}
}
else if(m_pDI->GetJoystickDir(JOYSTICK_UP) && m_pDI->GetJoystickDir(JOYSTICK_RIGHT))
{
if(m_fJoyTimer > .0002f)
{
GetCursorPos(&m_ptMousePos);
SetCursorPos(m_ptMousePos.x+3,m_ptMousePos.y-3);
m_fJoyTimer = 0;
}
}
else if(m_pDI->GetJoystickDir(JOYSTICK_DOWN) && m_pDI->GetJoystickDir(JOYSTICK_LEFT))
{
if(m_fJoyTimer > .0002f)
{
GetCursorPos(&m_ptMousePos);
SetCursorPos(m_ptMousePos.x-3,m_ptMousePos.y+3);
m_fJoyTimer = 0;
}
}
else if(m_pDI->GetJoystickDir(JOYSTICK_DOWN) && m_pDI->GetJoystickDir(JOYSTICK_RIGHT))
{
if(m_fJoyTimer > .0002f)
{
GetCursorPos(&m_ptMousePos);
SetCursorPos(m_ptMousePos.x+3,m_ptMousePos.y+3);
m_fJoyTimer = 0;
}
}
else if(m_pDI->GetJoystickDir(JOYSTICK_UP))
{
if(m_fJoyTimer > .0002f)
{
GetCursorPos(&m_ptMousePos);
SetCursorPos(m_ptMousePos.x,m_ptMousePos.y-3);
m_fJoyTimer = 0;
}
}
else if(m_pDI->GetJoystickDir(JOYSTICK_DOWN))
{
if(m_fJoyTimer > .0002f)
{
GetCursorPos(&m_ptMousePos);
SetCursorPos(m_ptMousePos.x,m_ptMousePos.y+3);
m_fJoyTimer = 0;
}
}
else if(m_pDI->GetJoystickDir(JOYSTICK_LEFT))
{
if(m_fJoyTimer > .0002f)
{
GetCursorPos(&m_ptMousePos);
SetCursorPos(m_ptMousePos.x-3,m_ptMousePos.y);
m_fJoyTimer = 0;
}
}
else if(m_pDI->GetJoystickDir(JOYSTICK_RIGHT))
{
if(m_fJoyTimer > .0002f)
{
GetCursorPos(&m_ptMousePos);
SetCursorPos(m_ptMousePos.x+3,m_ptMousePos.y);
m_fJoyTimer = 0;
}
}
#pragma endregion
if(m_pDI->GetBufferedKey(DIK_F1))
{
//Tile = &Map->GetTile(4,4);
m_pOM->UpdatePlayerUnitDestTile(Map->GetTile(0,2,4));
}
if(m_pDI->GetBufferedKey(DIK_F2))
{
//m_pPE->SetPostion(200, 200, m_nTestEmitter);
//m_pPE->SetIsRunning(m_nTestEmitter, true);
}
if(m_pDI->GetBufferedKey(DIK_F3))
{
m_pOM->SetSelectedUnitsRetreat();
}
/*if(m_pDI->GetBufferedKey(DIK_F8))
{
m_pCG->AddWins(false);
m_pCG->ChangeState(CWorldMapState::GetInstance());
}*/
POINT ptMousePos = m_pCG->GetMousePos();
if(ptMousePos.y <= 450 && ((ptMousePos.x > 0 && ptMousePos.x < 800) && (ptMousePos.y > 0 && ptMousePos.y < 600)))
{
if(m_pDI->GetBufferedMouseButton(M_BUTTON_LEFT) || m_pDI->GetBufferedJoyButton(JOYSTICK_X))
{
m_ptBoxLocation = ptMousePos;
m_ptCurrentLocation.x = m_ptBoxLocation.x + 1;
m_ptCurrentLocation.y = m_ptBoxLocation.y +1;
m_rSelectionBox = GetSelectionRect();
m_pOM->SetSelectedUnit(m_rSelectionBox);
// Only update when selected
CHUDState::GetInstance()->UpdateSelected();
}
else if(m_pDI->GetBufferedMouseButton(M_BUTTON_RIGHT) || m_pDI->GetBufferedJoyButton(JOYSTICK_A))
{
POINT globleMouse = m_pCamera->TransformToGlobal(ptMousePos.x, ptMousePos.y);
globleMouse = Map->IsoMouse(globleMouse.x, globleMouse.y, 0);
m_pOM->UpdatePlayerUnitDestTile(Map->GetTile(0,globleMouse.x, globleMouse.y));
}
else if(m_pDI->GetMouseButton(M_BUTTON_LEFT) || m_pDI->GetJoystickButton(JOYSTICK_X))
{
if(!m_bButtonDown)
{
m_bButtonDown = true;
m_ptBoxLocation = ptMousePos;
}
else
{
m_ptCurrentLocation = m_pCG->GetMousePos();
m_rSelectionBox = GetSelectionRect();
}
}
if(m_pDI->OnMouseButtonRelease(M_BUTTON_LEFT) || m_pDI->GetBufferedJoyButton(JOYSTICK_B))
{
m_pOM->SetSelectedUnit(m_rSelectionBox);
m_bButtonDown = false;
m_ptBoxLocation.x = m_ptBoxLocation.y = 0;
m_ptCurrentLocation.x = m_ptCurrentLocation.y = 0;;
m_rSelectionBox = GetSelectionRect();
CHUDState::GetInstance()->UpdateSelected();
}
}
#pragma region Camera
if(!m_bButtonDown)
{
m_pCamera->SetVelX(0);
m_pCamera->SetVelY(0);
// Mouse Camera Movement
//Move camera Left
if(m_pCG->GetCursorPosition().x <= 5)
m_pCamera->SetVelX(-200);
// Move camera Right
if(m_pCG->GetCursorPosition().x >= 795)
m_pCamera->SetVelX(200);
// Move camera Down
if(m_pCG->GetCursorPosition().y >= 595 )
m_pCamera->SetVelY(200);
// Move camera Up
if(m_pCG->GetCursorPosition().y <= 5)
m_pCamera->SetVelY(-200);
// Keyboard Camera Movement
// Move camera Left
if(m_pDI->GetKey((UCHAR)(CKeyBindState::GetInstance()->GetBoundKey(CAMERA_RIGHT))))
m_pCamera->SetVelX(200);
// Move camera Right
if( m_pDI->GetKey((UCHAR)(CKeyBindState::GetInstance()->GetBoundKey(CAMERA_LEFT))))
m_pCamera->SetVelX(-200);
// Move camera Down
if(m_pDI->GetKey((UCHAR)(CKeyBindState::GetInstance()->GetBoundKey(CAMERA_DOWN))))
m_pCamera->SetVelY(200);
// Move camera Up
if(m_pDI->GetKey((UCHAR)(CKeyBindState::GetInstance()->GetBoundKey(CAMERA_UP))))
m_pCamera->SetVelY(-200);
}
#pragma endregion
}
}
else
{
if(CGame::GetInstance()->IsMouseInRect(m_rTutorial))
{
CGame::GetInstance()->SetCursorClick();
if(m_pDI->GetBufferedMouseButton(M_BUTTON_LEFT)|| m_pDI->GetBufferedJoyButton(JOYSTICK_X))
{
m_bTutorial = false;
}
}
}
return true;
}
void CGamePlayState::Update(float fElapsedTime)
{
PROFILE("CGamePlayState::Update(float)");
// Rendered Paused
if(!m_bIsPaused)
{
if(m_bIsPaused)
return;
m_pCamera->Update(fElapsedTime);
// Update units
m_pOM->UpdateObjects(fElapsedTime);
m_pHUD->Update(fElapsedTime);
m_pES->ProcessEvents();
}
}
void CGamePlayState::Render(float fElapsedTime)
{
PROFILE("CGamePlayState::Render(float)");
if(!m_bTutorial)
{
// Render units
// Temp for map changes
//-----------------------------------------------
/*if( m_pDI->GetBufferedKey(DIK_1))
Map->LoadFile("Resource/Levels/KQ_Wawa.level");
else if( m_pDI->GetBufferedKey(DIK_2))
Map->LoadFile("Resource/Levels/KQ_Wee.level");
else if( m_pDI->GetBufferedKey(DIK_3))
Map->LoadFile("Resource/Levels/KQ_Tech_Demo1.level");*/
POINT MapLoc = m_pCamera->TransformToGlobal(m_pCG->GetCursorPosition().x, m_pCG->GetCursorPosition().y);
Map->Render(m_pCamera->GetScreenArea());
#if _DEBUG
if(m_pDI->GetMouseButton(M_BUTTON_RIGHT))
{
char buffer[32]; //Tile Pos
char buffer2[32]; //Tile Type
char buffer3[32]; //Player Spawn
char buffer4[32]; //Local Anchor
char buffer5[32]; //Global Anchor
POINT TileLoc = Map->IsoMouse(MapLoc.x, MapLoc.y, 0);
sprintf_s(buffer, 32, "Tile: %i, %i", TileLoc.x, TileLoc.y);
sprintf_s(buffer2, 32, "TileType: %i", Map->GetTile(0,TileLoc.x, TileLoc.y)->nType);
if(Map->GetTile(0,TileLoc.x, TileLoc.y)->bIsPlayerSpawn == true)
sprintf_s(buffer3, 32, "PlayerSpawn: True");
else
sprintf_s(buffer3, 32, "PlayerSpawn: False");
POINT miniTileLoc = Map->IsoMiniMouse(m_pCG->GetCursorPosition().x, m_pCG->GetCursorPosition().y, 0);
sprintf_s(buffer4, 32, "Local Anchor: %i, %i", Map->GetTile(0,TileLoc.x, TileLoc.y)->ptLocalAnchor.x, Map->GetTile(0,TileLoc.x, TileLoc.y)->ptLocalAnchor.y);
sprintf_s(buffer5, 32, "Global Anchor: %i, %i", MapLoc.x, MapLoc.y);
m_cFont.DrawTextA(buffer, 500, 0, .2f, .2f);
m_cFont.DrawTextA(buffer2, 500, 30, .2f, .2f);
m_cFont.DrawTextA(buffer3, 500, 60, .2f, .2f);
m_cFont.DrawTextA(buffer4, 500, 90, .2f, .2f);
m_cFont.DrawTextA(buffer5, 500, 120, .2f, .2f);
sprintf_s(buffer5, 32, "Minimap Tile: %i, %i", miniTileLoc.x, miniTileLoc.y);
m_cFont.DrawTextA(buffer5, 500, 150, .2f, .2f);
}
#endif
m_pOM->RenderObjects(fElapsedTime);
// Temp for demo
m_pTM->Draw(m_nButtonID, m_rVictoryButton.left, m_rVictoryButton.top, .4f, .3f);
//Map->ParalaxScroll(true, m_pCamera->GetScreenArea());
m_cFont.DrawTextA("Victory", m_rVictoryButton.left+30, m_rVictoryButton.top+24, .2f, .2f, D3DCOLOR_ARGB(255, 255, 0, 0));
//----------------------------------------------
RECT rHud;
rHud.top = rHud.left = 0;
rHud.bottom = 600;
rHud.right = 800;
POINT pSkyCloud = m_pCamera->TransformToScreen(0, -10);
m_pPE->SetPostion((float)pSkyCloud.x, (float)pSkyCloud.y, m_nSkyCloudID);
m_pPE->SetIsRunning(m_nSkyCloudID, true);
POINT pSkyCloud2 = m_pCamera->TransformToScreen(0, -10);
m_pPE->SetPostion((float)pSkyCloud2.x, (float)pSkyCloud2.y, m_nSkyCloudID2);
m_pPE->SetIsRunning(m_nSkyCloudID2, true);
m_pHUD->Render(fElapsedTime);
// m_pTM->Draw(m_nHUD_ID,0,0,1,1,&rHud);
// Render selection Box
m_pD3D->SpriteEnd();
m_pD3D->LineEnd();
m_pD3D->DeviceEnd();
//m_pD3D->DrawLine(0,450,800,450,255,0,0);
m_pD3D->DrawPrimitiveRect(m_rSelectionBox, D3DCOLOR_ARGB(255,255,255,255));
m_pD3D->DeviceBegin();
m_pD3D->LineBegin();
m_pD3D->SpriteBegin();
//---------------------------------------------
/*char buffer[128];
sprintf_s(buffer, 128, "%i, %i", m_pCG->GetCursorPosition().x,m_pCG->GetCursorPosition().y);
m_cFont.DrawTextA(buffer, 0, 0);*/
}
else if(CGame::GetInstance()->GetTutorialMode())
{
RECT toDraw; toDraw.top = 0; toDraw.left = 0; toDraw.right = 578; toDraw.bottom = 495;
int nImage = m_pTM->LoadTexture("Resource/KQ_TutorialBox.png");
m_pTM->Draw(nImage,0,2,1.4f,1.2f,&toDraw);
m_nScrollButtonID = m_pTM->LoadTexture("Resource/KQ_ScrollButton.png");
m_pTM->Draw(m_nScrollButtonID,325,400,.4f,.3f);
m_cFont.DrawTextA("Accept",350,425,.2f,.2f,D3DCOLOR_ARGB(255,255,0,0));
m_cFont.DrawTextA("Tutorial",315,15,.4f,.4f,D3DCOLOR_ARGB(255,255,0,0));
m_cFont.DrawTextA("Press Arrow Keys to move the camera. These /settings are adjustable through the options /menu. Click and hold the left mouse button./Drag the mouse over units to select them./Right click to move the selected units.//The objective here is to seek out all /enemies on the map and defeat them.",80,100,.25f,.25f,D3DCOLOR_ARGB(255,0,0,0));
}
}
string CGamePlayState::IntToString(int nNum)
{
PROFILE("CGamePlayState::IntToString(int)");
char szNumVal[10];
itoa(nNum, szNumVal, 10);
string szNum = szNumVal;
return szNum;
}
RECT CGamePlayState::GetSelectionRect()
{
PROFILE("CGamePlayState::GetSelectionRect()");
RECT toDraw;
toDraw.top = m_ptBoxLocation.y;
toDraw.left = m_ptBoxLocation.x;
toDraw.bottom = m_ptCurrentLocation.y;
toDraw.right = m_ptCurrentLocation.x;
if(toDraw.bottom == toDraw.top)
toDraw.bottom++;
if(toDraw.left == toDraw.right)
toDraw.right++;
int nSwap;
if(toDraw.top > toDraw.bottom)
{
nSwap = toDraw.top;
toDraw.top = toDraw.bottom;
toDraw.bottom = nSwap;
}
if(toDraw.left > toDraw.right)
{
nSwap = toDraw.left;
toDraw.left = toDraw.right;
toDraw.right = nSwap;
}
return toDraw;
}
|
[
"[email protected]@631b4192-2952-0410-9426-c5ed74a7d3ec",
"[email protected]@631b4192-2952-0410-9426-c5ed74a7d3ec",
"[email protected]@631b4192-2952-0410-9426-c5ed74a7d3ec",
"[email protected]@631b4192-2952-0410-9426-c5ed74a7d3ec",
"[email protected]@631b4192-2952-0410-9426-c5ed74a7d3ec"
] |
[
[
[
1,
9
],
[
16,
16
],
[
18,
19
],
[
21,
22
],
[
27,
32
],
[
34,
38
],
[
40,
40
],
[
42,
45
],
[
52,
57
],
[
61,
62
],
[
107,
107
],
[
117,
117
],
[
120,
120
],
[
123,
123
],
[
128,
128
],
[
133,
147
],
[
149,
151
],
[
153,
154
],
[
166,
169
],
[
172,
172
],
[
276,
276
],
[
323,
323
],
[
332,
332
],
[
335,
335
],
[
338,
338
],
[
341,
341
],
[
346,
346
],
[
349,
349
],
[
352,
352
],
[
355,
355
],
[
372,
376
],
[
386,
386
],
[
391,
395
],
[
409,
409
],
[
424,
424
],
[
427,
427
],
[
480,
480
],
[
498,
498
],
[
500,
503
],
[
505,
509
],
[
519,
522
]
],
[
[
10,
13
],
[
15,
15
],
[
17,
17
],
[
23,
26
],
[
33,
33
],
[
41,
41
],
[
48,
49
],
[
59,
59
],
[
63,
65
],
[
67,
69
],
[
71,
73
],
[
79,
79
],
[
132,
132
],
[
152,
152
],
[
171,
171
],
[
173,
270
],
[
272,
272
],
[
274,
275
],
[
277,
322
],
[
324,
329
],
[
342,
345
],
[
347,
348
],
[
350,
351
],
[
353,
354
],
[
357,
371
],
[
378,
384
],
[
387,
390
],
[
398,
404
],
[
406,
406
],
[
408,
408
],
[
410,
411
],
[
413,
413
],
[
416,
423
],
[
425,
426
],
[
434,
445
],
[
447,
447
],
[
449,
451
],
[
453,
458
],
[
460,
462
],
[
465,
467
],
[
469,
479
],
[
481,
497
],
[
499,
499
],
[
510,
512
],
[
514,
518
],
[
523,
537
]
],
[
[
14,
14
],
[
271,
271
],
[
273,
273
],
[
396,
396
]
],
[
[
20,
20
],
[
39,
39
],
[
148,
148
],
[
163,
164
],
[
170,
170
],
[
377,
377
],
[
397,
397
],
[
412,
412
],
[
414,
414
],
[
448,
448
],
[
504,
504
],
[
513,
513
]
],
[
[
46,
47
],
[
50,
51
],
[
58,
58
],
[
60,
60
],
[
66,
66
],
[
70,
70
],
[
74,
78
],
[
80,
106
],
[
108,
116
],
[
118,
119
],
[
121,
122
],
[
124,
127
],
[
129,
131
],
[
155,
162
],
[
165,
165
],
[
330,
331
],
[
333,
334
],
[
336,
337
],
[
339,
340
],
[
356,
356
],
[
385,
385
],
[
405,
405
],
[
407,
407
],
[
415,
415
],
[
428,
433
],
[
446,
446
],
[
452,
452
],
[
459,
459
],
[
463,
464
],
[
468,
468
]
]
] |
f33f4e6c9b0f25fbf24fabfe48e92c517fafb321
|
171daeea8e21d62e4e1ea549f94fcf638c542c25
|
/ZhengWu/Mocap_MB2011_Offline_1.0.0/skeletondevicetester.cpp
|
3b1fe4ae3dc70f1f90d520102514224116740282
|
[] |
no_license
|
sworldy/snarcmotioncapture
|
b8c848ee64212cfb38f002bdd183bf4b6257a9c7
|
d4f57f0b7e2ecda6375c11eaa7f6a6b6d3d0af21
|
refs/heads/master
| 2021-01-13T02:02:54.097775 | 2011-08-07T16:46:24 | 2011-08-07T16:46:24 | 33,110,437 | 0 | 0 | null | null | null | null |
GB18030
|
C++
| false | false | 20,070 |
cpp
|
// TCP/IP server : test for ordeviceskeleton
//
#include <stdio.h>
#include <iostream>
#include <vector>
#define WS_VERSION_REQUIRED 0x0101
#define NAN 19
#define DSCALE 175.987693025/1.7;
#include <winsock.h>
#include <windows.h>
#include <fstream>
//--- SDK include
#include "DeviceBuffer.h"
#include "Fusion.h"
using namespace std;
//ifstream qFile[31] = {ifstream("0.txt"),ifstream("1.txt"),ifstream("2.txt"),ifstream("3.txt"),
//ifstream("4.txt"),ifstream("5.txt"),ifstream("6.txt"),ifstream("7.txt"),ifstream("8.txt"),
//ifstream("9.txt"),ifstream("10.txt"),ifstream("11.txt"),ifstream("12.txt"),ifstream("13.txt"),
//ifstream("14.txt"),ifstream("15.txt"),ifstream("16.txt"),ifstream("17.txt"),ifstream("18.txt"),
//ifstream("19.txt"),ifstream("20.txt"),ifstream("21.txt"),ifstream("22.txt"),ifstream("23.txt"),
//ifstream("24.txt"),ifstream("25.txt"),ifstream("26.txt"),ifstream("27.txt"),ifstream("28.txt"),
//ifstream("29.txt"),ifstream("displacement.txt")};
ifstream sFile[16] = {ifstream("0.txt"),ifstream("1.txt"),ifstream("2.txt"),ifstream("3.txt"),
ifstream("4.txt"),ifstream("5.txt"),ifstream("6.txt"),ifstream("7.txt"),ifstream("8.txt"),
ifstream("9.txt"),ifstream("10.txt"),ifstream("11.txt"),ifstream("12.txt"),ifstream("13.txt"),
ifstream("14.txt"),ifstream("15.txt")};
ofstream tFile[3] = {ofstream("q0.txt"),ofstream("q1.txt"),ofstream("q2.txt")};
vector<vector<vector<float> > > dQuaternion;
vector<vector<vector<double> > > VSensorRawData;
double dtmp[3] = {0,0,0};
bool statFile[31];
bool IsData[16];
int Cnt = 0;
size_t dataLen;
Fusion* Quat_Dis=new Fusion();
int sensor2bone[31] = {3,7,8,9,NAN,NAN,0,1,2,NAN,NAN,4,4,5,6,NAN,16,10,11,12,NAN,NAN,NAN,17,13,14,15,NAN,NAN,NAN};
bool Cleanup()
{
if (WSACleanup())
{
// GetErrorStr();
WSACleanup();
return false;
}
return true;
}
bool Initialize()
{
WSADATA wsadata;
if (WSAStartup(WS_VERSION_REQUIRED, &wsadata))
{
// GetErrorStr();
Cleanup();
return false;
}
return true;
}
void bzero(char *b, size_t length)
{
memset( b,0,length );
}
int StartServer(int pPort)
{
int lSocket;
struct protoent* lP;
struct sockaddr_in lSin;
Initialize();
lP = getprotobyname("tcp");
lSocket = socket(AF_INET, SOCK_STREAM, lP->p_proto);
if (lSocket)
{
bzero((char *)&lSin, sizeof(lSin));
lSin.sin_family = AF_INET;
lSin.sin_port = htons(pPort);
lSin.sin_addr.s_addr = 0L;
//Bind socket
if( bind(lSocket, (struct sockaddr*)&lSin, sizeof(lSin)) < 0 )
{
return 0;
}
if( listen(lSocket, 5) < 0 )
{
return 0;
}
}
return lSocket;
}
nsTime GetNanoSeconds()
{
static double dmUnits = 0.0;
LARGE_INTEGER t;
if(QueryPerformanceCounter(&t))
{
double count;
count = (double) t.QuadPart;
if (!dmUnits)
{
QueryPerformanceFrequency(&t);
dmUnits = 1000000000.0 / (double) t.QuadPart;
}
return (unsigned __int64) (count * dmUnits);
}
return 0;
}
//void Quaternion2Matrix(FBQuaternion &pvector,FBMatrix &pmatrix)
//{
// double x2,y2,z2,xy,yz,xz,xw,yw,zw;
// x2 = pvector.mValue[0] * pvector.mValue[0] * 2;
// y2 = pvector.mValue[1] * pvector.mValue[1] * 2;
// z2 = pvector.mValue[2] * pvector.mValue[2] * 2;
// xy = pvector.mValue[0] * pvector.mValue[1] * 2;
// yz = pvector.mValue[2] * pvector.mValue[1] * 2;
// xz = pvector.mValue[0] * pvector.mValue[2] * 2;
// xw = pvector.mValue[0] * pvector.mValue[3] * 2;
// yw = pvector.mValue[1] * pvector.mValue[3] * 2;
// zw = pvector.mValue[2] * pvector.mValue[3] * 2;
// pmatrix(0,0) = 1 - y2 - z2;
// pmatrix(0,1) = xy + zw;
// pmatrix(0,2) = xz - yw;
// pmatrix(0,3) = 0;
// pmatrix(1,0) = xy - zw;
// pmatrix(1,1) = 1 - x2 - z2;
// pmatrix(1,2) = yz + xw;
// pmatrix(1,3) = 0;
// pmatrix(2,0) = xz + yw;
// pmatrix(2,1) = yz - xw;
// pmatrix(2,2) = 1 - x2 - y2;
// pmatrix(2,3) = 0;
// pmatrix(3,0) = 0;
// pmatrix(3,1) = 0;
// pmatrix(3,2) = 0;
// pmatrix(3,3) = 1;
//}
//void MatLocalRotation(FBMatrix parentMat,FBMatrix &pchildMat,FBMatrix TransMat)
//{
// FBMatrix tmpMat,tmpParentRotMat,tmpTansMat;
// FBGetLocalMatrix(tmpMat,parentMat,pchildMat);
// tmpParentRotMat = parentMat;
// for (int i = 0; i<3; i++) // Delete Translation Information
// {
// tmpParentRotMat[12+i] = 0;
// }
//
// FBMatrixMult(tmpMat,TransMat,tmpMat);
// FBGetGlobalMatrix(pchildMat,parentMat,tmpMat);
//}
//void LocalRotation(sDataBuffer& mDataBuffer,int parent,int child,FBMatrix TransMat)
//{
// FBMatrix parentMat,childMat,tmpMat;
// //Generate parentMat
// FBRotationToMatrix(parentMat,mDataBuffer.mChannel[parent].mR);
// memcpy(&parentMat[12], mDataBuffer.mChannel[parent].mT,sizeof(mDataBuffer.mChannel[parent].mT));
// //Generate childMat
// FBRotationToMatrix(childMat,mDataBuffer.mChannel[child].mR);
// memcpy(&childMat[12], mDataBuffer.mChannel[child].mT,sizeof(mDataBuffer.mChannel[child].mT));
// //Calculate Mat
// MatLocalRotation(parentMat,childMat,TransMat);
// //Update Translation
// memcpy(&mDataBuffer.mChannel[child].mT,&childMat[12],sizeof(mDataBuffer.mChannel[child].mT));
//
//}
//void ForceRotation(sDataBuffer& mDataBuffer,double * lcl,int parent,int child)
//{
// for (int i = 0; i<3; i++)
// {
// mDataBuffer.mChannel[child].mT[i] = *(lcl + i) + mDataBuffer.mChannel[parent].mT[i];
// }
//}
//void GetlclTrans(double * lcl,sDataBuffer& mDataBuffer,int parent,int child)
//{
// for (int i = 0; i <3 ; i++)
// {
// *(lcl+i) = mDataBuffer.mChannel[child].mT[i] - mDataBuffer.mChannel[parent].mT[i];
// }
//}
//void PartRotation(sDataBuffer& mDataBuffer,int parent, int child, FBMatrix Transmat)
//{
//
//}
//void RotationLocalize(sDataBuffer& mDataBuffer,int child,FBMatrix TransMat)
//{
// FBMatrix lclrefMat,lclMat,GblChannelMat;
// FBRotationToMatrix(lclrefMat,mDataBuffer.mChannel[child].mR);
// FBRotationToMatrix(GblChannelMat,mDataBuffer.mChannel[child].mR);
// memcpy(&GblChannelMat[12], mDataBuffer.mChannel[child].mT,sizeof(mDataBuffer.mChannel[child].mT));
// FBGetLocalMatrix(lclMat,lclrefMat,GblChannelMat);
// FBMatrixMult(lclMat,TransMat,lclMat);
// FBGetGlobalMatrix(GblChannelMat,lclrefMat,lclMat);
// FBMatrixToRotation((FBRVector&)*mDataBuffer.mChannel[child].mR,GblChannelMat);
//
//}
void InformCpy(sDataBuffer& mDataBuffer,int ID, int num)
{
for (int i = 1; i< num +1; i++)
{
for (int j = 0; j < 3; j++)
{
mDataBuffer.mChannel[ID+i].mR[j] = mDataBuffer.mChannel[ID].mR[j];
mDataBuffer.mChannel[ID+i].mT[j] = mDataBuffer.mChannel[ID].mT[j];
}
}
}
//void UpdateInformation(sDataBuffer& mDataBuffer, int ID,FBMatrix TransMat)
//{
// double lcl[3],lcl0[3],lcl1[3],lcl2[3],lcl3[3],lcl4[3],lcl5[3],lcl6[3],lcl7[3];
// double lcl8[3],lcl9[3],lcla[3],lclb[3],lclc[3],lcld[3],lcle[3],lclf[3];
//
// switch (ID)
// {
// case 0:
// GetlclTrans(&lcl0[0],mDataBuffer,11,12);
// GetlclTrans(&lcl1[0],mDataBuffer,11,13);
// GetlclTrans(&lcl2[0],mDataBuffer,11,16);
// GetlclTrans(&lcl3[0],mDataBuffer,11,17);
// GetlclTrans(&lcl4[0],mDataBuffer,11,18);
// GetlclTrans(&lcl5[0],mDataBuffer,11,19);
// GetlclTrans(&lcl6[0],mDataBuffer,11,23);
// GetlclTrans(&lcl7[0],mDataBuffer,11,24);
// GetlclTrans(&lcl8[0],mDataBuffer,11,25);
// GetlclTrans(&lcl9[0],mDataBuffer,11,26);
// GetlclTrans(&lcla[0],mDataBuffer,11,14);
// GetlclTrans(&lclb[0],mDataBuffer,11,15);
// LocalRotation(mDataBuffer,0,11,TransMat);
// ForceRotation(mDataBuffer,&lcl0[0],11,12);
// ForceRotation(mDataBuffer,&lcl1[0],11,13);
// ForceRotation(mDataBuffer,&lcl2[0],11,16);
// ForceRotation(mDataBuffer,&lcl3[0],11,17);
// ForceRotation(mDataBuffer,&lcl4[0],11,18);
// ForceRotation(mDataBuffer,&lcl5[0],11,19);
// ForceRotation(mDataBuffer,&lcl6[0],11,23);
// ForceRotation(mDataBuffer,&lcl7[0],11,24);
// ForceRotation(mDataBuffer,&lcl8[0],11,25);
// ForceRotation(mDataBuffer,&lcl9[0],11,26);
// ForceRotation(mDataBuffer,&lcla[0],11,14);
// ForceRotation(mDataBuffer,&lclb[0],11,15);
//
// GetlclTrans(&lcl0[0],mDataBuffer,1,2);
// GetlclTrans(&lcl1[0],mDataBuffer,1,3);
// LocalRotation(mDataBuffer,0,1,TransMat);
// ForceRotation(mDataBuffer,&lcl0[0],1,2);
// ForceRotation(mDataBuffer,&lcl1[0],1,3);
//
// GetlclTrans(&lcl0[0],mDataBuffer,6,7);
// GetlclTrans(&lcl1[0],mDataBuffer,6,8);
// LocalRotation(mDataBuffer,0,6,TransMat);
// ForceRotation(mDataBuffer,&lcl0[0],6,7);
// ForceRotation(mDataBuffer,&lcl1[0],6,8);
//
// RotationLocalize(mDataBuffer,ID,TransMat);
// break;
// case 1:
// GetlclTrans(&lcl[0],mDataBuffer,2,3);
// LocalRotation(mDataBuffer,1,2,TransMat);
// ForceRotation(mDataBuffer,&lcl[0],2,3);
// RotationLocalize(mDataBuffer,ID,TransMat);
// break;
// case 2:
// LocalRotation(mDataBuffer,2,3,TransMat);
// RotationLocalize(mDataBuffer,ID,TransMat);
// break;
// case 3:
// RotationLocalize(mDataBuffer,ID,TransMat);
// InformCpy(mDataBuffer,ID,2);
// break;
// case 4:
// break;
// case 5:
// break;
// case 6:
// GetlclTrans(&lcl[0],mDataBuffer,7,8);
// LocalRotation(mDataBuffer,6,7,TransMat);
// ForceRotation(mDataBuffer,&lcl[0],7,8);
// RotationLocalize(mDataBuffer,ID,TransMat);
// break;
// case 7:
// LocalRotation(mDataBuffer,7,8,TransMat);
// RotationLocalize(mDataBuffer,ID,TransMat);
// break;
// case 8:
// RotationLocalize(mDataBuffer,ID,TransMat);
// InformCpy(mDataBuffer,ID,2);
// break;
// case 9:
// break;
// case 10:
// break;
// case 11:
// GetlclTrans(&lcl0[0],mDataBuffer,12,13);
// GetlclTrans(&lcl1[0],mDataBuffer,12,14);
// GetlclTrans(&lcl2[0],mDataBuffer,12,15);
// GetlclTrans(&lcl3[0],mDataBuffer,12,16);
// GetlclTrans(&lcl4[0],mDataBuffer,12,17);
// GetlclTrans(&lcl5[0],mDataBuffer,12,18);
// GetlclTrans(&lcl6[0],mDataBuffer,12,19);
// GetlclTrans(&lcl7[0],mDataBuffer,12,23);
// GetlclTrans(&lcl8[0],mDataBuffer,12,24);
// GetlclTrans(&lcl9[0],mDataBuffer,12,25);
// GetlclTrans(&lcla[0],mDataBuffer,12,26);
// LocalRotation(mDataBuffer,11,12,TransMat);
// ForceRotation(mDataBuffer,&lcl0[0],12,13);
// ForceRotation(mDataBuffer,&lcl1[0],12,14);
// ForceRotation(mDataBuffer,&lcl2[0],12,15);
// ForceRotation(mDataBuffer,&lcl3[0],12,16);
// ForceRotation(mDataBuffer,&lcl4[0],12,17);
// ForceRotation(mDataBuffer,&lcl5[0],12,18);
// ForceRotation(mDataBuffer,&lcl6[0],12,19);
// ForceRotation(mDataBuffer,&lcl7[0],12,23);
// ForceRotation(mDataBuffer,&lcl8[0],12,24);
// ForceRotation(mDataBuffer,&lcl9[0],12,25);
// ForceRotation(mDataBuffer,&lcla[0],12,26);
//
// RotationLocalize(mDataBuffer,ID,TransMat);
// break;
// case 12:
// GetlclTrans(&lcl[0],mDataBuffer,16,17);
// GetlclTrans(&lcl1[0],mDataBuffer,16,18);
// GetlclTrans(&lcl2[0],mDataBuffer,16,19);
// GetlclTrans(&lcl3[0],mDataBuffer,23,24);
// GetlclTrans(&lcl4[0],mDataBuffer,23,25);
// GetlclTrans(&lcl5[0],mDataBuffer,23,26);
// LocalRotation(mDataBuffer,12,16,TransMat);
// LocalRotation(mDataBuffer,12,23,TransMat);
// ForceRotation(mDataBuffer,&lcl[0],16,17);
// ForceRotation(mDataBuffer,&lcl1[0],16,18);
// ForceRotation(mDataBuffer,&lcl2[0],16,19);
// ForceRotation(mDataBuffer,&lcl3[0],23,24);
// ForceRotation(mDataBuffer,&lcl4[0],23,25);
// ForceRotation(mDataBuffer,&lcl5[0],23,26);
//
// GetlclTrans(&lcl[0],mDataBuffer,13,14);
// GetlclTrans(&lcl1[0],mDataBuffer,13,15);
// LocalRotation(mDataBuffer,12,13,TransMat);
// ForceRotation(mDataBuffer,&lcl[0],13,14);
// ForceRotation(mDataBuffer,&lcl1[0],13,15);
//
// RotationLocalize(mDataBuffer,ID,TransMat);
// break;
// case 13:
// GetlclTrans(&lcl1[0],mDataBuffer,14,15);
// LocalRotation(mDataBuffer,13,14,TransMat);
// ForceRotation(mDataBuffer,&lcl[0],14,15);
//
//
// RotationLocalize(mDataBuffer,ID,TransMat);
// break;
// case 16:
// GetlclTrans(&lcl[0],mDataBuffer,17,18);
// GetlclTrans(&lcl1[0],mDataBuffer,17,19);
// LocalRotation(mDataBuffer,16,17,TransMat);
// ForceRotation(mDataBuffer,&lcl[0],17,18);
// ForceRotation(mDataBuffer,&lcl1[0],17,19);
//
// RotationLocalize(mDataBuffer,ID,TransMat);
// break;
//
// case 17:
// GetlclTrans(&lcl[0],mDataBuffer,18,19);
// LocalRotation(mDataBuffer,17,18,TransMat);
// ForceRotation(mDataBuffer,&lcl[0],18,19);
// RotationLocalize(mDataBuffer,ID,TransMat);
// break;
// case 18:
// LocalRotation(mDataBuffer,18,19,TransMat);
// RotationLocalize(mDataBuffer,ID,TransMat);
// break;
// case 19:
// RotationLocalize(mDataBuffer,ID,TransMat);
// InformCpy(mDataBuffer,ID,3);
// break;
// case 20:
// break;
// case 21:
// break;
// case 22:
// break;
// case 23:
// GetlclTrans(&lcl[0],mDataBuffer,24,25);
// GetlclTrans(&lcl1[0],mDataBuffer,24,26);
// LocalRotation(mDataBuffer,23,24,TransMat);
// ForceRotation(mDataBuffer,&lcl[0],24,25);
// ForceRotation(mDataBuffer,&lcl1[0],24,26);
//
// RotationLocalize(mDataBuffer,ID,TransMat);
// break;
// case 24:
// GetlclTrans(&lcl[0],mDataBuffer,25,26);
// LocalRotation(mDataBuffer,24,25,TransMat);
// ForceRotation(mDataBuffer,&lcl[0],25,26);
// RotationLocalize(mDataBuffer,ID,TransMat);
// break;
// case 25:
// LocalRotation(mDataBuffer,25,26,TransMat);
// RotationLocalize(mDataBuffer,ID,TransMat);
// break;
// case 26:
// RotationLocalize(mDataBuffer,ID,TransMat);
// InformCpy(mDataBuffer,ID,3);
// break;
// case 27:
// break;
// case 28:
// break;
// case 29:
// break;
// default:
// RotationLocalize(mDataBuffer,ID,TransMat);
// break;
//
// }
//}
void TransUpdate(sDataBuffer& mDataBuffer,vector<vector<float> >* ptmp)
{
double dt[3];
if (Cnt != 0)
{
for (int i = 0; i < 3; i++)
dt[i] = ptmp->at(Cnt).at(i) - ptmp->at(Cnt-1).at(i);
}
else
{
for (int i = 0; i < 3; i++)
dt[i] = 0;
//dt[0] = 300 / DSCALE; // Double Test
}
for (int i = 0; i < 30; i++)
{
for (int j = 0; j < 3; j++)
{
mDataBuffer.mChannel[i].mT[j] += dt[j]*DSCALE;
}
}
}
void UpdateBuffer(sDataBuffer& mDataBuffer)
{
vector<vector<float> >* ptmp;
//FBQuaternion Quater[30];
//FBMatrix lTransformation;
vector<vector<double> >* ptmpp;
vector<float>* ptmpf2;
double dtmp3[4],dtmp4[4];
if (Cnt == dataLen)
{
mDataBuffer.SetupBuffer();
Cnt = 0;
}
for(int i=0; i<18; i++) // SENSOR_NUM=16, 代表sensor个数
{
ptmp = &dQuaternion.at(i); // 第i个Sensor
ptmpf2 = &ptmp->at(Cnt); // 第j个数据点
for (int j = 0; j < 4; j++)
{
mDataBuffer.rawdata[i][j] = ptmpf2->at(j);
}
}
ptmp = &dQuaternion.at(18); // 第i个Sensor
ptmpf2 = &ptmp->at(Cnt); // 第j个数据点
for (int j = 0; j < 3; j++)
{
mDataBuffer.displace[j] = ptmpf2->at(j);
}
ptmp = &dQuaternion.at(18);
//TransUpdate(mDataBuffer,ptmp);
for (int i = 0; i< 30; i++)
{
if (statFile[sensor2bone[i]])
{
ptmp = &dQuaternion.at(sensor2bone[i]);
// Insert Difference
if (Cnt != 0)
{
for (int k = 0; k < 4; k++)
{
dtmp3[k] = -1 * ptmp->at(Cnt-1).at(k);
dtmp4[k] = ptmp->at(Cnt).at(k);
}
dtmp3[3] = -1 * dtmp3[3];
Quat_Dis->Quaternion_Multiple(dtmp3,dtmp4);
/*for (int j = 0; j < 4; j++)
{
Quater[i].mValue[j] = dtmp3[j];
}*/
}
else
{
/*for (int j = 0; j < 4; j++)
{
Quater[i].mValue[j] = ptmp->at(Cnt).at(j);
}*/
}
// Insert End
//Quaternion2Matrix(Quater[i],lTransformation);
//UpdateInformation(mDataBuffer,i,lTransformation);
}
}
Cnt++;
mDataBuffer.mCounter++;
}
int main(int argc, char* argv[])
{
int lineNum;
float tmp;
vector<vector<double> >* ptmp;
vector<vector<float> >* ptmpf;
vector<double>* ptmp2;
vector<float>* ptmpf2;
double* pbuf;
double Quat_Result[18][4]; // DIM_QUAT为4, quaternion维度;
double Dis_Result[3]; // DIM_VEC=3. 3维向量,存储位移结果
double Dis_AResult[3];
double Quat_ResAug[2][DIM_QUAT];
double dtmp[18][4],dtmp2[18][4],dtmp3[4],dtmp4[4];
sDataBuffer mb;
size_t a = sizeof(mb);
//std::string s =new std::string;
for (int i = 0; i < 16; i++)
{
VSensorRawData.push_back(vector <vector<double> >());
if (!sFile[i])
{
//No File
cerr << "Warning: Miss Sensor Data in " << i << "\n";
IsData[i] = FALSE;
}
else
{
ptmp = &VSensorRawData.at(i);
ptmp->push_back(vector<double>());
vector<double>* p = &ptmp->back();
lineNum = 0;
while (!sFile[i].eof())
{
sFile[i] >> tmp;
p->push_back(tmp);
if(++lineNum % 9 == 0)
{
ptmp->push_back(std::vector<double>());
p = &(ptmp->back());
}
}
sFile[i].close();
ptmp->pop_back();
cout << i << "..." << "\n";
statFile[i] = TRUE;
dataLen = ptmp->size();
}
}
statFile[16] = TRUE;statFile[17] = TRUE;
cout << "Done...\n";
cout << "Process Data...\n";
for (int i = 0; i<19; i++)
{
dQuaternion.push_back(vector <vector<float> >());
}
for (int j = 0; j < (int)dataLen; j++)
{
for(int i=0; i<SENSOR_NUM; i++) // SENSOR_NUM=16, 代表sensor个数
{
ptmp = &VSensorRawData.at(i); // 第i个Sensor
ptmp2 = &ptmp->at(j); // 第j个数据点
pbuf = &(ptmp2->at(0)); //指针
Quat_Dis->Get_Measure(i,pbuf); // 16个sensor遍历一遍,第一处
}
Quat_Dis->WholeBodyFusion(Quat_Result,Dis_Result); // 16个sensor遍历结束后,全身融合,第二处
Quat_Dis->Quaternion_Augment2(Quat_Result); // 写入左右肩膀的位移
//FrameTrans of Dis
Dis_AResult[2] = Dis_Result[0];
Dis_AResult[0] = -1 * Dis_Result[1];
Dis_AResult[1] = -1 * Dis_Result[2];
Dis_AResult[1] += 0.80;
//
ptmpf = &dQuaternion.at(18);
ptmpf->push_back(vector<float>());
ptmpf2 = &ptmpf->back();
for (int dim = 0; dim < 3; dim++)
ptmpf2->push_back((float)Dis_AResult[dim]);
for (int node = 0; node < 18; node++)
{
ptmpf = &dQuaternion.at(node);
ptmpf->push_back(vector<float>());
ptmpf2 = &ptmpf->back();
for (int dim = 0; dim < 4; dim++)
ptmpf2->push_back((float)Quat_Result[node][dim]);
}
}
//Debug Module
/*ptmpf = &dQuaternion.at(2);
for (int xx = 0; xx < dataLen; xx++)
{
for (int yy = 0; yy < DIM_QUAT; yy++)
{
tFile[2] << ptmpf->at(xx).at(yy) << "\t";
}
tFile[2] << "\n";
}
exit(0);*/
//Exit Debug
cout << "Done...\n";
printf("Server ...\n");
int Soc=0;
while (1)
{
static double ServerStartedOn = 0.0;
if (!Soc)
{
Soc = StartServer( PORTNUMBER );
if (Soc)
{
printf("Server started on port %d\n",PORTNUMBER);
}
} else
{
printf("Waiting for connection\n");
Cnt = 0;
sockaddr_in lClientAddr;
int lSize;
int lSocket;
lSize = sizeof(lClientAddr);
bzero((char *)&lClientAddr, sizeof(lClientAddr));
lSocket = accept(Soc, (struct sockaddr*)&lClientAddr, &lSize);
if( lSocket >= 0 )
{
sockaddr_in lAddr;
sDataBuffer mDataBuffer;
bzero((char *)&lAddr, sizeof(lAddr));
if( getsockname(lSocket, (struct sockaddr*)&lAddr, &lSize) < 0 )
{
return -1;
}
printf("Connection established\n");
ServerStartedOn = (double)GetNanoSeconds();
mDataBuffer.SetupBuffer();
for (;;)
{
mDataBuffer.Simulate(GetNanoSeconds());
if (send( lSocket, (char*)&mDataBuffer,sizeof(mDataBuffer), 0)==SOCKET_ERROR)
{
break;
}
UpdateBuffer(mDataBuffer);
Sleep( 1000/SIM_FPS );
}
shutdown(lSocket, 2);
closesocket(lSocket);
printf("Connection closed, connection time = %f ms\n",(GetNanoSeconds()-ServerStartedOn)/1000000.0);
}
}
}
if (Soc)
{
closesocket( Soc );
}
Cleanup();
return 0;
}
|
[
"Zhang Nan@4a66b584-afee-11de-9d1a-45ab25924541"
] |
[
[
[
1,
708
]
]
] |
81581e691e4b262c07b649b3c8c2411f716fcac6
|
b14d5833a79518a40d302e5eb40ed5da193cf1b2
|
/cpp/extern/xercesc++/2.6.0/src/xercesc/validators/common/AllContentModel.hpp
|
6688f79e8aa4f4f86e034356fcd22977e9e31be2
|
[
"Apache-2.0"
] |
permissive
|
andyburke/bitflood
|
dcb3fb62dad7fa5e20cf9f1d58aaa94be30e82bf
|
fca6c0b635d07da4e6c7fbfa032921c827a981d6
|
refs/heads/master
| 2016-09-10T02:14:35.564530 | 2011-11-17T09:51:49 | 2011-11-17T09:51:49 | 2,794,411 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 6,296 |
hpp
|
/*
* Copyright 2001,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Log: AllContentModel.hpp,v $
* Revision 1.8 2004/09/16 13:32:03 amassari
* Updated error message for UPA to also state the complex type that is failing the test
*
* Revision 1.7 2004/09/08 13:56:51 peiyongz
* Apache License Version 2.0
*
* Revision 1.6 2004/01/29 11:51:21 cargilld
* Code cleanup changes to get rid of various compiler diagnostic messages.
*
* Revision 1.5 2003/05/16 21:43:20 knoaman
* Memory manager implementation: Modify constructors to pass in the memory manager.
*
* Revision 1.4 2003/05/15 18:48:27 knoaman
* Partial implementation of the configurable memory manager.
*
* Revision 1.3 2003/03/07 18:16:57 tng
* Return a reference instead of void for operator=
*
* Revision 1.2 2002/11/04 14:54:58 tng
* C++ Namespace Support.
*
* Revision 1.1.1.1 2002/02/01 22:22:37 peiyongz
* sane_include
*
* Revision 1.2 2001/11/21 14:30:13 knoaman
* Fix for UPA checking.
*
* Revision 1.1 2001/08/24 12:48:48 tng
* Schema: AllContentModel
*
*/
#if !defined(ALLCONTENTMODEL_HPP)
#define ALLCONTENTMODEL_HPP
#include <xercesc/framework/XMLContentModel.hpp>
#include <xercesc/util/ValueVectorOf.hpp>
#include <xercesc/validators/common/ContentLeafNameTypeVector.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class ContentSpecNode;
//
// AllContentModel is a derivative of the abstract content model base
// class that handles the special case of <all> feature in schema. If a model
// is <all>, all non-optional children must appear
//
// So, all we have to do is to keep an array of the possible children and
// validate by just looking up each child being validated by looking it up
// in the list, and make sure all non-optional children appear.
//
class AllContentModel : public XMLContentModel
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
AllContentModel
(
ContentSpecNode* const parentContentSpec
, const bool isMixed
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~AllContentModel();
// -----------------------------------------------------------------------
// Implementation of the ContentModel virtual interface
// -----------------------------------------------------------------------
virtual int validateContent
(
QName** const children
, const unsigned int childCount
, const unsigned int emptyNamespaceId
) const;
virtual int validateContentSpecial
(
QName** const children
, const unsigned int childCount
, const unsigned int emptyNamespaceId
, GrammarResolver* const pGrammarResolver
, XMLStringPool* const pStringPool
) const;
virtual ContentLeafNameTypeVector* getContentLeafNameTypeVector() const ;
virtual unsigned int getNextState(const unsigned int currentState,
const unsigned int elementIndex) const;
virtual void checkUniqueParticleAttribution
(
SchemaGrammar* const pGrammar
, GrammarResolver* const pGrammarResolver
, XMLStringPool* const pStringPool
, XMLValidator* const pValidator
, unsigned int* const pContentSpecOrgURI
, const XMLCh* pComplexTypeName = 0
) ;
private :
// -----------------------------------------------------------------------
// Private helper methods
// -----------------------------------------------------------------------
void buildChildList
(
ContentSpecNode* const curNode
, ValueVectorOf<QName*>& toFill
, ValueVectorOf<bool>& toType
);
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
AllContentModel();
AllContentModel(const AllContentModel&);
AllContentModel& operator=(const AllContentModel&);
// -----------------------------------------------------------------------
// Private data members
//
// fCount
// The count of possible children in the fChildren member.
//
// fChildren
// The list of possible children that we have to accept. This array
// is allocated as large as needed in the constructor.
//
// fChildOptional
// The corresponding list of optional state of each child in fChildren
// True if the child is optional (i.e. minOccurs = 0).
//
// fNumRequired
// The number of required children in <all> (i.e. minOccurs = 1)
//
// fIsMixed
// AllContentModel with mixed PCDATA.
// -----------------------------------------------------------------------
MemoryManager* fMemoryManager;
unsigned int fCount;
QName** fChildren;
bool* fChildOptional;
unsigned int fNumRequired;
bool fIsMixed;
};
inline ContentLeafNameTypeVector* AllContentModel::getContentLeafNameTypeVector() const
{
return 0;
}
inline unsigned int
AllContentModel::getNextState(const unsigned int,
const unsigned int) const {
return XMLContentModel::gInvalidTrans;
}
XERCES_CPP_NAMESPACE_END
#endif
|
[
"[email protected]"
] |
[
[
[
1,
184
]
]
] |
4c8b33042026f6a8f5e77d9e4b7102eabe975d6e
|
5692a3cf85e1a125bddf00f6a55ce071e0dc5515
|
/muParser/muParserInt.cpp
|
d036b413eb37efa821725ef16e1bddf16ea75daa
|
[] |
no_license
|
zOrg1331/qdsgen
|
25390c571dca334186d0705eedbd2b75e02d1b74
|
cbcfcb3dcd9338552cec5dd5a1869bd8e3f2451a
|
refs/heads/master
| 2020-05-17T11:02:20.889232 | 2008-03-22T12:04:25 | 2008-03-22T12:04:25 | 32,092,036 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 9,338 |
cpp
|
/*
__________
_____ __ __\______ \_____ _______ ______ ____ _______
/ \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \
| Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/
|__|_| /|____/ |____| (____ /|__| /____ > \___ >|__|
\/ \/ \/ \/
Copyright (C) 2004-2007 Ingo Berg
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "muParserInt.h"
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;
/** \brief Namespace for mathematical applications. */
namespace mu
{
value_type ParserInt::Abs(value_type v) { return Round(fabs(v)); }
value_type ParserInt::Sign(value_type v) { return (Round(v)<0) ? -1 : (Round(v)>0) ? 1 : 0; }
value_type ParserInt::Ite(value_type v1,
value_type v2,
value_type v3) { return (Round(v1)==1) ? Round(v2) : Round(v3); }
value_type ParserInt::Add(value_type v1, value_type v2) { return Round(v1) + Round(v2); }
value_type ParserInt::Sub(value_type v1, value_type v2) { return Round(v1) - Round(v2); }
value_type ParserInt::Mul(value_type v1, value_type v2) { return Round(v1) * Round(v2); }
value_type ParserInt::Div(value_type v1, value_type v2) { return Round(v1) / Round(v2); }
value_type ParserInt::Mod(value_type v1, value_type v2) { return Round(v1) % Round(v2); }
value_type ParserInt::Shr(value_type v1, value_type v2) { return Round(v1) >> Round(v2); }
value_type ParserInt::Shl(value_type v1, value_type v2) { return Round(v1) << Round(v2); }
value_type ParserInt::LogAnd(value_type v1, value_type v2) { return Round(v1) & Round(v2); }
value_type ParserInt::LogOr(value_type v1, value_type v2) { return Round(v1) | Round(v2); }
value_type ParserInt::LogXor(value_type v1, value_type v2) { return Round(v1) ^ Round(v2); }
value_type ParserInt::And(value_type v1, value_type v2) { return Round(v1) && Round(v2); }
value_type ParserInt::Or(value_type v1, value_type v2) { return Round(v1) || Round(v2); }
value_type ParserInt::Less(value_type v1, value_type v2) { return Round(v1) < Round(v2); }
value_type ParserInt::Greater(value_type v1, value_type v2) { return Round(v1) > Round(v2); }
value_type ParserInt::LessEq(value_type v1, value_type v2) { return Round(v1) <= Round(v2); }
value_type ParserInt::GreaterEq(value_type v1, value_type v2) { return Round(v1) >= Round(v2); }
value_type ParserInt::Equal(value_type v1, value_type v2) { return Round(v1) == Round(v2); }
value_type ParserInt::NotEqual(value_type v1, value_type v2) { return Round(v1) != Round(v2); }
value_type ParserInt::Not(value_type v) { return !Round(v); }
//---------------------------------------------------------------------------
// Unary operator Callbacks: Infix operators
value_type ParserInt::UnaryMinus(value_type v)
{
return -Round(v);
}
//---------------------------------------------------------------------------
value_type ParserInt::Sum(const value_type* a_afArg, int a_iArgc)
{
if (!a_iArgc)
throw ParserError(_T("too few arguments for function sum."));
value_type fRes=0;
for (int i=0; i<a_iArgc; ++i)
fRes += a_afArg[i];
return fRes;
}
//---------------------------------------------------------------------------
value_type ParserInt::Min(const value_type* a_afArg, int a_iArgc)
{
if (!a_iArgc)
throw ParserError( _T("too few arguments for function min.") );
value_type fRes=a_afArg[0];
for (int i=0; i<a_iArgc; ++i)
fRes = std::min(fRes, a_afArg[i]);
return fRes;
}
//---------------------------------------------------------------------------
value_type ParserInt::Max(const value_type* a_afArg, int a_iArgc)
{
if (!a_iArgc)
throw ParserError(_T("too few arguments for function min."));
value_type fRes=a_afArg[0];
for (int i=0; i<a_iArgc; ++i)
fRes = std::max(fRes, a_afArg[i]);
return fRes;
}
//---------------------------------------------------------------------------
// Default value recognition callback
int ParserInt::IsVal(const char_type *a_szExpr, int *a_iPos, value_type *a_fVal)
{
string_type buf(a_szExpr);
std::size_t pos = buf.find_first_not_of(_T("0123456789"));
if (pos==std::string::npos)
return 0;
stringstream_type stream( buf.substr(0, pos ) );
int iVal(0);
stream >> iVal;
int iEnd = stream.tellg(); // Position after reading
if (iEnd==-1)
return 0;
*a_iPos += iEnd;
*a_fVal = (value_type)iVal;
return 1;
}
//---------------------------------------------------------------------------
int ParserInt::IsHexVal(const char_type *a_szExpr, int *a_iPos, value_type *a_fVal)
{
if (a_szExpr[0]!='$')
return 0;
unsigned iVal(0);
// New code based on streams for UNICODE compliance:
stringstream_type::pos_type nPos(0);
stringstream_type ss(a_szExpr+1);
ss >> std::hex >> iVal;
nPos = ss.tellg();
if (nPos==(stringstream_type::pos_type)0)
return 1;
*a_iPos += 1 + nPos;
*a_fVal = iVal;
return true;
}
//---------------------------------------------------------------------------
int ParserInt::IsBinVal(const char_type *a_szExpr, int *a_iPos, value_type *a_fVal)
{
if (a_szExpr[0]!='#')
return 0;
unsigned iVal(0),
iBits(sizeof(iVal)*8),
i(0);
for (i=0; (a_szExpr[i+1]=='0' || a_szExpr[i+1]=='1') && i<iBits; ++i)
iVal |= (int)(a_szExpr[i+1]=='1') << ((iBits-1)-i);
if (i==0)
return 0;
if (i==iBits)
throw exception_type(_T("Binary to integer conversion error (overflow)."));
*a_fVal = (unsigned)(iVal >> (iBits-i) );
*a_iPos += i+1;
return 1;
}
//---------------------------------------------------------------------------
/** \brief Constructor.
Call ParserBase class constructor and trigger Function, Operator and Constant initialization.
*/
ParserInt::ParserInt()
:ParserBase()
{
AddValIdent(IsVal);
AddValIdent(IsHexVal);
AddValIdent(IsBinVal);
InitCharSets();
InitFun();
InitOprt();
}
//---------------------------------------------------------------------------
void ParserInt::InitConst()
{
}
//---------------------------------------------------------------------------
void ParserInt::InitCharSets()
{
DefineNameChars( _T("0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") );
DefineOprtChars( _T("+-*^/?<>=!%&|~'_") );
DefineInfixOprtChars( _T("/+-*^?<>=!%&|~'_") );
}
//---------------------------------------------------------------------------
/** \brief Initialize the default functions. */
void ParserInt::InitFun()
{
DefineFun( _T("sign"), Sign);
DefineFun( _T("abs"), Abs);
DefineFun( _T("if"), Ite);
DefineFun( _T("sum"), Sum);
DefineFun( _T("min"), Min);
DefineFun( _T("max"), Max);
}
//---------------------------------------------------------------------------
/** \brief Initialize operators. */
void ParserInt::InitOprt()
{
// disable all built in operators, not all of them usefull for integer numbers
// (they don't do rounding of values)
EnableBuiltInOprt(false);
// Disable all built in operators, they wont work with integer numbers
// since they are designed for floating point numbers
DefineInfixOprt( _T("-"), UnaryMinus);
DefineInfixOprt( _T("!"), Not);
DefineOprt( _T("&"), LogAnd, prLOGIC);
DefineOprt( _T("|"), LogOr, prLOGIC);
DefineOprt( _T("^"), LogXor, prLOGIC);
DefineOprt( _T("&&"), And, prLOGIC);
DefineOprt( _T("||"), Or, prLOGIC);
DefineOprt( _T("<"), Less, prCMP);
DefineOprt( _T(">"), Greater, prCMP);
DefineOprt( _T("<="), LessEq, prCMP);
DefineOprt( _T(">="), GreaterEq, prCMP);
DefineOprt( _T("=="), Equal, prCMP);
DefineOprt( _T("!="), NotEqual, prCMP);
DefineOprt( _T("+"), Add, prADD_SUB);
DefineOprt( _T("-"), Sub, prADD_SUB);
DefineOprt( _T("*"), Mul, prMUL_DIV);
DefineOprt( _T("/"), Div, prMUL_DIV);
DefineOprt( _T("%"), Mod, prMUL_DIV);
DefineOprt( _T(">>"), Shr, prMUL_DIV+1);
DefineOprt( _T("<<"), Shl, prMUL_DIV+1);
}
} // namespace mu
|
[
"zOrg1331@cf3b2aff-0449-0410-953b-81e51c19c30f"
] |
[
[
[
1,
259
]
]
] |
6d6b7d264d4c0441c4429fb3eeb530d05da27034
|
011359e589f99ae5fe8271962d447165e9ff7768
|
/src/burn/misc/pre90s/d_gunsmoke.cpp
|
3676962b59defd8b26f623405029d467515a4758
|
[] |
no_license
|
PS3emulators/fba-next-slim
|
4c753375fd68863c53830bb367c61737393f9777
|
d082dea48c378bddd5e2a686fe8c19beb06db8e1
|
refs/heads/master
| 2021-01-17T23:05:29.479865 | 2011-12-01T18:16:02 | 2011-12-01T18:16:02 | 2,899,840 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 30,842 |
cpp
|
// FB Alpha Gun.Smoke driver module
// Based on MAME driver by Paul Leaman
#include "tiles_generic.h"
#include "burn_ym2203.h"
static unsigned char *Mem, *MemEnd, *Rom0, *Rom1, *Ram;
static unsigned char *Gfx0, *Gfx1, *Gfx2, *Gfx3, *Prom;
static unsigned char DrvJoy1[8], DrvJoy2[8], DrvJoy3[8], DrvDips[2], DrvReset;
static unsigned int *Palette, *DrvPal;
static unsigned char DrvCalcPal;
static unsigned char *SprTrnsp;
static unsigned char soundlatch;
static unsigned char flipscreen;
static int nGunsmokeBank;
static unsigned char sprite3bank;
static unsigned char chon, bgon, objon;
static unsigned char gunsmoke_scrollx[2], gunsmoke_scrolly;
static struct BurnInputInfo DrvInputList[] = {
{"P1 Coin" , BIT_DIGITAL , DrvJoy1 + 6, "p1 coin" },
{"P1 start" , BIT_DIGITAL , DrvJoy1 + 0, "p1 start" },
{"P1 Right" , BIT_DIGITAL , DrvJoy2 + 0, "p1 right" },
{"P1 Left" , BIT_DIGITAL , DrvJoy2 + 1, "p1 left" },
{"P1 Down" , BIT_DIGITAL , DrvJoy2 + 2, "p1 down" },
{"P1 Up" , BIT_DIGITAL , DrvJoy2 + 3, "p1 up" },
{"P1 Button 1" , BIT_DIGITAL , DrvJoy2 + 4, "p1 fire 1"},
{"P1 Button 2" , BIT_DIGITAL , DrvJoy2 + 5, "p1 fire 2"},
{"P1 Button 3" , BIT_DIGITAL , DrvJoy2 + 6, "p1 fire 3"},
{"P2 Coin" , BIT_DIGITAL , DrvJoy1 + 7, "p2 coin" },
{"P2 start" , BIT_DIGITAL , DrvJoy1 + 1, "p2 start" },
{"P2 Right" , BIT_DIGITAL , DrvJoy3 + 0, "p2 right" },
{"P2 Left" , BIT_DIGITAL , DrvJoy3 + 1, "p2 left" },
{"P2 Down" , BIT_DIGITAL , DrvJoy3 + 2, "p2 down" },
{"P2 Up" , BIT_DIGITAL , DrvJoy3 + 3, "p2 up" },
{"P2 Button 1" , BIT_DIGITAL , DrvJoy3 + 4, "p2 fire 1"},
{"P2 Button 2" , BIT_DIGITAL , DrvJoy3 + 5, "p2 fire 2"},
{"P2 Button 3" , BIT_DIGITAL , DrvJoy3 + 6, "p2 fire 3"},
{"Service" , BIT_DIGITAL , DrvJoy1 + 4, "service" },
{"Reset" , BIT_DIGITAL , &DrvReset , "reset" },
{"Dip 1" , BIT_DIPSWITCH, DrvDips + 0, "dip" },
{"Dip 2" , BIT_DIPSWITCH, DrvDips + 1, "dip" },
};
STDINPUTINFO(Drv)
static struct BurnDIPInfo DrvDIPList[]=
{
// Default Values
{0x14, 0xff, 0xff, 0xf7, NULL },
{0 , 0xfe, 0 , 4 , "Bonus Life" },
{0x14, 0x01, 0x03, 0x01, "30k 80k 80k+" },
{0x14, 0x01, 0x03, 0x03, "30k 100k 100k+" },
{0x14, 0x01, 0x03, 0x00, "30k 100k 150k+" },
{0x14, 0x01, 0x03, 0x02, "30k 100k" },
{0 , 0xfe, 0 , 2 , "Demo" },
{0x14, 0x01, 0x04, 0x00, "Off" },
{0x14, 0x01, 0x04, 0x04, "On" },
};
static struct BurnDIPInfo gunsmokeuaDIPList[]=
{
// Default Values
{0x14, 0xff, 0xff, 0xf7, NULL },
{0 , 0xfe, 0 , 4 , "Bonus Life" },
{0x14, 0x01, 0x03, 0x01, "30k 80k 80k+" },
{0x14, 0x01, 0x03, 0x03, "30k 100k 100k+" },
{0x14, 0x01, 0x03, 0x00, "30k 100k 150k+" },
{0x14, 0x01, 0x03, 0x02, "30k 100k" },
{0 , 0xfe, 0 , 2 , "Lifes" },
{0x14, 0x01, 0x04, 0x04, "3" },
{0x14, 0x01, 0x04, 0x00, "5" },
};
static struct BurnDIPInfo gunsmokeDIPList[]=
{
{0 , 0xfe, 0 , 2 , "Cabinet" },
{0x14, 0x01, 0x08, 0x00, "Upright" },
{0x14, 0x01, 0x08, 0x08, "Cocktail" },
{0 , 0xfe, 0 , 4 , "Difficulty" },
{0x14, 0x01, 0x30, 0x20, "Easy" },
{0x14, 0x01, 0x30, 0x30, "Normal" },
{0x14, 0x01, 0x30, 0x10, "Difficult" },
{0x14, 0x01, 0x30, 0x00, "Very Difficult" },
{0 , 0xfe, 0 , 2 , "Freeze" },
{0x14, 0x01, 0x40, 0x40, "Off" },
{0x14, 0x01, 0x40, 0x00, "On" },
{0 , 0xfe, 0 , 2 , "Service Mode" },
{0x14, 0x01, 0x80, 0x80, "Off" },
{0x14, 0x01, 0x80, 0x00, "On" },
// Default Values
{0x15, 0xff, 0xff, 0xff, NULL },
{0 , 0xfe, 0 , 8 , "Coin A" },
{0x15, 0x01, 0x07, 0x00, "4 Coins 1 Credit" },
{0x15, 0x01, 0x07, 0x01, "3 Coins 1 Credit" },
{0x15, 0x01, 0x07, 0x02, "2 Coins 1 Credit" },
{0x15, 0x01, 0x07, 0x07, "1 Coin 1 Credit" },
{0x15, 0x01, 0x07, 0x06, "1 Coin 2 Credits" },
{0x15, 0x01, 0x07, 0x05, "1 Coin 3 Credits" },
{0x15, 0x01, 0x07, 0x04, "1 Coin 4 Credits" },
{0x15, 0x01, 0x07, 0x03, "1 Coin 6 Credits" },
{0 , 0xfe, 0 , 8 , "Coin B" },
{0x15, 0x01, 0x38, 0x00, "4 Coins 1 Credit" },
{0x15, 0x01, 0x38, 0x08, "3 Coins 1 Credit" },
{0x15, 0x01, 0x38, 0x10, "2 Coins 1 Credit" },
{0x15, 0x01, 0x38, 0x38, "1 Coin 1 Credit" },
{0x15, 0x01, 0x38, 0x30, "1 Coin 2 Credits" },
{0x15, 0x01, 0x38, 0x28, "1 Coin 3 Credits" },
{0x15, 0x01, 0x38, 0x20, "1 Coin 4 Credits" },
{0x15, 0x01, 0x38, 0x18, "1 Coin 6 Credits" },
{0 , 0xfe, 0 , 2 , "Allow Continue" },
{0x15, 0x01, 0x40, 0x00, "No" },
{0x15, 0x01, 0x40, 0x40, "Yes" },
{0 , 0xfe, 0 , 2 , "Demo Sounds" },
{0x15, 0x01, 0x80, 0x00, "Off" },
{0x15, 0x01, 0x80, 0x80, "On" },
};
STDDIPINFOEXT(Drv, Drv, gunsmoke)
STDDIPINFOEXT(gunsmokeua, gunsmokeua, gunsmoke)
static inline void gunsmoke_bankswitch(int nBank)
{
if (nGunsmokeBank != nBank) {
nGunsmokeBank = nBank;
ZetMapArea(0x8000, 0xbfff, 0, Rom0 + 0x10000 + nBank * 0x04000);
ZetMapArea(0x8000, 0xbfff, 2, Rom0 + 0x10000 + nBank * 0x04000);
}
}
void __fastcall gunsmoke_cpu0_write(unsigned short address, unsigned char data)
{
switch (address)
{
case 0xc800:
soundlatch = data;
break;
case 0xc804:
gunsmoke_bankswitch((data >> 2) & 3);
flipscreen = data & 0x40;
chon = data & 0x80;
break;
case 0xc806:
break;
case 0xd800:
case 0xd801:
gunsmoke_scrollx[address & 1] = data;
break;
case 0xd802:
case 0xd803:
gunsmoke_scrolly = data;
break;
case 0xd806:
sprite3bank = data & 0x07;
bgon = data & 0x10;
objon = data & 0x20;
break;
}
}
unsigned char __fastcall gunsmoke_cpu0_read(unsigned short address)
{
unsigned char ret = 0xff;
switch (address)
{
case 0xc000:
{
for (int i = 0; i < 8; i++)
ret ^= DrvJoy1[i] << i;
return ret | 0x08;
}
case 0xc001:
{
for (int i = 0; i < 8; i++)
ret ^= DrvJoy2[i] << i;
return ret;
}
case 0xc002:
{
for (int i = 0; i < 8; i++)
ret ^= DrvJoy3[i] << i;
return ret;
}
case 0xc003: // dips
return DrvDips[0];
case 0xc004:
return DrvDips[1];
// reads at c4c9 - c4cb are part of some sort of protection or bug
case 0xc4c9:
return 0xff;
case 0xc4ca:
case 0xc4cb:
return 0;
}
return 0;
}
void __fastcall gunsmoke_cpu1_write(unsigned short address, unsigned char data)
{
switch (address)
{
case 0xe000: // control 0
BurnYM2203Write(0, 0, data);
break;
case 0xe001: // write 0
BurnYM2203Write(0, 1, data);
break;
case 0xe002: // control 1
BurnYM2203Write(1, 0, data);
break;
case 0xe003: // write 1
BurnYM2203Write(1, 1, data);
break;
}
}
unsigned char __fastcall gunsmoke_cpu1_read(unsigned short address)
{
if (address == 0xc800) return soundlatch;
return 0;
}
static int DrvDoReset()
{
DrvReset = 0;
memset (Ram, 0, 0x4000);
nGunsmokeBank = -1;
soundlatch = 0;
flipscreen = 0;
sprite3bank = 0;
chon = bgon = objon = 0;
gunsmoke_scrollx[0] = gunsmoke_scrollx[1] = 0;
gunsmoke_scrolly = 0;
ZetOpen(0);
ZetReset();
gunsmoke_bankswitch(0);
ZetClose();
ZetOpen(1);
ZetReset();
ZetClose();
BurnYM2203Reset();
return 0;
}
static int gunsmoke_palette_init()
{
int i, ctabentry;
unsigned int tmp[0x100];
for (i = 0; i < 0x100; i++)
{
unsigned char r, g, b;
r = Prom[i + 0x000] & 0x0f;
r |= r << 4;
g = Prom[i + 0x100] & 0x0f;
g |= g << 4;
b = Prom[i + 0x200] & 0x0f;
b |= b << 4;
tmp[i] = (r << 16) | (g << 8) | b;
}
for (i = 0; i < 0x100; i++)
{
ctabentry = Prom[0x300 + i] | 0x40;
Palette[0x000 + i] = tmp[ctabentry];
ctabentry = Prom[0x400 + i] | ((Prom[0x500 + i] & 0x03) << 4);
Palette[0x100 + i] = tmp[ctabentry];
ctabentry = Prom[0x600 + i] | ((Prom[0x700 + i] & 0x07) << 4) | 0x80;
Palette[0x200 + i] = tmp[ctabentry];
}
return 0;
}
static int gunsmoke_gfx_decode()
{
unsigned char *tmp = (unsigned char*)malloc(0x80000);
if (!tmp) return 1;
static int Planes[4] = { 0x100004, 0x100000, 4, 0 };
static int CharXOffs[8] = { 11, 10, 9, 8, 3, 2, 1, 0 };
static int CharYOffs[8] = { 112, 96, 80, 64, 48, 32, 16, 0 };
static int TileXOffs[32] = { 0, 1, 2, 3, 8, 9, 10, 11,
512, 513, 514, 515, 520, 521, 522, 523,
1024, 1025, 1026, 1027, 1032, 1033, 1034, 1035,
1536, 1537, 1538, 1539, 1544, 1545, 1546, 1547 };
static int TileYOffs[32] = { 0, 16, 32, 48, 64, 80, 96, 112,
128, 144, 160, 176, 192, 208, 224, 240,
256, 272, 288, 304, 320, 336, 352, 368,
384, 400, 416, 432, 448, 464, 480, 496 };
static int SpriXOffs[16] = { 0, 1, 2, 3, 8, 9, 10, 11,
256, 257, 258, 259, 264, 265, 266, 267 };
memcpy (tmp, Gfx0, 0x04000);
GfxDecode(0x400, 2, 8, 8, Planes + 2, CharXOffs, CharYOffs, 0x080, tmp, Gfx0);
memcpy (tmp, Gfx1, 0x40000);
GfxDecode(0x200, 4, 32, 32, Planes + 0, TileXOffs, TileYOffs, 0x800, tmp, Gfx1);
memcpy (tmp, Gfx2, 0x40000);
GfxDecode(0x800, 4, 16, 16, Planes + 0, SpriXOffs, TileYOffs, 0x200, tmp, Gfx2);
free (tmp);
{
memset (SprTrnsp, 1, 0x800);
for (int i = 0; i < 0x80000; i++)
if (Gfx2[i]) SprTrnsp[i >> 8] = 0;
}
return 0;
}
static int gunsmokeSynchroniseStream(int nSoundRate)
{
return (long long)ZetTotalCycles() * nSoundRate / 3000000;
}
static double gunsmokeGetTime()
{
return (double)ZetTotalCycles() / 3000000;
}
static int MemIndex()
{
unsigned char *Next; Next = Mem;
Rom0 = Next; Next += 0x20000;
Rom1 = Next; Next += 0x08000;
Ram = Next; Next += 0x04000;
Gfx0 = Next; Next += 0x10000;
Gfx1 = Next; Next += 0x80000;
Gfx2 = Next; Next += 0x80000;
Gfx3 = Next; Next += 0x08000;
Prom = Next; Next += 0x00800;
SprTrnsp = Next; Next += 0x00800;
Palette = (unsigned int*)Next; Next += 0x00300 * sizeof(unsigned int);
DrvPal = (unsigned int*)Next; Next += 0x00300 * sizeof(unsigned int);
MemEnd = Next;
return 0;
}
static int DrvInit()
{
int nLen;
Mem = NULL;
MemIndex();
nLen = MemEnd - (unsigned char *)0;
if ((Mem = (unsigned char *)malloc(nLen)) == NULL) return 1;
memset(Mem, 0, nLen);
MemIndex();
{
if (BurnLoadRom(Rom0 + 0x00000, 0, 1)) return 1;
if (BurnLoadRom(Rom0 + 0x10000, 1, 1)) return 1;
if (BurnLoadRom(Rom0 + 0x18000, 2, 1)) return 1;
if (BurnLoadRom(Rom1 + 0x00000, 3, 1)) return 1;
if (BurnLoadRom(Gfx0 + 0x00000, 4, 1)) return 1;
if (BurnLoadRom(Gfx3 + 0x00000, 21, 1)) return 1;
for (int i = 0; i < 8; i++) {
if (BurnLoadRom(Gfx1 + i * 0x8000, 5 + i, 1)) return 1;
if (BurnLoadRom(Gfx2 + i * 0x8000, 13 + i, 1)) return 1;
if (BurnLoadRom(Prom + i * 0x0100, 22 + i, 1)) return 1;
}
gunsmoke_gfx_decode();
gunsmoke_palette_init();
}
ZetInit(2);
ZetOpen(0);
ZetMapArea(0x0000, 0x7fff, 0, Rom0 + 0x00000);
ZetMapArea(0x0000, 0x7fff, 2, Rom0 + 0x00000);
ZetMapArea(0x8000, 0xbfff, 0, Rom0 + 0x10000);
ZetMapArea(0x8000, 0xbfff, 2, Rom0 + 0x10000);
ZetMapArea(0xd000, 0xd7ff, 0, Ram + 0x00000);
ZetMapArea(0xd000, 0xd7ff, 1, Ram + 0x00000);
ZetMapArea(0xe000, 0xefff, 0, Ram + 0x01000);
ZetMapArea(0xe000, 0xefff, 1, Ram + 0x01000);
ZetMapArea(0xe000, 0xefff, 2, Ram + 0x01000);
ZetMapArea(0xf000, 0xffff, 0, Ram + 0x02000);
ZetMapArea(0xf000, 0xffff, 1, Ram + 0x02000);
ZetSetReadHandler(gunsmoke_cpu0_read);
ZetSetWriteHandler(gunsmoke_cpu0_write);
ZetMemEnd();
ZetClose();
ZetOpen(1);
ZetMapArea(0x0000, 0x7fff, 0, Rom1 + 0x00000);
ZetMapArea(0x0000, 0x7fff, 2, Rom1 + 0x00000);
ZetMapArea(0xc000, 0xc7ff, 0, Ram + 0x03000);
ZetMapArea(0xc000, 0xc7ff, 1, Ram + 0x03000);
ZetMapArea(0xc000, 0xc7ff, 2, Ram + 0x03000);
ZetSetReadHandler(gunsmoke_cpu1_read);
ZetSetWriteHandler(gunsmoke_cpu1_write);
ZetMemEnd();
ZetClose();
GenericTilesInit();
BurnYM2203Init(2, 1500000, NULL, gunsmokeSynchroniseStream, gunsmokeGetTime, 0);
BurnTimerAttachZet(3000000);
DrvDoReset();
return 0;
}
static int DrvExit()
{
GenericTilesExit();
ZetExit();
BurnYM2203Exit();
free (Mem);
Mem = MemEnd = Rom0 = Rom1 = Ram = NULL;
Gfx0 = Gfx1 = Gfx2 = Gfx3 = Prom = NULL;
SprTrnsp = NULL;
Palette = DrvPal = NULL;
soundlatch = flipscreen = nGunsmokeBank;
sprite3bank = chon = bgon = objon = 0;
gunsmoke_scrollx[0] = gunsmoke_scrollx[1] = 0;
gunsmoke_scrolly = 0;
return 0;
}
static void draw_bg_layer()
{
unsigned short scroll = gunsmoke_scrollx[0] + (gunsmoke_scrollx[1] << 8);
unsigned char *tilerom = Gfx3 + ((scroll >> 1) & ~0x0f);
for (int offs = 0; offs < 0x50; offs++)
{
int attr = tilerom[1];
int code = tilerom[0] + ((attr & 1) << 8);
int color = (attr & 0x3c) >> 2;
int flipy = attr & 0x80;
int flipx = attr & 0x40;
int sy = (offs & 7) << 5;
int sx = (offs >> 3) << 5;
sy -= gunsmoke_scrolly;
sx -= (scroll & 0x1f);
if (flipscreen) {
flipy ^= 0x80;
flipx ^= 0x40;
sy = 224 - sy;
sx = 224 - sx;
}
sy -= 16;
if (flipy) {
if (flipx) {
Render32x32Tile_FlipXY_Clip(pTransDraw, code, sx, sy, color, 4, 0x100, Gfx1);
} else {
Render32x32Tile_FlipY_Clip(pTransDraw, code, sx, sy, color, 4, 0x100, Gfx1);
}
} else {
if (flipx) {
Render32x32Tile_FlipX_Clip(pTransDraw, code, sx, sy, color, 4, 0x100, Gfx1);
} else {
Render32x32Tile_Clip(pTransDraw, code, sx, sy, color, 4, 0x100, Gfx1);
}
}
tilerom += 2;
}
}
static void draw_fg_layer()
{
for (int offs = 0; offs < 0x400; offs++)
{
int sx = (offs << 3) & 0xf8;
int sy = (offs >> 2) & 0xf8;
int attr = Ram[0x0400 + offs];
int code = Ram[0x0000 + offs] + ((attr & 0xe0) << 2);
int color = attr & 0x1f;
if (code == 0x0024) continue;
unsigned char *src = Gfx0 + (code << 6);
color <<= 2;
if (flipscreen) {
sy = 240 - sy;
sx = 240 - sx;
sy -= 8;
for (int y = sy + 7; y >= sy; y--)
{
for (int x = sx + 7; x >= sx; x--, src++)
{
if (y < 0 || x < 0 || y > 223 || x > 255) continue;
if (!Palette[color|*src]) continue;
pTransDraw[(y << 8) | x] = color | *src;
}
}
} else {
sy -= 16;
for (int y = sy; y < sy + 8; y++)
{
for (int x = sx; x < sx + 8; x++, src++)
{
if (y < 0 || x < 0 || y > 223 || x > 255) continue;
if (!Palette[color|*src]) continue;
pTransDraw[(y << 8) | x] = color | *src;
}
}
}
}
}
static void draw_sprites()
{
for (int offs = 0x1000 - 32; offs >= 0; offs -= 32)
{
int attr = Ram[0x2001 + offs];
int bank = (attr & 0xc0) >> 6;
int code = Ram[0x2000 + offs];
int color = attr & 0x0f;
int flipx = 0;
int flipy = attr & 0x10;
int sx = Ram[0x2003 + offs] - ((attr & 0x20) << 3);
int sy = Ram[0x2002 + offs];
if (sy == 0 || sy > 0xef) continue;
if (bank == 3) bank += sprite3bank;
code += 256 * bank;
if (SprTrnsp[code]) continue;
if (flipscreen)
{
sx = 240 - sx;
sy = 240 - sy;
flipx = !flipx;
flipy = !flipy;
}
sy -= 16;
if (flipy) {
if (flipx) {
Render16x16Tile_Mask_FlipXY_Clip(pTransDraw, code, sx, sy, color, 4, 0, 0x200, Gfx2);
} else {
Render16x16Tile_Mask_FlipY_Clip(pTransDraw, code, sx, sy, color, 4, 0, 0x200, Gfx2);
}
} else {
if (flipx) {
Render16x16Tile_Mask_FlipX_Clip(pTransDraw, code, sx, sy, color, 4, 0, 0x200, Gfx2);
} else {
Render16x16Tile_Mask_Clip(pTransDraw, code, sx, sy, color, 4, 0, 0x200, Gfx2);
}
}
}
}
static int DrvDraw()
{
// Recalculate palette
if (DrvCalcPal) {
for (int i = 0; i < 0x300; i++) {
unsigned int col = Palette[i];
DrvPal[i] = BurnHighCol(col >> 16, col >> 8, col, 0);
}
}
if (!bgon) memset (pTransDraw, 0, 224 * 256 * 2);
if (bgon) draw_bg_layer();
if (objon) draw_sprites();
if (chon) draw_fg_layer();
BurnTransferCopy(DrvPal);
return 0;
}
static int DrvFrame()
{
if (DrvReset) {
DrvDoReset();
}
ZetNewFrame();
int nInterleave = 25;
int nSoundBufferPos = 0;
int nCyclesSegment;
int nCyclesDone[2], nCyclesTotal[2];
nCyclesTotal[0] = 4000000 / 60;
nCyclesTotal[1] = 3000000 / 60;
nCyclesDone[0] = nCyclesDone[1] = 0;
for (int i = 0; i < nInterleave; i++) {
int nCurrentCPU, nNext;
// Run Z80 #0
nCurrentCPU = 0;
ZetOpen(nCurrentCPU);
nNext = (i + 1) * nCyclesTotal[nCurrentCPU] / nInterleave;
nCyclesSegment = nNext - nCyclesDone[nCurrentCPU];
nCyclesDone[nCurrentCPU] += ZetRun(nCyclesSegment);
if (i == 20) ZetSetIRQLine(0, ZET_IRQSTATUS_ACK);
if (i == 21) ZetSetIRQLine(0, ZET_IRQSTATUS_NONE);
ZetClose();
// Run Z80 #1
nCurrentCPU = 1;
ZetOpen(nCurrentCPU);
nNext = (i + 1) * nCyclesTotal[nCurrentCPU] / nInterleave;
nCyclesSegment = nNext - nCyclesDone[nCurrentCPU];
nCyclesDone[nCurrentCPU] += ZetRun(nCyclesSegment);
BurnTimerUpdate(i * (nCyclesTotal[1] / nInterleave));
if (i == 5 || i == 10 || i == 15 || i == 20) ZetSetIRQLine(0, ZET_IRQSTATUS_ACK);
if (i == 6 || i == 11 || i == 16 || i == 21) ZetSetIRQLine(0, ZET_IRQSTATUS_NONE);
ZetClose();
// Render Sound Segment
if (pBurnSoundOut) {
int nSegmentLength = nBurnSoundLen - nSoundBufferPos;
short* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
ZetOpen(1);
BurnYM2203Update(pSoundBuf, nSegmentLength);
ZetClose();
nSoundBufferPos += nSegmentLength;
}
}
// Make sure the buffer is entirely filled.
if (pBurnSoundOut) {
int nSegmentLength = nBurnSoundLen - nSoundBufferPos;
short* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
if (nSegmentLength) {
ZetOpen(1);
BurnYM2203Update(pSoundBuf, nSegmentLength);
ZetClose();
}
}
ZetOpen(1);
BurnTimerEndFrame(nCyclesTotal[1] - nCyclesDone[1]);
ZetClose();
if (pBurnDraw) {
DrvDraw();
}
return 0;
}
static int DrvScan(int nAction,int *pnMin)
{
struct BurnArea ba;
if (pnMin) {
*pnMin = 0x029521;
}
if (nAction & ACB_VOLATILE) {
memset(&ba, 0, sizeof(ba));
ba.Data = Ram;
ba.nLen = 0x4000;
ba.szName = "All Ram";
BurnAcb(&ba);
ZetScan(nAction);
BurnYM2203Scan(nAction, pnMin);
// Scan critical driver variables
SCAN_VAR(soundlatch);
SCAN_VAR(flipscreen);
SCAN_VAR(nGunsmokeBank);
SCAN_VAR(sprite3bank);
SCAN_VAR(chon);
SCAN_VAR(bgon);
SCAN_VAR(objon);
SCAN_VAR(gunsmoke_scrollx[0]);
SCAN_VAR(gunsmoke_scrollx[1]);
SCAN_VAR(gunsmoke_scrolly);
}
return 0;
}
// Gun. Smoke (World)
static struct BurnRomInfo gunsmokeRomDesc[] = {
{ "09n_gs03.bin", 0x8000, 0x40a06cef, 1 | BRF_PRG | BRF_ESS }, // 0 Z80 #0 Code
{ "10n_gs04.bin", 0x8000, 0x8d4b423f, 1 | BRF_PRG | BRF_ESS }, // 1
{ "12n_gs05.bin", 0x8000, 0x2b5667fb, 1 | BRF_PRG | BRF_ESS }, // 2
{ "14h_gs02.bin", 0x8000, 0xcd7a2c38, 2 | BRF_PRG | BRF_ESS }, // 3 Z80 #1 Code
{ "11f_gs01.bin", 0x4000, 0xb61ece9b, 3 | BRF_GRA }, // 4 Character Tiles
{ "06c_gs13.bin", 0x8000, 0xf6769fc5, 4 | BRF_GRA }, // 5 32x32 Tiles
{ "05c_gs12.bin", 0x8000, 0xd997b78c, 4 | BRF_GRA }, // 6
{ "04c_gs11.bin", 0x8000, 0x125ba58e, 4 | BRF_GRA }, // 7
{ "02c_gs10.bin", 0x8000, 0xf469c13c, 4 | BRF_GRA }, // 8
{ "06a_gs09.bin", 0x8000, 0x539f182d, 4 | BRF_GRA }, // 9
{ "05a_gs08.bin", 0x8000, 0xe87e526d, 4 | BRF_GRA }, // 10
{ "04a_gs07.bin", 0x8000, 0x4382c0d2, 4 | BRF_GRA }, // 11
{ "02a_gs06.bin", 0x8000, 0x4cafe7a6, 4 | BRF_GRA }, // 12
{ "06n_gs22.bin", 0x8000, 0xdc9c508c, 5 | BRF_GRA }, // 13 Sprites
{ "04n_gs21.bin", 0x8000, 0x68883749, 5 | BRF_GRA }, // 14
{ "03n_gs20.bin", 0x8000, 0x0be932ed, 5 | BRF_GRA }, // 15
{ "01n_gs19.bin", 0x8000, 0x63072f93, 5 | BRF_GRA }, // 16
{ "06l_gs18.bin", 0x8000, 0xf69a3c7c, 5 | BRF_GRA }, // 17
{ "04l_gs17.bin", 0x8000, 0x4e98562a, 5 | BRF_GRA }, // 18
{ "03l_gs16.bin", 0x8000, 0x0d99c3b3, 5 | BRF_GRA }, // 19
{ "01l_gs15.bin", 0x8000, 0x7f14270e, 5 | BRF_GRA }, // 20
{ "11c_gs14.bin", 0x8000, 0x0af4f7eb, 6 | BRF_GRA }, // 21 Background Tilemaps
{ "03b_g-01.bin", 0x0100, 0x02f55589, 7 | BRF_GRA }, // 22 Color Proms
{ "04b_g-02.bin", 0x0100, 0xe1e36dd9, 7 | BRF_GRA }, // 23
{ "05b_g-03.bin", 0x0100, 0x989399c0, 7 | BRF_GRA }, // 24
{ "09d_g-04.bin", 0x0100, 0x906612b5, 7 | BRF_GRA }, // 25
{ "14a_g-06.bin", 0x0100, 0x4a9da18b, 7 | BRF_GRA }, // 26
{ "15a_g-07.bin", 0x0100, 0xcb9394fc, 7 | BRF_GRA }, // 27
{ "09f_g-09.bin", 0x0100, 0x3cee181e, 7 | BRF_GRA }, // 28
{ "08f_g-08.bin", 0x0100, 0xef91cdd2, 7 | BRF_GRA }, // 29
{ "02j_g-10.bin", 0x0100, 0x0eaf5158, 0 | BRF_OPT }, // 30 Video Timing
{ "01f_g-05.bin", 0x0100, 0x25c90c2a, 0 | BRF_OPT }, // 31 Priority
};
STD_ROM_PICK(gunsmoke)
STD_ROM_FN(gunsmoke)
struct BurnDriver BurnDrvGunsmoke = {
"gunsmoke", NULL, NULL, "1985",
"Gun. Smoke (World)\0", NULL, "Capcom", "Miscellaneous",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_MISC,
NULL, gunsmokeRomInfo, gunsmokeRomName, DrvInputInfo, DrvDIPInfo,
DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvCalcPal,
224, 256, 3, 4
};
// Gun. Smoke (Japan)
static struct BurnRomInfo gunsmokejRomDesc[] = {
{ "gs03_9n.rom", 0x8000, 0xb56b5df6, 1 | BRF_PRG | BRF_ESS }, // 0 Z80 #0 Code
{ "10n_gs04.bin", 0x8000, 0x8d4b423f, 1 | BRF_PRG | BRF_ESS }, // 1
{ "12n_gs05.bin", 0x8000, 0x2b5667fb, 1 | BRF_PRG | BRF_ESS }, // 2
{ "14h_gs02.bin", 0x8000, 0xcd7a2c38, 2 | BRF_PRG | BRF_ESS }, // 3 Z80 #1 Code
{ "11f_gs01.bin", 0x4000, 0xb61ece9b, 3 | BRF_GRA }, // 4 Character Tiles
{ "06c_gs13.bin", 0x8000, 0xf6769fc5, 4 | BRF_GRA }, // 5 32x32 Tiles
{ "05c_gs12.bin", 0x8000, 0xd997b78c, 4 | BRF_GRA }, // 6
{ "04c_gs11.bin", 0x8000, 0x125ba58e, 4 | BRF_GRA }, // 7
{ "02c_gs10.bin", 0x8000, 0xf469c13c, 4 | BRF_GRA }, // 8
{ "06a_gs09.bin", 0x8000, 0x539f182d, 4 | BRF_GRA }, // 9
{ "05a_gs08.bin", 0x8000, 0xe87e526d, 4 | BRF_GRA }, // 10
{ "04a_gs07.bin", 0x8000, 0x4382c0d2, 4 | BRF_GRA }, // 11
{ "02a_gs06.bin", 0x8000, 0x4cafe7a6, 4 | BRF_GRA }, // 12
{ "06n_gs22.bin", 0x8000, 0xdc9c508c, 5 | BRF_GRA }, // 13 Sprites
{ "04n_gs21.bin", 0x8000, 0x68883749, 5 | BRF_GRA }, // 14
{ "03n_gs20.bin", 0x8000, 0x0be932ed, 5 | BRF_GRA }, // 15
{ "01n_gs19.bin", 0x8000, 0x63072f93, 5 | BRF_GRA }, // 16
{ "06l_gs18.bin", 0x8000, 0xf69a3c7c, 5 | BRF_GRA }, // 17
{ "04l_gs17.bin", 0x8000, 0x4e98562a, 5 | BRF_GRA }, // 18
{ "03l_gs16.bin", 0x8000, 0x0d99c3b3, 5 | BRF_GRA }, // 19
{ "01l_gs15.bin", 0x8000, 0x7f14270e, 5 | BRF_GRA }, // 20
{ "11c_gs14.bin", 0x8000, 0x0af4f7eb, 6 | BRF_GRA }, // 21 Background Tilemaps
{ "03b_g-01.bin", 0x0100, 0x02f55589, 7 | BRF_GRA }, // 22 Color Proms
{ "04b_g-02.bin", 0x0100, 0xe1e36dd9, 7 | BRF_GRA }, // 23
{ "05b_g-03.bin", 0x0100, 0x989399c0, 7 | BRF_GRA }, // 24
{ "09d_g-04.bin", 0x0100, 0x906612b5, 7 | BRF_GRA }, // 25
{ "14a_g-06.bin", 0x0100, 0x4a9da18b, 7 | BRF_GRA }, // 26
{ "15a_g-07.bin", 0x0100, 0xcb9394fc, 7 | BRF_GRA }, // 27
{ "09f_g-09.bin", 0x0100, 0x3cee181e, 7 | BRF_GRA }, // 28
{ "08f_g-08.bin", 0x0100, 0xef91cdd2, 7 | BRF_GRA }, // 29
{ "02j_g-10.bin", 0x0100, 0x0eaf5158, 0 | BRF_OPT }, // 30 Video Timing
{ "01f_g-05.bin", 0x0100, 0x25c90c2a, 0 | BRF_OPT }, // 31 Priority
};
STD_ROM_PICK(gunsmokej)
STD_ROM_FN(gunsmokej)
struct BurnDriver BurnDrvGunsmokej = {
"gunsmokej", "gunsmoke", NULL, "1985",
"Gun. Smoke (Japan)\0", NULL, "Capcom", "Miscellaneous",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_MISC,
NULL, gunsmokejRomInfo, gunsmokejRomName, DrvInputInfo, DrvDIPInfo,
DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvCalcPal,
224, 256, 3, 4
};
// Gun. Smoke (US set 1)
static struct BurnRomInfo gunsmokeuRomDesc[] = {
{ "9n_gs03.bin", 0x8000, 0x592f211b, 1 | BRF_PRG | BRF_ESS }, // 0 Z80 #0 Code
{ "10n_gs04.bin", 0x8000, 0x8d4b423f, 1 | BRF_PRG | BRF_ESS }, // 1
{ "12n_gs05.bin", 0x8000, 0x2b5667fb, 1 | BRF_PRG | BRF_ESS }, // 2
{ "14h_gs02.bin", 0x8000, 0xcd7a2c38, 2 | BRF_PRG | BRF_ESS }, // 3 Z80 #1 Code
{ "11f_gs01.bin", 0x4000, 0xb61ece9b, 3 | BRF_GRA }, // 4 Character Tiles
{ "06c_gs13.bin", 0x8000, 0xf6769fc5, 4 | BRF_GRA }, // 5 32x32 Tiles
{ "05c_gs12.bin", 0x8000, 0xd997b78c, 4 | BRF_GRA }, // 6
{ "04c_gs11.bin", 0x8000, 0x125ba58e, 4 | BRF_GRA }, // 7
{ "02c_gs10.bin", 0x8000, 0xf469c13c, 4 | BRF_GRA }, // 8
{ "06a_gs09.bin", 0x8000, 0x539f182d, 4 | BRF_GRA }, // 9
{ "05a_gs08.bin", 0x8000, 0xe87e526d, 4 | BRF_GRA }, // 10
{ "04a_gs07.bin", 0x8000, 0x4382c0d2, 4 | BRF_GRA }, // 11
{ "02a_gs06.bin", 0x8000, 0x4cafe7a6, 4 | BRF_GRA }, // 12
{ "06n_gs22.bin", 0x8000, 0xdc9c508c, 5 | BRF_GRA }, // 13 Sprites
{ "04n_gs21.bin", 0x8000, 0x68883749, 5 | BRF_GRA }, // 14
{ "03n_gs20.bin", 0x8000, 0x0be932ed, 5 | BRF_GRA }, // 15
{ "01n_gs19.bin", 0x8000, 0x63072f93, 5 | BRF_GRA }, // 16
{ "06l_gs18.bin", 0x8000, 0xf69a3c7c, 5 | BRF_GRA }, // 17
{ "04l_gs17.bin", 0x8000, 0x4e98562a, 5 | BRF_GRA }, // 18
{ "03l_gs16.bin", 0x8000, 0x0d99c3b3, 5 | BRF_GRA }, // 19
{ "01l_gs15.bin", 0x8000, 0x7f14270e, 5 | BRF_GRA }, // 20
{ "11c_gs14.bin", 0x8000, 0x0af4f7eb, 6 | BRF_GRA }, // 21 Background Tilemaps
{ "03b_g-01.bin", 0x0100, 0x02f55589, 7 | BRF_GRA }, // 22 Color Proms
{ "04b_g-02.bin", 0x0100, 0xe1e36dd9, 7 | BRF_GRA }, // 23
{ "05b_g-03.bin", 0x0100, 0x989399c0, 7 | BRF_GRA }, // 24
{ "09d_g-04.bin", 0x0100, 0x906612b5, 7 | BRF_GRA }, // 25
{ "14a_g-06.bin", 0x0100, 0x4a9da18b, 7 | BRF_GRA }, // 26
{ "15a_g-07.bin", 0x0100, 0xcb9394fc, 7 | BRF_GRA }, // 27
{ "09f_g-09.bin", 0x0100, 0x3cee181e, 7 | BRF_GRA }, // 28
{ "08f_g-08.bin", 0x0100, 0xef91cdd2, 7 | BRF_GRA }, // 29
{ "02j_g-10.bin", 0x0100, 0x0eaf5158, 0 | BRF_OPT }, // 30 Video Timing
{ "01f_g-05.bin", 0x0100, 0x25c90c2a, 0 | BRF_OPT }, // 31 Priority
};
STD_ROM_PICK(gunsmokeu)
STD_ROM_FN(gunsmokeu)
struct BurnDriver BurnDrvGunsmokeu = {
"gunsmokeu", "gunsmoke", NULL, "1985",
"Gun. Smoke (US set 1)\0", NULL, "Capcom (Romstar License)", "Miscellaneous",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_MISC,
NULL, gunsmokeuRomInfo, gunsmokeuRomName, DrvInputInfo, DrvDIPInfo,
DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvCalcPal,
224, 256, 3, 4
};
// Gun. Smoke (US set 2)
static struct BurnRomInfo gunsmokeuaRomDesc[] = {
{ "gs03.9n", 0x8000, 0x51dc3f76, 1 | BRF_PRG | BRF_ESS }, // 0 Z80 #0 Code
{ "gs04.10n", 0x8000, 0x5ecf31b8, 1 | BRF_PRG | BRF_ESS }, // 1
{ "gs05.12n", 0x8000, 0x1c9aca13, 1 | BRF_PRG | BRF_ESS }, // 2
{ "14h_gs02.bin", 0x8000, 0xcd7a2c38, 2 | BRF_PRG | BRF_ESS }, // 3 Z80 #1 Code
{ "11f_gs01.bin", 0x4000, 0xb61ece9b, 3 | BRF_GRA }, // 4 Character Tiles
{ "06c_gs13.bin", 0x8000, 0xf6769fc5, 4 | BRF_GRA }, // 5 32x32 Tiles
{ "05c_gs12.bin", 0x8000, 0xd997b78c, 4 | BRF_GRA }, // 6
{ "04c_gs11.bin", 0x8000, 0x125ba58e, 4 | BRF_GRA }, // 7
{ "02c_gs10.bin", 0x8000, 0xf469c13c, 4 | BRF_GRA }, // 8
{ "06a_gs09.bin", 0x8000, 0x539f182d, 4 | BRF_GRA }, // 9
{ "05a_gs08.bin", 0x8000, 0xe87e526d, 4 | BRF_GRA }, // 10
{ "04a_gs07.bin", 0x8000, 0x4382c0d2, 4 | BRF_GRA }, // 11
{ "02a_gs06.bin", 0x8000, 0x4cafe7a6, 4 | BRF_GRA }, // 12
{ "06n_gs22.bin", 0x8000, 0xdc9c508c, 5 | BRF_GRA }, // 13 Sprites
{ "04n_gs21.bin", 0x8000, 0x68883749, 5 | BRF_GRA }, // 14
{ "03n_gs20.bin", 0x8000, 0x0be932ed, 5 | BRF_GRA }, // 15
{ "01n_gs19.bin", 0x8000, 0x63072f93, 5 | BRF_GRA }, // 16
{ "06l_gs18.bin", 0x8000, 0xf69a3c7c, 5 | BRF_GRA }, // 17
{ "04l_gs17.bin", 0x8000, 0x4e98562a, 5 | BRF_GRA }, // 18
{ "03l_gs16.bin", 0x8000, 0x0d99c3b3, 5 | BRF_GRA }, // 19
{ "01l_gs15.bin", 0x8000, 0x7f14270e, 5 | BRF_GRA }, // 20
{ "11c_gs14.bin", 0x8000, 0x0af4f7eb, 6 | BRF_GRA }, // 21 Background Tilemaps
{ "03b_g-01.bin", 0x0100, 0x02f55589, 7 | BRF_GRA }, // 22 Color Proms
{ "04b_g-02.bin", 0x0100, 0xe1e36dd9, 7 | BRF_GRA }, // 23
{ "05b_g-03.bin", 0x0100, 0x989399c0, 7 | BRF_GRA }, // 24
{ "09d_g-04.bin", 0x0100, 0x906612b5, 7 | BRF_GRA }, // 25
{ "14a_g-06.bin", 0x0100, 0x4a9da18b, 7 | BRF_GRA }, // 26
{ "15a_g-07.bin", 0x0100, 0xcb9394fc, 7 | BRF_GRA }, // 27
{ "09f_g-09.bin", 0x0100, 0x3cee181e, 7 | BRF_GRA }, // 28
{ "08f_g-08.bin", 0x0100, 0xef91cdd2, 7 | BRF_GRA }, // 29
{ "02j_g-10.bin", 0x0100, 0x0eaf5158, 0 | BRF_OPT }, // 30 Video Timing
{ "01f_g-05.bin", 0x0100, 0x25c90c2a, 0 | BRF_OPT }, // 31 Priority
};
STD_ROM_PICK(gunsmokeua)
STD_ROM_FN(gunsmokeua)
struct BurnDriver BurnDrvGunsmokeua = {
"gunsmokeua", "gunsmoke", NULL, "1986",
"Gun. Smoke (US set 2)\0", NULL, "Capcom (Romstar License)", "Miscellaneous",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL, 2, HARDWARE_MISC_MISC,
NULL, gunsmokeuaRomInfo, gunsmokeuaRomName, DrvInputInfo, gunsmokeuaDIPInfo,
DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvCalcPal,
224, 256, 3, 4
};
|
[
"[email protected]"
] |
[
[
[
1,
1008
]
]
] |
39fd49b00c013426c49254d24f7d217ec07066ae
|
222bc22cb0330b694d2c3b0f4b866d726fd29c72
|
/src/brookbox/wm2/WmlCircle2.h
|
c1f6a2d3aad9261fcb15a433d498d5d00b3f43f1
|
[
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
darwin/inferno
|
02acd3d05ca4c092aa4006b028a843ac04b551b1
|
e87017763abae0cfe09d47987f5f6ac37c4f073d
|
refs/heads/master
| 2021-03-12T22:15:47.889580 | 2009-04-17T13:29:39 | 2009-04-17T13:29:39 | 178,477 | 2 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 850 |
h
|
// Magic Software, Inc.
// http://www.magic-software.com
// http://www.wild-magic.com
// Copyright (c) 2003. All Rights Reserved
//
// The Wild Magic Library (WML) source code is supplied under the terms of
// the license agreement http://www.magic-software.com/License/WildMagic.pdf
// and may not be copied or disclosed except in accordance with the terms of
// that agreement.
#ifndef WMLCIRCLE2_H
#define WMLCIRCLE2_H
#include "WmlVector2.h"
namespace Wml
{
template <class Real>
class WML_ITEM Circle2
{
public:
Circle2 ();
Vector2<Real>& Center ();
const Vector2<Real>& Center () const;
Real& Radius ();
const Real& Radius () const;
protected:
Vector2<Real> m_kCenter;
Real m_fRadius;
};
typedef Circle2<float> Circle2f;
typedef Circle2<double> Circle2d;
}
#endif
|
[
"[email protected]"
] |
[
[
[
1,
41
]
]
] |
7cfe10e4c7f8fd764b3eb2e810b3aa0e355501ac
|
96fefafdfbb413a56e0a2444fcc1a7056afef757
|
/MQ2Chat/ISXEQChat.h
|
d8c7152db039743bb4e45f6b22e100195a877765
|
[] |
no_license
|
kevrgithub/peqtgc-mq2-sod
|
ffc105aedbfef16060769bb7a6fa6609d775b1fa
|
d0b7ec010bc64c3f0ac9dc32129a62277b8d42c0
|
refs/heads/master
| 2021-01-18T18:57:16.627137 | 2011-03-06T13:05:41 | 2011-03-06T13:05:41 | 32,849,784 | 1 | 3 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,732 |
h
|
#pragma once
#include <isxdk.h>
class ISXEQChat :
public ISXInterface
{
public:
virtual bool Initialize(ISInterface *p_ISInterface);
virtual void Shutdown();
void LoadSettings();
void ConnectServices();
void RegisterCommands();
void RegisterAliases();
void RegisterDataTypes();
void RegisterTopLevelObjects();
void RegisterServices();
void DisconnectServices();
void UnRegisterCommands();
void UnRegisterAliases();
void UnRegisterDataTypes();
void UnRegisterTopLevelObjects();
void UnRegisterServices();
};
extern ISInterface *pISInterface;
extern HISXSERVICE hPulseService;
extern HISXSERVICE hMemoryService;
extern HISXSERVICE hServicesService;
extern HISXSERVICE hEQChatService;
extern HISXSERVICE hEQUIService;
extern HISXSERVICE hEQGamestateService;
extern HISXSERVICE hEQSpawnService;
extern HISXSERVICE hEQZoneService;
extern ISXEQChat *pExtension;
#define printf pISInterface->Printf
#define EzDetour(Address, Detour, Trampoline) IS_Detour(pExtension,pISInterface,hMemoryService,(unsigned int)Address,Detour,Trampoline)
#define EzUnDetour(Address) IS_UnDetour(pExtension,pISInterface,hMemoryService,(unsigned int)Address)
#define EzModify(Address,NewData,Length,Reverse) Memory_Modify(pExtension,pISInterface,hMemoryService,(unsigned int)Address,NewData,Length,Reverse)
#define EzUnModify(Address) Memory_UnModify(pExtension,pISInterface,hMemoryService,(unsigned int)Address)
#define EzHttpRequest(_URL_,_pData_) IS_HttpRequest(pExtension,pISInterface,hHTTPService,_URL_,_pData_)
extern LSType *pStringType;
extern LSType *pIntType;
extern LSType *pBoolType;
extern LSType *pFloatType;
extern LSType *pTimeType;
extern LSType *pByteType;
|
[
"[email protected]@39408780-f958-9dab-a28b-4b240efc9052"
] |
[
[
[
1,
57
]
]
] |
22989bff40d61d4f06036a74ea5faf41e77402b1
|
260c113e54a8194a20af884e7fd7e3cadb1cf610
|
/sllabzzuf/src/Camera.cpp
|
24323c2f20daea18a342da929d264a4c0594f4e3
|
[] |
no_license
|
weimingtom/sllabzzuf
|
8ce0205cc11ff5cdb569e8b2a629eb6cbbfebfc6
|
5f22cc5686068b179b3c17010d948ff05f16724c
|
refs/heads/master
| 2020-06-09T01:02:00.944446 | 2011-04-07T05:34:22 | 2011-04-07T05:34:22 | 38,219,985 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 505 |
cpp
|
#include "camera.h"
Camera::Camera(){
bounds.x =0;
bounds.y =0;
bounds.w = SCREEN_WIDTH;
bounds.h = SCREEN_HEIGHT;
}
SDL_Rect *Camera::get_bounds(){
return &bounds;
}
int Camera::get_x(){
return bounds.x;
}
int Camera::get_y(){
return bounds.y;
}
int Camera::get_w(){
return bounds.w;
}
int Camera::get_h(){
return bounds.h;
}
void Camera::set_x(int x){
bounds.x = x;
}
void Camera::set_y(int y){
bounds.y = y;
}
|
[
"[email protected]"
] |
[
[
[
1,
36
]
]
] |
148f21a6c611fb70767fb26bd0da3776c09a581e
|
0c51dff7fad22caddab72ff125e2d7ace9c7e813
|
/kinsole.cpp
|
7fa3f8be6c5a2f0f53c473c81b816711b6131a42
|
[
"MIT"
] |
permissive
|
hacker/kinsole
|
adbad257f52e55f4aff7b30ad9c87a926632c967
|
fc7dc5278f4590c74e41b3ce89d093a05550ec44
|
refs/heads/master
| 2016-09-09T18:34:55.405333 | 2005-08-06T13:47:13 | 2005-08-06T13:47:13 | 892,105 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 18,547 |
cpp
|
#include <stdio.h>
#ifdef _DEBUG
#include <afxwin.h>
#else
#define ASSERT(f) ((void)0)
#define VERIFY(f) ((void)(f))
#define TRACE0(sz)
#define TRACE1(sz, p1)
#define TRACE2(sz, p1, p2)
#define TRACE3(sz, p1, p2, p3)
#endif
#include <winsock.h>
#include "resource.h"
#include "windowsx.h"
#define DAMN_KIN_NAME "KINSole"
#define DAMN_KIN_VERSION "1.1.1"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
enum {
WM_USERSOCKET = WM_USER+16,
WM_USERKEY,
WM_USERNOP
};
enum {
tnIAC = 255,
tnSE = 240,
tnNOP = 241,
tnDM = 242,
tnBreak = 243,
tnIP = 244,
tnAO = 245,
tnAYT = 246,
tnEC = 247,
tnEL = 248,
tnGA = 249,
tnSB = 250,
tnWILL = 251,
tnWONT = 252,
tnDO = 253,
tnDONT = 254
};
WSADATA wsaData;
ATOM wsaWC = NULL;
HWND wsaW = NULL;
CHAR remoteHost[256];
CHAR remoteProt[256];
sockaddr_in remoteSIN;
SOCKET telnetSocket;
HANDLE hConsoleInput;
HANDLE hConsoleOutput;
HWND hConsoleWindow;
HANDLE hConsoleThread;
DWORD consoleThreadID;
HANDLE hDispatchThread;
DWORD dispatchThreadID;
BOOL bTelnet,bTermPulled;
enum _cState {
cstateNone = 0, cstateIAC, cstateDO, cstateSB, cstateSBData,
cstateSBDataIAC, cstateWILL, cstateDONT,cstateWONT,
} connState = cstateNone;
BYTE negOption = 0;
BOOL SelectSocket() {
return WSAAsyncSelect(telnetSocket,wsaW,WM_USERSOCKET,FD_READ|FD_OOB|FD_CLOSE)!=SOCKET_ERROR;
}
BOOL ShowWill(BYTE o)
{
TRACE1("We're WILLing to %d\n",(WORD)o);
static
BYTE d[3] = {tnIAC,tnWILL,0};
d[2] = o;
BOOL rv = send(telnetSocket,(char*)d,sizeof(d),0)==sizeof(d);
SelectSocket();
return rv;
}
BOOL ShowUnwill(BYTE o)
{
TRACE1("We're NOT WILLing to %d\n",(WORD)o);
static
BYTE d[3] = {tnIAC,tnWONT,0};
d[2] = o;
BOOL rv = send(telnetSocket,(char*)d,sizeof(d),0)==sizeof(d);
SelectSocket();
return rv;
}
BOOL BegDo(BYTE o)
{
TRACE1("We beg to DO %d\n",(WORD)o);
static
BYTE d[3] = {tnIAC,tnDO,0};
d[2] = o;
BOOL rv = send(telnetSocket,(char*)d,sizeof(d),0)==sizeof(d);
SelectSocket();
return rv;
}
BOOL BegDont(BYTE o)
{
TRACE1("We beg DONT'T %d\n",(WORD)o);
static
BYTE d[3] = {tnIAC,tnDONT,0};
d[2] = o;
BOOL rv = send(telnetSocket,(char*)d,sizeof(d),0)==sizeof(d);
SelectSocket();
return rv;
}
BOOL SubNegotiate(BYTE o,LPBYTE data,UINT size)
{
LPBYTE d = new BYTE[3+size*2+2];
int ds = 0;
d[ds++]=tnIAC; d[ds++]=tnSB; d[ds++]=o;
for(UINT tmp=0;tmp<size;tmp++)
if(data[tmp]!=tnIAC)
d[ds++]=data[tmp];
else{
d[ds++]=tnIAC; d[ds++]=tnIAC;
}
d[ds++]=tnIAC;d[ds++]=tnSE;
BOOL rv = send(telnetSocket,(char*)d,ds,0)==ds;
delete d;
SelectSocket();
return rv;
}
BOOL SendLiteral(CHAR c)
{
BYTE d[2] = {tnIAC,0};
BOOL rv = FALSE;
if(c==tnIAC){
d[1]=c;
rv = send(telnetSocket,(char*)d,2,0)==2;
}else
rv = send(telnetSocket,&c,1,0)==1;
return rv;
}
BOOL SendLiteral(LPCTSTR c,UINT size)
{
for(UINT tmp=0;tmp<size;tmp++)
SendLiteral(c[tmp]);
return TRUE;
}
BOOL SendLiteral(LPCTSTR c)
{
return SendLiteral(c,strlen(c));
}
BOOL SendCommand(BYTE c)
{
TRACE1("Issuing %d command\n",(WORD)c);
static
BYTE d[2] = {tnIAC,0};
d[1] = c;
BOOL rv = send(telnetSocket,(char*)d,sizeof(d),0)==sizeof(d);
SelectSocket();
return rv;
}
BOOL CALLBACK consoleCtrlHandler(DWORD dwCtrlType)
{
switch(dwCtrlType){
case CTRL_BREAK_EVENT:
SendCommand(tnIP);
return TRUE;
case CTRL_CLOSE_EVENT:
case CTRL_LOGOFF_EVENT:
case CTRL_SHUTDOWN_EVENT:
PostMessage(wsaW,WM_QUIT,0,0);
return TRUE;
}
return FALSE;
}
#include "options.cpp"
BOOL ProcessConsoleInput()
{
INPUT_RECORD ir[512];
DWORD got;
while(GetNumberOfConsoleInputEvents(hConsoleInput,&got) && got){
VERIFY(ReadConsoleInput(hConsoleInput,ir,(sizeof(ir)/sizeof(*ir)),&got));
for(DWORD tmp=0;tmp<got;tmp++){
if(ir[tmp].EventType==KEY_EVENT && ir[tmp].Event.KeyEvent.bKeyDown){
if((
ir[tmp].Event.KeyEvent.wVirtualKeyCode=='X' ||
ir[tmp].Event.KeyEvent.wVirtualKeyCode=='Q'
) && ir[tmp].Event.KeyEvent.dwControlKeyState&(LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED)
){
PostMessage(wsaW,WM_QUIT,0,0);
return FALSE;
}else if(
ir[tmp].Event.KeyEvent.wVirtualKeyCode=='O'
&& ir[tmp].Event.KeyEvent.dwControlKeyState&(LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED)
){
SendCommand(tnAO);
}else if(
ir[tmp].Event.KeyEvent.wVirtualKeyCode=='Y'
&& ir[tmp].Event.KeyEvent.dwControlKeyState&(LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED)
){
SendCommand(tnAYT);
}else if(
ir[tmp].Event.KeyEvent.wVirtualKeyCode=='T'
&& ir[tmp].Event.KeyEvent.dwControlKeyState&(LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED)
){
BegDo(toTimingMark);
}else if(
ir[tmp].Event.KeyEvent.wVirtualKeyCode==VK_INSERT
&& ir[tmp].Event.KeyEvent.dwControlKeyState&SHIFT_PRESSED
){
if(IsClipboardFormatAvailable(CF_OEMTEXT)){
ASSERT(wsaW);
if(OpenClipboard(wsaW)){
HANDLE h = GetClipboardData(CF_OEMTEXT);
LPVOID gl = GlobalLock(h);
TerminalIn((LPCTSTR)gl);
GlobalUnlock(h);
// GlobalFree(h);
CloseClipboard();
}
}
}else if(
ir[tmp].Event.KeyEvent.wVirtualKeyCode==VK_INSERT
&& ir[tmp].Event.KeyEvent.dwControlKeyState&(LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED)
){
if(hConsoleWindow)
SendNotifyMessage(hConsoleWindow,WM_COMMAND,MAKELONG(0xE003,0),NULL);
}else
TerminalIn(ir[tmp].Event.KeyEvent);
}
}
}
return TRUE;
}
ULONG CALLBACK ConsoleThreadProc(LPVOID)
{
for(;;){
DWORD eves;
if(!(GetNumberOfConsoleInputEvents(hConsoleInput,&eves) && eves))
WaitForSingleObject(hConsoleInput,INFINITE);
ASSERT(wsaW);
SendMessage(wsaW,WM_USERKEY,0,0);
}
return 0;
}
BOOL SINTelnet(sockaddr_in& sin)
{
protoent* pe = getprotobyname("tcp");
short proto = pe?pe->p_proto:6;
telnetSocket = socket(sin.sin_family,SOCK_STREAM,proto);
if(telnetSocket==INVALID_SOCKET){
printf("Failed to create socket\n");
return FALSE;
}
static
BOOL bOOBInline = FALSE;
if(setsockopt(telnetSocket,SOL_SOCKET,SO_OOBINLINE,(const char*)&bOOBInline,sizeof(bOOBInline))){
TRACE0("Failed to setsockopt for OOB data\n");
}
printf("Trying %s..",inet_ntoa(sin.sin_addr));
if(connect(telnetSocket,(sockaddr*)&sin,sizeof(sin))){
switch(WSAGetLastError()){
case WSAECONNREFUSED: printf("\nConnection refused\n"); break;
case WSAEHOSTUNREACH: printf("\nNo route to host\n"); break;
case WSAENETDOWN: printf("\nNetwork is down\n"); break;
case WSAENETUNREACH: printf("\nNetwork is unreachable\n"); break;
case WSAETIMEDOUT: printf("\nConnection timed out\n"); break;
default: printf("\nFailed to connect\n"); break;
}
return FALSE;
}
printf("\nConnected. Alt-X/Alt-Q - Close telnet connection\n");
//*** hConsoleInput = ::GetStdHandle(STD_INPUT_HANDLE);
//*** hConsoleOutput = ::GetStdHandle(STD_OUTPUT_HANDLE);
hConsoleInput = CreateFile("CONIN$",GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,OPEN_EXISTING,0,NULL);
hConsoleOutput = CreateFile("CONOUT$",GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,OPEN_EXISTING,0,NULL);
ASSERT(hConsoleInput!=INVALID_HANDLE_VALUE &&
hConsoleOutput!=INVALID_HANDLE_VALUE);
if(!(bTelnet || bTermPulled))
TerminalPullType("TTY");
InitOptionsTable();
TRACE0("Connected\n");
VERIFY(SetConsoleCtrlHandler(&consoleCtrlHandler,TRUE));
hConsoleThread = CreateThread(NULL,0,ConsoleThreadProc,NULL,0,&consoleThreadID);
ASSERT(hConsoleThread);
if(bTelnet){
AskDo(toSuppressGA);
AskWill(toTerminalType);
AskWill(toNAWS);
AskUnwill(toEcho);
AskDo(toEcho);
if(Envars && nEnvars)
AskWill(toNewEnviron); // *** Or better (what's better?)
// AskWill(toLineMode);
// *** STATUS
}
MSG msg;
int rvgm;
PostMessage(wsaW,WM_USERNOP,0,0);
VERIFY(SelectSocket());
while(rvgm=GetMessage(&msg,NULL,NULL,NULL)){
if(rvgm<0)
break; // Some wheeping needed
TranslateMessage(&msg);
DispatchMessage(&msg);
// LRESULT CALLBACK WSWndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
// WSWndProc(msg.hwnd,msg.message,msg.wParam,msg.lParam);
VERIFY(SelectSocket());
}
VERIFY(TerminateThread(hConsoleThread,0xFFFFFFFF));
VERIFY(SetConsoleCtrlHandler(&consoleCtrlHandler,FALSE));
closesocket(telnetSocket);
return TRUE;
}
BOOL Telnet(LPCTSTR hostName,UINT port)
{
memset(&remoteSIN,0,sizeof(remoteSIN));
remoteSIN.sin_family = AF_INET;
remoteSIN.sin_port = htons(port);
remoteSIN.sin_addr.s_addr = inet_addr(hostName);
if(remoteSIN.sin_addr.s_addr==INADDR_NONE){
hostent* he = gethostbyname(hostName);
if(!he){
printf("Failed to resolve host name\n");
return FALSE;
}
ASSERT(he->h_addrtype==AF_INET);
ASSERT(he->h_length==sizeof(remoteSIN.sin_addr));
memmove(&remoteSIN.sin_addr,*he->h_addr_list,sizeof(remoteSIN.sin_addr));
}
strcpy(remoteHost,hostName);
return SINTelnet(remoteSIN);
}
void ProcessIACByte(BYTE c)
{
connState = cstateNone;
switch(c){
case tnIAC:
TerminalOut(c);
break;
case tnSE:
TRACE0("SE\n");break;
case tnNOP:
TRACE0("NOP\n");break;
case tnDM:
TRACE0("DM\n");break;
case tnBreak:
TRACE0("Break\n");break;
case tnIP:
TRACE0("IP\n");break;
case tnAO:
TRACE0("AO\n");break;
case tnAYT:
TRACE0("AYT\n");break;
case tnEC:
TRACE0("EC\n");break;
case tnEL:
TRACE0("EL\n");break;
case tnGA:
TRACE0("GA\n");break;
case tnSB:
connState = cstateSB;
break;
case tnWILL:
connState = cstateWILL;
break;
case tnWONT:
connState = cstateWONT;
break;
case tnDO:
connState = cstateDO;
break;
case tnDONT:
connState = cstateDONT;
break;
default:
TRACE1("Unknown OpCode = %d\n",(WORD)c);
break;
}
}
void ProcessNetByte(BYTE c)
{
// TRACE1("<%d>",connState);
switch(connState){
case cstateWONT:
ProcessWONT(c);
break;
case cstateDO:
ProcessDO(c);
break;
case cstateWILL:
ProcessWILL(c);
break;
case cstateDONT:
ProcessDONT(c);
break;
case cstateSB:
negOption = c;
connState = cstateSBData;
break;
case cstateSBData:
case cstateSBDataIAC:
ProcessSBData(c);
break;
case cstateIAC:
ProcessIACByte(c);
break;
case cstateNone:
default:
ASSERT(connState==cstateNone);
if(c==tnIAC)
connState=cstateIAC;
else
TerminalOut(c);
break;
}
}
LRESULT WSMessage(WPARAM wP,LPARAM lP)
{
if(WSAGETSELECTERROR(lP)){
TRACE0("SelectError\n");
PostMessage(wsaW,WM_QUIT,0,0);
return 0;
}
if(WSAGETSELECTEVENT(lP)&FD_READ){
//?? TRACE0("FD_READ\n");
BYTE input[80*12];
int got;
TerminalPreO();
//?? TRACE0("rv\n");
got=recv(telnetSocket,(CHAR*)input,sizeof(input),0);
//?? TRACE1("/rv %d\n",got);
for(int tmp=0;tmp<got;tmp++)
ProcessNetByte(input[tmp]);
TerminalPostO();
//?? TRACE0("/FD_READ\n");
return 0;
}
if(WSAGETSELECTEVENT(lP)&FD_OOB){
TRACE0("OOB\n");
}
if(WSAGETSELECTEVENT(lP)&FD_CLOSE){
TRACE0("CLOSE\n");
PostMessage(wsaW,WM_QUIT,0,0);
return 0;
}
VERIFY(SelectSocket());
return 0;
}
LRESULT CALLBACK WSWndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch(uMsg){
case WM_USERSOCKET:
return WSMessage(wParam,lParam);
case WM_USERKEY:
return ProcessConsoleInput();
default:
TRACE0("DEFWINDOWPROC\n");
return ::DefWindowProc(hWnd,uMsg,wParam,lParam);
}
return 0;
}
BOOL InitializeWinsock()
{
if(WSAStartup(0x101,&wsaData)){
printf("Failed to initialize winsock services\n");
return FALSE;
}
WNDCLASS wc;
memset(&wc,0,sizeof(wc));
wc.lpfnWndProc=WSWndProc; wc.hInstance=::GetModuleHandle(NULL);
wc.lpszClassName = "_WSTFWC_";
wsaWC = RegisterClass(&wc);
if(!wsaWC){
printf("Failed to initialize winsock services - 1\n");
return FALSE;
}
wsaW = ::CreateWindow("_WSTFWC_","KIN Sole Mio",0,0,0,0,0,NULL,NULL,::GetModuleHandle(NULL),NULL);
if(!wsaW){
printf("Failed to initialize winsock services\n");
return FALSE;
}
return TRUE;
}
void DeinitializeWinsock()
{
if(wsaW)
::DestroyWindow(wsaW);
wsaW=NULL;
if(wsaWC)
::UnregisterClass("_WSTFWC_",::GetModuleHandle(NULL));
wsaWC=NULL;
WSACleanup();
}
HWND GetThisConsoleWnd()
{
DWORD pid = GetCurrentProcessId();
CHAR title[512];
CHAR* t = title;
if(!GetConsoleTitle(title,sizeof(title)))
t = NULL;
HWND hrv = FindWindowEx(NULL,NULL,"tty",t);
HWND nopro = NULL;
UINT nopros=0;
do{
DWORD wpid;
if(!GetWindowThreadProcessId(hrv,&wpid))
continue;
if(wpid==pid)
return hrv;
nopro=hrv;
nopros++;
hrv = FindWindowEx(NULL,hrv,"tty",t);
}while(hrv);
if(nopros==1){
ASSERT(nopro);
return nopro;
}
return NULL;
}
main(int argc,char*argv[])
{
if(argc<2){
usagebye:
printf(
DAMN_KIN_NAME " " DAMN_KIN_VERSION ", Copyright (c) 1998-2005 Klever Group (http://www.klever.net/)\n\n"
"Usage:\t" DAMN_KIN_NAME " [<options> ]<host-name/ip-address>[ <port>]\n\n"
"Options are:\n"
"-r## or -##\tSet number of rows in console screenbuffer\n"
"-c##\t\tSet number of columns in console screenbuffer\n"
"\tnote: changing console screenbuffer size may not work properly\n"
"\twhen in full-screen mode\n"
"-l<user>\tPass username to remote server in environment\n"
"-e<var>=<val>\tPass environment variable to remote server\n"
"-v<var>=<val>\tPass user environment variable to remote server\n"
"-t<termtype>\tChange preferred terminal type\n"
"\tnote: there are only two different terminal emulations in this\n"
"\trelease - one for dumb terminal and one for vt terminal\n"
);
CleanEnvars();
return 1;
}
if(!InitializeWinsock()){
DeinitializeWinsock();
return 2;
}
CONSOLE_SCREEN_BUFFER_INFO csbi;
int ac = 0;
CHAR *ho = NULL, *po = NULL;
HANDLE hConsole = CreateFile("CONOUT$",GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,OPEN_EXISTING,0,NULL);
ASSERT(hConsole);
// *** GetStdHandle(STD_OUTPUT_HANDLE); // *?*?* Do something about redirections and not only here.
VERIFY(GetConsoleScreenBufferInfo(hConsole,&csbi));
BOOL bSized=FALSE;
bTermPulled=FALSE;
for(int tmp=1;tmp<argc;tmp++){
char* v = argv[tmp];
ASSERT(v && *v);
if((*v)=='/' || (*v)=='-'){
int lines = atoi(&v[1]);
if(lines){
if(lines<csbi.dwSize.Y){
SMALL_RECT wi = {0,0,csbi.dwSize.X-1,lines-1};
VERIFY(SetConsoleWindowInfo(hConsole,TRUE,&wi));
}
COORD ns = {csbi.dwSize.X,lines};
if(SetConsoleScreenBufferSize(hConsole,ns))
bSized=TRUE;
}else if(v[1]=='r'){
int lines = atoi(&v[2]);
if(lines){
if(lines<csbi.dwSize.Y){
SMALL_RECT wi = {0,0,csbi.dwSize.X-1,lines-1};
VERIFY(SetConsoleWindowInfo(hConsole,TRUE,&wi));
}
COORD ns = {csbi.dwSize.X,lines};
if(SetConsoleScreenBufferSize(hConsole,ns))
bSized=TRUE;
}else
goto usagebye;
}else if(v[1]=='c'){
int rows = atoi(&v[2]);
if(rows){
if(rows<csbi.dwSize.X){
SMALL_RECT wi = {0,0,rows-1,csbi.dwSize.Y-1};
VERIFY(SetConsoleWindowInfo(hConsole,TRUE,&wi));
}
COORD ns = {rows,csbi.dwSize.Y};
if(SetConsoleScreenBufferSize(hConsole,ns))
bSized=TRUE;
}else
goto usagebye;
}else if(v[1]=='l'){
CHAR* vv = &v[2];
VERIFY(AddEnvar(nesbVar,"USER",vv));
}else if(v[1]=='e'){ // -e<name>=<value> VAR
CHAR* n = &v[2];
CHAR* vv = strchr(&v[2],'=');
if(!vv)
goto usagebye;
*(vv++)=0;
VERIFY(AddEnvar(nesbVar,n,vv));
}else if(v[1]=='v'){ // -v<name>=<value> USERVAR
CHAR* n = &v[2];
CHAR* vv = strchr(n,'=');
if(!vv)
goto usagebye;
*(vv++)=0;
VERIFY(AddEnvar(nesbUserVar,n,vv));
}else if(v[1]=='t'){ // -t<ttype> -t<tname>=<ttype>
CHAR* n = &v[2];
CHAR* nn = strchr(n,'=');
if(nn){
*(nn++)=0;
if(!*nn)
nn=NULL;
}
if(!TerminalPullType(nn?nn:n,nn?n:NULL)){
printf("Available terminal types are:");
TerminalPrintTypes();
printf("\n");
goto usagebye;
}
bTermPulled=TRUE;
}else if(v[1]=='#'){
int cp = atoi(&v[2]);
#ifdef _DEBUG
TRACE2("SetCP(%d)=%d\n",cp,SetConsoleCP(cp));
TRACE2("SetOutCP(%d)=%d\n",cp,SetConsoleOutputCP(cp));
#else
SetConsoleCP(cp);
SetConsoleOutputCP(cp);
#endif
TRACE2("CP,OCP=%d,%d\n",GetConsoleCP(),GetConsoleOutputCP());
}else
goto usagebye;
}else{
if(ac==0){
ho = v;
ac++;
}else if(ac==1){
po = v;
ac++;
}else
goto usagebye;
}
}
if(!ho)
goto usagebye;
servent* se = getservbyname("telnet","tcp");
UINT port = po?atol(po):(se?ntohs(se->s_port):23);
if(port==23 || (se && port==ntohs(se->s_port)))
bTelnet = TRUE;
if(po && !port){
se = getservbyname(po,"tcp");
if(!se){
printf("Failed to resolve tcp-service port name\n");
DeinitializeWinsock();
return 2;
}
port = ntohs(se->s_port);
if(!stricmp(po,"telnet"))
bTelnet = TRUE;
else
bTelnet = FALSE;
}else{
se = getservbyport(htons(port),"tcp");
if(se){
po = se->s_name;
if(!stricmp(po,"telnet"))
bTelnet=TRUE;
}else{
VERIFY(_itoa(port,remoteProt,10));
po = NULL;
bTelnet=FALSE;
}
}
if(po)
strcpy(remoteProt,po);
HICON hIcon = LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_IKON));
LONG oldBIcon = NULL, oldSIcon = NULL;
hConsoleWindow = GetThisConsoleWnd();
if(hConsoleWindow){
oldBIcon = SendMessage(hConsoleWindow,WM_SETICON,ICON_BIG,(LPARAM)hIcon);
oldSIcon = SendMessage(hConsoleWindow,WM_SETICON,ICON_SMALL,(LPARAM)hIcon);
}
Telnet(ho,port);
CleanEnvars();
if(hConsoleWindow){
SendMessage(hConsoleWindow,WM_SETICON,ICON_BIG,(LPARAM)oldBIcon);
SendMessage(hConsoleWindow,WM_SETICON,ICON_SMALL,(LPARAM)oldSIcon);
}
Sleep(150);
if(bSized){
CONSOLE_SCREEN_BUFFER_INFO CSBI;
VERIFY(GetConsoleScreenBufferInfo(hConsole,&CSBI));
if(CSBI.dwSize.Y>csbi.dwSize.Y || CSBI.dwSize.X>csbi.dwSize.X){
SMALL_RECT wi = {0,0,csbi.dwSize.X-1,csbi.dwSize.Y-1};
VERIFY(SetConsoleWindowInfo(hConsole,TRUE,&wi));
}
COORD ns = {csbi.dwSize.X,csbi.dwSize.Y};
VERIFY(SetConsoleScreenBufferSize(hConsole,ns));
}
Sleep(100);
DeinitializeWinsock();
Sleep(100);
return 0;
}
|
[
"[email protected]"
] |
[
[
[
1,
736
]
]
] |
6655b0cdb60725719a87ee74f07573dfdc10060d
|
7a310d01d1a4361fd06b40a74a2afc8ddc23b4d3
|
/src/ParseInternetShortcutFile.h
|
e5f9c7d22806e88725ab8649aa7f617cf8b6bb79
|
[] |
no_license
|
plus7/DonutG
|
b6fec6111d25b60f9a9ae5798e0ab21bb2fa28f6
|
2d204c36f366d6162eaf02f4b2e1b8bc7b403f6b
|
refs/heads/master
| 2020-06-01T15:30:31.747022 | 2010-08-21T18:51:01 | 2010-08-21T18:51:01 | 767,753 | 1 | 2 | null | null | null | null |
SHIFT_JIS
|
C++
| false | false | 1,198 |
h
|
/**
* @file ParseInternetShortcutFile.h
* @brief インターネットショートカット(.url)からurlを取得. (検索拡張あり)
* @note
* MtlWeb.cpp にあった MdlParseInternetShortcutFile を、検索関係の拡張を
* したもの.
* 検索バーやアドレスバーを呼び出してて、すでに MTL の範疇外だが、
* Mtl::MDITabCtrl からも呼ばれるので、とりあえず MTL のフリをする.
* (MDITabCtrlからの呼び方を1クッションおくようにすべき...)
*/
#pragma once
namespace MTL {
///+++ unDonut側の処理を呼びまくるような改変をしたので、MtlWeb.cpp から移動.
bool ParseInternetShortcutFile(CString &strFilePath);
///+++ リンクバーでドロップされた文字列を検索する場合用.
int ParseInternetShortcutFile_SearchMode(CString &strFilePath, const CString& strSearch);
///+++ アドレスバーの文字列を返す.
/// ※ CSearchBar向けに用意. 本来は CDonutAddressBar::の同名関数を呼べばいいだけだが、
/// DonutAddressBar.hをSearchBar.hでincludeすると後がしんどいので...
CString GetAddressBarText();
}
|
[
"[email protected]"
] |
[
[
[
1,
27
]
]
] |
be02d3d82363e9e2e2d1c2ca00c2939c8964f07c
|
21dd1ece27a68047f93bac2bdf9e6603827b1990
|
/CppUTest/tests/AllTests.cpp
|
c9fbb3721fb9f92349c8cb63fbc6224dcf94dd72
|
[] |
no_license
|
LupusDei/8LU-DSP
|
c626ce817b6b178c226c437537426f25597958a5
|
65860326bb89a36ff71871b046642b7dd45d5607
|
refs/heads/master
| 2021-01-17T21:51:19.971505 | 2010-09-24T15:08:01 | 2010-09-24T15:08:01 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,775 |
cpp
|
/*
* Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "CppUTest/CommandLineTestRunner.h"
int main(int ac, const char** av)
{
return CommandLineTestRunner::RunAllTests(ac, av);
}
|
[
"[email protected]"
] |
[
[
[
1,
34
]
]
] |
e09bceb9ee9165ebaf296bf6a3fd6cd5b0328108
|
110f8081090ba9591d295d617a55a674467d127e
|
/tests/ThreadPoolTest.cpp
|
4284aa33ca1b343d2500243527c4009644526b67
|
[] |
no_license
|
rayfill/cpplib
|
617bcf04368a2db70aea8b9418a45d7fd187d8c2
|
bc37fbf0732141d0107dd93bcf5e0b31f0d078ca
|
refs/heads/master
| 2021-01-25T03:49:26.965162 | 2011-07-17T15:19:11 | 2011-07-17T15:19:11 | 783,979 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,211 |
cpp
|
#include <cppunit/extensions/HelperMacros.h>
#include <Thread/ThreadPool.hpp>
#include <iostream>
class TestRunnable : public Runnable
{
private:
volatile int counter;
public:
TestRunnable()
: counter()
{}
virtual ~TestRunnable()
{}
int getCounter() const
{
return counter;
}
virtual void prepare() throw()
{}
virtual void dispose() throw()
{}
virtual unsigned run() throw(ThreadException)
{
return ++counter;
}
};
class ThreadPoolTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(ThreadPoolTest);
CPPUNIT_TEST(internalThreadTest);
CPPUNIT_TEST_SUITE_END();
public:
void internalThreadTest()
{
typedef ThreadPool<>::RerunnableThread rerun_thread_t;
TestRunnable testRunner;
rerun_thread_t testThread;
rerun_thread_t::sleep(100);
CPPUNIT_ASSERT(testRunner.getCounter() == 0);
testThread.start(&testRunner);
testThread.join();
CPPUNIT_ASSERT(testRunner.getCounter() == 1);
testThread.start(&testRunner);
testThread.join();
CPPUNIT_ASSERT(testRunner.getCounter() == 2);
testThread.quit();
testThread.join();
}
};
CPPUNIT_TEST_SUITE_REGISTRATION( ThreadPoolTest );
|
[
"alfeim@287b3242-7fab-264f-8401-8509467ab285"
] |
[
[
[
1,
69
]
]
] |
6bc785a18e70c3e2ed339fc832db00928bebbc51
|
b4d726a0321649f907923cc57323942a1e45915b
|
/CODE/GRAPHICS/grd3dbatch.cpp
|
824bcc5fff8c6ec80102e08b0ead9cfcded88ffd
|
[] |
no_license
|
chief1983/Imperial-Alliance
|
f1aa664d91f32c9e244867aaac43fffdf42199dc
|
6db0102a8897deac845a8bd2a7aa2e1b25086448
|
refs/heads/master
| 2016-09-06T02:40:39.069630 | 2010-10-06T22:06:24 | 2010-10-06T22:06:24 | 967,775 | 2 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 22,321 |
cpp
|
/*
* Copyright (C) Volition, Inc. 1999. All rights reserved.
*
* All source code herein is the property of Volition, Inc. You may not sell
* or otherwise commercially exploit the source or things you created based on the
* source.
*
*/
/*
* $Log: grd3dbatch.cpp,v $
* Revision 1.1.1.1 2004/08/13 22:47:41 Spearhawk
* no message
*
* Revision 1.1.1.1 2004/08/13 20:45:53 Darkhill
* no message
*
* Revision 2.13 2004/03/20 14:47:13 randomtiger
* Added base for a general dynamic batching solution.
* Fixed NO_DSHOW_CODE code path bug.
*
* Revision 2.12 2004/02/16 11:47:33 randomtiger
* Removed a lot of files that we dont need anymore.
* Changed htl to be on by default, command now -nohtl
* Changed D3D to use a 2D vertex for 2D operations which should cut down on redundant data having to go though the system.
* Added small change to all -start_mission flag to take you to any mission by filename, very useful for testing.
* Removed old dshow code and took away timerbar compile flag condition since it uses a runtime flag now.
*
* Revision 2.11 2004/02/14 00:18:31 randomtiger
* Please note that from now on OGL will only run with a registry set by Launcher v4. See forum for details.
* OK, these changes effect a lot of file, I suggest everyone updates ASAP:
* Removal of many files from project.
* Removal of meanless Gr_bitmap_poly variable.
* Removal of glide, directdraw, software modules all links to them, and all code specific to those paths.
* Removal of redundant Fred paths that arent needed for Fred OGL.
* Have seriously tidied the graphics initialisation code and added generic non standard mode functionality.
* Fixed many D3D non standard mode bugs and brought OGL up to the same level.
* Removed texture section support for D3D8, voodoo 2 and 3 cards will no longer run under fs2_open in D3D, same goes for any card with a maximum texture size less than 1024.
*
* Revision 2.10 2004/01/24 15:52:26 randomtiger
* I have submitted the new movie playing code despite the fact in D3D it sometimes plays behind the main window.
* In OGL it works perfectly and in both API's it doesnt switch to the desktop anymore so hopefully people will not experience the crashes etc that the old system used to suffer from.
*
* Revision 2.9 2003/12/08 22:30:02 randomtiger
* Put render state and other direct D3D calls repetition check back in, provides speed boost.
* Fixed bug that caused fullscreen only crash with DXT textures
* Put dithering back in for tgas and jpgs
*
* Revision 2.8 2003/12/04 20:39:09 randomtiger
* Added DDS image support for D3D
* Added new command flag '-ship_choice_3d' to activate 3D models instead of ani's in ship choice, feature now off by default
* Hopefully have fixed D3D text batching bug that caused old values to appear
* Added Hud_target_object_factor variable to control 3D object sizes of zoom in HUD target
* Fixed jump nodes not showing
*
* Revision 2.7 2003/11/29 10:52:09 randomtiger
* Turned off D3D file mapping, its using too much memory which may be hurting older systems and doesnt seem to be providing much of a speed benifit.
* Added stats command for ingame stats on memory usage.
* Trys to play intro.mve and intro.avi, just to be safe since its not set by table.
* Added fix for fonts wrapping round in non standard hi res modes.
* Changed D3D mipmapping to a good value to suit htl mode.
* Added new fog colour method which makes use of the bitmap, making this htl feature backcompatible again.
*
* Revision 2.6 2003/11/19 20:37:24 randomtiger
* Almost fully working 32 bit pcx, use -pcx32 flag to activate.
* Made some commandline variables fit the naming standard.
* Changed timerbar system not to run pushes and pops if its not in use.
* Put in a note about not uncommenting asserts.
* Fixed up a lot of missing POP's on early returns?
* Perhaps the motivation for Assert functionality getting commented out?
* Fixed up some bad asserts.
* Changed nebula poofs to render in 2D in htl, it makes it look how it used to in non htl. (neb.cpp,1248)
* Before the poofs were creating a nasty stripe effect where they intersected with ships hulls.
* Put in a special check for the signs of that D3D init bug I need to lock down.
*
*/
#include "globalincs/pstypes.h"
#include "graphics/grbatch.h"
#include "grd3dbatch.h"
#include <d3d8.h>
#include <d3d8types.h>
#include "2d.h"
#include "graphics/grd3dinternal.h"
#include "debugconsole/timerbar.h"
const int FONT_VTYPE = D3DVT_VERTEX2D;
typedef D3DVERTEX2D FONT_VERTEX;
// BATCH STUFF
const int MAX_BATCH_BUFFERS = 5;
typedef struct
{
IDirect3DVertexBuffer8 *vbuffer;
int max_size;
int current_size;
int render_from;
int vertex_type;
int prim_type;
int lock;
BatchInfo current_info;
} Batch;
extern VertexTypeInfo vertex_types[D3DVT_MAX];
Batch *batch_array;
int batch_array_max;
// FONT BATCH STUFF
const int MIN_STRING_LEN = 1;
const int MAX_SM_STRINGS = 64;
const int MAX_SM_STR_LEN = 20;
const int MAX_LG_STRINGS = 10;
const int MAX_LG_STR_LEN = 256;
const int MAX_STRING_LEN = 512;
typedef struct
{
int magic_number;
int magic_number2;
bool used_this_frame;
bool free_slot;
int x,y, len;
int char_count;
uint color;
int offsetx;
int offsety;
IDirect3DVertexBuffer8 *vbuffer;
} StringBatch;
StringBatch *long_str_array;
StringBatch *small_str_array;
FONT_VERTEX d3d_verts[MAX_STRING_LEN*6];
bool d3d_batch_string_init();
void d3d_batch_string_deinit();
void d3d_batch_string_end_frame();
bool batch_info_are_equal(const BatchInfo &lhs, const BatchInfo &rhs)
{
return
(lhs.state_set_func == rhs.state_set_func) &&
(lhs.texture_id == rhs.texture_id) &&
(lhs.bitmap_type == rhs.bitmap_type) &&
(lhs.filter_type == rhs.filter_type) &&
(lhs.alpha_blend_type == rhs.alpha_blend_type) &&
(lhs.zbuffer_type == rhs.zbuffer_type);
}
bool d3d_batch_init()
{
Assert(batch_array == NULL);
batch_array = (Batch *) malloc(MAX_BATCH_BUFFERS * sizeof(Batch));
if(batch_array == NULL) return false;
batch_array_max = MAX_BATCH_BUFFERS;
ZeroMemory(batch_array, batch_array_max * sizeof(Batch));
return d3d_batch_string_init();
}
void d3d_batch_deinit()
{
if(batch_array == NULL) return;
for(int i = 0; i < batch_array_max; i++) {
if(batch_array[i].vbuffer != NULL) {
d3d_destory_batch(i);
}
}
free(batch_array);
d3d_batch_string_deinit();
}
int d3d_create_batch(int num_verts, int vert_type, int ptype)
{
if(batch_array_max == 0) return -1;
int i = 0;
// Find a free space
while(batch_array[i].vbuffer != NULL) {
i++;
// Failed to find
if(i == batch_array_max) return -1;
}
HRESULT hr = GlobalD3DVars::lpD3DDevice->CreateVertexBuffer(
num_verts * vertex_types[vert_type].size,
D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, // Usage
vertex_types[vert_type].fvf,
D3DPOOL_DEFAULT,
&batch_array[i].vbuffer);
if(FAILED(hr)) return -1;
if(batch_array[i].vbuffer == NULL) return -1;
batch_array[i].vertex_type = vert_type;
batch_array[i].prim_type = ptype;
ZeroMemory(&batch_array[i].current_info, sizeof(BatchInfo));
batch_array[i].max_size = num_verts;
return i;
}
void d3d_destory_batch(int batch_id)
{
if(batch_array_max == 0) return;
Assert(batch_id < batch_array_max);
Assert(batch_array[batch_id].vbuffer != NULL);
if(batch_array[batch_id].vbuffer) {
batch_array[batch_id].vbuffer->Release();
}
ZeroMemory(&batch_array[batch_id], sizeof(Batch));
}
void *d3d_batch_lock_vbuffer(int batch_id, int num_to_lock, BatchInfo &batch_info)
{
if(batch_array_max == 0) return NULL;
Assert(batch_id < batch_array_max);
Assert(batch_array[batch_id].vbuffer != NULL);
HRESULT hr;
BYTE *p_data = NULL;
// Default flag
int flags = D3DLOCK_NOOVERWRITE;
// If we run out of buffer space or render state or texture changes we must render and start
// a new batch
bool enough_space = (batch_array[batch_id].current_size + num_to_lock) < batch_array[batch_id].max_size;
bool info_match = true; // assume true
// If the info is actually then correct this
if(batch_array[batch_id].current_info.is_set)
{
info_match = batch_info_are_equal(batch_info, batch_array[batch_id].current_info);
}
else
{
memcpy(&batch_array[batch_id].current_info, &batch_info, sizeof(BatchInfo));
}
if(!enough_space || !info_match)
{
// Render now!
d3d_batch_draw_vbuffer(batch_id);
memcpy(&batch_array[batch_id].current_info, &batch_info, sizeof(BatchInfo));
batch_array[batch_id].current_info.is_set = true;
batch_array[batch_id].render_from = batch_array[batch_id].current_size;
flags = D3DLOCK_DISCARD;
}
int size = vertex_types[batch_array[batch_id].vertex_type].size;
hr = batch_array[batch_id].vbuffer->Lock(
batch_array[batch_id].current_size * size, // OffsetToLock,
num_to_lock * size, // SizeToLock,
&p_data,
flags); // Flags
batch_array[batch_id].lock++;
batch_array[batch_id].current_size += num_to_lock;
Assert(SUCCEEDED(hr));
return p_data;
}
void d3d_batch_unlock_vbuffer(int batch_id)
{
if(batch_array_max == 0) return;
Assert(batch_id < batch_array_max);
Assert(batch_array[batch_id].vbuffer != NULL);
// Goober5000 - commented to bypass warning
/*HRESULT hr =*/ batch_array[batch_id].vbuffer->Unlock();
batch_array[batch_id].lock--;
// Kazan - Commented out to bypass compiler saying symbol undefined :D
//Assert(hr);
}
void d3d_set_render_states(BatchInfo &batch_info)
{
gr_set_bitmap(batch_info.texture_id);
// Get this now rather than inside the loop
gr_d3d_set_state(
(gr_texture_source) batch_info.filter_type,
(gr_alpha_blend) batch_info.alpha_blend_type,
(gr_zbuffer_type) batch_info.zbuffer_type );
float u, v;
gr_tcache_set(batch_info.texture_id,
batch_info.bitmap_type, &u, &v );
if(batch_info.state_set_func != NULL)
batch_info.state_set_func();
}
bool d3d_batch_draw_vbuffer(int batch_id)
{
if(batch_array_max == 0) return false;
Assert(batch_id < batch_array_max);
Assert(batch_array[batch_id].vbuffer != NULL);
int vtype = batch_array[batch_id].vertex_type;
int ptype = batch_array[batch_id].prim_type;
int vertex_count = batch_array[batch_id].current_size - batch_array[batch_id].render_from;
if(vertex_count == 0)
return true;
if(batch_array[batch_id].lock > 0) {
d3d_batch_unlock_vbuffer(batch_id);
}
Assert(batch_array[batch_id].lock == 0);
int prim_count = d3d_get_num_prims(vertex_count, (D3DPRIMITIVETYPE) ptype);
d3d_set_render_states(batch_array[batch_id].current_info);
HRESULT hr;
hr = d3d_SetVertexShader(vtype);
Assert(SUCCEEDED(hr));
hr = GlobalD3DVars::lpD3DDevice->SetStreamSource(
0, batch_array[batch_id].vbuffer, vertex_types[vtype].size);
Assert(SUCCEEDED(hr));
hr = GlobalD3DVars::lpD3DDevice->DrawPrimitive(
(D3DPRIMITIVETYPE) ptype, batch_array[batch_id].render_from, prim_count);
Assert(SUCCEEDED(hr));
batch_array[batch_id].current_size = 0;
batch_array[batch_id].render_from = 0;
return SUCCEEDED(hr);
}
void d3d_batch_end_frame()
{
d3d_batch_string_end_frame();
if(batch_array_max == 0) return;
for(int i = 0; i < batch_array_max; i++) {
if(batch_array[i].vbuffer) {
d3d_batch_draw_vbuffer(i);
}
}
}
/**
* @param int x
* @param int y
* @param int w
* @param int h
* @param int sx
* @param int sy
*
* @return void
*/
void d3d_stuff_char(D3DVERTEX2D *src_v, int x,int y,int w,int h,int sx,int sy, int bw, int bh, float u_scale, float v_scale, uint color)
{
float u0, u1, v0, v1;
float x1, x2, y1, y2;
float fbw = i2fl(bw);
float fbh = i2fl(bh);
// Rendition
if(GlobalD3DVars::D3D_Antialiasing) {
u0 = u_scale*(i2fl(sx)-0.5f) / fbw;
v0 = v_scale*(i2fl(sy)+0.05f) / fbh;
u1 = u_scale*(i2fl(sx+w)-0.5f) / fbw;
v1 = v_scale*(i2fl(sy+h)-0.5f) / fbh;
} else if (GlobalD3DVars::D3D_rendition_uvs ) {
u0 = u_scale*(i2fl(sx)+0.5f) / fbw;
v0 = v_scale*(i2fl(sy)+0.5f) / fbh;
u1 = u_scale*(i2fl(sx+w)+0.5f) / fbw;
v1 = v_scale*(i2fl(sy+h)+0.5f) / fbh;
} else {
u0 = u_scale*i2fl(sx)/ fbw;
v0 = v_scale*i2fl(sy)/ fbh;
u1 = u_scale*i2fl(sx+w)/ fbw;
v1 = v_scale*i2fl(sy+h)/ fbh;
}
if(gr_screen.custom_size == -1)
{
x1 = i2fl(x+gr_screen.offset_x);
y1 = i2fl(y+gr_screen.offset_y);
x2 = i2fl(x+w+gr_screen.offset_x);
y2 = i2fl(y+h+gr_screen.offset_y);
} else {
int nx = x+gr_screen.offset_x;
int ny = y+gr_screen.offset_y;
int nw = x+w+gr_screen.offset_x;
int nh = y+h+gr_screen.offset_y;
gr_resize_screen_pos(&nx, &ny);
gr_resize_screen_pos(&nw, &nh);
x1 = i2fl(nx);
y1 = i2fl(ny);
x2 = i2fl(nw);
y2 = i2fl(nh);
}
#if 1
if(gr_screen.custom_size != -1)
{
u1 -= GlobalD3DVars::texture_adjust_u;
v1 -= GlobalD3DVars::texture_adjust_v;
}
#endif
// 0
src_v->sz = 0.99f;
src_v->rhw = 1.0f;
src_v->color = color;
src_v->sx = x1;
src_v->sy = y1;
src_v->tu = u0;
src_v->tv = v0;
src_v++;
// 1
src_v->sz = 0.99f;
src_v->rhw = 1.0f;
src_v->color = color;
src_v->sx = x2;
src_v->sy = y1;
src_v->tu = u1;
src_v->tv = v0;
src_v++;
// 2
src_v->sz = 0.99f;
src_v->rhw = 1.0f;
src_v->color = color;
src_v->sx = x2;
src_v->sy = y2;
src_v->tu = u1;
src_v->tv = v1;
src_v++;
// 0
src_v->sz = 0.99f;
src_v->rhw = 1.0f;
src_v->color = color;
src_v->sx = x1;
src_v->sy = y1;
src_v->tu = u0;
src_v->tv = v0;
src_v++;
// 2
src_v->sz = 0.99f;
src_v->rhw = 1.0f;
src_v->color = color;
src_v->sx = x2;
src_v->sy = y2;
src_v->tu = u1;
src_v->tv = v1;
src_v++;
// 3
src_v->sz = 0.99f;
src_v->rhw = 1.0f;
src_v->color = color;
src_v->sx = x1;
src_v->sy = y2;
src_v->tu = u0;
src_v->tv = v1;
}
bool d3d_batch_string_init()
{
int i;
HRESULT hr;
int size;
size = MAX_LG_STRINGS * sizeof(StringBatch);
long_str_array = (StringBatch *) malloc(size);
if(long_str_array == NULL) return false;
ZeroMemory(long_str_array, size);
for(i = 0; i < MAX_LG_STRINGS; i++) {
hr = d3d_CreateVertexBuffer(
FONT_VTYPE,
MAX_LG_STR_LEN * 6,
D3DUSAGE_WRITEONLY,
(void **) &long_str_array[i].vbuffer);
if(FAILED(hr)) {
d3d_batch_string_deinit();
return false;
}
}
size = MAX_SM_STRINGS * sizeof(StringBatch);
small_str_array = (StringBatch *) malloc(size);
if(small_str_array == NULL) return false;
ZeroMemory(small_str_array, size);
for(i = 0; i < MAX_SM_STRINGS; i++) {
hr = d3d_CreateVertexBuffer(
FONT_VTYPE,
MAX_SM_STR_LEN * 6,
D3DUSAGE_WRITEONLY,
(void **) &small_str_array[i].vbuffer);
if(FAILED(hr)) {
d3d_batch_string_deinit();
return false;
}
}
return true;
}
void d3d_batch_string_deinit()
{
int i;
if(long_str_array) {
for(i = 0; i < MAX_LG_STRINGS; i++) {
if(long_str_array[i].vbuffer)
long_str_array[i].vbuffer->Release();
long_str_array[i].vbuffer = NULL;
}
free(long_str_array);
}
if(small_str_array) {
for(i = 0; i < MAX_SM_STRINGS; i++) {
if(small_str_array[i].vbuffer)
small_str_array[i].vbuffer->Release();
small_str_array[i].vbuffer = NULL;
}
free(small_str_array);
}
}
void d3d_batch_string_end_frame()
{
int i;
for(i = 0; i < MAX_LG_STRINGS; i++) {
long_str_array[i].free_slot = !(long_str_array[i].used_this_frame);
long_str_array[i].used_this_frame = false;
}
for(i = 0; i < MAX_SM_STRINGS; i++) {
small_str_array[i].free_slot = !(small_str_array[i].used_this_frame);
small_str_array[i].used_this_frame = false;
}
}
int find_string(int len, int magic_num, int magic_num2, int sx, int sy, uint color, bool long_str)
{
StringBatch *array = (long_str) ? long_str_array : small_str_array;
int loop_len = (long_str) ? MAX_LG_STRINGS : MAX_SM_STRINGS;
for(int i = 0; i < loop_len; i++) {
if(array[i].magic_number == magic_num &&
array[i].magic_number2 == magic_num2 &&
array[i].len == len &&
array[i].offsetx == gr_screen.offset_x &&
array[i].offsety == gr_screen.offset_y &&
array[i].x == sx &&
array[i].y == sy &&
array[i].color == color) {
return i;
}
}
return -1;
}
int find_free_slot(bool long_str)
{
StringBatch *array = (long_str) ? long_str_array : small_str_array;
int loop_len = (long_str) ? MAX_LG_STRINGS : MAX_SM_STRINGS;
for(int i = 0; i < loop_len; i++) {
if(array[i].used_this_frame == false &&
array[i].free_slot == true)
{
return i;
}
}
return -1;
}
/**
* Generate magic number to identify string
*
* @param char *s - String to find length of
* @param int &magic_number
* @return - Length of string
*/
inline int strlen_magic(char *s, int &magic_number, int &magic_number2)
{
int count = 0;
magic_number = 0;
magic_number2 = 0;
while(*s != '\0')
{
magic_number += *s;
magic_number2 += (count % 2) ? + *s : - *s;
count++;
s++;
}
return count;
}
void d3d_batch_string(int sx, int sy, char *s, int bw, int bh, float u_scale, float v_scale, uint color)
{
int spacing = 0;
int width;
int x = sx;
int y = sy;
// centered
x =(sx==0x8000) ? get_centered_x(s) : sx;
do
{
HRESULT hr;
int magic_num, magic_num2;
int len = strlen_magic(s, magic_num, magic_num2);
int new_id = -1;
if(len == 0) return;
// Set to 0 to turn off batching to gfx card memory
#if 1
// Check the string is of a valid size
if(len > MIN_STRING_LEN && len < MAX_LG_STR_LEN)
{
bool long_str = (len >= MAX_SM_STR_LEN);
int index = find_string(len, magic_num, magic_num2, sx, sy, color, long_str);
// We have found the string, render and mark as rendered
if(index != -1)
{
StringBatch *array = (long_str) ? long_str_array : small_str_array;
extern VertexTypeInfo vertex_types[D3DVT_MAX];
d3d_SetVertexShader(FONT_VTYPE);
hr = GlobalD3DVars::lpD3DDevice->SetStreamSource(
0, array[index].vbuffer, vertex_types[FONT_VTYPE].size);
Assert(SUCCEEDED(hr));
hr = GlobalD3DVars::lpD3DDevice->DrawPrimitive(
D3DPT_TRIANGLELIST, 0, array[index].char_count * 2);
// Assert(SUCCEEDED(hr));
array[index].used_this_frame = true;
return;
// Prepare to enter the string
} else {
new_id = find_free_slot(long_str);
}
}
#endif
IDirect3DVertexBuffer8 *vbuffer = NULL;
FONT_VERTEX *locked_buffer = NULL;
StringBatch *array = NULL;
if(new_id != -1) {
array = (len > MAX_SM_STR_LEN) ? long_str_array : small_str_array;
vbuffer = array[new_id].vbuffer;
hr = vbuffer->Lock(0, len * 6 * vertex_types[FONT_VTYPE].size, (BYTE **) &locked_buffer, 0);
array[new_id].used_this_frame = true;
// We can always bail out at this point
if(FAILED(hr)) {
Assert(0);
new_id = -1;
}
}
int char_count = 0;
while (*s) {
x += spacing;
while (*s== '\n' ) {
s++;
y += Current_font->h;
// centered
x =(sx==0x8000) ? get_centered_x(s) : sx;
}
if (*s == 0 ) break;
int letter = get_char_width(s[0],s[1],&width,&spacing);
s++;
//not in font, draw as space
if (letter<0) {
continue;
}
int xd, yd, xc, yc;
int wc, hc;
// Check if this character is totally clipped
if ( x + width < gr_screen.clip_left ) continue;
if ( y + Current_font->h < gr_screen.clip_top ) continue;
if ( x > gr_screen.clip_right ) continue;
if ( y > gr_screen.clip_bottom ) continue;
xd = yd = 0;
if ( x < gr_screen.clip_left ) xd = gr_screen.clip_left - x;
if ( y < gr_screen.clip_top ) yd = gr_screen.clip_top - y;
xc = x+xd;
yc = y+yd;
wc = width - xd; hc = Current_font->h - yd;
if ( xc + wc > gr_screen.clip_right ) wc = gr_screen.clip_right - xc;
if ( yc + hc > gr_screen.clip_bottom ) hc = gr_screen.clip_bottom - yc;
if ( wc < 1 ) continue;
if ( hc < 1 ) continue;
font_char *ch;
ch = &Current_font->char_data[letter];
int u = Current_font->bm_u[letter];
int v = Current_font->bm_v[letter];
if ( wc < 1 ) continue;
if ( hc < 1 ) continue;
FONT_VERTEX *src_v = NULL;
if(new_id != -1) {
src_v = &locked_buffer[char_count * 6];
} else {
src_v = &d3d_verts[char_count * 6];
}
#if 0
// Change the color this way to see which strings are being cached
uint color2 = (new_id == -1) ? color : 0xff00ff00;
// Marks the end of a batch blue
if(char_count > (MAX_STRING_LEN - 10))
color2 = 0xff0000ff;
#endif
d3d_stuff_char(src_v, xc, yc, wc, hc, u+xd, v+yd, bw, bh, u_scale, v_scale, color);
char_count++;
if(char_count >= MAX_STRING_LEN) {
// We've run out of space, we are going to have to go round again
break;
}
}
if(new_id != -1) {
vbuffer->Unlock();
if(char_count == 0) {
array[new_id].free_slot = true;
array[new_id].used_this_frame = false;
continue;
}
hr = d3d_SetVertexShader(FONT_VTYPE);
Assert(SUCCEEDED(hr));
hr = GlobalD3DVars::lpD3DDevice->SetStreamSource(0, vbuffer, vertex_types[FONT_VTYPE].size);
Assert(SUCCEEDED(hr));
hr = GlobalD3DVars::lpD3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, char_count * 2);
// Assert(SUCCEEDED(hr));
// Fill in details
array[new_id].char_count = char_count;
array[new_id].color = color;
array[new_id].free_slot = false;
array[new_id].len = len;
array[new_id].magic_number = magic_num;
array[new_id].magic_number2 = magic_num2;
array[new_id].x = sx;
array[new_id].y = sy;
array[new_id].offsetx = gr_screen.offset_x;
array[new_id].offsety = gr_screen.offset_y;
array[new_id].used_this_frame = true;
} else if(char_count > 0) {
d3d_DrawPrimitive(FONT_VTYPE, D3DPT_TRIANGLELIST,(LPVOID)d3d_verts, char_count * 6);
}
} while (*s);
}
|
[
"[email protected]"
] |
[
[
[
1,
859
]
]
] |
c0ba9ab179e9462204d0a3184f85391b9168dc33
|
814b49df11675ac3664ac0198048961b5306e1c5
|
/Code/Engine/Graphics/include/SingleRenderTarget.h
|
f781cfb19c4fd79b0dd8d44487ef7953de9407fe
|
[] |
no_license
|
Atridas/biogame
|
f6cb24d0c0b208316990e5bb0b52ef3fb8e83042
|
3b8e95b215da4d51ab856b4701c12e077cbd2587
|
refs/heads/master
| 2021-01-13T00:55:50.502395 | 2011-10-31T12:58:53 | 2011-10-31T12:58:53 | 43,897,729 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 634 |
h
|
#pragma once
#ifndef __SINGLE_RENDER_TARGET_H__
#define __SINGLE_RENDER_TARGET_H__
#include "RenderTarget.h"
#include <d3dx9.h>
class CXMLTreeNode;
class CSingleRenderTarget :
public CRenderTarget
{
public:
CSingleRenderTarget() : m_pSurface(0) {};
virtual ~CSingleRenderTarget() {Done();};
void Activate(CRenderManager* l_pRM);
virtual void Activate(CRenderManager* l_pRM, int _iIndex);
virtual void Deactivate(CRenderManager* l_pRM) {};
LPDIRECT3DSURFACE9 GetSurface() const { return m_pSurface; };
protected:
virtual void Release();
LPDIRECT3DSURFACE9 m_pSurface;
};
#endif
|
[
"sergivalls@576ee6d0-068d-96d9-bff2-16229cd70485",
"Atridas87@576ee6d0-068d-96d9-bff2-16229cd70485"
] |
[
[
[
1,
18
],
[
20,
20
],
[
23,
31
]
],
[
[
19,
19
],
[
21,
22
]
]
] |
07867bd210b1fabe416026e39263a05cbb1da39c
|
e92a0b984f0798ef2bba9ad4199b431b4f5eb946
|
/2010/software/pc/webcam_utils.hpp
|
9441a0a54000fda0d492e30cecb6f9dc4f234904
|
[] |
no_license
|
AdamdbUT/mac-gyver
|
c09c1892080bf77c25cb4ca2a7ebaf7be3459032
|
32de5c0989710ccd671d46e0babb602e51bf8ff9
|
refs/heads/master
| 2021-01-23T15:53:19.383860 | 2010-06-21T13:33:38 | 2010-06-21T13:33:38 | 42,737,082 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 269 |
hpp
|
#ifndef __webcam_utils__
#define __webcam_utils__
#include "webcam_common.hpp"
bool init_utils();
void deinit_utils();
bool save_image(const image_t& img,const std::string& name);
bool load_image(image_t& img,const std::string& name);
#endif // __utils__
|
[
"[email protected]",
"[email protected]"
] |
[
[
[
1,
2
],
[
4,
4
]
],
[
[
3,
3
],
[
5,
11
]
]
] |
8b24cd9e43636ad6f7e52a3692d27872da1e2e84
|
a0bc9908be9d42d58af7a1a8f8398c2f7dcfa561
|
/SlonEngine/slon/Utility/Algorithm/aabb_tree.hpp
|
c9b21cd311627a1abdb0dc53b001c0f042afc5df
|
[] |
no_license
|
BackupTheBerlios/slon
|
e0ca1137a84e8415798b5323bc7fd8f71fe1a9c6
|
dc10b00c8499b5b3966492e3d2260fa658fee2f3
|
refs/heads/master
| 2016-08-05T09:45:23.467442 | 2011-10-28T16:19:31 | 2011-10-28T16:19:31 | 39,895,039 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 16,537 |
hpp
|
#ifndef SLON_ENGINE_UTILITY_ALGORITHM_AABB_TREE_HPP
#define SLON_ENGINE_UTILITY_ALGORITHM_AABB_TREE_HPP
#include "../if_then_else.hpp"
#include "../math.hpp"
#include "../Memory/object_in_pool.hpp"
#include "spatial_node.hpp"
#include <boost/iterator/iterator_facade.hpp>
#include <boost/type_traits/is_const.hpp>
#include <functional>
#include <queue>
#include <sgl/Math/AABB.hpp>
#include <sgl/Math/Intersection.hpp>
namespace slon {
template<typename LeafData, typename RealType = float>
class aabb_tree
{
public:
typedef math::Matrix<RealType, 3, 1> vec3_type;
typedef math::AABB<RealType, 3> aabb_type;
class leaf_node;
class volume_node;
class volume_node :
public object_in_pool<volume_node>
{
friend class aabb_tree;
public:
explicit volume_node(const aabb_type& _volume) :
volume(_volume),
parent(0)
{
childs[0] = 0;
childs[1] = 0;
}
bool is_leaf() const { return childs[1] == 0; }
bool is_internal() const { return childs[1] != 0; }
/** Get index of the child */
int indexof(const volume_node* child)
{
assert(child && child->parent == this);
return int(child == childs[1]);
}
/** Get bound of the volume */
const aabb_type& get_bounds() const { return volume; }
/** Get child node */
volume_node* get_child(int i) { return childs[i]; }
/** Get child node */
const volume_node* get_child(int i) const { return childs[i]; }
/** Get parent node */
volume_node* get_parent() { return parent; }
/** Get parent node */
const volume_node* get_parent() const { return parent; }
/** setup volume node as child of this node */
void set_child(int i, volume_node* child)
{
childs[i] = child;
child->parent = this;
}
/** Try to convert to leaf node */
leaf_node* as_leaf() { return is_leaf() ? static_cast<leaf_node*>(this) : 0; }
/** Try to convert to leaf node */
const leaf_node* as_leaf() const { return is_leaf() ? static_cast<const leaf_node*>(this) : 0; }
/** Destroy node */
void destroy()
{
if ( is_leaf() ) {
delete static_cast<leaf_node*>(this);
}
else {
delete this;
}
}
protected:
/// Use destroy instead
~volume_node() {}
private:
aabb_type volume;
volume_node* parent;
volume_node* childs[2];
};
class leaf_node :
public object_in_pool<leaf_node, volume_node>
{
public:
leaf_node( const aabb_type& _volume,
const LeafData& _data )
: object_in_pool<leaf_node, volume_node>(_volume)
, data(_data)
{
}
public:
LeafData data;
};
// DFS tree traverse iterator
template<typename T>
class iterator_impl :
public boost::iterator_facade<
iterator_impl<T>,
T,
boost::bidirectional_traversal_tag
>
{
private:
friend class aabb_tree;
friend class boost::iterator_core_access;
typedef typename if_then_else<boost::is_const<T>::value,
const volume_node,
volume_node>::type volume_node_type;
typedef typename if_then_else<boost::is_const<T>::value,
const leaf_node,
leaf_node>::type leaf_node_type;
private:
void increment()
{
assert(node);
// go up until we find nonvisited right child
volume_node_type* parent = node->get_parent();
while (parent && parent->get_child(1) == node)
{
node = parent;
parent = node->get_parent();
}
// go down, until leaf is reached
if (parent)
{
node = parent->get_child(1);
while (node) {
node = node->get_child(0);
}
}
}
void decrement()
{
assert(node);
// go up until we find nonvisited left child
volume_node_type* parent = node->get_parent();
while (parent && parent->get_child(0) == node)
{
node = parent;
parent = node->get_parent();
}
// go down, until leaf is reached
if (parent)
{
node = parent->get_child(0);
while (node) {
node = node->get_child(1);
}
}
}
bool equal(iterator_impl const& other) const
{
return node == other.node;
}
T& dereference() const
{
assert(node);
return get_node()->data;
}
public:
/// construct end iterator
iterator_impl() {}
explicit iterator_impl(volume_node_type* node_)
: node(node_)
{
assert(node);
while ( node->is_internal() ) {
node = node->get_child(0);
}
}
explicit iterator_impl(leaf_node_type* node_)
: node(node_)
{
assert(node);
}
operator bool () const { return (node != 0); }
leaf_node_type* get_node() const { return static_cast<leaf_node_type*>(node); }
private:
volume_node_type* node;
};
typedef iterator_impl<LeafData> iterator;
typedef iterator_impl<const LeafData> const_iterator;
public:
aabb_tree();
~aabb_tree();
/** Get bounding box of the aabb_tree */
const math::AABBf& get_bounds() const
{
if (root) {
return root->get_bounds();
}
return bounds<aabb_type>::inv_infinite();
}
/** Check wether tree is empty */
bool empty() const { return root == 0; }
/** Use manually constructed tree */
void set_root(volume_node* root_) { root = root_; }
/** Get root AABB node of the tree*/
volume_node* get_root() { return root; }
/** Get root AABB node of the tree*/
const volume_node* get_root() const { return root; }
/** Get begin iterator */
iterator begin() { return iterator(root); }
/** Get begin iterator */
const_iterator begin() const { return const_iterator(root); }
/** Get end iterator */
iterator end() { return iterator(); }
/** Get end iterator */
const_iterator end() const { return const_iterator(); }
/** Insert new element in the tree.
* @param volume - axis aligned bounding box of the element.
* @param leafData - data to store in the leaf.
* @return inserted node.
*/
iterator insert(const aabb_type& volume, const LeafData& leafData);
/** Insert new element in the tree at specified location.
* @param parent - parent AABB node for the item. Should be internal node.
* @param volume - axis aligned bounding box of the element.
* @param leafData - data to store in the leaf.
* @param asLeft - true if you wish to insert node as left child, otherwise false.
* @return inserted node.
*/
iterator insert(volume_node& parent, const aabb_type& volume, const LeafData& leafData, bool asLeft = false);
/** Remove node from the tree. */
void remove(iterator iter);
/** Update AABB of the node.
* @param iter - iterator pointing node to update.
* @param volume - new volume.
* @return iterator pointing new node position.
*/
iterator update(iterator iter, const aabb_type& volume);
/** Remove all nodes from aabb_tree */
void clear();
private:
// update bouding hierarchy from node to root
void relax(volume_node* node);
// insert leaf node in the tree
void insert_leaf(volume_node* root, leaf_node* leaf);
// remove leaf node from the tree
void remove_leaf(volume_node* root, leaf_node* leaf);
// Manhattan distance
RealType proximity(const aabb_type& a, const aabb_type& b)
{
const typename aabb_type::vec_type d = (a.minVec + a.maxVec) - (b.minVec + b.maxVec); // vector between centers
return abs(d.x) + abs(d.y) + abs(d.z);
}
// select closest node from the childs
volume_node* select_closest(const volume_node* v, volume_node* a, volume_node* b)
{
return proximity(v->volume, a->volume) < proximity(v->volume, b->volume) ? a : b;
}
private:
volume_node* root;
};
template<typename LeafData, typename RealType>
aabb_tree<LeafData, RealType>::aabb_tree() :
root(0)
{
}
template<typename LeafData, typename RealType>
aabb_tree<LeafData, RealType>::~aabb_tree()
{
clear();
}
template<typename LeafData, typename RealType>
void aabb_tree<LeafData, RealType>::relax(volume_node* node)
{
assert(node);
// extend hierarchy nodes if needed
volume_node* prev = node->parent;
while ( prev != 0 && !contains(prev->volume, node->volume) )
{
prev->volume = math::merge(prev->childs[0]->volume, prev->childs[1]->volume);
prev = prev->parent;
}
}
template<typename LeafData, typename RealType>
void aabb_tree<LeafData, RealType>::insert_leaf(volume_node* root, leaf_node* leaf)
{
if (!root) {
this->root = leaf;
}
else
{
while ( !root->is_leaf() ) {
root = select_closest(leaf, root->childs[0], root->childs[1]);
}
// insert new child
volume_node* prev = root->parent;
volume_node* node = new volume_node(math::merge(leaf->volume, root->volume));
if (prev)
{
prev->set_child(prev->indexof(root), node);
node->set_child(0, root);
node->set_child(1, leaf);
relax(node);
}
else
{
node->set_child(0, root);
node->set_child(1, leaf);
this->root = node;
}
}
}
template<typename LeafData, typename RealType>
void aabb_tree<LeafData, RealType>::remove_leaf(volume_node* parent, leaf_node* leaf)
{
if (leaf == root) {
this->root = 0;
}
else
{
volume_node* parent = leaf->parent;
volume_node* prev = parent->parent;
volume_node* sibling = parent->childs[1 - parent->indexof(leaf)];
if (prev)
{
prev->childs[prev->indexof(parent)] = sibling;
sibling->parent = prev;
delete parent;
while (prev)
{
const aabb_type& prevVolume = prev->volume;
prev->volume = math::merge(prev->childs[0]->volume, prev->childs[1]->volume);
if (prevVolume != prev->volume) {
prev = prev->parent;
}
else {
break;
}
}
}
else
{
this->root = sibling;
sibling->parent = 0;
delete parent;
}
}
}
template<typename LeafData, typename RealType>
typename aabb_tree<LeafData, RealType>::iterator aabb_tree<LeafData, RealType>::insert(const aabb_type& volume, const LeafData& leafData)
{
leaf_node* leaf = new leaf_node(volume, leafData);
insert_leaf(root, leaf);
return iterator(leaf);
}
template<typename LeafData, typename RealType>
typename aabb_tree<LeafData, RealType>::iterator aabb_tree<LeafData, RealType>::insert(volume_node& parent, const aabb_type& volume, const LeafData& leafData, bool asLeft)
{
assert( parent.is_internal() );
int childId = asLeft ? 0 : 1;
int otherId = asLeft ? 1 : 0;
volume_node* leaf = new leaf_node(volume, leafData);
volume_node* other = new volume_node(math::merge(parent->childs[0]->volume, parent->childs[1]->volume), &parent);
other->set_child(0, parent->childs[0]);
other->set_child(1, parent->childs[1]);
parent->set_child(childId, leaf);
parent->set_child(otherId, other);
relax(leaf);
return iterator(leaf);
}
template<typename LeafData, typename RealType>
void aabb_tree<LeafData, RealType>::remove(iterator iter)
{
leaf_node* node = iter.get_node();
assert(node);
remove_leaf(root, node);
node->destroy();
}
template<typename LeafData, typename RealType>
typename aabb_tree<LeafData, RealType>::iterator aabb_tree<LeafData, RealType>::update(iterator iter, const aabb_type& volume)
{
leaf_node* leaf = iter.get_node();
remove_leaf(root, leaf);
leaf->volume = volume;
insert_leaf(root, leaf);
return iterator(leaf);
}
template<typename LeafData, typename RealType>
void aabb_tree<LeafData, RealType>::clear()
{
if (root)
{
std::queue<volume_node*> queue;
queue.push(root);
while ( !queue.empty() )
{
volume_node* node = queue.front();
queue.pop();
if ( node->is_internal() )
{
queue.push( node->childs[0] );
queue.push( node->childs[1] );
}
delete node;
}
root = 0;
}
}
/** Perform function on leafe nodes.
* @param tree - tree for gathering elements.
* @param functor - perform functor(visitor). Return true to stop traverse.
*/
template< typename LeafData,
typename RealType,
typename Functor >
void perform_on_leaves( const aabb_tree<LeafData, RealType>& tree,
Functor functor )
{
typedef typename aabb_tree<LeafData, RealType>::volume_node volume_node;
typedef typename aabb_tree<LeafData, RealType>::leaf_node leaf_node;
const volume_node* root = tree.get_root();
if (root)
{
std::queue<const volume_node*> queue;
queue.push(root);
while ( !queue.empty() )
{
root = queue.front();
queue.pop();
if ( root->is_internal() )
{
queue.push( root->get_child(0) );
queue.push( root->get_child(1) );
}
else
{
if ( functor(static_cast<const leaf_node*>(root)->data) ) {
return;
}
}
}
}
}
/** Perform function on elements intersecting specified volume.
* @tparam Volume - type of the volume body(AABB, Frustum, etc.).
* @param tree - tree for gathering elements.
* @param volume - volume for gathering.
* @param functor - perform functor(visitor). Return true to stop traverse.
*/
template< typename LeafData,
typename RealType,
typename Functor,
typename Volume >
void perform_on_leaves( const aabb_tree<LeafData, RealType>& tree,
const Volume& volume,
Functor functor )
{
typedef typename aabb_tree<LeafData, RealType>::volume_node volume_node;
typedef typename aabb_tree<LeafData, RealType>::leaf_node leaf_node;
const volume_node* root = tree.get_root();
if ( root && math::test_intersection( volume, root->get_bounds() ) )
{
std::queue<const volume_node*> queue;
queue.push(root);
while ( !queue.empty() )
{
root = queue.front();
queue.pop();
if ( root->is_internal() )
{
if ( math::test_intersection( volume, root->get_child(0)->get_bounds() ) ) {
queue.push( root->get_child(0) );
}
if ( math::test_intersection( volume, root->get_child(1)->get_bounds() ) ) {
queue.push( root->get_child(1) );
}
}
else
{
if ( functor(static_cast<const leaf_node*>(root)->data) ) {
return;
}
}
}
}
}
} // namespace slon
#endif // SLON_ENGINE_UTILITY_ALGORITHM_AABB_TREE_HPP
|
[
"devnull@localhost"
] |
[
[
[
1,
570
]
]
] |
a49fd857dba9afce6b005e10147236facb1414ff
|
1349e3a4a73c98015476c92ba60f7f9cb15711b5
|
/convert_yv12.cpp
|
4b8b96ef0506e7c61e584ba78fe9427f6f9d6589
|
[] |
no_license
|
ejensen/yeti-codec
|
7d9492c09e50c0df8d9ff88a14753eb30b1b1560
|
c449e7cf37b874cc852e34c5ced83ef018179dd5
|
refs/heads/master
| 2021-03-16T10:23:59.355910 | 2011-06-07T04:46:25 | 2011-06-07T04:46:25 | 5,473,208 | 2 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 13,157 |
cpp
|
// Avisynth v2.5. Copyright 2002 Ben Rudiak-Gould et al.
// http://www.avisynth.org
// 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.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit
// http://www.gnu.org/copyleft/gpl.html .
//
// Linking Avisynth statically or dynamically with other modules is making a
// combined work based on Avisynth. Thus, the terms and conditions of the GNU
// General Public License cover the whole combination.
//
// As a special exception, the copyright holders of Avisynth give you
// permission to link Avisynth with independent modules that communicate with
// Avisynth solely through the interfaces defined in avisynth.h, regardless of the license
// terms of these independent modules, and to copy and distribute the
// resulting combined work under terms of your choice, provided that
// every copy of the combined work is accompanied by a complete copy of
// the source code of Avisynth (the version of Avisynth used to produce the
// combined work), being distributed under the terms of the GNU General
// Public License plus this exception. An independent module is a module
// which is not derived from or based on Avisynth, such as 3rd-party filters,
// import and export plugins, or graphical user interfaces.
#include "convert_yv12.h"
/*************************************
* Progressive YV12 -> YUY2 conversion
*
* (c) 2003, Klaus Post.
*
* Requires mod 8 pitch.
*************************************/
void isse_yv12_to_yuy2(const BYTE* srcY, const BYTE* srcU, const BYTE* srcV, int src_rowsize, int src_pitch, int src_pitch_uv,
BYTE* dst, int dst_pitch,
int height) {
unsigned int ebx_backup=0;
__asm mov ebx_backup,ebx;
__declspec(align(8)) static const __int64 add_ones=0x0101010101010101;
const BYTE** srcp= new const BYTE*[3];
int src_pitch_uv2 = src_pitch_uv * 2;
// int src_pitch_uv4 = src_pitch_uv*4;
//int skipnext = 0;
int dst_pitch2=dst_pitch * 2;
int src_pitch2 = src_pitch * 2;
/**** Do first and last lines - NO interpolation: *****/
// MMX loop relies on C-code to adjust the lines for it.
const BYTE* _srcY=srcY;
const BYTE* _srcU=srcU;
const BYTE* _srcV=srcV;
BYTE* _dst=dst;
for (int i=0;i<4;i++) {
switch (i) {
case 1:
_srcY+=src_pitch; // Same chroma as in 0
_dst+=dst_pitch;
break;
case 2:
_srcY=srcY+(src_pitch*(height-2));
_srcU=srcU+(src_pitch_uv*((height>>1)-1));
_srcV=srcV+(src_pitch_uv*((height>>1)-1));
_dst = dst+(dst_pitch*(height-2));
break;
case 3: // Same chroma as in 4
_srcY += src_pitch;
_dst += dst_pitch;
break;
default: // Nothing, case 0
break;
}
__asm {
mov edi, [_dst]
mov eax, [_srcY]
mov ebx, [_srcU]
mov ecx, [_srcV]
mov edx,0
pxor mm7,mm7
jmp xloop_test_p
xloop_p:
movq mm0,[eax] //Y
movd mm1,[ebx] //U
movq mm3,mm0
movd mm2,[ecx] //V
punpcklbw mm0,mm7 // Y low
punpckhbw mm3,mm7 // Y high
punpcklbw mm1,mm7 // 00uu 00uu
punpcklbw mm2,mm7 // 00vv 00vv
movq mm4,mm1
movq mm5,mm2
punpcklbw mm1,mm7 // 0000 00uu low
punpcklbw mm2,mm7 // 0000 00vv low
punpckhbw mm4,mm7 // 0000 00uu high
punpckhbw mm5,mm7 // 0000 00vv high
pslld mm1,8
pslld mm4,8
pslld mm2,24
pslld mm5,24
por mm0, mm1
por mm3, mm4
por mm0, mm2
por mm3, mm5
movq [edi],mm0
movq [edi+8],mm3
add eax,8
add ebx,4
add ecx,4
add edx,8
add edi, 16
xloop_test_p:
cmp edx,[src_rowsize]
jl xloop_p
}
}
/****************************************
* Conversion main loop.
* The code properly interpolates UV from
* interlaced material.
* We process two lines in the same field
* in the same loop, to avoid reloading
* chroma each time.
*****************************************/
height-=4;
dst+=dst_pitch2;
srcY+=src_pitch2;
srcU+=src_pitch_uv;
srcV+=src_pitch_uv;
srcp[0] = srcY;
srcp[1] = srcU-src_pitch_uv;
srcp[2] = srcV-src_pitch_uv;
int y=0;
int x=0;
__asm {
mov esi, [srcp]
mov edi, [dst]
mov eax,[esi]
mov ebx,[esi+4]
mov ecx,[esi+8]
mov edx,0
jmp yloop_test
align 16
yloop:
mov edx,0 // x counter
jmp xloop_test
align 16
xloop:
movq mm6,[add_ones]
mov edx, src_pitch_uv
movq mm0,[eax] // mm0 = Y current line
pxor mm7,mm7
movd mm2,[ebx+edx] // mm2 = U top field
movd mm3, [ecx+edx] // mm3 = V top field
movd mm4,[ebx] // U prev top field
movq mm1,mm0 // mm1 = Y current line
movd mm5,[ecx] // V prev top field
pavgb mm4,mm2 // interpolate chroma U (25/75)
pavgb mm5,mm3 // interpolate chroma V (25/75)
psubusb mm4, mm6 // Better rounding (thanks trbarry!)
psubusb mm5, mm6
pavgb mm4,mm2 // interpolate chroma U
pavgb mm5,mm3 // interpolate chroma V
punpcklbw mm0,mm7 // Y low
punpckhbw mm1,mm7 // Y high*
punpcklbw mm4,mm7 // U 00uu 00uu 00uu 00uu
punpcklbw mm5,mm7 // V 00vv 00vv 00vv 00vv
pxor mm6,mm6
punpcklbw mm6,mm4 // U 0000 uu00 0000 uu00 (low)
punpckhbw mm7,mm4 // V 0000 uu00 0000 uu00 (high
por mm0,mm6
por mm1,mm7
movq mm6,mm5
punpcklbw mm5,mm5 // V 0000 vvvv 0000 vvvv (low)
punpckhbw mm6,mm6 // V 0000 vvvv 0000 vvvv (high)
pslld mm5,24
pslld mm6,24
por mm0,mm5
por mm1,mm6
mov edx, src_pitch_uv2
movq [edi],mm0
movq [edi+8],mm1
//Next line
movq mm6,[add_ones]
movd mm4,[ebx+edx] // U next top field
movd mm5,[ecx+edx] // V prev top field
mov edx, [src_pitch]
pxor mm7,mm7
movq mm0,[eax+edx] // Next U-line
pavgb mm4,mm2 // interpolate chroma U
movq mm1,mm0 // mm1 = Y current line
pavgb mm5,mm3 // interpolate chroma V
psubusb mm4, mm6 // Better rounding (thanks trbarry!)
psubusb mm5, mm6
pavgb mm4,mm2 // interpolate chroma U
pavgb mm5,mm3 // interpolate chroma V
punpcklbw mm0,mm7 // Y low
punpckhbw mm1,mm7 // Y high*
punpcklbw mm4,mm7 // U 00uu 00uu 00uu 00uu
punpcklbw mm5,mm7 // V 00vv 00vv 00vv 00vv
pxor mm6,mm6
punpcklbw mm6,mm4 // U 0000 uu00 0000 uu00 (low)
punpckhbw mm7,mm4 // V 0000 uu00 0000 uu00 (high
por mm0,mm6
por mm1,mm7
movq mm6,mm5
punpcklbw mm5,mm5 // V 0000 vvvv 0000 vvvv (low)
punpckhbw mm6,mm6 // V 0000 vvvv 0000 vvvv (high)
pslld mm5,24
mov edx,[dst_pitch]
pslld mm6,24
por mm0,mm5
por mm1,mm6
movq [edi+edx],mm0
movq [edi+edx+8],mm1
add edi,16
mov edx, [x]
add eax, 8
add ebx, 4
add edx, 8
add ecx, 4
xloop_test:
cmp edx,[src_rowsize]
mov x,edx
jl xloop
mov edi, dst
mov eax,[esi]
mov ebx,[esi+4]
mov ecx,[esi+8]
add edi,[dst_pitch2]
add eax,[src_pitch2]
add ebx,[src_pitch_uv]
add ecx,[src_pitch_uv]
mov edx, [y]
mov [esi],eax
mov [esi+4],ebx
mov [esi+8],ecx
mov [dst],edi
add edx, 2
yloop_test:
cmp edx,[height]
mov [y],edx
jl yloop
sfence
emms
}
delete[] srcp;
__asm mov ebx,ebx_backup
}
/********************************
* Progressive YUY2 to YV12
*
* (c) Copyright 2003, Klaus Post
*
* Converts 8x2 (8 pixels, two lines) in parallel.
* Requires mod8 pitch for output, and mod16 pitch for input.
********************************/
void isse_yuy2_to_yv12(const BYTE* src, int src_rowsize, int src_pitch,
BYTE* dstY, BYTE* dstU, BYTE* dstV, int dst_pitchY, int dst_pitchUV,
int height) {
unsigned int ebx_backup=0;
__asm mov ebx_backup,ebx
__declspec(align(8)) static __int64 mask1 = 0x00ff00ff00ff00ff;
__declspec(align(8)) static __int64 mask2 = 0xff00ff00ff00ff00;
const BYTE* dstp[4];
dstp[0]=dstY;
dstp[1]=dstY+dst_pitchY;
dstp[2]=dstU;
dstp[3]=dstV;
int src_pitch2 = src_pitch * 2;
int dst_pitch2 = dst_pitchY * 2;
int y=0;
//int x=0;
src_rowsize = (src_rowsize+3) / 4;
__asm {
movq mm7,[mask2]
movq mm4,[mask1]
mov edx,0
mov esi, src
lea edi, dstp
jmp yloop_test
align 16
yloop:
mov edx,0 // x counter
mov eax, [src_pitch]
jmp xloop_test
align 16
xloop:
movq mm0,[esi] // YUY2 upper line (4 pixels luma, 2 chroma)
movq mm1,[esi+eax] // YUY2 lower line
movq mm6,mm0
movq mm2, [esi+8] // Load second pair
movq mm3, [esi+eax+8]
movq mm5,mm2
pavgb mm6,mm1 // Average (chroma)
pavgb mm5,mm3 // Average Chroma (second pair)
pand mm0,mm4 // Mask luma
psrlq mm5, 8
pand mm1,mm4 // Mask luma
psrlq mm6, 8
pand mm2,mm4 // Mask luma
pand mm3,mm4
pand mm5,mm4 // Mask chroma
pand mm6,mm4 // Mask chroma
packuswb mm0, mm2 // Pack luma (upper)
packuswb mm6, mm5 // Pack chroma
packuswb mm1, mm3 // Pack luma (lower)
movq mm5, mm6 // Chroma copy
pand mm5, mm7 // Mask V
pand mm6, mm4 // Mask U
psrlq mm5,8 // shift down V
packuswb mm5, mm7 // Pack U
packuswb mm6, mm7 // Pack V
mov ebx, [edi]
mov ecx, [edi+4]
movq [ebx+edx*2],mm0
movq [ecx+edx*2],mm1
mov ecx, [edi+8]
mov ebx, [edi+12]
movd [ecx+edx], mm6 // Store U
movd [ebx+edx], mm5 // Store V
add esi, 16
add edx, 4
xloop_test:
cmp edx,[src_rowsize]
jl xloop
mov esi, src
mov edx,[edi]
mov ebx,[edi+4]
mov ecx,[edi+8]
mov eax,[edi+12]
add edx, [dst_pitch2]
add ebx, [dst_pitch2]
add ecx, [dst_pitchUV]
add eax, [dst_pitchUV]
add esi, [src_pitch2]
mov [edi],edx
mov [edi+4],ebx
mov [edi+8],ecx
mov [edi+12],eax
mov edx, [y]
mov [src],esi
add edx, 2
yloop_test:
cmp edx,[height]
mov [y],edx
jl yloop
sfence
emms
}
__asm mov ebx,ebx_backup
}
|
[
"[email protected]"
] |
[
[
[
1,
393
]
]
] |
8ecfb0d2d1f5070db9ec8a6ff01ea376aa6eb38a
|
f02d9d86fb32f26a1f2615be8240539cac92f9c2
|
/Streaming.h
|
c7cde0efe780c485fe6883f3faeba34a961528ef
|
[] |
no_license
|
MarSik/MarSclock
|
30cc546c5cba98c3d28eaf348de50004e6b6f066
|
4df639a1b3cd19e75ae9ef599bdab0841e64ce8d
|
refs/heads/master
| 2020-12-24T14:36:59.876220 | 2011-02-22T22:21:57 | 2011-02-22T22:21:57 | 1,200,961 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 2,474 |
h
|
/*
Streaming.h - Arduino library for supporting the << streaming operator
Copyright (c) 2010 Mikal Hart. All rights reserved.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef ARDUINO_STREAMING
#define ARDUINO_STREAMING
#include <WProgram.h>
#define STREAMING_LIBRARY_VERSION 4
// Generic template
template<class T>
inline Print &operator <<(Print &stream, T arg)
{ stream.print(arg); return stream; }
struct _BASED
{
long val;
int base;
_BASED(long v, int b): val(v), base(b)
{}
};
#define _HEX(a) _BASED(a, HEX)
#define _DEC(a) _BASED(a, DEC)
#define _OCT(a) _BASED(a, OCT)
#define _BIN(a) _BASED(a, BIN)
#define _BYTE(a) _BASED(a, BYTE)
// Specialization for class _BASED
// Thanks to Arduino forum user Ben Combee who suggested this
// clever technique to allow for expressions like
// Serial << _HEX(a);
inline Print &operator <<(Print &obj, const _BASED &arg)
{ obj.print(arg.val, arg.base); return obj; }
#if ARDUINO >= 18
// Specialization for class _FLOAT
// Thanks to Michael Margolis for suggesting a way
// to accommodate Arduino 0018's floating point precision
// feature like this:
// Serial << _FLOAT(gps_latitude, 6); // 6 digits of precision
struct _FLOAT
{
float val;
int digits;
_FLOAT(double v, int d): val(v), digits(d)
{}
};
inline Print &operator <<(Print &obj, const _FLOAT &arg)
{ obj.print(arg.val, arg.digits); return obj; }
#endif
// Specialization for enum _EndLineCode
// Thanks to Arduino forum user Paul V. who suggested this
// clever technique to allow for expressions like
// Serial << "Hello!" << endl;
enum _EndLineCode { endl };
inline Print &operator <<(Print &obj, _EndLineCode arg)
{ obj.println(); return obj; }
#endif
|
[
"[email protected]"
] |
[
[
[
1,
84
]
]
] |
001f432e0fcb7bc93a126881a9cd1dcb9ad4c437
|
f7275659680b07fbb9fb1647f0f26cc029565939
|
/wxalarmApp.h
|
b41087dec5931de3d8e041c325bd782e014202e8
|
[] |
no_license
|
rexzhang/wxalarm
|
f564fcf019c8e9c9c1a0d75b4c1dae24113ad1c5
|
435d244e0382c10f38d1675c0699a7d7acc4bc7a
|
refs/heads/master
| 2016-09-06T10:37:59.614623 | 2008-08-31T14:38:43 | 2008-08-31T14:38:43 | 32,366,981 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 684 |
h
|
/***************************************************************
* Name: wxalarmApp.h
* Purpose: Defines Application Class
* Author: Rex Zhang ([email protected])
* Created: 2007-11-01
* Copyright: Rex Zhang (http://code.google.com/p/wxalarm/)
* License:
**************************************************************/
#ifndef WXALARMAPP_H
#define WXALARMAPP_H
#include <wx/app.h>
#include <wx/taskbar.h>
#include "myWxTary.h"
class wxalarmApp : public wxApp
{
public:
virtual bool OnInit();
//wxTaskBarIcon* myTary;
//static
myWxTary* myTary;
~wxalarmApp();
};
#endif // WXALARMAPP_H
|
[
"rex.zhang@cce68e7b-343c-0410-bfd2-9b215a1710d6"
] |
[
[
[
1,
29
]
]
] |
25d5bcc2badc84cb7fc5d790ee5657831e065f60
|
ef23e388061a637f82b815d32f7af8cb60c5bb1f
|
/src/mame/includes/exprraid.h
|
a7055bad2d28f7bd55a4c9f8e3bc098fd24c6bbc
|
[] |
no_license
|
marcellodash/psmame
|
76fd877a210d50d34f23e50d338e65a17deff066
|
09f52313bd3b06311b910ed67a0e7c70c2dd2535
|
refs/heads/master
| 2021-05-29T23:57:23.333706 | 2011-06-23T20:11:22 | 2011-06-23T20:11:22 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,253 |
h
|
/*************************************************************************
Express Raider
*************************************************************************/
class exprraid_state : public driver_device
{
public:
exprraid_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
/* memory pointers */
UINT8 * m_main_ram;
UINT8 * m_videoram;
UINT8 * m_colorram;
UINT8 * m_spriteram;
size_t m_spriteram_size;
/* video-related */
tilemap_t *m_bg_tilemap;
tilemap_t *m_fg_tilemap;
int m_bg_index[4];
/* misc */
//int m_coin; // used in the commented out INTERRUPT_GEN - can this be removed?
/* devices */
device_t *m_maincpu;
device_t *m_slave;
};
/*----------- defined in video/exprraid.c -----------*/
extern WRITE8_HANDLER( exprraid_videoram_w );
extern WRITE8_HANDLER( exprraid_colorram_w );
extern WRITE8_HANDLER( exprraid_flipscreen_w );
extern WRITE8_HANDLER( exprraid_bgselect_w );
extern WRITE8_HANDLER( exprraid_scrollx_w );
extern WRITE8_HANDLER( exprraid_scrolly_w );
extern VIDEO_START( exprraid );
extern SCREEN_UPDATE( exprraid );
|
[
"Mike@localhost"
] |
[
[
[
1,
45
]
]
] |
5a0eb1378fad94ebcc5dc738321d7fee7e10b855
|
ee065463a247fda9a1927e978143186204fefa23
|
/Src/Engine/GameState/IFactory.h
|
35817f4c08d67f2aea6fee32acc8f7a337a4a237
|
[] |
no_license
|
ptrefall/hinsimviz
|
32e9a679170eda9e552d69db6578369a3065f863
|
9caaacd39bf04bbe13ee1288d8578ece7949518f
|
refs/heads/master
| 2021-01-22T09:03:52.503587 | 2010-09-26T17:29:20 | 2010-09-26T17:29:20 | 32,448,374 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 305 |
h
|
#pragma once
#include <ClanLib/core.h>
namespace Engine
{
namespace Core { class IManager; }
namespace GameState
{
class IGameState;
class IFactory
{
public:
IFactory(Core::IManager *coreMgr) {}
virtual ~IFactory() {}
virtual IGameState *create(const char *name) = 0;
};
}
}
|
[
"[email protected]@28a56cb3-1e7c-bc60-7718-65c159e1d2df"
] |
[
[
[
1,
22
]
]
] |
4ff9188e723f8e01b9169b5e7273fcf71743f296
|
f2b4a9d938244916aa4377d4d15e0e2a6f65a345
|
/Game/Artifacts.h
|
5dc8c4d7a659f7652ced7afc9215fc2d79907550
|
[
"Apache-2.0"
] |
permissive
|
notpushkin/palm-heroes
|
d4523798c813b6d1f872be2c88282161cb9bee0b
|
9313ea9a2948526eaed7a4d0c8ed2292a90a4966
|
refs/heads/master
| 2021-05-31T19:10:39.270939 | 2010-07-25T12:25:00 | 2010-07-25T12:25:00 | 62,046,865 | 2 | 1 | null | null | null | null |
UTF-8
|
C++
| false | false | 2,337 |
h
|
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
#ifndef _HMM_GAME_ARTIFACTS_H_
#define _HMM_GAME_ARTIFACTS_H_
/*
* Artifacts container
*/
struct iArtCell {
iArtCell(HERO_ART_CELL _cell, uint16 _artId = 0xFFFF) : cell(_cell), artId(_artId) {}
inline bool Empty() const { return artId == 0xFFFF;}
inline void Reset() { artId = 0xFFFF; }
ART_ASSIGN_TYPE AssignType();
HERO_ART_CELL cell;
uint16 artId;
};
typedef iSimpleArray<uint16> iArtList;
typedef iSimpleArray<iArtCell> iArtCellList;
//
class iArtCtr
{
public:
iArtCtr(iHero* pOwner);
//
uint16 Pop();
//
bool HasArtType(ART_TYPE artt) const;
bool CanAttach(uint16 artId) const;
void Push(uint16 artId);
bool CanSmartPush(uint16 artId) const;
void SmartPush(uint16 artId);
void PushDressed(uint16 artId, HERO_ART_CELL cell);
void PushToBackPack(uint16 artId);
uint16 Pop(bool bDressed, uint32 idx);
void PopBackPack(iArtList& artList);
void PopAll(iArtList& artList);
void GetAll(iArtList& artList) const;
// Backpack
inline uint32 BackPackCount() const { return m_BackPack.GetSize(); }
inline uint16 BackPackItem(uint32 idx) const { check(idx<m_BackPack.GetSize()); return m_BackPack[idx]; }
inline const iArtCell& DressedItem(HERO_ART_CELL cell) const { return m_Dressed[cell]; }
inline iArtCell& DressedItem(HERO_ART_CELL cell) { return m_Dressed[cell]; }
inline iArtList& BackPack() { return m_BackPack; }
uint32 TotalCount() const;
private:
iArtCellList m_Dressed;
iArtList m_BackPack;
iHero* m_pOwner;
};
#endif //_HMM_GAME_ARTIFACTS_H_
|
[
"palmheroesteam@2c21ad19-eed7-4c86-9350-8a7669309276"
] |
[
[
[
1,
77
]
]
] |
867492eb2c51707369e712851ee8e51cdf29ace4
|
b5e490bbfe04b051c5d7cdc40a5d866119d619b8
|
/Kompex-SQLite-Wrapper/inc/KompexSQLiteStatement.h
|
d5cd506146c5b8928cb27a21d772c07b4b6b7acb
|
[] |
no_license
|
pandabear41/animetracker
|
07a10acbeba40d02d28958f8c560938bd5275e61
|
7591bc021d73c1b66d7e2c15cbbfdba275faf1e8
|
refs/heads/master
| 2021-01-15T12:16:09.430378 | 2011-01-13T22:46:02 | 2011-01-13T22:46:02 | 1,247,216 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 24,725 |
h
|
/*
This file is part of Kompex SQLite Wrapper.
Copyright (c) 2008-2010 Sven Broeske
Kompex SQLite Wrapper 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 3 of the License, or
(at your option) any later version.
Kompex SQLite Wrapper 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 Kompex SQLite Wrapper. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KompexSQLiteStatement_H
#define KompexSQLiteStatement_H
#include <map>
#include <string>
#include "sqlite3.h"
#include "KompexSQLitePrerequisites.h"
namespace Kompex
{
#if defined(_MSC_VER) || defined(__BORLANDC__)
typedef __int64 int64;
typedef unsigned __int64 uint64;
#else
typedef long long int int64;
typedef unsigned long long int uint64;
#endif
class SQLiteDatabase;
class _SQLiteWrapperExport SQLiteStatement
{
public:
//! Constructor.\n
//! @param db Database in which the SQL should be performed
SQLiteStatement(SQLiteDatabase *db);
//! Destructor.
virtual ~SQLiteStatement();
//! Only for SQL statements, which have no result.
//! Can be used for transactions; if you want, you can use an own error handling.
//! @param sqlStatement SQL statement (UTF-8)
void SqlStatement(const std::string &sqlStatement);
//! Only for SQL statements, which have no result.
//! Can be used for transactions; if you want, you can use an own error handling.
//! @param sqlStatement SQL statement (UTF-8)
void SqlStatement(const char *sqlStatement);
//! Only for SQL statements, which have no result.
//! Can be used for transactions; if you want, you can use an own error handling.
//! @param sqlStatement SQL statement (UTF-16)
void SqlStatement(const wchar_t *sqlStatement);
//! Only for SQL queries/statements which have a result.\n
//! e.g. SELECT's or INSERT's which use Bind..() methods!
//! Do not forget to call FreeQuery() when you have finished.
inline void Sql(const std::string &sql) {Prepare(sql.c_str());}
//! Only for SQL queries/statements which have a result.\n
//! e.g. SELECT's or INSERT's which use Bind..() methods!
//! Do not forget to call FreeQuery() when you have finished.
inline void Sql(const wchar_t *sql) {Prepare(sql);}
//! Only for SQL queries/statements which have a result.\n
//! e.g. SELECT's or INSERT's which use Bind..() methods!
//! Do not forget to call FreeQuery() when you have finished.
inline void Sql(const char *sql) {Prepare(sql);}
//! If you have called Sql(), you can step throw all results.
bool FetchRow() const;
//! Call FreeQuery() after Sql() and FetchRow() to clean-up.
void FreeQuery();
//! Can be used for all SQLite aggregate functions.
//! Here you can see all available aggregate functions:
//! http://sqlite.org/lang_aggfunc.html
//! @param countSql Complete SQL query string (UTF-16).
float SqlAggregateFuncResult(const std::string &countSql);
//! Can be used for all SQLite aggregate functions.
//! Here you can see all available aggregate functions:
//! http://sqlite.org/lang_aggfunc.html
//! @param countSql Complete SQL query string (UTF-16).
float SqlAggregateFuncResult(wchar_t *countSql);
//! Can be used for all SQLite aggregate functions.
//! Here you can see all available aggregate functions:
//! http://sqlite.org/lang_aggfunc.html
//! @param countSql Complete SQL query string (UTF-16).
float SqlAggregateFuncResult(const char *countSql);
//! Returns the name (UTF-8) assigned to a particular column in the result set of a SELECT statement.\n
//! You must first call Sql()!
const char *GetColumnName(int column) const;
//! Returns the name (UTF-16) assigned to a particular column in the result set of a SELECT statement.\n
//! You must first call Sql()!
wchar_t *GetColumnName16(int column) const;
//! Returns the datatype code for the initial data type of the result column.\n
//! SQLITE_INTEGER 1\n
//! SQLITE_FLOAT 2\n
//! SQLITE_TEXT 3\n
//! SQLITE3_TEXT 3\n
//! SQLITE_BLOB 4\n
//! SQLITE_NULL 5\n
//! You must first call Sql()!
int GetColumnType(int column) const;
//! Returns a character-string from a single column of the current result row of a query.\n
//! You must first call Sql()!
const unsigned char *GetColumnCString(int column) const;
//! Returns a std::string from a single column of the current result row of a query.\n
//! You must first call Sql()!
std::string GetColumnString(int column) const;
//! Returns a UTF-16 string from a single column of the current result row of a query.\n
//! You must first call Sql()!
wchar_t *GetColumnString16(int column) const;
//! Returns a double from a single column of the current result row of a query.\n
//! You must first call Sql()!
double GetColumnDouble(int column) const;
//! Returns a int from a single column of the current result row of a query.\n
//! You must first call Sql()!
int GetColumnInt(int column) const;
//! Returns a int64 from a single column of the current result row of a query.\n
//! You must first call Sql()!
int64 GetColumnInt64(int column) const;
//! Returns a void* from a single column of the current result row of a query.\n
//! You must first call Sql()!
const void *GetColumnBlob(int column) const;
//! Return the number of columns in the result set.\n
//! You must first call Sql()!
int GetColumnCount() const;
//! Returns the number of bytes in a column that has type BLOB or the number of bytes in a TEXT string with UTF-8 encoding.\n
//! You must first call Sql()!
int GetColumnBytes(int column) const;
//! Returns the same value for BLOBs but for TEXT strings returns the number of bytes in a UTF-16 encoding.\n
//! You must first call Sql()!
int GetColumnBytes16(int column) const;
//! Returns a UTF-8 zero-terminated name of the database.\n
//! You must first call Sql()!
const char *GetColumnDatabaseName(int column) const;
//! Returns a UTF-16 zero-terminated name of the database.\n
//! You must first call Sql()!
wchar_t *GetColumnDatabaseName16(int column) const;
//! Returns a UTF-8 zero-terminated name of the table.\n
//! You must first call Sql()!
const char *GetColumnTableName(int column) const;
//! Returns a UTF-16 zero-terminated name of the table.\n
//! You must first call Sql()!
wchar_t *GetColumnTableName16(int column) const;
//! Returns a UTF-8 zero-terminated name of the table column.\n
//! You must first call Sql()!
const char *GetColumnOriginName(int column) const;
//! Returns a UTF-16 zero-terminated name of the table column.\n
//! You must first call Sql()!
wchar_t *GetColumnOriginName16(int column) const;
//! Returns a zero-terminated UTF-8 string containing the declared datatype of the table column.\n
//! You must first call Sql()!
const char *GetColumnDeclaredDatatype(int column) const;
//! Returns a zero-terminated UTF-16 string containing the declared datatype of the table column.\n
//! You must first call Sql()!
wchar_t *GetColumnDeclaredDatatype16(int column) const;
//! Returns the number of values in the current row of the result set.\n
//! You must first call Sql()!
inline int GetDataCount() const {return sqlite3_data_count(mStatement);}
//! Overrides prior binding on the same parameter with an int value.\n
//! You must call Sql() one time, before you can use Bind..() methods!
//! @param column Column, in which the data should be inserted
//! @param value int value which should inserted in the indicated column
void BindInt(int column, int value) const;
//! Overrides prior binding on the same parameter with an UTF-8 string.\n
//! You must call Sql() one time, before you can use Bind..() methods!
//! @param column Column, in which the data should be inserted
//! @param string UTF-8 string which should inserted in the indicated column
void BindString(int column, const std::string &string) const;
//! Overrides prior binding on the same parameter with an UTF-16 string.\n
//! You must call Sql() one time, before you can use Bind..() methods!
//! @param column Column, in which the data should be inserted
//! @param string UTF-16 string which should inserted in the indicated column
void BindString16(int column, const wchar_t *string) const;
//! Overrides prior binding on the same parameter with a double value.\n
//! You must call Sql() one time, before you can use Bind..() methods!
//! @param column Column, in which the data should be inserted
//! @param value double value which should inserted in the indicated column
void BindDouble(int column, double value) const;
//! Overrides prior binding on the same parameter with an int64 value.\n
//! You must call Sql() one time, before you can use Bind..() methods!
//! @param column Column, in which the data should be inserted
//! @param value int64 value which should inserted in the indicated column
void BindInt64(int column, int64 value) const;
//! Overrides prior binding on the same parameter with NULL.\n
//! You must call Sql() one time, before you can use Bind..() methods!
//! @param column Column, in which the data should be inserted
void BindNull(int column) const;
//! Overrides prior binding on the same parameter with a BLOB.\n
//! You must call Sql() one time, before you can use Bind..() methods!
//! @param column Column, in which the data should be inserted
//! @param data BLOB data which should inserted in the indicated column
//! @param numberOfBytes The size of the second parameter (const void *data) in bytes.\n
//! Please pay attention, that numberOfBytes is not the number of characters!
//! Default: -1.\n
//! Negative numberOfBytes means, that the length of the string is the number of\n
//! bytes up to the first zero terminator.
void BindBlob(int column, const void* data, int numberOfBytes = -1) const;
//! Overrides prior binding on the same parameter with a blob that is filled with zeroes.\n
//! You must call Sql() one time, before you can use Bind..() methods!
//! @param column Column, in which the data should be inserted
//! @param length length of BLOB, which is filled with zeroes
void BindZeroBlob(int column, int length) const;
//! Executes a INSERT statement and clean-up.\n
//! You must first call Sql() and Bind..() methods!
void ExecuteAndFree();
//! Returns the result as a complete table.\n
//! Note: only for console (textoutput)\n
//! Output: std::cout
//! @param sql SQL query string
//! @param consoleOutputColumnWidth Width of the output column within the console
void GetTable(const std::string &sql, unsigned short consoleOutputColumnWidth = 20) const;
//! Returns metadata about a specific column of a specific database table.
//! Note: only console output\n
//! Output: std::cout
//! @param tableName Table in which the column is found
//! @param columnName Column for which we want the metadata
void GetTableColumnMetadata(const std::string &tableName, const std::string &columnName) const;
//! Resets all SQL parameter bindings back to NULL.\n
//! ClearBindings() does not reset the bindings on a prepared statement!
void ClearBindings() const;
//! Reset() is called to reset a prepared statement object back to its initial state,\n
//! ready to be re-executed. Any SQL statement variables that had values bound to them\n
//! using the Bind*() functions retain their values. Use ClearBindings() to reset the bindings.
void Reset() const;
//! Begins a transaction.
void BeginTransaction();
//! Commits a transaction.\n
//! Exception output: std::cerr
void CommitTransaction();
//! Rollback a transaction.
inline void RollbackTransaction()
{
SqlStatement("ROLLBACK;");
FreeAllStatements();
}
//! Can be used only for transaction SQL statements.\n
//! Can be used for transactions, if you want use the default error handling.
//! Please note that there is only used a reference of your sql statement.\n
//! If your sql statement variable is invalid before you called CommitTransaction()
//! you need to use SecureTransaction(), which creates a internal copy of your sql statement.
//! @param sql SQL statement
inline void Transaction(const char *sql) {mTransactionSQL[mTransactionID++] = std::make_pair(sql, false);}
//! Can be used only for transaction SQL statements.\n
//! Can be used for transactions, if you want use the default error handling.
//! Please note that there is only used a reference of your sql statement.\n
//! If your sql statement variable is invalid before you called CommitTransaction()
//! you need to use SecureTransaction(), which creates a internal copy of your sql statement.
//! @param sql SQL statement
inline void Transaction(const std::string &sql) {mTransactionSQL[mTransactionID++] = std::make_pair(sql.c_str(), false);}
//! Can be used only for transaction SQL statements.\n
//! Can be used for transactions, if you want use the default error handling.
//! Please note that there is only used a reference of your sql statement.\n
//! If your sql statement variable is invalid before you called CommitTransaction()
//! you need to use SecureTransaction(), which creates a internal copy of your sql statement.
//! @param sql SQL statement
inline void Transaction(const wchar_t *sql) {mTransactionSQL16[mTransactionID++] = std::make_pair(sql, false);}
//! Can be used only for transaction SQL statements.\n
//! Can be used for transactions, if you want use the default error handling.\n
//! The SecureTransaction() method creates a internal copy of the given sql statement string,\n
//! so that you do not run into danger if the string will be invalid due to deletion or local scope.
//! @param sql SQL statement
void SecureTransaction(const char *sql);
//! Can be used only for transaction SQL statements.\n
//! Can be used for transactions, if you want use the default error handling.\n
//! The SecureTransaction() method creates a internal copy of the given sql statement string,\n
//! so that you do not run into danger if the string will be invalid due to deletion or local scope.
//! @param sql SQL statement
void SecureTransaction(const std::string sql);
//! Can be used only for transaction SQL statements.\n
//! Can be used for transactions, if you want use the default error handling.\n
//! The SecureTransaction() method creates a internal copy of the given sql statement string,\n
//! so that you do not run into danger if the string will be invalid due to deletion or local scope.
//! @param sql SQL statement
void SecureTransaction(const wchar_t *sql);
//! Executes a SQL statement and returns instantly the result value of the first column from the first row.
//! @param sql SQL statement
//! @param defaultReturnValue Default return value when the SQL statement has no result
std::string GetSqlResultString(const std::string &sql, const std::string &defaultReturnValue = "");
//! Executes a SQL statement and returns instantly the result value of the first column from the first row.
//! @param sql SQL statement
//! @param defaultReturnValue Default return value when the SQL statement has no result
std::string GetSqlResultString(const char *sql, const std::string &defaultReturnValue = "");
//! Executes a SQL statement and returns instantly the result value of the first column from the first row.
//! @param sql SQL statement
//! @param defaultReturnValue Default return value when the SQL statement has no result
std::string GetSqlResultString(const wchar_t *sql, const std::string &defaultReturnValue = "");
//! Executes a SQL statement and returns instantly the result value of the first column from the first row.
//! @param sql SQL statement
//! @param defaultReturnValue Default return value when the SQL statement has no result
int GetSqlResultInt(const std::string &sql, int defaultReturnValue = -1);
//! Executes a SQL statement and returns instantly the result value of the first column from the first row.
//! @param sql SQL statement
//! @param defaultReturnValue Default return value when the SQL statement has no result
int GetSqlResultInt(const char *sql, int defaultReturnValue = -1);
//! Executes a SQL statement and returns instantly the result value of the first column from the first row.
//! @param sql SQL statement
//! @param defaultReturnValue Default return value when the SQL statement has no result
int GetSqlResultInt(const wchar_t *sql, int defaultReturnValue = -1);
//! Executes a SQL statement and returns instantly the result value of the first column from the first row.
//! @param sql SQL statement
//! @param defaultReturnValue Default return value when the SQL statement has no result
int64 GetSqlResultInt64(const std::string &sql, int64 defaultReturnValue = -1);
//! Executes a SQL statement and returns instantly the result value of the first column from the first row.
//! @param sql SQL statement
//! @param defaultReturnValue Default return value when the SQL statement has no result
int64 GetSqlResultInt64(const char *sql, int64 defaultReturnValue = -1);
//! Executes a SQL statement and returns instantly the result value of the first column from the first row.
//! @param sql SQL statement
//! @param defaultReturnValue Default return value when the SQL statement has no result
int64 GetSqlResultInt64(const wchar_t *sql, int64 defaultReturnValue = -1);
//! Executes a SQL statement and returns instantly the result value of the first column from the first row.
//! @param sql SQL statement
//! @param defaultReturnValue Default return value when the SQL statement has no result
double GetSqlResultDouble(const std::string &sql, double defaultReturnValue = -1);
//! Executes a SQL statement and returns instantly the result value of the first column from the first row.
//! @param sql SQL statement
//! @param defaultReturnValue Default return value when the SQL statement has no result
double GetSqlResultDouble(const char *sql, double defaultReturnValue = -1);
//! Executes a SQL statement and returns instantly the result value of the first column from the first row.
//! @param sql SQL statement
//! @param defaultReturnValue Default return value when the SQL statement has no result
double GetSqlResultDouble(const wchar_t *sql, double defaultReturnValue = -1);
//! Executes a SQL statement and returns instantly the result value of the first column from the first row.
//! @param sql SQL statement
//! @param defaultReturnValue Default return value when the SQL statement has no result
const unsigned char *GetSqlResultCString(const std::string &sql, const unsigned char *defaultReturnValue = 0);
//! Executes a SQL statement and returns instantly the result value of the first column from the first row.
//! @param sql SQL statement
//! @param defaultReturnValue Default return value when the SQL statement has no result
const unsigned char *GetSqlResultCString(const char *sql, const unsigned char *defaultReturnValue = 0);
//! Executes a SQL statement and returns instantly the result value of the first column from the first row.
//! @param sql SQL statement
//! @param defaultReturnValue Default return value when the SQL statement has no result
const unsigned char *GetSqlResultCString(const wchar_t *sql, const unsigned char *defaultReturnValue = 0);
//! Executes a SQL statement and returns instantly the result value of the first column from the first row.
//! @param sql SQL statement
//! @param defaultReturnValue Default return value when the SQL statement has no result
wchar_t *GetSqlResultString16(const std::string &sql, wchar_t *defaultReturnValue = 0);
//! Executes a SQL statement and returns instantly the result value of the first column from the first row.
//! @param sql SQL statement
//! @param defaultReturnValue Default return value when the SQL statement has no result
wchar_t *GetSqlResultString16(const char *sql, wchar_t *defaultReturnValue = 0);
//! Executes a SQL statement and returns instantly the result value of the first column from the first row.
//! @param sql SQL statement
//! @param defaultReturnValue Default return value when the SQL statement has no result
wchar_t *GetSqlResultString16(const wchar_t *sql, wchar_t *defaultReturnValue = 0);
//! Executes a SQL statement and returns instantly the result value of the first column from the first row.
//! @param sql SQL statement
//! @param defaultReturnValue Default return value when the SQL statement has no result
const void *GetSqlResultBlob(const std::string &sql, const void *defaultReturnValue = 0);
//! Executes a SQL statement and returns instantly the result value of the first column from the first row.
//! @param sql SQL statement
//! @param defaultReturnValue Default return value when the SQL statement has no result
const void *GetSqlResultBlob(const char *sql, const void *defaultReturnValue = 0);
//! Executes a SQL statement and returns instantly the result value of the first column from the first row.
//! @param sql SQL statement
//! @param defaultReturnValue Default return value when the SQL statement has no result
const void *GetSqlResultBlob(const wchar_t *sql, const void *defaultReturnValue = 0);
//! After you have called the Sql() function you can get the number of rows which were returned as result.
unsigned int GetNumberOfRows();
protected:
//! Compile sql query into a byte-code program.
//! @param sqlStatement SQL statement (UTF-8)
void Prepare(const char *sqlStatement);
//! Compile sql query into a byte-code program.
//! @param sqlStatement SQL statement (UTF-16)
void Prepare(const wchar_t *sqlStatement);
//! Must be called one or more times to evaluate the statement.
bool Step() const;
//! Checks if the statement pointer is valid
void CheckStatement() const;
//! Checks if the database pointer is valid
void CheckDatabase() const;
//! Clean-up all statements.
void FreeAllStatements();
//! Free the allocated memory and clean the containers
void CleanUpTransaction();
//! Free the allocated memory of sql statements
//! @param isMemAllocated Was memory allocated?
//! @param str SQL statement string
template<class T>
inline void DeleteTransactionSqlStr(bool isMemAllocated, T *str)
{
if(isMemAllocated)
delete[] str;
}
//! Returns the first value of the first row from the given sql statement result.
//! @param sql SQL statement
//! @param getColumnFunc Function to get the SQL statement result
//! @param defaultReturnValue Default return value when the SQL statement has no result
template<class S, class T>
T GetColumnValue(S sql, T(Kompex::SQLiteStatement::*getColumnFunc)(int columnNumber)const, T defaultReturnValue);
private:
//! SQL statement
struct sqlite3_stmt *mStatement;
//! Database pointer
SQLiteDatabase *mDatabase;
//! typedef for UTF-8 transaction statements
typedef std::map<unsigned short /* transaction id */, std::pair<const char* /* sql */, bool /* memory allocated */> > TTransactionSQL;
//! typedef for UTF-16 transaction statements
typedef std::map<unsigned short /* transaction id */, std::pair<const wchar_t* /* sql */, bool /* is memory allocated */> > TTransactionSQL16;
//! Stores UTF-8 transaction statements
TTransactionSQL mTransactionSQL;
//! Stores UTF-16 transaction statements
TTransactionSQL16 mTransactionSQL16;
//! id for transactions
unsigned short mTransactionID;
};
};
#endif // KompexSQLiteStatement_H
|
[
"[email protected]"
] |
[
[
[
1,
449
]
]
] |
1665195ee2727292b1f11923a4b77cc801220cb0
|
57574cc7192ea8564bd630dbc2a1f1c4806e4e69
|
/Poker/Comun/XmlParserArchivo.h
|
e4c88bd4ae243e2dbf4e3caffa451ba5dca238a8
|
[] |
no_license
|
natlehmann/taller-2010-2c-poker
|
3c6821faacccd5afa526b36026b2b153a2e471f9
|
d07384873b3705d1cd37448a65b04b4105060f19
|
refs/heads/master
| 2016-09-05T23:43:54.272182 | 2010-11-17T11:48:00 | 2010-11-17T11:48:00 | 32,321,142 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,083 |
h
|
#ifndef _XMLPARSERARCHIVO_H__
#define _XMLPARSERARCHIVO_H__
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string.h>
#include <sstream>
#include <list>
#include <set>
#include <map>
#include <deque>
#include <fstream>
#include "XmlParser.h"
class XmlParserArchivo : public XmlParser
{
private:
string nombreArchivo;
bool finArchivo;
bool inicializado;
bool validado;
ifstream* archivo;
DomTree* arbol;
unsigned int contadorLinea;
void setNombreArchivo(string nombreArchivo);
void procesarArchivo();
void procesarLinea(string linea);
public:
XmlParserArchivo(string nombreArchivo);
virtual ~XmlParserArchivo(void);
/**
* Procesa el archivo recibido por parametro o el que se haya seteado en
* el contructor. El parametro nombreArchivo puede ser vacio.
*/
virtual DomTree* toDom(string nombreArchivo);
/**
* Devuelve un arbol conteniendo el siguiente elemento en el archivo
* procesado o NULL en caso de que se haya llegado al fin de archivo.
*/
DomTree* getSiguiente();
};
#endif
|
[
"natlehmann@a9434d28-8610-e991-b0d0-89a272e3a296"
] |
[
[
[
1,
50
]
]
] |
22602558ee6c356facccb09e4b7ab30868af5cc4
|
e7c45d18fa1e4285e5227e5984e07c47f8867d1d
|
/SMDK/Kenwalt/KW_SMDK1/KW_SMDK1.cpp
|
e55a56f314c7d69336687ee2a6a8d7075019cea0
|
[] |
no_license
|
abcweizhuo/Test3
|
0f3379e528a543c0d43aad09489b2444a2e0f86d
|
128a4edcf9a93d36a45e5585b70dee75e4502db4
|
refs/heads/master
| 2021-01-17T01:59:39.357645 | 2008-08-20T00:00:29 | 2008-08-20T00:00:29 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,353 |
cpp
|
//================== SysCAD - Copyright Kenwalt (Pty) Ltd ===================
// $Nokeywords: $
//===========================================================================
#include "stdafx.h"
#define __KW_SMDK1_CPP
#include "kw_smdk1.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
#include "scdmacros.h"
#include "md_headers.h"
#pragma LIBCOMMENT("..\\..\\Bin\\", "\\DevLib" )
#pragma LIBCOMMENT("..\\..\\Bin\\", "\\scdlib" )
#pragma LIBCOMMENT("..\\..\\Bin\\", "\\scexec" )
//===========================================================================
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
//if (!MakeVersionOK("KW_SMDK1.DLL", _MAKENAME, SCD_VERINFO_V0, SCD_VERINFO_V1, SCD_VERINFO_V2, SCD_VERINFO_V3))
// return FALSE;
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
//===========================================================================
extern "C" __declspec(dllexport) BOOL IsSMDKLibDLL()
{
return TRUE;
}
//===========================================================================
|
[
"[email protected]",
"[email protected]"
] |
[
[
[
1,
15
],
[
17,
17
],
[
19,
31
],
[
34,
51
]
],
[
[
16,
16
],
[
18,
18
],
[
32,
33
]
]
] |
e6e10599308adc000612aa439b322de004a2b28f
|
0b66a94448cb545504692eafa3a32f435cdf92fa
|
/branches/nn/cbear.berlios.de/windows/com/static/interface_list.hpp
|
33e186077773ebf18941858bdfbde6bccf1f003a
|
[
"MIT"
] |
permissive
|
BackupTheBerlios/cbear-svn
|
e6629dfa5175776fbc41510e2f46ff4ff4280f08
|
0109296039b505d71dc215a0b256f73b1a60b3af
|
refs/heads/master
| 2021-03-12T22:51:43.491728 | 2007-09-28T01:13:48 | 2007-09-28T01:13:48 | 40,608,034 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,076 |
hpp
|
#ifndef CBEAR_BERLIOS_DE_WINDOWS_COM_STATIC_INTERFACE_LIST_HPP_INCLUDED
#define CBEAR_BERLIOS_DE_WINDOWS_COM_STATIC_INTERFACE_LIST_HPP_INCLUDED
#include <cbear.berlios.de/windows/com/static/interface.hpp>
#include <cbear.berlios.de/meta/list.hpp>
namespace cbear_berlios_de
{
namespace windows
{
namespace com
{
namespace static_
{
template<class T, class L>
class interface_list:
public interface_<T, typename L::front::type>,
public interface_list<T, typename L::pop_front::type>
{
protected:
typedef interface_<T, typename L::front::type> interface_t;
typedef interface_list<T, typename L::pop_front::type> pop_front_t;
iunknown_t::move_t query_interface(const uuid &U) throw()
{
iunknown_t::move_t R = this->interface_t::query_interface(U);
if(*R)
{
return R;
}
return this->pop_front_t::query_interface(U);
}
};
template<class T>
class interface_list<T, meta::list>
{
protected:
iunknown_t::move_t query_interface(const uuid &) throw()
{
return iunknown_t::move_t();
}
};
}
}
}
}
#endif
|
[
"nn0@e6e9985e-9100-0410-869a-e199dc1b6838"
] |
[
[
[
1,
50
]
]
] |
062008f4999cb3ce06a9387ced351c28c779b5e6
|
57574cc7192ea8564bd630dbc2a1f1c4806e4e69
|
/Poker/Servidor/Thread.h
|
f642bb3bc2758e4df1e2930eed3769dd0d84f39c
|
[] |
no_license
|
natlehmann/taller-2010-2c-poker
|
3c6821faacccd5afa526b36026b2b153a2e471f9
|
d07384873b3705d1cd37448a65b04b4105060f19
|
refs/heads/master
| 2016-09-05T23:43:54.272182 | 2010-11-17T11:48:00 | 2010-11-17T11:48:00 | 32,321,142 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,174 |
h
|
#ifndef THREAD_H_
#define THREAD_H_
#include <windows.h>
class Thread
{
protected:
HANDLE m_hThread; //Thread handle
bool m_bActive; //activity indicator
DWORD m_lpId; //Thread ID
public:
Thread(){}
virtual ~Thread(){Kill();}
//Thread Management
bool CreateNewThread();
bool Wait(); //Wait for thread to end
bool Suspend(); //Suspend the thread
bool Resume(); //Resume a suspended thread
bool Kill(); //Terminate a thread
bool IsActive(); //Check for activity
//override these functions in the derived class
virtual void ThreadEntry(){ }
virtual void ThreadExit(){ }
virtual void Run(){ }
//a friend
//friend DWORD WINAPI _ThreadFunc(LPVOID pvThread);
//Friend of Thread class
//Actual thread around which the OO wrapper is built.
//Do not call twice on the same object.
//do something (initializing and finalizing) in ThreadEntry and ThreadExit functions.
friend DWORD WINAPI _ThreadFunc(LPVOID pvThread)
{
Thread* pThread = (Thread*)pvThread; //typecast
pThread->ThreadEntry(); //initialize
pThread->Run();
pThread->ThreadExit(); //finalize
return 0;
};
};
#endif /*THREAD_H_*/
|
[
"flrago78538@a9434d28-8610-e991-b0d0-89a272e3a296"
] |
[
[
[
1,
48
]
]
] |
1458a19e5f22db76c170e52441c8f561b8c6a2cd
|
4b4e6844d1df21457cdd77b51960b276cedec243
|
/hit_load_request_thread.h
|
dfb9f966617224d6b146673ec0aff80360dc2783
|
[] |
no_license
|
leonhong/sitemon2
|
45681c0e6788cf764889a201ba1917aa476d27cf
|
c376953f584d9e8bfc3af69117586f5d1f5a3863
|
refs/heads/master
| 2021-01-16T20:00:19.591266 | 2010-04-11T16:09:15 | 2010-04-11T16:09:15 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 748 |
h
|
#ifndef HIT_LOAD_REQUEST_THREAD_H
#define HIT_LOAD_REQUEST_THREAD_H
#include "utils/thread.h"
#include "script.h"
#include "http_engine.h"
struct RequestThreadData
{
RequestThreadData(int thread, Script *pScript, int debugLevel = 0) : m_thread(thread), m_pScript(pScript), m_debugLevel(debugLevel) { }
Script *m_pScript;
int m_thread;
int m_debugLevel;
};
class HitLoadRequestThread : public Thread
{
public:
HitLoadRequestThread(RequestThreadData *data);
virtual ~HitLoadRequestThread();
virtual void run();
std::vector<HTTPResponse> &getResponses() { return m_aResponses; }
protected:
int m_threadID;
int m_debugLevel;
Script m_Script;
std::vector<HTTPResponse> m_aResponses;
};
#endif
|
[
"[email protected]"
] |
[
[
[
1,
35
]
]
] |
915b464f6670265819e8a48069a69287c3d4bd26
|
c95a83e1a741b8c0eb810dd018d91060e5872dd8
|
/libs/stdlith/stringholder.h
|
b93be99975b9ac4511836731def46d9daa6bb839
|
[] |
no_license
|
rickyharis39/nolf2
|
ba0b56e2abb076e60d97fc7a2a8ee7be4394266c
|
0da0603dc961e73ac734ff365bfbfb8abb9b9b04
|
refs/heads/master
| 2021-01-01T17:21:00.678517 | 2011-07-23T12:11:19 | 2011-07-23T12:11:19 | 38,495,312 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 2,058 |
h
|
//------------------------------------------------------------------
//
// FILE : StringHolder.h
//
// PURPOSE : Defines the CStringHolder class. StringHolders
// help you manage memory when dealing with strings
// in particular.
//
// CREATED : 5/1/96
//
// COPYRIGHT : Monolith 1996 All Rights Reserved
//
//------------------------------------------------------------------
#ifndef __STRINGHOLDER_H__
#define __STRINGHOLDER_H__
#ifndef __STDLITHDEFS_H__
#include "stdlithdefs.h"
#endif
#ifndef __DYNARRAY_H__
#include "dynarray.h"
#endif
#ifndef __MEMORY_H__
#include "memory.h"
#endif
class SBank {
public:
char *m_pString;
uint16 m_AllocSize;
uint16 m_StringSize; // Current length of the string.
};
class CStringHolder {
public:
// Constructors
CStringHolder();
CStringHolder(unsigned short allocSize);
// Destructor
~CStringHolder();
// Member functions
// Changes the allocation size. You can only do this when the stringholder is empty.
void SetAllocSize(unsigned short size);
// Adds the string in, and grows the internal array if necessary.
// If bFindFirst=TRUE, it'll search the current array and
// if the string's already there, return a pointer to it.
char *AddString(const char *pString, LTBOOL bFindFirst=TRUE);
// Same as above, but here it'll use len and ignore the
// contents of the string.
char *AddString(const char *pString, LTBOOL bFindFirst, unsigned int len);
// Returns a pointer if it can find it.
// Returns Null if it's not in there.
char *FindString(const char *pString);
// Clears out all strings.
void ClearStrings();
private:
// Member variables
// Pointers to strings.
CMoArray<SBank> m_Strings;
// When it has to allocate a string,
// this is how big the string is (at a minimum).
unsigned short m_AllocSize;
};
#endif
|
[
"[email protected]"
] |
[
[
[
1,
83
]
]
] |
bd874467cfcb56cc14abddedebb37ef6c7ac9e12
|
28aa891f07cc2240c771b5fb6130b1f4025ddc84
|
/clpbr/clpbr/progressive_photon_map_renderer.h
|
0fa5a19ed382951ebd724cc92b06572227ddab99
|
[] |
no_license
|
Hincoin/mid-autumn
|
e7476d8c9826db1cc775028573fc01ab3effa8fe
|
5271496fb820f8ab1d613a1c2355504251997fef
|
refs/heads/master
| 2021-01-10T19:17:01.479703 | 2011-12-19T14:32:51 | 2011-12-19T14:32:51 | 34,730,620 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 681 |
h
|
#ifndef _PROGRESSIVE_PHOTON_MAP_RENDERER_H_
#define _PROGRESSIVE_PHOTON_MAP_RENDERER_H_
#include <vector>
#include "renderer.h"
#include "ray_buffer.h"
#include "photon_map.h"
class Sampler;
class Camera;
class Film;
struct scene_info_memory_t;
class PPMRenderer:public Renderer
{
public:
PPMRenderer(Camera* c,Film* im,Sampler* s,photon_map_t* photon_map);
virtual void Render(const scene_info_memory_t& scene_info);
virtual ~PPMRenderer();
private:
void InitializeDeviceData(const scene_info_memory_t& scene_info);
private:
Camera* camera_;
Film* image_;
Sampler* sampler_;
//sppm data
photon_map_t* photon_map_;
//
};
#endif
|
[
"luozhiyuan@ea6f400c-e855-0410-84ee-31f796524d81"
] |
[
[
[
1,
36
]
]
] |
a8a4925c22e223ca6dab4b1463f2057e98db5926
|
09057f4cce385ad826cf5f61454e85f214e937a8
|
/vs2010/GetCPU/Au3_WaitUntilIdle/stdafx.cpp
|
ba772e7912a4040533ea0f62675ca05df5b38ad8
|
[] |
no_license
|
van-smith/OPBM
|
751f8f71e6823b7f1c95e5002909427910479f90
|
69ae167a375dfbfa9552b9bfb388f317447dbd9d
|
refs/heads/master
| 2016-08-07T10:44:54.348257 | 2011-07-28T05:28:59 | 2011-07-28T05:28:59 | 2,143,608 | 0 | 1 | null | null | null | null |
UTF-8
|
C++
| false | false | 304 |
cpp
|
// stdafx.cpp : source file that includes just the standard includes
// Au3_WaitUntilIdle.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
|
[
"[email protected]"
] |
[
[
[
1,
8
]
]
] |
d50ecba6928d88aaa85bd022fb4831af2ec7ae34
|
e23043ccdd94075885800a4143630af7f2f01d4d
|
/lookupwin.h
|
88c86fcae6608bc92a8b0e98236ad637dbd29a49
|
[] |
no_license
|
daniel-kun/jisho
|
4f47e0492d080d0da34e7a14cf350384ea1de56f
|
b230a3e7c7f93f348bf4a9f9d8bbc73ad618cac2
|
refs/heads/master
| 2016-09-05T20:41:20.410020 | 2010-04-24T18:58:50 | 2010-04-24T18:58:50 | 627,086 | 1 | 1 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,172 |
h
|
#ifndef LOOKUPWIN_H
#define LOOKUPWIN_H
#include <QWidget>
#include <QLabel>
#include <QLineEdit>
#include <QTextEdit>
#include <QGridLayout>
#include <QToolButton>
#include "lookupedit.h"
#include "jisho.h"
class JishouToolButton: public QToolButton
{
Q_OBJECT
public:
JishouToolButton()
{
// setAutoRaise(true);
setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
setAutoFillBackground(true);
setCheckable(true);
}
void setJishoStyle(const JishoStyle &style)
{
QPalette pal = palette();
pal.setColor(QPalette::Window, style.fill);
setPalette(pal);
}
};
class JishoLookupWin: public QWidget
{
Q_OBJECT
signals:
public:
JishoLookupWin();
void setJishoStyle(const JishoStyle &style);
void retranslateUi();
void focusLookupEdit();
private:
QGridLayout m_glMain;
JishoLookupEdit m_edLookup;
QToolButton m_btnGo;
JishouToolButton m_btnAutomatic, m_btnEnglish, m_btnRomaji, m_btnJapanese;
QTextEdit m_htmlResults;
QString defaultText() const;
private slots:
void executeLookup();
};
#endif // LOOKUPWIN_H
|
[
"[email protected]"
] |
[
[
[
1,
62
]
]
] |
c3e8b9acd0902e2f939af23c48134e77b734c909
|
6477cf9ac119fe17d2c410ff3d8da60656179e3b
|
/Projects/openredalert/src/game/UHarvestEvent.h
|
a30ed9d5e1dd024603c2cc5fd3fb45b5e5bcf3a8
|
[] |
no_license
|
crutchwalkfactory/motocakerteam
|
1cce9f850d2c84faebfc87d0adbfdd23472d9f08
|
0747624a575fb41db53506379692973e5998f8fe
|
refs/heads/master
| 2021-01-10T12:41:59.321840 | 2010-12-13T18:19:27 | 2010-12-13T18:19:27 | 46,494,539 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,802 |
h
|
// UHarvestEvent.h
// 1.0
// This file is part of OpenRedAlert.
//
// OpenRedAlert 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, version 2 of the License.
//
// OpenRedAlert 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.
//
// You should have received a copy of the GNU General Public License
// along with OpenRedAlert. If not, see <http://www.gnu.org/licenses/>.
#ifndef UHARVESTEVENT_H
#define UHARVESTEVENT_H
#include "SDL/SDL_types.h"
#include "UnitAnimEvent.h"
#define HARVEST_RETURN_STEP_1 1
#define HARVEST_RETURN_STEP_2 2
#define HARVEST_RETURN_STEP_3 3
#define HARVEST_RETURN_STEP_4 4
class Unit;
class UnitOrStructure;
/**
* Animation played when harvester is harvesting
*/
class UHarvestEvent : public UnitAnimEvent
{
public:
UHarvestEvent(Uint32 p, Unit * un);
virtual ~UHarvestEvent();
void stop();
void setHarvestingPos(Uint32 pos);
virtual void update();
virtual void run();
private:
int GetBaseRefineryPos();
Uint16 RetryMoveCounter;
/** this is used to empty the truck when it is not full jet. */
bool ForceEmpty;
Uint8 ReturnStep;
bool new_orgimage;
Unit* un;
bool stopping;
bool manual_pauze;
UnitOrStructure * target;
int index;
int delay;
int facing;
Uint32 MoveTargePos;
Uint32 OrgImage;
/** Number of pieces resource in harvester */
Uint8 NumbResources;
/** Resource type in harvester */
Uint8 ResourceTypes[10];
};
#endif //UHARVESTEVENT_H
|
[
"[email protected]"
] |
[
[
[
1,
70
]
]
] |
7cc426b95ae9ca885f0ae5fa87026d3da3a3d16c
|
814b49df11675ac3664ac0198048961b5306e1c5
|
/Code/Engine/Input/include/InputManager.h
|
b7db2c14c82a0b12f7857fbcc8a0bb7e96b03aec
|
[] |
no_license
|
Atridas/biogame
|
f6cb24d0c0b208316990e5bb0b52ef3fb8e83042
|
3b8e95b215da4d51ab856b4701c12e077cbd2587
|
refs/heads/master
| 2021-01-13T00:55:50.502395 | 2011-10-31T12:58:53 | 2011-10-31T12:58:53 | 43,897,729 | 0 | 0 | null | null | null | null |
ISO-8859-13
|
C++
| false | false | 3,511 |
h
|
//----------------------------------------------------------------------------------
// CInputManager class
// Author: Enric Vergara
//
// Description:
// Esta clase gestiona los inputs de entrada de aplicacion; raton, teclado y joystick
// Internamente utiliza la librerķa DirectInput.
//----------------------------------------------------------------------------------
#pragma once
#ifndef INC_INPUT_MANAGER_H_
#define INC_INPUT_MANAGER_H_
#include <dinput.h>
#include "InputDefs.h"
//#include "Script/ScriptRegister.h" <------------ FALTA ScriptRegister.h
//---Forward Declarations--
class CScriptManager;
class CMouse;
class CKeyboard;
class CGamePad;
//-------------------------
class CInputManager//: public CScriptRegister <------------ FALTA CScriptRegister
{
public:
// Init and End protocols
CInputManager(): m_bIsOk(false), m_pDI( NULL ), m_pKB( NULL ), m_pMouse( NULL ), m_pGamePad(NULL) {}
virtual ~CInputManager() { Done(); }
bool Init (HWND, const Vect2i& screenRes, bool exclusiveModeinMouse, float _fSensitivity);
void Done ();
bool IsOk () const { return m_bIsOk; }
// Poll input devices
HRESULT Update ();
//--Query Input Data and States--------
HRESULT GetPosition (INPUT_DEVICE_TYPE, Vect2i&); // will work for mouse and joystick only
const Vect3i& GetMouseDelta (); // get change in mouse position
bool IsDown (INPUT_DEVICE_TYPE, uint32); // will work for keyboard, mouse and joystick
bool IsDownUp (INPUT_DEVICE_TYPE, uint32); // will work for keyboard, mouse and joystick
bool IsUpDown (INPUT_DEVICE_TYPE, uint32); // will work for keyboard, mouse and joystick
bool HasGamePad (INPUT_DEVICE_TYPE device = IDV_GAMEPAD1) const; // GamePad available?
int32 Scan2ascii (uint32 scancode, uint16* result);
//GamePad functions:
bool GetGamePadLeftThumbDeflection (float *pfX, float *pfY, INPUT_DEVICE_TYPE device = IDV_GAMEPAD1);
bool GetGamePadRightThumbDeflection (float *pfX, float *pfY, INPUT_DEVICE_TYPE device = IDV_GAMEPAD1);
bool GetGamePadDeltaTriggers (float *pfLeft, float *pfRight, INPUT_DEVICE_TYPE device = IDV_GAMEPAD1);
void SetGamePadLeftMotorSpeed (uint32 speed, INPUT_DEVICE_TYPE device = IDV_GAMEPAD1); //[0-65535]
void SetGamePadRightMotorSpeed (uint32 speed, INPUT_DEVICE_TYPE device = IDV_GAMEPAD1); //[0-65535]
//----CScriptRegister interface-------------------
//virtual void RegisterFunctions (CScriptManager* scriptManager);
uint32 GetCode(const string& _szCodeName) {return m_String2Code[_szCodeName];};
void SetMouseSensitivity(float _fSensitivity);
private:
void Release ();
private:
void InitString2Input ();
map<std::string, uint32> m_String2Code;
bool m_bIsOk; // Initialization boolean control
LPDIRECTINPUT8 m_pDI;
CKeyboard* m_pKB; // Pointer to the Keyboard instance
CMouse* m_pMouse; // Pointer to the Mouse instance
CGamePad* m_pGamePad; // Pointer to the GamePad instance
HWND m_hWndMain; // application main window
};
#endif //INC_INPUT_MANAGER_H_
|
[
"[email protected]",
"sergivalls@576ee6d0-068d-96d9-bff2-16229cd70485",
"Atridas87@576ee6d0-068d-96d9-bff2-16229cd70485"
] |
[
[
[
1,
32
],
[
34,
59
],
[
61,
61
],
[
65,
67
],
[
74,
83
]
],
[
[
33,
33
],
[
60,
60
],
[
68,
73
]
],
[
[
62,
64
]
]
] |
4a8675ec8dd337071d2c0b3d6057362d25e63cdb
|
8ad5d6836fe4ad3349929802513272db86d15bc3
|
/lib/Spin/Handlers/UDPDataHandler.h
|
4ebb4a4e83e65c839890f9cdda62b85e6ea177c7
|
[] |
no_license
|
blytkerchan/arachnida
|
90a72c27f0c650a6fbde497896ef32186c0219e5
|
468f4ef6c35452de3ca026af42b8eedcef6e4756
|
refs/heads/master
| 2021-01-10T21:43:51.505486 | 2010-03-12T04:02:19 | 2010-03-12T04:02:42 | 2,203,393 | 0 | 1 | null | null | null | null |
UTF-8
|
C++
| false | false | 763 |
h
|
#ifndef _spin_handlers_udpdatahandler_h
#define _spin_handlers_udpdatahandler_h
#include "../Details/prologue.h"
#include <boost/shared_ptr.hpp>
namespace Spin
{
class UDPSocket;
namespace Handlers
{
//! Handler for when new data is ready on a UDP socket
class SPIN_API UDPDataHandler
{
public :
const UDPDataHandler & operator()(boost::shared_ptr< UDPSocket > socket) const
{
onDataReady(socket.get());
return *this;
}
const UDPDataHandler & operator()(UDPSocket * socket) const
{
onDataReady(socket);
return *this;
}
protected :
virtual ~UDPDataHandler();
//! Called when new data is ready.
virtual void onDataReady(UDPSocket * socket) const = 0;
};
}
}
#endif
|
[
"[email protected]"
] |
[
[
[
1,
36
]
]
] |
fbe8fd3d2427de3d45314c65b765f9839207fd23
|
fd792229322e4042f6e88a01144665cebdb1c339
|
/src/vector2D.h
|
31368cb0b484e4e1fcc9faaf49f1ec6b77febe79
|
[] |
no_license
|
weimingtom/mmomm
|
228d70d9d68834fa2470d2cd0719b9cd60f8dbcd
|
cab04fcad551f7f68f99fa0b6bb14cec3b962023
|
refs/heads/master
| 2021-01-10T02:14:31.896834 | 2010-03-15T16:15:43 | 2010-03-15T16:15:43 | 44,764,408 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 5,214 |
h
|
#ifndef VECTOR2D_H_
#define VECTOR2D_H_
#include <cmath>
#include <cfloat>
#include <RakNet/NativeTypes.h>
#include <boost/functional/hash.hpp>
// A mostly-immutable 2-dimensional vector
template<typename T>
struct GVector2D {
GVector2D(): x(), y() { }
template<typename U>
GVector2D(U x, U y): x(T(x)), y(T(y)) { }
template<typename U>
explicit GVector2D(const GVector2D<U>& rhs): x(T(rhs.x)), y(T(rhs.y)) { }
// Returns the length squared of this vector (faster than length()).
T lengthSquared() const;
// Returns the length of this vector.
T length() const;
// Returns a vector pointing in the same direction, of length 1.
GVector2D normalized() const;
// Memberwise multiplication/division
GVector2D memberwiseMult(const GVector2D& rhs) const;
GVector2D memberwiseDiv(const GVector2D& rhs) const;
GVector2D memberwiseMod(const GVector2D& rhs) const;
// Returns the dot product of this and another vector.
// |a||b|cos(theta)
T dot(const GVector2D& rhs) const;
// Returns the perpendicular dot product of this and another vector.
// Similar to cross product, or wedge product.
// |a||b|sin(theta)
T perpDot(const GVector2D& rhs) const;
// x and y coordinates
T x;
T y;
// Returns a hash of the given value.
friend std::size_t hash_value(const GVector2D& v)
{
std::size_t seed = 0;
boost::hash_combine(seed, v.x);
boost::hash_combine(seed, v.y);
return seed;
}
};
// Negation
template<typename T>
inline GVector2D<T> operator+(const GVector2D<T>& v)
{
return v;
}
template<typename T>
inline GVector2D<T> operator-(const GVector2D<T>& v)
{
return GVector2D<T>(-v.x, -v.y);
}
// Vector addition/subtraction
template<typename T>
inline GVector2D<T> operator+(const GVector2D<T>& v1, const GVector2D<T>& v2)
{
return GVector2D<T>(v1.x + v2.x, v1.y + v2.y);
}
template<typename T>
inline GVector2D<T> operator-(const GVector2D<T>& v1, const GVector2D<T>& v2)
{
return GVector2D<T>(v1.x - v2.x, v1.y - v2.y);
}
template<typename T>
inline GVector2D<T>& operator+=(GVector2D<T>& v1, const GVector2D<T>& v2)
{
return v1 = v1 + v2;
}
template<typename T>
inline GVector2D<T>& operator-=(GVector2D<T>& v1, const GVector2D<T>& v2)
{
return v1 = v1 - v2;
}
// Scalar multiplication/division
template<typename T>
inline GVector2D<T> operator*(const GVector2D<T>& v, T scalar)
{
return GVector2D<T>(v.x * scalar, v.y * scalar);
}
template<typename T>
inline GVector2D<T> operator*(T scalar, const GVector2D<T>& v)
{
return v * scalar;
}
template<typename T>
inline GVector2D<T> operator/(const GVector2D<T>& v, T scalar)
{
return GVector2D<T>(v.x / scalar, v.y / scalar);
}
template<typename T>
inline GVector2D<T> operator/(T scalar, const GVector2D<T>& v)
{
return GVector2D<T>(scalar / v.x, scalar / v.y);
}
template<typename T>
inline GVector2D<T> operator%(const GVector2D<T>& v, T scalar)
{
return GVector2D<T>(v.x % scalar, v.y % scalar);
}
template<typename T>
inline GVector2D<T>& operator*=(GVector2D<T>& v, T scalar)
{
return v = v * scalar;
}
template<typename T>
inline GVector2D<T>& operator/=(GVector2D<T>& v, T scalar)
{
return v = v / scalar;
}
template<typename T>
inline GVector2D<T>& operator%=(GVector2D<T>& v, T scalar)
{
return v = v % scalar;
}
template<typename T>
inline bool operator==(const GVector2D<T>& v1, const GVector2D<T>& v2)
{
return (v1.x == v2.x && v1.y == v2.y);
}
template<typename T>
inline bool operator!=(const GVector2D<T>& v1, const GVector2D<T>& v2)
{
return !(v1 == v2);
}
template<typename T>
inline GVector2D<T> GVector2D<T>::memberwiseMult(const GVector2D<T>& rhs) const
{
return GVector2D<T>(x * rhs.x, y * rhs.y);
}
template<typename T>
inline GVector2D<T> GVector2D<T>::memberwiseDiv(const GVector2D<T>& rhs) const
{
return GVector2D<T>(x / rhs.x, y / rhs.y);
}
template<typename T>
inline GVector2D<T> GVector2D<T>::memberwiseMod(const GVector2D<T>& rhs) const
{
return GVector2D<T>(x % rhs.x, y % rhs.y);
}
template<typename T>
inline T GVector2D<T>::lengthSquared() const
{
return this->dot(*this);
}
template<typename T>
inline T GVector2D<T>::length() const
{
return std::sqrt(lengthSquared());
}
template<typename T>
inline GVector2D<T> GVector2D<T>::normalized() const
{
return lengthSquared() >= FLT_EPSILON * FLT_EPSILON ? *this / length() : GVector2D<T>();
}
template<typename T>
inline T GVector2D<T>::dot(const GVector2D<T>& rhs) const
{
return x * rhs.x + y * rhs.y;
}
template<typename T>
inline T GVector2D<T>::perpDot(const GVector2D<T>& rhs) const
{
return x * rhs.y - y * rhs.x;
}
// Not working for some reason.
/*
namespace std {
// Returns the minimal/maximal coordinates of the pair.
inline ::GVector2D min(const ::GVector2D& v1, const ::GVector2D& v2)
{
return ::Vector2D(min(v1.x, v2.x), min(v1.y, v2.y));
}
inline ::GVector2D max(const ::GVector2D& v1, const ::GVector2D& v2)
{
return ::Vector2D(max(v1.x, v2.x), max(v1.y, v2.y));
}
}
*/
typedef GVector2D<double> Vector2D;
typedef GVector2D<int32_t> IVector2D;
#endif
|
[
"[email protected]"
] |
[
[
[
1,
204
]
]
] |
a225a6d7dd118ad65036a1d3e78d0caeb800d7c0
|
c4fe84ad515b1538a4f09f651f1bcc2104086d19
|
/example.h
|
dfdea50370d87e028277b9dce28acc8add5e9a5b
|
[] |
no_license
|
vi-k/mrulist
|
d1aee4960bb85bf32f8a4ecb53d190e50eb2c06b
|
199e894d43261b99072f66e167940a101767ef0e
|
refs/heads/master
| 2021-01-10T02:00:53.526700 | 2010-06-07T08:24:58 | 2010-06-07T08:24:58 | 44,525,975 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 2,914 |
h
|
#ifndef EXAMPLE_H
#define EXAMPLE_H
#include <iostream>
class tile_id
{
//private:
public:
int map_id_;
int z_;
int x_;
int y_;
public:
tile_id()
: map_id_(0), z_(0), x_(0), y_(0) {}
tile_id(int map_id, int z, int x, int y)
: map_id_(map_id), z_(z), x_(x), y_(y) {}
tile_id(const tile_id &other)
: map_id_(other.map_id_)
, z_(other.z_)
, x_(other.x_)
, y_(other.y_) {}
tile_id& operator=(const tile_id &other)
{
map_id_ = other.map_id_;
z_ = other.z_;
x_ = other.x_;
y_ = other.y_;
return *this;
}
inline bool operator ==(const tile_id &other) const
{
return map_id_ == other.map_id_
&& z_ == other.z_
&& x_ == other.x_
&& y_ == other.y_;
}
inline bool operator <(const tile_id &other) const
{
if (map_id_ != other.map_id_)
return map_id_ < other.map_id_;
if (z_ != other.z_)
return z_ < other.z_;
if (x_ != other.x_)
return x_ < other.x_;
return y_ < other.y_;
}
friend std::ostream& operator <<(std::ostream& out, const tile_id &t)
{
out << "{" << t.map_id_
<< "," << t.z_
<< "," << t.x_
<< "," << t.y_ << "}";
return out;
}
//friend std::size_t boost::hash_value(const tile_id &t);
/*-
{
std::size_t seed = 0;
boost::hash_combine(seed, t.map_id_);
boost::hash_combine(seed, t.z_);
boost::hash_combine(seed, t.x_);
boost::hash_combine(seed, t.y_);
return seed;
}
-*/
friend struct ihash; /* Для std::unordered_map */
};
namespace boost {
std::size_t hash_value(const tile_id &t)
{
std::size_t seed = 0;
boost::hash_combine(seed, t.map_id_);
boost::hash_combine(seed, t.z_);
boost::hash_combine(seed, t.x_);
boost::hash_combine(seed, t.y_);
return seed;
}
}
struct ihash : std::unary_function<tile_id, std::size_t>
{
std::size_t operator()(const tile_id &t) const
{
std::size_t seed = 0;
boost::hash_combine(seed, t.map_id_);
boost::hash_combine(seed, t.z_);
boost::hash_combine(seed, t.x_);
boost::hash_combine(seed, t.y_);
return seed;
}
};
#ifndef TEST_TYPE
#define TEST_TYPE int
#endif
#define TEST_DEBUG 0
class test
{
public:
TEST_TYPE a;
void init()
{
if (count()++ == 0)
std::cout << "*** first test::test() ***\n";
#if TEST_DEBUG
std::cout << "test(" << a << ") count=" << count() << std::endl;
#endif
}
test() { init(); }
test(const TEST_TYPE &a) : a(a) { init(); }
test(const test &t) : a(t.a) { init(); }
~test()
{
if (--count() == 0)
std::cout << "*** last test::~test() ***\n";
#if TEST_DEBUG
std::cout << "~test(" << a << ") count=" << count() << std::endl;
#endif
}
static int& count()
{
static int count_ = 0;
return count_;
};
friend std::ostream& operator <<(std::ostream& out, const test &t)
{
out << t.a;
return out;
}
};
#endif
|
[
"victor.dunaev@localhost",
"victor dunaev ([email protected])"
] |
[
[
[
1,
7
],
[
10,
64
],
[
67,
75
],
[
77,
81
],
[
95,
153
]
],
[
[
8,
9
],
[
65,
66
],
[
76,
76
],
[
82,
94
]
]
] |
898cc156ca112072dbc12d60753628b9fb2e9284
|
a742b2e3b2b7a38dea908afc22bf5c596f3b9aa3
|
/src/cpp/esorics09/solution.cpp
|
e2fdb05f259545b9e7b328c38c9f80c5a8b1795b
|
[] |
no_license
|
Contezero74/pri-views
|
ca5644c0838f72dccbe63625bcec03245081a6b3
|
81a672ab85d0b383abc9e6985768e327f5fddb02
|
refs/heads/master
| 2021-01-23T08:38:42.600931 | 2011-05-21T06:43:55 | 2011-05-21T06:43:55 | 32,253,156 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 891 |
cpp
|
/** This module defines the types and alias for
* solution management.
*
* version 1.5
*
* UNIBG and UNIMI @2009
*
* Implementation file
*/
#include "solution.h"
/** The default constructor create an empty solution with an
* undefined cost (represented as -1).
*/
solution::solution() {
Cost = -1;
}
/** This constructor initialize the solution struct with the
* input arguments.
*
* @param T the string representing the set of attributes
* used as solution
* @param C the cost of the solution
*/
solution::solution(const string &T, const int &C) {
SA = solution_attrs(T);
Cost = C;
}
/** This copy constructor create a new instance of a solution,
* copying the information from the input solution.
*
* @param S the input solution to copy
*/
solution::solution(const solution &S) {
SA = S.SA;
Cost = S.Cost;
}
|
[
"[email protected]@0b577695-253f-ada3-4816-9b21ae5cddc2"
] |
[
[
[
1,
40
]
]
] |
6fd95317d66ea93b122e905f0883877852d3c18d
|
6477cf9ac119fe17d2c410ff3d8da60656179e3b
|
/Projects/openredalert/src/game/UAttackAnimEvent.cpp
|
6dbe3c2e93ffc616f0fb0b749e5505f034996b05
|
[] |
no_license
|
crutchwalkfactory/motocakerteam
|
1cce9f850d2c84faebfc87d0adbfdd23472d9f08
|
0747624a575fb41db53506379692973e5998f8fe
|
refs/heads/master
| 2021-01-10T12:41:59.321840 | 2010-12-13T18:19:27 | 2010-12-13T18:19:27 | 46,494,539 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 7,364 |
cpp
|
// UAttackAnimEvent.h
// 1.0
// This file is part of OpenRedAlert.
//
// OpenRedAlert 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, version 2 of the License.
//
// OpenRedAlert 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.
//
// You should have received a copy of the GNU General Public License
// along with OpenRedAlert. If not, see <http://www.gnu.org/licenses/>.
#include "UAttackAnimEvent.h"
#include <cmath>
#include "SDL/SDL_types.h"
#include "ActionEventQueue.h"
#include "UnitOrStructure.h"
#include "TurnAnimEvent.h"
#include "unittypes.h"
#include "MoveAnimEvent.h"
#include "Projectile.h"
#include "Weapon.h"
#include "PlayerPool.h"
#include "game/Unit.h"
#include "CnCMap.h"
#include "include/Logger.h"
#include "Unit.h"
namespace p {
extern PlayerPool* ppool;
extern ActionEventQueue * aequeue;
extern CnCMap * ccmap;
}
extern Logger * logger;
UAttackAnimEvent::UAttackAnimEvent(Uint32 p, Unit *un) : UnitAnimEvent(p,un)
{
//logger->debug("UAttack cons\n");
this->un = un;
this->target = un->getTarget();
stopping = false;
waiting = 0;
target->referTo();
Weapon *Weap;
UsePrimaryWeapon = true;
// Determine the weapon to use
if (!target->getType()->isStructure()){
switch (((Unit*)target)->getType()->getType()){
case UN_INFANTRY:
case UN_VEHICLE:
Weap = un->getType()->getWeapon();
if (Weap != NULL){
if (!Weap->getProjectile()->AntiGround()){
UsePrimaryWeapon = false;
}
}
break;
case UN_BOAT:
Weap = un->getType()->getWeapon();
if (Weap != NULL){
if (!Weap->getProjectile()->AntiGround()){
UsePrimaryWeapon = false;
}
}
break;
case UN_PLANE:
case UN_HELICOPTER:
Weap = un->getType()->getWeapon();
if (Weap != NULL){
if (!Weap->getProjectile()->AntiAir()){
UsePrimaryWeapon = false;
}
}
break;
default:
logger->error ("%s line %i: ERROR unknown unit type %i\n", __FILE__, __LINE__, ((Unit*)target)->getType()->getType());
break;
}
}else{
Weap = un->getType()->getWeapon();
if (Weap != NULL){
if (!Weap->getProjectile()->AntiGround()){
UsePrimaryWeapon = false;
}
}
}
if (UsePrimaryWeapon == false){
// printf ("%s line %i: Using secundary weapon\n", __FILE__, __LINE__);
if (un->getType()->getWeapon(UsePrimaryWeapon) == NULL){
logger->error ("Primary weapon not oke, secundary weapon not available\n");
UsePrimaryWeapon = true;
if (un->getType()->getWeapon(UsePrimaryWeapon) == NULL){
stop();
}
}
}
}
UAttackAnimEvent::~UAttackAnimEvent()
{
//logger->debug("UAttack dest\n");
target->unrefer();
if (un->attackanim == this)
un->attackanim = NULL;
}
void UAttackAnimEvent::stop()
{
if (un == NULL) {
logger->error("UAttackAnimEvent::stop: un is NULL!?\n");
abort();
}
stopping = true;
}
void UAttackAnimEvent::update()
{
//logger->debug("UAtk updating\n");
target->unrefer();
target = un->getTarget();
target->referTo();
stopping = false;
}
/**
*/
void UAttackAnimEvent::run()
{
Sint32 xtiles, ytiles;
Uint16 atkpos;
float alpha;
Uint8 facing;
#ifdef LOOPEND_TURN
Uint8 loopend2=((UnitType*)un->type)->getAnimInfo().loopend2;
#endif
//logger->debug("attack run t%p u%p\n",this,un);
waiting = 0;
if( !un->isAlive() || stopping ) {
delete this;
return;
}
if( !target->isAlive() || stopping) {
if ( !target->isAlive() ) {
un->doRandTalk(TB_postkill);
}
delete this;
return;
}
// Check if we have a healing weapon (medic) and if we have healed someone completely
if (un->getType()->getWeapon(UsePrimaryWeapon)->getDamage() < 0){
// Oke, this is a healing weapon
if ( target->getHealth() == target->getType()->getMaxHealth()){
delete this;
return;
}
}
atkpos = un->getTargetCell();
xtiles = un->getPos() % p::ccmap->getWidth() - atkpos % p::ccmap->getWidth();
ytiles = un->getPos() / p::ccmap->getWidth() - atkpos / p::ccmap->getWidth();
// @todo modify calculs
//distance = abs()>abs(ytiles)?abs(xtiles):abs(ytiles);
double distance = sqrt(xtiles*xtiles + ytiles*ytiles);
if( distance > un->type->getWeapon(UsePrimaryWeapon)->getRange() /* weapons range */ ) {
setDelay(0);
waiting = 3;
un->move(atkpos,false);
un->moveanim->setRange(un->type->getWeapon(UsePrimaryWeapon)->getRange());
un->moveanim->setSchedule(this);
return;
}
//Make sure we're facing the right way
if( xtiles == 0 ) {
if( ytiles < 0 ) {
alpha = -1.57079632679489661923;
} else {
alpha = 1.57079632679489661923;
}
} else {
alpha = atan((float)ytiles/(float)xtiles);
if( xtiles < 0 ) {
alpha = 3.14159265358979323846+alpha;
}
}
#ifdef LOOPEND_TURN
facing = ((Sint8)((loopend2+1)*(1-alpha/2/3.14159265358979323846)+8))&loopend2;
if (un->type->isInfantry()) {
if (facing != (un->getImageNum(0)&loopend2)) {
un->setImageNum((Sint8)((loopend2+1)*facing/8),0);
}
} else if (un->type->getNumLayers() > 1 ) {
if (abs((int)(facing - (un->getImageNum(1)&loopend2))) > un->type->getROT()) {
#else
facing = (40-(Sint8)(alpha*16/M_PI))&0x1f;
if (un->type->isInfantry()) {
if (facing != (un->getImageNum(0)&0x1f)) {
un->setImageNum(facing>>2,0);
}
} else if (un->type->getNumLayers() > 1 ) {
if (abs((int)(facing - (un->getImageNum(1)&0x1f))) > un->type->getROT()) {
#endif
setDelay(0);
waiting = 2;
un->turn(facing,1);
un->turnanim2->setSchedule(this);
return;
}
} else {
#ifdef LOOPEND_TURN
if (abs((int)(facing - un->getImageNum(0)&loopend2)) > un->type->getROT()) {
#else
if (abs((int)(facing - un->getImageNum(0)&0x1f)) > un->type->getROT()) {
#endif
setDelay(0);
waiting = 1;
un->turn(facing,0);
un->turnanim1->setSchedule(this);
return;
}
}
// If we have a healing weapon we don't want to heal a enemy
if (un->getType()->getWeapon(UsePrimaryWeapon)->getDamage() < 0){
if (un->getOwner() != target->getOwner()){
delete this;
return;
}
}
// Throw an event
HandleTriggers(target, TRIGGER_EVENT_ATTACKED,
p::ppool->getHouseNumByPlayerNum(un->getOwner()));
// We can shoot
un->type->getWeapon(UsePrimaryWeapon)->fire(un, target->getBPos(un->getPos()), target->getSubpos());
// set delay to reloadtime
setDelay(un->type->getWeapon(UsePrimaryWeapon)->getReloadTime());
waiting = 4;
p::aequeue->scheduleEvent(this);
}
|
[
"[email protected]"
] |
[
[
[
1,
257
]
]
] |
3c934dd9c72ba9ec502b8614edcbcddeb9935a6d
|
e93e33cdf3df6aa6f41dc0c61ebd425a2bb730f7
|
/advanced_programming_ex06/Design Patterns/Singleton/Singleton.cpp
|
11b26b4cdc63787e5c83b2d142a389fb3b6ce58c
|
[] |
no_license
|
arielstolerman/tau-cs-spring-2010-advanced-topics-in-programming-ariel-shay
|
537f4936e1c6a386952c4cc81af0f26deb300578
|
714cbf1d0b1555b3a3c673143f02af0a584a1648
|
refs/heads/master
| 2021-01-20T09:32:59.237122 | 2011-12-20T05:45:45 | 2011-12-20T05:45:45 | 32,401,930 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 90 |
cpp
|
#include "Singleton.h"
Singleton* Singleton:: sngPtr = 0; // init static data
|
[
"arielstolerman@885801dc-8b0f-3d06-18ec-ad975b9ac306"
] |
[
[
[
1,
6
]
]
] |
435253789eb3c7872bacbee1de0fc1e54940dbb6
|
fcdddf0f27e52ece3f594c14fd47d1123f4ac863
|
/terralib/src/terralib/kernel/TeGeometricTransformation.cpp
|
40d739eba17d3e7fdc1232cbfae2e52ecdf925f4
|
[] |
no_license
|
radtek/terra-printer
|
32a2568b1e92cb5a0495c651d7048db6b2bbc8e5
|
959241e52562128d196ccb806b51fda17d7342ae
|
refs/heads/master
| 2020-06-11T01:49:15.043478 | 2011-12-12T13:31:19 | 2011-12-12T13:31:19 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 57,921 |
cpp
|
/*
TerraLib - a library for developing GIS applications.
Copyright 2001, 2002, 2003 INPE and Tecgraf/PUC-Rio.
This code is part of the TerraLib library.
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.
You should have received a copy of the GNU Lesser General Public
License along with this library.
The authors reassure the license terms regarding the warranties.
They specifically disclaim any warranties, including, but not limited to,
the implied warranties of merchantability and fitness for a particular
purpose. The library provided hereunder is on an "as is" basis, and the
authors have no obligation to provide maintenance, support, updates,
enhancements, or modifications.
In no event shall INPE be held liable to any party
for direct, indirect, special, incidental, or consequential damages arising
out of the use of this library and its documentation.
*/
#include "TeGeometricTransformation.h"
#include "TeMutex.h"
#include "TeThreadFunctor.h"
#include "TeUtils.h"
#include "TeAgnostic.h"
#include <math.h>
#include <float.h>
#include <map>
#include <algorithm>
// This is a workaround since Visual C++ is so very very considerate and
// pollutes global namespace with macros named min and max.
#ifdef max
#undef max
#endif
#ifdef min
#undef min
#endif
#include <limits>
TeGeometricTransformation::TeGeometricTransformation()
{
}
TeGeometricTransformation::~TeGeometricTransformation()
{
}
void TeGeometricTransformation::getParameters( TeGTParams& params ) const
{
params = internal_params_;
}
const TeGTParams& TeGeometricTransformation::getParameters() const
{
return internal_params_;
}
bool TeGeometricTransformation::reset( const TeGTParams& newparams )
{
/* If previous calculated parameters were supplied, no need to do calcules */
if( isTransDefined( newparams ) )
{
internal_params_ = newparams;
return true;
} else {
/* No previous parameters given - Need to calculate the new transformation
parameters */
const unsigned int req_tie_pts_nmb = getMinRequiredTiePoints();
if( newparams.tiepoints_.size() < req_tie_pts_nmb )
{
return false;
}
else if( newparams.tiepoints_.size() == req_tie_pts_nmb )
{
internal_params_ = newparams;
return computeParameters( internal_params_ );
}
else
{
internal_params_ = newparams;
switch( newparams.out_rem_strat_ ) {
case TeGTParams::NoOutRemotion :
{
if( computeParameters( internal_params_ ) ) {
if( ( newparams.max_dmap_error_ >=
getDirectMappingError( internal_params_ ) ) &&
( newparams.max_imap_error_ >=
getInverseMappingError( internal_params_ ) ) ) {
return true;
}
}
break;
}
case TeGTParams::ExaustiveOutRemotion :
{
if( internal_params_.enable_multi_thread_ ) {
if( exaustiveOutRemotion( internal_params_,
TeGetPhysProcNumber() - 1 ) ) {
return true;
}
} else {
if( exaustiveOutRemotion( internal_params_, 0 ) ) {
return true;
}
}
break;
}
case TeGTParams::LWOutRemotion :
{
if( lWOutRemotion( internal_params_ ) ) {
return true;
}
break;
}
case TeGTParams::RANSACRemotion :
{
if( ransacRemotion( newparams, internal_params_ ) ) {
return true;
}
break;
}
default :
{
TEAGN_LOG_AND_THROW(
"Invalid outliers remotion strategy" )
break;
}
}
}
}
internal_params_.reset();
return false;
}
double TeGeometricTransformation::getDirectMappingError(
const TeGTParams& params ) const
{
TEAGN_DEBUG_CONDITION( isTransDefined( params ),
"Transformation not defined" )
unsigned int tiepoints_size = params.tiepoints_.size();
double max_error = 0;
double current_error = 0;
for( unsigned int tpindex = 0 ; tpindex < tiepoints_size ; ++tpindex ) {
current_error = getDirectMappingError( params.tiepoints_[ tpindex ],
params );
if( current_error > max_error ) {
max_error = current_error;
}
}
return max_error;
}
double TeGeometricTransformation::getInverseMappingError(
const TeGTParams& params ) const
{
TEAGN_DEBUG_CONDITION( isTransDefined( params ),
"Transformation not defined" )
unsigned int tiepoints_size = params.tiepoints_.size();
double max_error = 0;
double current_error = 0;
for( unsigned int tpindex = 0 ; tpindex < tiepoints_size ; ++tpindex ) {
current_error = getInverseMappingError( params.tiepoints_[ tpindex ],
params );
if( current_error > max_error ) {
max_error = current_error;
}
}
return max_error;
}
double TeGeometricTransformation::getDMapRMSE(
const TeGTParams& params ) const
{
TEAGN_DEBUG_CONDITION( isTransDefined( params ),
"Transformation not defined" )
unsigned int tiepoints_size = params.tiepoints_.size();
if( tiepoints_size == 0 )
{
return 0;
}
else
{
double error2_sum = 0;
double current_error = 0;
for( unsigned int tpindex = 0 ; tpindex < tiepoints_size ; ++tpindex ) {
current_error = getDirectMappingError( params.tiepoints_[ tpindex ],
params );
error2_sum += ( current_error * current_error );
}
return sqrt( error2_sum / ( (double)tiepoints_size ) );
}
}
double TeGeometricTransformation::getIMapRMSE(
const TeGTParams& params ) const
{
TEAGN_DEBUG_CONDITION( isTransDefined( params ),
"Transformation not defined" )
unsigned int tiepoints_size = params.tiepoints_.size();
if( tiepoints_size == 0 )
{
return 0;
}
else
{
double error2_sum = 0;
double current_error = 0;
for( unsigned int tpindex = 0 ; tpindex < tiepoints_size ; ++tpindex ) {
current_error = getInverseMappingError( params.tiepoints_[ tpindex ],
params );
error2_sum += ( current_error * current_error );
}
return sqrt( error2_sum / ( (double)tiepoints_size ) );
}
}
double TeGeometricTransformation::getDirectMappingError(
const TeCoordPair& tie_point, const TeGTParams& params ) const
{
TEAGN_DEBUG_CONDITION( isTransDefined( params ),
"Transformation not defined" )
TeCoord2D direct_mapped_point;
directMap( params, tie_point.pt1, direct_mapped_point );
double diff_x = tie_point.pt2.x() - direct_mapped_point.x();
double diff_y = tie_point.pt2.y() - direct_mapped_point.y();
return hypot( diff_x, diff_y );
}
double TeGeometricTransformation::getInverseMappingError(
const TeCoordPair& tie_point, const TeGTParams& params ) const
{
TEAGN_DEBUG_CONDITION( isTransDefined( params ),
"Transformation not defined" )
TeCoord2D inverse_mapped_point;
inverseMap( params, tie_point.pt2, inverse_mapped_point );
double diff_x = tie_point.pt1.x() - inverse_mapped_point.x();
double diff_y = tie_point.pt1.y() - inverse_mapped_point.y();
return hypot( diff_x, diff_y );
}
bool TeGeometricTransformation::recombineSeed( std::vector<unsigned int>& seed,
const unsigned int& seedpos, const unsigned int& elements_nmb )
{
unsigned int seed_size = seed.size();
if( seedpos >= seed_size ) {
return false;
}
if( seed[ seedpos ] >= ( elements_nmb - seed_size + seedpos + 1 ) ) {
if( seedpos == seed_size - 1 ) {
return false;
} else if( seedpos == 0 ) {
return recombineSeed( seed, seedpos + 1, elements_nmb ) ;
} else {
return recombineSeed( seed, seedpos + 1, elements_nmb ) ;
};
} else if( seed[ seedpos ] == 0 ) {
if( seedpos == 0 ) {
seed[ seedpos ] = 1 ;
return recombineSeed( seed, seedpos + 1, elements_nmb );
} else if( seedpos == seed_size - 1 ) {
seed[ seedpos ] = seed[ seedpos - 1 ] + 1;
return true;
} else {
seed[ seedpos ] = seed[ seedpos - 1 ] + 1;
seed[ seedpos + 1 ] = 0;
return recombineSeed( seed, seedpos + 1, elements_nmb );
}
} else {
if( seedpos == seed_size - 1 ) {
seed[ seedpos ] = seed[ seedpos ] + 1;
return true;
} else if( seedpos == 0 ) {
if( recombineSeed( seed, seedpos + 1, elements_nmb ) ) {
return true;
} else {
seed[ seedpos ] = seed[ seedpos ] + 1;
seed[ seedpos + 1 ] = 0;
return recombineSeed( seed, seedpos + 1, elements_nmb );
}
} else {
if( recombineSeed( seed, seedpos + 1, elements_nmb ) ) {
return true;
} else {
seed[ seedpos ] = seed[ seedpos ] + 1;
seed[ seedpos + 1 ] = 0;
return recombineSeed( seed, seedpos + 1, elements_nmb );
}
}
}
}
TeGeometricTransformation* TeGeometricTransformation::DefaultObject(
const TeGTParams& )
{
TEAGN_LOG_AND_THROW( "Trying to create an invalid "
"TeGemetricTransformation instance" );
return 0;
};
bool TeGeometricTransformation::exaustiveOutRemotion(
TeGTParams& params, unsigned int threads_nmb )
{
TEAGN_DEBUG_CONDITION( ( params.out_rem_strat_ ==
TeGTParams::ExaustiveOutRemotion ),
"Inconsistent outliers remotion strategy" )
TEAGN_TRUE_OR_THROW( ( params.max_dmap_error_ >= 0 ),
"Invalid maximum allowed direct mapping error" );
TEAGN_TRUE_OR_THROW( ( params.max_imap_error_ >= 0 ),
"Invalid maximum allowed inverse mapping error" );
/* Initiating seed */
std::vector<unsigned int> comb_seed_vec;
unsigned int req_tie_pts_nmb = getMinRequiredTiePoints();
for( unsigned int comb_seed_vec_index = 0 ;
comb_seed_vec_index < req_tie_pts_nmb ;
++comb_seed_vec_index ) {
comb_seed_vec.push_back( 0 );
}
/* initializing mutexes */
TeMutex comb_seed_vec_mutex;
TeMutex trans_params_mutex;
/* Initializing threads */
TeGTParams best_trans_params;
volatile double best_trans_dmap_error = DBL_MAX;
volatile double best_trans_imap_error = DBL_MAX;
std::vector< TeThreadFunctor::pointer > threads_vector;
TeThreadParameters thread_params;
thread_params.store( "req_tie_pts_nmb", req_tie_pts_nmb );
thread_params.store( "init_trans_params_ptr",
(TeGTParams const*)(¶ms) );
thread_params.store( "best_trans_params_ptr",
&best_trans_params );
thread_params.store( "best_trans_dmap_error_ptr",
&best_trans_dmap_error );
thread_params.store( "best_trans_imap_error_ptr",
&best_trans_imap_error );
thread_params.store( "comb_seed_vec_ptr", &comb_seed_vec );
thread_params.store( "trans_params_mutex_ptr",
&trans_params_mutex );
thread_params.store( "comb_seed_vec_mutex_ptr",
&comb_seed_vec_mutex );
thread_params.store( "geo_trans_ptr",
(TeGeometricTransformation const*)this );
unsigned int thread_index = 0;
for( thread_index = 0 ; thread_index < threads_nmb ;
++thread_index ) {
TeThreadFunctor::pointer aux_thread_ptr(
new TeThreadFunctor );
aux_thread_ptr->setStartFunctPtr( eORThreadEntry );
aux_thread_ptr->setParameters( thread_params );
aux_thread_ptr->start();
threads_vector.push_back( aux_thread_ptr );
}
bool my_return = eORThreadEntry( thread_params );
bool threads_return = true;
for( thread_index = 0 ; thread_index < threads_nmb ;
++thread_index ) {
threads_vector[ thread_index ]->waitToFinish();
threads_return = threads_return &
threads_vector[ thread_index ]->getReturnValue();
}
if( my_return & threads_return ) {
if( best_trans_params.tiepoints_.size() >= req_tie_pts_nmb ) {
params = best_trans_params;
return true;
} else {
return false;
}
} else {
return false;
}
}
bool TeGeometricTransformation::eORThreadEntry(
const TeThreadParameters& params )
{
/* Extracting parameters */
unsigned int req_tie_pts_nmb = 0;
TEAGN_TRUE_OR_THROW( params.retrive( "req_tie_pts_nmb",
req_tie_pts_nmb ), "Missing parameter" );
TeGTParams const* init_trans_params_ptr = 0;
TEAGN_TRUE_OR_THROW( params.retrive( "init_trans_params_ptr",
init_trans_params_ptr ), "Missing parameter" );
TeGTParams* best_trans_params_ptr = 0;
TEAGN_TRUE_OR_THROW( params.retrive( "best_trans_params_ptr",
best_trans_params_ptr ), "Missing parameter" );
double volatile* best_trans_dmap_error_ptr = 0;
TEAGN_TRUE_OR_THROW( params.retrive( "best_trans_dmap_error_ptr",
best_trans_dmap_error_ptr ), "Missing parameter" );
double volatile* best_trans_imap_error_ptr = 0;
TEAGN_TRUE_OR_THROW( params.retrive( "best_trans_imap_error_ptr",
best_trans_imap_error_ptr ), "Missing parameter" );
std::vector<unsigned int>* comb_seed_vec_ptr = 0;
TEAGN_TRUE_OR_THROW( params.retrive( "comb_seed_vec_ptr",
comb_seed_vec_ptr ), "Missing parameter" );
TeMutex* trans_params_mutex_ptr = 0;
TEAGN_TRUE_OR_THROW( params.retrive( "trans_params_mutex_ptr",
trans_params_mutex_ptr ), "Missing parameter" );
TeMutex* comb_seed_vec_mutex_ptr = 0;
TEAGN_TRUE_OR_THROW( params.retrive( "comb_seed_vec_mutex_ptr",
comb_seed_vec_mutex_ptr ), "Missing parameter" );
TeGeometricTransformation const* geo_trans_ptr = 0;
TEAGN_TRUE_OR_THROW( params.retrive( "geo_trans_ptr",
geo_trans_ptr ), "Missing parameter" );
/* Optimized local variables based on the input parameters */
std::vector<unsigned int>& comb_seed_vec =
(*comb_seed_vec_ptr);
TeMutex& comb_seed_vec_mutex = (*comb_seed_vec_mutex_ptr);
const TeGeometricTransformation& geo_trans = (*geo_trans_ptr);
/* Copying some parameters to local variables to avoid
mutex overhead */
trans_params_mutex_ptr->lock();
const TeGTParams initial_trans_params = (*init_trans_params_ptr);
const unsigned int initial_tiepoints_size =
initial_trans_params.tiepoints_.size();
trans_params_mutex_ptr->unLock();
/* Trying to find the best tie-points by building
the transformation with the highest number of
tie-points, but with an acceptable mapping error */
TeGTParams local_best_params;
double local_best_params_dmap_error = DBL_MAX;
double local_best_params_imap_error = DBL_MAX;
TeGTParams curr_params = initial_trans_params;
double curr_params_dmap_error = DBL_MAX;
double curr_params_imap_error = DBL_MAX;
TeGTParams cp_plus_new_point;
double cp_plus_new_point_dmap_error = DBL_MAX;
double cp_plus_new_point_imap_error = DBL_MAX;
unsigned int tiepoints_index = 0;
bool point_already_present = false;
bool seed_recombined = true;
unsigned int comb_seed_vec_index_2 = 0;
unsigned int comb_seed_vec_index_3 = 0;
while( seed_recombined ) {
/* trying to recombine seed */
comb_seed_vec_mutex.lock();
seed_recombined = recombineSeed( comb_seed_vec, 0,
initial_tiepoints_size );
comb_seed_vec_mutex.unLock();
if( seed_recombined ) {
/* Extracting tie-points from the original vector */
curr_params.tiepoints_.clear();
for( comb_seed_vec_index_2 = 0 ;
comb_seed_vec_index_2 < req_tie_pts_nmb ;
++comb_seed_vec_index_2 ) {
curr_params.tiepoints_.push_back(
initial_trans_params.tiepoints_[ comb_seed_vec[
comb_seed_vec_index_2 ] - 1 ] );
}
/* Trying to generate a valid transformation */
if( geo_trans.computeParameters( curr_params ) ) {
curr_params_dmap_error = geo_trans.getDirectMappingError(
curr_params );
curr_params_imap_error = geo_trans.getInverseMappingError(
curr_params );
if( ( initial_trans_params.max_dmap_error_ >=
curr_params_dmap_error ) &&
( initial_trans_params.max_imap_error_ >=
curr_params_imap_error ) ) {
/* Trying to insert more tie-points into current
transformation */
for( tiepoints_index = 0 ; tiepoints_index <
initial_tiepoints_size ; ++tiepoints_index ) {
/* Verifying if the current tie-point is already
present */
point_already_present = false;
for( comb_seed_vec_index_3 = 0 ;
comb_seed_vec_index_3 < req_tie_pts_nmb ;
++comb_seed_vec_index_3 ) {
if( tiepoints_index == (
comb_seed_vec[ comb_seed_vec_index_3 ] - 1 ) ) {
point_already_present = true;
break;
}
}
if( ! point_already_present ) {
cp_plus_new_point = curr_params;
cp_plus_new_point.tiepoints_.push_back(
initial_trans_params.tiepoints_[ tiepoints_index ] );
/* Verifying if the new tie-point insertion does
not generate an invalid transformation */
if( geo_trans.computeParameters( cp_plus_new_point ) ) {
cp_plus_new_point_dmap_error =
geo_trans.getDirectMappingError( cp_plus_new_point );
cp_plus_new_point_imap_error =
geo_trans.getInverseMappingError( cp_plus_new_point );
if( ( cp_plus_new_point_dmap_error <=
initial_trans_params.max_dmap_error_ ) &&
( cp_plus_new_point_imap_error <=
initial_trans_params.max_imap_error_ ) ) {
curr_params = cp_plus_new_point;
curr_params_dmap_error =
cp_plus_new_point_dmap_error;
curr_params_imap_error =
cp_plus_new_point_imap_error;
}
}
}
}
/* A valid transformation was generated, now
verifying
if the number of tie-poits is greater then the current
thread local best transformation.
*/
if( curr_params.tiepoints_.size() >=
local_best_params.tiepoints_.size() ) {
if( ( curr_params_dmap_error <
local_best_params_dmap_error ) &&
( curr_params_imap_error <
local_best_params_imap_error ) ) {
local_best_params = curr_params;
local_best_params_dmap_error = curr_params_dmap_error;
local_best_params_imap_error = curr_params_imap_error;
}
}
}
} //if( geo_trans.computeParameters( curr_params ) )
} //if( seed_recombined )
} //while( seed_recombined )
/* A valid local thread transformation was generated, now
verifying
if the error is smaller then the current
global transformation.
*/
if( local_best_params.tiepoints_.size() >= req_tie_pts_nmb ) {
trans_params_mutex_ptr->lock();
if( local_best_params.tiepoints_.size() >=
best_trans_params_ptr->tiepoints_.size() ) {
if( ( local_best_params_dmap_error <
(*best_trans_dmap_error_ptr) ) &&
( local_best_params_imap_error <
(*best_trans_imap_error_ptr) ) ) {
(*best_trans_params_ptr) = local_best_params;
(*best_trans_dmap_error_ptr) = local_best_params_dmap_error;
(*best_trans_imap_error_ptr) = local_best_params_imap_error;
}
}
trans_params_mutex_ptr->unLock();
}
return true;
}
bool TeGeometricTransformation::lWOutRemotion(
TeGTParams& external_params )
{
TEAGN_DEBUG_CONDITION( ( external_params.out_rem_strat_ ==
TeGTParams::LWOutRemotion ),
"Inconsistent outliers remotion strategy" )
TEAGN_TRUE_OR_THROW( ( external_params.tiePointsWeights_.size() ?
( external_params.tiePointsWeights_.size() ==
external_params.tiepoints_.size() ) : true ),
"The tie-points vector size do not match the tie-points "
"weights vector size" )
TEAGN_TRUE_OR_THROW( ( external_params.max_dmap_error_ >= 0 ),
"Invalid maximum allowed direct mapping error" );
TEAGN_TRUE_OR_THROW( ( external_params.max_imap_error_ >= 0 ),
"Invalid maximum allowed inverse mapping error" );
TEAGN_TRUE_OR_THROW( ( external_params.max_dmap_rmse_ >= 0 ),
"Invalid maximum allowed direct mapping RMSE" );
TEAGN_TRUE_OR_THROW( ( external_params.max_imap_rmse_ >= 0 ),
"Invalid maximum allowed inverse mapping RMSE" );
const unsigned int req_tie_pts_nmb = getMinRequiredTiePoints();
// Normalizing tie-points weights
const bool useTPWeights = ( external_params.tiePointsWeights_.size() ) ?
true : false;
TEAGN_TRUE_OR_THROW( normalizeTPWeights(
external_params.tiePointsWeights_ ),
"Error normalizing tie-points weights" );
if( external_params.tiepoints_.size() == req_tie_pts_nmb ) {
return computeParameters( external_params );
} else if( external_params.tiepoints_.size() > req_tie_pts_nmb ) {
/* Global vars */
const double max_dmap_error =
external_params.max_dmap_error_;
const double max_imap_error =
external_params.max_imap_error_;
const double max_dmap_rmse =
external_params.max_dmap_rmse_;
const double max_imap_rmse =
external_params.max_imap_rmse_;
/* Computing the initial global transformation */
if( ! computeParameters( external_params ) ) {
return false;
}
if( ( getDirectMappingError( external_params )
<= max_dmap_error ) &&
( getInverseMappingError( external_params )
<= max_imap_error ) &&
( getDMapRMSE( external_params )
<= max_dmap_rmse ) &&
( getIMapRMSE( external_params )
<= max_imap_rmse ) ) {
/* This transformation has no outliers */
return true;
}
/* Iterating over the current transformation tie-points */
TeGTParams best_params;
double best_params_dmap_rmse = DBL_MAX;
double best_params_imap_rmse = DBL_MAX;
double best_params_dmap_error = DBL_MAX;
double best_params_imap_error = DBL_MAX;
bool transformation_not_updated = false;
unsigned int iterations_remainning = (unsigned int)
external_params.tiepoints_.size();
std::vector< TPDataNode > norm_err_vec;
std::list< ExcTPDataNode > exc_tp_list;
TeGTParams iteration_params = external_params;
TeCoordPair excluded_tp;
double excluded_tp_weight = 0;
ExcTPDataNode dummy_exctpdata;
while( ( iteration_params.tiepoints_.size() >
req_tie_pts_nmb ) && iterations_remainning )
{
unsigned int iter_tps_nmb = (unsigned int)
iteration_params.tiepoints_.size();
transformation_not_updated = true;
/* Updating the normalized error map */
updateTPErrVec( iteration_params, useTPWeights, norm_err_vec );
/* Generating all possible transformations without
each tie-point, starting with the worse point */
for( int norm_err_vec_idx = ((int)norm_err_vec.size()) - 1 ;
( norm_err_vec_idx > ( -1 ) ) ; --norm_err_vec_idx )
{
const unsigned int& cur_candtp_idx =
norm_err_vec[ norm_err_vec_idx ].tpindex_;
TEAGN_DEBUG_CONDITION( ( cur_candtp_idx <
iteration_params.tiepoints_.size() ), "Invalid index" )
/* Generating a transformation parameters without the
current tie-point (bigger error)*/
TeGTParams new_iteration_params = iteration_params;
new_iteration_params.tiepoints_.clear();
new_iteration_params.tiePointsWeights_.clear();
new_iteration_params.direct_parameters_.Clear();
new_iteration_params.inverse_parameters_.Clear();
for( unsigned int tpindex2 = 0 ; tpindex2 < iter_tps_nmb ;
++tpindex2 )
{
if( cur_candtp_idx != tpindex2 )
{
new_iteration_params.tiepoints_.push_back(
iteration_params.tiepoints_[ tpindex2 ] );
if( useTPWeights )
{
new_iteration_params.tiePointsWeights_.push_back(
iteration_params.tiePointsWeights_[ tpindex2 ] );
}
}
}
/* Trying to generate a transformation without the current
candidate tie-point for exclusion */
if( computeParameters( new_iteration_params ) )
{
double new_it_dmap_rmse =
getDMapRMSE( new_iteration_params );
double new_it_imap_rmse =
getIMapRMSE( new_iteration_params );
if( ( best_params_dmap_rmse > new_it_dmap_rmse ) &&
( best_params_imap_rmse > new_it_imap_rmse ) )
{
double new_it_dmap_error =
getDirectMappingError( new_iteration_params );
double new_it_imap_error =
getInverseMappingError( new_iteration_params );
excluded_tp = iteration_params.tiepoints_[ cur_candtp_idx ];
if( useTPWeights )
{
excluded_tp_weight = iteration_params.tiePointsWeights_[
cur_candtp_idx ];
}
/* Trying to insert back other tie-points excluded
before */
if( exc_tp_list.size() > 0 )
{
/* Updating the excluded tie points errors map */
updateExcTPErrList( new_iteration_params, useTPWeights,
exc_tp_list );
/* Iterating over the excluded tps */
std::list< ExcTPDataNode >::iterator
exc_tps_list_it = exc_tp_list.begin();
std::list< ExcTPDataNode >::iterator
exc_tps_list_it_end = exc_tp_list.end();
while( exc_tps_list_it != exc_tps_list_it_end )
{
const ExcTPDataNode& curr_exc_tp_data =
*exc_tps_list_it;
/* Does this tp has direct and inverse errors
smaller than the current new_iteration_params ?? */
if( ( curr_exc_tp_data.dmap_error_ <=
new_it_dmap_error ) &&
( curr_exc_tp_data.imap_error_ <=
new_it_imap_error ) )
{
/* Trying to generate a trasformation with
this point */
TeGTParams new_iteration_params_plus1tp =
new_iteration_params;
new_iteration_params.tiepoints_.push_back(
curr_exc_tp_data.tp_ );
if( useTPWeights )
{
new_iteration_params.tiePointsWeights_.push_back(
curr_exc_tp_data.tp_weight_ );
}
if( computeParameters(
new_iteration_params_plus1tp ) )
{
double newp1tp_dmap_rmse = getDMapRMSE(
new_iteration_params_plus1tp );
double newp1tp_imap_rmse = getIMapRMSE(
new_iteration_params_plus1tp );
if( ( new_it_dmap_rmse >= newp1tp_dmap_rmse ) &&
( new_it_imap_rmse >= newp1tp_imap_rmse ) )
{
new_iteration_params =
new_iteration_params_plus1tp;
new_it_dmap_error = getDirectMappingError(
new_iteration_params_plus1tp );
new_it_imap_error = getInverseMappingError(
new_iteration_params_plus1tp );
new_it_dmap_rmse = newp1tp_dmap_rmse;
new_it_imap_rmse = newp1tp_imap_rmse;
exc_tp_list.erase( exc_tps_list_it );
updateExcTPErrList( new_iteration_params,
useTPWeights, exc_tp_list );
exc_tps_list_it = exc_tp_list.begin();
exc_tps_list_it_end = exc_tp_list.end();
}
else
{
++exc_tps_list_it;
}
}
else
{
++exc_tps_list_it;
}
}
else
{
++exc_tps_list_it;
}
}
}
/* Updating the best transformation parameters */
best_params_dmap_error = new_it_dmap_error;
best_params_imap_error = new_it_imap_error;
best_params_dmap_rmse = new_it_dmap_rmse;
best_params_imap_rmse = new_it_imap_rmse;
best_params = new_iteration_params;
/* Updating the next iteration parameters */
iteration_params = new_iteration_params;
transformation_not_updated = false;
/* Putting the excluded tie-point into the
excluded tie-points map */
dummy_exctpdata.tp_ = excluded_tp;
if( useTPWeights )
{
dummy_exctpdata.tp_weight_ = excluded_tp_weight;
}
exc_tp_list.push_back( dummy_exctpdata );
/* break the current tie-points loop */
break;
} //if( ( best_params_dmap_error > new_it_dmap_error ) &&
} //if( computeParameters( new_iteration_params ) ) {
}
if( transformation_not_updated ) {
/* There is no way to improve the current transformation
since all tie-points were tested */
break; /* break the iterations loop */
} else {
if( ( max_dmap_error >= best_params_dmap_error ) &&
( max_imap_error >= best_params_imap_error ) &&
( max_dmap_rmse >= best_params_dmap_rmse ) &&
( max_imap_rmse >= best_params_imap_rmse ) ) {
/* A valid transformation was found */
break;
}
}
--iterations_remainning;
}//while( params.tiepoints_.size() > req_tie_pts_nmb ) {
if( ( best_params.tiepoints_.size() >= req_tie_pts_nmb ) &&
( max_dmap_error >= best_params_dmap_error ) &&
( max_imap_error >= best_params_imap_error ) &&
( max_dmap_rmse >= best_params_dmap_rmse ) &&
( max_imap_rmse >= best_params_imap_rmse ) ) {
external_params = best_params;
return true;
} else {
return false;
}
}
return false;
}
void TeGeometricTransformation::updateExcTPErrList(
const TeGTParams& params,
bool useTPWeights,
std::list< ExcTPDataNode >& exc_tp_list )
const
{
if( exc_tp_list.size() > 0 )
{
TEAGN_DEBUG_CONDITION( ( useTPWeights ?
( params.tiePointsWeights_.size() ==
params.tiepoints_.size() ) : true ),
"The tie-points vector size do not match the tie-points "
"weights vector size" )
/* Updating the new direct and inverse mapping errors */
std::list< ExcTPDataNode >::iterator tp_list_it =
exc_tp_list.begin();
std::list< ExcTPDataNode >::iterator tp_list_it_end =
exc_tp_list.end();
double dmap_err_min = DBL_MAX;
double dmap_err_max = (-1.0) * DBL_MAX;
double imap_err_min = DBL_MAX;
double imap_err_max = (-1.0) * DBL_MAX;
while( tp_list_it != tp_list_it_end )
{
ExcTPDataNode& curr_node = *tp_list_it;
const TeCoordPair& cur_ex_tp = curr_node.tp_;
curr_node.dmap_error_ = getDirectMappingError( cur_ex_tp,
params );
curr_node.imap_error_ = getInverseMappingError( cur_ex_tp,
params );
if( dmap_err_min > curr_node.dmap_error_ ) {
dmap_err_min = curr_node.dmap_error_;
}
if( dmap_err_max < curr_node.dmap_error_ ) {
dmap_err_max = curr_node.dmap_error_;
}
if( imap_err_min > curr_node.imap_error_ ) {
imap_err_min = curr_node.imap_error_;
}
if( imap_err_max < curr_node.imap_error_ ) {
imap_err_max = curr_node.imap_error_;
}
++tp_list_it;
}
double dmap_err_range = dmap_err_max - dmap_err_min;
double imap_err_range = imap_err_max - imap_err_min;
/* Updating the normalized error */
tp_list_it = exc_tp_list.begin();
if( ( dmap_err_range == 0.0 ) &&
( imap_err_range == 0.0 ) )
{
while( tp_list_it != tp_list_it_end )
{
tp_list_it->tp_error_ = 0.0;
++tp_list_it;
}
}
else if( dmap_err_range == 0.0 )
{
if( useTPWeights )
{
while( tp_list_it != tp_list_it_end )
{
TEAGN_DEBUG_CONDITION( tp_list_it->tp_weight_ > 0.0,
"Invalid tie-point weight" )
TEAGN_DEBUG_CONDITION( tp_list_it->tp_weight_ <= 1.0,
"Invalid tie-point weight" )
tp_list_it->tp_error_ =
(
(
tp_list_it->imap_error_ - imap_err_min
)
/ ( imap_err_range * tp_list_it->tp_weight_ )
);
++tp_list_it;
}
}
else
{
while( tp_list_it != tp_list_it_end )
{
tp_list_it->tp_error_ =
(
(
tp_list_it->imap_error_ - imap_err_min
)
/ imap_err_range
);
++tp_list_it;
}
}
}
else if( imap_err_range == 0.0 )
{
if( useTPWeights )
{
while( tp_list_it != tp_list_it_end )
{
TEAGN_DEBUG_CONDITION( tp_list_it->tp_weight_ > 0.0,
"Invalid tie-point weight" )
TEAGN_DEBUG_CONDITION( tp_list_it->tp_weight_ <= 1.0,
"Invalid tie-point weight" )
tp_list_it->tp_error_ =
(
(
tp_list_it->dmap_error_ - dmap_err_min
)
/ ( dmap_err_range * tp_list_it->tp_weight_ )
);
++tp_list_it;
}
}
else
{
while( tp_list_it != tp_list_it_end )
{
tp_list_it->tp_error_ =
(
(
tp_list_it->dmap_error_ - dmap_err_min
)
/ dmap_err_range
);
++tp_list_it;
}
}
}
else
{
if( useTPWeights )
{
while( tp_list_it != tp_list_it_end )
{
TEAGN_DEBUG_CONDITION( tp_list_it->tp_weight_ > 0.0,
"Invalid tie-point weight" )
TEAGN_DEBUG_CONDITION( tp_list_it->tp_weight_ <= 1.0,
"Invalid tie-point weight" )
tp_list_it->tp_error_ =
(
(
(
tp_list_it->dmap_error_ - dmap_err_min
)
/ dmap_err_range
)
+
(
(
tp_list_it->imap_error_ - imap_err_min
)
/ imap_err_range
)
) / ( 2.0 * tp_list_it->tp_weight_ );
++tp_list_it;
}
}
else
{
while( tp_list_it != tp_list_it_end )
{
tp_list_it->tp_error_ =
(
(
(
tp_list_it->dmap_error_ - dmap_err_min
)
/ dmap_err_range
)
+
(
(
tp_list_it->imap_error_ - imap_err_min
)
/ imap_err_range
)
);
++tp_list_it;
}
}
}
/* Sorting list */
exc_tp_list.sort();
/* printing */
/*
tp_list_it = exc_tp_list.begin();
tp_list_it_end = exc_tp_list.end();
std::cout << std::endl << "Excluded Tie points list" << std::endl;
while( tp_list_it != tp_list_it_end )
{
const ExcTPDataNode& node = *tp_list_it;
std::cout << node.norm_error_ << " " <<
" [" + Te2String( node.tp_.pt1.x(),2 ) + "," +
Te2String( node.tp_.pt1.y(),2 ) + "-" +
Te2String( node.tp_.pt2.x(),2 ) + "," +
Te2String( node.tp_.pt2.y(),2 ) + "]"
<< std::endl;
++tp_list_it;
}
std::cout << std::endl;
*/
}
}
void TeGeometricTransformation::updateTPErrVec(
const TeGTParams& params, bool useTPWeights,
std::vector< TPDataNode >& errvec ) const
{
TEAGN_DEBUG_CONDITION( ( useTPWeights ?
( params.tiePointsWeights_.size() ==
params.tiepoints_.size() ) : true ),
"The tie-points vector size do not match the tie-points "
"weights vector size" )
/* Calculating the two mapping errors */
const unsigned int iter_tps_nmb = (unsigned int)
params.tiepoints_.size();
errvec.clear();
double dmap_err_vec_min = DBL_MAX;
double dmap_err_vec_max = ( -1.0 ) * dmap_err_vec_min;
double imap_err_vec_min = DBL_MAX;
double imap_err_vec_max = ( -1.0 ) * imap_err_vec_min;
const TPDataNode dummy_struct;
for( unsigned int par_tps_vec_idx = 0 ; par_tps_vec_idx < iter_tps_nmb ;
++par_tps_vec_idx )
{
const TeCoordPair& cur_tp = params.tiepoints_[
par_tps_vec_idx ];
errvec.push_back( dummy_struct );
TPDataNode& newNode = errvec[ errvec.size() - 1 ];
newNode.tpindex_ = par_tps_vec_idx;
newNode.dmap_error_ = getDirectMappingError( cur_tp,
params );
newNode.imap_error_ = getInverseMappingError( cur_tp,
params );
if( dmap_err_vec_min > newNode.dmap_error_ ) {
dmap_err_vec_min = newNode.dmap_error_;
}
if( dmap_err_vec_max < newNode.dmap_error_ ) {
dmap_err_vec_max = newNode.dmap_error_;
}
if( imap_err_vec_min > newNode.imap_error_ ) {
imap_err_vec_min = newNode.imap_error_;
}
if( imap_err_vec_max < newNode.imap_error_ ) {
imap_err_vec_max = newNode.imap_error_;
}
}
const double dmap_err_vec_range =
dmap_err_vec_max - dmap_err_vec_min;
const double imap_err_vec_range =
imap_err_vec_max - imap_err_vec_min;
TEAGN_DEBUG_CONDITION( dmap_err_vec_range >= 0, "Invalid range" )
TEAGN_DEBUG_CONDITION( imap_err_vec_range >= 0, "Invalid range" )
const std::vector< double >& tpwVec = params.tiePointsWeights_;
/* Updating normalized mapping errors */
if( ( dmap_err_vec_range == 0.0 ) && ( imap_err_vec_range == 0.0 ) )
{
for( unsigned int errvec_idx = 0 ; errvec_idx < iter_tps_nmb ;
++errvec_idx )
{
errvec[ errvec_idx ].tp_error_ = 0;
}
}
else if( dmap_err_vec_range == 0.0 )
{
for( unsigned int errvec_idx = 0 ; errvec_idx < iter_tps_nmb ;
++errvec_idx )
{
TPDataNode& curr_elem = errvec[ errvec_idx ];
if( useTPWeights )
{
TEAGN_DEBUG_CONDITION( tpwVec[ errvec_idx ] > 0.0,
"Invalid tie-point weight" )
TEAGN_DEBUG_CONDITION( tpwVec[ errvec_idx ] <= 1.0,
"Invalid tie-point weight" )
curr_elem.tp_error_ =
(
(
curr_elem.imap_error_ -
imap_err_vec_min
)
/ ( imap_err_vec_range * tpwVec[ errvec_idx ] )
);
}
else
{
curr_elem.tp_error_ =
(
(
curr_elem.imap_error_ -
imap_err_vec_min
)
/ imap_err_vec_range
);
}
}
}
else if( imap_err_vec_range == 0.0 )
{
for( unsigned int errvec_idx = 0 ; errvec_idx < iter_tps_nmb ;
++errvec_idx )
{
TPDataNode& curr_elem = errvec[ errvec_idx ];
if( useTPWeights )
{
TEAGN_DEBUG_CONDITION( tpwVec[ errvec_idx ] > 0.0,
"Invalid tie-point weight" )
TEAGN_DEBUG_CONDITION( tpwVec[ errvec_idx ] <= 1.0,
"Invalid tie-point weight" )
curr_elem.tp_error_ =
(
(
curr_elem.dmap_error_ -
dmap_err_vec_min
)
/ ( dmap_err_vec_range * tpwVec[ errvec_idx ] )
);
}
else
{
curr_elem.tp_error_ =
(
(
curr_elem.dmap_error_ -
dmap_err_vec_min
)
/ dmap_err_vec_range
);
}
}
}
else
{
for( unsigned int errvec_idx = 0 ; errvec_idx < iter_tps_nmb ;
++errvec_idx )
{
TPDataNode& curr_elem = errvec[ errvec_idx ];
if( useTPWeights )
{
TEAGN_DEBUG_CONDITION( tpwVec[ errvec_idx ] > 0.0,
"Invalid tie-point weight" )
TEAGN_DEBUG_CONDITION( tpwVec[ errvec_idx ] <= 1.0,
"Invalid tie-point weight" )
curr_elem.tp_error_ =
(
(
(
curr_elem.dmap_error_ -
dmap_err_vec_min
)
/ dmap_err_vec_range
)
+
(
(
curr_elem.imap_error_ -
imap_err_vec_min
)
/ imap_err_vec_range
)
) / ( 2.0 * tpwVec[ errvec_idx ] );
}
else
{
curr_elem.tp_error_ =
(
(
curr_elem.dmap_error_ -
dmap_err_vec_min
)
/ dmap_err_vec_range
)
+
(
(
curr_elem.imap_error_ -
imap_err_vec_min
)
/ imap_err_vec_range
);
}
}
}
sort( errvec.begin(), errvec.end() );
/* printing */
/*
std::cout << std::endl << "Tie points error vector" << std::endl;
for( unsigned int errvec_idx = 0 ; errvec_idx < iter_tps_nmb ;
++errvec_idx )
{
const unsigned int& tp_pars_vec_idx = errvec[ errvec_idx ].tpindex_;
const TeCoordPair& currtp = params.tiepoints_[
tp_pars_vec_idx ];
std::cout << errvec[ errvec_idx ].norm_error_ << " " <<
" [" + Te2String( currtp.pt1.x(),2 ) + "," +
Te2String( currtp.pt1.y(),2 ) + "-" +
Te2String( currtp.pt2.x(),2 ) + "," +
Te2String( currtp.pt2.y(),2 ) + "]"
<< std::endl;
}
*/
}
bool TeGeometricTransformation::ransacRemotion(
const TeGTParams& inputParams, TeGTParams& outputParams ) const
{
TEAGN_DEBUG_CONDITION( ( inputParams.out_rem_strat_ ==
TeGTParams::RANSACRemotion ),
"Inconsistent outliers remotion strategy" )
TEAGN_TRUE_OR_THROW( ( inputParams.max_dmap_error_ >= 0 ),
"Invalid maximum allowed direct mapping error" );
TEAGN_TRUE_OR_THROW( ( inputParams.max_imap_error_ >= 0 ),
"Invalid maximum allowed inverse mapping error" );
TEAGN_TRUE_OR_THROW( ( inputParams.max_dmap_rmse_ >= 0 ),
"Invalid maximum allowed direct mapping RMSE" );
TEAGN_TRUE_OR_THROW( ( inputParams.max_imap_rmse_ >= 0 ),
"Invalid maximum allowed inverse mapping RMSE" );
TEAGN_TRUE_OR_THROW( ( inputParams.tiePointsWeights_.size() ?
( inputParams.tiePointsWeights_.size() ==
inputParams.tiepoints_.size() ) : true ),
"The tie-points vector size do not match the tie-points "
"weights vector size" )
// Checking the number of required tie-points
const unsigned int reqTPsNmb = getMinRequiredTiePoints();
const unsigned int inputTPNmb = (unsigned int)inputParams.tiepoints_.size();
if( inputTPNmb < reqTPsNmb )
{
return false;
}
else
{
// generating the tie-points accumulated probabilities map
// with positive values up to RAND_MAX + 1
std::map< double, TeCoordPair > tpsMap;
{
if( inputParams.tiePointsWeights_.size() > 0 )
{
// finding normalization factors
double originalWSum = 0.0;
unsigned int tpIdx = 0;
for( tpIdx = 0 ; tpIdx < inputTPNmb ; ++tpIdx )
{
originalWSum += inputParams.tiePointsWeights_[ tpIdx ];
}
TEAGN_TRUE_OR_THROW( originalWSum > 0.0,
"Invalid tie-points weighs sum" );
// map fill
double newWSum = 0.0;
double newW = 0.0;
for( tpIdx = 0 ; tpIdx < inputTPNmb ; ++tpIdx )
{
newW = inputParams.tiePointsWeights_[ tpIdx ];
newW /= originalWSum;
newW *= ((double)RAND_MAX) + 1.0;
newWSum += newW;
tpsMap[ newWSum ] = inputParams.tiepoints_[ tpIdx ];
}
}
else
{
double wSum = 0;
const double increment = ( ((double)RAND_MAX) + 1.0 ) /
((double)inputParams.tiepoints_.size());
for( unsigned int tpIdx = 0 ; tpIdx < inputTPNmb ; ++tpIdx )
{
wSum += increment;
tpsMap[ wSum ] = inputParams.tiepoints_[ tpIdx ];
}
}
/*
std::map< double, TeCoordPair >::const_iterator mapIt =
tpsMap.begin();
while( mapIt != tpsMap.end() )
{
std::cout << " [" << mapIt->first
<< "," << mapIt->second.pt1.x_
<< "," << mapIt->second.pt1.y_
<< "," << mapIt->second.pt2.x_
<< "," << mapIt->second.pt2.y_
<< "]";
++mapIt;
}
*/
}
// The Maximum Number of iterations
const RansacItCounterT maxIterations = std::numeric_limits< RansacItCounterT >::max();
// Transformation maximum errors
const double maxDMapErr = inputParams.max_dmap_error_;
const double maxIMapErr = inputParams.max_imap_error_;
const double maxDRMSE = inputParams.max_dmap_rmse_;
const double maxIRMSE = inputParams.max_imap_rmse_;
// This is the maximum number of allowed consecutive invalid
// consensus sets (no transformation generated)
const RansacItCounterT maxConsecutiveInvalidBaseSets = (
((RansacItCounterT)inputTPNmb) *
((RansacItCounterT)reqTPsNmb) * ((RansacItCounterT)reqTPsNmb) *
((RansacItCounterT)reqTPsNmb) );
// This is the minimum number of consecutive valid
// consensus sets (with the same number of tie-points)
const RansacItCounterT minConsecutiveValidBaseSets =
( ((RansacItCounterT)inputTPNmb) * ((RansacItCounterT)reqTPsNmb) );
// If the difference between consecutive valid sets RMSE drops
// below this value the process is stoped.
const double consecValidBaseSetsDRMSEThr = MIN( maxDMapErr / 2.0,
maxDRMSE );
const double consecValidBaseSetsIRMSEThr = MIN( maxIMapErr / 2.0,
maxIRMSE );
TeGTParams bestParams;
bestParams.transformation_name_ = inputParams.transformation_name_;
double bestParamsMaxDMapErr = maxDMapErr;
double bestParamsMaxIMapErr = maxIMapErr;
double bestParamsDRMSE = maxDRMSE;
double bestParamsIRMSE = maxIRMSE;
TeGTParams consensusSetParams;
consensusSetParams.transformation_name_ = inputParams.transformation_name_;
double consensusSetMaxDMapErr = 0;
double consensusSetMaxIMapErr = 0;
double consensusSetDRMSE = 0;
double consensusSetIRMSE = 0;
double consensusSetIRMSEDiff = 0; // diff against bestParamsIRMSE
double consensusSetDRMSEDiff = 0; // diff against bestParamsDRMSE
double tiePointDMapErr = 0;
double tiePointIMapErr = 0;
std::map< double, TeCoordPair >::const_iterator tpsMapIt;
unsigned int inputTpIdx = 0;
RansacItCounterT selectedTpsCounter = 0;
std::vector< TeCoordPair* > selectedTpsPtrsVec;
selectedTpsPtrsVec.resize( reqTPsNmb, 0 );
unsigned int selectedTpsPtrsVecIdx = 0;
bool selectedTpsNotSelectedBefore = false;
// RANSAC main loop
RansacItCounterT consecutiveInvalidBaseSetsLeft =
maxConsecutiveInvalidBaseSets;
RansacItCounterT iterationsLeft = maxIterations;
RansacItCounterT consecutiveValidBaseSets = 0;
while( iterationsLeft )
{
// Trying to find a valid base consensus set
// with the minimum number of required tie-points
// Random selecting n distinc tpoints from the original set
consensusSetParams.tiepoints_.clear();
selectedTpsCounter = 0;
while( selectedTpsCounter < reqTPsNmb )
{
tpsMapIt = tpsMap.upper_bound( (double)rand() );
TEAGN_DEBUG_CONDITION( tpsMapIt != tpsMap.end(),
"Tie-point random selection error" );
// Checking if this TP was already selected before
selectedTpsNotSelectedBefore = true;
for( selectedTpsPtrsVecIdx = 0 ; selectedTpsPtrsVecIdx <
selectedTpsCounter ; ++selectedTpsPtrsVecIdx )
{
if( selectedTpsPtrsVec[ selectedTpsPtrsVecIdx ] ==
&(tpsMapIt->second) )
{
selectedTpsNotSelectedBefore = false;
break;
}
}
if( selectedTpsNotSelectedBefore )
{
consensusSetParams.tiepoints_.push_back( tpsMapIt->second );
}
++selectedTpsCounter;
}
/* Trying to generate a valid base consensus transformation with the
selected points */
if( computeParameters( consensusSetParams ) )
{
// consecutiveInvalidBaseSetsLeft = maxConsecutiveInvalidBaseSets;
// finding those tie-points in agreement with the generated
// consensus basic transformation
consensusSetParams.tiepoints_.clear();
consensusSetDRMSE = 0;
consensusSetIRMSE = 0;
consensusSetMaxDMapErr = 0;
consensusSetMaxIMapErr = 0;
for( inputTpIdx = 0 ; inputTpIdx < inputTPNmb ; ++inputTpIdx )
{
const TeCoordPair& curTP = inputParams.tiepoints_[ inputTpIdx ];
tiePointDMapErr = getDirectMappingError( curTP, consensusSetParams );
tiePointIMapErr = getInverseMappingError( curTP, consensusSetParams );
if( ( tiePointDMapErr < maxDMapErr ) &&
( tiePointIMapErr < maxIMapErr ) )
{
consensusSetParams.tiepoints_.push_back( curTP );
consensusSetDRMSE += ( tiePointDMapErr * tiePointDMapErr );
consensusSetIRMSE += ( tiePointIMapErr * tiePointIMapErr );
if( tiePointDMapErr > consensusSetMaxDMapErr )
consensusSetMaxDMapErr = tiePointDMapErr;
if( tiePointIMapErr > consensusSetMaxIMapErr )
consensusSetMaxIMapErr = tiePointIMapErr;
}
}
consensusSetDRMSE = sqrt( consensusSetDRMSE );
consensusSetIRMSE = sqrt( consensusSetIRMSE );
consensusSetIRMSEDiff = ABS( bestParamsIRMSE - consensusSetIRMSE );
consensusSetDRMSEDiff = ABS( bestParamsDRMSE - consensusSetDRMSE );
/* Is this an acceptable consensus set ?? */
if( ( consensusSetDRMSE < maxDRMSE ) &&
( consensusSetIRMSE < maxIRMSE ) &&
( consensusSetMaxDMapErr < maxDMapErr ) &&
( consensusSetMaxIMapErr < maxIMapErr ) )
{
// Is this consensus set better than the current better one ??
// (by using the number of tie-points as parameter
// since we are interested in consensus sets with
// the higher number of tie-points
if( consensusSetParams.tiepoints_.size() >
bestParams.tiepoints_.size() )
{
bestParams = consensusSetParams;
bestParamsDRMSE = consensusSetDRMSE;
bestParamsIRMSE = consensusSetIRMSE;
bestParamsMaxDMapErr = consensusSetMaxDMapErr;
bestParamsMaxIMapErr = consensusSetMaxIMapErr;
consecutiveValidBaseSets = 0;
consecutiveInvalidBaseSetsLeft = maxConsecutiveInvalidBaseSets;
}
else if(
(
consensusSetParams.tiepoints_.size() ==
bestParams.tiepoints_.size()
)
&&
( consensusSetDRMSE < bestParamsDRMSE )
&&
( consensusSetIRMSE < bestParamsIRMSE )
)
{
bestParams = consensusSetParams;
bestParamsDRMSE = consensusSetDRMSE;
bestParamsIRMSE = consensusSetIRMSE;
bestParamsMaxDMapErr = consensusSetMaxDMapErr;
bestParamsMaxIMapErr = consensusSetMaxIMapErr;
++consecutiveValidBaseSets;
consecutiveInvalidBaseSetsLeft = maxConsecutiveInvalidBaseSets;
}
else
{
// This consensus set isn't good enough
--consecutiveInvalidBaseSetsLeft;
}
}
else
{
/* This isn't an acceptable consensus */
--consecutiveInvalidBaseSetsLeft;
}
}
else
{
// decrement the number of remaining consecutive
// invalid base sets left
--consecutiveInvalidBaseSetsLeft;
}
if( consecutiveInvalidBaseSetsLeft == 0 ) break;
if( ( consecutiveValidBaseSets > minConsecutiveValidBaseSets ) &&
( consensusSetDRMSEDiff < consecValidBaseSetsDRMSEThr ) &&
( consensusSetIRMSEDiff < consecValidBaseSetsIRMSEThr ) )
{
break;
}
--iterationsLeft;
}
if( bestParams.tiepoints_.size() >= reqTPsNmb )
{
outputParams = bestParams;
return true;
}
else
{
return false;
}
}
}
bool TeGeometricTransformation::normalizeTPWeights(
std::vector< double >& tpWeights ) const
{
const unsigned int size = (unsigned int)tpWeights.size();
if( size )
{
double wSum = 0;
unsigned int idx = 0;
for( ; idx < size ; ++idx )
{
if( tpWeights[ idx ] < 0.0 ) return false;
wSum += tpWeights[ idx ];
}
if( wSum > 0.0 )
{
for( idx = 0 ; idx < size ; ++idx )
{
tpWeights[ idx ] /= wSum;
}
}
}
return true;
}
|
[
"[email protected]@58180da6-ba8b-8960-36a5-00cc02a3ddec"
] |
[
[
[
1,
1814
]
]
] |
0a54bcb7b2aaceda37fc37d8330e8f0601057bd7
|
4d01363b089917facfef766868fb2b1a853605c7
|
/src/Utils/Algo/MergeSort.h
|
ee65c0a2b9210165ee591aaf81746c6ac04e35e1
|
[] |
no_license
|
FardMan69420/aimbot-57
|
2bc7075e2f24dc35b224fcfb5623083edcd0c52b
|
3f2b86a1f86e5a6da0605461e7ad81be2a91c49c
|
refs/heads/master
| 2022-03-20T07:18:53.690175 | 2009-07-21T22:45:12 | 2009-07-21T22:45:12 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 758 |
h
|
#ifndef mergesort_h
#define mergesort_h
namespace Algorithms
{
template <class T>
static void mergeSort(T a[], int n)
{
int i, j, k;
T tmp;
/* For small arrays, insertion sort is much faster */
if (n < 64) {
for (i = 1; i < n; i++) {
tmp = a[i];
for (j = i - 1; j >= 0 && tmp < a[j]; j--)
a[j + 1] = a[j];
a[j + 1] = tmp;
}
return;
}
int f = n / 2;
mergeSort(a, f);
mergeSort(a + f, n - f);
/* Merge */
T *s = new T[n];
for (i = 0, j = f, k = 0; i < f && j < n;)
s[k++] = (a[i] < a[j]) ? a[i++] : a[j++];
while (i < f)
s[k++] = a[i++];
while (j < n)
s[k++] = a[j++];
for (i = 0; i < n; i++)
a[i] = s[i];
delete [] s;
}
}
#endif
|
[
"daven.hughes@92c3b6dc-493d-11de-82d9-516ade3e46db"
] |
[
[
[
1,
47
]
]
] |
448553688a695e9926b9e9ef193311a4824312ad
|
155c4955c117f0a37bb9481cd1456b392d0e9a77
|
/Tessa/TessaVM/StateVector.h
|
660e6cdad35f20ddfdeb8730241168ba789fe17d
|
[] |
no_license
|
zwetan/tessa
|
605720899aa2eb4207632700abe7e2ca157d19e6
|
940404b580054c47f3ced7cf8995794901cf0aaa
|
refs/heads/master
| 2021-01-19T19:54:00.236268 | 2011-08-31T00:18:24 | 2011-08-31T00:18:24 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 654 |
h
|
/****
* A state vector keeps track of a variable. This can be any number of things whether they be declared local variables
* or stack slots. State vectors can grow/shrink the number of things they track at any given time.
*/
namespace TessaVM {
class StateVector : public MMgc::GCObject {
private:
List<TessaInstruction*, avmplus::LIST_GCObjects>* currentReferences;
MMgc::GC *gc;
public:
StateVector(int numberOfLocals, MMgc::GC* gc);
int getNumberOfLocals();
void setLocal(int slot, TessaInstruction* reference);
TessaInstruction* getLocal(int slot);
void deleteLocal(int slot);
StateVector* clone();
};
}
|
[
"[email protected]"
] |
[
[
[
1,
21
]
]
] |
cf5edf1b5913277f0a53b8cc4190c1607405067c
|
7b4c786d4258ce4421b1e7bcca9011d4eeb50083
|
/_代码统计专用文件夹/C++Primer中文版(第4版)/第九章 顺序容器/20090210_代码9.4_vector类的capacity成员函数.cpp
|
974ce8a8afbb0de3b95b07a1ec8d4ce5d830dbe2
|
[] |
no_license
|
lzq123218/guoyishi-works
|
dbfa42a3e2d3bd4a984a5681e4335814657551ef
|
4e78c8f2e902589c3f06387374024225f52e5a92
|
refs/heads/master
| 2021-12-04T11:11:32.639076 | 2011-05-30T14:12:43 | 2011-05-30T14:12:43 | null | 0 | 0 | null | null | null | null |
GB18030
|
C++
| false | false | 1,045 |
cpp
|
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<int> ivec;
cout << "ivec: size: " << ivec.size()
<< "\tcapacity: " << ivec.capacity() << endl;
//添加元素
for (vector<int>::size_type ix = 0; ix != 24; ++ix) {
ivec.push_back(ix);
}
cout << "ivec: size: " << ivec.size()
<< "\tcapacity: " << ivec.capacity() << endl;
//使用reserve()提高预留空间
ivec.reserve(50);
cout << "ivec: size: " << ivec.size()
<< "\tcapacity: " << ivec.capacity() << endl;
//将预留空间使用完
while (ivec.size() != ivec.capacity())
ivec.push_back(0);
cout << "ivec: size: " << ivec.size()
<< "\tcapacity: " << ivec.capacity() << endl;
//添加新的元素
ivec.push_back(0);
cout << "ivec: size: " << ivec.size()
<< "\tcapacity: " << ivec.capacity() << endl;
//关于reserve的用法
cout << "ivec: size: " << ivec.size()
<< "\tcapacity: " << ivec.capacity()
<< "\treserve(50): " << ivec.reserve(50) << endl; //Wrong!
return 0;
}
|
[
"baicaibang@70501136-4834-11de-8855-c187e5f49513"
] |
[
[
[
1,
46
]
]
] |
90b04b82068324ec0cc807a4bf6cb810b5e89597
|
dba70d101eb0e52373a825372e4413ed7600d84d
|
/RendererComplement/include/Vector3.h
|
09879f68971bac7bd0e00fd41f2c68933095528b
|
[] |
no_license
|
nustxujun/simplerenderer
|
2aa269199f3bab5dc56069caa8162258e71f0f96
|
466a43a1e4f6e36e7d03722d0d5355395872ad86
|
refs/heads/master
| 2021-03-12T22:38:06.759909 | 2010-10-02T03:30:26 | 2010-10-02T03:30:26 | 32,198,944 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 5,329 |
h
|
#ifndef _Vector3_H_
#define _Vector3_H_
namespace RCP
{
class Vector3
{
public:
float x, y, z;
public:
inline Vector3()
{
}
inline Vector3( const float fX, const float fY, const float fZ )
: x( fX ), y( fY ), z( fZ )
{
}
inline Vector3( const Vector3& rkVector )
: x( rkVector.x ), y( rkVector.y ), z( rkVector.z )
{
}
inline Vector3& operator = ( const Vector3& rkVector )
{
x = rkVector.x;
y = rkVector.y;
z = rkVector.z;
return *this;
}
inline bool operator == ( const Vector3& rkVector ) const
{
return ( x == rkVector.x && y == rkVector.y && z == rkVector.z );
}
inline bool operator != ( const Vector3& rkVector ) const
{
return ( x != rkVector.x || y != rkVector.y || z != rkVector.z );
}
// arithmetic operations
inline Vector3 operator + ( const Vector3& rkVector ) const
{
return Vector3(
x + rkVector.x,
y + rkVector.y,
z + rkVector.z);
}
inline Vector3 operator - ( const Vector3& rkVector ) const
{
return Vector3(
x - rkVector.x,
y - rkVector.y,
z - rkVector.z);
}
inline Vector3 operator * ( const float fScalar ) const
{
return Vector3(
x * fScalar,
y * fScalar,
z * fScalar);
}
inline Vector3 operator * ( const Vector3& rhs) const
{
return Vector3(
x * rhs.x,
y * rhs.y,
z * rhs.z);
}
inline Vector3 operator / ( const float fScalar ) const
{
assert( fScalar != 0.0 );
float fInv = 1.0f / fScalar;
return Vector3(
x * fInv,
y * fInv,
z * fInv);
}
inline Vector3 operator / ( const Vector3& rhs) const
{
return Vector3(
x / rhs.x,
y / rhs.y,
z / rhs.z);
}
// arithmetic updates
inline Vector3& operator += ( const Vector3& rkVector )
{
x += rkVector.x;
y += rkVector.y;
z += rkVector.z;
return *this;
}
inline Vector3& operator -= ( const Vector3& rkVector )
{
x -= rkVector.x;
y -= rkVector.y;
z -= rkVector.z;
return *this;
}
inline Vector3& operator *= ( const float fScalar )
{
x *= fScalar;
y *= fScalar;
z *= fScalar;
return *this;
}
inline Vector3& operator *= ( const Vector3& rkVector )
{
x *= rkVector.x;
y *= rkVector.y;
z *= rkVector.z;
return *this;
}
inline Vector3& operator /= ( const float fScalar )
{
assert( fScalar != 0.0 );
float fInv = 1.0f / fScalar;
x *= fInv;
y *= fInv;
z *= fInv;
return *this;
}
inline Vector3& operator /= ( const Vector3& rkVector )
{
x /= rkVector.x;
y /= rkVector.y;
z /= rkVector.z;
return *this;
}
inline float length () const
{
return sqrt( x * x + y * y + z * z );
}
inline float squaredLength () const
{
return x * x + y * y + z * z;
}
inline float distance(const Vector3& rhs) const
{
return (*this - rhs).length();
}
inline float squaredDistance(const Vector3& rhs) const
{
return (*this - rhs).squaredLength();
}
inline float dotProduct(const Vector3& vec) const
{
return x * vec.x + y * vec.y + z * vec.z;
}
inline float absDotProduct(const Vector3& vec) const
{
return abs(x * vec.x) + abs(y * vec.y) + abs(z * vec.z);
}
inline float normalise()
{
float fLength = sqrt( x * x + y * y + z * z );
// Will also work for zero-sized vectors, but will change nothing
if ( fLength > 1e-08 )
{
float fInvLength = 1.0f / fLength;
x *= fInvLength;
y *= fInvLength;
z *= fInvLength;
}
return fLength;
}
inline Vector3 crossProduct( const Vector3& rkVector ) const
{
return Vector3(
y * rkVector.z - z * rkVector.y,
z * rkVector.x - x * rkVector.z,
x * rkVector.y - y * rkVector.x);
}
inline Vector3 operator - () const
{
return Vector3(-x, -y, -z);
}
};
}
#endif//_Vector3_H_
|
[
"[email protected]@c2606ca0-2ebb-fda8-717c-293879e69bc3"
] |
[
[
[
1,
222
]
]
] |
b4d1e307bb2811386fe7e5b781a53eb807f59960
|
5c7e6f9fce5ad61e3353d5cdc141c81e38ce791b
|
/cn/interpolacao_Newton_Gregory.cpp
|
77d67c4ea91077d2a1e43b20d08c92439e4e2ba0
|
[] |
no_license
|
luizirber/maestrograd
|
cd343438953bcc9e3136da3282ac84324b48ea83
|
db6ed5ccea454c5c6d790b44b6dcdbc49a41e7e0
|
refs/heads/master
| 2021-01-19T21:25:35.334049 | 2008-09-22T23:47:01 | 2008-09-22T23:47:01 | 960,820 | 1 | 0 | null | null | null | null |
ISO-8859-1
|
C++
| false | false | 6,294 |
cpp
|
// Alexandre Yukio Harano - RA: 254274 - k = 1
// Cálculo Numérico - Turma A - Professor Fernando
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <cassert>
using namespace std;
// Função Fatorial
int fatorial (int n) {
if ( n == 0 )
return 1;
else
return n*fatorial(n-1);
}
// Função recursiva que retorna o valor das combinações k a k dos final-inicial+1 raízes
double calculo_combinatorio (int inicial, int final, int combinacoes_k_a_k, int* vetor) {
if (combinacoes_k_a_k == 1) {
double somatoria = 0.0;
for (int i = inicial; i < final+1; i++)
somatoria -= vetor[i];
return somatoria;
}
else {
double soma_e_produto = 0.0;
for (int i = inicial; i < final - combinacoes_k_a_k + 2; i++){
soma_e_produto -= vetor[i]*calculo_combinatorio(i+1, final, combinacoes_k_a_k - 1, vetor);
}
return soma_e_produto;
}
}
// O método de polinômios interpoladores de Newton é computado pelo programa abaixo
int main(){
bool controle_programa = 1;
while (controle_programa){
int n = 0;
while (n < 1){
cout<<"Entre com a ordem do polinomio interpolador a ser deduzido: ";
cin>>n;
}
n++; // O número de elementos do polinômio é a ordem + 1 e esse será o valor de n ao longo
// do programa
cout<<endl;
// Alocação de vetores e matrizes dinâmicas para o cálculo da tabela de diferenciais
// finitas (TDF) e do vetor dos coeficientes do polinômio gerado, além de "zerá-los"
double** TDF;
int* u;
double* coeficientes;
u = new int[n];
assert(u!=0);
coeficientes = new double[n];
assert(coeficientes!=0);
TDF = new double*[n];
assert( TDF != 0 );
for (int i = 0; i < n; i++) {
TDF[i] = new double[n-i+1];
assert( TDF != 0 );
u[i] = i;
coeficientes[i] = 0.0;
for (int j=0; j < n-i+1; j++)
TDF[i][j] = 0.0;
}
double minimo = 0.0;
double maximo = 0.0;
double h = 0.0;
double x0;
// Leitura dos valores x0 e h e a determinação do intervalo do domínio do polinômio gerado
cout<<"Entre com o valor de x[0]: ";
cin>>x0;
while ( h == 0.0 ) {
cout<<"Entre com o intervalo h: ";
cin>>h;
}
if ( h < 0 ) {
maximo = x0;
minimo = x0 + (n-1)*h;
}
else {
maximo = x0 + (n-1)*h;
minimo = x0;
}
cout<<endl;
// Leitura dos valores de y
for (int i = 0; i < n; i++) {
cout<<"Entre com o valor de y["<<i<<"]: ";
cin>>TDF[i][0];
}
cout<<endl;
// Cálculo da tabela de diferencas finitas
for (int j = 1; j < n; j++)
for (int i = 0; i < n-j; i++)
TDF[i][j] = (TDF[i+1][j-1]-TDF[i][j-1]);
cout<<"TABELA DE DIFERENCAS FINITAS"<<endl<<endl;
cout<<"u | x";
for (int j = 0; j < n; j++)
cout<<" | delta"<<j;
cout<<endl;
for (int i = 0; i < n; i++) {
cout<<i<<" | "<<setprecision(10)<<(x0+i*h)<<" | ";
for (int j = 0; j < n-i; j++)
cout<<setprecision(10)<<TDF[i][j]<<" ";
cout<<endl;
}
cout<<endl;
// Preenchimento dos vetores dos coeficientes dos polinomios onde i é o número relativo ao
// i-ésimo termo pelo polinômio interpolador de Newton descrita no anexo e j é o número
// relativo a j-ésima combinação a ser calculada
for (int i = 0; i < n; i++)
for (int j = 0; j < i+1; j++)
if (j == 0)
coeficientes[n-i-1] += TDF[0][i]/fatorial(i);
else
coeficientes[n-i+j-1] += calculo_combinatorio(0,i-1,j,u)*TDF[0][i]/fatorial(i);
// Amostra do polinômio de interpolação na forma "bruta"
cout<<"O polinomio gerado eh P(u) = "<<setprecision(10)<<TDF[0][0]<<" + ";
for (int i = 0; i < n-1; i++) {
for (int j = 0; j<i+1; j++)
cout<<"(u-"<<setprecision(10)<<u[j]<<")*";
cout<<"("<<setprecision(10)<<TDF[0][i+1]<<")/("<<i+1<<"!)";
if (i!=n-2)
cout<<" + ";
}
cout<<endl<<endl;
// Amostra do polinômio da forma usual
cout<<"Equivalente a P(u) = ";
for (int contagem = 0; contagem<n; contagem++) {
cout<<"("<<setprecision(10)<<coeficientes[contagem]<<")";
if (contagem!=n-1)
cout<<"*x^"<<n-contagem-1<<" + ";
}
cout<<endl<<endl;
// Teste do polinômio interpolador gerado
bool teste_polinomio = 1;
while (teste_polinomio){
double x_teste;
bool x_dentro_do_intervalo = 0;
while (!x_dentro_do_intervalo){
cout<<"Entre com um valor para x: ";
cin>>x_teste;
if ((x_teste < minimo)||(x_teste > maximo))
cout<<"O valor digitado estah fora do intervalo ["<<setprecision(10)<<minimo<<","
<<setprecision(10)<<maximo<<"]."<<endl<<endl;
else
x_dentro_do_intervalo = 1;
}
double u_teste = (x_teste - x0)/h;
double p_teste = coeficientes[n-1];
for (int i = 0; i<n-1; i++){
double produtorio = coeficientes[i];
for (int j = 0; j<n-i-1; j++)
produtorio = produtorio*u_teste;
p_teste += produtorio;
}
cout<<"u = (x - x0)/h ==> u = (("<<setprecision(10)<<x_teste<<") - ("
<<setprecision(10)<<x0<<"))/"<<setprecision(10)<<h<<" ==> u = "
<<setprecision(10)<<u_teste<<endl;
cout<<"P("<<setprecision(10)<<u_teste<<") = "<<setprecision(10)<<p_teste<<endl<<endl;
// Verificação se deseja testar com outro valor
char char_teste = '\0';
while ((char_teste!='s')&&(char_teste!='S')&&(char_teste!='n')&&(char_teste!='N')) {
cout<<"Deseja testar o polinomio interpolador gerado com outro valor (S ou N)? ";
cin>>char_teste;
}
cout<<endl;
if ((char_teste=='n')||(char_teste=='N'))
teste_polinomio = 0;
}
// Desaloca a memória referente aos vetores e matrizes
delete coeficientes;
delete u;
delete TDF;
// Verificação se deseja gerar outro polinômio interpolador
char verifica = '\0';
while (((verifica!='s')&&(verifica!='S'))&&((verifica!='n')&&(verifica!='N'))) {
cout<<"Deseja gerar outro polinomio interpolador (S ou N)? ";
cin>>verifica;
}
if ((verifica=='n')||(verifica=='N'))
controle_programa = 0;
cout<<endl;
}
return 0;
}
|
[
"[email protected]"
] |
[
[
[
1,
212
]
]
] |
022ada526a58ff128eea82f33a4a436b461fda84
|
0b55a33f4df7593378f58b60faff6bac01ec27f3
|
/Konstruct/Common/Utility/kpuFileManager.h
|
17b8d89da67c3d725916fe1cf2cc2715abd9d449
|
[] |
no_license
|
RonOHara-GG/dimgame
|
8d149ffac1b1176432a3cae4643ba2d07011dd8e
|
bbde89435683244133dca9743d652dabb9edf1a4
|
refs/heads/master
| 2021-01-10T21:05:40.480392 | 2010-09-01T20:46:40 | 2010-09-01T20:46:40 | 32,113,739 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 390 |
h
|
#pragma once
class kpuFileManager
{
public:
kpuFileManager(void);
~kpuFileManager(void);
static void SetRootPath(const char* szRoot);
static bool GetFullFilePath(const char* szInFile, char* szOutFile, int nOutFileSize);
static char* GetRoot() { return sm_szRootPath; }
static char* GetDirectory(const char* szFilename);
protected:
static char sm_szRootPath[];
};
|
[
"acid1789@0c57dbdb-4d19-7b8c-568b-3fe73d88484e",
"bflassing@0c57dbdb-4d19-7b8c-568b-3fe73d88484e"
] |
[
[
[
1,
10
],
[
13,
16
]
],
[
[
11,
12
]
]
] |
908f23386c2af669ed8b6060e441854d91b63971
|
1a558ab3eacfc15e68c58744a45ddaa762d81073
|
/CDReader.cpp
|
b702e60fd1669b3239a014a2ca7ad5640a3ced22
|
[] |
no_license
|
markessien/discreader
|
2c1d3c6aaaa42dc233c00a5275464cbd6a37b93c
|
bd888923c134baf86586cc963845b4657078c653
|
refs/heads/master
| 2020-06-08T16:58:08.178715 | 2010-10-23T12:33:49 | 2010-10-23T12:33:49 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,971 |
cpp
|
// CDReader.cpp : Implementation of DLL Exports.
// Note: Proxy/Stub Information
// To build a separate proxy/stub DLL,
// run nmake -f CDReaderps.mk in the project directory.
#include "stdafx.h"
#include "resource.h"
#include <initguid.h>
#include "CDReader.h"
#include "CDReader_i.c"
#include "CDReaderObj.h"
CComModule _Module;
BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_CDReader, CCDReaderObj)
END_OBJECT_MAP()
/////////////////////////////////////////////////////////////////////////////
// DLL Entry Point
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
_Module.Init(ObjectMap, hInstance, &LIBID_CDREADERLib);
DisableThreadLibraryCalls(hInstance);
}
else if (dwReason == DLL_PROCESS_DETACH)
_Module.Term();
return TRUE; // ok
}
/////////////////////////////////////////////////////////////////////////////
// Used to determine whether the DLL can be unloaded by OLE
STDAPI DllCanUnloadNow(void)
{
return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// Returns a class factory to create an object of the requested type
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
return _Module.GetClassObject(rclsid, riid, ppv);
}
/////////////////////////////////////////////////////////////////////////////
// DllRegisterServer - Adds entries to the system registry
STDAPI DllRegisterServer(void)
{
// registers object, typelib and all interfaces in typelib
return _Module.RegisterServer(TRUE);
}
/////////////////////////////////////////////////////////////////////////////
// DllUnregisterServer - Removes entries from the system registry
STDAPI DllUnregisterServer(void)
{
return _Module.UnregisterServer(TRUE);
}
|
[
"[email protected]"
] |
[
[
[
1,
72
]
]
] |
292b633e3c122f3ccf892d84dd314df84e589d81
|
3f37de877cbd9a426e0b1dd26a290553bcaab109
|
/sources/balle.hpp
|
2f4b68b0feab75927ecc36c1ff062d410d3dddbe
|
[] |
no_license
|
Birdimol/GreenPlague
|
f698ba87a7325fd015da619146cb93057e94fe44
|
1675ec597247be9f09e30a3ceac01a7d7ec1af43
|
refs/heads/master
| 2016-09-09T18:57:25.414142 | 2011-10-19T06:08:15 | 2011-10-19T06:08:15 | 2,480,187 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 642 |
hpp
|
#ifndef DEF_BALLE
#define DEF_BALLE
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
#include <iostream>
#include <SFML/Graphics.hpp>
#include <string>
#include "map.hpp"
class Balle
{
public:
Balle(sf::Image image,Map *map);
void set(float x_envoye, float y_envoye, float direction_x_envoye, float direction_y_envoye, float rotation_envoye);
void avancer(float time);
sf::Sprite getSprite();
int statut;
private:
float direction_x;
float direction_y;
float rotation;
float x;
float y;
Map *map;
sf::Image image;
sf::Sprite sprite;
};
#endif
|
[
"[email protected]"
] |
[
[
[
1,
32
]
]
] |
628bdf0ec12232b9bb7affaae6b743125cebc917
|
da5547e6a2b8b329be1f3975fc93faea6e40660c
|
/App/Views.cpp
|
c401a42236e8d54a9668361f28446c83371fde6c
|
[] |
no_license
|
hackerlank/directui
|
5599b673d7273e743ea48baf6c301df12d770e74
|
c5d55e8dfda86355b731d5af5166b8b3786f5187
|
refs/heads/master
| 2020-01-23T21:35:28.834222 | 2011-04-02T01:47:01 | 2011-04-02T01:47:01 | null | 0 | 0 | null | null | null | null |
GB18030
|
C++
| false | false | 29,024 |
cpp
|
#include "StdAfx.h"
#include "Views.h"
#include <exdisp.h>
#include <comdef.h>
UINT CStandardPageWnd::GetClassStyle() const
{
return UI_CLASSSTYLE_CHILD;
}
void CStandardPageWnd::OnFinalMessage(HWND /*hWnd*/)
{
delete this;
}
LRESULT CStandardPageWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if( uMsg == WM_CREATE ) {
m_pm.Init(m_hWnd);
CDialogBuilder builder;
CControlUI* pRoot = builder.Create(GetDialogResource());
ASSERT(pRoot && _T("Failed to parse XML"));
m_pm.AttachDialog(pRoot);
m_pm.AddNotifier(this);
Init();
return 0;
}
LRESULT lRes = 0;
if( m_pm.MessageHandler(uMsg, wParam, lParam, lRes) ) return lRes;
return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
}
void CStandardPageWnd::Init()
{
}
void CStandardPageWnd::OnPrepareAnimation()
{
}
void CStandardPageWnd::Notify(TNotifyUI& msg)
{
if( msg.sType == _T("windowinit") ) OnPrepareAnimation();
}
////////////////////////////////////////////////////////////////////////
//
LPCTSTR CStartPageWnd::GetWindowClassName() const
{
return _T("UIStart");
}
LPCTSTR CStartPageWnd::GetDialogResource() const
{
return _T("<Dialog>")
_T("<HorizontalLayout>")
_T("<VerticalLayout width=\"150\" >")
_T("<Toolbar>")
_T("<ToolGripper />")
_T("</Toolbar>")
_T("<NavigatorPanel>")
_T("<PaddingPanel height=\"18\" />")
_T("<NavigatorButton name=\"page_start\" text=\"<i 0> 开始\" selected=\"true\" tooltip=\"Vis 开始 siden\" />")
_T("<NavigatorButton name=\"page_registers\" text=\"<i 4> 登记\" tooltip=\"Vis forskellige registre\" />")
_T("<NavigatorButton name=\"page_systems\" text=\"<i 4> 系统\" />")
_T("<NavigatorButton name=\"page_configure\" text=\"<i 4> Opsning\" />")
_T("<NavigatorButton name=\"page_reports\" text=\"<i 4> 报表\" />")
_T("</NavigatorPanel>")
_T("</VerticalLayout>")
_T("<VerticalLayout>")
_T("<Toolbar>")
_T("<LabelPanel align=\"right\" text=\"<f 6><c #fffe28>开始滑动动画</c></f>\" />")
_T("</Toolbar>")
_T("<ToolbarTitlePanel text=\"<f 7>测试程序</f>\" />")
_T("<TitleShadow />")
_T("<WindowCanvas watermark=\"StartWatermark\" >")
_T("<VerticalLayout>")
_T("<TextPanel text=\"<f 8>Vlg startomrde</h>\" />")
_T("<FadedLine />")
_T("<TileLayout scrollbar=\"true\" >")
_T("<TextPanel name=\"link_registers\" text=\"<i 7 50><a><f 6>登记(&R)</f></a>\n<h>\n<c #444540>Vlg denne menu for at rette i diverse registre i systemet.\n\nDu kan rette i kunde, vogn og chauffr-reigsteret.\" shortcut=\"R\" />")
_T("<TextPanel name=\"link_systems\" text=\"<i 9 50><a><f 6>系统(&S)</f></a>\n<h>\n<c #444540>Gennem denne menu kan du opstte diverse ting.\" shortcut=\"S\" />")
_T("<TextPanel name=\"link_configure\" text=\"<i 6 50><a><f 6>Opstning</f></a>\n<h>\n<c #444540>Opstning giver adgang til konfiguration af de mange krsels-systemer og regler.\" />")
_T("<TextPanel name=\"link_reports\" text=\"<i 5 50><a><f 6>报表</f></a>\n<h>\n<c #444540>报表 giver dig overblik over registre samt hverdagens ture og bestillinger.\n\nGennem statistik og lister kan du hurtigt f?prsenteret historiske data fra systemet.\" />")
_T("</TileLayout>")
_T("</VerticalLayout>")
_T("</WindowCanvas>")
_T("</VerticalLayout>")
_T("</HorizontalLayout>")
_T("</Dialog>");
}
void CStartPageWnd::OnPrepareAnimation()
{
COLORREF clrBack = m_pm.GetThemeColor(UICOLOR_WINDOW_BACKGROUND);
RECT rcCtrl = m_pm.FindControl(_T("link_registers"))->GetPos();
m_pm.AddAnimJob(CAnimJobUI(UIANIMTYPE_FLAT, 0, 350, clrBack, clrBack, CRect(rcCtrl.left, rcCtrl.top, rcCtrl.left + 50, rcCtrl.top + 50), 40, 0, 4, 255, 0.3f));
rcCtrl = m_pm.FindControl(_T("link_systems"))->GetPos();
m_pm.AddAnimJob(CAnimJobUI(UIANIMTYPE_FLAT, 200, 350, clrBack, clrBack, CRect(rcCtrl.left, rcCtrl.top, rcCtrl.left + 50, rcCtrl.top + 50), 40, 0, 4, 255, 0.3f));
rcCtrl = m_pm.FindControl(_T("link_configure"))->GetPos();
m_pm.AddAnimJob(CAnimJobUI(UIANIMTYPE_FLAT, 100, 350, clrBack, clrBack, CRect(rcCtrl.left, rcCtrl.top, rcCtrl.left + 50, rcCtrl.top + 50), 40, 0, 4, 255, 0.3f));
rcCtrl = m_pm.FindControl(_T("link_reports"))->GetPos();
m_pm.AddAnimJob(CAnimJobUI(UIANIMTYPE_FLAT, 250, 350, clrBack, clrBack, CRect(rcCtrl.left, rcCtrl.top, rcCtrl.left + 50, rcCtrl.top + 50), 40, 0, 4, 255, 0.3f));
}
void CStartPageWnd::Init()
{
}
////////////////////////////////////////////////////////////////////////
//
LPCTSTR CConfigurePageWnd::GetWindowClassName() const
{
return _T("UIConfigure");
}
LPCTSTR CConfigurePageWnd::GetDialogResource() const
{
return _T("<Dialog>")
_T("<HorizontalLayout>")
_T("<VerticalLayout width=\"150\" >")
_T("<Toolbar>")
_T("<ToolGripper />")
_T("</Toolbar>")
_T("<NavigatorPanel>")
_T("<PaddingPanel height=\"18\" />")
_T("<NavigatorButton name=\"page_start\" text=\"<i 0> 开始\" tooltip=\"Vis 开始 siden\" />")
_T("<NavigatorButton name=\"page_registers\" text=\"<i 4> 登记\" tooltip=\"Vis forskellige registre\" />")
_T("<NavigatorButton name=\"page_systems\" text=\"<i 4> 系统\" />")
_T("<NavigatorButton name=\"page_configure\" text=\"<i 4> Opstning\" selected=\"true\" />")
_T("<NavigatorButton name=\"page_reports\" text=\"<i 4> 报表\" />")
_T("</NavigatorPanel>")
_T("</VerticalLayout>")
_T("<VerticalLayout>")
_T("<Toolbar>")
_T("<LabelPanel align=\"right\" text=\"<f 6><c #fffe28>系统 Opstning</c></f>\" />")
_T("</Toolbar>")
_T("<ToolbarTitlePanel name=\"titlepanel\" text=\"<f 7>系统 Opstning</f>\" />")
_T("<TitleShadow />")
_T("<WindowCanvas>")
_T("<VerticalLayout>")
_T("<TextPanel text=\"<f 8>Hvad vil du konfigurere?</h>\" />")
_T("<FadedLine />")
_T("<HorizontalLayout>")
_T("<TaskPanel text=\"<f 2>Opgaver</f>\" >")
_T("<TextPanel text=\"<i 2><a>Skift trafikniveau</a>\" />")
_T("<TextPanel text=\"<i 3><a>Brugerindstillinger</a>\" />")
_T("</TaskPanel>")
_T("<PaddingPanel width=\"12\" />")
_T("<VerticalLayout>")
_T("<TextPanel text=\"<f 6><c #2c4378>Opstningsliste</c></f>\" />")
_T("<SeparatorLine />")
_T("<TextPanel text=\"<c #414141>Dobbeltklik p?et element i listen for at konfigurere det.</c>\n\" />")
_T("<List header=\"hidden\" >")
_T("<TextPanel text=\"<x 16><c #585ebf><b>登记</b>\n<h>\" />")
_T("<ListLabelElement text=\"<i 4> 会员登记\" />")
_T("<ListLabelElement text=\"<i 4> 商品登记\" />")
_T("<ListLabelElement text=\"<i 4> Kunde register\" />")
_T("<ListLabelElement text=\"<i 4> Vognmandsregister\" />")
_T("<ListLabelElement text=\"<i 4> Vogn register\" />")
_T("<ListLabelElement text=\"<i 4> Chauffr register\" />")
_T("<TextPanel text=\"<x 16><c #F00000><b>一个很酷的效果</b>\n<h>\" />")
_T("<ListLabelElement text=\"<i 7> 调整大小看看\" />")
_T("</List>")
_T("</VerticalLayout>")
_T("</HorizontalLayout>")
_T("</VerticalLayout>")
_T("</WindowCanvas>")
_T("</VerticalLayout>")
_T("</HorizontalLayout>")
_T("</Dialog>");
}
void CConfigurePageWnd::OnPrepareAnimation()
{
COLORREF clrBack = m_pm.GetThemeColor(UICOLOR_TITLE_BACKGROUND);
const RECT rcCtrl = m_pm.FindControl(_T("titlepanel"))->GetPos();
m_pm.AddAnimJob(CAnimJobUI(UIANIMTYPE_FLAT, 0, 300, clrBack, CLR_INVALID, rcCtrl, 140, 0, 5, 200, 0.1f));
}
////////////////////////////////////////////////////////////////////////
//
LPCTSTR CRegistersPageWnd::GetWindowClassName() const
{
return _T("UIRegisters");
}
LPCTSTR CRegistersPageWnd::GetDialogResource() const
{
return _T("<Dialog>")
_T("<HorizontalLayout>")
_T("<VerticalLayout width=\"150\" >")
_T("<Toolbar>")
_T("<ToolGripper />")
_T("</Toolbar>")
_T("<NavigatorPanel>")
_T("<PaddingPanel height=\"18\" />")
_T("<NavigatorButton name=\"page_start\" text=\"<i 0> 开始\" tooltip=\"Vis 开始 siden\" />")
_T("<NavigatorButton name=\"page_registers\" text=\"<i 4> 登记\" tooltip=\"Vis forskellige registre\" selected=\"true\" />")
_T("<NavigatorButton name=\"page_systems\" text=\"<i 4> 系统\" />")
_T("<NavigatorButton name=\"page_configure\" text=\"<i 4> Opstning\" />")
_T("<NavigatorButton name=\"page_reports\" text=\"<i 4> 报表\" />")
_T("</NavigatorPanel>")
_T("</VerticalLayout>")
_T("<VerticalLayout>")
_T("<Toolbar>")
_T("<LabelPanel align=\"right\" text=\"<f 6><c #fffe28>登记</c></f>\" />")
_T("</Toolbar>")
_T("<TitleShadow />")
_T("<WindowCanvas>")
_T("<SearchTitlePanel image=\"10\" >")
_T("<TabFolder width=\"200\" inset=\"8 8\" >")
_T("<TabPage text=\"登记\" >")
_T("<DialogLayout scrollbar=\"false\" >")
_T("<LabelPanel pos=\"0, 0, 150, 24\" text=\"名称(&N)\" />")
_T("<SingleLineEdit pos=\"0, 24, 150, 44\" name=\"name\" />")
_T("<LabelPanel pos=\"0, 48, 150, 68\" text=\"类别(&T)\" />")
_T("<SingleLineEdit pos=\"0, 68, 150, 88\" name=\"类别\" />")
_T("<Button pos=\"95, 98, 150, 118\" name=\"ok\" text=\"确定(&O)\" />")
_T("</DialogLayout>")
_T("</TabPage>")
_T("</TabFolder>")
_T("<List name=\"list\">")
_T("<ListHeaderItem text=\"名称\" width=\"240\" />")
_T("<ListHeaderItem text=\"类别\" width=\"160\" />")
_T("</List>")
_T("</SearchTitlePanel>")
_T("</WindowCanvas>")
_T("</VerticalLayout>")
_T("</HorizontalLayout>")
_T("</Dialog>");
}
void CRegistersPageWnd::OnPrepareAnimation()
{
CListUI* pList = static_cast<CListUI*>(m_pm.FindControl(_T("list")));
pList->SetTextCallback(this); // We want GetItemText for items
for( int i = 0; i < 1000; i++ ) pList->Add(new CListTextElementUI); // We want 1000 items in list
}
LPCTSTR CRegistersPageWnd::GetItemText(CControlUI* pControl, int iIndex, int iSubItem)
{
if( iIndex == 0 && iSubItem == 0 ) return _T("<i 3>第一行");
if( iIndex == 1 && iSubItem == 0 ) return _T("<i 3>第二行");
if( iIndex == 2 && iSubItem == 0 ) return _T("<i 3>第三行");
if( iIndex == 0 && iSubItem == 1 ) return _T("马");
if( iIndex == 1 && iSubItem == 1 ) return _T("狗");
if( iIndex == 2 && iSubItem == 1 ) return _T("兔子");
static CStdString sTemp;
sTemp.Format(_T("第%d行 第%d列"), iIndex + 1, iSubItem + 1);
return sTemp;
}
int CRegistersPageWnd::CompareItem(CControlUI* pList, CControlUI* pItem1, CControlUI* pItem2)
{
return 0;
}
////////////////////////////////////////////////////////////////////////
//
LPCTSTR CSystemsPageWnd::GetWindowClassName() const
{
return _T("UISystems");
}
LPCTSTR CSystemsPageWnd::GetDialogResource() const
{
return _T("<Dialog>")
_T("<HorizontalLayout>")
_T("<VerticalLayout width=\"150\" >")
_T("<Toolbar>")
_T("<ToolGripper />")
_T("</Toolbar>")
_T("<NavigatorPanel>")
_T("<PaddingPanel height=\"18\" />")
_T("<NavigatorButton name=\"page_start\" text=\"<i 0> 开始\" tooltip=\"开始菜单\" />")
_T("<NavigatorButton name=\"page_registers\" text=\"<i 4> 登记\" tooltip=\"登记\" />")
_T("<NavigatorButton name=\"page_systems\" text=\"<i 4> 系统\" selected=\"true\" />")
_T("<NavigatorButton name=\"page_configure\" text=\"<i 4> Opstning\" />")
_T("<NavigatorButton name=\"page_reports\" text=\"<i 4> 报表\" />")
_T("</NavigatorPanel>")
_T("</VerticalLayout>")
_T("<VerticalLayout>")
_T("<Toolbar>")
_T("<LabelPanel align=\"right\" text=\"<f 6><c #fffe28>系统</c></f>\" />")
_T("</Toolbar>")
_T("<TitleShadow />")
_T("<WindowCanvas>")
_T("<VerticalLayout>")
_T("<DialogLayout scrollbar=\"true\" >")
_T("<LabelPanel pos=\"0, 0, 50, 24\" text=\"<b>名称(&N)</b>\" stretch=\"group\" />")
_T("<SingleLineEdit pos=\"50, 2, 190, 22\" name=\"name\" stretch=\"size_x\" />")
_T("<Button pos=\"194, 2, 235, 22\" text=\"确定\" name=\"ok\" stretch=\"move_x\" />")
_T("<LabelPanel pos=\"250, 0, 300, 24\" text=\"<b>类别(&T)</b>\" stretch=\"move_x\" />")
_T("<SingleLineEdit pos=\"300, 2, 480, 22\" name=\"type\" stretch=\"move_x size_x\" />")
_T("<ImagePanel image=\"logo_search\" pos=\"490, 0, 555, 56\" stretch=\"move_x\" />")
_T("<Toolbar pos=\"0, 30, 480, 53\" stretch=\"group size_x\" >")
_T("<PaddingPanel />")
_T("<ToolButton text=\"<i 15> 修改\" />")
_T("<ToolButton text=\"<i 0>\" />")
_T("<ToolButton text=\"<i 1>\" />")
_T("</Toolbar>")
_T("<ListHeaderShadow pos=\"0, 53, 480, 56\" stretch=\"group size_x\" />")
_T("</DialogLayout>")
_T("<List name=\"list\" expanding=\"true\">")
_T("<ListHeaderItem enabled=\"false\" width=\"30\" />")
_T("<ListHeaderItem text=\"名称\" width=\"140\" />")
_T("<ListHeaderItem text=\"价格\" width=\"80\" />")
_T("<ListHeaderItem text=\"连接\" width=\"180\" />")
_T("<ListExpandElement />")
_T("<ListExpandElement />")
_T("<ListExpandElement />")
_T("</List>")
_T("</VerticalLayout>")
_T("</WindowCanvas>")
_T("</VerticalLayout>")
_T("</HorizontalLayout>")
_T("</Dialog>");
}
void CSystemsPageWnd::Notify(TNotifyUI& msg)
{
if( msg.sType == _T("itemexpand") ) OnExpandItem(msg.pSender);
CStandardPageWnd::Notify(msg);
}
LPCTSTR CSystemsPageWnd::GetItemText(CControlUI* pControl, int iIndex, int iSubItem)
{
if( iIndex == 0 && iSubItem == 1 ) return _T("Expanding Item #1");
if( iIndex == 1 && iSubItem == 1 ) return _T("Expanding Item #2");
if( iIndex == 2 && iSubItem == 1 ) return _T("Expanding Item #3");
if( iIndex == 0 && iSubItem == 2 ) return _T("100.0");
if( iIndex == 1 && iSubItem == 2 ) return _T("20.0");
if( iIndex == 2 && iSubItem == 2 ) return _T("30.0");
if( iIndex == 0 && iSubItem == 3 ) return _T("<a>Kunde #1</a>");
if( iIndex == 1 && iSubItem == 3 ) return _T("");
if( iIndex == 2 && iSubItem == 3 ) return _T("<a>Kunde #3</a>");
return _T("");
}
int CSystemsPageWnd::CompareItem(CControlUI* pList, CControlUI* pItem1, CControlUI* pItem2)
{
return 0;
}
void CSystemsPageWnd::OnPrepareAnimation()
{
CListUI* pList = static_cast<CListUI*>(m_pm.FindControl(_T("list")));
pList->SetTextCallback(this); // List will call our GetItemText()
}
void CSystemsPageWnd::OnExpandItem(CControlUI* pControl)
{
CListExpandElementUI* pItem = static_cast<CListExpandElementUI*>(pControl);
CStdString sText;
sText.Format(_T("<b>Episode:</b> Gyldendal #%p"), pControl);
CTextPanelUI* pText = new CTextPanelUI();
pText->SetText(sText);
pItem->Add(pText);
pItem->Add((new CTextPanelUI())->ApplyAttributeList(_T("text=\"<b>name:</b> Anders And</b>\"")));
pItem->Add((new CTextPanelUI())->ApplyAttributeList(_T("text=\"<b>Tidspunkt:</b> <i 3>Juleaften\"")));
}
////////////////////////////////////////////////////////////////////////
//
LPCTSTR CReportsPageWnd::GetWindowClassName() const
{
return _T("UI报表s");
}
LPCTSTR CReportsPageWnd::GetDialogResource() const
{
return _T("<Dialog>")
_T("<HorizontalLayout>")
_T("<VerticalLayout width=\"150\" >")
_T("<Toolbar>")
_T("<ToolGripper />")
_T("</Toolbar>")
_T("<NavigatorPanel>")
_T("<PaddingPanel height=\"18\" />")
_T("<NavigatorButton name=\"page_start\" text=\"<i 0> 开始\" tooltip=\"Vis 开始 siden\" />")
_T("<NavigatorButton name=\"page_registers\" text=\"<i 4> 登记\" tooltip=\"Vis forskellige registre\" />")
_T("<NavigatorButton name=\"page_systems\" text=\"<i 4> 系统\" />")
_T("<NavigatorButton name=\"page_configure\" text=\"<i 4> Opstning\" />")
_T("<NavigatorButton name=\"page_reports\" text=\"<i 4> 报表\" selected=\"true\" />")
_T("</NavigatorPanel>")
_T("</VerticalLayout>")
_T("<VerticalLayout>")
_T("<Toolbar>")
_T("<LabelPanel align=\"right\" text=\"<f 6><c #fffe28>报表</c></f>\" />")
_T("</Toolbar>")
_T("<ToolbarTitlePanel name=\"titlepanel\" text=\"<f 7>报表</f>\" />")
_T("<TitleShadow />")
_T("<WindowCanvas>")
_T("<TileLayout>")
_T("<TextPanel text=\"<i 0 50><a><f 6>顾客报表</f></a>\n<h>\n<c #444540>顾客登记报表.\" />")
_T("<TextPanel text=\"<i 1 50><a><f 6>车辆报表</f></a>\n<h>\n<c #444540>车辆报表.\" />")
_T("<TextPanel text=\"<i 2 50><a><f 6>Chauffr Report</f></a>\n<h>\n<c #444540>chauffrer registeret报表 .\" />")
_T("<TextPanel text=\"<i 3 50><a><f 6>Bestilling Report</f></a>\n<h>\n<c #444540>over bestillinger报表.\" />")
_T("</TileLayout>")
_T("</WindowCanvas>")
_T("</VerticalLayout>")
_T("</HorizontalLayout>")
_T("</Dialog>");
}
void CReportsPageWnd::OnPrepareAnimation()
{
const RECT rcCtrl = m_pm.FindControl(_T("titlepanel"))->GetPos();
m_pm.AddAnimJob(CAnimJobUI(UIANIMTYPE_FLAT, 0, 300, CLR_INVALID, CLR_INVALID, rcCtrl, 0, 0, -2, -200, 0.0f));
}
////////////////////////////////////////////////////////////////////////
//
LPCTSTR CSearchPageWnd::GetWindowClassName() const
{
return _T("UISearch");
}
void CSearchPageWnd::Init()
{
m_pm.SetMinMaxInfo(640,480);
}
void CSearchPageWnd::Notify(TNotifyUI& msg)
{
if( msg.sType == _T("click") )
{
if( msg.pSender->GetName() == _T("ok") ) {
CStandardPageWnd* pWindow = new CEditPageWnd;
pWindow->Create(m_hWnd, NULL, UI_WNDSTYLE_FRAME, 0L);
}
if( msg.pSender->GetName() == _T("cancel") ) Close();
}
CStandardPageWnd::Notify(msg);
}
LPCTSTR CSearchPageWnd::GetDialogResource() const
{
return _T("<Dialog caption=\"Search Page\" >")
_T("<VerticalLayout>")
_T("<ToolbarTitlePanel text=\"<f 6>确定 efter en vej.</f><p><x 10>Indtast sgekriterier og 确定 efter vejen.\" />")
_T("<DialogCanvas>")
_T("<VerticalLayout>")
_T("<DialogLayout>")
_T("<LabelPanel pos=\"0, 10, 60, 34\" text=\"类别\" stretch=\"group\" />")
_T("<DropDown pos=\"60, 12, 340, 32\" name=\"name\" stretch=\"size_x\" >")
_T("<ListLabelElement text=\"<i 2> 姓名\" selected=\"true\" />")
_T("<ListLabelElement text=\"<i 5> 联系人\" />")
_T("<ListLabelElement text=\"<i 8> 电子邮件\" />")
_T("<ListLabelElement text=\"<i 8> 客户\" />")
_T("</DropDown>")
_T("<LabelPanel pos=\"0, 36, 60, 60\" text=\"名称\" stretch=\"group\" />")
_T("<SingleLineEdit pos=\"60, 38, 250, 58\" name=\"search\" text=\"\" stretch=\"size_x\" />")
_T("<Button pos=\"260, 38, 340, 58\" name=\"ok\" text=\"确定(&O)\" stretch=\"move_x\" />")
_T("<SeparatorLine pos=\"0, 68, 340, 78\" stretch=\"group size_x\" />")
_T("<LabelPanel pos=\"0, 78, 340, 98\" text=\"Valgbare veje\" />")
_T("<PaddingPanel pos=\"0, 98, 340, 100\" />")
_T("</DialogLayout>")
_T("<List name=\"list\">")
_T("<ListHeaderItem text=\"name\" width=\"140\" />")
_T("<ListHeaderItem text=\"Position\" width=\"80\" />")
_T("</List>")
_T("<DialogLayout>")
_T("<PaddingPanel pos=\"0, 0, 340, 4\" />")
_T("<SeparatorLine pos=\"0, 4, 340, 18\" stretch=\"group size_x\" />")
_T("<PaddingPanel pos=\"0, 18, 160, 38\" stretch=\"group size_x\" />")
_T("<Button pos=\"160, 18, 246, 38\" text=\"确定\" name=\"ok\" stretch=\"move_x\" />")
_T("<Button pos=\"250, 18, 340, 38\" text=\"取消\" name=\"cancel\" stretch=\"move_x\" />")
_T("<PaddingPanel pos=\"0, 38, 340, 48\" />")
_T("</DialogLayout>")
_T("</VerticalLayout>")
_T("</DialogCanvas>")
_T("</VerticalLayout>")
_T("</Dialog>");
}
////////////////////////////////////////////////////////////////////////
//
LPCTSTR CEditPageWnd::GetWindowClassName() const
{
return _T("UIEdit");
}
void CEditPageWnd::Init()
{
ResizeClient(640, 480);
m_pm.SetMinMaxInfo(640,480);
}
void CEditPageWnd::Notify(TNotifyUI& msg)
{
if( msg.sType == _T("click") && msg.pSender->GetName() == _T("cancel") ) Close();
if( msg.sType == _T("link") && msg.pSender->GetName() == _T("warning") ) {
CPopupWnd* pPopup = new CPopupWnd;
pPopup->Create(m_hWnd, _T(""), UI_WNDSTYLE_DIALOG, UI_WNDSTYLE_EX_DIALOG, 0, 0, 0, 0, NULL);
pPopup->ShowModal();
}
CStandardPageWnd::Notify(msg);
}
LPCTSTR CEditPageWnd::GetDialogResource() const
{
return _T("<Dialog caption=\"Rediger Person\" >")
_T("<VerticalLayout>")
_T("<Toolbar>")
_T("<ToolGripper />")
_T("<ToolButton text=\"<i 0> Luk\" name=\"cancel\" />")
_T("<ToolButton text=\"<i 1>\" />")
_T("<ToolSeparator />")
_T("</Toolbar>")
_T("<TitleShadow />")
_T("<DialogCanvas>")
_T("<VerticalLayout>")
_T("<WarningPanel name=\"warning\" type=\"warning\" text=\"<i 7>You have not specified an e-mail address.\nTry entering one. Click <a>here</a> to get more help.\" />")
_T("<TabFolder>")
_T("<TabPage text=\"Generelt\" >")
_T("<DialogLayout scrollbar=\"true\" >")
_T("<LabelPanel pos=\"0, 0, 110, 24\" text=\"&name\" stretch=\"group\" />")
_T("<SingleLineEdit pos=\"110, 2, 240, 22\" name=\"name\" text=\"\" stretch=\"size_x\" />")
_T("<LabelPanel pos=\"260, 0, 370, 24\" text=\"Telefon 1\" stretch=\"move_x\" />")
_T("<SingleLineEdit pos=\"370, 2, 510, 22\" text=\"+45 12345678\" stretch=\"move_x size_x\" />")
_T("<LabelPanel pos=\"0, 30, 110, 54\" text=\"&Firma Nr\" stretch=\"group\" />")
_T("<SingleLineEdit pos=\"110, 32, 240, 52\" text=\"\" stretch=\"size_x\" />")
_T("<LabelPanel pos=\"260, 30, 370, 54\" text=\"Telefon 2\" stretch=\"move_x\" />")
_T("<SingleLineEdit pos=\"370, 32, 510, 52\" text=\"+45 87654321\" enabled=\"false\" stretch=\"move_x size_x\" />")
_T("<LabelPanel pos=\"0, 60, 110, 84\" text=\"Kontakt\" stretch=\"group\" />")
_T("<SingleLinePick pos=\"110, 62, 240, 82\" text=\"<i 3><a>Bjarke Vikse</a>\" stretch=\"size_x\" />")
_T("<LabelPanel pos=\"260, 60, 370, 84\" text=\"Website\" stretch=\"move_x\" />")
_T("<SingleLineEdit pos=\"370, 62, 510, 82\" text=\"www.viksoe.dk/code\" stretch=\"move_x size_x\" />")
_T("<GreyTextHeader pos=\"0, 100, 510, 120\" text=\"Adresse\" stretch=\"group size_x\" />")
_T("<LabelPanel pos=\"0, 130, 110, 154\" text=\"Vej\" stretch=\"group\" />")
_T("<SingleLinePick pos=\"110, 132, 240, 152\" text=\"<a>Nrrebred, Vallensbk</a>\" stretch=\"size_x\" />")
_T("<LabelPanel pos=\"260, 130, 370, 154\" text=\"Note\" stretch=\"move_x\" />")
_T("<MultiLineEdit pos=\"370, 132, 510, 192\" text=\"Dette er en meget lang note omkring denne person. Her flger noget mere tekst\" stretch=\"move_x size_x\" />")
_T("<LabelPanel pos=\"0, 160, 110, 184\" text=\"Post Nr\" stretch=\"line\" />")
_T("<DropDown pos=\"110, 162, 240, 182\" stretch=\"move_x size_x\">")
_T("<ListLabelElement text=\"2560 Holte\" selected=\"true\" />")
_T("<ListLabelElement text=\"2625 Vallensbk\" />")
_T("</DropDown>")
_T("<Option pos=\"0, 192, 120, 212\" text=\"Husnr krvet\" selected=\"true\" />")
_T("<Option pos=\"120, 192, 240, 212\" text=\"Ikke krvet\" />")
_T("</DialogLayout>")
_T("</TabPage>")
_T("<TabPage text=\"Egenskaber\" >")
_T("<VerticalLayout>")
_T("<Toolbar>")
_T("<PaddingPanel />")
_T("<ToolButton text=\"<i 0>\" />")
_T("<ToolButton text=\"<i 1>\" />")
_T("</Toolbar>")
_T("<ListHeaderShadow />")
_T("<List name=\"list\">")
_T("<ListHeaderItem enabled=\"false\" width=\"40\" />")
_T("<ListHeaderItem text=\"name\" width=\"140\" />")
_T("<ListHeaderItem text=\"Position\" width=\"80\" />")
_T("</List>")
_T("</VerticalLayout>")
_T("</TabPage>")
_T("</TabFolder>")
_T("</VerticalLayout>")
_T("</DialogCanvas>")
_T("<Statusbar text=\"<b>Status:</b> Klar\" />")
_T("</VerticalLayout>")
_T("</Dialog>");
}
void CEditPageWnd::OnPrepareAnimation()
{
const RECT rcCtrl = m_pm.FindControl(_T("warning"))->GetPos();
m_pm.AddAnimJob(CAnimJobUI(UIANIMTYPE_FLAT, 0, 300, CLR_INVALID, CLR_INVALID, rcCtrl, 0, 0, -2, -200, 0.0f));
}
////////////////////////////////////////////////////////////////////////
//
UINT CPopupWnd::GetClassStyle() const
{
return UI_CLASSSTYLE_DIALOG;
}
LPCTSTR CPopupWnd::GetWindowClassName() const
{
return _T("UIPopup");
}
void CPopupWnd::Init()
{
ResizeClient(440, 210);
CenterWindow();
}
void CPopupWnd::Notify(TNotifyUI& msg)
{
if( msg.sType == _T("click") ) Close();
CStandardPageWnd::Notify(msg);
}
LPCTSTR CPopupWnd::GetDialogResource() const
{
return _T("<Dialog>")
_T("<VerticalLayout>")
_T("<ToolbarTitlePanel text=\"<f 6>Er du sikker?</f><p><x 10>Er du sikker p?at du har trykket p?linket?\" />")
_T("<DialogCanvas>")
_T("<VerticalLayout>")
_T("<TextPanel text=\"Det er ikke altid godt at trykke p?linket. Du kan fortryde dit klik ved at vlge Nej knappen.\" />")
_T("<PaddingPanel />")
_T("<DialogLayout>")
_T("<PaddingPanel pos=\"0, 0, 340, 4\" />")
_T("<SeparatorLine pos=\"0, 4, 340, 18\" stretch=\"group size_x\" />")
_T("<PaddingPanel pos=\"0, 18, 160, 38\" stretch=\"group size_x\" />")
_T("<Button pos=\"180, 18, 256, 38\" text=\"Ja\" name=\"ok\" stretch=\"move_x\" />")
_T("<Button pos=\"260, 18, 340, 38\" text=\"Nej\" name=\"cancel\" stretch=\"move_x\" />")
_T("<PaddingPanel pos=\"0, 38, 340, 48\" />")
_T("</DialogLayout>")
_T("</VerticalLayout>")
_T("</DialogCanvas>")
_T("</VerticalLayout>")
_T("</Dialog>");
}
|
[
"[email protected]"
] |
[
[
[
1,
642
]
]
] |
097270af3cc364ab517402f4c1d424b6de824ff1
|
8fcf3f01e46f8933b356f763c61938ab11061a38
|
/Interface/sources/Rendering/SurfaceRender.cpp
|
ca62ec7ee254b834d61bf40f4d5e6a2697c7ddb8
|
[] |
no_license
|
jonesbusy/parser-effex
|
9facab7e0ff865d226460a729f6cb1584e8798da
|
c8c00e7f9cf360c0f70d86d1929ad5b44c5521be
|
refs/heads/master
| 2021-01-01T16:50:16.254785 | 2011-02-26T22:27:05 | 2011-02-26T22:27:05 | 33,957,768 | 0 | 0 | null | null | null | null |
ISO-8859-1
|
C++
| false | false | 3,975 |
cpp
|
#include "Rendering/SurfaceRender.h"
SurfaceRender::SurfaceRender(IExpression* function, double x1, double x2, const ItemData& data, QGraphicsScene* scene) : FunctionItem(function, data, scene)
{
// Inversion si besoin
if (x2 >= x1)
{
this->x1 = x1;
this->x2 = x2;
}
else
{
this->x1 = x2;
this->x2 = x1;
}
// Effet de transparence
QGraphicsOpacityEffect* effect = new QGraphicsOpacityEffect();
// 60 % d'opacité | 40 % de transparence
effect->setOpacity(0.6);
this->setGraphicsEffect(effect);
}
void SurfaceRender::compute(QRectF* bounds, int accuracy)
{
// Hors écran ?
if (bounds->right() <= this->x1 || bounds->left() >= this->x2)
{
this->surface = QPolygonF();
return;
}
// Calcul d'un nouveau delta
this->setYDelta(bounds);
// Optimisation des bords
double x1 = (this->x1 > bounds->left()) ? this->x1 : bounds->left();
double x2 = (this->x2 < bounds->right()) ? this->x2 : bounds->right();
// Incrément
double increment = (x2 - x1) / (((x2 - x1) / bounds->width()) * accuracy);
// Recherche d'un côté gauche fiable
while (true)
{
// Point y
double y = this->eval(bounds, x1);
// Côté gauche trouvé ?
if (this->getStatus(bounds, y) != UNDEFINED)
break;
// Incrémentation
x1 += increment;
// Figure impossible à représenter ?
if (x1 > x2)
{
this->surface = QPolygonF();
return;
}
}
// Valeur y de base (optimisation)
double yBase = 0;
if (bounds->top() > 0)
yBase = bounds->top() - this->getYDelta();
else if (bounds->bottom() < 0)
yBase = bounds->bottom() + this->getYDelta();
// Points du polygone
QVector<QPointF> points;
// Premier point
points.push_back(QPointF(x1, yBase));
// Limite en x
double xLimit = x2 + increment / 2.0;
// Calcul de tous les points
for (double x = x1; x <= xLimit; x += increment)
{
double y = this->eval(bounds, x);
if (this->getStatus(bounds, y) != UNDEFINED)
points.push_back(QPointF(x, y));
}
// Dernier point
points.push_back(QPointF(points.last().x(), yBase));
// Création de la surface
this->surface = QPolygonF(points);
// Invoque un rafraîchissement d'affichage
this->update();
}
void SurfaceRender::setColor(const QColor& color)
{
// Couleurs intermédiaires
QColor middleColor1 = color;
QColor middleColor2 = color;
middleColor1.setRed(middleColor1.red() / 1.1);
middleColor1.setGreen(middleColor1.green() / 1.1);
middleColor1.setBlue(middleColor1.blue() / 1.1);
middleColor2.setRed(middleColor2.red() / 1.7);
middleColor2.setGreen(middleColor2.green() / 1.7);
middleColor2.setBlue(middleColor2.blue() / 1.7);
// Nouveau dégradé
this->gradient = QLinearGradient();
gradient.setCoordinateMode(QGradient::ObjectBoundingMode);
// Affectation des couleurs
gradient.setColorAt(0.0, color);
gradient.setColorAt(0.3, middleColor2);
gradient.setColorAt(0.5, middleColor1);
gradient.setColorAt(0.7, middleColor2);
gradient.setColorAt(1.0, color);
// Appel du parent
FunctionItem::setColor(color);
}
QRectF SurfaceRender::boundingRect() const
{
return this->surface.boundingRect();
}
void SurfaceRender::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
// Surface non visible ?
if (this->surface.isEmpty())
return;
// Pinceau
painter->setPen(this->getPen());
// Dégradé
painter->setBrush(this->gradient);
// Dessin de la surface
painter->drawPolygon(this->surface);
}
|
[
"jonesbusy@fa255007-c97c-c9ae-ff28-e9f0558300b6"
] |
[
[
[
1,
159
]
]
] |
01b271a6c6bbdf22b79fcdd8d5376708f82509bf
|
91b964984762870246a2a71cb32187eb9e85d74e
|
/SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/test/example/unit_test_example_09_1.cpp
|
91403d532bf4a49272aa8bdab76c2ee925635a94
|
[
"LicenseRef-scancode-unknown-license-reference",
"BSL-1.0"
] |
permissive
|
willrebuild/flyffsf
|
e5911fb412221e00a20a6867fd00c55afca593c7
|
d38cc11790480d617b38bb5fc50729d676aef80d
|
refs/heads/master
| 2021-01-19T20:27:35.200154 | 2011-02-10T12:34:43 | 2011-02-10T12:34:43 | 32,710,780 | 3 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,028 |
cpp
|
// (C) Copyright Gennadiy Rozental 2005-2006.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/test for the library home page.
// Boost.Test
#define BOOST_TEST_MODULE Unit_test_example_09
#include <boost/test/unit_test.hpp>
// STL
#include <iostream>
//____________________________________________________________________________//
struct MyConfig {
MyConfig() { std::cout << "global setup part1\n"; }
~MyConfig() { std::cout << "global teardown part1\n"; }
};
// structure MyConfig is used as a global fixture - it's invoked pre and post any testing is perfrmed
BOOST_GLOBAL_FIXTURE( MyConfig )
//____________________________________________________________________________//
BOOST_AUTO_TEST_CASE( my_test1 )
{
BOOST_CHECK( true );
}
//____________________________________________________________________________//
// EOF
|
[
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
] |
[
[
[
1,
34
]
]
] |
ae82b13e3d3bbf988bd5116942624ea1b15f6d24
|
90aa2eebb1ab60a2ac2be93215a988e3c51321d7
|
/castor/branches/boost/libs/castor/test/test_io.cpp
|
acb3ca6fa8d3d7ad926c4d6bc9aa222aa1651cd8
|
[
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
roshannaik/castor
|
b9f4ea138a041fe8bccf2d8fc0dceeb13bcca5a6
|
e86e2bf893719bf3164f9da9590217c107cbd913
|
refs/heads/master
| 2021-04-18T19:24:38.612073 | 2010-08-18T05:10:39 | 2010-08-18T05:10:39 | 126,150,539 | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 6,779 |
cpp
|
#include <boost/castor.h>
#include <boost/test/minimal.hpp>
#include <sstream>
#include <vector>
using namespace castor;
namespace {
struct Base {
int b;
Base() : b(0) { }
};
struct Derived : Base {
int d;
Derived() : d(1), Base() { }
};
} // namespace
int getN(int, int, int, int, int, int) { return 6; }
struct num {
int i;
num(int i) : i(i) {}
num(const num& n) : i(n.i) {}
num operator+ (const num& r) const {
return num(i + r.i);
}
static num static_compute(num i, num j, num k) {
return num(i.i + j.i / k.i);
}
num nonstatic_compute(num i, num j, num k) {
return num(i.i + j.i / k.i);
}
};
num operator*(num l, num r) {
return num(l.i * r.i);
}
std::ostream& operator<< (std::ostream &o, const num& n) {
return o << n.i;
}
struct Functor6 {
typedef int result_type;
static int result;
int operator() (void) { return 0; }
int operator() (int i1) { return i1; }
int operator() (int i1, int i2) { return i1 + i2; }
int operator() (int i1, int i2, int i3) { return i1 + i2 + i3; }
int operator() (int i1, int i2, int i3, int i4) { return i1 + i2 + i3 + i4; }
int operator() (int i1, int i2, int i3, int i4, int i5) { return i1 + i2 + i3 + i4 + i5; }
int operator() (int i1, int i2, int i3, int i4, int i5, int i6) { return i1 + i2 + i3 + i4 + i5 + i6; }
int method (void) { return 0; }
int method (int i1) { return i1; }
int method (int i1, int i2) { return i1 + i2; }
int method (int i1, int i2, int i3) { return i1 + i2 + i3; }
int method (int i1, int i2, int i3, int i4) { return i1 + i2 + i3 + i4; }
int method (int i1, int i2, int i3, int i4, int i5) { return i1 + i2 + i3 + i4 + i5; }
int method (int i1, int i2, int i3, int i4, int i5, int i6) { return i1 + i2 + i3 + i4 + i5 + i6; }
int method (int i1, int i2, int i3) const { return i1 + i2 + i3; }
int max(int i, int j) { return (i > j) ? i : j; }
double max(double i, double j) { return (i > j) ? i : j; }
};
int test_main(int, char * [])
{
{ // write value to stream
std::stringstream sstrm;
BOOST_CHECK(writeTo(sstrm, "Hello")());
std::string s;
sstrm >> s;
BOOST_CHECK(s == "Hello");
}
std::string as[] = {"1", "2", "3", "4"};
{ // write to stream using pointers
std::stringstream sstrm;
BOOST_CHECK(writeAllTo(sstrm, as, as + 4, " ")());
std::string s; int i=0;
while (sstrm >> s) {
BOOST_CHECK(s == as[i++]);
}
}
{ // write to stream using iterators
std::stringstream sstrm;
std::vector<std::string> vs (as, as + 4);
BOOST_CHECK(writeAllTo(sstrm, vs.begin(), vs.end(), "")());
std::string s;
while (sstrm >> s) {
BOOST_CHECK(s == "1234");
}
}
{ // write container to stream
std::stringstream sstrm;
lref<const std::vector<std::string> > vls = std::vector<std::string>(as, as + 4);
BOOST_CHECK(writeAllTo(sstrm, vls, "")());
std::string s;
while (sstrm >> s) {
BOOST_CHECK(s == "1234");
}
}
{ // acquire lref<iterators> relationally and then use them with writeAllTo
std::stringstream sstrm;
lref<std::vector<std::string> > lvs = std::vector<std::string>(as, as + 4);
lref<std::vector<std::string>::iterator> b, e;
relation r = begin(lvs, b) && end(lvs, e) && writeAllTo(sstrm, b, e, "");
while (r());
std::string s;
while (sstrm >> s) {
BOOST_CHECK(s == "1234");
}
}
{ // write value of computing an ILE to stream
std::stringstream sstrm;
lref<num> i=3;
writeTo_f(sstrm, i + i * i)();
BOOST_CHECK(sstrm.str() == "12");
}
{ // write value of computing a func
std::stringstream sstrm;
lref<num> i=3;
writeTo_f(sstrm, &num::static_compute, i, 3, i)();
BOOST_CHECK(sstrm.str() == "4");
}
{
std::stringstream sstrm;
lref<int> i=3;
writeTo_f(sstrm, Functor6(), i, i, i)();
BOOST_CHECK(sstrm.str() == "9");
}
{
std::stringstream sstrm;
lref<num> i=3;
lref<num> n(5);
writeTo_mf(sstrm, n, &num::nonstatic_compute, i, i, i)();
BOOST_CHECK(sstrm.str() == "4");
}
{
typedef std::pair<std::string, std::string> name;
lref<name> me = name("Roshan", "Naik");
std::stringstream sstrm;
writeTo_mem(sstrm, me, &name::first)();
BOOST_CHECK(sstrm.str() == "Roshan");
}
{ // base class member
lref<Derived> d = Derived();
std::stringstream sstrm;
writeTo_mem(sstrm, d, &Base::b)();
writeTo_mem(sstrm, d, &Derived::b)();
writeTo_mem(sstrm, d, &Derived::d)();
BOOST_CHECK(sstrm.str()=="001");
}
{ // write value to stream and then read it
std::stringstream sstrm;
relation r = writeTo(sstrm, "Hello") && readFrom(sstrm, "Hello");
BOOST_CHECK(r());
}
{ // copy words from one stream to another
std::stringstream inputData, outputData;
inputData << "Hello World.";
lref<std::string> ls;
relation copyWords = readFrom(inputData, ls) && writeTo(outputData, ls);
int count=0;
while (copyWords()) { ++count; }
BOOST_CHECK(count == 2 && !ls.defined());
}
{ // read value into undefined lref
std::stringstream sstrm;
sstrm << "Hello";
lref<std::string> s;
BOOST_CHECK(readFrom(sstrm, s)());
}
{ // read value into defined lref
std::stringstream sstrm;
sstrm << "Hello";
lref<std::string> s = "Hello";
BOOST_CHECK(readFrom(sstrm, s)());
}
{ // read value into defined lref
std::stringstream sstrm;
sstrm << "Hello";
BOOST_CHECK(!readFrom(sstrm, "World")());
}
{ // read all values from stream
std::stringstream sstrm;
sstrm << "Hello World";
lref<std::string> s;
relation r = readFrom(sstrm, s);
BOOST_CHECK(r() && *s == "Hello");
BOOST_CHECK(r() && *s == "World");
}
return 0;
}
|
[
"[email protected]",
"[email protected]"
] |
[
[
[
1,
1
],
[
3,
3
],
[
5,
6
],
[
9,
9
],
[
23,
23
],
[
28,
28
],
[
30,
30
],
[
32,
32
],
[
35,
35
],
[
45,
45
],
[
49,
49
],
[
55,
55
],
[
60,
77
],
[
80,
96
],
[
98,
107
],
[
109,
120
],
[
123,
148
],
[
152,
152
],
[
154,
156
],
[
160,
160
],
[
162,
163
],
[
165,
165
],
[
167,
169
],
[
172,
173
],
[
176,
176
],
[
178,
179
],
[
181,
185
],
[
187,
188
],
[
192,
192
],
[
200,
216
],
[
219,
219
],
[
221,
227
],
[
229,
235
],
[
237,
242
],
[
244,
251
]
],
[
[
2,
2
],
[
4,
4
],
[
7,
8
],
[
10,
22
],
[
24,
27
],
[
29,
29
],
[
31,
31
],
[
33,
34
],
[
36,
44
],
[
46,
48
],
[
50,
54
],
[
56,
59
],
[
78,
79
],
[
97,
97
],
[
108,
108
],
[
121,
122
],
[
149,
151
],
[
153,
153
],
[
157,
159
],
[
161,
161
],
[
164,
164
],
[
166,
166
],
[
170,
171
],
[
174,
175
],
[
177,
177
],
[
180,
180
],
[
186,
186
],
[
189,
191
],
[
193,
199
],
[
217,
218
],
[
220,
220
],
[
228,
228
],
[
236,
236
],
[
243,
243
],
[
252,
252
]
]
] |
ad0ec2bd9a7013856aabfa5e15f6b462311cd270
|
bd89d3607e32d7ebb8898f5e2d3445d524010850
|
/adaptationlayer/modematadaptation/modematcommon_dll/src/modemat_common.cpp
|
20efbaf4b94c4d0d330114f69ac814072867687b
|
[] |
no_license
|
wannaphong/symbian-incubation-projects.fcl-modemadaptation
|
9b9c61ba714ca8a786db01afda8f5a066420c0db
|
0e6894da14b3b096cffe0182cedecc9b6dac7b8d
|
refs/heads/master
| 2021-05-30T05:09:10.980036 | 2010-10-19T10:16:20 | 2010-10-19T10:16:20 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 24,492 |
cpp
|
/*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/
#include "modemat_common.h"
#include "modemattrace.h"
#include "OstTraceDefinitions.h"
#ifdef OST_TRACE_COMPILER_IN_USE
#include "modemat_commonTraces.h"
#endif
_LIT8(KAtNvramStatusCmd, "at&v");
_LIT8(KEchoMode, "*E? *");
_LIT8(KVerboseMode, "* V? *");
_LIT8(KQuietMode, "* Q? *");
_LIT8(KCarriageChar, "*S03:??? *");
_LIT8(KLineFeedChar, "*S04:??? *");
_LIT8(KBackspaceChar, "*S05:??? *");
const TUint8 EchoModeOffset(1);
const TUint8 VerboseModeOffset(2);
const TUint8 QuietModeOffset(2);
const TUint8 CarriageCharOffset(4);
const TUint8 LineFeedCharOffset(4);
const TUint8 BackspaceCharOffset(4);
const TInt KNvramCommandLength(20);
const TInt KNvramBufLength(1024);
const TInt KReplyTypeOther( 3 );
const TInt KEchoOn( 1 );
const TInt KEchoOff( 2 );
const TInt KVerboseOn( 3 );
const TInt KVerboseOff( 4 );
const TInt KQuietOn( 5 );
const TInt KQuietOff( 6 );
#define KDefaultBackSpace 8
#define KDefaultLineFeed 10
#define KDefaultCarriageChar 13
#define KDefaultEchoMode 1
#define KDefaultQuietMode 0
#define KDefaultVerboseMode 1
#define KValueOn 1
#define KValueOff 0
CModemAtCommon* CModemAtCommon::NewL()
{
C_TRACE((_L("CModemAtCommon::NewL")));
OstTrace0( TRACE_NORMAL, CMODEMATCOMMON_NEWL, "CModemAtCommon::NewL" );
CModemAtCommon* self = new (ELeave) CModemAtCommon();
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::Pop(self);
C_TRACE((_L("return 0x%x"), self));
return self;
}
CModemAtCommon::~CModemAtCommon()
{
C_TRACE((_L("CModemAtCommon::~CModemAtCommon")));
OstTrace0( TRACE_NORMAL, CMODEMATCOMMON_CMODEMATCOMMON, "CModemAtCommon::~CModemAtCommon" );
iRModemAt.Disconnect();
delete iNvramStatus;
iNvramStatus = NULL;
}
CModemAtCommon::CModemAtCommon() :
iReceiveModeStatusChange( 0 ),
iReceiveNvramStatusChange( 0 ),
iEchoMode( KDefaultEchoMode ),
iQuietMode( KDefaultQuietMode ),
iVerboseMode( KDefaultVerboseMode ),
iCarriageChar( KDefaultCarriageChar ),
iLineFeedChar( KDefaultLineFeed ),
iBackspaceChar( KDefaultBackSpace ),
iCommandMode( EIgnore )
{
C_TRACE((_L("CModemAtCommon::CModemAtCommon")));
OstTrace0( TRACE_NORMAL, DUP1_CMODEMATCOMMON_CMODEMATCOMMON, "CModemAtCommon::CModemAtCommon" );
}
void CModemAtCommon::ConstructL()
{
C_TRACE((_L("CModemAtCommon::ConstructL")));
OstTrace0( TRACE_NORMAL, CMODEMATCOMMON_CONSTRUCTL, "CModemAtCommon::ConstructL" );
iNvramStatus = HBufC8::NewL( KNvramBufLength );
C_TRACE((_L("KNvramBufLength : %d"), KNvramBufLength ));
OstTrace1( TRACE_NORMAL, DUP1_CMODEMATCOMMON_CONSTRUCTL, "CModemAtCommon::ConstructL;KNvramBufLength=%d", KNvramBufLength );
}
void CModemAtCommon::ReportConnectionName( const TDesC8& aName )
{
C_TRACE((_L("CModemAtCommon::ReportConnectionName()")));
OstTraceExt1( TRACE_NORMAL, CMODEMATCOMMON_REPORTCONNECTIONNAME, "CModemAtCommon::ReportConnectionName;aName=%s", aName );
iMediaName = aName;
DUMP_MESSAGE(aName);
iRModemAt.Connect( ECommonPlugin, iMediaName, this );
TBuf8<KNvramCommandLength> command;
command.Copy(KAtNvramStatusCmd);
command.Append(iCarriageChar);
TPtr8 tempPtr( iNvramStatus->Des() );
#ifndef __WINSCW__
iRModemAt.GetNvramStatus(command, tempPtr);
#else
tempPtr.Copy(_L8("||ACTIVE PROFILE:||E1 Q0 V1 X5 &C1 &D2 &S0 &Y0||+CVHU=1 +DS=0,0,2048,32 +DR=0||S00:000 S01:000 S02:043 S03:013 S04:010 S05:008 S07:060 S08:002||S10:100 S12:050 S25:000||||OK||"));
#endif
ParseNvramStatus();
}
TInt CModemAtCommon::GetMode( TUint aMask, TUint& aMode )
{
C_TRACE((_L("CModemAtCommon::GetMode()")));
OstTrace0( TRACE_NORMAL, CMODEMATCOMMON_GETMODE, "CModemAtCommon::GetMode" );
#ifdef _DEBUG
PrintModes();
#endif
aMode = 0;
if ( aMask & KModeEcho )
{
aMode |= iEchoMode * KEchoModeBase;
C_TRACE((_L("echomode %d"), aMode));
OstTrace1( TRACE_NORMAL, DUP1_CMODEMATCOMMON_GETMODE, "echomode;aMode=%u", aMode );
}
if ( aMask & KModeQuiet )
{
aMode |= iQuietMode * KQuietModeBase;
C_TRACE((_L("quietmode %d"), aMode));
OstTrace1( TRACE_NORMAL, DUP2_CMODEMATCOMMON_GETMODE, "quietmode;aMode=%u", aMode );
}
if ( aMask & KModeVerbose )
{
aMode |= iVerboseMode * KVerboseModeBase;
C_TRACE((_L("verbosemode %d"), aMode));
OstTrace1( TRACE_NORMAL, DUP3_CMODEMATCOMMON_GETMODE, "verbosemode;aMode=%u", aMode );
}
if ( aMask & KModeCarriage )
{
aMode = iCarriageChar;
C_TRACE((_L("Carriage return")));
OstTrace0( TRACE_NORMAL, DUP4_CMODEMATCOMMON_GETMODE, "carriage return" );
}
if ( aMask & KModeLineFeed )
{
aMode = iLineFeedChar;
C_TRACE((_L("line feed")));
OstTrace0( TRACE_NORMAL, DUP5_CMODEMATCOMMON_GETMODE, "line feed" );
}
if ( aMask & KModeBackspace )
{
C_TRACE((_L("backspace")));
OstTrace0( TRACE_NORMAL, DUP6_CMODEMATCOMMON_GETMODE, "backspace" );
aMode = iBackspaceChar;
}
if( aMode )
{
C_TRACE((_L("return KErrNone")));
OstTrace0( TRACE_NORMAL, DUP7_CMODEMATCOMMON_GETMODE, "return KErrNone" );
return KErrNone;
}
C_TRACE((_L("return KErrNotSupported")));
OstTrace0( TRACE_NORMAL, DUP8_CMODEMATCOMMON_GETMODE, "return KErrNotSupported" );
return KErrNotSupported;
}
TInt CModemAtCommon::ReceiveModeStatusChange()
{
OstTrace0( TRACE_NORMAL, CMODEMATCOMMON_RECEIVEMODESTATUSCHANGE, "CModemAtCommon::ReceiveModeStatusChange" );
C_TRACE((_L("CModemAtCommon::ReceiveModeStatusChange()")));
iReceiveModeStatusChange++;
return KErrNone;
}
void CModemAtCommon::CancelReceiveModeStatusChange()
{
OstTrace0( TRACE_NORMAL, CMODEMATCOMMON_CANCELRECEIVEMODESTATUSCHANGE, "CModemAtCommon::CancelReceiveModeStatusChange" );
C_TRACE((_L("CModemAtCommon::CancelReceiveModeStatusChange()")));
if( iReceiveModeStatusChange > 0 )
{
iReceiveModeStatusChange--;
}
}
TInt CModemAtCommon::GetNvramStatus( RBuf8& aNvram )
{
C_TRACE((_L("CModemAtCommon::GetNvramStatus")));
OstTrace0( TRACE_NORMAL, CMODEMATCOMMON_GETNVRAMSTATUS, "CModemAtCommon::GetNvramStatus" );
TInt retVal ( KErrNone );
TPtr8 response( iNvramStatus->Des() );
TBuf8<KNvramCommandLength> cmd;
cmd.Copy(KAtNvramStatusCmd);
cmd.Append(iCarriageChar);
retVal = iRModemAt.GetNvramStatus( cmd, response );
C_TRACE( (_L("CModemAtCommon::GetNvramStatus Creating response for atext")));
OstTrace0( TRACE_NORMAL, DUP1_CMODEMATCOMMON_GETNVRAMSTATUS, "CModemAtCommon::GetNvramStatus Creating response for atext" );
aNvram.Create( response ); //atext deletes message
return retVal;
}
TInt CModemAtCommon::ReceiveNvramStatusChange()
{
C_TRACE((_L("CModemAtCommon::ReceiveNvramStatusChange()")));
OstTrace0( TRACE_NORMAL, CMODEMATCOMMON_RECEIVENVRAMSTATUSCHANGE, "CModemAtCommon::ReceiveNvramStatusChange" );
iReceiveNvramStatusChange++;
return KErrNone;
}
void CModemAtCommon::CancelReceiveNvramStatusChange()
{
C_TRACE((_L("CModemAtCommon::CancelReceiveNvramStatusChange()")));
OstTrace0( TRACE_NORMAL, CMODEMATCOMMON_CANCELRECEIVENVRAMSTATUSCHANGE, "CModemAtCommon::CancelReceiveNvramStatusChange" );
if( iReceiveNvramStatusChange > 0)
{
iReceiveNvramStatusChange--;
}
}
void CModemAtCommon::HandleATCommandCompleted( TInt /*aErr*/ )
{
C_TRACE((_L("CModemAtCommon::HandleATCommandCompleted()")));
OstTrace0( TRACE_NORMAL, CMODEMATCOMMON_HANDLEATCOMMANDCOMPLETED, "CModemAtCommon::HandleATCommandCompleted" );
//not used by common plugin
}
TBool CModemAtCommon::HasNvramStatusChanged()
{
C_TRACE((_L("CModemAtCommon::HasNvramStatusChanged")));
OstTrace0( TRACE_NORMAL, CMODEMATCOMMON_HASNVRAMSTATUSCHANGED, "CModemAtCommon::HasNvramStatusChanged" );
HBufC8* oldNvramBuf(NULL);
TRAPD( err, oldNvramBuf = HBufC8::NewL( KNvramBufLength ) );
ASSERT_PANIC_ALWAYS( err == KErrNone );
oldNvramBuf->Des().Copy( iNvramStatus->Des() );
C_TRACE((_L("Making AT&V query")));
OstTrace0( TRACE_NORMAL, DUP1_CMODEMATCOMMON_HASNVRAMSTATUSCHANGED, "Making AT&V query" );
TBuf8<KNvramCommandLength> cmd;
cmd.Copy( KAtNvramStatusCmd );
cmd.Append( iCarriageChar );
C_TRACE((_L("Old:")));
TPtr8 oldNvramPtr( oldNvramBuf->Des() );
DUMP_MESSAGE( oldNvramPtr );
OstTraceExt1( TRACE_NORMAL, DUP2_CMODEMATCOMMON_HASNVRAMSTATUSCHANGED, "Old:;oldNvramPtr=%s", oldNvramPtr );
TPtr8 newNvramPtr( iNvramStatus->Des() );
TInt nvramStatus = iRModemAt.GetNvramStatus( cmd, newNvramPtr );
if( nvramStatus != KErrNone &&
nvramStatus != KReplyTypeOther )
{
// at&v can't be handled in data mode. Then this is ignored.
C_TRACE((_L("Nvram status NOT changed, pipe is in data mode")));
OstTrace0( TRACE_NORMAL, DUP3_CMODEMATCOMMON_HASNVRAMSTATUSCHANGED, "Nvram status NOT changed, pipe is in data mode" );
delete oldNvramBuf;
return EFalse;
}
C_TRACE((_L("New:")));
DUMP_MESSAGE((newNvramPtr));
OstTraceExt1( TRACE_NORMAL, DUP4_CMODEMATCOMMON_HASNVRAMSTATUSCHANGED, "New:;newNvramPtr=%s", newNvramPtr );
if( oldNvramPtr.Compare( newNvramPtr ) == KErrNone )
{
C_TRACE((_L("Nvram status NOT changed")));
OstTrace0( TRACE_NORMAL, DUP5_CMODEMATCOMMON_HASNVRAMSTATUSCHANGED, "Nvram status NOT changed" );
delete oldNvramBuf;
return EFalse;
}
delete oldNvramBuf;
C_TRACE((_L("Nvram status HAS changed")));
OstTrace0( TRACE_NORMAL, DUP6_CMODEMATCOMMON_HASNVRAMSTATUSCHANGED, "Nvram status HAS changed" );
return ETrue;
}
TUint CModemAtCommon::GetChangedMode()
{
C_TRACE((_L("CModemAtCommon::GetChangedMode()")));
OstTrace0( TRACE_NORMAL, CMODEMATCOMMON_GETCHANGEDMODE, "CModemAtCommon::GetChangedMode" );
TUint newMode( 0 ); //mask for mode changes
TUint8 oldEchoMode( iEchoMode );
TUint8 oldQuietMode( iQuietMode );
TUint8 oldVerboseMode( iVerboseMode );
TUint8 oldCarriageChar( iCarriageChar );
TUint8 oldLineFeedChar( iLineFeedChar );
TUint8 oldBackspaceChar( iBackspaceChar );
ParseNvramStatus();
if( iReceiveModeStatusChange )
{
C_TRACE((_L("iReceiveModeStatusChange true")));
OstTrace0( TRACE_NORMAL, DUP1_CMODEMATCOMMON_GETCHANGEDMODE, "iReceiveModeStatusChange true" );
if (oldEchoMode != iEchoMode)
{
OstTrace0( TRACE_NORMAL, DUP2_CMODEMATCOMMON_GETCHANGEDMODE, "KEchoModeChanged" );
C_TRACE((_L("KEchoModeChanged")));
newMode |= KEchoModeChanged;
newMode |= iEchoMode*KModeEcho;
}
if (oldQuietMode != iQuietMode)
{
OstTrace0( TRACE_NORMAL, DUP3_CMODEMATCOMMON_GETCHANGEDMODE, "KQuietModeChanged" );
C_TRACE((_L("KQuietModeChanged")));
newMode |= KQuietModeChanged;
newMode |= iQuietMode*KModeQuiet;
}
if (oldVerboseMode != iVerboseMode)
{
OstTrace0( TRACE_NORMAL, DUP4_CMODEMATCOMMON_GETCHANGEDMODE, "KVerboseModeChanged" );
C_TRACE((_L("KVerboseModeChanged")));
newMode |= KVerboseModeChanged;
newMode |= iVerboseMode*KModeVerbose;
}
if (oldCarriageChar != iCarriageChar)
{
OstTrace0( TRACE_NORMAL, DUP5_CMODEMATCOMMON_GETCHANGEDMODE, "KCarriageChanged" );
C_TRACE((_L("KCarriageChanged")));
newMode |= KCarriageChanged;
newMode |= iCarriageChar;
}
if (oldLineFeedChar != iLineFeedChar)
{
OstTrace0( TRACE_NORMAL, DUP6_CMODEMATCOMMON_GETCHANGEDMODE, "KLineFeedChanged" );
C_TRACE((_L("KLineFeedChanged")));
newMode |= KLineFeedChanged;
newMode |= iLineFeedChar;
}
if (oldBackspaceChar != iBackspaceChar)
{
OstTrace0( TRACE_NORMAL, DUP7_CMODEMATCOMMON_GETCHANGEDMODE, "KBackspaceChanged" );
C_TRACE((_L("KBackspaceChanged")));
newMode |= KBackspaceChanged;
newMode |= iBackspaceChar;
}
}
return newMode;
}
void CModemAtCommon::HandleSignalIndication( TInt aErr )
{
OstTrace1( TRACE_NORMAL, CMODEMATCOMMON_HANDLESIGNALINDICATION, "CModemAtCommon::HandleSignalIndication;aErr=%d", aErr );
C_TRACE((_L("CModemAtCommon::HandleSignalIndication(%d)"), aErr));
if( aErr < KErrNone )
{
OstTrace1( TRACE_NORMAL, DUP1_CMODEMATCOMMON_HANDLESIGNALINDICATION, "SignalIndication Error;aErr=%d", aErr );
C_TRACE((_L("SignalIndication Error %d"), aErr ));
return;
}
else if( aErr > KErrNone )
{
TBool indicationHandled( EFalse );
TUint newMode( 0 );
TUint8 oldEchoMode( iEchoMode );
TUint8 oldQuietMode( iQuietMode );
TUint8 oldVerboseMode( iVerboseMode );
switch( aErr )
{
case KEchoOff:
{
iEchoMode = KValueOff;
indicationHandled = ETrue;
break;
}
case KEchoOn:
{
iEchoMode = KValueOn;
indicationHandled = ETrue;
break;
}
case KVerboseOn:
{
iVerboseMode = KValueOn;
indicationHandled = ETrue;
break;
}
case KVerboseOff:
{
iVerboseMode = KValueOff;
indicationHandled = ETrue;
break;
}
case KQuietOn:
{
iQuietMode = KValueOn;
indicationHandled = ETrue;
break;
}
case KQuietOff:
{
iQuietMode = KValueOff;
indicationHandled = ETrue;
break;
}
default:
{
OstTrace1( TRACE_NORMAL, DUP2_CMODEMATCOMMON_HANDLESIGNALINDICATION, "SignalIndication Error;aErr=%d", aErr );
C_TRACE((_L("SignalIndication Error %d"), aErr ));
indicationHandled = EFalse;
break;
}
}
if( oldEchoMode != iEchoMode )
{
OstTrace0( TRACE_NORMAL, DUP3_CMODEMATCOMMON_HANDLESIGNALINDICATION, "SignalIndication KEchoModeChanged" );
C_TRACE((_L("SignalIndication KEchoModeChanged")));
newMode |= KEchoModeChanged;
newMode |= iEchoMode * KModeEcho;
}
if( oldQuietMode != iQuietMode )
{
OstTrace0( TRACE_NORMAL, DUP4_CMODEMATCOMMON_HANDLESIGNALINDICATION, "SignalIndication KModeQuietChanged" );
C_TRACE((_L("SignalIndication KQuietModeChanged")));
newMode |= KQuietModeChanged;
newMode |= iQuietMode * KModeQuiet;
}
if( oldVerboseMode != iVerboseMode )
{
OstTrace0( TRACE_NORMAL, DUP5_CMODEMATCOMMON_HANDLESIGNALINDICATION, "SignalIndication KVerboseModeChanged" );
C_TRACE((_L("SignalIndication KVerboseModeChanged")));
newMode |= KVerboseModeChanged;
newMode |= iVerboseMode * KModeVerbose;
}
if( indicationHandled )
{
OstTrace0( TRACE_NORMAL, DUP6_CMODEMATCOMMON_HANDLESIGNALINDICATION, "Indication handled by common plug-in." );
C_TRACE((_L("Indication handled by common plug-in.")));
if( newMode )
{
OstTrace0( TRACE_NORMAL, DUP7_CMODEMATCOMMON_HANDLESIGNALINDICATION, "Mode changed" );
C_TRACE((_L("Mode changed")));
SendModeStatusChange( newMode );
}
return;
}
}
OstTrace0( TRACE_NORMAL, DUP8_CMODEMATCOMMON_HANDLESIGNALINDICATION, "Indication is handled by common plug-in, by using AT&V query." );
C_TRACE((_L("Indication is handled by common plug-in, by using AT&V query.")));
TBool val = HasNvramStatusChanged();
if( val == EFalse )
{
OstTrace0( TRACE_NORMAL, DUP9_CMODEMATCOMMON_HANDLESIGNALINDICATION, "HasNvramStatusChanged EFalse" );
C_TRACE((_L("HasNvramStatusChanged EFalse")));
return;
}
//receive nvram status changes
if( iReceiveNvramStatusChange )
{
// call base class
OstTrace0( TRACE_NORMAL, DUP10_CMODEMATCOMMON_HANDLESIGNALINDICATION, "iReceiveNvramStatusChange true" );
C_TRACE((_L("iReceiveNvramStatusChange true")));
SendNvramStatusChange( iNvramStatus->Des() );
iReceiveNvramStatusChange--;
}
TUint newMode = GetChangedMode();
OstTrace1( TRACE_NORMAL, DUP11_CMODEMATCOMMON_HANDLESIGNALINDICATION, "newMode;newMode=%x", newMode );
C_TRACE((_L("Newmode 0x%x"),newMode));
if( newMode ) //mode is changed
{
OstTrace0( TRACE_NORMAL, DUP12_CMODEMATCOMMON_HANDLESIGNALINDICATION, "Mode changed" );
C_TRACE((_L("Mode changed")));
SendModeStatusChange( newMode );
}
}
void CModemAtCommon::ParseNvramStatus()
{
OstTrace0( TRACE_NORMAL, CMODEMATCOMMON_PARSENVRAMSTATUS, "CModemAtCommon::ParseNvramStatus" );
C_TRACE((_L("CModemAtCommon::ParseNvramStatus()")));
TUint8 value;
TInt retVal;
retVal = ParseValue(KEchoMode, EchoModeOffset, value);
if( retVal == KErrNone )
{
iEchoMode = value;
}
retVal = ParseValue( KVerboseMode, VerboseModeOffset, value);
if( retVal == KErrNone )
{
iVerboseMode = value;
}
retVal = ParseValue(KQuietMode, QuietModeOffset, value);
if( retVal == KErrNone )
{
iQuietMode = value;
}
retVal = ParseValue(KCarriageChar, CarriageCharOffset, value);
if( retVal == KErrNone )
{
OstTrace1( TRACE_NORMAL, DUP1_CMODEMATCOMMON_PARSENVRAMSTATUS, "CModemAtCommon::ParseNvramStatus - iCarriageChar;value=%d", value );
C_TRACE((_L("CModemAtCommon::ParseNvramStatus( ) iCarriageChar %d"), value));
iCarriageChar = value;
}
retVal = ParseValue(KLineFeedChar, LineFeedCharOffset, value);
if( retVal == KErrNone )
{
OstTrace1( TRACE_NORMAL, DUP2_CMODEMATCOMMON_PARSENVRAMSTATUS, "CModemAtCommon::ParseNvramStatus - iLineFeedChar;value=%d", value );
C_TRACE((_L("CModemAtCommon::ParseNvramStatus( ) iLineFeedChar %d"), value));
iLineFeedChar = value;
}
retVal = ParseValue(KBackspaceChar, BackspaceCharOffset, value);
if( retVal == KErrNone )
{
iBackspaceChar = value;
}
#ifdef _DEBUG
PrintModes();
#endif
}
TInt CModemAtCommon::ParseValue( const TDesC8& aReg, TInt aPos, TUint8& aValue)
{
OstTraceExt3( TRACE_NORMAL, CMODEMATCOMMON_PARSEVALUE, "CModemAtCommon::ParseValue;aReg=%s;aPos=%d;aValue=%p", aReg, aPos, &aValue );
C_TRACE((_L("CModemAtCommon::ParseValue( aPos: %d, aValue: 0x%x"), aPos, &aValue));
DUMP_MESSAGE(aReg);
TPtr8 tempPtr(iNvramStatus->Des());
TInt start = tempPtr.Match(aReg);
OstTraceExt2( TRACE_NORMAL, DUP1_CMODEMATCOMMON_PARSEVALUE, "Starting;start=%d;length=%d", start, tempPtr.Length() );
C_TRACE((_L("Starting %d length %d"), start, tempPtr.Length()));
if ( start < 0 )
{
return start;
}
TInt firstValueChar = aReg.Locate('?');
TInt valueChars = aReg.LocateReverse('?') - firstValueChar + 1;
OstTrace1( TRACE_NORMAL, DUP2_CMODEMATCOMMON_PARSEVALUE, "Firstvaluechar;firstValueChar=%d", firstValueChar );
OstTrace1( TRACE_NORMAL, DUP3_CMODEMATCOMMON_PARSEVALUE, "Valuechars;Valuechars=%d", valueChars );
C_TRACE((_L("Firstvaluechar %d"), firstValueChar));
C_TRACE((_L("Valuechars %d"), valueChars));
if( firstValueChar < 0 || valueChars == 0 || (start + aPos + valueChars >= tempPtr.Length()) )
{
TRACE_ASSERT_ALWAYS;
return KErrGeneral;
}
TBuf8<KNvramCommandLength> valueString;
valueString = tempPtr.Mid( start + aPos, valueChars);
OstTraceExt1( TRACE_NORMAL, DUP4_CMODEMATCOMMON_PARSEVALUE, "valueString dump;valueString=%s", valueString );
DUMP_MESSAGE((valueString));
TLex8 lex( valueString );
TInt value;
if( lex.Val(value) == KErrNone )
{
OstTrace1( TRACE_NORMAL, DUP5_CMODEMATCOMMON_PARSEVALUE, "Value;value=%d", value );
C_TRACE((_L("Value %d"), value));
aValue = value;
return KErrNone;
}
TRACE_ASSERT_ALWAYS;
return KErrGeneral;
}
#ifdef _DEBUG
void CModemAtCommon::PrintModes()
{
OstTrace0( TRACE_NORMAL, CMODEMATCOMMON_PRINTMODES, "CModemAtCommon::PrintModes" );
OstTrace1( TRACE_NORMAL, DUP1_CMODEMATCOMMON_PRINTMODES, "echo mode;iEchoMode=%d", iEchoMode );
OstTrace1( TRACE_NORMAL, DUP2_CMODEMATCOMMON_PRINTMODES, "quiet mode;iQuietMode=%d", iQuietMode );
OstTrace1( TRACE_NORMAL, DUP3_CMODEMATCOMMON_PRINTMODES, "verbose mode;iVerboseMode=%d", iVerboseMode );
OstTrace1( TRACE_NORMAL, DUP4_CMODEMATCOMMON_PRINTMODES, "Carriagechar mode;iCarriageChar=%d", iCarriageChar );
OstTrace1( TRACE_NORMAL, DUP5_CMODEMATCOMMON_PRINTMODES, "Linefeed char;iLineFeedChar=%d", iLineFeedChar );
OstTrace1( TRACE_NORMAL, DUP7_CMODEMATCOMMON_PRINTMODES, "Backspace mode;iBackspaceChar=%d", iBackspaceChar );
OstTrace1( TRACE_NORMAL, DUP8_CMODEMATCOMMON_PRINTMODES, "Command mode;iCommandMode=%d", (TInt)iCommandMode );
C_TRACE((_L("CModemAtCommon::PrintModes")));
C_TRACE((_L("echo mode %d"), iEchoMode));
C_TRACE((_L("quiet mode %d"), iQuietMode));
C_TRACE((_L("verbose mode %d"), iVerboseMode));
C_TRACE((_L("Carriagechar mode %d"), iCarriageChar));
C_TRACE((_L("Linefeed char %d"), iLineFeedChar));
C_TRACE((_L("Backspace mode %d"), iBackspaceChar));
C_TRACE((_L("Command mode %d"), (TInt)iCommandMode));
}
#endif
void CModemAtCommon::HandleUnsolicitedResultReceived(TInt /*aErr*/)
{
OstTrace0( TRACE_NORMAL, CMODEMATCOMMON_HANDLEUNSOLICITEDRESULTRECEIVED, "CModemAtCommon::HandleUnsolicitedResultReceived - ignored" );
C_TRACE((_L("CModemAtCommon::HandleUnsolicitedResultReceived - ignored")));
//unsolicitedresult is handled in atext-plugin
}
void CModemAtCommon::HandleCommandModeChanged( TInt aErr, TCommandMode aMode )
{
OstTraceExt2( TRACE_NORMAL, CMODEMATCOMMON_HANDLECOMMANDMODECHANGED, "CModemAtCommon::HandleCommandModeChanged;aErr=%d;aMode=%d", aErr, aMode );
C_TRACE((_L("CModemAtCommon::HandleCommandModeChanged( aErr: %d, aMode: %d) "), aErr, aMode));
iCommandMode = aMode;
TUint mode( 0 );
mode |= KCommandModeChanged;
if( aMode != EDataMode)
{
C_TRACE((_L("Not EDataMode")));
mode |= KModeCommand;
}
OstTrace1( TRACE_NORMAL, DUP1_CMODEMATCOMMON_HANDLECOMMANDMODECHANGED, "COMMON PLUGIN SendModeStatusChange:;mode=%x", mode );
C_TRACE((_L("COMMON PLUGIN SendModeStatusChange: 0x%x"), mode));
SendModeStatusChange( mode );
}
// End of File
|
[
"dalarub@localhost",
"mikaruus@localhost",
"[email protected]"
] |
[
[
[
1,
20
],
[
26,
42
],
[
51,
57
],
[
60,
63
],
[
65,
75
],
[
77,
93
],
[
95,
99
],
[
101,
102
],
[
104,
108
],
[
110,
127
],
[
129,
137
],
[
139,
143
],
[
145,
147
],
[
149,
149
],
[
151,
155
],
[
157,
161
],
[
163,
166
],
[
168,
172
],
[
174,
176
],
[
178,
182
],
[
184,
190
],
[
192,
201
],
[
203,
209
],
[
211,
217
],
[
219,
225
],
[
227,
235
],
[
237,
243
],
[
245,
250
],
[
252,
258
],
[
261,
261
],
[
273,
273
],
[
275,
278
],
[
280,
284
],
[
286,
291
],
[
293,
305
],
[
307,
308
],
[
310,
315
],
[
317,
322
],
[
324,
325
],
[
327,
329
],
[
331,
332
],
[
334,
336
],
[
338,
339
],
[
341,
343
],
[
345,
346
],
[
348,
350
],
[
352,
354
],
[
356,
356
],
[
358,
358
],
[
360,
362
],
[
439,
439
],
[
457,
459
],
[
462,
467
],
[
470,
474
],
[
476,
478
],
[
480,
486
],
[
488,
508
],
[
510,
515
],
[
517,
531
],
[
533,
537
],
[
539,
547
],
[
550,
560
],
[
562,
568
],
[
570,
580
],
[
589,
601
],
[
603,
608
],
[
610,
610
],
[
623,
625
]
],
[
[
21,
25
],
[
43,
50
],
[
58,
59
],
[
64,
64
],
[
76,
76
],
[
94,
94
],
[
100,
100
],
[
103,
103
],
[
109,
109
],
[
128,
128
],
[
138,
138
],
[
144,
144
],
[
150,
150
],
[
156,
156
],
[
162,
162
],
[
167,
167
],
[
173,
173
],
[
177,
177
],
[
183,
183
],
[
191,
191
],
[
202,
202
],
[
210,
210
],
[
218,
218
],
[
226,
226
],
[
236,
236
],
[
244,
244
],
[
251,
251
],
[
259,
260
],
[
262,
272
],
[
274,
274
],
[
279,
279
],
[
285,
285
],
[
292,
292
],
[
306,
306
],
[
309,
309
],
[
316,
316
],
[
323,
323
],
[
326,
326
],
[
330,
330
],
[
333,
333
],
[
337,
337
],
[
340,
340
],
[
344,
344
],
[
347,
347
],
[
351,
351
],
[
355,
355
],
[
357,
357
],
[
359,
359
],
[
363,
438
],
[
440,
456
],
[
460,
461
],
[
468,
469
],
[
475,
475
],
[
479,
479
],
[
487,
487
],
[
509,
509
],
[
516,
516
],
[
532,
532
],
[
538,
538
],
[
548,
549
],
[
561,
561
],
[
569,
569
],
[
581,
588
],
[
602,
602
],
[
609,
609
],
[
619,
619
]
],
[
[
148,
148
],
[
611,
618
],
[
620,
622
]
]
] |
a007307faf8eece8ef3ae95118abadc10d38d294
|
f55665c5faa3d79d0d6fe91fcfeb8daa5adf84d0
|
/Depend/MyGUI/MyGUIEngine/src/MyGUI_ScrollViewBase.cpp
|
1e3eefa23a1b886d424a0b7c07945a4f08c551f1
|
[] |
no_license
|
lxinhcn/starworld
|
79ed06ca49d4064307ae73156574932d6185dbab
|
86eb0fb8bd268994454b0cfe6419ffef3fc0fc80
|
refs/heads/master
| 2021-01-10T07:43:51.858394 | 2010-09-15T02:38:48 | 2010-09-15T02:38:48 | 47,859,019 | 2 | 1 | null | null | null | null |
WINDOWS-1251
|
C++
| false | false | 10,005 |
cpp
|
/*!
@file
@author Albert Semenov
@date 10/2008
*/
/*
This file is part of MyGUI.
MyGUI 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 3 of the License, or
(at your option) any later version.
MyGUI 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 MyGUI. If not, see <http://www.gnu.org/licenses/>.
*/
#include "MyGUI_Precompiled.h"
#include "MyGUI_ScrollViewBase.h"
#include "MyGUI_VScroll.h"
#include "MyGUI_HScroll.h"
namespace MyGUI
{
ScrollViewBase::ScrollViewBase() :
mVScroll(nullptr),
mHScroll(nullptr),
mClient(nullptr),
mVisibleHScroll(true),
mVisibleVScroll(true),
mVRange(0),
mHRange(0),
mChangeContentByResize(false)
{
}
void ScrollViewBase::updateScrollSize()
{
if (mClient == nullptr)
return;
eraseContent();
IntSize contentSize = getContentSize();
IntSize viewSize = getViewSize();
// вертикальный контент не помещается
if (contentSize.height > viewSize.height)
{
if (mVScroll != nullptr)
{
if (( ! mVScroll->getVisible()) && (mVisibleVScroll))
{
mVScroll->setVisible(true);
mClient->setSize(mClient->getWidth() - mVScroll->getWidth(), mClient->getHeight());
// размер может измениться
if (mChangeContentByResize)
{
eraseContent();
contentSize = getContentSize();
viewSize = getViewSize();
}
if (mHScroll != nullptr)
{
mHScroll->setSize(mHScroll->getWidth() - mVScroll->getWidth(), mHScroll->getHeight());
// если показали вертикальный скрол бар, уменьшилось вью по горизонтали,
// пересчитываем горизонтальный скрол на предмет показа
if ((contentSize.width > viewSize.width) && ( ! mHScroll->getVisible()) && (mVisibleHScroll))
{
mHScroll->setVisible(true);
mClient->setSize(mClient->getWidth(), mClient->getHeight() - mHScroll->getHeight());
mVScroll->setSize(mVScroll->getWidth(), mVScroll->getHeight() - mHScroll->getHeight());
// размер может измениться
if (mChangeContentByResize)
{
eraseContent();
contentSize = getContentSize();
viewSize = getViewSize();
}
}
}
}
}
}
// вертикальный контент помещается
else
{
if (mVScroll != nullptr)
{
if (mVScroll->getVisible())
{
mVScroll->setVisible(false);
mClient->setSize(mClient->getWidth() + mVScroll->getWidth(), mClient->getHeight());
// размер может измениться
if (mChangeContentByResize)
{
eraseContent();
contentSize = getContentSize();
viewSize = getViewSize();
}
if (mHScroll != nullptr)
{
mHScroll->setSize(mHScroll->getWidth() + mVScroll->getWidth(), mHScroll->getHeight());
// если скрыли вертикальный скрол бар, увеличилось вью по горизонтали,
// пересчитываем горизонтальный скрол на предмет скрытия
if ((contentSize.width <= viewSize.width) && (mHScroll->getVisible()))
{
mHScroll->setVisible(false);
mClient->setSize(mClient->getWidth(), mClient->getHeight() + mHScroll->getHeight());
mVScroll->setSize(mVScroll->getWidth(), mVScroll->getHeight() + mHScroll->getHeight());
// размер может измениться
if (mChangeContentByResize)
{
eraseContent();
contentSize = getContentSize();
viewSize = getViewSize();
}
}
}
}
}
}
// горизонтальный контент не помещается
if (contentSize.width > viewSize.width)
{
if (mHScroll != nullptr)
{
if (( ! mHScroll->getVisible()) && (mVisibleHScroll))
{
mHScroll->setVisible(true);
mClient->setSize(mClient->getWidth(), mClient->getHeight() - mHScroll->getHeight());
// размер может измениться
if (mChangeContentByResize)
{
eraseContent();
contentSize = getContentSize();
viewSize = getViewSize();
}
if (mVScroll != nullptr)
{
mVScroll->setSize(mVScroll->getWidth(), mVScroll->getHeight() - mHScroll->getHeight());
// если показали горизонтальный скрол бар, уменьшилось вью по вертикали,
// пересчитываем вертикальный скрол на предмет показа
if ((contentSize.height > viewSize.height) && ( ! mVScroll->getVisible()) && (mVisibleVScroll))
{
mVScroll->setVisible(true);
mClient->setSize(mClient->getWidth() - mVScroll->getWidth(), mClient->getHeight());
mHScroll->setSize(mHScroll->getWidth() - mVScroll->getWidth(), mHScroll->getHeight());
// размер может измениться
if (mChangeContentByResize)
{
eraseContent();
contentSize = getContentSize();
viewSize = getViewSize();
}
}
}
}
}
}
// горизонтальный контент помещается
else
{
if (mHScroll != nullptr)
{
if (mHScroll->getVisible())
{
mHScroll->setVisible(false);
mClient->setSize(mClient->getWidth(), mClient->getHeight() + mHScroll->getHeight());
// размер может измениться
if (mChangeContentByResize)
{
eraseContent();
contentSize = getContentSize();
viewSize = getViewSize();
}
if (mVScroll != nullptr)
{
mVScroll->setSize(mVScroll->getWidth(), mVScroll->getHeight() + mHScroll->getHeight());
// если скрыли горизонтальный скрол бар, увеличилось вью по вертикали,
// пересчитываем вертикальный скрол на предмет скрытия
if ((contentSize.height <= viewSize.height) && (mVScroll->getVisible()))
{
mVScroll->setVisible(false);
mClient->setSize(mClient->getWidth() + mVScroll->getWidth(), mClient->getHeight());
mHScroll->setSize(mHScroll->getWidth() + mVScroll->getWidth(), mHScroll->getHeight());
// размер может измениться
if (mChangeContentByResize)
{
eraseContent();
contentSize = getContentSize();
viewSize = getViewSize();
}
}
}
}
}
}
mVRange = (viewSize.height >= contentSize.height) ? 0 : contentSize.height - viewSize.height;
mHRange = (viewSize.width >= contentSize.width) ? 0 : contentSize.width - viewSize.width;
if (mVScroll != nullptr)
{
size_t page = getVScrollPage();
mVScroll->setScrollPage(page);
mVScroll->setScrollViewPage(viewSize.width > (int)page ? viewSize.width : page);
mVScroll->setScrollRange(mVRange + 1);
if (contentSize.height) mVScroll->setTrackSize(int (float(mVScroll->getLineSize() * viewSize.height) / float(contentSize.height)));
}
if (mHScroll != nullptr)
{
size_t page = getHScrollPage();
mHScroll->setScrollPage(page);
mHScroll->setScrollViewPage(viewSize.height > (int)page ? viewSize.height : page);
mHScroll->setScrollRange(mHRange + 1);
if (contentSize.width) mHScroll->setTrackSize(int (float(mHScroll->getLineSize() * viewSize.width) / float(contentSize.width)));
}
}
void ScrollViewBase::updateScrollPosition()
{
// размер контекста
IntSize contentSize = getContentSize();
// текущее смещение контекста
IntPoint contentPoint = getContentPosition();
// расчетное смещение
IntPoint offset = contentPoint;
IntSize viewSize = getViewSize();
Align align = getContentAlign();
if (contentSize.width > viewSize.width)
{
// максимальный выход влево
if ((offset.left + viewSize.width) > contentSize.width)
{
offset.left = contentSize.width - viewSize.width;
}
// максимальный выход вправо
else if (offset.left < 0)
{
offset.left = 0;
}
}
else
{
if (align.isLeft())
{
offset.left = 0;
}
else if (align.isRight())
{
offset.left = contentSize.width - viewSize.width;
}
else
{
offset.left = (contentSize.width - viewSize.width) / 2;
}
}
if (contentSize.height > viewSize.height)
{
// максимальный выход вверх
if ((offset.top + viewSize.height) > contentSize.height)
{
offset.top = contentSize.height - viewSize.height;
}
// максимальный выход вниз
else if (offset.top < 0)
{
offset.top = 0;
}
}
else
{
if (align.isTop())
{
offset.top = 0;
}
else if (align.isBottom())
{
offset.top = contentSize.height - viewSize.height;
}
else
{
offset.top = (contentSize.height - viewSize.height) / 2;
}
}
if (offset != contentPoint)
{
if (nullptr != mVScroll) mVScroll->setScrollPosition(offset.top);
if (nullptr != mHScroll) mHScroll->setScrollPosition(offset.left);
setContentPosition(offset);
}
}
} // namespace MyGUI
|
[
"albertclass@a94d7126-06ea-11de-b17c-0f1ef23b492c"
] |
[
[
[
1,
326
]
]
] |
1d7f8bbee295c89fa60b4f7de92b158c6328f33b
|
c5534a6df16a89e0ae8f53bcd49a6417e8d44409
|
/trunk/nGENE Toolset/PrefabPlaneWrapper.h
|
d69c14d53dee490526ed04618fe6b5f72f1287c8
|
[] |
no_license
|
svn2github/ngene
|
b2cddacf7ec035aa681d5b8989feab3383dac012
|
61850134a354816161859fe86c2907c8e73dc113
|
refs/heads/master
| 2023-09-03T12:34:18.944872 | 2011-07-27T19:26:04 | 2011-07-27T19:26:04 | 78,163,390 | 2 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 3,670 |
h
|
/*
---------------------------------------------------------------------------
This source file is part of nGENE Tech.
Copyright (c) 2006- Wojciech Toman
This program is free software.
File: PrefabPlaneWrapper.h
Version: 0.01
---------------------------------------------------------------------------
*/
#ifndef __INC_PREFABPLANEWRAPPER_H_
#define __INC_PREFABPLANEWRAPPER_H_
#include "nGENE.h"
#include "NodeWrapper.h"
#include <sstream>
namespace nGENEToolset
{
using namespace System;
using namespace System::Drawing;
/// Wrapper for a PrefabPlane class.
ref class PrefabPlaneWrapper: public NodeVisibleWrapper
{
protected:
PrefabPlane* m_pPlane;
static int s_nPlaneCount;
nGENEToolset::Vector2^ m_TexCoord;
public:
PrefabPlaneWrapper()
{
SceneManager* sm = Engine::getSingleton().getSceneManager(0);
Plane pl(nGENE::Vector3::UNIT_Y, nGENE::Point(0.0f, 0.0f, 0.0f));
m_pPlane = sm->createPlane(pl);
m_pPlane->setPosition(0.0f, 0.0f, 0.0f);
Surface* pSurface = m_pPlane->getSurface(L"Base");
Material* pMaterial = MaterialManager::getSingleton().getLibrary(L"default")->getMaterial(L"normalMap");
pSurface->setMaterial(pMaterial);
m_Position = gcnew Vector3(&m_pPlane->getPositionLocal());
m_Dimensions = gcnew Vector3(&m_pPlane->getScale());
m_Rotation = gcnew Quaternion(&m_pPlane->getRotation());
m_TexCoord = gcnew Vector2(&m_pPlane->getTexCoordMult());
m_pNode = m_pPlane;
//m_PositionWorld->setVector(m_pNode->getPositionWorld());
wostringstream buffer;
buffer << "Plane";
buffer << s_nPlaneCount;
wstring text = buffer.str();
if(frmSceneGraph::graph->getActive() != nullptr)
frmSceneGraph::graph->getActive()->getnGENENode()->addChild(text, m_pPlane);
this->Name = "Plane" + (s_nPlaneCount);
this->Key = "Plane" + (s_nPlaneCount++);
frmSceneGraph::graph->addNode(this);
frmSceneGraph::graph->beginAdd();
for(uint i = 0; i < m_pPlane->getSurfacesNum(); ++i)
{
String^ str = gcnew String(m_pPlane->getSurface(i)->getName().c_str());
SurfaceWrapper^ surf = gcnew SurfaceWrapper(m_pPlane->getSurface(i), str);
}
frmSceneGraph::graph->endAdd();
}
PrefabPlaneWrapper(PrefabPlane* _Plane, String^ _name):
NodeVisibleWrapper(_Plane, _name, 0)
{
m_pPlane = _Plane;
s_nPlaneCount++;
m_TexCoord = gcnew Vector2(&m_pPlane->getTexCoordMult());
frmSceneGraph::graph->beginAdd();
for(uint i = 0; i < m_pPlane->getSurfacesNum(); ++i)
{
String^ str = gcnew String(m_pPlane->getSurface(i)->getName().c_str());
SurfaceWrapper^ surf = gcnew SurfaceWrapper(m_pPlane->getSurface(i), str);
}
frmSceneGraph::graph->endAdd();
}
virtual ~PrefabPlaneWrapper()
{
}
[Browsable(true), CategoryAttribute("Plane"),
DescriptionAttribute("Texture coordinates multiplier")]
property nGENEToolset::Vector2^ TexCoord
{
nGENEToolset::Vector2^ get()
{
if(!frmRenderTarget::engine->tryLock())
return m_TexCoord;
m_pPlane->setTexCoordMult(m_TexCoord->getVector());
frmRenderTarget::engine->releaseLock();
return m_TexCoord;
}
void set(nGENEToolset::Vector2^ value)
{
m_TexCoord->x = value->x;
m_TexCoord->y = value->y;
}
}
[Browsable(true), CategoryAttribute("Plane"),
DescriptionAttribute("Plane's side length")]
property float SideLength
{
float get()
{
return m_pPlane->getSideLength();
}
void set(float value)
{
m_pPlane->setSideLength(value);
}
}
};
}
#endif
|
[
"Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57"
] |
[
[
[
1,
146
]
]
] |
93d85e716ae27cdb29ef437684e2983ae13c294a
|
f55665c5faa3d79d0d6fe91fcfeb8daa5adf84d0
|
/Depend/MyGUI/UnitTests/UnitTest_GraphView/GraphView.h
|
12525bb25d43ecd4914fd8ddf6bc9aa1c137209d
|
[] |
no_license
|
lxinhcn/starworld
|
79ed06ca49d4064307ae73156574932d6185dbab
|
86eb0fb8bd268994454b0cfe6419ffef3fc0fc80
|
refs/heads/master
| 2021-01-10T07:43:51.858394 | 2010-09-15T02:38:48 | 2010-09-15T02:38:48 | 47,859,019 | 2 | 1 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,134 |
h
|
/*!
@file
@author Albert Semenov
@date 08/2009
@module
*/
#ifndef __GRAPH_VIEW_H__
#define __GRAPH_VIEW_H__
#include <MyGUI.h>
#include "BaseGraphView.h"
namespace demo
{
class GraphView : public wraps::BaseGraphView
{
public:
GraphView() :
wraps::BaseGraphView("GraphView.layout", nullptr)
{
MyGUI::CanvasPtr canvas = nullptr;
assignWidget(canvas, "Canvas");
wrapCanvas(canvas);
assignWidget(mScrollView, "ScrollView");
mScrollView->setCanvasSize(16, 16);
canvas->setCoord(0, 0, 16, 16);
eventChangeSize = MyGUI::newDelegate(this, &GraphView::notifyChangeSize);
notifyChangeSize(this, MyGUI::IntSize());
}
private:
void notifyChangeSize(wraps::BaseGraphView* _sender, MyGUI::IntSize _size)
{
const MyGUI::IntCoord& coord = mScrollView->getClientCoord();
if (_size.width < coord.width) _size.width = coord.width;
if (_size.height < coord.height) _size.height = coord.height;
mScrollView->setCanvasSize(_size);
}
private:
MyGUI::ScrollViewPtr mScrollView;
};
} // namespace demo
#endif // __GRAPH_VIEW_H__
|
[
"albertclass@a94d7126-06ea-11de-b17c-0f1ef23b492c"
] |
[
[
[
1,
52
]
]
] |
153a323a0c56f525e22ea284a4c205abb0cccdcf
|
317f62189c63646f81198d1692bed708d8f18497
|
/contrib/orion/Allocator/Arbiter.h
|
7b5d103ef0c902f38cdaf8bb8a78a8a78fc84b20
|
[
"MIT"
] |
permissive
|
mit-carbon/Graphite-Cycle-Level
|
8fb41d5968e0a373fd4adbf0ad400a9aa5c10c90
|
db3f1e986ddc10f3e5f3a5d4b68bd6a9885969b3
|
refs/heads/master
| 2021-01-25T07:08:46.628355 | 2011-11-23T08:53:18 | 2011-11-23T08:53:18 | 1,930,686 | 1 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 1,085 |
h
|
#ifndef __ARBITER_H__
#define __ARBITER_H__
#include "Type.h"
class TechParameter;
class FlipFlop;
class Arbiter
{
public:
enum ArbiterModel
{
NO_MODEL = 0,
RR_ARBITER,
MATRIX_ARBITER
};
public:
Arbiter(
const ArbiterModel arb_model_,
const uint32_t req_width_,
const double len_in_wire_,
const TechParameter* tech_param_ptr_
);
virtual ~Arbiter() = 0;
public:
virtual double calc_dynamic_energy(double num_req_, bool is_max_) const = 0;
double get_static_power() const;
protected:
ArbiterModel m_arb_model;
uint32_t m_req_width;
double m_len_in_wire;
const TechParameter* m_tech_param_ptr;
FlipFlop* m_ff_ptr;
double m_e_chg_req;
double m_e_chg_grant;
double m_i_static;
public:
static Arbiter* create_arbiter(
const string& arb_model_str_,
const string& ff_model_str_,
uint32_t req_width_,
double len_in_wire_,
const TechParameter* tech_param_ptr_
);
};
#endif
|
[
"[email protected]"
] |
[
[
[
1,
56
]
]
] |
a1528f6dd69dc073e8d1623f0513935aeeda3b23
|
68127d36b179fd5548a1e593e2c20791db6b48e3
|
/compiladores/slr/Unit1.cpp
|
e5d3c5e7501f06ebfdf85db8f9e4af825ac0c82a
|
[] |
no_license
|
renatomb/engComp
|
fa50b962dbdf4f9387fd02a28b3dc130b683ed02
|
b533c876b50427d44cfdb92c507a6e74b1b7fa79
|
refs/heads/master
| 2020-04-11T06:22:05.209022 | 2006-04-26T13:40:08 | 2018-12-13T04:25:08 | 161,578,821 | 1 | 0 | null | null | null | null |
ISO-8859-1
|
C++
| false | false | 7,559 |
cpp
|
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::nt_maisClick(TObject *Sender)
{
naoterm->RowCount++;
slr->ColCount=naoterm->RowCount+2;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::nt_menosClick(TObject *Sender)
{
naoterm->RowCount--;
slr->ColCount--;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::naotermSetEditText(TObject *Sender, int ACol,
int ARow, const AnsiString Value)
{
for (int i=1;i<slr->ColCount-1;i++){
slr->Cells[i][0]=naoterm->Cells[0][i-1];
}
slr->Cells[slr->ColCount-1][0]="$";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::rg_maisClick(TObject *Sender)
{
regras->RowCount++;
for(int i=0;i<regras->RowCount;i++){
regras->Cells[0][i]=i+1;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::rg_menosClick(TObject *Sender)
{
regras->RowCount--;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::slr_maisClick(TObject *Sender)
{
slr->RowCount++;
transicoes->RowCount=slr->RowCount;
for(int i=1;i<slr->RowCount;i++){
slr->Cells[0][i]=i-1;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::slr_menosClick(TObject *Sender)
{
slr->RowCount--;
transicoes->RowCount=slr->RowCount;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::regrasSetEditText(TObject *Sender, int ACol,
int ARow, const AnsiString Value)
{
int colunas=0;
for(int i=0;i<regras->RowCount;i++){
if (regras->Cells[1][i] != "") {
bool existe=false;
for (int j=0;j<transicoes->ColCount;j++){
if (regras->Cells[1][i] == transicoes->Cells[j][0]) {
existe=true;
}
}
if (!existe) {
colunas++;
transicoes->ColCount=colunas;
transicoes->Cells[transicoes->ColCount-1][0]=regras->Cells[1][i];
}
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::iniciaClick(TObject *Sender)
{
status->RowCount=1;
pilha="0";
entrada=exp->Text+"$";
bool continua=true;
while (continua) {
status->Cells[0][status->RowCount]=pilha;
status->Cells[1][status->RowCount]=entrada;
status->Cells[2][status->RowCount-1]=acao;
status->RowCount++;
AnsiString nt_vez,num_vez,comando;
for (int h=0;h<naoterm->RowCount;h++) {
if (naoterm->Cells[0][h] == entrada.SubString(1,naoterm->Cells[0][h].Length())) {
nt_vez=naoterm->Cells[0][h];
}
}
if (nt_vez == "") {
nt_vez=entrada;
}
if (pilha.Length() > 1) {
for (int h=pilha.Length();h>0;h=h-1){
if (!((pilha[h] >= 48) && (pilha[h] <=57))) {
num_vez=pilha.SubString(h+1,pilha.Length()-h);
break;
}
}
}
else {
num_vez=pilha;
}
int lin,col;
lin=num_vez.ToInt()+1;
for (int r=1;r<slr->ColCount;r++){
if (slr->Cells[r][0] == nt_vez) {
col=r;
break;
}
}
comando=slr->Cells[col][lin];
if (comando == "") {
acao="Sentença recusada!!!";
continua=false;
}
else {
if (comando.UpperCase() == "AC") {
acao="Sentença ACEITA!!!";
continua=false;
}
else {
AnsiString subcomando,prox_tran;
subcomando=comando.SubString(1,1).UpperCase();
prox_tran=comando.SubString(2,comando.Length()-1);
if (subcomando == "E") {
acao=comando+": Empilha "+nt_vez+prox_tran;
pilha=pilha+nt_vez+prox_tran;
entrada=entrada.SubString(nt_vez.Length()+1,entrada.Length()-nt_vez.Length());
}
else {
if (subcomando == "R") {
int linha_regra;
AnsiString procuraregra,memoria,xyz;
linha_regra=prox_tran.ToInt()-1;
procuraregra=regras->Cells[2][linha_regra];
acao=comando+": Reduz "+regras->Cells[1][linha_regra]+"=>"+procuraregra;
memoria="";
bool achei=false;
while (!achei) {
int ultimo;
ultimo=pilha[pilha.Length()];
if ((ultimo >= 48) && (ultimo <=57)) {
pilha=pilha.SubString(1,pilha.Length()-1);
}
else {
memoria=pilha.SubString(pilha.Length(),1)+memoria;
pilha=pilha.SubString(1,pilha.Length()-1);
}
if (memoria == procuraregra) {
xyz=pilha;
pilha=pilha+regras->Cells[1][linha_regra];
achei=true;
}
// ShowMessage("Pilha: "+pilha+"\nMemoria: "+memoria);
}
AnsiString procura_trans="";
for (int q=xyz.Length();q>0;q=q-1) {
int procurado;
procurado=xyz[q];
if (!((procurado >= 48) && (procurado <=57))) {
procura_trans=xyz.SubString(q+1,xyz.Length()-q);
break;
}
}
if (procura_trans == "") {
procura_trans=xyz;
}
acao=acao+" Transição ["+procura_trans+","+regras->Cells[1][linha_regra]+"]=";
AnsiString proximatransicao;
for (int x=0;x<transicoes->ColCount;x++) {
if (transicoes->Cells[x][0] == regras->Cells[1][linha_regra]) {
int lin_tab;
lin_tab=procura_trans.ToInt()+1;
proximatransicao=transicoes->Cells[x][lin_tab];
}
}
acao=acao+proximatransicao;
pilha=pilha+proximatransicao;
}
else {
acao="Comando invalido: "+comando;
continua=false;
}
}
}
}
}
status->Cells[0][status->RowCount]=pilha;
status->Cells[1][status->RowCount]=entrada;
status->Cells[2][status->RowCount-1]=acao;
status->Cells[0][0]="Pilha";
status->Cells[1][0]="Entrada";
status->Cells[2][0]="Ação";
}
//---------------------------------------------------------------------------
|
[
"[email protected]"
] |
[
[
[
1,
211
]
]
] |
22e55d7deff4febc0ff79dc70cc93982d7b94576
|
9bccf7cb7a70b8d165f83cf0ea5ea02d6955b7e4
|
/pa_beos/PlaybackNode.cc
|
5eb54ca0fb9ed24096385ba79c693e1b6ca324f8
|
[
"LicenseRef-scancode-warranty-disclaimer",
"MIT"
] |
permissive
|
dirocco/portaudio
|
246a57ddf221114360f5d27ec5718e14b044bd81
|
75498a1cb12b0644d23a21e8ec5bed5f302e131d
|
refs/heads/master
| 2020-05-18T05:18:44.159191 | 2009-05-26T00:34:22 | 2009-05-26T00:34:22 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C++
| false | false | 17,845 |
cc
|
/*
* $Id: PlaybackNode.cc,v 1.1 2003/01/15 06:10:13 gsilber Exp $
* PortAudio Portable Real-Time Audio Library
* Latest Version at: http://www.portaudio.com
* BeOS Media Kit Implementation by Joshua Haberman
*
* Copyright (c) 2001 Joshua Haberman <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
* they can be incorporated into the canonical version.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* ---
*
* Significant portions of this file are based on sample code from Be. The
* Be Sample Code Licence follows:
*
* Copyright 1991-1999, Be Incorporated.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions, and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <be/media/BufferGroup.h>
#include <be/media/Buffer.h>
#include <be/media/TimeSource.h>
#include "PlaybackNode.h"
#define PRINT(x) { printf x; fflush(stdout); }
#ifdef DEBUG
#define DBUG(x) PRINT(x)
#else
#define DBUG(x)
#endif
PaPlaybackNode::PaPlaybackNode(uint32 channels, float frame_rate, uint32 frames_per_buffer,
PortAudioCallback* callback, void *user_data) :
BMediaNode("PortAudio input node"),
BBufferProducer(B_MEDIA_RAW_AUDIO),
BMediaEventLooper(),
mAborted(false),
mRunning(false),
mBufferGroup(NULL),
mDownstreamLatency(0),
mStartTime(0),
mCallback(callback),
mUserData(user_data),
mFramesPerBuffer(frames_per_buffer)
{
DBUG(("Constructor called.\n"));
mPreferredFormat.type = B_MEDIA_RAW_AUDIO;
mPreferredFormat.u.raw_audio.channel_count = channels;
mPreferredFormat.u.raw_audio.frame_rate = frame_rate;
mPreferredFormat.u.raw_audio.byte_order =
(B_HOST_IS_BENDIAN) ? B_MEDIA_BIG_ENDIAN : B_MEDIA_LITTLE_ENDIAN;
mPreferredFormat.u.raw_audio.buffer_size =
media_raw_audio_format::wildcard.buffer_size;
mOutput.destination = media_destination::null;
mOutput.format = mPreferredFormat;
/* The amount of time it takes for this node to produce a buffer when
* asked. Essentially, it is how long the user's callback takes to run.
* We set this to be the length of the sound data each buffer of the
* requested size can hold. */
//mInternalLatency = (bigtime_t)(1000000 * frames_per_buffer / frame_rate);
/* ACK! it seems that the mixer (at least on my machine) demands that IT
* specify the buffer size, so for now I'll just make a generic guess here */
mInternalLatency = 1000000 / 20;
}
PaPlaybackNode::~PaPlaybackNode()
{
DBUG(("Destructor called.\n"));
Quit(); /* Stop the BMediaEventLooper thread */
}
/*************************
*
* Local methods
*
*/
bool PaPlaybackNode::IsRunning()
{
return mRunning;
}
PaTimestamp PaPlaybackNode::GetStreamTime()
{
BTimeSource *timeSource = TimeSource();
PaTimestamp time = (timeSource->Now() - mStartTime) *
mPreferredFormat.u.raw_audio.frame_rate / 1000000;
return time;
}
void PaPlaybackNode::SetSampleFormat(PaSampleFormat inFormat,
PaSampleFormat outFormat)
{
uint32 beOutFormat;
switch(outFormat)
{
case paFloat32:
beOutFormat = media_raw_audio_format::B_AUDIO_FLOAT;
mOutputSampleWidth = 4;
break;
case paInt16:
beOutFormat = media_raw_audio_format::B_AUDIO_SHORT;
mOutputSampleWidth = 2;
break;
case paInt32:
beOutFormat = media_raw_audio_format::B_AUDIO_INT;
mOutputSampleWidth = 4;
break;
case paInt8:
beOutFormat = media_raw_audio_format::B_AUDIO_CHAR;
mOutputSampleWidth = 1;
break;
case paUInt8:
beOutFormat = media_raw_audio_format::B_AUDIO_UCHAR;
mOutputSampleWidth = 1;
break;
case paInt24:
case paPackedInt24:
case paCustomFormat:
DBUG(("Unsupported output format: %x\n", outFormat));
break;
default:
DBUG(("Unknown output format: %x\n", outFormat));
}
mPreferredFormat.u.raw_audio.format = beOutFormat;
mFramesPerBuffer * mPreferredFormat.u.raw_audio.channel_count * mOutputSampleWidth;
}
BBuffer *PaPlaybackNode::FillNextBuffer(bigtime_t time)
{
/* Get a buffer from the buffer group */
BBuffer *buf = mBufferGroup->RequestBuffer(
mOutput.format.u.raw_audio.buffer_size, BufferDuration());
unsigned long frames = mOutput.format.u.raw_audio.buffer_size /
mOutputSampleWidth / mOutput.format.u.raw_audio.channel_count;
bigtime_t start_time;
int ret;
if( !buf )
{
DBUG(("Unable to allocate a buffer\n"));
return NULL;
}
start_time = mStartTime +
(bigtime_t)((double)mSamplesSent /
(double)mOutput.format.u.raw_audio.frame_rate /
(double)mOutput.format.u.raw_audio.channel_count *
1000000.0);
/* Now call the user callback to get the data */
ret = mCallback(NULL, /* Input buffer */
buf->Data(), /* Output buffer */
frames, /* Frames per buffer */
mSamplesSent / mOutput.format.u.raw_audio.channel_count, /* timestamp */
mUserData);
if( ret )
mAborted = true;
media_header *hdr = buf->Header();
hdr->type = B_MEDIA_RAW_AUDIO;
hdr->size_used = mOutput.format.u.raw_audio.buffer_size;
hdr->time_source = TimeSource()->ID();
hdr->start_time = start_time;
return buf;
}
/*************************
*
* BMediaNode methods
*
*/
BMediaAddOn *PaPlaybackNode::AddOn( int32 * ) const
{
DBUG(("AddOn() called.\n"));
return NULL; /* we don't provide service to outside applications */
}
status_t PaPlaybackNode::HandleMessage( int32 message, const void *data,
size_t size )
{
DBUG(("HandleMessage() called.\n"));
return B_ERROR; /* we don't define any custom messages */
}
/*************************
*
* BMediaEventLooper methods
*
*/
void PaPlaybackNode::NodeRegistered()
{
DBUG(("NodeRegistered() called.\n"));
/* Start the BMediaEventLooper thread */
SetPriority(B_REAL_TIME_PRIORITY);
Run();
/* set up as much information about our output as we can */
mOutput.source.port = ControlPort();
mOutput.source.id = 0;
mOutput.node = Node();
::strcpy(mOutput.name, "PortAudio Playback");
}
void PaPlaybackNode::HandleEvent( const media_timed_event *event,
bigtime_t lateness, bool realTimeEvent )
{
// DBUG(("HandleEvent() called.\n"));
status_t err;
switch(event->type)
{
case BTimedEventQueue::B_START:
DBUG((" Handling a B_START event\n"));
if( RunState() != B_STARTED )
{
mStartTime = event->event_time + EventLatency();
mSamplesSent = 0;
mAborted = false;
mRunning = true;
media_timed_event firstEvent( mStartTime,
BTimedEventQueue::B_HANDLE_BUFFER );
EventQueue()->AddEvent( firstEvent );
}
break;
case BTimedEventQueue::B_STOP:
DBUG((" Handling a B_STOP event\n"));
mRunning = false;
EventQueue()->FlushEvents( 0, BTimedEventQueue::B_ALWAYS, true,
BTimedEventQueue::B_HANDLE_BUFFER );
break;
case BTimedEventQueue::B_HANDLE_BUFFER:
//DBUG((" Handling a B_HANDLE_BUFFER event\n"));
/* make sure we're started and connected */
if( RunState() != BMediaEventLooper::B_STARTED ||
mOutput.destination == media_destination::null )
break;
BBuffer *buffer = FillNextBuffer(event->event_time);
/* make sure we weren't aborted while this routine was running.
* this can happen in one of two ways: either the callback returned
* nonzero (in which case mAborted is set in FillNextBuffer() ) or
* the client called AbortStream */
if( mAborted )
{
if( buffer )
buffer->Recycle();
Stop(0, true);
break;
}
if( buffer )
{
err = SendBuffer(buffer, mOutput.destination);
if( err != B_OK )
buffer->Recycle();
}
mSamplesSent += mOutput.format.u.raw_audio.buffer_size / mOutputSampleWidth;
/* Now schedule the next buffer event, so we can send another
* buffer when this one runs out. We calculate when it should
* happen by calculating when the data we just sent will finish
* playing.
*
* NOTE, however, that the event will actually get generated
* earlier than we specify, to account for the latency it will
* take to produce the buffer. It uses the latency value we
* specified in SetEventLatency() to determine just how early
* to generate it. */
/* totalPerformanceTime includes the time represented by the buffer
* we just sent */
bigtime_t totalPerformanceTime = (bigtime_t)((double)mSamplesSent /
(double)mOutput.format.u.raw_audio.channel_count /
(double)mOutput.format.u.raw_audio.frame_rate * 1000000.0);
bigtime_t nextEventTime = mStartTime + totalPerformanceTime;
media_timed_event nextBufferEvent(nextEventTime,
BTimedEventQueue::B_HANDLE_BUFFER);
EventQueue()->AddEvent(nextBufferEvent);
break;
}
}
/*************************
*
* BBufferProducer methods
*
*/
status_t PaPlaybackNode::FormatSuggestionRequested( media_type type,
int32 /*quality*/, media_format* format )
{
/* the caller wants to know this node's preferred format and provides
* a suggestion, asking if we support it */
DBUG(("FormatSuggestionRequested() called.\n"));
if(!format)
return B_BAD_VALUE;
*format = mPreferredFormat;
/* we only support raw audio (a wildcard is okay too) */
if ( type == B_MEDIA_UNKNOWN_TYPE || type == B_MEDIA_RAW_AUDIO )
return B_OK;
else
return B_MEDIA_BAD_FORMAT;
}
status_t PaPlaybackNode::FormatProposal( const media_source& output,
media_format* format )
{
/* This is similar to FormatSuggestionRequested(), but it is actually part
* of the negotiation process. We're given the opportunity to specify any
* properties that are wildcards (ie. properties that the other node doesn't
* care one way or another about) */
DBUG(("FormatProposal() called.\n"));
/* Make sure this proposal really applies to our output */
if( output != mOutput.source )
return B_MEDIA_BAD_SOURCE;
/* We return two things: whether we support the proposed format, and our own
* preferred format */
*format = mPreferredFormat;
if( format->type == B_MEDIA_UNKNOWN_TYPE || format->type == B_MEDIA_RAW_AUDIO )
return B_OK;
else
return B_MEDIA_BAD_FORMAT;
}
status_t PaPlaybackNode::FormatChangeRequested( const media_source& source,
const media_destination& destination, media_format* io_format, int32* )
{
/* we refuse to change formats, supporting only 1 */
DBUG(("FormatChangeRequested() called.\n"));
return B_ERROR;
}
status_t PaPlaybackNode::GetNextOutput( int32* cookie, media_output* out_output )
{
/* this is where we allow other to enumerate our outputs -- the cookie is
* an integer we can use to keep track of where we are in enumeration. */
DBUG(("GetNextOutput() called.\n"));
if( *cookie == 0 )
{
*out_output = mOutput;
*cookie = 1;
return B_OK;
}
return B_BAD_INDEX;
}
status_t PaPlaybackNode::DisposeOutputCookie( int32 cookie )
{
DBUG(("DisposeOutputCookie() called.\n"));
return B_OK;
}
void PaPlaybackNode::LateNoticeReceived( const media_source& what,
bigtime_t how_much, bigtime_t performance_time )
{
/* This function is called as notification that a buffer we sent wasn't
* received by the time we stamped it with -- it got there late. Basically,
* it means we underestimated our own latency, so we should increase it */
DBUG(("LateNoticeReceived() called.\n"));
if( what != mOutput.source )
return;
if( RunMode() == B_INCREASE_LATENCY )
{
mInternalLatency += how_much;
SetEventLatency( mDownstreamLatency + mInternalLatency );
DBUG(("Increasing latency to %Ld\n", mDownstreamLatency + mInternalLatency));
}
else
DBUG(("I don't know what to do with this notice!"));
}
void PaPlaybackNode::EnableOutput( const media_source& what, bool enabled,
int32* )
{
DBUG(("EnableOutput() called.\n"));
/* stub -- we don't support this yet */
}
status_t PaPlaybackNode::PrepareToConnect( const media_source& what,
const media_destination& where, media_format* format,
media_source* out_source, char* out_name )
{
/* the final stage of format negotiations. here we _must_ make specific any
* remaining wildcards */
DBUG(("PrepareToConnect() called.\n"));
/* make sure this really refers to our source */
if( what != mOutput.source )
return B_MEDIA_BAD_SOURCE;
/* make sure we're not already connected */
if( mOutput.destination != media_destination::null )
return B_MEDIA_ALREADY_CONNECTED;
if( format->type != B_MEDIA_RAW_AUDIO )
return B_MEDIA_BAD_FORMAT;
if( format->u.raw_audio.format != mPreferredFormat.u.raw_audio.format )
return B_MEDIA_BAD_FORMAT;
if( format->u.raw_audio.buffer_size ==
media_raw_audio_format::wildcard.buffer_size )
{
DBUG(("We were left to decide buffer size: choosing 2048"));
format->u.raw_audio.buffer_size = 2048;
}
else
DBUG(("Using consumer specified buffer size of %lu.\n",
format->u.raw_audio.buffer_size));
/* Reserve the connection, return the information */
mOutput.destination = where;
mOutput.format = *format;
*out_source = mOutput.source;
strncpy( out_name, mOutput.name, B_MEDIA_NAME_LENGTH );
return B_OK;
}
void PaPlaybackNode::Connect(status_t error, const media_source& source,
const media_destination& destination, const media_format& format, char* io_name)
{
DBUG(("Connect() called.\n"));
|
[
"gsilber"
] |
[
[
[
1,
538
]
]
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.