blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
5
146
content_id
stringlengths
40
40
detected_licenses
sequencelengths
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
sequencelengths
1
16
author_lines
sequencelengths
1
16
57f13db0947cbac87854266cb0593729a52083ea
8a3fce9fb893696b8e408703b62fa452feec65c5
/AutoBall/AutoBall/App/Entity/MoveEntity.cpp
399cf74735256cc1e43701ac6642498009140006
[]
no_license
win18216001/tpgame
bb4e8b1a2f19b92ecce14a7477ce30a470faecda
d877dd51a924f1d628959c5ab638c34a671b39b2
refs/heads/master
2021-04-12T04:51:47.882699
2011-03-08T10:04:55
2011-03-08T10:04:55
42,728,291
0
2
null
null
null
null
UTF-8
C++
false
false
1,071
cpp
#include "stdafx.h" #include "MoveEntity.h" void CMoveEntity::SetHeading(Vector2D new_heading) { assert( (new_heading.LengthSq() - 1.0) < 0.00001); if( GetID() == 2 ) { char str[256]; sprintf_s(str,"Position x=%f,y=%f",Heading().x,Heading().y); char p; p='1'; } m_vHeading = new_heading; m_vSide = m_vHeading.Perp(); } bool CMoveEntity::RotateHeadingToFacePosition(Vector2D target) { Vector2D toTarget = Vec2DNormalize(target - m_vPosition); double dot = m_vHeading.Dot(toTarget); Clamp(dot, -1, 1); double angle = acos(dot); if (angle < 0.00001) return true; if (angle > m_dMaxTurnRate) angle = m_dMaxTurnRate; C2DMatrix RotationMatrix; RotationMatrix.Rotate(angle * m_vHeading.Sign(toTarget)); if( GetID() == 2 ) { char str[256]; sprintf_s(str,"Position x=%f,y=%f",Heading().x,Heading().y); char p; p='1'; } RotationMatrix.TransformVector2Ds(m_vHeading); RotationMatrix.TransformVector2Ds(m_vVelocity); m_vSide = m_vHeading.Perp(); return false; }
[ [ [ 1, 50 ] ] ]
5ae2d939a78832b4313661af0c881b9321cffbcc
54cacc105d6bacdcfc37b10d57016bdd67067383
/libraries/asx-2.16.0/include/ASXEngine.tpp
ef8dc7a6ca2c28075d908ff15ede512024386d48
[]
no_license
galek/hesperus
4eb10e05945c6134901cc677c991b74ce6c8ac1e
dabe7ce1bb65ac5aaad144933d0b395556c1adc4
refs/heads/master
2020-12-31T05:40:04.121180
2009-12-06T17:38:49
2009-12-06T17:38:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,986
tpp
/*** * asx: ASXEngine.tpp * Copyright Stuart Golodetz, 2009. All rights reserved. ***/ #include "ASXException.h" #include "ASXMethodTypeString.h" #include "ASXStructorTypeString.h" //#################### PUBLIC METHODS #################### template <typename F> void ASXEngine::register_constructor(F f, std::string obj, std::string decl) { register_structor(f, asBEHAVE_CONSTRUCT, obj, decl); } template <typename F> void ASXEngine::register_destructor(F f, std::string obj, std::string decl) { register_structor(f, asBEHAVE_DESTRUCT, obj, decl); } template <typename F> void ASXEngine::register_global_function(F f, const std::string& name) { register_global_function<F>(f, name, ASXTypeString<F>(name)()); } template <typename F> void ASXEngine::register_global_function(F f, const std::string& name, const std::string& decl) { int result = m_engine->RegisterGlobalFunction(decl.c_str(), asFUNCTION(f), asCALL_CDECL); if(result < 0) throw ASXException("Global function " + name + " could not be registered"); } template <typename F> void ASXEngine::register_global_operator(F f, asEBehaviours behaviour) { register_global_operator<F>(f, behaviour, ASXTypeString<F>("f")()); } template <typename F> void ASXEngine::register_global_operator(F f, asEBehaviours behaviour, const std::string& decl) { int result = m_engine->RegisterGlobalBehaviour(behaviour, decl.c_str(), asFUNCTION(f), asCALL_CDECL); if(result < 0) throw ASXException("Global operator could not be registered"); } template <typename T, typename F> void ASXEngine::register_instantiable_ref_type(F factory) { register_instantiable_ref_type<T,F>(factory, ASXTypeString<T>()()); } template <typename T, typename F> void ASXEngine::register_instantiable_ref_type(F factory, const std::string& obj) { register_uninstantiable_ref_type<T>(); std::string factorySig = obj + "@ f()"; int result = m_engine->RegisterObjectBehaviour(obj.c_str(), asBEHAVE_FACTORY, factorySig.c_str(), asFUNCTION(factory), asCALL_CDECL); if(result < 0) throw ASXException("Unable to register factory for reference type " + obj); } template <typename F> void ASXEngine::register_object_method(F f, const std::string& name) { ASXMethodTypeString<F> typeString(name); register_object_method(f, name, typeString.object_type(), typeString.function_type()); } template <typename F> void ASXEngine::register_object_method(F f, const std::string& name, const std::string& obj) { ASXMethodTypeString<F> typeString(name); register_object_method(f, name, obj, typeString.function_type()); } template <typename F> void ASXEngine::register_object_method(F f, const std::string& name, const std::string& obj, const std::string& decl) { int result = m_engine->RegisterObjectMethod(obj.c_str(), decl.c_str(), asSMethodPtr<sizeof(f)>::Convert(f), asCALL_THISCALL); if(result < 0) throw ASXException("Object method " + name + " could not be registered"); } template <typename F> void ASXEngine::register_object_operator(F f, asEBehaviours behaviour, std::string obj, std::string decl) { if(obj == "" || decl == "") { ASXMethodTypeString<F> typeString("f"); if(obj == "") obj = typeString.object_type(); if(decl == "") decl = typeString.function_type(); } int result = m_engine->RegisterObjectBehaviour(obj.c_str(), behaviour, decl.c_str(), asSMethodPtr<sizeof(f)>::Convert(f), asCALL_THISCALL); if(result < 0) throw ASXException("Object operator could not be registered"); } template <typename T, typename M> void ASXEngine::register_object_property(M T::*m, const std::string& name, std::string obj, std::string decl, int byteOffset) { if(obj == "") obj = ASXTypeString<T>()(); if(decl == "") decl = ASXTypeString<M>(name)(); if(byteOffset == -1) { // Note: This is the equivalent of offsetof (but is technically not portable). byteOffset = (int)((ptrdiff_t)&(((T*)0)->*m)); } int result = m_engine->RegisterObjectProperty(obj.c_str(), decl.c_str(), byteOffset); if(result < 0) throw ASXException("Object property " + name + " could not be registered"); } template <typename T> void ASXEngine::register_pod_type() { register_pod_type<T>(ASXTypeString<T>()()); } template <typename T> void ASXEngine::register_pod_type(const std::string& obj) { int result = m_engine->RegisterObjectType(obj.c_str(), sizeof(T), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS); if(result < 0) throw ASXException("Unable to register value type " + obj); } template <typename T> void ASXEngine::register_uninstantiable_ref_type() { register_uninstantiable_ref_type<T>(ASXTypeString<T>()()); } template <typename T> void ASXEngine::register_uninstantiable_ref_type(const std::string& obj) { int result = m_engine->RegisterObjectType(obj.c_str(), 0, asOBJ_REF); if(result < 0) throw ASXException("Unable to register reference type " + obj); result = m_engine->RegisterObjectBehaviour(obj.c_str(), asBEHAVE_ADDREF, "void f()", asMETHOD(T,add_ref), asCALL_THISCALL); if(result < 0) throw ASXException("Unable to register addref for reference type " + obj); result = m_engine->RegisterObjectBehaviour(obj.c_str(), asBEHAVE_RELEASE, "void f()", asMETHOD(T,release), asCALL_THISCALL); if(result < 0) throw ASXException("Unable to register release for reference type " + obj); } //#################### PRIVATE METHODS #################### template <typename F> void ASXEngine::register_structor(F f, asEBehaviours behaviour, std::string obj, std::string decl) { if(obj == "" || decl == "") { ASXStructorTypeString<F> structorTypeString; if(obj == "") obj = structorTypeString.object_type(); if(decl == "") decl = structorTypeString.function_type(); } int result = m_engine->RegisterObjectBehaviour(obj.c_str(), behaviour, decl.c_str(), asFUNCTION(f), asCALL_CDECL_OBJFIRST); if(result < 0) throw ASXException("'structor could not be registered"); }
[ [ [ 1, 160 ] ] ]
fbd42b8e30eac73099bb4772f7324dcef55fd575
ce0622a0f49dd0ca172db04efdd9484064f20973
/tools/GameList/Common/AtgAnimation.h
c9b7f4397889cdce367737fd8988ed362849d470
[]
no_license
maninha22crazy/xboxplayer
a78b0699d4002058e12c8f2b8c83b1cbc3316500
e9ff96899ad8e8c93deb3b2fe9168239f6a61fe1
refs/heads/master
2020-12-24T18:42:28.174670
2010-03-14T13:57:37
2010-03-14T13:57:37
56,190,024
1
0
null
null
null
null
UTF-8
C++
false
false
9,074
h
//----------------------------------------------------------------------------- // AtgAnimation.h // // Animation data structures for keyframed animation. // // Xbox Advanced Technology Group. // Copyright (C) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- #pragma once #ifndef ATG_ANIMATION_H #define ATG_ANIMATION_H #include <assert.h> #include "AtgResourceDatabase.h" namespace ATG { //---------------------------------------------------------------------------------- // Name: class AnimationKeyArray // Desc: A data structure that holds an array of multidimensional animation keys. // Each key consists of a non-negative float time and at least one float value. // It is crucial that key times be non-negative, since this class is optimized // to avoid float branches, since they cause a performance penalty on the // Xbox 360 CPU. // The class is also optimized to be initialized with a pre-sorted array of // keys, using the PointToBuffer() method. //---------------------------------------------------------------------------------- class AnimationKeyArray { public: // Constructor and destructor AnimationKeyArray( DWORD dwValueDimension ); ~AnimationKeyArray(); // Initialization VOID Resize( DWORD dwNewCapacity ); VOID PointToBuffer( FLOAT* pBuffer, DWORD dwBufferSizeBytes, DWORD dwKeyCount, DWORD dwValueDimension ); // Data access DWORD GetKeyCount() const { return m_dwSize; } DWORD GetCapacity() const { return m_dwCapacity; } FLOAT GetKeyTime( DWORD dwKeyIndex ) const { assert( dwKeyIndex < m_dwSize ); DWORD dwIndex = dwKeyIndex * ( m_dwValueDimension + 1 ); return m_pFloatData[ dwIndex ]; } FLOAT* GetKeyValue( DWORD dwKeyIndex ) { assert( dwKeyIndex < m_dwSize ); DWORD dwIndex = dwKeyIndex * ( m_dwValueDimension + 1 ) + 1; return &m_pFloatData[ dwIndex ]; } const FLOAT* GetKeyValue( DWORD dwKeyIndex ) const { assert( dwKeyIndex < m_dwSize ); DWORD dwIndex = dwKeyIndex * ( m_dwValueDimension + 1 ) + 1; return &m_pFloatData[ dwIndex ]; } XMVECTOR GetKeyVector( DWORD dwKeyIndex ) const { assert( m_dwValueDimension > 1 && m_dwValueDimension < 5 ); const FLOAT* pFloatData = GetKeyValue( dwKeyIndex ); switch( m_dwValueDimension ) { case 3: return XMLoadFloat3( (const XMFLOAT3*)pFloatData ); case 4: return XMLoadFloat4( (const XMFLOAT4*)pFloatData ); case 2: return XMLoadFloat2( (const XMFLOAT2*)pFloatData ); } return XMVectorZero(); } FLOAT GetKeyScalar( DWORD dwKeyIndex ) { assert( m_dwValueDimension == 1 ); FLOAT* pFloatData = GetKeyValue( dwKeyIndex ); return *pFloatData; } // Data update functions // Note: Ideally, these should not be executed at runtime, since they are a // slow way of updating this structure. DWORD AddKey(); VOID SetKeyTime( DWORD dwKeyIndex, FLOAT fTime ) const { assert( dwKeyIndex < m_dwSize ); assert( fTime >= 0.0f ); DWORD dwIndex = dwKeyIndex * ( m_dwValueDimension + 1 ); m_pFloatData[ dwIndex ] = fTime; } VOID SetKeyValue( DWORD dwKeyIndex, XMVECTOR vValue ); VOID SortKeys(); // Key search and sampling DWORD FindKey( FLOAT fTime, DWORD dwKeyIndexHint, BOOL bPlayForward ) const; XMVECTOR SampleVector( FLOAT fTime, DWORD* pKeyIndexHint, BOOL bPlayForward ) const; XMVECTOR SampleVectorLooping( FLOAT fTime, FLOAT fDuration, DWORD* pKeyIndexHint, BOOL bPlayForward ) const; protected: DWORD GetKeyTimeCode( DWORD dwKeyIndex ) const { assert( dwKeyIndex < m_dwSize ); DWORD dwIndex = dwKeyIndex * ( m_dwValueDimension + 1 ); return *(DWORD*)&m_pFloatData[ dwIndex ]; } protected: FLOAT* m_pFloatData; DWORD m_dwValueDimension; DWORD m_dwCapacity; DWORD m_dwSize; }; //---------------------------------------------------------------------------------- // Name: class AnimationTransformTrack // Desc: An animation track that contains a 3D position curve, a 4D quaternion // orientation curve, and a 3D scaling curve, all stored as keyframed // sequences. //---------------------------------------------------------------------------------- class AnimationTransformTrack : public NamedTypedObject { DEFINE_TYPE_INFO(); public: AnimationTransformTrack() : m_PositionKeys( 3 ), m_OrientationKeys( 4 ), m_ScaleKeys( 3 ) { } AnimationKeyArray& GetPositionKeys() { return m_PositionKeys; } AnimationKeyArray& GetOrientationKeys() { return m_OrientationKeys; } AnimationKeyArray& GetScaleKeys() { return m_ScaleKeys; } XMVECTOR SamplePosition( FLOAT fTime, DWORD* pLastKeyIndex = NULL, BOOL bPlayingForward = TRUE ) const { if( m_PositionKeys.GetKeyCount() == 0 ) return XMVectorZero(); return m_PositionKeys.SampleVector( fTime, pLastKeyIndex, bPlayingForward ); } XMVECTOR SampleOrientation( FLOAT fTime, DWORD* pLastKeyIndex = NULL, BOOL bPlayingForward = TRUE ) const { if( m_OrientationKeys.GetKeyCount() == 0 ) return XMQuaternionIdentity(); return m_OrientationKeys.SampleVector( fTime, pLastKeyIndex, bPlayingForward ); } XMVECTOR SampleScale( FLOAT fTime, DWORD* pLastKeyIndex = NULL, BOOL bPlayingForward = TRUE ) const { if( m_ScaleKeys.GetKeyCount() == 0 ) return XMVectorSet( 1, 1, 1, 1 ); return m_ScaleKeys.SampleVector( fTime, pLastKeyIndex, bPlayingForward ); } XMVECTOR SamplePositionLooping( FLOAT fTime, FLOAT fDuration, DWORD* pLastKeyIndex = NULL, BOOL bPlayingForward = TRUE ) const { if( m_PositionKeys.GetKeyCount() == 0 ) return XMVectorZero(); return m_PositionKeys.SampleVectorLooping( fTime, fDuration, pLastKeyIndex, bPlayingForward ); } XMVECTOR SampleOrientationLooping( FLOAT fTime, FLOAT fDuration, DWORD* pLastKeyIndex = NULL, BOOL bPlayingForward = TRUE ) const { if( m_OrientationKeys.GetKeyCount() == 0 ) return XMQuaternionIdentity(); return m_OrientationKeys.SampleVectorLooping( fTime, fDuration, pLastKeyIndex, bPlayingForward ); } XMVECTOR SampleScaleLooping( FLOAT fTime, FLOAT fDuration, DWORD* pLastKeyIndex = NULL, BOOL bPlayingForward = TRUE ) const { if( m_ScaleKeys.GetKeyCount() == 0 ) return XMVectorSet( 1, 1, 1, 1 ); return m_ScaleKeys.SampleVectorLooping( fTime, fDuration, pLastKeyIndex, bPlayingForward ); } protected: AnimationKeyArray m_PositionKeys; AnimationKeyArray m_OrientationKeys; AnimationKeyArray m_ScaleKeys; }; typedef std::vector<AnimationTransformTrack*> AnimationTransformTrackVector; //---------------------------------------------------------------------------------- // Name: class Animation // Desc: A graphics resource that contains a list of animation tracks, as well as // a duration for the animation. //---------------------------------------------------------------------------------- class Animation : public Resource { DEFINE_TYPE_INFO(); public: Animation() : m_fDuration( 0.0f ) { } ~Animation(); VOID SetDuration( FLOAT fDuration ) { m_fDuration = fDuration; } FLOAT GetDuration() const { return m_fDuration; } VOID AddAnimationTrack( AnimationTransformTrack* pTrack ) { m_Tracks.push_back( pTrack ); } DWORD GetAnimationTrackCount() const { return (DWORD)m_Tracks.size(); } AnimationTransformTrack* GetAnimationTrack( DWORD dwIndex ) { return m_Tracks[dwIndex]; } protected: AnimationTransformTrackVector m_Tracks; FLOAT m_fDuration; }; } // namespace ATG #endif // ATG_ANIMATION_H
[ "goohome@343f5ee6-a13e-11de-ba2c-3b65426ee844" ]
[ [ [ 1, 216 ] ] ]
c0ee24f02ba3c199ff209ed0811ac6947846788b
1caba14ec096b36815b587f719dda8c963d60134
/branches/smxgroup/smx/libsmx/straryx.h
7b606ea5430a63bec5e3b2c761ee1abf6d24978f
[]
no_license
BackupTheBerlios/smx-svn
0502dff1e494cffeb1c4a79ae8eaa5db647e5056
7955bd611e88b76851987338b12e47a97a327eaf
refs/heads/master
2021-01-10T19:54:39.450497
2009-03-01T12:24:56
2009-03-01T12:24:56
40,749,397
0
0
null
null
null
null
UTF-8
C++
false
false
1,870
h
#ifndef _STRARY_H #define _STRARY_H #ifndef _STR_H #include "str.h" #endif #ifndef _MAP_H #include "str.h" #endif #define CBufZ CBufChainZ class CStrAry : public CBufZ<CStr> { public: CStrAry(int n = 0) { m_buf = 0; Grow(n); } CStrAry(CStr *d, int n) { m_buf = 0; Grow(n); memcpy(m_buf, d, n * sizeof(CStr)); } CStr *Grow(int n) {int o = Count(); CBufZ<CStr>::Grow(n); if (Count() < o) {int i; for (i = Count(); i < o; ++i) Data()[i].Free();} return Data();} ~CStrAry() {int i; for (i = 0; i < (Alloc() / (int) sizeof(CStr)); ++i) Data()[i].Free();} int Count() const {if (this) return CBufZ<CStr>::Count(); else return 0;} CStr &GetAt(int i) {if (i < Count()) return Data()[i]; else return CStr::Null;} CStr &SetAt(int i, const char *str) {if (i >= Count()) Grow(i+1); return Data()[i] = str;} CStr &SetAt(int i, CStr &str) {if (i >= Count()) Grow(i+1); return Data()[i] = str;} CStr &Add(CStr str) {Grow(Count()+1); return Data()[Count()-1] = str;} operator char **() {return (char **) Data();} operator const char **() {return (const char **) Data();} CStr &operator [](int index) {return GetAt(index);} inline CStrAry &operator =(const CStrAry &newBuf) { int i; for (i = 0; i < (Alloc() / (int) sizeof(CStr)); ++i) Data()[i].Free(); if (&newBuf && newBuf.Data()) { i = newBuf.Count(); Grow(i); for (i = 0; i < Count(); ++i) Data()[i] = newBuf.Data()[i]; } return *this; } inline CStrAry &operator =(const char **newBuf) { int i; for (i = 0; i < (Alloc() / (int) sizeof(CStr)); ++i) Data()[i].Free(); if (newBuf) { const char **t = newBuf; while (*t) ++t; Grow(t-newBuf); for (t = newBuf; *t; ++t) Data()[i] = *t; } return *this; } }; #endif // #ifndef _STRARY_H
[ "simul@407f561b-fe63-0410-8234-8332a1beff53" ]
[ [ [ 1, 78 ] ] ]
fa51195fd94a3b225ccf828a523677d82b640540
279b68f31b11224c18bfe7a0c8b8086f84c6afba
/branches/0.0.1-DEV/tidy_html_parser.cpp
71dc4cd85fea6bcc29ef6a448924a9076cb4a84d
[]
no_license
bogus/findik
83b7b44b36b42db68c2b536361541ee6175bb791
2258b3b3cc58711375fe05221588d5a068da5ea8
refs/heads/master
2020-12-24T13:36:19.550337
2009-08-16T21:46:57
2009-08-16T21:46:57
32,120,100
0
0
null
null
null
null
UTF-8
C++
false
false
2,654
cpp
#include "tidy_html_parser.hpp" namespace findik { namespace parser { tidy_html_parser::tidy_html_parser(void) { parsed_content = new std::string(); } tidy_html_parser::~tidy_html_parser(void) { } void tidy_html_parser::clear() { delete this->parsed_content; tidyRelease( this->tdoc ); } std::string * tidy_html_parser::get_content() { return this->parsed_content; } void tidy_html_parser::create_doc(const char* html_content) { int rc = -1; Bool ok; TidyBuffer errbuf; tidyBufInit( &errbuf ); this->tdoc = tidyCreate(); ok = tidyOptSetBool( tdoc, TidyXhtmlOut, yes ); if( ok ) rc = tidySetErrorBuffer( tdoc, &errbuf); // Capture diagnostics*/ if ( rc >= 0 ) rc = tidyParseString( tdoc, html_content ); // Parse the input if ( rc >= 0 ) rc = tidyCleanAndRepair( tdoc ); // Tidy it up! tidyBufFree( &errbuf ); } void tidy_html_parser::parse_html() { this->dumpDoc(); } void tidy_html_parser::dumpDoc() { dumpNode( tidyGetRoot(this->tdoc) ); } void tidy_html_parser::dumpNode(TidyNode tnod) { TidyNode child; TidyBuffer buffer; tidyBufInit(&buffer); for ( child = tidyGetChild(tnod); child; child = tidyGetNext(child) ) { char * name = NULL; switch ( tidyNodeGetType(child) ) { /* case TidyNode_Root: name = "Root"; break; case TidyNode_DocType: name = "DOCTYPE"; break; case TidyNode_Comment: name = "Comment"; break; case TidyNode_ProcIns: name = "Processing Instruction"; break; */ case TidyNode_Text: tidyNodeGetText(this->tdoc,child,&buffer); parsed_content->append((char *)buffer.bp); break; /* case TidyNode_CDATA: name = "CDATA"; break; case TidyNode_Section: name = "XML Section"; break; case TidyNode_Asp: name = "ASP"; break; case TidyNode_Jste: name = "JSTE"; break; case TidyNode_Php: name = "PHP"; break; case TidyNode_XmlDecl: name = "XML Declaration"; break; case TidyNode_Start: case TidyNode_End: case TidyNode_StartEnd: default: name = tidyNodeGetName( child ); break; */ default: break; } //assert( name != NULL); dumpNode( child ); } tidyBufFree(&buffer); } } }
[ "shelta@d40773b4-ada0-11de-b0a2-13e92fe56a31" ]
[ [ [ 1, 105 ] ] ]
9d4aa5c8c01d6f607d47d79a65f4dd6aae9cb0b7
1d6dcdeddc2066f451338361dc25196157b8b45c
/tp1/Geometria/Segmento.cpp
8c5e744c7cfa878f25121a3c84e6274418eef779
[]
no_license
nicohen/ssgg2009
1c105811837f82aaa3dd1f55987acaf8f62f16bb
467e4f475ef04d59740fa162ac10ee51f1f95f83
refs/heads/master
2020-12-24T08:16:36.476182
2009-08-15T00:43:57
2009-08-15T00:43:57
34,405,608
0
0
null
null
null
null
UTF-8
C++
false
false
5,414
cpp
#include "Segmento.h" #include "../Motor.h" Segmento::Segmento(Coordenadas* desde, Coordenadas* hasta) { this->desde = desde; this->hasta = hasta; } Segmento::~Segmento() { delete this->desde; delete this->hasta; } float Segmento::pendiente(){ float pendiente = 0; Coordenadas* inicio = this->desde; Coordenadas* fin = this->hasta; int dx, dy; if (this->desde->tieneMayorX(this->hasta)){ inicio = this->hasta; fin = this->desde; } dy = fin->getY() - inicio->getY(); dx = fin->getX() - inicio->getX(); if (dx == 0) pendiente = INFINITO; else pendiente = (float)(dy)/(dx); return pendiente; } double Segmento::longitud(){ return (this->desde->distancia(*hasta)); } void Segmento::dibujar(){ glColor3f(this->borde->getRojo(), this->borde->getVerde(), this->borde->getAzul()); switch (Motor::getInstancia()->getModo()){ case 'D': this->dibujarDDA(); break; case 'B': this->dibujarBresenham(); break; default: break; } } void Segmento::dibujarPunteado() { glColor3f(this->borde->getRojo(), this->borde->getVerde(), this->borde->getAzul()); switch (Motor::getInstancia()->getModo()){ case 'D': this->dibujarDDAPunteado(); break; case 'B': this->dibujarBresenhamPunteado(); break; default: break; } } void Segmento::dibujarDDA() { int dx = this->hasta->getX()-this->desde->getX(); int dy = this->hasta->getY()-this->desde->getY(); int steps, k; float xIncrement, yIncrement, x=this->desde->getX(), y=this->desde->getY(); if (abs(dx)>abs(dy)) { steps = abs(dx); } else { steps = abs(dy); } xIncrement = dx / (float)steps; yIncrement = dy / (float)steps; glBegin(GL_POINTS); glVertex2i((int)(x+0.5), (int)(y+0.5)); for(k=0;k<steps;k++) { x+=xIncrement; y+=yIncrement; glVertex2i((int)(x+0.5), (int)(y+0.5)); } glEnd(); } void Segmento::dibujarDDAPunteado() { int pixelCounter = 1; int canDraw = true; int dx = this->hasta->getX()-this->desde->getX(); int dy = this->hasta->getY()-this->desde->getY(); int steps, k; float xIncrement, yIncrement, x=this->desde->getX(), y=this->desde->getY(); if (abs(dx)>abs(dy)) { steps = abs(dx); } else { steps = abs(dy); } xIncrement = dx / (float)steps; yIncrement = dy / (float)steps; glBegin(GL_POINTS); glVertex2i((int)(x+0.5), (int)(y+0.5)); for(k=0;k<steps;k++) { x+=xIncrement; y+=yIncrement; if(canDraw) { glVertex2i((int)(x+0.5), (int)(y+0.5)); } pixelCounter++; if(pixelCounter==10) { pixelCounter=0; canDraw=!canDraw; } } glEnd(); } void Segmento::dibujarBresenham() { unsigned int x0 = floor(this->desde->getX()); unsigned int y0 = floor(this->desde->getY()); unsigned int x1 = floor(this->hasta->getX()); unsigned int y1 = floor(this->hasta->getY()); int dx = x1 - x0; int dy = y1 - y0; glBegin(GL_POINTS); glVertex2i(x0,y0); if (abs(dx) > abs(dy)) { // pendiente < 1 float m = (float) dy / (float) dx; float b = y0 - m*x0; if(dx<0) { dx = -1; } else { dx = 1; } while (x0 != x1) { x0 += dx; y0 = round(m*x0 + b); glVertex2i(x0,y0); } } else { if (dy != 0) { float m = (float) dx / (float) dy; float b = x0 - m*y0; if(dy<0) { dy = -1; } else { dy = 1; } while (y0 != y1) { y0 += dy; x0 = round(m*y0 + b); glVertex2i(x0,y0); } } } glEnd(); } void Segmento::dibujarBresenhamPunteado(){ int pixelCounter = 1; int canDraw = true; unsigned int x0 = floor(this->desde->getX()); unsigned int y0 = floor(this->desde->getY()); unsigned int x1 = floor(this->hasta->getX()); unsigned int y1 = floor(this->hasta->getY()); int dx = x1 - x0; int dy = y1 - y0; glBegin(GL_POINTS); glVertex2i(x0,y0); if (abs(dx) > abs(dy)) { // pendiente < 1 float m = (float) dy / (float) dx; float b = y0 - m*x0; if(dx<0) { dx = -1; } else { dx = 1; } while (x0 != x1) { x0 += dx; y0 = round(m*x0 + b); if (canDraw) glVertex2i(x0,y0); pixelCounter++; if(pixelCounter==10) { pixelCounter=0; canDraw=!canDraw; } } } else { if (dy != 0) { float m = (float) dx / (float) dy; float b = x0 - m*y0; if(dy<0) { dy = -1; } else { dy = 1; } while (y0 != y1) { y0 += dy; x0 = round(m*y0 + b); if (canDraw) glVertex2i(x0,y0); pixelCounter++; if(pixelCounter==10) { pixelCounter=0; canDraw=!canDraw; } } } } glEnd(); } void Segmento::rellenar() { } bool Segmento::contiene(int x, int y){ //TODO return false; }
[ "rodvar@6da81292-15a5-11de-a4db-e31d5fa7c4f0", "nicohen@6da81292-15a5-11de-a4db-e31d5fa7c4f0" ]
[ [ [ 1, 51 ], [ 59, 59 ], [ 78, 80 ], [ 87, 88 ], [ 105, 107 ], [ 121, 122 ], [ 124, 124 ], [ 134, 135 ], [ 166, 167 ], [ 170, 228 ], [ 232, 236 ] ], [ [ 52, 58 ], [ 60, 77 ], [ 81, 86 ], [ 89, 104 ], [ 108, 120 ], [ 123, 123 ], [ 125, 133 ], [ 136, 165 ], [ 168, 169 ], [ 229, 231 ] ] ]
719ac8298178d72f00ed90e1e3f4371df9bfed14
3e1e78cd64328f947fdd721213f75b47a810d68c
/windows/UpdaterUI/MainFrm.cpp
0091df4ee35640d2274705e75228ad5cb350938b
[]
no_license
phuonglelephuong/dynamicipupdate
daeb10b891a06da80d345ced677cd96bdaa62d8f
58eb721427f132900d81ee95acf3cb09ea133f59
refs/heads/master
2021-01-15T20:53:17.046848
2011-12-06T18:41:32
2011-12-06T18:45:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
27,521
cpp
// Copyright (c) 2009 OpenDNS, LLC. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "stdafx.h" #ifndef MAIN_FRM #include "MainFrm.h" static bool HasDynamicNetworkWithLabel(NetworkInfo *head, const char *label) { while (head) { if (head->isDynamic) { if (streq(head->label, label)) return true; } head = head->next; } return false; } static void LogIpUpdate(char *resp) { slog("sent ip update for\nuser '"); assert(g_pref_user_name); if (g_pref_user_name) slog(g_pref_user_name); slog("', \nresponse: '"); if (resp) slog(resp); slog("'\nurl: "); const char *urlTxt = GetIpUpdateUrl(); if (urlTxt) slog(urlTxt); free((void*)urlTxt); slog("\nhost: "); slog(GetIpUpdateHost()); slog("\n"); } CMainFrame::CMainFrame() { m_ipFromDns = IP_UNKNOWN; m_ipFromHttp = NULL; m_ipUpdateResult = IpUpdateOk; m_simulatedError = SE_NO_ERROR; m_editErrorMsgRequestedDy = 0; m_editFontName = NULL; m_minWinDx = 320; // this is absolute minimum height of the window's client area m_minWinDy = 200; m_minStatusEditDx = 320 - 16; m_uiState = UI_STATE_VISIBLE; m_minutesSinceLastUpdate = 0; m_winBgColorBrush = ::CreateSolidBrush(colWinBg); } CMainFrame::~CMainFrame() { free(m_ipFromHttp); free(m_editFontName); DeleteObject(m_winBgColorBrush); } BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) { return CFrameWindowImpl<CMainFrame>::PreTranslateMessage(pMsg); } void CMainFrame::OnClose() { BOOL sendingUpdates = GetPrefValBool(g_pref_send_updates); if (CanSendIPUpdates() && sendingUpdates && !IsLeftAltAndCtrlPressed()) { SwitchToHiddenState(); SetMsgHandled(TRUE); } else { SetMsgHandled(FALSE); } } LRESULT CMainFrame::OnLButtonDown(UINT /*nFlags*/, CPoint /*point*/) { SetFocus(); return 0; } void CMainFrame::OnGetMinMaxInfo(LPMINMAXINFO lpMMI) { lpMMI->ptMinTrackSize.x = m_minWinDx; lpMMI->ptMinTrackSize.y = m_minWinDy; } // returns true if the time has changed and we need to update // the text in UI bool CMainFrame::GetLastIpUpdateTime() { // optimization: not showing ui => no need to update if (m_uiState != UI_STATE_VISIBLE) return false; int minutesSinceLastUpdate = m_updaterThread->MinutesSinceLastUpdate(); #if 0 // we don't want to show "0 minutes ago", so show at least "1 minute ago" if (0 == minutesSinceLastUpdate) minutesSinceLastUpdate = 1; #endif if (minutesSinceLastUpdate == m_minutesSinceLastUpdate) return false; m_minutesSinceLastUpdate = minutesSinceLastUpdate; return true; } void CMainFrame::UpdateLastUpdateText() { if (!GetLastIpUpdateTime()) return; UpdateStatusEdit(); } BOOL CMainFrame::OnIdle() { return FALSE; } void CMainFrame::ChangeNetwork(int supressFlags) { StartDownloadNetworks(g_pref_token, supressFlags); UpdateStatusEdit(); } LRESULT CMainFrame::OnSelChange(LPNMHDR /*pnmh*/) { SetFocus(); return 0; } void CMainFrame::OnSendUpdatesButtonClicked(UINT /*uNotifyCode*/, int /*nID*/, CWindow wndCtl) { CButton b = wndCtl; BOOL checked = b.GetCheck(); SetPrefValBool(&g_pref_send_updates, checked); PreferencesSave(); } // sent by rich edit control so that we can know its desired height LRESULT CMainFrame::OnRequestResize(LPNMHDR pnmh) { REQRESIZE* r = (REQRESIZE*)pnmh; m_editErrorMsgRequestedDy = RectDy(r->rc); return 0; } bool CMainFrame::IsLink(HWND hwnd) { if (hwnd == m_linkAbout.m_hWnd) return true; return false; } bool CMainFrame::IsCheckBoxButton(HWND hwnd) { if (hwnd == m_buttonSendIpUpdates.m_hWnd) return true; return false; } bool CMainFrame::IsStatic(HWND /*hwnd*/) { return false; } BOOL CMainFrame::OnEraseBkgnd(CDCHandle dc) { CRect rc; GetClientRect(rc); { #if 0 // Double-buffering. In our case we don't draw enough to make a difference CMemoryDC dc(dc, rc); #endif // paint top bar in a bluish gradient TRIVERTEX vert[2] ; GRADIENT_RECT gRect; vert[0].x = 0; vert[0].y = 0; vert[0].Red = 0x6b00; vert[0].Green = 0x7900; vert[0].Blue = 0xde00; vert[0].Alpha = 0x0000; vert[1].x = RectDx(rc); vert[1].y = TOP_BAR_DY; vert[1].Red = 0x8400; vert[1].Green = 0xa600; vert[1].Blue = 0xef00; vert[1].Alpha = 0x0000; gRect.UpperLeft = 0; gRect.LowerRight = 1; GradientFill(dc, vert, 2, &gRect, 1, GRADIENT_FILL_RECT_H); // paint solid background everywhere except in top bar rc.MoveToY(TOP_BAR_DY); dc.FillSolidRect(rc, colWinBg); // draw top bar text HFONT prevFont = dc.SelectFont(m_topBarFont); dc.SetBkMode(TRANSPARENT); dc.SetTextColor(colWhite); dc.TextOut(m_topBarX, m_topBarY, TOP_BAR_TXT); dc.SelectFont(prevFont); } return 1; } HBRUSH CMainFrame::OnCtlColorStatic(CDCHandle dc, CWindow wnd) { HWND hwnd = wnd; // TODO: could probabably do IsLink() and IsStatic() by // comparing WINDOWINFO.atomWindowType (obtained via GetWindowInfo()) // with ATOM corresponding to syslink and static classes found // with GetClassInfo() if (IsLink(hwnd)) { dc.SetBkColor(colWinBg); return 0; } else if (IsStatic(hwnd)) { //dc.SetBkColor(colWinBg); dc.SetTextColor(colBlack); dc.SetBkMode(TRANSPARENT); } else if (IsCheckBoxButton(hwnd)) { return m_winBgColorBrush; } else { SetMsgHandled(false); return 0; } return (HBRUSH)::GetStockObject(NULL_BRUSH); } bool CMainFrame::IsLoggedIn() { if (SE_NOT_LOGGED_IN == m_simulatedError) return false; if (strempty(g_pref_user_name)) return false; return true; } // returns true if we get valid ip address from both // http query and dns query and they are not the same // (it does happen) bool CMainFrame::DnsVsHttpIpMismatch() { if (!RealIpAddress(m_ipFromDns) || !m_ipFromHttp) return false; return (0 != m_ipFromDnsStr.Compare(m_ipFromHttp)); } void CMainFrame::BuildStatusEditRtf(RtfTextInfo& ti) { CString s; CUITextSizer sizer(*this); sizer.SetFont(m_statusEditFont); int minDx = 80; int dx; ti.Init(m_editFontName, EDIT_CTRL_FONT_SIZE); ti.StartBoldStyle(); if (IsLoggedIn()) { s = "Logged in as "; s += g_pref_user_name; s += ". "; ti.AddTxt(s); ti.AddLink("Change account.", LINK_CHANGE_ACCOUNT); s += "Change account. "; sizer.SetText(s); dx = sizer.GetIdealSizeDx(); if (dx > minDx) minDx = dx; ti.AddPara(); } if (!strempty(g_pref_user_name)) { if (streq(UNS_OK, g_pref_user_networks_state)) { if (strempty(g_pref_hostname)) { s = "Sending updates for default network. "; } else { s = "Sending updates for network '"; s += g_pref_hostname; s += "'. "; } ti.AddTxt(s); ti.AddLink("Change network.", LINK_CHANGE_NETWORK); s += "Change network. "; sizer.SetText(s); dx = sizer.GetIdealSizeDx(); if (dx > minDx) minDx = dx; ti.AddPara(); } } IP4_ADDRESS myNewIp = m_ipFromDns; if (RealIpAddress(myNewIp)) { IP4_ADDRESS a = myNewIp; s.Format(_T("Your IP address is %u.%u.%u.%u"), (a >> 24) & 255, (a >> 16) & 255, (a >> 8) & 255, a & 255); ti.AddTxt(s); ti.AddPara(); ti.AddTxt("You're using OpenDNS service."); } if (m_minutesSinceLastUpdate >= 0) { ti.AddPara(); ti.AddTxt("Last update: "); TCHAR *timeTxt = FormatUpdateTime(m_minutesSinceLastUpdate); if (timeTxt) { ti.AddTxt(timeTxt); free(timeTxt); } ti.AddTxt(" ago. "); ti.AddLink("Update now", LINK_SEND_IP_UPDATE); } ti.EndStyle(); ti.AddPara(); ti.AddPara(); // show error scenarios at the end, in bold red ti.StartBoldStyle(); ti.StartFgCol(RtfTextInfo::ColRed); if (!IsLoggedIn()) { s = "You're not logged to your OpenDNS account. "; ti.AddTxt(s); ti.AddLink("Log in.", LINK_CHANGE_ACCOUNT); s += "Log in. "; sizer.SetText(s); dx = sizer.GetIdealSizeDx(); if (dx > minDx) minDx = dx; ti.AddPara(); } if ((IP_NOT_USING_OPENDNS == myNewIp) || (SE_NOT_USING_OPENDNS == m_simulatedError)) { ti.AddTxt("You're not using OpenDNS service. Learn how to "); ti.AddLink("setup OpenDNS.", LINK_SETUP_OPENDNS); ti.AddPara(); ti.AddPara(); } else if ((IP_DNS_RESOLVE_ERROR == myNewIp) || (SE_NO_INTERNET == m_simulatedError)) { ti.AddTxt("Looks like there's no internet connectivity."); ti.AddPara(); ti.AddPara(); } if (!strempty(g_pref_user_name)) { if (streq(UNS_NO_NETWORKS, g_pref_user_networks_state) || (SE_NO_NETWORKS_CONFIGURED == m_simulatedError)) { #if 1 ti.AddTxt("You don't have any networks configured. "); ti.AddLink("Configure a network", LINK_CONFIGURE_NETWORKS); ti.AddTxt(" in your OpenDNS account."); #else ti.AddTxt("You don't have any networks configured. Configure a network in your OpenDNS account. "); ti.AddLink("Configure a network.", LINK_CONFIGURE_NETWORKS); #endif ti.AddPara(); ti.AddPara(); } else if (streq(UNS_NO_DYNAMIC_IP_NETWORKS, g_pref_user_networks_state) || (SE_NO_DYNAMIC_IP_NETWORKS == m_simulatedError)) { ti.AddTxt("None of your networks is configured for dynamic IP. "); ti.AddLink("Configure a network", LINK_CONFIGURE_NETWORKS); ti.AddTxt(" for dynamic IP in your OpenDNS account and "); ti.AddLink("choose a network", LINK_SELECT_NETWORK); ti.AddPara(); ti.AddPara(); } else if (streq(UNS_NO_NETWORK_SELECTED, g_pref_user_networks_state) || (SE_NO_NETWORK_SELECTED == m_simulatedError)) { ti.AddTxt("You need to select one of your networks for IP updates. "); ti.AddLink("Select network.", LINK_SELECT_NETWORK); ti.AddPara(); ti.AddPara(); } } if ((IpUpdateNotYours == m_ipUpdateResult) || (SE_IP_NOT_YOURS == m_simulatedError)) { ti.AddTxt(_T("Your IP address is taken by another user.")); ti.AddPara(); ti.AddPara(); } if ((IpUpdateBadAuth == m_ipUpdateResult) || (SE_BAD_AUTH == m_simulatedError)) { ti.AddTxt(_T("Your authorization token is invalid.")); ti.AddPara(); ti.AddPara(); } bool ipMismatch = DnsVsHttpIpMismatch(); if (ipMismatch) { ti.AddTxt(_T("Your OpenDNS filtering settings might not work due to DNS IP address (")); ti.AddTxt(m_ipFromDnsStr); ti.AddTxt(_T(") and HTTP IP address (")); ti.AddTxt(m_ipFromHttp); ti.AddTxt(_T(") mismatch.")); ti.AddPara(); ti.AddPara(); } ti.EndCol(); ti.EndStyle(); if (g_showDebug) { if (UsingDevServers()) { ti.AddTxt("Using dev api servers "); } else { ti.AddTxt("Using production api servers "); } ti.AddLink("(toggle)", LINK_TOGGLE_DEV_PRODUCTION); ti.AddTxt("."); ti.AddPara(); ti.AddLink("Send IP update", LINK_SEND_IP_UPDATE); ti.AddTxt(" "); ti.AddLink("Crash me", LINK_CRASH_ME); ti.AddPara(); } else { #if 0 if (UsingDevServers()) { ti.AddTxt("Using dev api servers."); ti.AddPara(); } #endif } ti.End(); m_minStatusEditDx = minDx; } void CMainFrame::UpdateStatusEdit(bool doLayout) { GetLastIpUpdateTime(); BuildStatusEditRtf(m_rti); const TCHAR *s = m_rti.text; #ifdef UNICODE // Don't know why I have to do this, but SetWindowText() with unicode // doesn't work (rtf codes are not being recognized) const char *sUtf = WstrToUtf8(s); m_editErrorMsg.SetTextEx((LPCTSTR)sUtf, ST_DEFAULT, CP_UTF8); #else m_editErrorMsg.SetWindowText(s); #endif SetRtfLinks(&m_rti); #if 0 m_editErrorMsg.SetSelAll(); PARAFORMAT2 paraFormat; memset(&paraFormat, 0, sizeof(paraFormat)); paraFormat.cbSize = sizeof(PARAFORMAT2); paraFormat.dwMask = PFM_LINESPACING; paraFormat.bLineSpacingRule = 5; // spacing is dyLineSpacing/20 lines (i.e. 20 - single spacing, 40 - double spacing etc.) paraFormat.dyLineSpacing = 20; HWND hwndEdit = m_editErrorMsg; ::SendMessage(hwndEdit, EM_SETPARAFORMAT, 0, (LPARAM)&paraFormat); #endif m_editErrorMsg.SetSelNone(); m_editErrorMsg.RequestResize(); if (doLayout) PostMessage(WMAPP_DO_LAYOUT); } void CMainFrame::SetRtfLinks(RtfTextInfo *rti) { RtfLinkInfo *link = rti->firstLink; while (link) { LONG start = link->start; LONG end = link->end; m_editErrorMsg.SetSel(start, end); CHARFORMAT2 cf; cf.cbSize = sizeof(cf); cf.dwMask = CFM_LINK; cf.dwEffects = CFE_LINK; m_editErrorMsg.SetCharFormat(cf, SCF_SELECTION); link = link->next; } } LRESULT CMainFrame::OnLinkStatusEdit(LPNMHDR pnmh) { ENLINK *e = (ENLINK *)pnmh; if (e->msg != WM_LBUTTONDOWN) return 0; CHARRANGE chr = e->chrg; LONG start = chr.cpMin; LONG end = chr.cpMax; RtfLinkId linkId; BOOL found = m_rti.FindLinkFromRange(start, end, linkId); assert(found); if (!found) return 0; if (LINK_CHANGE_ACCOUNT == linkId) { ChangeAccount(); } else if (LINK_CHANGE_NETWORK == linkId) { ChangeNetwork(0); } else if (LINK_SETUP_OPENDNS == linkId) { LaunchUrl(SETUP_OPENDNS_URL); } else if (LINK_SELECT_NETWORK == linkId) { ChangeNetwork(0); } else if (LINK_CONFIGURE_NETWORKS == linkId) { LaunchUrl(GetDashboardUrl()); } else if (LINK_TOGGLE_DEV_PRODUCTION == linkId) { if (UsingDevServers()) UseDevServers(false); else UseDevServers(true); UpdateStatusEdit(); } else if (LINK_SEND_IP_UPDATE == linkId) { m_updaterThread->ForceSendIpUpdate(); UpdateStatusEdit(); } else if (LINK_CRASH_ME == linkId) { CrashMe(); } else assert(0); SetFocus(); return 0; } void CMainFrame::ChangeAccount() { CSignInDlg dlg; INT_PTR nRet = dlg.DoModal(); if (IDCANCEL == nRet) { // nothing has changed return; } StartDownloadNetworks(g_pref_token, SupressOneNetworkMsgFlag | SuppressNoDynamicIpMsgFlag); UpdateStatusEdit(); } void CMainFrame::DoLayout() { static const int Y_SPACING = 4; int x, y; int minDx = m_minStatusEditDx + LEFT_MARGIN + RIGHT_MARGIN; int dxLine; SIZE s; // place exit button on the lower right corner BOOL ok; RECT clientRect; ok = GetClientRect(&clientRect); if (!ok) return; int clientDx = RectDx(clientRect); int clientDy = RectDy(clientRect); // position "Send IP updates" check-box in the bottom right corner CUICheckBoxButtonSizer sendIpUpdatsSizer(m_buttonSendIpUpdates); static const int BTN_SEND_UPDATES_RIGHT_MARGIN = 8; static const int BTN_SEND_UPDATES_BOTTOM_MARGIN = 4; RECT pos; CalcFixedPositionBottomRight(clientDx, clientDy, BTN_SEND_UPDATES_RIGHT_MARGIN, BTN_SEND_UPDATES_BOTTOM_MARGIN, &sendIpUpdatsSizer, pos); m_buttonSendIpUpdates.MoveWindow(&pos); int buttonDy = RectDy(pos); CUILinkSizer linkSizer; CUITextSizer textSizer; // position "About" link in the bottom left corner x = LEFT_MARGIN; linkSizer.SetWindow(m_linkAbout); linkSizer.SetFont(m_defaultGuiFont); s = linkSizer.GetIdealSize2(); static const int LINK_ABOUT_BOTTOM_MARGIN = 5; m_linkAbout.MoveWindow(x, clientDy - s.cy - LINK_ABOUT_BOTTOM_MARGIN, s.cx, s.cy); // position title in the middle of top bar RECT topBarRect = {0, 0, clientDx, TOP_BAR_DY}; m_topBarRect = topBarRect; textSizer.SetWindow(m_hWnd); // doesn't matter which window textSizer.SetFont(m_topBarFont); textSizer.SetText(TOP_BAR_TXT); s = textSizer.GetIdealSize2(); //y = (TOP_BAR_DY - s.cy) / 2; m_topBarY = 4; m_topBarX = (clientDx - s.cx) / 2; dxLine = s.cx + 2 * LEFT_MARGIN; if (dxLine > minDx) minDx = dxLine; // position "Logged in as" + (potential) "Change account" link x = LEFT_MARGIN; y = TOP_BAR_DY + 4; // position status edit box m_editErrorMsg.MoveWindow(LEFT_MARGIN, y, m_editErrorMsgDx, m_editErrorMsgRequestedDy); y += (m_editErrorMsgRequestedDy + Y_SPACING); dxLine = x + s.cx + RIGHT_MARGIN; if (dxLine > minDx) minDx = dxLine; int minDy = y + buttonDy + 8; // resize the window if the current size is smaller than // what's needed to display content int newClientDx = clientDx; if (minDx > clientDx) newClientDx = minDx; int newClientDy = clientDy; if (minDy > newClientDy) newClientDy = minDy; if ((newClientDx != clientDx) || (newClientDy != clientDy)) { ResizeClient(newClientDx, newClientDy); RECT r = {0, 0, newClientDx, newClientDy}; DWORD winStyle = GetStyle(); BOOL hasMenu = FALSE; ::AdjustWindowRect(&r, winStyle, hasMenu); m_minWinDx = RectDx(r); Invalidate(); } RECT r = {0, 0, 0, minDy}; DWORD winStyle = GetStyle(); BOOL hasMenu = FALSE; ::AdjustWindowRect(&r, winStyle, hasMenu); m_minWinDy = RectDy(r); } LRESULT CMainFrame::OnLayout(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/) { DoLayout(); InvalidateRect(m_topBarRect); return 0; } void CMainFrame::OnIpCheckResult(IP4_ADDRESS myIp) { if (m_ipFromDns == myIp) { // since this is called every minute, we use this // to check if we should update display of "last updated" time if (GetLastIpUpdateTime()) PostMessage(WMAPP_UPDATE_STATUS); return; } m_ipFromDns = myIp; IP4_ADDRESS a = m_ipFromDns; m_ipFromDnsStr.Format(_T("%u.%u.%u.%u"), (a >> 24) & 255, (a >> 16) & 255, (a >> 8) & 255, a & 255); // This is called on dns thread so trigger update of // the ui on ui thread PostMessage(WMAPP_UPDATE_STATUS); // on ip change force sending ip update to update // possible error state m_updaterThread->ForceSendIpUpdate(); } LRESULT CMainFrame::OnLinkAbout(LPNMHDR /*pnmh*/) { /* Show debug info when clicking on a link while pressing left alt key */ if (IsLeftAltPressed()) { if (g_showDebug) g_showDebug = false; else g_showDebug = true; UpdateStatusEdit(); return 0; } LaunchUrl(ABOUT_URL); return 0; } void CMainFrame::OnIpUpdateResult(char *ipUpdateRes) { IpUpdateResult ipUpdateResult = IpUpdateResultFromString(ipUpdateRes); LogIpUpdate(ipUpdateRes); free(m_ipFromHttp); m_ipFromHttp = NULL; if ((IpUpdateOk == ipUpdateResult) || (IpUpdateNotYours == ipUpdateResult)) { const char *ip = StrFindChar(ipUpdateRes, ' '); if (ip) m_ipFromHttp = StrToTStr(ip+1); } if (ipUpdateResult == m_ipUpdateResult) return; m_ipUpdateResult = ipUpdateResult; if (ipUpdateResult != IpUpdateOk) SwitchToVisibleState(); PostMessage(WMAPP_UPDATE_STATUS); } LRESULT CMainFrame::OnNewVersion(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/) { TCHAR *url = (TCHAR*)wParam; int ret = ::MessageBox(NULL, _T("New version of OpenDNS Updater client is available. Download new version?"), MAIN_FRAME_TITLE, MB_YESNO); if (ret == IDOK) { LaunchUrl(url); } free(url); return 0; } void CMainFrame::OnNewVersionAvailable(char *updateUrl) { TCHAR *url = StrToTStr(updateUrl); if (!url) return; PostMessage(WMAPP_NEW_VERSION, (WPARAM)url); } void CMainFrame::OnSize(UINT nType, CSize /*size*/) { if (SIZE_MINIMIZED == nType) return; RECT clientRect; BOOL ok = GetClientRect(&clientRect); if (!ok) return; int clientDx = RectDx(clientRect); m_editErrorMsgDx = clientDx - LEFT_MARGIN - RIGHT_MARGIN; m_editErrorMsg.RequestResize(); PostMessage(WMAPP_DO_LAYOUT); } void CMainFrame::StartDownloadNetworks(char *token, int supressFlags) { CString params = ApiParamsNetworksGet(token); const char *paramsTxt = TStrToStr(params); // TODO: could do it async but probably not worth it //HttpPostAsync(API_HOST, API_URL, paramsTxt, API_IS_HTTPS, m_hWnd, WM_HTTP_DOWNLOAD_NETOWRKS); const char *apiHost = GetApiHost(); bool apiHostIsHttps = IsApiHostHttps(); HttpResult *httpRes = HttpPost(apiHost, API_URL, paramsTxt, apiHostIsHttps); free((void*)paramsTxt); OnDownloadNetworks(0, (WPARAM)httpRes, (LPARAM)supressFlags); } static BOOL IsBitSet(int flags, int bit) { if (flags & bit) return true; return false; } LRESULT CMainFrame::OnDownloadNetworks(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam) { NetworkInfo *ni = NULL; char *jsonTxt = NULL; JsonEl *json = NULL; NetworkInfo *selectedNetwork = NULL; int supressFlags = (int)lParam; BOOL supressOneNetworkMsg = IsBitSet(supressFlags,SupressOneNetworkMsgFlag); BOOL suppressNoDynamicIpMsg = IsBitSet(supressFlags, SuppressNoDynamicIpMsgFlag); HttpResult *ctx = (HttpResult*)wParam; assert(ctx); if (!ctx || !ctx->IsValid()) goto Error; DWORD dataSize; jsonTxt = (char*)ctx->data.getData(&dataSize); json = ParseJsonToDoc(jsonTxt); if (!json) goto Error; WebApiStatus status = GetApiStatus(json); if (WebApiStatusSuccess != status) { if (WebApiStatusFailure == status) { long err; bool ok = GetApiError(json, &err); if (!ok) goto Error; if (ERR_NETWORK_DOESNT_EXIST == err) goto NoNetworks; if (ERR_BAD_TOKEN == err) goto BadToken; goto Error; } } ni = ParseNetworksGetJson(json); size_t networksCount = ListLengthGeneric(ni); assert(0 != networksCount); if (0 == networksCount) goto Error; size_t dynamicNetworksCount = DynamicNetworksCount(ni); if (0 == dynamicNetworksCount) goto NoDynamicNetworks; NetworkInfo *dynamicNetwork = FindFirstDynamic(ni); assert(dynamicNetwork); if (!dynamicNetwork) goto Error; if (1 == dynamicNetworksCount) { if (!supressOneNetworkMsg) MessageBox(_T("Only one network configured for dynamic IP updates. Using that network."), MAIN_FRAME_TITLE); PrefSetHostname(dynamicNetwork->label); SetPrefVal(&g_pref_user_networks_state, UNS_OK); goto Exit; } selectedNetwork = SelectNetwork(ni); if (!selectedNetwork) { // if cancelled selection but has a network already // selected, keep the old network if (!streq(UNS_OK, g_pref_user_networks_state)) goto NoNetworkSelected; if (strempty(g_pref_hostname)) goto NoNetworkSelected; // rare but possible case: currently selected network // is not on the list of downloaded network (e.g. user // changed networks on website) if (!HasDynamicNetworkWithLabel(ni, g_pref_hostname)) goto NoNetworkSelected; goto Exit; } PrefSetHostname(selectedNetwork->label); SetPrefVal(&g_pref_user_networks_state, UNS_OK); Exit: NetworkInfoFreeList(ni); JsonElFree(json); delete ctx; // prefs changed so save them PreferencesSave(); m_updaterThread->ForceSendIpUpdate(); // hack: sometimes cursor gets hidden so set // it to standard cursor to ensure it's visible HCURSOR curs = LoadCursor(NULL, IDC_ARROW); SetCursor(curs); return 0; NoNetworkSelected: //MessageBox(_T("You need to select a network for Dynamic IP Update."), MAIN_FRAME_TITLE); SetPrefVal(&g_pref_user_networks_state, UNS_NO_NETWORK_SELECTED); SetPrefVal(&g_pref_hostname, NULL); goto Exit; NoDynamicNetworks: if (!suppressNoDynamicIpMsg) MessageBox(_T("You don't have any networks enabled for Dynamic IP Update. Enable Dynamic IP Updates in your OpenDNS account"), MAIN_FRAME_TITLE); SetPrefVal(&g_pref_user_networks_state, UNS_NO_DYNAMIC_IP_NETWORKS); SetPrefVal(&g_pref_hostname, NULL); goto Exit; NoNetworks: //MessageBox(_T("You don't have any networks configured. You need to configure a network in your OpenDNS account"), MAIN_FRAME_TITLE); SetPrefVal(&g_pref_user_networks_state, UNS_NO_NETWORKS); SetPrefVal(&g_pref_hostname, NULL); goto Exit; BadToken: // TODO: this should never happen, not sure what the user can do // should we just nuke username/pwd/token in preferences? MessageBox(_T("Not a valid token"), MAIN_FRAME_TITLE); goto Exit; Error: MessageBox(_T("There was an error downloading networks"), MAIN_FRAME_TITLE); goto Exit; } NetworkInfo *CMainFrame::SelectNetwork(NetworkInfo *ni) { CSelectNetworkDlg dlg(ni); INT_PTR nRet = dlg.DoModal(); if (IDOK != nRet) return NULL; NetworkInfo *selected = dlg.m_selectedNetwork; assert(selected); return selected; } int CMainFrame::OnCreate(LPCREATESTRUCT /* lpCreateStruct */) { SetMenu(NULL); // remove WS_CLIPCHILDREN style to make transparent // static controls work ModifyStyle(WS_CLIPCHILDREN, 0); SetWindowText(MAIN_FRAME_TITLE); #if 0 m_defaultFont = AtlGetDefaultGuiFont(); #else HDC dc = GetWindowDC(); CLogFont logFontDefault(AtlGetDefaultGuiFont()); //_tcscpy_s(logFontDefault.lfFaceName, dimof(logFontDefault.lfFaceName), "Tahoma"); logFontDefault.SetBold(); logFontDefault.SetHeight(DEFAULT_FONT_SIZE, dc); m_defaultFont.Attach(logFontDefault.CreateFontIndirect()); CLogFont logFontEditFont(AtlGetDefaultGuiFont()); logFontEditFont.SetBold(); logFontEditFont.SetHeight(EDIT_CTRL_FONT_SIZE, dc); m_statusEditFont.Attach(logFontEditFont.CreateFontIndirect()); ReleaseDC(dc); #endif CLogFont lf(m_defaultFont); m_editFontName = tstrdup(lf.lfFaceName); //m_editFontName = tstrdup(_T("Tahoma")); //m_editFontName = tstrdup(_T("Times New Roman")); //m_editFontName = tstrdup(_T("Arial")); //m_editFontName = tstrdup(_T("Trebuchet MS")); //m_editFontName = tstrdup(_T("Fixedsys")); m_topBarFont = m_defaultFont; // values inside r don't matter - things get positioned in DoLayout() RECT r = {10, 10, 20, 20}; m_defaultGuiFont = AtlGetDefaultGuiFont(); // TODO: tried using LWS_TRANSPARENT and/or WS_EX_TRANSPARENT but they don't // seem to work as expected (i.e. create transparent background for the link // control) m_linkAbout.Create(m_hWnd, r, _T("<a>About this program</a>"), WS_CHILD | WS_VISIBLE); m_linkAbout.SetFont(m_defaultGuiFont); m_linkAbout.SetDlgCtrlID(IDC_LINK_ABOUT); m_buttonSendIpUpdates.Create(m_hWnd, r, _T("Send background IP updates"), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX); m_buttonSendIpUpdates.SetFont(m_defaultGuiFont); //m_buttonSendIpUpdates.SetFont(m_topBarFont); m_buttonSendIpUpdates.SetDlgCtrlID(IDC_CHECK_SEND_UPDATES); BOOL sendingUpdates = GetPrefValBool(g_pref_send_updates); m_buttonSendIpUpdates.SetCheck(sendingUpdates); m_editErrorMsg.Create(m_hWnd, r, _T(""), WS_CHILD | WS_VISIBLE | ES_MULTILINE); m_editErrorMsg.SetReadOnly(TRUE); m_editErrorMsg.SetEventMask(ENM_REQUESTRESIZE | ENM_LINK | ENM_SELCHANGE); //m_editErrorMsg.SetEventMask(ENM_REQUESTRESIZE | ENM_LINK); m_editErrorMsg.SetBackgroundColor(colWinBg); m_editErrorMsg.SetDlgCtrlID(IDC_EDIT_STATUS); if (strempty(g_pref_user_name) || strempty(g_pref_token)) { CSignInDlg dlg; dlg.DoModal(); } CMessageLoop* pLoop = _Module.GetMessageLoop(); ATLASSERT(pLoop != NULL); pLoop->AddMessageFilter(this); pLoop->AddIdleHandler(this); m_updaterThread = new UpdaterThread(this); m_updaterThread->ForceSendIpUpdate(); m_updaterThread->ForceSoftwareUpdateCheck(); return 0; } LRESULT CMainFrame::OnUpdateStatus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/) { UpdateStatusEdit(); return 0; } void CMainFrame::SwitchToVisibleState() { ShowWindow(SW_SHOW); m_uiState = UI_STATE_VISIBLE; UpdateStatusEdit(); } void CMainFrame::SwitchToHiddenState() { ShowWindow(SW_HIDE); m_uiState = UI_STATE_HIDDEN; } LRESULT CMainFrame::OnErrorNotif(UINT /*uMsg*/, WPARAM specialCmd, LPARAM /*lParam*/) { slog("CMainFrame::OnErrorNotif(): "); if (SPECIAL_CMD_SHOW == specialCmd) { SwitchToVisibleState(); slog("SPECIAL_CMD_SHOW\n"); } else { char buf[32]; slog("unknown specialCmd="); itoa((int)specialCmd, buf, 10); slog(buf); slog("\n"); assert(0); } return 0; } #endif
[ [ [ 1, 990 ] ] ]
d87fd0871bf0d24a7f54de4a62b5c06303235980
74c8da5b29163992a08a376c7819785998afb588
/NetAnimal/addons/pa/ParticleUniverse/src/ParticleAffectors/ParticleUniversePathFollowerTokens.cpp
af9ceeb469065e0858475db7dddb409492b4dbfe
[]
no_license
dbabox/aomi
dbfb46c1c9417a8078ec9a516cc9c90fe3773b78
4cffc8e59368e82aed997fe0f4dcbd7df626d1d0
refs/heads/master
2021-01-13T14:05:10.813348
2011-06-07T09:36:41
2011-06-07T09:36:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,907
cpp
/* ----------------------------------------------------------------------------------------------- This source file is part of the Particle Universe product. Copyright (c) 2010 Henry van Merode Usage of this program is licensed under the terms of the Particle Universe Commercial License. You can find a copy of the Commercial License in the Particle Universe package. ----------------------------------------------------------------------------------------------- */ #include "ParticleUniversePCH.h" #ifndef PARTICLE_UNIVERSE_EXPORTS #define PARTICLE_UNIVERSE_EXPORTS #endif #include "ParticleAffectors/ParticleUniversePathFollower.h" #include "ParticleAffectors/ParticleUniversePathFollowerTokens.h" namespace ParticleUniverse { //----------------------------------------------------------------------- bool PathFollowerTranslator::translateChildProperty(Ogre::ScriptCompiler* compiler, const Ogre::AbstractNodePtr &node) { Ogre::PropertyAbstractNode* prop = reinterpret_cast<Ogre::PropertyAbstractNode*>(node.get()); ParticleAffector* af = Ogre::any_cast<ParticleAffector*>(prop->parent->context); PathFollower* affector = static_cast<PathFollower*>(af); if (prop->name == token[TOKEN_PATH_POINT]) { // Property: path_follower_point if (passValidateProperty(compiler, prop, token[TOKEN_PATH_POINT], VAL_VECTOR3)) { Ogre::Vector3 val; if(getVector3(prop->values.begin(), prop->values.end(), &val)) { affector->addPoint(val); return true; } } } return false; } //----------------------------------------------------------------------- bool PathFollowerTranslator::translateChildObject(Ogre::ScriptCompiler* compiler, const Ogre::AbstractNodePtr &node) { // No objects return false; } //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- void PathFollowerWriter::write(ParticleScriptSerializer* serializer, const IElement* element) { // Cast the element to a PathFollower const PathFollower* affector = static_cast<const PathFollower*>(element); // Write the header of the PathFollower serializer->writeLine(token[TOKEN_AFFECTOR], affector->getAffectorType(), affector->getName(), 8); serializer->writeLine("{", 8); // Write base attributes ParticleAffectorWriter::write(serializer, element); // Write own attributes unsigned short numberOfPoints = affector->getNumPoints(); if (numberOfPoints > 0) { for (unsigned short u = 0; u < numberOfPoints; ++u) { serializer->writeLine(token[TOKEN_PATH_POINT], Ogre::StringConverter::toString(affector->getPoint(u)), 12); } } // Write the close bracket serializer->writeLine("}", 8); } }
[ [ [ 1, 81 ] ] ]
dd46e2dd635d44ecd0a370284c74f6699dd184ff
028d6009f3beceba80316daa84b628496a210f8d
/uidesigner/com.nokia.sdt.referenceprojects.test/data/TUI_5_0/reference/inc/TUI_5_0AppUi.h
f9d8ae31fcc3dea9c77d0d992ea399fcecf11ff4
[]
no_license
JamesLinus/oss.FCL.sftools.dev.ide.carbidecpp
fa50cafa69d3e317abf0db0f4e3e557150fd88b3
4420f338bc4e522c563f8899d81201857236a66a
refs/heads/master
2020-12-30T16:45:28.474973
2010-10-20T16:19:31
2010-10-20T16:19:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,615
h
#ifndef TUI_5_0APPUI_H #define TUI_5_0APPUI_H // [[[ begin generated region: do not modify [Generated Includes] #include <aknviewappui.h> // ]]] end generated region [Generated Includes] // [[[ begin generated region: do not modify [Generated Forward Declarations] class CTUI_5_0ContainerView; // ]]] end generated region [Generated Forward Declarations] /** * @class CTUI_5_0AppUi TUI_5_0AppUi.h * @brief The AppUi class handles application-wide aspects of the user interface, including * view management and the default menu, control pane, and status pane. */ class CTUI_5_0AppUi : public CAknViewAppUi { public: // constructor and destructor CTUI_5_0AppUi(); virtual ~CTUI_5_0AppUi(); void ConstructL(); public: // from CCoeAppUi TKeyResponse HandleKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ); // from CEikAppUi void HandleCommandL( TInt aCommand ); void HandleResourceChangeL( TInt aType ); // from CAknAppUi void HandleViewDeactivation( const TVwsViewId& aViewIdToBeDeactivated, const TVwsViewId& aNewlyActivatedViewId ); private: void InitializeContainersL(); // [[[ begin generated region: do not modify [Generated Methods] public: // ]]] end generated region [Generated Methods] // [[[ begin generated region: do not modify [Generated Instance Variables] private: CTUI_5_0ContainerView* iTUI_5_0ContainerView; // ]]] end generated region [Generated Instance Variables] // [[[ begin [User Handlers] protected: // ]]] end [User Handlers] }; #endif // TUI_5_0APPUI_H
[ [ [ 1, 58 ] ] ]
af1b8bcaaacecd0ec712b256818226bc51e9a8cb
5f41a9d36008ef931c7b068ec0e05175beb1e82b
/user paint.cpp
05428972d4feeaedc023817e36430b2602bf800d
[]
no_license
zootella/backup
438af7bbe4c7cdc453b6983de48f498104bf9d3f
806271bdf84795a990558c90f932b9bf7f7971bd
refs/heads/master
2021-01-10T21:04:27.693788
2011-12-26T23:39:16
2011-12-26T23:39:16
146,246
2
0
null
null
null
null
UTF-8
C++
false
false
5,608
cpp
// Include statements #include <windows.h> #include <windef.h> #include <atlstr.h> #include <shlobj.h> #include "resource.h" #include "program.h" #include "class.h" #include "function.h" // Global objects extern handleitem Handle; // Make painting tools once when the program starts void PaintCreate() { // Make color brushes Handle.white = CreateBrush(RGB(255, 255, 255)); Handle.black = CreateBrush(RGB( 0, 0, 0)); Handle.blue = CreateBrush(RGB( 0, 102, 204)); Handle.lightblue = CreateBrush(RGB( 51, 153, 255)); Handle.yellow = CreateBrush(RGB(255, 204, 0)); Handle.lightyellow = CreateBrush(RGB(255, 255, 102)); Handle.green = CreateBrush(RGB(102, 204, 51)); Handle.lightgreen = CreateBrush(RGB(153, 255, 102)); Handle.red = CreateBrush(RGB(255, 102, 51)); Handle.lightred = CreateBrush(RGB(255, 153, 102)); Handle.middle = CreateBrush(ColorMix(GetSysColor(COLOR_3DFACE), 1, GetSysColor(COLOR_3DSHADOW), 1)); // Make fonts Handle.arial = CreateFont(L"Arial", 299); // Biggest size that will still have font smoothing // Make a font based on what the system uses in message boxes NONCLIENTMETRICS info; ZeroMemory(&info, sizeof(info)); info.cbSize = sizeof(info); // Must define _WIN32_WINNT=0x0501 for sizeof(info) to return the size SPI_GETNONCLIENTMETRICS expects SystemParametersInfo( SPI_GETNONCLIENTMETRICS, // System parameter to retrieve sizeof(info), // Size of the structure &info, // Structure to fill with information 0); // Not setting a system parameter Handle.font = CreateFontIndirect(&info.lfMenuFont); if (!Handle.font) Report(L"error createfontindirect"); } // Paint the client area of the window and resize the child window controls void Paint() { // Sizes used in the layout int margin = 16; int labelwidth = 70; int buttonwidth = 80; int taskheight = 122; int buttonheight = 25; int statusheight = 54; // Rectangular sizes in the client area sizeitem client; sizeitem label1, label2, label3; sizeitem border1, border2, border3; sizeitem tasks, status, errors; sizeitem clear, task, start, stop, reset; // Find the width and height of the client area RECT rectangle; GetClientRect(Handle.window, &rectangle); client.set(rectangle); // 0 when the window is minimized // Tasks label label1.set(margin, margin, labelwidth, taskheight); // Tasks box border1 = label1; border1.x(label1.r() + margin); border1.r(client.w() - margin); // Measure from right, and keep it wide enough if (border1.w() < buttonwidth) border1.w(buttonwidth); // Clear button clear = border1; clear.y(border1.b() + margin); clear.w(buttonwidth); clear.h(buttonheight); // Buttons in that row task = clear; task.addx(buttonwidth + margin); start = task; start.addx(buttonwidth + margin); stop = start; stop.addx(buttonwidth + margin); reset = stop; reset.addx(buttonwidth + margin); // Labels on the left label2 = label1; label2.y(clear.b() + margin); label2.h(statusheight); label3 = label2; label3.y(label2.b() + margin); label3.b(client.b() - margin); // Measure from bottom, and keep it tall enough if (label3.h() < buttonheight) label3.h(buttonheight); // Controls on the right border2 = label2; border2.x(border1.x()); border2.w(border1.w()); border3 = label3; border3.x(border1.x()); border3.w(border1.w()); // Controls in borders; tasks = border1; tasks.inside(); status = border2; status.inside(); errors = border3; errors.inside(); // Move labels inside to line up with controls label1.inside(); label2.inside(); label3.inside(); // Pick colors for the background banner message brushitem *field, *text, *label; if (Handle.display.banner == L"start") { field = &Handle.blue; text = &Handle.lightblue; label = &Handle.white; } else if (Handle.display.banner == L"running") { field = &Handle.yellow; text = &Handle.lightyellow; label = &Handle.black; } else if (Handle.display.banner == L"done") { field = &Handle.green; text = &Handle.lightgreen; label = &Handle.black; } else if (Handle.display.banner == L"errors") { field = &Handle.red; text = &Handle.lightred; label = &Handle.white; } else { field = &Handle.blue; text = &Handle.lightblue; label = &Handle.white; } // Position and size child window controls WindowSize(Handle.tasks, tasks); WindowSize(Handle.status, status); WindowSize(Handle.errors, errors); WindowSize(Handle.clear, clear); WindowSize(Handle.task, task); WindowSize(Handle.start, start); WindowSize(Handle.stop, stop); WindowSize(Handle.reset, reset); // Paint the window deviceitem device; device.OpenPaint(Handle.window); // Paint the background color PaintFill(&device, client, field->brush); // Paint the banner device.Font(Handle.arial); device.FontColor(text->color); device.BackgroundColor(field->color); PaintText(&device, Handle.display.banner, client); // Paint the text lables on the left device.Font(Handle.font); device.FontColor(label->color); device.Background(TRANSPARENT); PaintText(&device, L"Tasks", label1); PaintText(&device, L"Status", label2); PaintText(&device, L"Errors", label3); // Paint the borders PaintBorder(&device, border1, Handle.middle.brush); PaintBorder(&device, border2, Handle.middle.brush); PaintBorder(&device, border3, Handle.middle.brush); }
[ "Kevin@machine.(none)", "[email protected]" ]
[ [ [ 1, 31 ], [ 33, 35 ], [ 38, 43 ], [ 45, 123 ], [ 129, 156 ], [ 160, 165 ] ], [ [ 32, 32 ], [ 36, 37 ], [ 44, 44 ], [ 124, 128 ], [ 157, 159 ] ] ]
906ebc99dbf3d2e1d8126f38632ae39b993b967e
9420f67e448d4990326fd19841dd3266a96601c3
/ mcvr/mcvr/Tests.h
b6baa756e8dae4778000990952d90b7270b41629
[]
no_license
xrr/mcvr
4d8d7880c2fd50e41352fae1b9ede0231cf970a2
b8d3b3c46cfddee281e099945cee8d844cea4e23
refs/heads/master
2020-06-05T11:59:27.857504
2010-02-24T19:32:21
2010-02-24T19:32:21
32,275,830
0
0
null
null
null
null
UTF-8
C++
false
false
780
h
#pragma once #include "Payoff.h" class Tests { public: static void VTest(void); static void SampleTest(void); // ==> static void BaseTests(void); static void LinearCongruentialGeneratorTest(unsigned=5000); static void MersenneTwisterGeneratorTest(unsigned=5000); static void BoxMullerGeneratorTest(unsigned=5000); static void MarsagliaGeneratorTest(unsigned=5000); static void MillionGaussSpeedTest(unsigned=100); // ==> static void RNGTests(void); static void LognormalTest(unsigned=5000); static void BlackScholesSDETest(void); // ==> static void BSTests(void); static void PayoffTest(Payoff*, const char*); // ==> static void PayoffTests(void); static void MonteCarloTest(void); //==> static void MCTests(void); };
[ "romain.rousseau@fa0ec5f0-0fe6-11df-8179-3f26cfb4ba5f" ]
[ [ [ 1, 34 ] ] ]
2495ced88d714e2c99ab860c4a248969b511d2e2
42a799a12ffd61672ac432036b6fc8a8f3b36891
/cpp/IGC_Tron/IGC_Tron/Menu.h
9a1a79bd6107d21d2b90e0c03c6797b86f86d518
[]
no_license
timotheehub/igctron
34c8aa111dbcc914183d5f6f405e7a07b819e12e
e608de209c5f5bd0d315a5f081bf0d1bb67fe097
refs/heads/master
2020-02-26T16:18:33.624955
2010-04-08T16:09:10
2010-04-08T16:09:10
71,101,932
0
0
null
null
null
null
ISO-8859-1
C++
false
false
831
h
// Menu.h // Déclaration de la classe Menu #ifndef __MENU_H__ #define __MENU_H__ #include "Singleton.h" #include "AbstractCamera.h" #include "CameraOverall.h" class Menu : public Singleton<Menu> { friend class Singleton<Menu>; public: static const int BUTTON_COUNT = 3; enum ButtonEnum { SOLO, SETTINGS, QUIT }; static void OnKeyDown( int keyboardContext, int keyCode ); static void OnKeyUp( int keyboardContext, int keyCode ); void Init ( ); void Free ( ); void Update ( ); void Draw ( ); ButtonEnum GetButtonPointer ( ); void SetButtonPointer ( ButtonEnum aButton ); protected: ButtonEnum nButtonPointer; AbstractCamera *currentCamera; CameraOverall cameraOverall; private: // Constructeur Menu ( ); // Destructeur ~Menu ( ); }; #endif // __MENU_H__*/
[ [ [ 1, 45 ] ] ]
966e36b3a895c532369e7d45a955a615c1f111c7
2bf221bc84477471c79e47bdb758776176202e0a
/plc/pamiec.h
d20de9dbe562fa2474dcd08edc086118a1cd7dac
[]
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
2,066
h
#ifndef pamiec_h_included #define pamiec_h_included #include <windows.h> #include <stdio.h> #include <string> using namespace std; #define MOZNA_CONST 0x0001 #define MOZNA_I 0x0002 #define MOZNA_Q 0x0004 #define MOZNA_R 0x0008 #define MOZNA_M 0x0010 #define MOZNA_AI 0x0020 #define MOZNA_AQ 0x0040 #define KOLOR_ADRES_DOBRY 0x000000 #define KOLOR_ADRES_ZLY 0x0000ff typedef enum { typ_CONST = 1, typ_I = 2, typ_Q = 4, typ_R = 8, typ_M = 16, typ_AI = 32, typ_AQ = 64 } typy_pamieci; struct opis_komorki { wstring opis; typy_pamieci typ; int adres; opis_komorki * nastepny; }; class pamiec { private: static int * I; static int * Q; static int * R; static int * M; static int * AI; static int * AQ; static int il_I; static int il_Q; static int il_R; static int il_M; static int il_AI; static int il_AQ; int adres_pamieci; int zajetosc_pamieci; typy_pamieci typ_pamieci; int dozwolone_typy; int valid; wstring nazwa_komorki; void wybierz_pamiec(int * &komorka, int adres); static void usun_opisy(void); static wstring poszukaj_opisu(typy_pamieci typ, int adres); public: static opis_komorki * lista_opisow; static opis_komorki * koniec_listy; pamiec(wstring nazwa, int dozwolone, int szerokosc = 1); pamiec(typy_pamieci typ, int adres, int szerokosc); pamiec(FILE * plik); ~pamiec(); static void nowe_parametry_sterownika(int nowe_I, int nowe_Q, int nowe_R, int nowe_M, int nowe_AI, int nowe_AQ); static void wyczysc_pamiec(void); void zapisz_pamiec(int wartosc, int adres = 0); int odczytaj_pamiec(int adres = 0); wstring podpisz_nazwa(void); void narysuj_nazwe(HDC kontekst, int x, int y, int align); wstring podpisz_adres(void); void narysuj_adres(HDC kontekst, int x, int y, int align); static void dodaj_opis(typy_pamieci typ, int adres, wstring opis); friend void zmien_parametry_pamieci(HWND okno, pamiec * aktualna); void zapisz(FILE * plik); }; void zmien_parametry_pamieci(HWND okno, pamiec * aktualna); #endif
[ "[email protected]@2c618d7f-f323-8192-d80b-44f770db81a5" ]
[ [ [ 1, 85 ] ] ]
9229e1ff3b9c2b6a26862f49d996e01b4fc0c2d5
09a84291381a2ae9e366b848aff5ac94342e6d4b
/WinSubst/Source/AboutDialog.h
20ec223b755c5be3628a46b741f51be0ef41b7a9
[]
no_license
zephyrer/xsubst
0088343300d62d909a87e235da490728b9af5106
111829b6094d796aefb7c8e4ec7bd40bae4d6449
refs/heads/master
2020-05-20T03:22:44.200074
2011-06-18T05:50:34
2011-06-18T05:50:34
40,066,695
0
0
null
null
null
null
UTF-8
C++
false
false
1,339
h
// WinSubst application. // Copyright (c) 2004-2011 by Elijah Zarezky, // All rights reserved. // 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. // AboutDialog.h - interface of the CAboutDialog class #if !defined(__AboutDialog_h) #define __AboutDialog_h #if defined(_MSC_VER) && (_MSC_VER > 1000) #pragma once #endif // _MSC_VER class CAboutDialog: public CDialog { DECLARE_DYNAMIC(CAboutDialog) DECLARE_MESSAGE_MAP() // construction/destruction public: CAboutDialog(CWnd* pParentWnd = NULL); virtual ~CAboutDialog(void); // overridables public: virtual BOOL OnInitDialog(void); // diagnostic services #if defined(_DEBUG) public: virtual void AssertValid(void) const; virtual void Dump(CDumpContext& dumpCtx) const; #endif }; #endif // __AboutDialog_h // end of file
[ "Elijah Zarezky@9a190745-9f41-0410-876d-23307a9d09e3", "elijah@9a190745-9f41-0410-876d-23307a9d09e3" ]
[ [ [ 1, 4 ], [ 17, 50 ] ], [ [ 5, 16 ] ] ]
9f33ee1eb836682d14bf4f2922d7e600b04c9a26
6d7b85cb2b2655ecede756d19e5c1e43fd31cf13
/sources/mainwindow.h
493e8ce59c5f992cc5a306ae461ee1433c2c3b93
[]
no_license
s-jonas/MT.Copy
b44fe22627e3a4394692199846032b64416281b8
abdbaa7cb175921d69dcbb887ce80f55dd9f7481
refs/heads/master
2021-01-10T22:05:34.098859
2011-08-18T09:49:05
2011-08-18T09:49:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
525
h
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QtGui> class MainWindow : public QMainWindow { Q_OBJECT private: QFileSystemWatcher* watcher; QFileInfo* fileInfo; void initMenu(); void initMainWindow(); public: MainWindow(QMainWindow *parent = 0, Qt::WindowFlags flags = 0); ~MainWindow(); QTextEdit* editor; public slots: void addAccount(); void onFileChanged(const QString& file); }; #endif // MAINWINDOW_H
[ [ [ 1, 22 ] ] ]
d8329740e63deae3bf29d68157cc38afa14ed468
c1bcff0f1321de8a6425723cdfa0b5aa65b5c81f
/TransX/trunk/TransXFunction.h
0c312bc80c8742f62ae5dbc20f788e119dfcec11
[ "MIT" ]
permissive
net-lisias-orbiter/transx
560266e7a4ef73ed29d9004e406fd8db28da9a43
b9297027718a7499934a9614430aebb47422ce7f
refs/heads/master
2023-06-27T14:16:10.697238
2010-09-05T01:18:54
2010-09-05T01:18:54
390,398,358
0
0
null
null
null
null
UTF-8
C++
false
false
4,900
h
/* Copyright (c) 2007 Duncan Sharpe, Steve Arch ** ** 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.*/ #ifndef __TRANSXFUNCTION_H #define __TRANSXFUNCTION_H #include "mfdfunction.h" #include "parser.h" #include "mfdvarhandler.h" #include "intercept.h" #include "graph.h" #define MAX_HELPSTRING_LENGTH 40 #define PEN_DEFAULT Grey #define PEN_PLANET Grey #define PEN_HYPO Yellow #define PEN_CRAFT Green #define PEN_ATMOSPHERE Blue class transxstate; class TransXFunction: public MFDFunction { public: enum PenIdentifier { Hollow = -1, Green = 0, Blue, Yellow, Red, Grey, White, NUM_PENS }; private: static void initpens(void); virtual bool initialisevars() = 0; static void deletepens(); Parser parser; char helpstring1[MAX_HELPSTRING_LENGTH], helpstring2[MAX_HELPSTRING_LENGTH], helpstring3[MAX_HELPSTRING_LENGTH], helpstring4[MAX_HELPSTRING_LENGTH], helpstring5[MAX_HELPSTRING_LENGTH]; protected: OBJHANDLE hmajor, hminor, hmajtarget, hcraft, hbase;//Standard set of OBJHANDLES for the TransX MFD double gravbodyratio; //Specific computation associated with hmajor+hminor double simstartMJD; //Time at which current scenario commenced class MFDvarhandler vars; //Variable set associated with this MFDFunction class transxstate *state; //Pointer to calling transxstate static Pen *pens[NUM_PENS];//Replacement pens for MFD static Brush *brush[NUM_PENS]; public: static Pen* SelectDefaultPen(Sketchpad *sketchpad, int value); static Brush* TransXFunction::SelectBrush(Sketchpad *sketchpad, int value); MFDvarhandler* getvariablehandler();//Passes pointer to variable handler TransXFunction(class transxstate *tstate, OBJHANDLE thmajor, OBJHANDLE thminor, OBJHANDLE thtarget, OBJHANDLE thcraft, OBJHANDLE thbase);//Constructor TransXFunction(class transxstate *tstate, OBJHANDLE thmajor, OBJHANDLE thminor,OBJHANDLE thcraft);//Constructor virtual ~TransXFunction();//Destructor virtual void restoreself(FILEHANDLE scn);//Attempts to restore previous saved state virtual void saveself(FILEHANDLE scn);//Saves current state to file void findfinish(FILEHANDLE scn);//Find end of function bool loadhandle(FILEHANDLE scn,OBJHANDLE *handle);//Loads an objecthandle from a file void savehandle(FILEHANDLE scn, OBJHANDLE handle);//Saves handle to scenario file void savevector(FILEHANDLE scn, VECTOR3 &vector); void savedouble(FILEHANDLE scn, double savenumber); bool loadint(FILEHANDLE scn, int *loadedint); bool loaddouble(FILEHANDLE scn, double *loadednumber); bool loadvector(FILEHANDLE scn, VECTOR3 *loadedvector); void saveorbit(FILEHANDLE scn, const OrbitElements &saveorbit);//Saves an orbit structure bool loadorbit(FILEHANDLE scn, OrbitElements *loadorbit);//Loads an orbit structure virtual void doupdate(Sketchpad *sketchpad, int tw, int th, int viewmode){return;};//overloaded to create views MFDvariable *getcurrentvariable(int view); void gethandles(OBJHANDLE *thmajor, OBJHANDLE *thminor, OBJHANDLE *thtarget, OBJHANDLE *thcraft, OBJHANDLE *thbase); //Gets handles OBJHANDLE gethmajor(){return hmajor;};//Return central body OBJHANDLE gethcraft(){return hcraft;}; OBJHANDLE gethtarget(){return hmajtarget;};//Return target handle void sethandles(OBJHANDLE thmajor, OBJHANDLE thminor, OBJHANDLE thtarget, OBJHANDLE thcraft, OBJHANDLE thbase); void sethmajor(OBJHANDLE handle); virtual bool sethminor(OBJHANDLE handle); bool sethminorstd(OBJHANDLE handle);//Standard operations to set hminor bool sethmajtarget(OBJHANDLE handle); void sethcraft(OBJHANDLE handle); void sethbase(OBJHANDLE handle); void sethelp(char *help1,char *help2,char *help3,char *help4,char *help5); void gethelp(char *help1,char *help2,char *help3,char *help4,char *help5) const; }; #endif
[ "steve@5a6c10e1-6920-0410-8c7b-9669c677a970", "agentgonzo@5a6c10e1-6920-0410-8c7b-9669c677a970" ]
[ [ [ 1, 41 ], [ 43, 54 ], [ 56, 56 ], [ 58, 69 ], [ 72, 73 ], [ 76, 92 ], [ 94, 111 ] ], [ [ 42, 42 ], [ 55, 55 ], [ 57, 57 ], [ 70, 71 ], [ 74, 75 ], [ 93, 93 ] ] ]
48226183c7b1c4c4370833dd750c2a69e65eb85b
f744f8897adce6654cdfe6466eaf4d0fad4ba661
/src/data/character/ChSkeleton.h
c3ebb678b53324fae3ed44cf5b64a676e39cacfb
[]
no_license
pizibing/bones-animation
37919ab3750683a5da0cc849f80d1e0f5b37c89c
92ce438e28e3020c0e8987299c11c4b74ff98ed5
refs/heads/master
2016-08-03T05:34:19.294712
2009-09-16T14:59:32
2009-09-16T14:59:32
33,969,248
0
0
null
null
null
null
UTF-8
C++
false
false
1,605
h
#pragma once #include <string> #include <map> class ChBone; // Skeleton for a character // contains the pointers of all bones // must set bone total number when create a new skeleton class ChSkeleton { public: // constructor ChSkeleton(void); // destructor ~ChSkeleton(void); // get bone by name // @param name the name for the bone // @return the pointer for the bone with the name // if no bone has the name, create a new bone ChBone* getBone(const std::string &name); // get bone by index // @param boneId the index for the bone // @return the pointer for the bone with the index // if no bone has the index return NULL ChBone* getBone(int boneId); // get the index of bone with the name // @param name the name for the bone // @return the index of the bone int getBoneId(const std::string &name); // get the array of all bones ChBone** getAllBones()const; // @return the number of bones int getBoneNum() const; // @return the root bone pointer ChBone* getRootBone()const; // set root bone void setRootBone(ChBone *bone); // calculate transform in world space void calculateAbsoluteTransform(); // init the pointer array for bones // skeleton can be initialized only once // @param bone_num the number of bones // @return true if successful bool init(int bone_num); private: // the bone name int m_bone_num; // bone pointers ChBone **m_bones; // map bone name with bone index std::map< std::string, int > m_boneMap; // root bone pointer ChBone * m_rootBone; };
[ [ [ 1, 67 ] ] ]
3bb654a4e13d4a847077badb470311d4b05c0302
94d9e8ec108a2f79068da09cb6ac903c16b77730
/sociarium/view.h
ce9e01dc7766b2f65b8336c861bf253700fb814c
[]
no_license
kiyoya/sociarium
d375c0e5abcce11ae4b087930677483d74864d09
b26c2c9cbd23c2f8ef219d0059e42370294865d1
refs/heads/master
2021-01-25T07:28:25.862346
2009-10-22T05:57:42
2009-10-22T05:57:42
318,115
1
0
null
null
null
null
UTF-8
C++
false
false
6,066
h
// s.o.c.i.a.r.i.u.m: view.h // HASHIMOTO, Yasuhiro (E-mail: hy @ sys.t.u-tokyo.ac.jp) /* Copyright (c) 2005-2009, HASHIMOTO, Yasuhiro, 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 University of Tokyo 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 COPYRIGHT HOLDERS AND CONTRIBUTORS * "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 COPYRIGHT * OWNER OR CONTRIBUTORS 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. */ #ifndef INCLUDE_GUARD_SOCIARIUM_PROJECT_VIEW_H #define INCLUDE_GUARD_SOCIARIUM_PROJECT_VIEW_H #include "../shared/vector2.h" namespace hashimoto_ut { //////////////////////////////////////////////////////////////////////////////// namespace NodeStyle { enum { POLYGON = 0x01, TEXTURE = 0x02, MASK1 = 0x03, MASK2 = 0x04 }; } //////////////////////////////////////////////////////////////////////////////// namespace EdgeStyle { enum { LINE = 0x01, POLYGON = 0x02, MASK1 = 0x03, MASK2 = 0x04 }; } //////////////////////////////////////////////////////////////////////////////// namespace CommunityStyle { enum { POLYGON_CIRCLE = 0x01, TEXTURE = 0x02, POLYGON_CURVE = 0x04, MASK1 = 0x07, MASK2 = 0x08 }; } //////////////////////////////////////////////////////////////////////////////// namespace CommunityEdgeStyle { enum { LINE = 0x01, POLYGON = 0x02, MASK1 = 0x03, MASK2 = 0x04 }; } namespace sociarium_project_view { namespace { // Initial distance between the center of the world and the eyepoint. float const VIEW_DISTANCE = 100.0f; float const VIEW_DISTANCE_MAX = 500.0f; float const VIEW_DISTANCE_MIN = 1.0f; } //////////////////////////////////////////////////////////////////////////////// // Draw or not each graph element. bool get_show_node(void); void set_show_node(bool b); bool get_show_edge(void); void set_show_edge(bool b); bool get_show_community(void); void set_show_community(bool b); bool get_show_community_edge(void); void set_show_community_edge(bool b); //////////////////////////////////////////////////////////////////////////////// // Draw or not the name of each graph element. bool get_show_node_name(void); void set_show_node_name(bool b); bool get_show_edge_name(void); void set_show_edge_name(bool b); bool get_show_community_name(void); void set_show_community_name(bool b); bool get_show_community_edge_name(void); void set_show_community_edge_name(bool b); //////////////////////////////////////////////////////////////////////////////// // The drawing size of the name is variable or not. bool get_node_name_size_variable(void); void set_node_name_size_variable(bool b); bool get_edge_name_size_variable(void); void set_edge_name_size_variable(bool b); bool get_community_name_size_variable(void); void set_community_name_size_variable(bool b); bool get_community_edge_name_size_variable(void); void set_community_edge_name_size_variable(bool b); //////////////////////////////////////////////////////////////////////////////// // The drawing style of each graph element. unsigned int get_node_style(void); void set_node_style(unsigned int value); void shift_node_style(void); unsigned int get_edge_style(void); void set_edge_style(unsigned int value); void shift_edge_style(void); unsigned int get_community_style(void); void set_community_style(unsigned int value); void shift_community_style(void); unsigned int get_community_edge_style(void); void set_community_edge_style(unsigned int value); void shift_community_edge_style(void); //////////////////////////////////////////////////////////////////////////////// // Draw or not other elements. bool get_show_slider(void); void set_show_slider(bool b); bool get_show_grid(void); void set_show_grid(bool b); bool get_show_fps(void); void set_show_fps(bool b); bool get_show_center(void); void set_show_center(bool b); bool get_show_layer_name(void); void set_show_layer_name(bool b); bool get_show_layout_frame(void); void set_show_layout_frame(bool b); bool get_show_diagram(void); void set_show_diagram(bool b); } // The end of the namespace "sociarium_project_view" } // The end of the namespace "hashimoto_ut" #endif // INCLUDE_GUARD_SOCIARIUM_PROJECT_VIEW_H
[ [ [ 1, 176 ] ] ]
8f737f3f52fa32671b0a67913299625801caca26
de2b54a7b68b8fa5d9bdc85bc392ef97dadc4668
/TrackerOnFann21/NeuralNetwork/NeuralNet.cpp
1f6249f42fea5eb42215c0150ead85eca5fc082c
[]
no_license
kumarasn/tracker
8c7c5b828ff93179078cea4db71f6894a404f223
a3e5d30a3518fe3836f007a81050720cef695345
refs/heads/master
2021-01-10T07:57:09.306936
2009-04-17T15:02:16
2009-04-17T15:02:16
55,039,695
0
0
null
null
null
null
UTF-8
C++
false
false
1,244
cpp
/* * NeuralNet.cpp * * Created on: 05-feb-2009 * Author: Timpa */ #include "NeuralNet.h" NeuralNet::NeuralNet() { // TODO Auto-generated constructor stub } NeuralNet::~NeuralNet() { // TODO Auto-generated destructor stub fann_destroy(network);//check this!! } void NeuralNet::run(IplImage *scr) { //Podemos tener varias redes y trabajar de manera conjunta, tipo voting-system if ( scr != NULL){ input_values = normal_filter->applyFilter(scr);//Normalizo la Imagen output_values = fann_run(network,input_values); xCoord = output_values[0]; yCoord = output_values[1]; } } int NeuralNet::getYcoord() { return yCoord; } int NeuralNet::getXcoord() { return xCoord; } void NeuralNet::shutDown() { //grabamos en el log el tiempo promedio de proceso, y demas fann_destroy(network); } bool NeuralNet::startNet() { //si no podemos grabamos en el log if ( netFile == "" )//log return false; network = fann_create_from_file(netFile.c_str()); normal_filter = new NormalFilter(); input_values = new fann_type[4800]; output_values = new fann_type[2]; xCoord = 0; yCoord = 0; return true; }
[ "latesisdegrado@048d8772-f3ab-11dd-a8e2-f7cb3c35fcff" ]
[ [ [ 1, 89 ] ] ]
b6e83a7d9e9f2b33cd4535f25c34063c71adb2c9
f4f8ec5c50bf0411b31379f55b8365d9b82cb61e
/Bookshop/bookshop.cpp
107a3100996f10d23fb28585d7b31e01a19947c7
[]
no_license
xhbang/cpp-homework
388da7b07ddc296bf67d373c96b7ea134c42ef0c
fb9a21fef40ac042210b662964ca120998ac8bcf
refs/heads/master
2021-01-22T05:20:59.989600
2011-12-05T10:31:14
2011-12-05T10:31:14
2,915,735
0
0
null
null
null
null
UTF-8
C++
false
false
4,997
cpp
// 书店函数文件 #ifndef BOOKSHOP_CPP #define BOOKSHOP_CPP #include "bookshop.h" #include <iostream> #include <conio.h> #include <sstream> #include <iomanip> #include <fstream> #include <functional> #include <algorithm> #include <string> #include <vector> using namespace std; //********************************* 构造函数 ******************************************** Bookshop::Bookshop() { ifstream infile ( "Bookshop.txt" ); if ( !infile) throw 1; else { infile.read( ( char * )&_bookshop,sizeof( vector< Book > ) ); } infile.close(); } //******************************* 提取文件内容到内存 ************************************************ vector < Book > Bookshop::setbookshop() { _bookshop.clear(); ifstream infile ("Bookshop.txt"); if (!infile) throw 1; else { infile.read( ( char * )&_bookshop,sizeof( vector<Book> ) ); } infile.close(); return _bookshop; } //***************************** 打印 *********************************************** void Bookshop::display( vector<Book> b ) { size_t m = 0; for(; m < b.size(); m++) cout << left <<setw( 10 ) <<b[m].get_serial_number() << setw( 16 ) <<b[m].get_bookname() << setw( 16 ) <<b[m].get_author() << setw( 8 ) <<b[m].get_number() << setw( 10 ) << b[m].get_price() << endl; } //************************************ 找书 ********************************************* void Bookshop::findbook( vector<Book> &vec1 ) { vec1.clear(); vector<Book> b; int i = 0, n = 0, m = 0; string bookname; string author; string serial_number ; b = setbookshop(); //将文件内容存放到容器中 cout <<"1、按书名查找 2、按作者姓名查找 " <<"请选择 : "; cin >> i; switch(i) { case 1: cout <<"请输入书名 : "; cin>>bookname; for((size_t)m = 0; m < b.size(); m++ ) if(b[m].get_bookname() == bookname) { n++; vec1.push_back(b[m]); } if( n == 0 ) cout << "对不起 ! 你要找的信息不存在 。" <<endl; else cout << " 共找到 " << n <<" 个结果 !\n"; break; case 2: cout << "请输入作者姓名 : "; cin >> author; for(m = 0; m < b.size(); m++ ) if(b[m].get_author() == author) { n++; vec1.push_back(b[m]); } if( n == 0 ) cout << "对不起 ! 你要找的信息不存在 。" <<endl; else cout << " 共找到 " << n <<" 个结果 !\n"; break; default: throw 2; } if( vec1.size() != 0 ) for ( m = 0; m < vec1.size(); m++ ) cout << left << setw(3) << m + 1 << setw(10) << vec1[m].get_serial_number() << setw(16) << vec1[m].get_bookname() << setw(16) << vec1[m].get_author() << setw(5) << vec1[m].get_number() << setw(8) << vec1[m].get_price() << endl; } //*************************** 书店进入界面 ***************************** char Bookshop::showBookshopLoginMenu() { system( "cls" ); system( "color 56" ); cout << endl << " XXXX书店欢迎您 ! " << endl<<endl << " >>>>>>>>>>>>>>> 欢迎监督书店营业状况 <<<<<<<<<<<<<<< " << endl << " >> 请选择功能: >> " << endl << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " << endl << " >> 1.顾客登录 >> " << endl << " >> 2.管理员登录 >> " << endl << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " << endl; cout<<"请选择 : "; char ch; cin>>ch; return ch; } //***************************** 排序输出 ********************************************** void Bookshop::book_sort( vector< Book > &b,char ch) { int i, n; Book p; for ( i = 0; i < b.size(); i++ ) for(n = 0; n < (b.size() - i - 1 ); n++ ) { if ( b[n].get_number() < b[n+1].get_number() ) { p = b[n]; b[n] = b[n+1]; b[n+1]=p; } } switch (ch) //M 代表管理员全部输出, C 代表顾客输出5项 , N 代表不做任何事。 { case 'M': for ( i=0;i<b.size();i++) cout<<left<<setw(10)<<b[i].get_serial_number() <<setw(16)<<b[i].get_bookname()<<setw(16) <<b[i].get_author()<<setw(5)<<b[i].get_number() <<setw(8)<<b[i].get_price()<<endl; break; case 'C': for ( n = 0;n < 5 ; n++ ) cout<<left<<setw(10)<<b[n].get_serial_number() <<setw(16)<<b[n].get_bookname()<<setw(16) <<b[n].get_author()<<setw(5)<<b[n].get_number() <<setw(8)<<b[n].get_price()<<endl; break; case 'N': break; default: throw 2; } } #endif
[ [ [ 1, 189 ] ] ]
2769015be1e05654f07c9b5d8a3f2d17686e96d3
0f40e36dc65b58cc3c04022cf215c77ae31965a8
/src/apps/vis/base/vis_base_init.cpp
7ed1f3dd04294833d38456de8c20f7da391edffc
[ "MIT", "BSD-3-Clause" ]
permissive
venkatarajasekhar/shawn-1
08e6cd4cf9f39a8962c1514aa17b294565e849f8
d36c90dd88f8460e89731c873bb71fb97da85e82
refs/heads/master
2020-06-26T18:19:01.247491
2010-10-26T17:40:48
2010-10-26T17:40:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,736
cpp
/************************************************************************ ** This file is part of the network simulator Shawn. ** ** Copyright (C) 2004,2005 by SwarmNet (www.swarmnet.de) ** ** and SWARMS (www.swarms.de) ** ** Shawn is free software; you can redistribute it and/or modify it ** ** under the terms of the GNU General Public License, version 2. ** ************************************************************************/ #include "../buildfiles/_apps_enable_cmake.h" #ifdef ENABLE_VIS #include "apps/vis/base/vis_base_init.h" #include "apps/vis/base/visualization_keeper.h" #include "apps/vis/writer/vis_writer_keeper.h" #include "apps/vis/writer/vis_png_writer_factory.h" #include "apps/vis/writer/vis_pdf_writer_factory.h" #include "apps/vis/writer/vis_ps_writer_factory.h" #include "apps/vis/elements/vis_drawable_node_default_factory.h" #include "apps/vis/elements/vis_drawable_node_keeper.h" #include "sys/simulation/simulation_controller.h" #include "apps/vis/examples/processors/vis_energy_processor.h" #include "apps/vis/examples/processors/vis_energy_processor_factory.h" namespace vis { void init_vis_base( shawn::SimulationController& sc ) { sc.add_keeper( new VisualizationKeeper ); sc.add_keeper( new WriterKeeper ); sc.add_keeper( new DrawableNodeKeeper ); PdfWriterFactory::register_factory(sc); PngWriterFactory::register_factory(sc); PsWriterFactory::register_factory(sc); DrawableNodeDefaultFactory::register_factory( sc ); #ifdef ENABLE_EXAMPLES VisEnergyProcessorFactory::register_factory(sc); #endif } } #endif
[ [ [ 1, 43 ] ] ]
e7aebf13cbfc7f83be98c052740eed58d26490aa
ce262ae496ab3eeebfcbb337da86d34eb689c07b
/SETools/SEToolsCommon/SECollada/SEColladaInstanceController.cpp
4431d4e27725144f39ef41a21e0180b2402551e0
[]
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
UTF-8
C++
false
false
2,649
cpp
// 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 #include "SEToolsCommonPCH.h" #include "SEColladaInstanceController.h" using namespace Swing; SE_IMPLEMENT_RTTI(Swing, SEColladaInstanceController, SEObject); SE_IMPLEMENT_DEFAULT_NAME_ID(SEColladaInstanceController, SEObject); //---------------------------------------------------------------------------- SEColladaInstanceController::SEColladaInstanceController(ControllerType eType, domController* pController, domNode* pSkeletonRoot, SENode* pMeshRoot) { m_eControllerType = eType; m_pController = pController; m_pSkeletonRoot = pSkeletonRoot; m_pMeshRoot = pMeshRoot; } //---------------------------------------------------------------------------- SEColladaInstanceController::SEColladaInstanceController() { } //---------------------------------------------------------------------------- SEColladaInstanceController::~SEColladaInstanceController() { } //---------------------------------------------------------------------------- SEColladaInstanceController::ControllerType SEColladaInstanceController::GetControllerType() const { return m_eControllerType; } //---------------------------------------------------------------------------- domController* SEColladaInstanceController::GetController() { return m_pController; } //---------------------------------------------------------------------------- domNode* SEColladaInstanceController::GetSkeletonRoot() { return m_pSkeletonRoot; } //---------------------------------------------------------------------------- SENode* SEColladaInstanceController::GetMeshRoot() { return m_pMeshRoot; } //----------------------------------------------------------------------------
[ "[email protected]@876e9856-8d94-11de-b760-4d83c623b0ac" ]
[ [ [ 1, 67 ] ] ]
44a9486cf6d7cac3c41f47f0858a5cf4e0916143
221e3e713891c951e674605eddd656f3a4ce34df
/core/OUE/Impl/Win32.h
6cdbe11465ccf1660c18ff9c9689534c6fed736a
[ "MIT" ]
permissive
zacx-z/oneu-engine
da083f817e625c9e84691df38349eab41d356b76
d47a5522c55089a1e6d7109cebf1c9dbb6860b7d
refs/heads/master
2021-05-28T12:39:03.782147
2011-10-18T12:33:45
2011-10-18T12:33:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,530
h
/* This source file is part of OneU Engine. Copyright (c) 2011 Ladace 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. */ #pragma once #include "../OUEDefs.h" namespace OneU { extern HWND g_hWnd; extern HINSTANCE g_hInstance; class WinErrorString { pcwstr m_pMsgBuf; HRESULT m_hRes; WinErrorString(const WinErrorString&); WinErrorString& operator=(const WinErrorString&); public: WinErrorString(HRESULT hRes) : m_hRes(hRes), m_pMsgBuf(NULL){} ~WinErrorString(); pcwstr c_str() const; }; }
[ "[email protected]@d30a3831-f586-b1a3-add9-2db6dc386f9c" ]
[ [ [ 1, 43 ] ] ]
4891670a3aa5cd5ff660e46d7d8b14e9f0093be5
fd3f2268460656e395652b11ae1a5b358bfe0a59
/cryptopp/vmac.cpp
7889b62914c08868ee097d97cf66a2b1ac0fd165
[ "LicenseRef-scancode-cryptopp", "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
mikezhoubill/emule-gifc
e1cc6ff8b1bb63197bcfc7e67c57cfce0538ff60
46979cf32a313ad6d58603b275ec0b2150562166
refs/heads/master
2021-01-10T20:37:07.581465
2011-08-13T13:58:37
2011-08-13T13:58:37
32,465,033
4
2
null
null
null
null
UTF-8
C++
false
false
23,534
cpp
// vmac.cpp - written and placed in the public domain by Wei Dai // based on Ted Krovetz's public domain vmac.c and draft-krovetz-vmac-01.txt #include "pch.h" #include "vmac.h" #include "argnames.h" #include "cpu.h" NAMESPACE_BEGIN(CryptoPP) #if defined(_MSC_VER) && !CRYPTOPP_BOOL_SLOW_WORD64 #include <intrin.h> #endif #define VMAC_BOOL_WORD128 (defined(CRYPTOPP_WORD128_AVAILABLE) && !defined(CRYPTOPP_X64_ASM_AVAILABLE)) #ifdef __BORLANDC__ #define const // Turbo C++ 2006 workaround #endif static const word64 p64 = W64LIT(0xfffffffffffffeff); /* 2^64 - 257 prime */ static const word64 m62 = W64LIT(0x3fffffffffffffff); /* 62-bit mask */ static const word64 m63 = W64LIT(0x7fffffffffffffff); /* 63-bit mask */ static const word64 m64 = W64LIT(0xffffffffffffffff); /* 64-bit mask */ static const word64 mpoly = W64LIT(0x1fffffff1fffffff); /* Poly key mask */ #ifdef __BORLANDC__ #undef const #endif #if VMAC_BOOL_WORD128 #ifdef __powerpc__ // workaround GCC Bug 31690: ICE with const __uint128_t and C++ front-end #define m126 ((word128(m62)<<64)|m64) #else static const word128 m126 = (word128(m62)<<64)|m64; /* 126-bit mask */ #endif #endif void VMAC_Base::UncheckedSetKey(const byte *userKey, unsigned int keylength, const NameValuePairs &params) { int digestLength = params.GetIntValueWithDefault(Name::DigestSize(), DefaultDigestSize()); if (digestLength != 8 && digestLength != 16) throw InvalidArgument("VMAC: DigestSize must be 8 or 16"); m_is128 = digestLength == 16; m_L1KeyLength = params.GetIntValueWithDefault(Name::L1KeyLength(), 128); if (m_L1KeyLength <= 0 || m_L1KeyLength % 128 != 0) throw InvalidArgument("VMAC: L1KeyLength must be a positive multiple of 128"); AllocateBlocks(); BlockCipher &cipher = AccessCipher(); cipher.SetKey(userKey, keylength, params); unsigned int blockSize = cipher.BlockSize(); unsigned int blockSizeInWords = blockSize / sizeof(word64); SecBlock<word64> out(blockSizeInWords); SecByteBlock in; in.CleanNew(blockSize); size_t i; /* Fill nh key */ in[0] = 0x80; cipher.AdvancedProcessBlocks(in, NULL, (byte *)m_nhKey(), m_nhKeySize()*sizeof(word64), cipher.BT_InBlockIsCounter); ConditionalByteReverse<word64>(BIG_ENDIAN_ORDER, m_nhKey(), m_nhKey(), m_nhKeySize()*sizeof(word64)); /* Fill poly key */ in[0] = 0xC0; in[15] = 0; for (i = 0; i <= (size_t)m_is128; i++) { cipher.ProcessBlock(in, out.BytePtr()); m_polyState()[i*4+2] = GetWord<word64>(true, BIG_ENDIAN_ORDER, out.BytePtr()) & mpoly; m_polyState()[i*4+3] = GetWord<word64>(true, BIG_ENDIAN_ORDER, out.BytePtr()+8) & mpoly; in[15]++; } /* Fill ip key */ in[0] = 0xE0; in[15] = 0; word64 *l3Key = m_l3Key(); for (i = 0; i <= (size_t)m_is128; i++) do { cipher.ProcessBlock(in, out.BytePtr()); l3Key[i*2+0] = GetWord<word64>(true, BIG_ENDIAN_ORDER, out.BytePtr()); l3Key[i*2+1] = GetWord<word64>(true, BIG_ENDIAN_ORDER, out.BytePtr()+8); in[15]++; } while ((l3Key[i*2+0] >= p64) || (l3Key[i*2+1] >= p64)); m_padCached = false; size_t nonceLength; const byte *nonce = GetIVAndThrowIfInvalid(params, nonceLength); Resynchronize(nonce, (int)nonceLength); } void VMAC_Base::GetNextIV(RandomNumberGenerator &rng, byte *IV) { SimpleKeyingInterface::GetNextIV(rng, IV); IV[0] &= 0x7f; } void VMAC_Base::Resynchronize(const byte *nonce, int len) { size_t length = ThrowIfInvalidIVLength(len); size_t s = IVSize(); byte *storedNonce = m_nonce(); if (m_is128) { memset(storedNonce, 0, s-length); memcpy(storedNonce+s-length, nonce, length); AccessCipher().ProcessBlock(storedNonce, m_pad()); } else { if (m_padCached && (storedNonce[s-1] | 1) == (nonce[length-1] | 1)) { m_padCached = VerifyBufsEqual(storedNonce+s-length, nonce, length-1); for (size_t i=0; m_padCached && i<s-length; i++) m_padCached = (storedNonce[i] == 0); } if (!m_padCached) { memset(storedNonce, 0, s-length); memcpy(storedNonce+s-length, nonce, length-1); storedNonce[s-1] = nonce[length-1] & 0xfe; AccessCipher().ProcessBlock(storedNonce, m_pad()); m_padCached = true; } storedNonce[s-1] = nonce[length-1]; } m_isFirstBlock = true; Restart(); } void VMAC_Base::HashEndianCorrectedBlock(const word64 *data) { assert(false); throw 0; } #if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && CRYPTOPP_BOOL_X86 #pragma warning(disable: 4731) // frame pointer register 'ebp' modified by inline assembly code void #ifdef __GNUC__ __attribute__ ((noinline)) // Intel Compiler 9.1 workaround #endif VMAC_Base::VHASH_Update_SSE2(const word64 *data, size_t blocksRemainingInWord64, int tagPart) { const word64 *nhK = m_nhKey(); word64 *polyS = m_polyState(); word32 L1KeyLength = m_L1KeyLength; #ifdef __GNUC__ word32 temp; __asm__ __volatile__ ( AS2( mov %%ebx, %0) AS2( mov %1, %%ebx) ".intel_syntax noprefix;" #else #if _MSC_VER < 1300 || defined(__INTEL_COMPILER) char isFirstBlock = m_isFirstBlock; AS2( mov ebx, [L1KeyLength]) AS2( mov dl, [isFirstBlock]) #else AS2( mov ecx, this) AS2( mov ebx, [ecx+m_L1KeyLength]) AS2( mov dl, [ecx+m_isFirstBlock]) #endif AS2( mov eax, tagPart) AS2( shl eax, 4) AS2( mov edi, nhK) AS2( add edi, eax) AS2( add eax, eax) AS2( add eax, polyS) AS2( mov esi, data) AS2( mov ecx, blocksRemainingInWord64) #endif AS2( shr ebx, 3) AS1( push ebp) AS2( sub esp, 12) ASL(4) AS2( mov ebp, ebx) AS2( cmp ecx, ebx) AS2( cmovl ebp, ecx) AS2( sub ecx, ebp) AS2( lea ebp, [edi+8*ebp]) // end of nhK AS2( movq mm6, [esi]) AS2( paddq mm6, [edi]) AS2( movq mm5, [esi+8]) AS2( paddq mm5, [edi+8]) AS2( add esi, 16) AS2( add edi, 16) AS2( movq mm4, mm6) ASS( pshufw mm2, mm6, 1, 0, 3, 2) AS2( pmuludq mm6, mm5) ASS( pshufw mm3, mm5, 1, 0, 3, 2) AS2( pmuludq mm5, mm2) AS2( pmuludq mm2, mm3) AS2( pmuludq mm3, mm4) AS2( pxor mm7, mm7) AS2( movd [esp], mm6) AS2( psrlq mm6, 32) AS2( movd [esp+4], mm5) AS2( psrlq mm5, 32) AS2( cmp edi, ebp) ASJ( je, 1, f) ASL(0) AS2( movq mm0, [esi]) AS2( paddq mm0, [edi]) AS2( movq mm1, [esi+8]) AS2( paddq mm1, [edi+8]) AS2( add esi, 16) AS2( add edi, 16) AS2( movq mm4, mm0) AS2( paddq mm5, mm2) ASS( pshufw mm2, mm0, 1, 0, 3, 2) AS2( pmuludq mm0, mm1) AS2( movd [esp+8], mm3) AS2( psrlq mm3, 32) AS2( paddq mm5, mm3) ASS( pshufw mm3, mm1, 1, 0, 3, 2) AS2( pmuludq mm1, mm2) AS2( pmuludq mm2, mm3) AS2( pmuludq mm3, mm4) AS2( movd mm4, [esp]) AS2( paddq mm7, mm4) AS2( movd mm4, [esp+4]) AS2( paddq mm6, mm4) AS2( movd mm4, [esp+8]) AS2( paddq mm6, mm4) AS2( movd [esp], mm0) AS2( psrlq mm0, 32) AS2( paddq mm6, mm0) AS2( movd [esp+4], mm1) AS2( psrlq mm1, 32) AS2( paddq mm5, mm1) AS2( cmp edi, ebp) ASJ( jne, 0, b) ASL(1) AS2( paddq mm5, mm2) AS2( movd [esp+8], mm3) AS2( psrlq mm3, 32) AS2( paddq mm5, mm3) AS2( movd mm4, [esp]) AS2( paddq mm7, mm4) AS2( movd mm4, [esp+4]) AS2( paddq mm6, mm4) AS2( movd mm4, [esp+8]) AS2( paddq mm6, mm4) AS2( lea ebp, [8*ebx]) AS2( sub edi, ebp) // reset edi to start of nhK AS2( movd [esp], mm7) AS2( psrlq mm7, 32) AS2( paddq mm6, mm7) AS2( movd [esp+4], mm6) AS2( psrlq mm6, 32) AS2( paddq mm5, mm6) AS2( psllq mm5, 2) AS2( psrlq mm5, 2) #define a0 [eax+2*4] #define a1 [eax+3*4] #define a2 [eax+0*4] #define a3 [eax+1*4] #define k0 [eax+2*8+2*4] #define k1 [eax+2*8+3*4] #define k2 [eax+2*8+0*4] #define k3 [eax+2*8+1*4] AS2( test dl, dl) ASJ( jz, 2, f) AS2( movd mm1, k0) AS2( movd mm0, [esp]) AS2( paddq mm0, mm1) AS2( movd a0, mm0) AS2( psrlq mm0, 32) AS2( movd mm1, k1) AS2( movd mm2, [esp+4]) AS2( paddq mm1, mm2) AS2( paddq mm0, mm1) AS2( movd a1, mm0) AS2( psrlq mm0, 32) AS2( paddq mm5, k2) AS2( paddq mm0, mm5) AS2( movq a2, mm0) AS2( xor edx, edx) ASJ( jmp, 3, f) ASL(2) AS2( movd mm0, a3) AS2( movq mm4, mm0) AS2( pmuludq mm0, k3) // a3*k3 AS2( movd mm1, a0) AS2( pmuludq mm1, k2) // a0*k2 AS2( movd mm2, a1) AS2( movd mm6, k1) AS2( pmuludq mm2, mm6) // a1*k1 AS2( movd mm3, a2) AS2( psllq mm0, 1) AS2( paddq mm0, mm5) AS2( movq mm5, mm3) AS2( movd mm7, k0) AS2( pmuludq mm3, mm7) // a2*k0 AS2( pmuludq mm4, mm7) // a3*k0 AS2( pmuludq mm5, mm6) // a2*k1 AS2( paddq mm0, mm1) AS2( movd mm1, a1) AS2( paddq mm4, mm5) AS2( movq mm5, mm1) AS2( pmuludq mm1, k2) // a1*k2 AS2( paddq mm0, mm2) AS2( movd mm2, a0) AS2( paddq mm0, mm3) AS2( movq mm3, mm2) AS2( pmuludq mm2, k3) // a0*k3 AS2( pmuludq mm3, mm7) // a0*k0 AS2( movd [esp+8], mm0) AS2( psrlq mm0, 32) AS2( pmuludq mm7, mm5) // a1*k0 AS2( pmuludq mm5, k3) // a1*k3 AS2( paddq mm0, mm1) AS2( movd mm1, a2) AS2( pmuludq mm1, k2) // a2*k2 AS2( paddq mm0, mm2) AS2( paddq mm0, mm4) AS2( movq mm4, mm0) AS2( movd mm2, a3) AS2( pmuludq mm2, mm6) // a3*k1 AS2( pmuludq mm6, a0) // a0*k1 AS2( psrlq mm0, 31) AS2( paddq mm0, mm3) AS2( movd mm3, [esp]) AS2( paddq mm0, mm3) AS2( movd mm3, a2) AS2( pmuludq mm3, k3) // a2*k3 AS2( paddq mm5, mm1) AS2( movd mm1, a3) AS2( pmuludq mm1, k2) // a3*k2 AS2( paddq mm5, mm2) AS2( movd mm2, [esp+4]) AS2( psllq mm5, 1) AS2( paddq mm0, mm5) AS2( psllq mm4, 33) AS2( movd a0, mm0) AS2( psrlq mm0, 32) AS2( paddq mm6, mm7) AS2( movd mm7, [esp+8]) AS2( paddq mm0, mm6) AS2( paddq mm0, mm2) AS2( paddq mm3, mm1) AS2( psllq mm3, 1) AS2( paddq mm0, mm3) AS2( psrlq mm4, 1) AS2( movd a1, mm0) AS2( psrlq mm0, 32) AS2( por mm4, mm7) AS2( paddq mm0, mm4) AS2( movq a2, mm0) #undef a0 #undef a1 #undef a2 #undef a3 #undef k0 #undef k1 #undef k2 #undef k3 ASL(3) AS2( test ecx, ecx) ASJ( jnz, 4, b) AS2( add esp, 12) AS1( pop ebp) AS1( emms) #ifdef __GNUC__ ".att_syntax prefix;" AS2( mov %0, %%ebx) : "=m" (temp) : "m" (L1KeyLength), "c" (blocksRemainingInWord64), "S" (data), "D" (nhK+tagPart*2), "d" (m_isFirstBlock), "a" (polyS+tagPart*4) : "memory", "cc" ); #endif } #endif #if VMAC_BOOL_WORD128 #define DeclareNH(a) word128 a=0 #define MUL64(rh,rl,i1,i2) {word128 p = word128(i1)*(i2); rh = word64(p>>64); rl = word64(p);} #define AccumulateNH(a, b, c) a += word128(b)*(c) #define Multiply128(r, i1, i2) r = word128(word64(i1)) * word64(i2) #else #if _MSC_VER >= 1400 && !defined(__INTEL_COMPILER) #define MUL32(a, b) __emulu(word32(a), word32(b)) #else #define MUL32(a, b) ((word64)((word32)(a)) * (word32)(b)) #endif #if defined(CRYPTOPP_X64_ASM_AVAILABLE) #define DeclareNH(a) word64 a##0=0, a##1=0 #define MUL64(rh,rl,i1,i2) asm ("mulq %3" : "=a"(rl), "=d"(rh) : "a"(i1), "g"(i2) : "cc"); #define AccumulateNH(a, b, c) asm ("mulq %3; addq %%rax, %0; adcq %%rdx, %1" : "+r"(a##0), "+r"(a##1) : "a"(b), "g"(c) : "%rdx", "cc"); #define ADD128(rh,rl,ih,il) asm ("addq %3, %1; adcq %2, %0" : "+r"(rh),"+r"(rl) : "r"(ih),"r"(il) : "cc"); #elif defined(_MSC_VER) && !CRYPTOPP_BOOL_SLOW_WORD64 #define DeclareNH(a) word64 a##0=0, a##1=0 #define MUL64(rh,rl,i1,i2) (rl) = _umul128(i1,i2,&(rh)); #define AccumulateNH(a, b, c) {\ word64 ph, pl;\ pl = _umul128(b,c,&ph);\ a##0 += pl;\ a##1 += ph + (a##0 < pl);} #else #define VMAC_BOOL_32BIT 1 #define DeclareNH(a) word64 a##0=0, a##1=0, a##2=0 #define MUL64(rh,rl,i1,i2) \ { word64 _i1 = (i1), _i2 = (i2); \ word64 m1= MUL32(_i1,_i2>>32); \ word64 m2= MUL32(_i1>>32,_i2); \ rh = MUL32(_i1>>32,_i2>>32); \ rl = MUL32(_i1,_i2); \ ADD128(rh,rl,(m1 >> 32),(m1 << 32)); \ ADD128(rh,rl,(m2 >> 32),(m2 << 32)); \ } #define AccumulateNH(a, b, c) {\ word64 p = MUL32(b, c);\ a##1 += word32((p)>>32);\ a##0 += word32(p);\ p = MUL32((b)>>32, c);\ a##2 += word32((p)>>32);\ a##1 += word32(p);\ p = MUL32((b)>>32, (c)>>32);\ a##2 += p;\ p = MUL32(b, (c)>>32);\ a##1 += word32(p);\ a##2 += word32(p>>32);} #endif #endif #ifndef VMAC_BOOL_32BIT #define VMAC_BOOL_32BIT 0 #endif #ifndef ADD128 #define ADD128(rh,rl,ih,il) \ { word64 _il = (il); \ (rl) += (_il); \ (rh) += (ih) + ((rl) < (_il)); \ } #endif #if !(defined(_MSC_VER) && _MSC_VER < 1300) template <bool T_128BitTag> #endif void VMAC_Base::VHASH_Update_Template(const word64 *data, size_t blocksRemainingInWord64) { #define INNER_LOOP_ITERATION(j) {\ word64 d0 = ConditionalByteReverse(LITTLE_ENDIAN_ORDER, data[i+2*j+0]);\ word64 d1 = ConditionalByteReverse(LITTLE_ENDIAN_ORDER, data[i+2*j+1]);\ AccumulateNH(nhA, d0+nhK[i+2*j+0], d1+nhK[i+2*j+1]);\ if (T_128BitTag)\ AccumulateNH(nhB, d0+nhK[i+2*j+2], d1+nhK[i+2*j+3]);\ } #if (defined(_MSC_VER) && _MSC_VER < 1300) bool T_128BitTag = m_is128; #endif size_t L1KeyLengthInWord64 = m_L1KeyLength / 8; size_t innerLoopEnd = L1KeyLengthInWord64; const word64 *nhK = m_nhKey(); word64 *polyS = m_polyState(); bool isFirstBlock = true; size_t i; #if !VMAC_BOOL_32BIT #if VMAC_BOOL_WORD128 word128 a1, a2; #else word64 ah1, al1, ah2, al2; #endif word64 kh1, kl1, kh2, kl2; kh1=(polyS+0*4+2)[0]; kl1=(polyS+0*4+2)[1]; if (T_128BitTag) { kh2=(polyS+1*4+2)[0]; kl2=(polyS+1*4+2)[1]; } #endif do { DeclareNH(nhA); DeclareNH(nhB); i = 0; if (blocksRemainingInWord64 < L1KeyLengthInWord64) { if (blocksRemainingInWord64 % 8) { innerLoopEnd = blocksRemainingInWord64 % 8; for (; i<innerLoopEnd; i+=2) INNER_LOOP_ITERATION(0); } innerLoopEnd = blocksRemainingInWord64; } for (; i<innerLoopEnd; i+=8) { INNER_LOOP_ITERATION(0); INNER_LOOP_ITERATION(1); INNER_LOOP_ITERATION(2); INNER_LOOP_ITERATION(3); } blocksRemainingInWord64 -= innerLoopEnd; data += innerLoopEnd; #if VMAC_BOOL_32BIT word32 nh0[2], nh1[2]; word64 nh2[2]; nh0[0] = word32(nhA0); nhA1 += (nhA0 >> 32); nh1[0] = word32(nhA1); nh2[0] = (nhA2 + (nhA1 >> 32)) & m62; if (T_128BitTag) { nh0[1] = word32(nhB0); nhB1 += (nhB0 >> 32); nh1[1] = word32(nhB1); nh2[1] = (nhB2 + (nhB1 >> 32)) & m62; } #define a0 (((word32 *)(polyS+i*4))[2+NativeByteOrder::ToEnum()]) #define a1 (*(((word32 *)(polyS+i*4))+3-NativeByteOrder::ToEnum())) // workaround for GCC 3.2 #define a2 (((word32 *)(polyS+i*4))[0+NativeByteOrder::ToEnum()]) #define a3 (*(((word32 *)(polyS+i*4))+1-NativeByteOrder::ToEnum())) #define aHi ((polyS+i*4)[0]) #define k0 (((word32 *)(polyS+i*4+2))[2+NativeByteOrder::ToEnum()]) #define k1 (*(((word32 *)(polyS+i*4+2))+3-NativeByteOrder::ToEnum())) #define k2 (((word32 *)(polyS+i*4+2))[0+NativeByteOrder::ToEnum()]) #define k3 (*(((word32 *)(polyS+i*4+2))+1-NativeByteOrder::ToEnum())) #define kHi ((polyS+i*4+2)[0]) if (isFirstBlock) { isFirstBlock = false; if (m_isFirstBlock) { m_isFirstBlock = false; for (i=0; i<=(size_t)T_128BitTag; i++) { word64 t = (word64)nh0[i] + k0; a0 = (word32)t; t = (t >> 32) + nh1[i] + k1; a1 = (word32)t; aHi = (t >> 32) + nh2[i] + kHi; } continue; } } for (i=0; i<=(size_t)T_128BitTag; i++) { word64 p, t; word32 t2; p = MUL32(a3, 2*k3); p += nh2[i]; p += MUL32(a0, k2); p += MUL32(a1, k1); p += MUL32(a2, k0); t2 = (word32)p; p >>= 32; p += MUL32(a0, k3); p += MUL32(a1, k2); p += MUL32(a2, k1); p += MUL32(a3, k0); t = (word64(word32(p) & 0x7fffffff) << 32) | t2; p >>= 31; p += nh0[i]; p += MUL32(a0, k0); p += MUL32(a1, 2*k3); p += MUL32(a2, 2*k2); p += MUL32(a3, 2*k1); t2 = (word32)p; p >>= 32; p += nh1[i]; p += MUL32(a0, k1); p += MUL32(a1, k0); p += MUL32(a2, 2*k3); p += MUL32(a3, 2*k2); a0 = t2; a1 = (word32)p; aHi = (p >> 32) + t; } #undef a0 #undef a1 #undef a2 #undef a3 #undef aHi #undef k0 #undef k1 #undef k2 #undef k3 #undef kHi #else // #if VMAC_BOOL_32BIT if (isFirstBlock) { isFirstBlock = false; if (m_isFirstBlock) { m_isFirstBlock = false; #if VMAC_BOOL_WORD128 #define first_poly_step(a, kh, kl, m) a = (m & m126) + ((word128(kh) << 64) | kl) first_poly_step(a1, kh1, kl1, nhA); if (T_128BitTag) first_poly_step(a2, kh2, kl2, nhB); #else #define first_poly_step(ah, al, kh, kl, mh, ml) {\ mh &= m62;\ ADD128(mh, ml, kh, kl); \ ah = mh; al = ml;} first_poly_step(ah1, al1, kh1, kl1, nhA1, nhA0); if (T_128BitTag) first_poly_step(ah2, al2, kh2, kl2, nhB1, nhB0); #endif continue; } else { #if VMAC_BOOL_WORD128 a1 = (word128((polyS+0*4)[0]) << 64) | (polyS+0*4)[1]; #else ah1=(polyS+0*4)[0]; al1=(polyS+0*4)[1]; #endif if (T_128BitTag) { #if VMAC_BOOL_WORD128 a2 = (word128((polyS+1*4)[0]) << 64) | (polyS+1*4)[1]; #else ah2=(polyS+1*4)[0]; al2=(polyS+1*4)[1]; #endif } } } #if VMAC_BOOL_WORD128 #define poly_step(a, kh, kl, m) \ { word128 t1, t2, t3, t4;\ Multiply128(t2, a>>64, kl);\ Multiply128(t3, a, kh);\ Multiply128(t1, a, kl);\ Multiply128(t4, a>>64, 2*kh);\ t2 += t3;\ t4 += t1;\ t2 += t4>>64;\ a = (word128(word64(t2)&m63) << 64) | word64(t4);\ t2 *= 2;\ a += m & m126;\ a += t2>>64;} poly_step(a1, kh1, kl1, nhA); if (T_128BitTag) poly_step(a2, kh2, kl2, nhB); #else #define poly_step(ah, al, kh, kl, mh, ml) \ { word64 t1h, t1l, t2h, t2l, t3h, t3l, z=0; \ /* compute ab*cd, put bd into result registers */ \ MUL64(t2h,t2l,ah,kl); \ MUL64(t3h,t3l,al,kh); \ MUL64(t1h,t1l,ah,2*kh); \ MUL64(ah,al,al,kl); \ /* add together ad + bc */ \ ADD128(t2h,t2l,t3h,t3l); \ /* add 2 * ac to result */ \ ADD128(ah,al,t1h,t1l); \ /* now (ah,al), (t2l,2*t2h) need summing */ \ /* first add the high registers, carrying into t2h */ \ ADD128(t2h,ah,z,t2l); \ /* double t2h and add top bit of ah */ \ t2h += t2h + (ah >> 63); \ ah &= m63; \ /* now add the low registers */ \ mh &= m62; \ ADD128(ah,al,mh,ml); \ ADD128(ah,al,z,t2h); \ } poly_step(ah1, al1, kh1, kl1, nhA1, nhA0); if (T_128BitTag) poly_step(ah2, al2, kh2, kl2, nhB1, nhB0); #endif #endif // #if VMAC_BOOL_32BIT } while (blocksRemainingInWord64); #if VMAC_BOOL_WORD128 (polyS+0*4)[0]=word64(a1>>64); (polyS+0*4)[1]=word64(a1); if (T_128BitTag) { (polyS+1*4)[0]=word64(a2>>64); (polyS+1*4)[1]=word64(a2); } #elif !VMAC_BOOL_32BIT (polyS+0*4)[0]=ah1; (polyS+0*4)[1]=al1; if (T_128BitTag) { (polyS+1*4)[0]=ah2; (polyS+1*4)[1]=al2; } #endif } inline void VMAC_Base::VHASH_Update(const word64 *data, size_t blocksRemainingInWord64) { #if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && CRYPTOPP_BOOL_X86 if (HasSSE2()) { VHASH_Update_SSE2(data, blocksRemainingInWord64, 0); if (m_is128) VHASH_Update_SSE2(data, blocksRemainingInWord64, 1); m_isFirstBlock = false; } else #endif { #if defined(_MSC_VER) && _MSC_VER < 1300 VHASH_Update_Template(data, blocksRemainingInWord64); #else if (m_is128) VHASH_Update_Template<true>(data, blocksRemainingInWord64); else VHASH_Update_Template<false>(data, blocksRemainingInWord64); #endif } } size_t VMAC_Base::HashMultipleBlocks(const word64 *data, size_t length) { size_t remaining = ModPowerOf2(length, m_L1KeyLength); VHASH_Update(data, (length-remaining)/8); return remaining; } static word64 L3Hash(const word64 *input, const word64 *l3Key, size_t len) { word64 rh, rl, t, z=0; word64 p1 = input[0], p2 = input[1]; word64 k1 = l3Key[0], k2 = l3Key[1]; /* fully reduce (p1,p2)+(len,0) mod p127 */ t = p1 >> 63; p1 &= m63; ADD128(p1, p2, len, t); /* At this point, (p1,p2) is at most 2^127+(len<<64) */ t = (p1 > m63) + ((p1 == m63) & (p2 == m64)); ADD128(p1, p2, z, t); p1 &= m63; /* compute (p1,p2)/(2^64-2^32) and (p1,p2)%(2^64-2^32) */ t = p1 + (p2 >> 32); t += (t >> 32); t += (word32)t > 0xfffffffeU; p1 += (t >> 32); p2 += (p1 << 32); /* compute (p1+k1)%p64 and (p2+k2)%p64 */ p1 += k1; p1 += (0 - (p1 < k1)) & 257; p2 += k2; p2 += (0 - (p2 < k2)) & 257; /* compute (p1+k1)*(p2+k2)%p64 */ MUL64(rh, rl, p1, p2); t = rh >> 56; ADD128(t, rl, z, rh); rh <<= 8; ADD128(t, rl, z, rh); t += t << 8; rl += t; rl += (0 - (rl < t)) & 257; rl += (0 - (rl > p64-1)) & 257; return rl; } void VMAC_Base::TruncatedFinal(byte *mac, size_t size) { size_t len = ModPowerOf2(GetBitCountLo()/8, m_L1KeyLength); if (len) { memset(m_data()+len, 0, (0-len)%16); VHASH_Update(DataBuf(), ((len+15)/16)*2); len *= 8; // convert to bits } else if (m_isFirstBlock) { // special case for empty string m_polyState()[0] = m_polyState()[2]; m_polyState()[1] = m_polyState()[3]; if (m_is128) { m_polyState()[4] = m_polyState()[6]; m_polyState()[5] = m_polyState()[7]; } } if (m_is128) { word64 t[2]; t[0] = L3Hash(m_polyState(), m_l3Key(), len) + GetWord<word64>(true, BIG_ENDIAN_ORDER, m_pad()); t[1] = L3Hash(m_polyState()+4, m_l3Key()+2, len) + GetWord<word64>(true, BIG_ENDIAN_ORDER, m_pad()+8); if (size == 16) { PutWord(false, BIG_ENDIAN_ORDER, mac, t[0]); PutWord(false, BIG_ENDIAN_ORDER, mac+8, t[1]); } else { t[0] = ConditionalByteReverse(BIG_ENDIAN_ORDER, t[0]); t[1] = ConditionalByteReverse(BIG_ENDIAN_ORDER, t[1]); memcpy(mac, t, size); } } else { word64 t = L3Hash(m_polyState(), m_l3Key(), len); t += GetWord<word64>(true, BIG_ENDIAN_ORDER, m_pad() + (m_nonce()[IVSize()-1]&1) * 8); if (size == 8) PutWord(false, BIG_ENDIAN_ORDER, mac, t); else { t = ConditionalByteReverse(BIG_ENDIAN_ORDER, t); memcpy(mac, &t, size); } } } NAMESPACE_END
[ "Mike.Ken.S@dd569cc8-ff36-11de-bbca-1111db1fd05b", "[email protected]@dd569cc8-ff36-11de-bbca-1111db1fd05b" ]
[ [ [ 1, 10 ], [ 12, 27 ], [ 32, 33 ], [ 35, 59 ], [ 62, 87 ], [ 91, 98 ], [ 100, 100 ], [ 105, 106 ], [ 110, 112 ], [ 119, 120 ], [ 125, 126 ], [ 128, 135 ], [ 137, 148 ], [ 150, 378 ], [ 380, 401 ], [ 403, 488 ], [ 490, 494 ], [ 496, 499 ], [ 501, 832 ] ], [ [ 11, 11 ], [ 28, 31 ], [ 34, 34 ], [ 60, 61 ], [ 88, 90 ], [ 99, 99 ], [ 101, 104 ], [ 107, 109 ], [ 113, 118 ], [ 121, 124 ], [ 127, 127 ], [ 136, 136 ], [ 149, 149 ], [ 379, 379 ], [ 402, 402 ], [ 489, 489 ], [ 495, 495 ], [ 500, 500 ] ] ]
dc68789d5f7432f07107b29c7c808e9b750e0aba
c2d3b2484afb98a6447dfacfe733b98e8778e0a9
/vfpmathlibrary/vfp_clobbers.h
0de05bcff3289ef8e9763200e0708ccbb0e15d52
[]
no_license
soniccat/3dEngine
cfb73af5c9b25d61dd77e882a31f4a62fbd3f036
abf1d49a1756fb0217862f829b1ec7877a59eaf4
refs/heads/master
2020-05-15T07:07:22.751350
2010-03-27T13:05:38
2010-03-27T13:05:38
469,267
3
0
null
null
null
null
UTF-8
C++
false
false
68,256
h
/* VFP math library for the iPhone / iPod touch Copyright (c) 2007-2008 Wolfgang Engel and Matthias Grundmann http://code.google.com/p/vfpmathlibrary/ This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ // VFP registers clobber list specified by intervals [s0, s31] // Header file is created by the following snippet. /* #include <iostream> int main() { int min_reg = 0; int max_reg = 31; for (int i = min_reg; i < max_reg; ++i) { for (int j = i+1; j <= max_reg; ++j) { std::cout << "#define VFP_CLOBBER_S" << i << "_" << "S" << j << " "; for (int k = i; k <= j; ++k) { std::cout << "\"s" << k << "\""; if (k != j) { std::cout << ", "; if (k > i && (k-i) % 8 == 0) { std::cout << " \\\n "; } } } std::cout << "\n"; } } } */ #define VFP_CLOBBER_S0_S1 "s0", "s1" #define VFP_CLOBBER_S0_S2 "s0", "s1", "s2" #define VFP_CLOBBER_S0_S3 "s0", "s1", "s2", "s3" #define VFP_CLOBBER_S0_S4 "s0", "s1", "s2", "s3", "s4" #define VFP_CLOBBER_S0_S5 "s0", "s1", "s2", "s3", "s4", "s5" #define VFP_CLOBBER_S0_S6 "s0", "s1", "s2", "s3", "s4", "s5", "s6" #define VFP_CLOBBER_S0_S7 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7" #define VFP_CLOBBER_S0_S8 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8" #define VFP_CLOBBER_S0_S9 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", \ "s9" #define VFP_CLOBBER_S0_S10 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", \ "s9", "s10" #define VFP_CLOBBER_S0_S11 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", \ "s9", "s10", "s11" #define VFP_CLOBBER_S0_S12 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", \ "s9", "s10", "s11", "s12" #define VFP_CLOBBER_S0_S13 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", \ "s9", "s10", "s11", "s12", "s13" #define VFP_CLOBBER_S0_S14 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", \ "s9", "s10", "s11", "s12", "s13", "s14" #define VFP_CLOBBER_S0_S15 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", \ "s9", "s10", "s11", "s12", "s13", "s14", "s15" #define VFP_CLOBBER_S0_S16 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", \ "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16" #define VFP_CLOBBER_S0_S17 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", \ "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17" #define VFP_CLOBBER_S0_S18 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", \ "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17", "s18" #define VFP_CLOBBER_S0_S19 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", \ "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17", "s18", "s19" #define VFP_CLOBBER_S0_S20 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", \ "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17", "s18", "s19", "s20" #define VFP_CLOBBER_S0_S21 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", \ "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17", "s18", "s19", "s20", "s21" #define VFP_CLOBBER_S0_S22 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", \ "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17", "s18", "s19", "s20", "s21", "s22" #define VFP_CLOBBER_S0_S23 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", \ "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17", "s18", "s19", "s20", "s21", "s22", "s23" #define VFP_CLOBBER_S0_S24 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", \ "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24" #define VFP_CLOBBER_S0_S25 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", \ "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", \ "s25" #define VFP_CLOBBER_S0_S26 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", \ "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", \ "s25", "s26" #define VFP_CLOBBER_S0_S27 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", \ "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", \ "s25", "s26", "s27" #define VFP_CLOBBER_S0_S28 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", \ "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", \ "s25", "s26", "s27", "s28" #define VFP_CLOBBER_S0_S29 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", \ "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", \ "s25", "s26", "s27", "s28", "s29" #define VFP_CLOBBER_S0_S30 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", \ "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", \ "s25", "s26", "s27", "s28", "s29", "s30" #define VFP_CLOBBER_S0_S31 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", \ "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", \ "s25", "s26", "s27", "s28", "s29", "s30", "s31" #define VFP_CLOBBER_S1_S2 "s1", "s2" #define VFP_CLOBBER_S1_S3 "s1", "s2", "s3" #define VFP_CLOBBER_S1_S4 "s1", "s2", "s3", "s4" #define VFP_CLOBBER_S1_S5 "s1", "s2", "s3", "s4", "s5" #define VFP_CLOBBER_S1_S6 "s1", "s2", "s3", "s4", "s5", "s6" #define VFP_CLOBBER_S1_S7 "s1", "s2", "s3", "s4", "s5", "s6", "s7" #define VFP_CLOBBER_S1_S8 "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8" #define VFP_CLOBBER_S1_S9 "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9" #define VFP_CLOBBER_S1_S10 "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", \ "s10" #define VFP_CLOBBER_S1_S11 "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", \ "s10", "s11" #define VFP_CLOBBER_S1_S12 "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", \ "s10", "s11", "s12" #define VFP_CLOBBER_S1_S13 "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", \ "s10", "s11", "s12", "s13" #define VFP_CLOBBER_S1_S14 "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", \ "s10", "s11", "s12", "s13", "s14" #define VFP_CLOBBER_S1_S15 "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", \ "s10", "s11", "s12", "s13", "s14", "s15" #define VFP_CLOBBER_S1_S16 "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", \ "s10", "s11", "s12", "s13", "s14", "s15", "s16" #define VFP_CLOBBER_S1_S17 "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", \ "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17" #define VFP_CLOBBER_S1_S18 "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", \ "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", \ "s18" #define VFP_CLOBBER_S1_S19 "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", \ "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", \ "s18", "s19" #define VFP_CLOBBER_S1_S20 "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", \ "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", \ "s18", "s19", "s20" #define VFP_CLOBBER_S1_S21 "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", \ "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", \ "s18", "s19", "s20", "s21" #define VFP_CLOBBER_S1_S22 "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", \ "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", \ "s18", "s19", "s20", "s21", "s22" #define VFP_CLOBBER_S1_S23 "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", \ "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", \ "s18", "s19", "s20", "s21", "s22", "s23" #define VFP_CLOBBER_S1_S24 "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", \ "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", \ "s18", "s19", "s20", "s21", "s22", "s23", "s24" #define VFP_CLOBBER_S1_S25 "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", \ "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", \ "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25" #define VFP_CLOBBER_S1_S26 "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", \ "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", \ "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25", \ "s26" #define VFP_CLOBBER_S1_S27 "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", \ "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", \ "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25", \ "s26", "s27" #define VFP_CLOBBER_S1_S28 "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", \ "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", \ "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25", \ "s26", "s27", "s28" #define VFP_CLOBBER_S1_S29 "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", \ "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", \ "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25", \ "s26", "s27", "s28", "s29" #define VFP_CLOBBER_S1_S30 "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", \ "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", \ "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25", \ "s26", "s27", "s28", "s29", "s30" #define VFP_CLOBBER_S1_S31 "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", \ "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", \ "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25", \ "s26", "s27", "s28", "s29", "s30", "s31" #define VFP_CLOBBER_S2_S3 "s2", "s3" #define VFP_CLOBBER_S2_S4 "s2", "s3", "s4" #define VFP_CLOBBER_S2_S5 "s2", "s3", "s4", "s5" #define VFP_CLOBBER_S2_S6 "s2", "s3", "s4", "s5", "s6" #define VFP_CLOBBER_S2_S7 "s2", "s3", "s4", "s5", "s6", "s7" #define VFP_CLOBBER_S2_S8 "s2", "s3", "s4", "s5", "s6", "s7", "s8" #define VFP_CLOBBER_S2_S9 "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9" #define VFP_CLOBBER_S2_S10 "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10" #define VFP_CLOBBER_S2_S11 "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", \ "s11" #define VFP_CLOBBER_S2_S12 "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", \ "s11", "s12" #define VFP_CLOBBER_S2_S13 "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", \ "s11", "s12", "s13" #define VFP_CLOBBER_S2_S14 "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", \ "s11", "s12", "s13", "s14" #define VFP_CLOBBER_S2_S15 "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", \ "s11", "s12", "s13", "s14", "s15" #define VFP_CLOBBER_S2_S16 "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", \ "s11", "s12", "s13", "s14", "s15", "s16" #define VFP_CLOBBER_S2_S17 "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", \ "s11", "s12", "s13", "s14", "s15", "s16", "s17" #define VFP_CLOBBER_S2_S18 "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", \ "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18" #define VFP_CLOBBER_S2_S19 "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", \ "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", \ "s19" #define VFP_CLOBBER_S2_S20 "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", \ "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", \ "s19", "s20" #define VFP_CLOBBER_S2_S21 "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", \ "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", \ "s19", "s20", "s21" #define VFP_CLOBBER_S2_S22 "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", \ "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", \ "s19", "s20", "s21", "s22" #define VFP_CLOBBER_S2_S23 "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", \ "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", \ "s19", "s20", "s21", "s22", "s23" #define VFP_CLOBBER_S2_S24 "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", \ "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", \ "s19", "s20", "s21", "s22", "s23", "s24" #define VFP_CLOBBER_S2_S25 "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", \ "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", \ "s19", "s20", "s21", "s22", "s23", "s24", "s25" #define VFP_CLOBBER_S2_S26 "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", \ "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", \ "s19", "s20", "s21", "s22", "s23", "s24", "s25", "s26" #define VFP_CLOBBER_S2_S27 "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", \ "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", \ "s19", "s20", "s21", "s22", "s23", "s24", "s25", "s26", \ "s27" #define VFP_CLOBBER_S2_S28 "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", \ "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", \ "s19", "s20", "s21", "s22", "s23", "s24", "s25", "s26", \ "s27", "s28" #define VFP_CLOBBER_S2_S29 "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", \ "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", \ "s19", "s20", "s21", "s22", "s23", "s24", "s25", "s26", \ "s27", "s28", "s29" #define VFP_CLOBBER_S2_S30 "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", \ "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", \ "s19", "s20", "s21", "s22", "s23", "s24", "s25", "s26", \ "s27", "s28", "s29", "s30" #define VFP_CLOBBER_S2_S31 "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", \ "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", \ "s19", "s20", "s21", "s22", "s23", "s24", "s25", "s26", \ "s27", "s28", "s29", "s30", "s31" #define VFP_CLOBBER_S3_S4 "s3", "s4" #define VFP_CLOBBER_S3_S5 "s3", "s4", "s5" #define VFP_CLOBBER_S3_S6 "s3", "s4", "s5", "s6" #define VFP_CLOBBER_S3_S7 "s3", "s4", "s5", "s6", "s7" #define VFP_CLOBBER_S3_S8 "s3", "s4", "s5", "s6", "s7", "s8" #define VFP_CLOBBER_S3_S9 "s3", "s4", "s5", "s6", "s7", "s8", "s9" #define VFP_CLOBBER_S3_S10 "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10" #define VFP_CLOBBER_S3_S11 "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11" #define VFP_CLOBBER_S3_S12 "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", \ "s12" #define VFP_CLOBBER_S3_S13 "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", \ "s12", "s13" #define VFP_CLOBBER_S3_S14 "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", \ "s12", "s13", "s14" #define VFP_CLOBBER_S3_S15 "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", \ "s12", "s13", "s14", "s15" #define VFP_CLOBBER_S3_S16 "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", \ "s12", "s13", "s14", "s15", "s16" #define VFP_CLOBBER_S3_S17 "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", \ "s12", "s13", "s14", "s15", "s16", "s17" #define VFP_CLOBBER_S3_S18 "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", \ "s12", "s13", "s14", "s15", "s16", "s17", "s18" #define VFP_CLOBBER_S3_S19 "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", \ "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19" #define VFP_CLOBBER_S3_S20 "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", \ "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", \ "s20" #define VFP_CLOBBER_S3_S21 "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", \ "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", \ "s20", "s21" #define VFP_CLOBBER_S3_S22 "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", \ "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", \ "s20", "s21", "s22" #define VFP_CLOBBER_S3_S23 "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", \ "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", \ "s20", "s21", "s22", "s23" #define VFP_CLOBBER_S3_S24 "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", \ "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", \ "s20", "s21", "s22", "s23", "s24" #define VFP_CLOBBER_S3_S25 "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", \ "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", \ "s20", "s21", "s22", "s23", "s24", "s25" #define VFP_CLOBBER_S3_S26 "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", \ "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", \ "s20", "s21", "s22", "s23", "s24", "s25", "s26" #define VFP_CLOBBER_S3_S27 "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", \ "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", \ "s20", "s21", "s22", "s23", "s24", "s25", "s26", "s27" #define VFP_CLOBBER_S3_S28 "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", \ "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", \ "s20", "s21", "s22", "s23", "s24", "s25", "s26", "s27", \ "s28" #define VFP_CLOBBER_S3_S29 "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", \ "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", \ "s20", "s21", "s22", "s23", "s24", "s25", "s26", "s27", \ "s28", "s29" #define VFP_CLOBBER_S3_S30 "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", \ "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", \ "s20", "s21", "s22", "s23", "s24", "s25", "s26", "s27", \ "s28", "s29", "s30" #define VFP_CLOBBER_S3_S31 "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", \ "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", \ "s20", "s21", "s22", "s23", "s24", "s25", "s26", "s27", \ "s28", "s29", "s30", "s31" #define VFP_CLOBBER_S4_S5 "s4", "s5" #define VFP_CLOBBER_S4_S6 "s4", "s5", "s6" #define VFP_CLOBBER_S4_S7 "s4", "s5", "s6", "s7" #define VFP_CLOBBER_S4_S8 "s4", "s5", "s6", "s7", "s8" #define VFP_CLOBBER_S4_S9 "s4", "s5", "s6", "s7", "s8", "s9" #define VFP_CLOBBER_S4_S10 "s4", "s5", "s6", "s7", "s8", "s9", "s10" #define VFP_CLOBBER_S4_S11 "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11" #define VFP_CLOBBER_S4_S12 "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12" #define VFP_CLOBBER_S4_S13 "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", \ "s13" #define VFP_CLOBBER_S4_S14 "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", \ "s13", "s14" #define VFP_CLOBBER_S4_S15 "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", \ "s13", "s14", "s15" #define VFP_CLOBBER_S4_S16 "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", \ "s13", "s14", "s15", "s16" #define VFP_CLOBBER_S4_S17 "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", \ "s13", "s14", "s15", "s16", "s17" #define VFP_CLOBBER_S4_S18 "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", \ "s13", "s14", "s15", "s16", "s17", "s18" #define VFP_CLOBBER_S4_S19 "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", \ "s13", "s14", "s15", "s16", "s17", "s18", "s19" #define VFP_CLOBBER_S4_S20 "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", \ "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20" #define VFP_CLOBBER_S4_S21 "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", \ "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", \ "s21" #define VFP_CLOBBER_S4_S22 "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", \ "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", \ "s21", "s22" #define VFP_CLOBBER_S4_S23 "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", \ "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", \ "s21", "s22", "s23" #define VFP_CLOBBER_S4_S24 "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", \ "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", \ "s21", "s22", "s23", "s24" #define VFP_CLOBBER_S4_S25 "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", \ "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", \ "s21", "s22", "s23", "s24", "s25" #define VFP_CLOBBER_S4_S26 "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", \ "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", \ "s21", "s22", "s23", "s24", "s25", "s26" #define VFP_CLOBBER_S4_S27 "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", \ "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", \ "s21", "s22", "s23", "s24", "s25", "s26", "s27" #define VFP_CLOBBER_S4_S28 "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", \ "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", \ "s21", "s22", "s23", "s24", "s25", "s26", "s27", "s28" #define VFP_CLOBBER_S4_S29 "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", \ "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", \ "s21", "s22", "s23", "s24", "s25", "s26", "s27", "s28", \ "s29" #define VFP_CLOBBER_S4_S30 "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", \ "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", \ "s21", "s22", "s23", "s24", "s25", "s26", "s27", "s28", \ "s29", "s30" #define VFP_CLOBBER_S4_S31 "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", \ "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", \ "s21", "s22", "s23", "s24", "s25", "s26", "s27", "s28", \ "s29", "s30", "s31" #define VFP_CLOBBER_S5_S6 "s5", "s6" #define VFP_CLOBBER_S5_S7 "s5", "s6", "s7" #define VFP_CLOBBER_S5_S8 "s5", "s6", "s7", "s8" #define VFP_CLOBBER_S5_S9 "s5", "s6", "s7", "s8", "s9" #define VFP_CLOBBER_S5_S10 "s5", "s6", "s7", "s8", "s9", "s10" #define VFP_CLOBBER_S5_S11 "s5", "s6", "s7", "s8", "s9", "s10", "s11" #define VFP_CLOBBER_S5_S12 "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12" #define VFP_CLOBBER_S5_S13 "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13" #define VFP_CLOBBER_S5_S14 "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", \ "s14" #define VFP_CLOBBER_S5_S15 "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", \ "s14", "s15" #define VFP_CLOBBER_S5_S16 "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", \ "s14", "s15", "s16" #define VFP_CLOBBER_S5_S17 "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", \ "s14", "s15", "s16", "s17" #define VFP_CLOBBER_S5_S18 "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", \ "s14", "s15", "s16", "s17", "s18" #define VFP_CLOBBER_S5_S19 "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", \ "s14", "s15", "s16", "s17", "s18", "s19" #define VFP_CLOBBER_S5_S20 "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", \ "s14", "s15", "s16", "s17", "s18", "s19", "s20" #define VFP_CLOBBER_S5_S21 "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", \ "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21" #define VFP_CLOBBER_S5_S22 "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", \ "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", \ "s22" #define VFP_CLOBBER_S5_S23 "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", \ "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", \ "s22", "s23" #define VFP_CLOBBER_S5_S24 "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", \ "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", \ "s22", "s23", "s24" #define VFP_CLOBBER_S5_S25 "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", \ "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", \ "s22", "s23", "s24", "s25" #define VFP_CLOBBER_S5_S26 "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", \ "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", \ "s22", "s23", "s24", "s25", "s26" #define VFP_CLOBBER_S5_S27 "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", \ "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", \ "s22", "s23", "s24", "s25", "s26", "s27" #define VFP_CLOBBER_S5_S28 "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", \ "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", \ "s22", "s23", "s24", "s25", "s26", "s27", "s28" #define VFP_CLOBBER_S5_S29 "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", \ "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", \ "s22", "s23", "s24", "s25", "s26", "s27", "s28", "s29" #define VFP_CLOBBER_S5_S30 "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", \ "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", \ "s22", "s23", "s24", "s25", "s26", "s27", "s28", "s29", \ "s30" #define VFP_CLOBBER_S5_S31 "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", \ "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", \ "s22", "s23", "s24", "s25", "s26", "s27", "s28", "s29", \ "s30", "s31" #define VFP_CLOBBER_S6_S7 "s6", "s7" #define VFP_CLOBBER_S6_S8 "s6", "s7", "s8" #define VFP_CLOBBER_S6_S9 "s6", "s7", "s8", "s9" #define VFP_CLOBBER_S6_S10 "s6", "s7", "s8", "s9", "s10" #define VFP_CLOBBER_S6_S11 "s6", "s7", "s8", "s9", "s10", "s11" #define VFP_CLOBBER_S6_S12 "s6", "s7", "s8", "s9", "s10", "s11", "s12" #define VFP_CLOBBER_S6_S13 "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13" #define VFP_CLOBBER_S6_S14 "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14" #define VFP_CLOBBER_S6_S15 "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", \ "s15" #define VFP_CLOBBER_S6_S16 "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", \ "s15", "s16" #define VFP_CLOBBER_S6_S17 "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", \ "s15", "s16", "s17" #define VFP_CLOBBER_S6_S18 "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", \ "s15", "s16", "s17", "s18" #define VFP_CLOBBER_S6_S19 "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", \ "s15", "s16", "s17", "s18", "s19" #define VFP_CLOBBER_S6_S20 "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", \ "s15", "s16", "s17", "s18", "s19", "s20" #define VFP_CLOBBER_S6_S21 "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", \ "s15", "s16", "s17", "s18", "s19", "s20", "s21" #define VFP_CLOBBER_S6_S22 "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", \ "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22" #define VFP_CLOBBER_S6_S23 "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", \ "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22", \ "s23" #define VFP_CLOBBER_S6_S24 "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", \ "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22", \ "s23", "s24" #define VFP_CLOBBER_S6_S25 "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", \ "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22", \ "s23", "s24", "s25" #define VFP_CLOBBER_S6_S26 "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", \ "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22", \ "s23", "s24", "s25", "s26" #define VFP_CLOBBER_S6_S27 "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", \ "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22", \ "s23", "s24", "s25", "s26", "s27" #define VFP_CLOBBER_S6_S28 "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", \ "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22", \ "s23", "s24", "s25", "s26", "s27", "s28" #define VFP_CLOBBER_S6_S29 "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", \ "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22", \ "s23", "s24", "s25", "s26", "s27", "s28", "s29" #define VFP_CLOBBER_S6_S30 "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", \ "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22", \ "s23", "s24", "s25", "s26", "s27", "s28", "s29", "s30" #define VFP_CLOBBER_S6_S31 "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", \ "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22", \ "s23", "s24", "s25", "s26", "s27", "s28", "s29", "s30", \ "s31" #define VFP_CLOBBER_S7_S8 "s7", "s8" #define VFP_CLOBBER_S7_S9 "s7", "s8", "s9" #define VFP_CLOBBER_S7_S10 "s7", "s8", "s9", "s10" #define VFP_CLOBBER_S7_S11 "s7", "s8", "s9", "s10", "s11" #define VFP_CLOBBER_S7_S12 "s7", "s8", "s9", "s10", "s11", "s12" #define VFP_CLOBBER_S7_S13 "s7", "s8", "s9", "s10", "s11", "s12", "s13" #define VFP_CLOBBER_S7_S14 "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14" #define VFP_CLOBBER_S7_S15 "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15" #define VFP_CLOBBER_S7_S16 "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", \ "s16" #define VFP_CLOBBER_S7_S17 "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", \ "s16", "s17" #define VFP_CLOBBER_S7_S18 "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", \ "s16", "s17", "s18" #define VFP_CLOBBER_S7_S19 "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", \ "s16", "s17", "s18", "s19" #define VFP_CLOBBER_S7_S20 "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", \ "s16", "s17", "s18", "s19", "s20" #define VFP_CLOBBER_S7_S21 "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", \ "s16", "s17", "s18", "s19", "s20", "s21" #define VFP_CLOBBER_S7_S22 "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", \ "s16", "s17", "s18", "s19", "s20", "s21", "s22" #define VFP_CLOBBER_S7_S23 "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", \ "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23" #define VFP_CLOBBER_S7_S24 "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", \ "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", \ "s24" #define VFP_CLOBBER_S7_S25 "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", \ "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", \ "s24", "s25" #define VFP_CLOBBER_S7_S26 "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", \ "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", \ "s24", "s25", "s26" #define VFP_CLOBBER_S7_S27 "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", \ "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", \ "s24", "s25", "s26", "s27" #define VFP_CLOBBER_S7_S28 "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", \ "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", \ "s24", "s25", "s26", "s27", "s28" #define VFP_CLOBBER_S7_S29 "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", \ "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", \ "s24", "s25", "s26", "s27", "s28", "s29" #define VFP_CLOBBER_S7_S30 "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", \ "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", \ "s24", "s25", "s26", "s27", "s28", "s29", "s30" #define VFP_CLOBBER_S7_S31 "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", \ "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", \ "s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31" #define VFP_CLOBBER_S8_S9 "s8", "s9" #define VFP_CLOBBER_S8_S10 "s8", "s9", "s10" #define VFP_CLOBBER_S8_S11 "s8", "s9", "s10", "s11" #define VFP_CLOBBER_S8_S12 "s8", "s9", "s10", "s11", "s12" #define VFP_CLOBBER_S8_S13 "s8", "s9", "s10", "s11", "s12", "s13" #define VFP_CLOBBER_S8_S14 "s8", "s9", "s10", "s11", "s12", "s13", "s14" #define VFP_CLOBBER_S8_S15 "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15" #define VFP_CLOBBER_S8_S16 "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16" #define VFP_CLOBBER_S8_S17 "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17" #define VFP_CLOBBER_S8_S18 "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17", "s18" #define VFP_CLOBBER_S8_S19 "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17", "s18", "s19" #define VFP_CLOBBER_S8_S20 "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17", "s18", "s19", "s20" #define VFP_CLOBBER_S8_S21 "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17", "s18", "s19", "s20", "s21" #define VFP_CLOBBER_S8_S22 "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17", "s18", "s19", "s20", "s21", "s22" #define VFP_CLOBBER_S8_S23 "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17", "s18", "s19", "s20", "s21", "s22", "s23" #define VFP_CLOBBER_S8_S24 "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24" #define VFP_CLOBBER_S8_S25 "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", \ "s25" #define VFP_CLOBBER_S8_S26 "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", \ "s25", "s26" #define VFP_CLOBBER_S8_S27 "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", \ "s25", "s26", "s27" #define VFP_CLOBBER_S8_S28 "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", \ "s25", "s26", "s27", "s28" #define VFP_CLOBBER_S8_S29 "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", \ "s25", "s26", "s27", "s28", "s29" #define VFP_CLOBBER_S8_S30 "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", \ "s25", "s26", "s27", "s28", "s29", "s30" #define VFP_CLOBBER_S8_S31 "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \ "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", \ "s25", "s26", "s27", "s28", "s29", "s30", "s31" #define VFP_CLOBBER_S9_S10 "s9", "s10" #define VFP_CLOBBER_S9_S11 "s9", "s10", "s11" #define VFP_CLOBBER_S9_S12 "s9", "s10", "s11", "s12" #define VFP_CLOBBER_S9_S13 "s9", "s10", "s11", "s12", "s13" #define VFP_CLOBBER_S9_S14 "s9", "s10", "s11", "s12", "s13", "s14" #define VFP_CLOBBER_S9_S15 "s9", "s10", "s11", "s12", "s13", "s14", "s15" #define VFP_CLOBBER_S9_S16 "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16" #define VFP_CLOBBER_S9_S17 "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17" #define VFP_CLOBBER_S9_S18 "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", \ "s18" #define VFP_CLOBBER_S9_S19 "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", \ "s18", "s19" #define VFP_CLOBBER_S9_S20 "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", \ "s18", "s19", "s20" #define VFP_CLOBBER_S9_S21 "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", \ "s18", "s19", "s20", "s21" #define VFP_CLOBBER_S9_S22 "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", \ "s18", "s19", "s20", "s21", "s22" #define VFP_CLOBBER_S9_S23 "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", \ "s18", "s19", "s20", "s21", "s22", "s23" #define VFP_CLOBBER_S9_S24 "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", \ "s18", "s19", "s20", "s21", "s22", "s23", "s24" #define VFP_CLOBBER_S9_S25 "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", \ "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25" #define VFP_CLOBBER_S9_S26 "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", \ "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25", \ "s26" #define VFP_CLOBBER_S9_S27 "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", \ "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25", \ "s26", "s27" #define VFP_CLOBBER_S9_S28 "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", \ "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25", \ "s26", "s27", "s28" #define VFP_CLOBBER_S9_S29 "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", \ "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25", \ "s26", "s27", "s28", "s29" #define VFP_CLOBBER_S9_S30 "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", \ "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25", \ "s26", "s27", "s28", "s29", "s30" #define VFP_CLOBBER_S9_S31 "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", \ "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25", \ "s26", "s27", "s28", "s29", "s30", "s31" #define VFP_CLOBBER_S10_S11 "s10", "s11" #define VFP_CLOBBER_S10_S12 "s10", "s11", "s12" #define VFP_CLOBBER_S10_S13 "s10", "s11", "s12", "s13" #define VFP_CLOBBER_S10_S14 "s10", "s11", "s12", "s13", "s14" #define VFP_CLOBBER_S10_S15 "s10", "s11", "s12", "s13", "s14", "s15" #define VFP_CLOBBER_S10_S16 "s10", "s11", "s12", "s13", "s14", "s15", "s16" #define VFP_CLOBBER_S10_S17 "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17" #define VFP_CLOBBER_S10_S18 "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18" #define VFP_CLOBBER_S10_S19 "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", \ "s19" #define VFP_CLOBBER_S10_S20 "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", \ "s19", "s20" #define VFP_CLOBBER_S10_S21 "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", \ "s19", "s20", "s21" #define VFP_CLOBBER_S10_S22 "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", \ "s19", "s20", "s21", "s22" #define VFP_CLOBBER_S10_S23 "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", \ "s19", "s20", "s21", "s22", "s23" #define VFP_CLOBBER_S10_S24 "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", \ "s19", "s20", "s21", "s22", "s23", "s24" #define VFP_CLOBBER_S10_S25 "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", \ "s19", "s20", "s21", "s22", "s23", "s24", "s25" #define VFP_CLOBBER_S10_S26 "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", \ "s19", "s20", "s21", "s22", "s23", "s24", "s25", "s26" #define VFP_CLOBBER_S10_S27 "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", \ "s19", "s20", "s21", "s22", "s23", "s24", "s25", "s26", \ "s27" #define VFP_CLOBBER_S10_S28 "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", \ "s19", "s20", "s21", "s22", "s23", "s24", "s25", "s26", \ "s27", "s28" #define VFP_CLOBBER_S10_S29 "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", \ "s19", "s20", "s21", "s22", "s23", "s24", "s25", "s26", \ "s27", "s28", "s29" #define VFP_CLOBBER_S10_S30 "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", \ "s19", "s20", "s21", "s22", "s23", "s24", "s25", "s26", \ "s27", "s28", "s29", "s30" #define VFP_CLOBBER_S10_S31 "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", \ "s19", "s20", "s21", "s22", "s23", "s24", "s25", "s26", \ "s27", "s28", "s29", "s30", "s31" #define VFP_CLOBBER_S11_S12 "s11", "s12" #define VFP_CLOBBER_S11_S13 "s11", "s12", "s13" #define VFP_CLOBBER_S11_S14 "s11", "s12", "s13", "s14" #define VFP_CLOBBER_S11_S15 "s11", "s12", "s13", "s14", "s15" #define VFP_CLOBBER_S11_S16 "s11", "s12", "s13", "s14", "s15", "s16" #define VFP_CLOBBER_S11_S17 "s11", "s12", "s13", "s14", "s15", "s16", "s17" #define VFP_CLOBBER_S11_S18 "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18" #define VFP_CLOBBER_S11_S19 "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19" #define VFP_CLOBBER_S11_S20 "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", \ "s20" #define VFP_CLOBBER_S11_S21 "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", \ "s20", "s21" #define VFP_CLOBBER_S11_S22 "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", \ "s20", "s21", "s22" #define VFP_CLOBBER_S11_S23 "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", \ "s20", "s21", "s22", "s23" #define VFP_CLOBBER_S11_S24 "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", \ "s20", "s21", "s22", "s23", "s24" #define VFP_CLOBBER_S11_S25 "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", \ "s20", "s21", "s22", "s23", "s24", "s25" #define VFP_CLOBBER_S11_S26 "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", \ "s20", "s21", "s22", "s23", "s24", "s25", "s26" #define VFP_CLOBBER_S11_S27 "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", \ "s20", "s21", "s22", "s23", "s24", "s25", "s26", "s27" #define VFP_CLOBBER_S11_S28 "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", \ "s20", "s21", "s22", "s23", "s24", "s25", "s26", "s27", \ "s28" #define VFP_CLOBBER_S11_S29 "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", \ "s20", "s21", "s22", "s23", "s24", "s25", "s26", "s27", \ "s28", "s29" #define VFP_CLOBBER_S11_S30 "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", \ "s20", "s21", "s22", "s23", "s24", "s25", "s26", "s27", \ "s28", "s29", "s30" #define VFP_CLOBBER_S11_S31 "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", \ "s20", "s21", "s22", "s23", "s24", "s25", "s26", "s27", \ "s28", "s29", "s30", "s31" #define VFP_CLOBBER_S12_S13 "s12", "s13" #define VFP_CLOBBER_S12_S14 "s12", "s13", "s14" #define VFP_CLOBBER_S12_S15 "s12", "s13", "s14", "s15" #define VFP_CLOBBER_S12_S16 "s12", "s13", "s14", "s15", "s16" #define VFP_CLOBBER_S12_S17 "s12", "s13", "s14", "s15", "s16", "s17" #define VFP_CLOBBER_S12_S18 "s12", "s13", "s14", "s15", "s16", "s17", "s18" #define VFP_CLOBBER_S12_S19 "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19" #define VFP_CLOBBER_S12_S20 "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20" #define VFP_CLOBBER_S12_S21 "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", \ "s21" #define VFP_CLOBBER_S12_S22 "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", \ "s21", "s22" #define VFP_CLOBBER_S12_S23 "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", \ "s21", "s22", "s23" #define VFP_CLOBBER_S12_S24 "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", \ "s21", "s22", "s23", "s24" #define VFP_CLOBBER_S12_S25 "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", \ "s21", "s22", "s23", "s24", "s25" #define VFP_CLOBBER_S12_S26 "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", \ "s21", "s22", "s23", "s24", "s25", "s26" #define VFP_CLOBBER_S12_S27 "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", \ "s21", "s22", "s23", "s24", "s25", "s26", "s27" #define VFP_CLOBBER_S12_S28 "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", \ "s21", "s22", "s23", "s24", "s25", "s26", "s27", "s28" #define VFP_CLOBBER_S12_S29 "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", \ "s21", "s22", "s23", "s24", "s25", "s26", "s27", "s28", \ "s29" #define VFP_CLOBBER_S12_S30 "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", \ "s21", "s22", "s23", "s24", "s25", "s26", "s27", "s28", \ "s29", "s30" #define VFP_CLOBBER_S12_S31 "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", \ "s21", "s22", "s23", "s24", "s25", "s26", "s27", "s28", \ "s29", "s30", "s31" #define VFP_CLOBBER_S13_S14 "s13", "s14" #define VFP_CLOBBER_S13_S15 "s13", "s14", "s15" #define VFP_CLOBBER_S13_S16 "s13", "s14", "s15", "s16" #define VFP_CLOBBER_S13_S17 "s13", "s14", "s15", "s16", "s17" #define VFP_CLOBBER_S13_S18 "s13", "s14", "s15", "s16", "s17", "s18" #define VFP_CLOBBER_S13_S19 "s13", "s14", "s15", "s16", "s17", "s18", "s19" #define VFP_CLOBBER_S13_S20 "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20" #define VFP_CLOBBER_S13_S21 "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21" #define VFP_CLOBBER_S13_S22 "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", \ "s22" #define VFP_CLOBBER_S13_S23 "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", \ "s22", "s23" #define VFP_CLOBBER_S13_S24 "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", \ "s22", "s23", "s24" #define VFP_CLOBBER_S13_S25 "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", \ "s22", "s23", "s24", "s25" #define VFP_CLOBBER_S13_S26 "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", \ "s22", "s23", "s24", "s25", "s26" #define VFP_CLOBBER_S13_S27 "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", \ "s22", "s23", "s24", "s25", "s26", "s27" #define VFP_CLOBBER_S13_S28 "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", \ "s22", "s23", "s24", "s25", "s26", "s27", "s28" #define VFP_CLOBBER_S13_S29 "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", \ "s22", "s23", "s24", "s25", "s26", "s27", "s28", "s29" #define VFP_CLOBBER_S13_S30 "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", \ "s22", "s23", "s24", "s25", "s26", "s27", "s28", "s29", \ "s30" #define VFP_CLOBBER_S13_S31 "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", \ "s22", "s23", "s24", "s25", "s26", "s27", "s28", "s29", \ "s30", "s31" #define VFP_CLOBBER_S14_S15 "s14", "s15" #define VFP_CLOBBER_S14_S16 "s14", "s15", "s16" #define VFP_CLOBBER_S14_S17 "s14", "s15", "s16", "s17" #define VFP_CLOBBER_S14_S18 "s14", "s15", "s16", "s17", "s18" #define VFP_CLOBBER_S14_S19 "s14", "s15", "s16", "s17", "s18", "s19" #define VFP_CLOBBER_S14_S20 "s14", "s15", "s16", "s17", "s18", "s19", "s20" #define VFP_CLOBBER_S14_S21 "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21" #define VFP_CLOBBER_S14_S22 "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22" #define VFP_CLOBBER_S14_S23 "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22", \ "s23" #define VFP_CLOBBER_S14_S24 "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22", \ "s23", "s24" #define VFP_CLOBBER_S14_S25 "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22", \ "s23", "s24", "s25" #define VFP_CLOBBER_S14_S26 "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22", \ "s23", "s24", "s25", "s26" #define VFP_CLOBBER_S14_S27 "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22", \ "s23", "s24", "s25", "s26", "s27" #define VFP_CLOBBER_S14_S28 "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22", \ "s23", "s24", "s25", "s26", "s27", "s28" #define VFP_CLOBBER_S14_S29 "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22", \ "s23", "s24", "s25", "s26", "s27", "s28", "s29" #define VFP_CLOBBER_S14_S30 "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22", \ "s23", "s24", "s25", "s26", "s27", "s28", "s29", "s30" #define VFP_CLOBBER_S14_S31 "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22", \ "s23", "s24", "s25", "s26", "s27", "s28", "s29", "s30", \ "s31" #define VFP_CLOBBER_S15_S16 "s15", "s16" #define VFP_CLOBBER_S15_S17 "s15", "s16", "s17" #define VFP_CLOBBER_S15_S18 "s15", "s16", "s17", "s18" #define VFP_CLOBBER_S15_S19 "s15", "s16", "s17", "s18", "s19" #define VFP_CLOBBER_S15_S20 "s15", "s16", "s17", "s18", "s19", "s20" #define VFP_CLOBBER_S15_S21 "s15", "s16", "s17", "s18", "s19", "s20", "s21" #define VFP_CLOBBER_S15_S22 "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22" #define VFP_CLOBBER_S15_S23 "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23" #define VFP_CLOBBER_S15_S24 "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", \ "s24" #define VFP_CLOBBER_S15_S25 "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", \ "s24", "s25" #define VFP_CLOBBER_S15_S26 "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", \ "s24", "s25", "s26" #define VFP_CLOBBER_S15_S27 "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", \ "s24", "s25", "s26", "s27" #define VFP_CLOBBER_S15_S28 "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", \ "s24", "s25", "s26", "s27", "s28" #define VFP_CLOBBER_S15_S29 "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", \ "s24", "s25", "s26", "s27", "s28", "s29" #define VFP_CLOBBER_S15_S30 "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", \ "s24", "s25", "s26", "s27", "s28", "s29", "s30" #define VFP_CLOBBER_S15_S31 "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", \ "s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31" #define VFP_CLOBBER_S16_S17 "s16", "s17" #define VFP_CLOBBER_S16_S18 "s16", "s17", "s18" #define VFP_CLOBBER_S16_S19 "s16", "s17", "s18", "s19" #define VFP_CLOBBER_S16_S20 "s16", "s17", "s18", "s19", "s20" #define VFP_CLOBBER_S16_S21 "s16", "s17", "s18", "s19", "s20", "s21" #define VFP_CLOBBER_S16_S22 "s16", "s17", "s18", "s19", "s20", "s21", "s22" #define VFP_CLOBBER_S16_S23 "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23" #define VFP_CLOBBER_S16_S24 "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24" #define VFP_CLOBBER_S16_S25 "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", \ "s25" #define VFP_CLOBBER_S16_S26 "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", \ "s25", "s26" #define VFP_CLOBBER_S16_S27 "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", \ "s25", "s26", "s27" #define VFP_CLOBBER_S16_S28 "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", \ "s25", "s26", "s27", "s28" #define VFP_CLOBBER_S16_S29 "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", \ "s25", "s26", "s27", "s28", "s29" #define VFP_CLOBBER_S16_S30 "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", \ "s25", "s26", "s27", "s28", "s29", "s30" #define VFP_CLOBBER_S16_S31 "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", \ "s25", "s26", "s27", "s28", "s29", "s30", "s31" #define VFP_CLOBBER_S17_S18 "s17", "s18" #define VFP_CLOBBER_S17_S19 "s17", "s18", "s19" #define VFP_CLOBBER_S17_S20 "s17", "s18", "s19", "s20" #define VFP_CLOBBER_S17_S21 "s17", "s18", "s19", "s20", "s21" #define VFP_CLOBBER_S17_S22 "s17", "s18", "s19", "s20", "s21", "s22" #define VFP_CLOBBER_S17_S23 "s17", "s18", "s19", "s20", "s21", "s22", "s23" #define VFP_CLOBBER_S17_S24 "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24" #define VFP_CLOBBER_S17_S25 "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25" #define VFP_CLOBBER_S17_S26 "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25", \ "s26" #define VFP_CLOBBER_S17_S27 "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25", \ "s26", "s27" #define VFP_CLOBBER_S17_S28 "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25", \ "s26", "s27", "s28" #define VFP_CLOBBER_S17_S29 "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25", \ "s26", "s27", "s28", "s29" #define VFP_CLOBBER_S17_S30 "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25", \ "s26", "s27", "s28", "s29", "s30" #define VFP_CLOBBER_S17_S31 "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25", \ "s26", "s27", "s28", "s29", "s30", "s31" #define VFP_CLOBBER_S18_S19 "s18", "s19" #define VFP_CLOBBER_S18_S20 "s18", "s19", "s20" #define VFP_CLOBBER_S18_S21 "s18", "s19", "s20", "s21" #define VFP_CLOBBER_S18_S22 "s18", "s19", "s20", "s21", "s22" #define VFP_CLOBBER_S18_S23 "s18", "s19", "s20", "s21", "s22", "s23" #define VFP_CLOBBER_S18_S24 "s18", "s19", "s20", "s21", "s22", "s23", "s24" #define VFP_CLOBBER_S18_S25 "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25" #define VFP_CLOBBER_S18_S26 "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25", "s26" #define VFP_CLOBBER_S18_S27 "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25", "s26", \ "s27" #define VFP_CLOBBER_S18_S28 "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25", "s26", \ "s27", "s28" #define VFP_CLOBBER_S18_S29 "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25", "s26", \ "s27", "s28", "s29" #define VFP_CLOBBER_S18_S30 "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25", "s26", \ "s27", "s28", "s29", "s30" #define VFP_CLOBBER_S18_S31 "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25", "s26", \ "s27", "s28", "s29", "s30", "s31" #define VFP_CLOBBER_S19_S20 "s19", "s20" #define VFP_CLOBBER_S19_S21 "s19", "s20", "s21" #define VFP_CLOBBER_S19_S22 "s19", "s20", "s21", "s22" #define VFP_CLOBBER_S19_S23 "s19", "s20", "s21", "s22", "s23" #define VFP_CLOBBER_S19_S24 "s19", "s20", "s21", "s22", "s23", "s24" #define VFP_CLOBBER_S19_S25 "s19", "s20", "s21", "s22", "s23", "s24", "s25" #define VFP_CLOBBER_S19_S26 "s19", "s20", "s21", "s22", "s23", "s24", "s25", "s26" #define VFP_CLOBBER_S19_S27 "s19", "s20", "s21", "s22", "s23", "s24", "s25", "s26", "s27" #define VFP_CLOBBER_S19_S28 "s19", "s20", "s21", "s22", "s23", "s24", "s25", "s26", "s27", \ "s28" #define VFP_CLOBBER_S19_S29 "s19", "s20", "s21", "s22", "s23", "s24", "s25", "s26", "s27", \ "s28", "s29" #define VFP_CLOBBER_S19_S30 "s19", "s20", "s21", "s22", "s23", "s24", "s25", "s26", "s27", \ "s28", "s29", "s30" #define VFP_CLOBBER_S19_S31 "s19", "s20", "s21", "s22", "s23", "s24", "s25", "s26", "s27", \ "s28", "s29", "s30", "s31" #define VFP_CLOBBER_S20_S21 "s20", "s21" #define VFP_CLOBBER_S20_S22 "s20", "s21", "s22" #define VFP_CLOBBER_S20_S23 "s20", "s21", "s22", "s23" #define VFP_CLOBBER_S20_S24 "s20", "s21", "s22", "s23", "s24" #define VFP_CLOBBER_S20_S25 "s20", "s21", "s22", "s23", "s24", "s25" #define VFP_CLOBBER_S20_S26 "s20", "s21", "s22", "s23", "s24", "s25", "s26" #define VFP_CLOBBER_S20_S27 "s20", "s21", "s22", "s23", "s24", "s25", "s26", "s27" #define VFP_CLOBBER_S20_S28 "s20", "s21", "s22", "s23", "s24", "s25", "s26", "s27", "s28" #define VFP_CLOBBER_S20_S29 "s20", "s21", "s22", "s23", "s24", "s25", "s26", "s27", "s28", \ "s29" #define VFP_CLOBBER_S20_S30 "s20", "s21", "s22", "s23", "s24", "s25", "s26", "s27", "s28", \ "s29", "s30" #define VFP_CLOBBER_S20_S31 "s20", "s21", "s22", "s23", "s24", "s25", "s26", "s27", "s28", \ "s29", "s30", "s31" #define VFP_CLOBBER_S21_S22 "s21", "s22" #define VFP_CLOBBER_S21_S23 "s21", "s22", "s23" #define VFP_CLOBBER_S21_S24 "s21", "s22", "s23", "s24" #define VFP_CLOBBER_S21_S25 "s21", "s22", "s23", "s24", "s25" #define VFP_CLOBBER_S21_S26 "s21", "s22", "s23", "s24", "s25", "s26" #define VFP_CLOBBER_S21_S27 "s21", "s22", "s23", "s24", "s25", "s26", "s27" #define VFP_CLOBBER_S21_S28 "s21", "s22", "s23", "s24", "s25", "s26", "s27", "s28" #define VFP_CLOBBER_S21_S29 "s21", "s22", "s23", "s24", "s25", "s26", "s27", "s28", "s29" #define VFP_CLOBBER_S21_S30 "s21", "s22", "s23", "s24", "s25", "s26", "s27", "s28", "s29", \ "s30" #define VFP_CLOBBER_S21_S31 "s21", "s22", "s23", "s24", "s25", "s26", "s27", "s28", "s29", \ "s30", "s31" #define VFP_CLOBBER_S22_S23 "s22", "s23" #define VFP_CLOBBER_S22_S24 "s22", "s23", "s24" #define VFP_CLOBBER_S22_S25 "s22", "s23", "s24", "s25" #define VFP_CLOBBER_S22_S26 "s22", "s23", "s24", "s25", "s26" #define VFP_CLOBBER_S22_S27 "s22", "s23", "s24", "s25", "s26", "s27" #define VFP_CLOBBER_S22_S28 "s22", "s23", "s24", "s25", "s26", "s27", "s28" #define VFP_CLOBBER_S22_S29 "s22", "s23", "s24", "s25", "s26", "s27", "s28", "s29" #define VFP_CLOBBER_S22_S30 "s22", "s23", "s24", "s25", "s26", "s27", "s28", "s29", "s30" #define VFP_CLOBBER_S22_S31 "s22", "s23", "s24", "s25", "s26", "s27", "s28", "s29", "s30", \ "s31" #define VFP_CLOBBER_S23_S24 "s23", "s24" #define VFP_CLOBBER_S23_S25 "s23", "s24", "s25" #define VFP_CLOBBER_S23_S26 "s23", "s24", "s25", "s26" #define VFP_CLOBBER_S23_S27 "s23", "s24", "s25", "s26", "s27" #define VFP_CLOBBER_S23_S28 "s23", "s24", "s25", "s26", "s27", "s28" #define VFP_CLOBBER_S23_S29 "s23", "s24", "s25", "s26", "s27", "s28", "s29" #define VFP_CLOBBER_S23_S30 "s23", "s24", "s25", "s26", "s27", "s28", "s29", "s30" #define VFP_CLOBBER_S23_S31 "s23", "s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31" #define VFP_CLOBBER_S24_S25 "s24", "s25" #define VFP_CLOBBER_S24_S26 "s24", "s25", "s26" #define VFP_CLOBBER_S24_S27 "s24", "s25", "s26", "s27" #define VFP_CLOBBER_S24_S28 "s24", "s25", "s26", "s27", "s28" #define VFP_CLOBBER_S24_S29 "s24", "s25", "s26", "s27", "s28", "s29" #define VFP_CLOBBER_S24_S30 "s24", "s25", "s26", "s27", "s28", "s29", "s30" #define VFP_CLOBBER_S24_S31 "s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31" #define VFP_CLOBBER_S25_S26 "s25", "s26" #define VFP_CLOBBER_S25_S27 "s25", "s26", "s27" #define VFP_CLOBBER_S25_S28 "s25", "s26", "s27", "s28" #define VFP_CLOBBER_S25_S29 "s25", "s26", "s27", "s28", "s29" #define VFP_CLOBBER_S25_S30 "s25", "s26", "s27", "s28", "s29", "s30" #define VFP_CLOBBER_S25_S31 "s25", "s26", "s27", "s28", "s29", "s30", "s31" #define VFP_CLOBBER_S26_S27 "s26", "s27" #define VFP_CLOBBER_S26_S28 "s26", "s27", "s28" #define VFP_CLOBBER_S26_S29 "s26", "s27", "s28", "s29" #define VFP_CLOBBER_S26_S30 "s26", "s27", "s28", "s29", "s30" #define VFP_CLOBBER_S26_S31 "s26", "s27", "s28", "s29", "s30", "s31" #define VFP_CLOBBER_S27_S28 "s27", "s28" #define VFP_CLOBBER_S27_S29 "s27", "s28", "s29" #define VFP_CLOBBER_S27_S30 "s27", "s28", "s29", "s30" #define VFP_CLOBBER_S27_S31 "s27", "s28", "s29", "s30", "s31" #define VFP_CLOBBER_S28_S29 "s28", "s29" #define VFP_CLOBBER_S28_S30 "s28", "s29", "s30" #define VFP_CLOBBER_S28_S31 "s28", "s29", "s30", "s31" #define VFP_CLOBBER_S29_S30 "s29", "s30" #define VFP_CLOBBER_S29_S31 "s29", "s30", "s31" #define VFP_CLOBBER_S30_S31 "s30", "s31"
[ [ [ 1, 975 ] ] ]
2e6570e2849bdb6620d5ab609663840d4f72ba5f
b14d5833a79518a40d302e5eb40ed5da193cf1b2
/cpp/extern/xercesc++/2.6.0/src/xercesc/util/regx/RegxParser.hpp
381414826456d35a2be01dd9d0f2bcb16e8a7b9f
[ "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
10,642
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. */ /* * $Id: RegxParser.hpp,v 1.9 2004/09/08 13:56:47 peiyongz Exp $ */ /* * A regular expression parser */ #if !defined(REGXPARSER_HPP) #define REGXPARSER_HPP // --------------------------------------------------------------------------- // Includes // --------------------------------------------------------------------------- #include <xercesc/util/RefVectorOf.hpp> #include <xercesc/util/XMLUniDefs.hpp> #include <xercesc/util/Mutexes.hpp> XERCES_CPP_NAMESPACE_BEGIN // --------------------------------------------------------------------------- // Forward Declaration // --------------------------------------------------------------------------- class Token; class RangeToken; class TokenFactory; class XMLUTIL_EXPORT RegxParser : public XMemory { public: // ----------------------------------------------------------------------- // Public constant data // ----------------------------------------------------------------------- // Parse tokens enum { REGX_T_CHAR = 0, REGX_T_EOF = 1, REGX_T_OR = 2, REGX_T_STAR = 3, REGX_T_PLUS = 4, REGX_T_QUESTION = 5, REGX_T_LPAREN = 6, REGX_T_RPAREN = 7, REGX_T_DOT = 8, REGX_T_LBRACKET = 9, REGX_T_BACKSOLIDUS = 10, REGX_T_CARET = 11, REGX_T_DOLLAR = 12, REGX_T_LPAREN2 = 13, REGX_T_LOOKAHEAD = 14, REGX_T_NEGATIVELOOKAHEAD = 15, REGX_T_LOOKBEHIND = 16, REGX_T_NEGATIVELOOKBEHIND = 17, REGX_T_INDEPENDENT = 18, REGX_T_SET_OPERATIONS = 19, REGX_T_POSIX_CHARCLASS_START = 20, REGX_T_COMMENT = 21, REGX_T_MODIFIERS = 22, REGX_T_CONDITION = 23, REGX_T_XMLSCHEMA_CC_SUBTRACTION = 24 }; static const unsigned short S_NORMAL; static const unsigned short S_INBRACKETS; static const unsigned short S_INXBRACKETS; // ----------------------------------------------------------------------- // Public Constructors and Destructor // ----------------------------------------------------------------------- RegxParser(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); virtual ~RegxParser(); // ----------------------------------------------------------------------- // Getter methods // ----------------------------------------------------------------------- unsigned short getParseContext() const; unsigned short getState() const; XMLInt32 getCharData() const; int getNoParen() const; int getOffset() const; bool hasBackReferences() const; TokenFactory* getTokenFactory() const; // ----------------------------------------------------------------------- // Setter methods // ----------------------------------------------------------------------- void setParseContext(const unsigned short value); void setTokenFactory(TokenFactory* const tokFactory); // ----------------------------------------------------------------------- // Public Parsing methods // ----------------------------------------------------------------------- Token* parse(const XMLCh* const regxStr, const int options); protected: // ----------------------------------------------------------------------- // Protected Helper methods // ----------------------------------------------------------------------- virtual bool checkQuestion(const int off); virtual XMLInt32 decodeEscaped(); MemoryManager* getMemoryManager() const; // ----------------------------------------------------------------------- // Protected Parsing/Processing methods // ----------------------------------------------------------------------- void processNext(); Token* parseRegx(const bool matchingRParen = false); virtual Token* processCaret(); virtual Token* processDollar(); virtual Token* processLook(const unsigned short tokType); virtual Token* processBacksolidus_A(); virtual Token* processBacksolidus_z(); virtual Token* processBacksolidus_Z(); virtual Token* processBacksolidus_b(); virtual Token* processBacksolidus_B(); virtual Token* processBacksolidus_lt(); virtual Token* processBacksolidus_gt(); virtual Token* processBacksolidus_c(); virtual Token* processBacksolidus_C(); virtual Token* processBacksolidus_i(); virtual Token* processBacksolidus_I(); virtual Token* processBacksolidus_g(); virtual Token* processBacksolidus_X(); virtual Token* processBackReference(); virtual Token* processStar(Token* const tok); virtual Token* processPlus(Token* const tok); virtual Token* processQuestion(Token* const tok); virtual Token* processParen(); virtual Token* processParen2(); virtual Token* processCondition(); virtual Token* processModifiers(); virtual Token* processIndependent(); virtual RangeToken* parseCharacterClass(const bool useNRange); virtual RangeToken* parseSetOperations(); virtual XMLInt32 processCInCharacterClass(RangeToken* const tok, const XMLInt32 ch); RangeToken* processBacksolidus_pP(const XMLInt32 ch); // ----------------------------------------------------------------------- // Protected PreCreated RangeToken access methods // ----------------------------------------------------------------------- virtual Token* getTokenForShorthand(const XMLInt32 ch); private: // ----------------------------------------------------------------------- // Private parsing/processing methods // ----------------------------------------------------------------------- Token* parseTerm(const bool matchingRParen = false); Token* parseFactor(); Token* parseAtom(); // ----------------------------------------------------------------------- // Unimplemented constructors and operators // ----------------------------------------------------------------------- RegxParser(const RegxParser&); RegxParser& operator=(const RegxParser&); // ----------------------------------------------------------------------- // Private data types // ----------------------------------------------------------------------- class ReferencePosition : public XMemory { public : ReferencePosition(const int refNo, const int position); int fReferenceNo; int fPosition; }; // ----------------------------------------------------------------------- // Private Helper methods // ----------------------------------------------------------------------- bool isSet(const int flag); int hexChar(const XMLInt32 ch); // ----------------------------------------------------------------------- // Private data members // ----------------------------------------------------------------------- MemoryManager* fMemoryManager; bool fHasBackReferences; int fOptions; int fOffset; int fNoGroups; unsigned short fParseContext; int fStringLen; unsigned short fState; XMLInt32 fCharData; XMLCh* fString; RefVectorOf<ReferencePosition>* fReferences; TokenFactory* fTokenFactory; XMLMutex fMutex; }; // --------------------------------------------------------------------------- // RegxParser: Getter Methods // --------------------------------------------------------------------------- inline unsigned short RegxParser::getParseContext() const { return fParseContext; } inline unsigned short RegxParser::getState() const { return fState; } inline XMLInt32 RegxParser::getCharData() const { return fCharData; } inline int RegxParser::getNoParen() const { return fNoGroups; } inline int RegxParser::getOffset() const { return fOffset; } inline bool RegxParser::hasBackReferences() const { return fHasBackReferences; } inline TokenFactory* RegxParser::getTokenFactory() const { return fTokenFactory; } inline MemoryManager* RegxParser::getMemoryManager() const { return fMemoryManager; } // --------------------------------------------------------------------------- // RegxParser: Setter Methods // --------------------------------------------------------------------------- inline void RegxParser::setParseContext(const unsigned short value) { fParseContext = value; } inline void RegxParser::setTokenFactory(TokenFactory* const tokFactory) { fTokenFactory = tokFactory; } // --------------------------------------------------------------------------- // RegxParser: Helper Methods // --------------------------------------------------------------------------- inline bool RegxParser::isSet(const int flag) { return (fOptions & flag) == flag; } inline int RegxParser::hexChar(const XMLInt32 ch) { if (ch < chDigit_0 || ch > chLatin_f) return -1; if (ch <= chDigit_9) return ch - chDigit_0; if (ch < chLatin_A) return -1; if (ch <= chLatin_F) return ch - chLatin_A + 10; if (ch < chLatin_a) return -1; return ch - chLatin_a + 10; } XERCES_CPP_NAMESPACE_END #endif /** * End file RegxParser.hpp */
[ [ [ 1, 300 ] ] ]
9a78593ea8aad8833fddab6cbf0c1db47535e3cf
944e19e1a68ac1d4c5f6e7ccde1061a43e791887
/OBBDetection/OBBDetection/old_code/hashTClass.h
5bc856171a66521d17644515cbf2170b7e7952da
[]
no_license
Fredrib/obbdetection
0a797ecac2c24be1a75ddd67fd928e35ddc586f5
41e065c379ddfb7ec0ca4ec0616be5204736b984
refs/heads/master
2020-04-22T14:03:17.358440
2011-01-17T15:24:09
2011-01-17T15:24:09
41,830,450
1
0
null
null
null
null
UTF-8
C++
false
false
1,719
h
#include <iostream> // iostream header: allows input/output functions #include <string.h> // string functions (strcpy, etc) #include <stdio.h> #include <math.h> #include <fstream> #include <cstdlib> #include "../../linked_lists/study_examples/lListClass.h"; #ifndef HASHTCLASS #define HASHTCLASS using namespace std; class hashT { public: // ***** CONSTRUCTORS AND DESTRUCTORS ***** hashT(); hashT(unsigned long size, float max_load); ~hashT(); // ***** REFERENCE AND MODIFIER FUNCTIONS ***** unsigned long getSize(){return size;}; //O(1) float getLoad(){return load_factor;}; //O(1) void addKV(lList * newKV); //O(1+N) N is length of hash bin (hopefully 1 for low load) void rehash(); //O(N) void printHash(unsigned long length = -1); //O(N) void printHashBucket(unsigned long length, unsigned long bucketNo); //O(N) void loadHashTFromFile(string fileName); //>O(N) - Probably need to reballance a few times if size is small lList* findHash(char * key); //O(1) - whoot! unsigned long getTableLength(); //O(N) --> could be order one (load*size) but this is more thorough! // ***** HASH SUB FUNCTIONS ***** --> MAKE PRIVATE AFTER TESTING unsigned long calcHash(char* key); // djb2 --> Very general: Dan Bernstein //O(1) - + overhead // DEBUGGING static unsigned long howManyHashTs; private: // Internal Variables and functions void addKV(lList ** table, lList * newKV, unsigned long size); //Add to a table (not to a hash table class) unsigned long size; lList** table; // Array of pointers to linked-lists! float load_factor; float max_load; }; #endif
[ "jonathantompson@5e2a6976-228a-6e25-3d16-ad1625af6446" ]
[ [ [ 1, 47 ] ] ]
82a0c0e0175d71997d5627e01af56bdfedb6400e
f7b5d803225fa1fdbcc22b69d8cc083691c68f01
/cvaddon_file_io/cvaddon_file_io.h
d7a729090c607e924c5711dbf3389d94d24ce02d
[]
no_license
a40712344/cvaddon
1b3e4b8295eaea3b819598bb7982aa1ba786cb57
e7ebbef09b864b98cce14f0151cef643d2e6bf9d
refs/heads/master
2020-05-20T07:18:49.379088
2008-12-09T03:40:11
2008-12-09T03:40:11
35,675,249
0
0
null
null
null
null
UTF-8
C++
false
false
840
h
#ifndef _CVADDON_FILE_IO_H #define _CVADDON_FILE_IO_H // For saving and loading OpenCV structures to and from files // By Wai Ho Li // // TODO Error checks #include <cxcore.h> #include <cv.h> #include <string> using std::string; inline void cvAddonWriteCvArrXML(const CvArr* src, const char* path, const char* name) { CvFileStorage* fs = cvOpenFileStorage( (string(path) + "/" + string(name)).c_str() , 0, CV_STORAGE_WRITE); cvWrite( fs, "CvArr", src, cvAttrList(0,0) ); cvReleaseFileStorage( &fs ); } inline CvArr* cvAddonReadCvArrXML(const char* path, const char* name) { CvFileStorage* fs = cvOpenFileStorage( (string(path) + "/" + string(name)).c_str(), 0, CV_STORAGE_READ ); CvMat *readMat = (CvMat*)cvReadByName( fs, NULL, "CvArr", NULL); cvReleaseFileStorage( &fs ); return readMat; } #endif
[ "waiho@66626562-0408-11df-adb7-1be7f7e3f636" ]
[ [ [ 1, 30 ] ] ]
a9ab6288d7496ffe5c63d189fbd12bb9ef406fb9
58ef4939342d5253f6fcb372c56513055d589eb8
/ExDoc/Symbian_How_To_Folder/InformationContainer.h
c28c93850370324e66964e0762527368e41dc1cf
[]
no_license
flaithbheartaigh/lemonplayer
2d77869e4cf787acb0aef51341dc784b3cf626ba
ea22bc8679d4431460f714cd3476a32927c7080e
refs/heads/master
2021-01-10T11:29:49.953139
2011-04-25T03:15:18
2011-04-25T03:15:18
50,263,327
0
0
null
null
null
null
UTF-8
C++
false
false
1,550
h
/* ============================================================================ Name : InformationContainer.h Author : zengcity Version : 1.0 Copyright : Your copyright notice Description : CInformationContainer declaration ============================================================================ */ #ifndef INFORMATIONCONTAINER_H #define INFORMATIONCONTAINER_H #include <aknapp.h> #include <eikenv.h> // for CEikonEnv #include <eikmenub.h> // for CEikMenuBar #include <eiksbfrm.h> // for CEikScrollBarFrame class CInformationContainer : public CCoeControl, MCoeControlObserver, MEikScrollBarObserver { public: void ConstructL(const TRect& aRect); ~CInformationContainer(); void setInformationL(const TDesC& info); private: TInt calcLineChar(const TDesC& info, TInt& thisEnd, TInt& nextStart); void SizeChanged(); TInt CountComponentControls() const; CCoeControl* ComponentControl(TInt aIndex) const; void Draw(const TRect& aRect) const; void HandleControlEventL(CCoeControl* aControl, TCoeEvent aEventType); TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType); void HandleScrollEventL(CEikScrollBar* aScrollBar, TEikScrollEvent aEventType); const CFont* iFont; CDesCArray* iInfoArray; CEikScrollBarFrame *iScrollBar; TBool iWordWrap; TUint iBorderWidth; TUint iBorderHeight; TUint iLeftMargin; TUint iRightMargin; TUint iTopMargin; TUint iLineSpace; TInt iDispLines; TUint iTopLine; }; #endif // INFORMATIONCONTAINER_H
[ "zengcity@415e30b0-1e86-11de-9c9a-2d325a3e6494" ]
[ [ [ 1, 51 ] ] ]
bbd7730e6b7c59201afed6f42fd0b3f1f47ed8f6
9aedcc9da750a80a8d12238f24d5825e5f0469e6
/griddata3_MG.h
5a9555a1db3b51d92f51aa982bcd64dd5c751423
[]
no_license
andriybun/g4m-parallel
87c2304bbcee089f603739068bfa5054d5556481
62746076660c9ecff25079b4961c15f521ea9a4d
refs/heads/master
2021-01-25T12:20:36.616586
2009-10-18T19:20:25
2009-10-18T19:20:25
32,204,814
0
0
null
null
null
null
UTF-8
C++
false
false
8,824
h
// Name: GridData class 1.3 + output to file // Author: Andriy Bun // Date: 9.06.2008 #ifndef griddata_h_ #define griddata_h_ #include <iostream> #include <cstdlib> #include <cstring> #include <fstream> using namespace std; class griddata { private: int HorResolution; int VerResolution; int HorNeigh; int VerNeigh; double GridRows[]; double *grid, *gridPrev; public: griddata(int VR, int HR, double val); griddata(); griddata(const griddata& g); ~griddata(); void ShowArray(); // prints array void PrintToFile(string fileName, string rastrType); // print array to file void PrintToFilePrev(string fileName, string rastrType); // print previous year array to file void ShowArrayPrev(); // prints array for the previous year void update(); // updates values for previous year to current values void set(int x, int y, double val); // assigns value val to cell [x][y] void setPrev(int x, int y, double val); // assigns previous year value val to cell [x][y] void inc(int x, int y, double val); // adds value val to the existing value in cell [x][y] double get(int x, int y); // returns value stored in cell [x][y] double getPrev(int x, int y); // returns value for the previous year stored in cell [x][y] void SetNeighNum(int n, int m); // sets number of neighbour cells to be considered double GetMax(int x, int y); // returns maximum value of all neighbours for the previous year double GetMin(int x, int y); // returns minimum value of all neighbours for the previous year double GetAvg(int x, int y); // returns average value for the previous year }; void griddata::ShowArray() { for (int j = 0; j < VerResolution; j++) { cout << j << "|\t"; for (int i = 0; i < HorResolution; i++) { cout << grid[j*HorResolution+i] << "\t"; } cout << endl; } } void griddata::PrintToFile(string fileName, string rastrType = "ESRI") { ofstream f; fileName = "output\\" + fileName + ".txt"; f.open(fileName.c_str(),ios::out); if (f.is_open()) { /////////////////////// Select grid type: if (rastrType == "GRASS"){ f << "cols: " << HorResolution << endl; f << "rows: " << VerResolution << endl; f << "west: -180" << endl; f << "south: -90" << endl; f << "north: 90" << endl; f << "east: 180" << endl; }else if (rastrType == "ESRI"){ //---------------------------- // ESRI ascii Grid f << "NCOLS " << HorResolution << endl; f << "NROWS " << VerResolution << endl; f << "XLLCORNER -180" << endl; f << "YLLCORNER -90" << endl; f << "CELLSIZE " << 360./HorResolution << endl; f << "NODATA_VALUE -9999" << endl; }else {cout<<"griddata3 error message: Specify correct rastrType: ESRI or GRASS"<<endl;} //----------------------------- for (int j = 0; j < VerResolution; j++) { for (int i = 0; i < HorResolution; i++) { f << grid[(VerResolution-j-1)*HorResolution+i] << " "; } f << endl; } f.close(); } else { cout << "Unable to save to file!" << endl; } } void griddata::PrintToFilePrev(string fileName, string rastrType = "ESRI") { ofstream f; fileName = "output\\" + fileName + ".txt"; f.open(fileName.c_str(),ios::out); if (f.is_open()) { /////////////////////// Select grid type: //GRASS ascii Grid if (rastrType == "GRASS"){ f << "cols: " << HorResolution << endl; f << "rows: " << VerResolution << endl; f << "west: -180" << endl; f << "south: -90" << endl; f << "north: 90" << endl; f << "east: 180" << endl; }else if (rastrType == "ESRI"){ //---------------------------- // ESRI ascii Grid f << "NCOLS " << HorResolution << endl; f << "NROWS " << VerResolution << endl; f << "XLLCORNER -180" << endl; f << "YLLCORNER -90" << endl; f << "CELLSIZE " << 360./HorResolution << endl; f << "NODATA_VALUE -9999" << endl; }else {cout<<"griddata3 error message: Specify correct rastrType: ESRI or GRASS"<<endl;} //----------------------------- for (int j = 0; j < VerResolution; j++) { for (int i = 0; i < HorResolution; i++) { f << gridPrev[(VerResolution-j-1)*HorResolution+i] << " "; } f << endl; } f.close(); } else { cout << "Unable to save to file!" << endl; } } void griddata::ShowArrayPrev() { for (int j = 0; j < VerResolution; j++) { cout << j << "|\t"; for (int i = 0; i < HorResolution; i++) { cout << gridPrev[j*HorResolution+i] << "\t"; } cout << endl; } } void griddata::set(int x, int y, double val) { grid[y*HorResolution+x] = val; } void griddata::setPrev(int x, int y, double val) { gridPrev[y*HorResolution+x] = val; } void griddata::inc(int x, int y, double val) { grid[y*HorResolution+x] += val; } double griddata::get(int x, int y) { return (grid[y*HorResolution+x]); } double griddata::getPrev(int x, int y) { return (gridPrev[y*HorResolution+x]); } void griddata::update() { memcpy(gridPrev,grid,VerResolution*HorResolution*sizeof(double)); } void griddata::SetNeighNum(int n, int m) { HorNeigh = n; VerNeigh = m; } double griddata::GetMax(int x, int y) { int tmpx = x - HorNeigh; if (tmpx < 0) tmpx = HorResolution + tmpx; int tmpy = y - VerNeigh; if (tmpy < 0) tmpy = 0; double maxv = gridPrev[tmpy*HorResolution+tmpx]; for (int j = tmpy; j <= y + VerNeigh; j++) { if (j >= VerResolution) break; for (int i = -HorNeigh; i <= HorNeigh; i++) { int ii = x + i; if (ii >= HorResolution) ii -= HorResolution; else if (ii < 0) ii += HorResolution; if ((gridPrev[j*HorResolution+ii] > maxv) && !((ii == x) && (j == y))) maxv = gridPrev[j*HorResolution+ii]; } } return(maxv); } double griddata::GetMin(int x, int y) { int tmpx = x - HorNeigh; if (tmpx < 0) tmpx = HorResolution + tmpx; int tmpy = y - VerNeigh; if (tmpy < 0) tmpy = 0; double minv = gridPrev[tmpy*HorResolution+tmpx]; for (int j = tmpy; j <= y + VerNeigh; j++) { if (j >= VerResolution) break; for (int i = -HorNeigh; i <= HorNeigh; i++) { int ii = x + i; if (ii >= HorResolution) ii -= HorResolution; else if (ii < 0) ii += HorResolution; if ((gridPrev[j*HorResolution+ii] < minv) && !((ii == x) && (j == y))) minv = gridPrev[j*HorResolution+ii]; } } return(minv); } double griddata::GetAvg(int x, int y) { int count = 0; int tmpx = x - HorNeigh; if (tmpx < 0) tmpx = HorResolution + tmpx; int tmpy = y - VerNeigh; if (tmpy < 0) tmpy = 0; double sumv = 0; for (int j = tmpy; j <= y + VerNeigh; j++) { if (j >= VerResolution) break; for (int i = -HorNeigh; i <= HorNeigh; i++) { int ii = x + i; if (ii >= HorResolution) ii -= HorResolution; else if (ii < 0) ii += HorResolution; count++; sumv += gridPrev[j*HorResolution+ii]; } } return(sumv/count); } // Class constructor griddata::griddata(int HR, int VR, double val) { HorResolution = HR; VerResolution = VR; HorNeigh = 1; VerNeigh = 1; grid = new double[HorResolution*VerResolution]; gridPrev = new double[HorResolution*VerResolution]; memset(grid,val,HorResolution*VerResolution*sizeof(double)); memset(gridPrev,val,HorResolution*VerResolution*sizeof(double)); } // Default constructor griddata::griddata() { HorResolution = 720; VerResolution = 360; HorNeigh = 1; VerNeigh = 1; grid = new double[HorResolution*VerResolution]; gridPrev = new double[HorResolution*VerResolution]; memset(grid,0,HorResolution*VerResolution*sizeof(double)); memset(gridPrev,0,HorResolution*VerResolution*sizeof(double)); } // Copy constructor griddata::griddata(const griddata& g) { HorResolution = g.HorResolution; VerResolution = g.VerResolution; HorNeigh = g.HorNeigh; VerNeigh = g.VerNeigh; grid = new double[HorResolution*VerResolution]; gridPrev = new double[HorResolution*VerResolution]; memcpy(grid,g.grid,HorResolution*VerResolution*sizeof(double)); memcpy(gridPrev,g.gridPrev,HorResolution*VerResolution*sizeof(double)); } // Destructor griddata::~griddata() { delete []grid; delete []gridPrev; } #endif
[ "Andr.Bun@efe78254-b83b-11de-a71d-8f2b2e058ad8" ]
[ [ [ 1, 302 ] ] ]
93f54ed89b731a980b01b249dd46483524874703
fac8de123987842827a68da1b580f1361926ab67
/inc/physics/Common/Base/Math/Matrix/hkMatrix4.h
980919ad5ad7c093466a332c7d4fa855060b7743
[]
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
7,222
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-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. * */ #ifndef HK_MATH_MATRIX4_H #define HK_MATH_MATRIX4_H #ifndef HK_MATH_MATH_H # error Please include Common/Base/hkBase.h instead of this file. #endif /// A 4x4 matrix of hkReals. /// This class is only used in our tool chain. /// It is not optimized for runtime use. Use hkTransform instead. /// Internal storage is 16 hkReals in a 4x4 matrix. /// Elements are stored in column major format.<br> /// i.e. contiguous memory locations are (x00, x10, x20, x30), (x01, x11,...) /// where x10 means row 1, column 0 for example. class hkMatrix4 { public: HK_DECLARE_NONVIRTUAL_CLASS_ALLOCATOR(HK_MEMORY_CLASS_MATH, hkMatrix4); /// Empty constructor. The elements of the matrix are not initialized. HK_FORCE_INLINE hkMatrix4() { } /// Gets a read-write reference to the i'th column. HK_FORCE_INLINE hkVector4& getColumn(int i); /// Gets a read-only reference to the i'th column. HK_FORCE_INLINE const hkVector4& getColumn(int i) const; /// Returns a copy of the i'th row. HK_FORCE_INLINE void getRow( int row, hkVector4& r) const; /// Gets read-write access to the specified element. HK_FORCE_INLINE hkReal& operator() (int row, int col); /// Gets read-only access to the specified elements. HK_FORCE_INLINE const hkReal& operator() (int row, int col) const; /// Sets all rows at once. HK_FORCE_INLINE void setRows( const hkVector4& r0, const hkVector4& r1, const hkVector4& r2, const hkVector4& r3); /// Writes the rows 0 to 3 in to the parameters r0, r1, r2, r3 respectively. HK_FORCE_INLINE void getRows( hkVector4& r0, hkVector4& r1, hkVector4& r2, hkVector4& r3) const; /// Sets all columns of the current matrix. Where column is set to r0 and so on. HK_FORCE_INLINE void setCols( const hkVector4& c0, const hkVector4& c1, const hkVector4& c2, const hkVector4& c3); /// Writes the columns 0 to 3 into the parameters c0, c1, c2 and c3 respectively. HK_FORCE_INLINE void getCols( hkVector4& c0, hkVector4& c1, hkVector4& c2, hkVector4& c3) const; /// Zeroes all values in this matrix. HK_FORCE_INLINE void setZero(); /// Sets the specified diagonal values, zeroes the non-diagonal values. HK_FORCE_INLINE void setDiagonal( hkReal m00, hkReal m11, hkReal m22, hkReal m33 = 1.0f ); /// Sets the diagonal values to 1, zeroes the non-diagonal values. HK_FORCE_INLINE void setIdentity(); /// Returns a global identity transform. HK_FORCE_INLINE static const hkMatrix4& HK_CALL getIdentity(); /// Set the contents based on the given hkTransform. Will set the bottom row to (0,0,0,1) in this hkMatrix4 as /// it is undefined in a hkTransform (not used) void set(const hkTransform& t); /// Writes a 4x4 matrix suitable for rendering into p. void get4x4ColumnMajor(hkReal* p) const; /// Reads a 4x4 matrix from p. void set4x4ColumnMajor(const hkReal* p); /// Writes a 4x4 matrix suitable for rendering into p. void get4x4RowMajor(hkReal* p) const; /// Reads a 4x4 matrix from p. void set4x4RowMajor(const hkReal* p); /// Checks if this matrix is equal to m within an optional epsilon. hkBool isApproximatelyEqual( const hkMatrix4& m, hkReal epsilon=1e-3f ) const; /// Inverts the matrix. This function returns HK_SUCCESS if the determinant is greater than epsilon. Otherwise it returns HK_FAILURE and the matrix values are undefined. hkResult invert(hkReal epsilon); /// Transposes this matrix in place. void transpose(); /// set to the transpose of another matrix void setTranspose( const hkMatrix4& s ); /// Set this matrix to be the product of a and b. (this = a * b) void setMul( const hkMatrix4& a, const hkMatrix4& b ); /// Sets this matrix to be the product of a and the inverse of b. (this = a * b^-1) void setMulInverse( const hkMatrix4& a, const hkMatrix4& b ); /// Sets this matrix to be the product of a and scale (this = a * scale) void setMul( hkSimdRealParameter scale, const hkMatrix4& a ); /// Modifies this matrix by adding the matrix a to it. (this += a) void add( const hkMatrix4& a ); /// Modifies this matrix by subtracting the matrix a from it. (this += a) void sub( const hkMatrix4& a ); /// Modifies this matrix by post multiplying it by the matrix a. (this = this*a) void mul( const hkMatrix4& a); /// Modifies this matrix by multiplying by scale (this *= scale) void mul( hkSimdRealParameter scale ); /// Copies all elements from a into this matrix. inline void operator= ( const hkMatrix4& a ); /// Checks for bad values (denormals or infinities) hkBool isOk() const; /// Checks whether the matrix represents a transformation (the 4th row is 0,0,0,1) hkBool32 isTransformation() const; /// Forces the matrix to represent a transformation (resets the 4th row to 0,0,0,1) void resetFourthRow (); /// Transforms a position. It temporarily sets the w component of the vector to 1 and then multiplies by the matrix. /// If the matrix is doesn't represent a transformation, a warning is given. void transformPosition (const hkVector4& positionIn, hkVector4& positionOut) const; /// Transforms a direction. It temporarily sets the w component of the vector to 0 and then multiplies it by the matrix. /// If the matrix is doesn't represent a transformation, a warning is given. void transformDirection (const hkVector4& directionIn, hkVector4& directionOut) const; /// Multiplies a 4-element vector by this matrix4. Notice that the 4th component of the vector (w) is very relevant here. /// Use "transformPosition" or "transformDirection" to transform vectors representing positions or directions by matrices /// representing transformations. void multiplyVector (const hkVector4& vectorIn, hkVector4& resultOut) const; protected: hkVector4 m_col0; hkVector4 m_col1; hkVector4 m_col2; hkVector4 m_col3; }; #endif // HK_MATH_MATRIX4_H /* * 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, 168 ] ] ]
d83fff614a72b92b4a14708d75dce4972639533d
8103a6a032f7b3ec42bbf7a4ad1423e220e769e0
/Prominence/KeyboardController.h
3625a3970647c6b551aa60418dc064973722541e
[]
no_license
wgoddard/2d-opengl-engine
0400bb36c2852ce4f5619f8b5526ba612fda780c
765b422277a309b3d4356df2e58ee8db30d91914
refs/heads/master
2016-08-08T14:28:07.909649
2010-06-17T19:13:12
2010-06-17T19:13:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
533
h
#pragma once #include "InputDevice.h" #include "SDL.h" namespace Prominence { class KeyboardController : public InputDevice { protected: Uint8* keys; public: KeyboardController(void); virtual ~KeyboardController(void); virtual bool GetAKey() = 0; virtual bool GetBKey() = 0; virtual bool GeyXKey() = 0; virtual bool GetYKey() = 0; virtual void GetDirection(int &MagX, int &MagY) = 0; virtual bool GetLKey() = 0; virtual bool GetRKey() = 0; virtual bool GetStart() = 0; }; }
[ "William@18b72257-4ce5-c346-ae33-905a28f88ba6" ]
[ [ [ 1, 27 ] ] ]
4c7036f62fdd466137faa7b32e4f4737c1b3f868
9a5db9951432056bb5cd4cf3c32362a4e17008b7
/FacesCapture/branches/ShangHai/RemoteImaging/FaceProcessingWrapper/FrontFaceChecker.cpp
7a150771034621fb8f5e97e2eeb9d7cfe73d7096
[]
no_license
miaozhendaoren/appcollection
65b0ede264e74e60b68ca74cf70fb24222543278
f8b85af93f787fa897af90e8361569a36ff65d35
refs/heads/master
2021-05-30T19:27:21.142158
2011-06-27T03:49:22
2011-06-27T03:49:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
956
cpp
#pragma once #include "StdAfx.h" #include "..\..\FaceProcessing\FaceProcessing\FrontFaceChecker.h" using namespace System; using namespace System::Runtime::InteropServices; namespace FaceProcessingWrapper { public ref class FrontFaceChecker { public: static FrontFaceChecker^ FromFile(System::String^ templateFile) { return gcnew FaceProcessingWrapper::FrontFaceChecker(templateFile); } bool IsFront( OpenCvSharp::IplImage^ face ) { return this->pChecker->IsFrontFace( (IplImage*) face->CvPtr.ToPointer() ); } private: FrontFaceChecker(System::String^ templateFile) { IntPtr strPtr = Marshal::StringToHGlobalAnsi(templateFile); const char *pTemplate = static_cast<const char*>( strPtr.ToPointer() ); this->pChecker = new frontalFaceDetect(); this->pChecker->LoadEyeTemplate( pTemplate ); Marshal::FreeHGlobal(strPtr); } frontalFaceDetect *pChecker; }; }
[ "shenbinsc@cbf8b9f2-3a65-11de-be05-5f7a86268029" ]
[ [ [ 1, 43 ] ] ]
10fd8fae1f4ccc1e31dcf129ee1060e92012f922
44e10950b3bf454080553a5da36bf263e6a62f8f
/src/SceneNode/Weather/IWeatherManagerAtmosphere.cpp
9e9d58d801fa8a69b918a4d018440c9ce768161e
[]
no_license
ptrefall/ste6246tradingagent
a515d88683bf5f55f862c0b3e539ad6144a260bb
89c8e5667aec4c74aef3ffe47f19eb4a1b17b318
refs/heads/master
2020-05-18T03:50:47.216489
2011-12-20T19:02:32
2011-12-20T19:02:32
32,448,454
1
0
null
null
null
null
UTF-8
C++
false
false
14,046
cpp
// Copyright (C) 2009-2010 Josiah Hartzell (Skyreign Software) // This file is part of the "irrWeatherManager" weather management library for the Irrlicht rendering engine. // For conditions of distribution and use, see copyright notice in irrWeatherManager.h #include "IWeatherManagerAtmosphere.h" using namespace irr; using namespace core; using namespace video; using namespace scene; float round( float d ) { return (float)floor( (double)d + 0.5 ); } IWeatherManagerAtmosphere::IWeatherManagerAtmosphere(irr::IrrlichtDevice* const irrDevice,irr::scene::ISceneNode* const parent, irr::s32 id) { //default values kin=0; ilgis=0; uvX=0.0f; i=0; rad=0.017453292519943295769236907684886f;//degree to radian (PI/180); /* prspalva[0]=0;//tamsi prspalva[1]=128; prspalva[2]=255; pbspalva[0]=128;//sviesi pbspalva[1]=255; pbspalva[2]=255; vspalva[0]=113;//vidurys vspalva[1]=184; vspalva[2]=255;*/ J=DateToJulian(2010,3,26,16,50);//start time dayspeed=60.0f; time_int_step=0.0f;//start sun pos interpolation sun_interpolation_speed=30.0f;//make sun pos interpolation every 30 virtual min J1minute=1.0f/1440.0f;//one minute in Julian time // Start the sky skyid=id; device=irrDevice; driver=device->getVideoDriver(); smgr=device->getSceneManager(); setSkyImage("sky2.tga"); CreateSkyPallete(); startTimer(); setAmbientLight2(SColor(255,255,255,255));//bug fix UpdateFog = false; } void IWeatherManagerAtmosphere::setDate(u32 year, u32 month, u32 day, u32 hour, u32 minute) { J = DateToJulian(year,month,day,hour,minute); } //###rounds angle to fit 360 degrees f32 IWeatherManagerAtmosphere::round360(f32 angle) { if (angle>360) { while (angle>360) { angle-=360; } } return angle; } vector3df IWeatherManagerAtmosphere::getInterpolated3df(vector3df from,vector3df to, f32 d) { f32 inv = 1.0f - d; vector3df rez; rez.X=from.X *inv + to.X*d; rez.Y=from.Y*inv + to.Y*d; rez.Z=from.Z*inv + to.Z*d; return rez; } //prepare sun position interpolation (find start and end positions) void IWeatherManagerAtmosphere::prep_interpolation(f64 Jdate, f64 time)//time-time from 1st sun pos to 2nd { core::matrix4 mat; core::vector3df kampas; saule(52.0f,-5.0f,Jdate);//52.0 -5.0 kaunas 54.54 -23.54 kampas.X=(irr::f32)-sun_angle[1];//heigh kampas.Y=(irr::f32)sun_angle[0];//0.0f;- kampas.Z=0.0f; mat.setRotationDegrees(kampas); f32 vieta[4]; vieta[0]=0.0f; vieta[1]=0.0f; vieta[2]=1000.0f; vieta[3]=0.0f; mat.multiplyWith1x4Matrix(vieta); sun_pos_from.X=vieta[0]; sun_pos_from.Y=vieta[1]; sun_pos_from.Z=vieta[2]; sun_angle_from=sun_angle[1]; saule(52.0f,-5.0f,Jdate+time);//52.0 -5.0 kaunas 54.54 -23.54 kampas.X=(irr::f32)-sun_angle[1];//heigh kampas.Y=(irr::f32)sun_angle[0];//0.0f;- kampas.Z=0.0f; core::matrix4 mat2; mat2.setRotationDegrees(kampas); vieta[0]=0.0f; vieta[1]=0.0f; vieta[2]=1000.0f; vieta[3]=0.0f; sun_angle_to=sun_angle[1]; mat2.multiplyWith1x4Matrix(vieta); sun_pos_to.X=vieta[0]; sun_pos_to.Y=vieta[1]; sun_pos_to.Z=vieta[2]; } //calculate sun position void IWeatherManagerAtmosphere::saule(f64 pl,f64 lw,f64 J) { //lw - longitude //pl - latitude //double J=2453097; f64 M = 357.5291f + 0.98560028*(J - 2451545);//degree M=(irr::f64)round360((irr::f32)M);//degree f64 Mrad=M*rad;//radian f64 C = 1.9148f* sin(Mrad) + 0.02f* sin(2*Mrad) + 0.0003f*sin(3* Mrad);//degree //printf("C %3.4f\n",C); C=(irr::f64)round360((irr::f32)C);//degree //f64 Crad=C*rad;//radian f64 lemda = M + 102.9372f + C + 180.0f;//degree lemda=(irr::f64)round360((irr::f32)lemda);//degree f64 lemdarad=lemda*rad;//radian f64 alfa =lemda - 2.468f *sin(2* lemdarad) + 0.053f* sin(4* lemdarad)-0.0014f *sin(6 *lemdarad);//degree alfa=(irr::f64)round360((irr::f32)alfa);//degree f64 sigma=22.8008f* sin(lemdarad) + 0.5999f* sin(lemdarad)*sin(lemdarad)*sin(lemdarad) + 0.0493f* sin(lemdarad)*sin(lemdarad)*sin(lemdarad)*sin(lemdarad)*sin(lemdarad);//degree sigma=(irr::f64)round360((irr::f32)sigma);//degree f64 sigmarad=sigma*rad;//radian f64 zv=280.16f+360.9856235f*(J-2451545.0f)-lw;//degree zv=(irr::f64)round360((irr::f32)zv);//degree f64 H = zv - alfa;//degree H=(irr::f64)round360((irr::f32)H);//degree f64 Hrad=H*rad;//radian f64 A = atan2(sin(Hrad), cos(Hrad)* sin(pl*rad) - tan(sigmarad)*cos(pl*rad))/rad; f64 h = asin(sin(pl*rad)*sin(sigmarad) + cos(pl*rad)*cos(sigmarad)*cos(Hrad))/rad; //A from 0..180,-180..0 //printf("M %3.4f C %3.4f lemda %3.4f alfa %3.4f sigma %3.4f\n",M,C,lemda,alfa,sigma); //printf("zv %3.4f H %3.4f A %3.4f h %3.15f\n",zv,H,A,h); sun_angle[0]=A; sun_angle[1]=h;//height } void IWeatherManagerAtmosphere::setSkyImage(const char *filename) { skyimage=driver->createImageFromFile(filename); } void IWeatherManagerAtmosphere::CreateSkyPallete() { //Psize-paletes dydis if (dangus!=NULL) { driver->removeTexture(dangus); } dangus=driver->getTexture("../../bin/resources/Sky/sky2.tga"); //stars box ISceneNode* skybox = smgr->addSkyBoxSceneNode( driver->getTexture("../../bin/resources/Sky/stars_top.png"), driver->getTexture("../../bin/resources/Sky/stars_bottom.png"), driver->getTexture("../../bin/resources/Sky/stars.png"), driver->getTexture("../../bin/resources/Sky/stars.png"), driver->getTexture("../../bin/resources/Sky/stars.png"), driver->getTexture("../../bin/resources/Sky/stars.png")); skybox->setMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL); Sky = new IAtmosphereSkySceneNode(dangus,smgr->getRootSceneNode(), smgr,80, skyid); //sun billboard bill=new IAtmosphereStarSceneNode(smgr->getRootSceneNode(),smgr,0, core::vector3df(0,0,0),core::dimension2d<f32>(150,150)); bill->setMaterialFlag(video::EMF_LIGHTING, false); bill->setMaterialTexture(0, driver->getTexture("../../bin/resources/Sky/sun.tga")); bill->getMaterial(0).MaterialTypeParam = 0.01f; bill->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL); Sky->getMaterial(0).MaterialTypeParam = 0.01f; Sky->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL); sunlight = smgr->addLightSceneNode(bill, core::vector3df(0,100,0), video::SColorf(1.0f, 0.6f, 0.7f, 1.0f), 10000.0f); } //###Starts ATMOsphere and prepares for work /*void IWeatherManagerAtmosphere::start(IrrlichtDevice* const irrDevice,scene::ISceneNode* const parent, s32 id) { skyid=id; device=irrDevice; driver=device->getVideoDriver(); smgr=device->getSceneManager(); setSkyImage("sky2.tga"); CreateSkyPallete(); startTimer(); setAmbientLight2(SColor(255,255,255,255));//bug fix }*/ //###starts timer void IWeatherManagerAtmosphere::startTimer() { // Atimer=new ITimer(); Atimer=device->getTimer(); // Atimer->start(); //Atimer->setTime(0); currentTime=(irr::f32)Atimer->getRealTime(); startTime=(irr::f32)Atimer->getRealTime(); dTime=0.0f; J1=J;//force update sun first time ptime=Atimer->getRealTime(); gtime=Atimer->getRealTime(); JulianToDate(J); } //###Calculates delta time (time from last frame) for timer void IWeatherManagerAtmosphere::updateTimer() { currentTime =(irr::f32)Atimer->getRealTime(); dTime=currentTime-startTime; } //###returns sun rotation about y axis f64 IWeatherManagerAtmosphere::getSunXAngle() { return sun_angle[0]*rad;//angle in radians } //###returns sun rotation about x axis (sun height above horizont) f64 IWeatherManagerAtmosphere::getSunYAngle() { return sun_angle[1]*rad;// angle in radians } void IWeatherManagerAtmosphere::setDaysPerDay(f64 days) { dayspeed=days; } f64 IWeatherManagerAtmosphere::getDayspeed() { return dayspeed; } void IWeatherManagerAtmosphere::update() { updateTimer(); SColor sp; J=J+(((double)dayspeed/86400)/1000.0f)*dTime; //if interpolation is finished then start again if(time_int_step==0.0f) { //calculate sun interpolation positions prep_interpolation(J,sun_interpolation_speed*J1minute); JulianToDate(J); counter_time=0.0f; }//1440 //printf("%8.4f %4.8f\n",J,time_int_step); //---move sun billboard to sun place counter_time+=J-J1;//1440 time_int_step=counter_time/(sun_interpolation_speed*J1minute);//(1.0f/(sun_interpolation_speed*(1.0f/1440.0f)))*dTime; vector3df sun_place=getInterpolated3df(sun_pos_from,sun_pos_to, (irr::f32)time_int_step); J1=J; ICameraSceneNode *cam=smgr->getActiveCamera(); core::vector3df cameraPos = cam->getAbsolutePosition(); core::vector3df vt;//billboard position vt.X=sun_place.X+cameraPos.X; vt.Y=sun_place.Y+cameraPos.Y; vt.Z=sun_place.Z+cameraPos.Z; bill->setPosition(vt); vt.X=-sun_place.X+cameraPos.X; vt.Y=-sun_place.Y+cameraPos.Y; vt.Z=-sun_place.Z+cameraPos.Z; bill->setMoonPosition(vt); // sunlight->setPosition(vt); //---sun movement end f32 inv = 1.0f - (irr::f32)time_int_step; uvX=(((irr::f32)sun_angle_from *inv + (irr::f32)sun_angle_to*(irr::f32)time_int_step)+90.0f)/180; if(time_int_step>=1.0f) time_int_step=0.0f; sp=skyimage->getPixel((int)round(128*uvX),117); // Y = 123 //driver->setAmbientLight(SColor(255,sp.getRed(),sp.getGreen(),sp.getBlue())); //printf("vt %3.4f",getSunYAngle()); ClearColor = SColor(255,sp.getRed(),sp.getGreen(),sp.getBlue()); if(UpdateFog) { SColor fogColor; E_FOG_TYPE fogType; f32 fogStart; f32 fogEnd; f32 fogDensity; bool pixelFog; bool rangeFog; driver->getFog(fogColor,fogType,fogStart,fogEnd,fogDensity,pixelFog,rangeFog); driver->setFog(ClearColor,fogType,fogStart,fogEnd,fogDensity,pixelFog,rangeFog); } if (getSunYAngle()<0.0042) {//isjungti lenpa kai naktis sunlight->setVisible(false); setAmbientLight2(SColor(255,sp.getRed(),sp.getGreen(),sp.getBlue())); } else { sunlight->setVisible(true); setAmbientLight2(SColor(255,sp.getRed(),sp.getGreen(),sp.getBlue()));//bug fix } // smgr->setShadowColor(SColor(50,sp.getRed(),sp.getGreen(),sp.getBlue())); //sunlight->getLightData().DiffuseColor=SColor(255,sp.getRed(),sp.getGreen(),sp.getBlue()); Sky->setuvX(uvX); startTime = currentTime; } wchar_t IWeatherManagerAtmosphere::getTextDate() { JulianToDate(J); return 1; } //###Converts normal date tu Julian calendar date f64 IWeatherManagerAtmosphere::DateToJulian(u16 y,u16 m,u16 d,u16 h,u16 min) { //http://www.phys.uu.nl/~strous/AA/en//reken/juliaansedag.html f64 hh=h*60+min; //to minutes f64 dd=d+(hh/1440.0f); printf("dd= %8.8f %8.8f\n",dd,hh); if (m<3) { m=m+12; y=y-1; } f64 c=2-floor(float(y/100))+floor(float(y/400)); f64 dt=floor(float(1461.0f*(y+4716.0f)/4))+floor(float(153*(m+1)/5))+dd+c-1524.5f; return dt; } //###Converts Julian calendar date to normal calendar date void IWeatherManagerAtmosphere::JulianToDate(f64 x) { //http://www.phys.uu.nl/~strous/AA/en//reken/juliaansedag.html f64 p = floor(x + 0.5); f64 s1 = p + 68569; f64 n = floor(4*s1/146097); f64 s2 = s1 - floor((146097*n + 3)/4); f64 i = floor(4000*(s2 + 1)/1461001); f64 s3 = s2 - floor(1461*i/4) + 31; f64 q = floor(80*s3/2447); f64 e = s3 - floor(2447*q/80); f64 s4 = floor(q/11); f64 m = q + 2 - 12*s4; f64 y = 100*(n - 49) + i + s4; f64 d = e + x - p + 0.5; double rr; f64 h = ((modf(d,&rr)*1440)/60); d=floor(d); f64 min=floor(modf(h,&rr)*60); h=floor(h); printf("update time:%4.0f %2.0f %2.0f %2.0f %2.0f\n",y,m,d,h,min); Ndate[0]=(u16)y; Ndate[1]=(u16)m; Ndate[2]=(u16)d; Ndate[3]=(u16)h; Ndate[4]=(u16)min; } void IWeatherManagerAtmosphere::setAmbientLight2(video::SColor color) { io::IFileSystem* files=device->getFileSystem(); io::IAttributes* a = files->createEmptyAttributes(); // get the current attributes scene::ISceneNode* self = smgr->getRootSceneNode(); self->serializeAttributes(a); // set the color attribute a->setAttribute("AmbientLight", color); self->deserializeAttributes(a); // destroy attributes a->drop(); } IWeatherManagerAtmosphere::~IWeatherManagerAtmosphere() { if(bill) bill->remove(); if(Sun) Sun->remove(); if(Sky) Sky->remove(); }
[ "[email protected]@92bc644c-bee7-7203-82ab-e16328aa9dbe" ]
[ [ [ 1, 413 ] ] ]
31b2b4a673741f63aa2d276f713d38f4c82084fa
1e23d293a86830184ff9d59039e4d8f2d2a8f318
/bdf.h
1087840195ecaef39ef91044cab52117193710a1
[]
no_license
beru/bitmap-font-encoder
c95a3e9641119f79cf0c93fd797a41db84685473
1ca6f91c440dc05db4c4ec2ac99a14ffe908209a
refs/heads/master
2016-09-06T17:27:29.748951
2011-08-23T13:21:33
2011-08-23T13:21:33
33,050,307
0
0
null
null
null
null
UTF-8
C++
false
false
741
h
#ifndef BDF_H_INCLUDED__ #define BDF_H_INCLUDED__ #include <string> namespace BDF { struct Header { uint16_t SIZE[3]; int16_t FONTBOUNDINGBOX[4]; std::string CHARSET_REGISTRY; uint16_t CHARS; }; struct CharacterSegment { // uint16_t STARTCHAR; // descriptive name uint16_t ENCODING; // decimal code point // uint8_t SWIDTH; uint8_t DWIDTH; int16_t BBX[4]; // BBw BBh BBox BBoy }; const char* ReadHeader(const char* text, size_t len, Header& header); void ReadCharacterSegments( const char* text, size_t len, const Header& header, CharacterSegment* pSegments, uint8_t* pData ); size_t CalcSegmentMaxDataSize(const Header& header); } // namespace bdf #endif // #ifndef BDF_H_INCLUDED__
[ [ [ 1, 37 ] ] ]
ba1ea0e67aef9709ae160080c4cc1b1659c9df18
7b379862f58f587d9327db829ae4c6493b745bb1
/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Slider.cpp
7d9f26209c32cc6e4ee28d16fccf5f09d7010005
[]
no_license
owenvallis/Nomestate
75e844e8ab68933d481640c12019f0d734c62065
7fe7c06c2893421a3c77b5180e5f27ab61dd0ffd
refs/heads/master
2021-01-19T07:35:14.301832
2011-12-28T07:42:50
2011-12-28T07:42:50
2,950,072
2
0
null
null
null
null
UTF-8
C++
false
false
45,420
cpp
/* ============================================================================== This file is part of the JUCE library - "Jules' Utility Class Extensions" Copyright 2004-11 by Raw Material Software Ltd. ------------------------------------------------------------------------------ JUCE can be redistributed and/or modified under the terms of the GNU General Public License (Version 2), as published by the Free Software Foundation. A copy of the license is included in the JUCE distribution, or can be found online at www.gnu.org/licenses. JUCE 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. ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are available: visit www.rawmaterialsoftware.com/juce for more information. ============================================================================== */ BEGIN_JUCE_NAMESPACE //============================================================================== class Slider::PopupDisplayComponent : public BubbleComponent, public Timer { public: PopupDisplayComponent (Slider& owner_) : owner (owner_), font (15.0f, Font::bold) { setAlwaysOnTop (true); } void paintContent (Graphics& g, int w, int h) { g.setFont (font); g.setColour (findColour (TooltipWindow::textColourId, true)); g.drawFittedText (text, 0, 0, w, h, Justification::centred, 1); } void getContentSize (int& w, int& h) { w = font.getStringWidth (text) + 18; h = (int) (font.getHeight() * 1.6f); } void updatePosition (const String& newText) { text = newText; BubbleComponent::setPosition (&owner); repaint(); } void timerCallback() { owner.popupDisplay = nullptr; } private: Slider& owner; Font font; String text; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PopupDisplayComponent); }; //============================================================================== Slider::Slider (const String& name) : Component (name), lastCurrentValue (0), lastValueMin (0), lastValueMax (0), minimum (0), maximum (10), interval (0), skewFactor (1.0), velocityModeSensitivity (1.0), velocityModeOffset (0.0), velocityModeThreshold (1), rotaryStart (float_Pi * 1.2f), rotaryEnd (float_Pi * 2.8f), numDecimalPlaces (7), sliderRegionStart (0), sliderRegionSize (1), sliderBeingDragged (-1), pixelsForFullDragExtent (250), style (LinearHorizontal), textBoxPos (TextBoxLeft), textBoxWidth (80), textBoxHeight (20), incDecButtonMode (incDecButtonsNotDraggable), editableText (true), doubleClickToValue (false), isVelocityBased (false), userKeyOverridesVelocity (true), rotaryStop (true), incDecButtonsSideBySide (false), sendChangeOnlyOnRelease (false), popupDisplayEnabled (false), menuEnabled (false), menuShown (false), scrollWheelEnabled (true), snapsToMousePos (true), parentForPopupDisplay (nullptr) { setWantsKeyboardFocus (false); setRepaintsOnMouseActivity (true); Slider::lookAndFeelChanged(); updateText(); currentValue.addListener (this); valueMin.addListener (this); valueMax.addListener (this); } Slider::~Slider() { currentValue.removeListener (this); valueMin.removeListener (this); valueMax.removeListener (this); popupDisplay = nullptr; } //============================================================================== void Slider::handleAsyncUpdate() { cancelPendingUpdate(); Component::BailOutChecker checker (this); listeners.callChecked (checker, &SliderListener::sliderValueChanged, this); // (can't use Slider::Listener due to idiotic VC2005 bug) } void Slider::sendDragStart() { startedDragging(); Component::BailOutChecker checker (this); listeners.callChecked (checker, &SliderListener::sliderDragStarted, this); } void Slider::sendDragEnd() { stoppedDragging(); sliderBeingDragged = -1; Component::BailOutChecker checker (this); listeners.callChecked (checker, &SliderListener::sliderDragEnded, this); } void Slider::addListener (SliderListener* const listener) { listeners.add (listener); } void Slider::removeListener (SliderListener* const listener) { listeners.remove (listener); } //============================================================================== void Slider::setSliderStyle (const SliderStyle newStyle) { if (style != newStyle) { style = newStyle; repaint(); lookAndFeelChanged(); } } void Slider::setRotaryParameters (const float startAngleRadians, const float endAngleRadians, const bool stopAtEnd) { // make sure the values are sensible.. jassert (rotaryStart >= 0 && rotaryEnd >= 0); jassert (rotaryStart < float_Pi * 4.0f && rotaryEnd < float_Pi * 4.0f); jassert (rotaryStart < rotaryEnd); rotaryStart = startAngleRadians; rotaryEnd = endAngleRadians; rotaryStop = stopAtEnd; } void Slider::setVelocityBasedMode (const bool velBased) { isVelocityBased = velBased; } void Slider::setVelocityModeParameters (const double sensitivity, const int threshold, const double offset, const bool userCanPressKeyToSwapMode) { jassert (threshold >= 0); jassert (sensitivity > 0); jassert (offset >= 0); velocityModeSensitivity = sensitivity; velocityModeOffset = offset; velocityModeThreshold = threshold; userKeyOverridesVelocity = userCanPressKeyToSwapMode; } void Slider::setSkewFactor (const double factor) { skewFactor = factor; } void Slider::setSkewFactorFromMidPoint (const double sliderValueToShowAtMidPoint) { if (maximum > minimum) skewFactor = log (0.5) / log ((sliderValueToShowAtMidPoint - minimum) / (maximum - minimum)); } void Slider::setMouseDragSensitivity (const int distanceForFullScaleDrag) { jassert (distanceForFullScaleDrag > 0); pixelsForFullDragExtent = distanceForFullScaleDrag; } void Slider::setIncDecButtonsMode (const IncDecButtonMode mode) { if (incDecButtonMode != mode) { incDecButtonMode = mode; lookAndFeelChanged(); } } void Slider::setTextBoxStyle (const TextEntryBoxPosition newPosition, const bool isReadOnly, const int textEntryBoxWidth, const int textEntryBoxHeight) { if (textBoxPos != newPosition || editableText != (! isReadOnly) || textBoxWidth != textEntryBoxWidth || textBoxHeight != textEntryBoxHeight) { textBoxPos = newPosition; editableText = ! isReadOnly; textBoxWidth = textEntryBoxWidth; textBoxHeight = textEntryBoxHeight; repaint(); lookAndFeelChanged(); } } void Slider::setTextBoxIsEditable (const bool shouldBeEditable) { editableText = shouldBeEditable; if (valueBox != nullptr) valueBox->setEditable (shouldBeEditable && isEnabled()); } void Slider::showTextBox() { jassert (editableText); // this should probably be avoided in read-only sliders. if (valueBox != nullptr) valueBox->showEditor(); } void Slider::hideTextBox (const bool discardCurrentEditorContents) { if (valueBox != nullptr) { valueBox->hideEditor (discardCurrentEditorContents); if (discardCurrentEditorContents) updateText(); } } void Slider::setChangeNotificationOnlyOnRelease (const bool onlyNotifyOnRelease) { sendChangeOnlyOnRelease = onlyNotifyOnRelease; } void Slider::setSliderSnapsToMousePosition (const bool shouldSnapToMouse) { snapsToMousePos = shouldSnapToMouse; } void Slider::setPopupDisplayEnabled (const bool enabled, Component* const parentComponentToUse) { popupDisplayEnabled = enabled; parentForPopupDisplay = parentComponentToUse; } Component* Slider::getCurrentPopupDisplay() const noexcept { return popupDisplay.get(); } //============================================================================== void Slider::colourChanged() { lookAndFeelChanged(); } void Slider::lookAndFeelChanged() { LookAndFeel& lf = getLookAndFeel(); if (textBoxPos != NoTextBox) { const String previousTextBoxContent (valueBox != nullptr ? valueBox->getText() : getTextFromValue (currentValue.getValue())); valueBox = nullptr; addAndMakeVisible (valueBox = getLookAndFeel().createSliderTextBox (*this)); valueBox->setWantsKeyboardFocus (false); valueBox->setText (previousTextBoxContent, false); if (valueBox->isEditable() != editableText) // (avoid overriding the single/double click flags unless we have to) valueBox->setEditable (editableText && isEnabled()); valueBox->addListener (this); if (style == LinearBar) valueBox->addMouseListener (this, false); valueBox->setTooltip (getTooltip()); } else { valueBox = nullptr; } if (style == IncDecButtons) { addAndMakeVisible (incButton = lf.createSliderButton (true)); incButton->addListener (this); addAndMakeVisible (decButton = lf.createSliderButton (false)); decButton->addListener (this); if (incDecButtonMode != incDecButtonsNotDraggable) { incButton->addMouseListener (this, false); decButton->addMouseListener (this, false); } else { incButton->setRepeatSpeed (300, 100, 20); incButton->addMouseListener (decButton, false); decButton->setRepeatSpeed (300, 100, 20); decButton->addMouseListener (incButton, false); } incButton->setTooltip (getTooltip()); decButton->setTooltip (getTooltip()); } else { incButton = nullptr; decButton = nullptr; } setComponentEffect (lf.getSliderEffect()); resized(); repaint(); } //============================================================================== void Slider::setRange (const double newMin, const double newMax, const double newInt) { if (minimum != newMin || maximum != newMax || interval != newInt) { minimum = newMin; maximum = newMax; interval = newInt; // figure out the number of DPs needed to display all values at this // interval setting. numDecimalPlaces = 7; if (newInt != 0) { int v = abs ((int) (newInt * 10000000)); while ((v % 10) == 0) { --numDecimalPlaces; v /= 10; } } // keep the current values inside the new range.. if (style != TwoValueHorizontal && style != TwoValueVertical) { setValue (getValue(), false, false); } else { setMinValue (getMinValue(), false, false); setMaxValue (getMaxValue(), false, false); } updateText(); } } void Slider::triggerChangeMessage (const bool synchronous) { if (synchronous) handleAsyncUpdate(); else triggerAsyncUpdate(); valueChanged(); } void Slider::valueChanged (Value& value) { if (value.refersToSameSourceAs (currentValue)) { if (style != TwoValueHorizontal && style != TwoValueVertical) setValue (currentValue.getValue(), false, false); } else if (value.refersToSameSourceAs (valueMin)) setMinValue (valueMin.getValue(), false, false, true); else if (value.refersToSameSourceAs (valueMax)) setMaxValue (valueMax.getValue(), false, false, true); } double Slider::getValue() const { // for a two-value style slider, you should use the getMinValue() and getMaxValue() // methods to get the two values. jassert (style != TwoValueHorizontal && style != TwoValueVertical); return currentValue.getValue(); } void Slider::setValue (double newValue, const bool sendUpdateMessage, const bool sendMessageSynchronously) { // for a two-value style slider, you should use the setMinValue() and setMaxValue() // methods to set the two values. jassert (style != TwoValueHorizontal && style != TwoValueVertical); newValue = constrainedValue (newValue); if (style == ThreeValueHorizontal || style == ThreeValueVertical) { jassert ((double) valueMin.getValue() <= (double) valueMax.getValue()); newValue = jlimit ((double) valueMin.getValue(), (double) valueMax.getValue(), newValue); } if (newValue != lastCurrentValue) { if (valueBox != nullptr) valueBox->hideEditor (true); lastCurrentValue = newValue; // (need to do this comparison because the Value will use equalsWithSameType to compare // the new and old values, so will generate unwanted change events if the type changes) if (currentValue != newValue) currentValue = newValue; updateText(); repaint(); if (popupDisplay != nullptr) popupDisplay->updatePosition (getTextFromValue (newValue)); if (sendUpdateMessage) triggerChangeMessage (sendMessageSynchronously); } } double Slider::getMinValue() const { // The minimum value only applies to sliders that are in two- or three-value mode. jassert (style == TwoValueHorizontal || style == TwoValueVertical || style == ThreeValueHorizontal || style == ThreeValueVertical); return valueMin.getValue(); } double Slider::getMaxValue() const { // The maximum value only applies to sliders that are in two- or three-value mode. jassert (style == TwoValueHorizontal || style == TwoValueVertical || style == ThreeValueHorizontal || style == ThreeValueVertical); return valueMax.getValue(); } void Slider::setMinValue (double newValue, const bool sendUpdateMessage, const bool sendMessageSynchronously, const bool allowNudgingOfOtherValues) { // The minimum value only applies to sliders that are in two- or three-value mode. jassert (style == TwoValueHorizontal || style == TwoValueVertical || style == ThreeValueHorizontal || style == ThreeValueVertical); newValue = constrainedValue (newValue); if (style == TwoValueHorizontal || style == TwoValueVertical) { if (allowNudgingOfOtherValues && newValue > (double) valueMax.getValue()) setMaxValue (newValue, sendUpdateMessage, sendMessageSynchronously); newValue = jmin ((double) valueMax.getValue(), newValue); } else { if (allowNudgingOfOtherValues && newValue > lastCurrentValue) setValue (newValue, sendUpdateMessage, sendMessageSynchronously); newValue = jmin (lastCurrentValue, newValue); } if (lastValueMin != newValue) { lastValueMin = newValue; valueMin = newValue; repaint(); if (popupDisplay != nullptr) popupDisplay->updatePosition (getTextFromValue (newValue)); if (sendUpdateMessage) triggerChangeMessage (sendMessageSynchronously); } } void Slider::setMaxValue (double newValue, const bool sendUpdateMessage, const bool sendMessageSynchronously, const bool allowNudgingOfOtherValues) { // The maximum value only applies to sliders that are in two- or three-value mode. jassert (style == TwoValueHorizontal || style == TwoValueVertical || style == ThreeValueHorizontal || style == ThreeValueVertical); newValue = constrainedValue (newValue); if (style == TwoValueHorizontal || style == TwoValueVertical) { if (allowNudgingOfOtherValues && newValue < (double) valueMin.getValue()) setMinValue (newValue, sendUpdateMessage, sendMessageSynchronously); newValue = jmax ((double) valueMin.getValue(), newValue); } else { if (allowNudgingOfOtherValues && newValue < lastCurrentValue) setValue (newValue, sendUpdateMessage, sendMessageSynchronously); newValue = jmax (lastCurrentValue, newValue); } if (lastValueMax != newValue) { lastValueMax = newValue; valueMax = newValue; repaint(); if (popupDisplay != nullptr) popupDisplay->updatePosition (getTextFromValue (valueMax.getValue())); if (sendUpdateMessage) triggerChangeMessage (sendMessageSynchronously); } } void Slider::setMinAndMaxValues (double newMinValue, double newMaxValue, bool sendUpdateMessage, bool sendMessageSynchronously) { // The maximum value only applies to sliders that are in two- or three-value mode. jassert (style == TwoValueHorizontal || style == TwoValueVertical || style == ThreeValueHorizontal || style == ThreeValueVertical); if (newMaxValue < newMinValue) std::swap (newMaxValue, newMinValue); newMinValue = constrainedValue (newMinValue); newMaxValue = constrainedValue (newMaxValue); if (lastValueMax != newMaxValue || lastValueMin != newMinValue) { lastValueMax = newMaxValue; lastValueMin = newMinValue; valueMin = newMinValue; valueMax = newMaxValue; repaint(); if (sendUpdateMessage) triggerChangeMessage (sendMessageSynchronously); } } void Slider::setDoubleClickReturnValue (const bool isDoubleClickEnabled, const double valueToSetOnDoubleClick) { doubleClickToValue = isDoubleClickEnabled; doubleClickReturnValue = valueToSetOnDoubleClick; } double Slider::getDoubleClickReturnValue (bool& isEnabled_) const { isEnabled_ = doubleClickToValue; return doubleClickReturnValue; } void Slider::updateText() { if (valueBox != nullptr) valueBox->setText (getTextFromValue (currentValue.getValue()), false); } void Slider::setTextValueSuffix (const String& suffix) { if (textSuffix != suffix) { textSuffix = suffix; updateText(); } } String Slider::getTextValueSuffix() const { return textSuffix; } String Slider::getTextFromValue (double v) { if (getNumDecimalPlacesToDisplay() > 0) return String (v, getNumDecimalPlacesToDisplay()) + getTextValueSuffix(); else return String (roundToInt (v)) + getTextValueSuffix(); } double Slider::getValueFromText (const String& text) { String t (text.trimStart()); if (t.endsWith (textSuffix)) t = t.substring (0, t.length() - textSuffix.length()); while (t.startsWithChar ('+')) t = t.substring (1).trimStart(); return t.initialSectionContainingOnly ("0123456789.,-") .getDoubleValue(); } double Slider::proportionOfLengthToValue (double proportion) { if (skewFactor != 1.0 && proportion > 0.0) proportion = exp (log (proportion) / skewFactor); return minimum + (maximum - minimum) * proportion; } double Slider::valueToProportionOfLength (double value) { const double n = (value - minimum) / (maximum - minimum); return skewFactor == 1.0 ? n : pow (n, skewFactor); } double Slider::snapValue (double attemptedValue, const bool) { return attemptedValue; } //============================================================================== void Slider::startedDragging() { } void Slider::stoppedDragging() { } void Slider::valueChanged() { } //============================================================================== void Slider::enablementChanged() { repaint(); } void Slider::setPopupMenuEnabled (const bool menuEnabled_) { menuEnabled = menuEnabled_; } void Slider::setScrollWheelEnabled (const bool enabled) { scrollWheelEnabled = enabled; } //============================================================================== void Slider::labelTextChanged (Label* label) { const double newValue = snapValue (getValueFromText (label->getText()), false); if (newValue != (double) currentValue.getValue()) { sendDragStart(); setValue (newValue, true, true); sendDragEnd(); } updateText(); // force a clean-up of the text, needed in case setValue() hasn't done this. } void Slider::buttonClicked (Button* button) { if (style == IncDecButtons) { sendDragStart(); if (button == incButton) setValue (snapValue (getValue() + interval, false), true, true); else if (button == decButton) setValue (snapValue (getValue() - interval, false), true, true); sendDragEnd(); } } //============================================================================== double Slider::constrainedValue (double value) const { if (interval > 0) value = minimum + interval * std::floor ((value - minimum) / interval + 0.5); if (value <= minimum || maximum <= minimum) value = minimum; else if (value >= maximum) value = maximum; return value; } float Slider::getLinearSliderPos (const double value) { double sliderPosProportional; if (maximum > minimum) { if (value < minimum) { sliderPosProportional = 0.0; } else if (value > maximum) { sliderPosProportional = 1.0; } else { sliderPosProportional = valueToProportionOfLength (value); jassert (sliderPosProportional >= 0 && sliderPosProportional <= 1.0); } } else { sliderPosProportional = 0.5; } if (isVertical() || style == IncDecButtons) sliderPosProportional = 1.0 - sliderPosProportional; return (float) (sliderRegionStart + sliderPosProportional * sliderRegionSize); } bool Slider::isHorizontal() const { return style == LinearHorizontal || style == LinearBar || style == TwoValueHorizontal || style == ThreeValueHorizontal; } bool Slider::isVertical() const { return style == LinearVertical || style == TwoValueVertical || style == ThreeValueVertical; } bool Slider::incDecDragDirectionIsHorizontal() const { return incDecButtonMode == incDecButtonsDraggable_Horizontal || (incDecButtonMode == incDecButtonsDraggable_AutoDirection && incDecButtonsSideBySide); } float Slider::getPositionOfValue (const double value) { if (isHorizontal() || isVertical()) { return getLinearSliderPos (value); } else { jassertfalse; // not a valid call on a slider that doesn't work linearly! return 0.0f; } } //============================================================================== void Slider::paint (Graphics& g) { if (style != IncDecButtons) { if (style == Rotary || style == RotaryHorizontalDrag || style == RotaryVerticalDrag) { const float sliderPos = (float) valueToProportionOfLength (lastCurrentValue); jassert (sliderPos >= 0 && sliderPos <= 1.0f); getLookAndFeel().drawRotarySlider (g, sliderRect.getX(), sliderRect.getY(), sliderRect.getWidth(), sliderRect.getHeight(), sliderPos, rotaryStart, rotaryEnd, *this); } else { getLookAndFeel().drawLinearSlider (g, sliderRect.getX(), sliderRect.getY(), sliderRect.getWidth(), sliderRect.getHeight(), getLinearSliderPos (lastCurrentValue), getLinearSliderPos (lastValueMin), getLinearSliderPos (lastValueMax), style, *this); } if (style == LinearBar && valueBox == nullptr) { g.setColour (findColour (Slider::textBoxOutlineColourId)); g.drawRect (0, 0, getWidth(), getHeight(), 1); } } } void Slider::resized() { int minXSpace = 0; int minYSpace = 0; if (textBoxPos == TextBoxLeft || textBoxPos == TextBoxRight) minXSpace = 30; else minYSpace = 15; const int tbw = jmax (0, jmin (textBoxWidth, getWidth() - minXSpace)); const int tbh = jmax (0, jmin (textBoxHeight, getHeight() - minYSpace)); if (style == LinearBar) { if (valueBox != nullptr) valueBox->setBounds (getLocalBounds()); } else { if (textBoxPos == NoTextBox) { sliderRect = getLocalBounds(); } else if (textBoxPos == TextBoxLeft) { valueBox->setBounds (0, (getHeight() - tbh) / 2, tbw, tbh); sliderRect.setBounds (tbw, 0, getWidth() - tbw, getHeight()); } else if (textBoxPos == TextBoxRight) { valueBox->setBounds (getWidth() - tbw, (getHeight() - tbh) / 2, tbw, tbh); sliderRect.setBounds (0, 0, getWidth() - tbw, getHeight()); } else if (textBoxPos == TextBoxAbove) { valueBox->setBounds ((getWidth() - tbw) / 2, 0, tbw, tbh); sliderRect.setBounds (0, tbh, getWidth(), getHeight() - tbh); } else if (textBoxPos == TextBoxBelow) { valueBox->setBounds ((getWidth() - tbw) / 2, getHeight() - tbh, tbw, tbh); sliderRect.setBounds (0, 0, getWidth(), getHeight() - tbh); } } const int indent = getLookAndFeel().getSliderThumbRadius (*this); if (style == LinearBar) { const int barIndent = 1; sliderRegionStart = barIndent; sliderRegionSize = getWidth() - barIndent * 2; sliderRect.setBounds (sliderRegionStart, barIndent, sliderRegionSize, getHeight() - barIndent * 2); } else if (isHorizontal()) { sliderRegionStart = sliderRect.getX() + indent; sliderRegionSize = jmax (1, sliderRect.getWidth() - indent * 2); sliderRect.setBounds (sliderRegionStart, sliderRect.getY(), sliderRegionSize, sliderRect.getHeight()); } else if (isVertical()) { sliderRegionStart = sliderRect.getY() + indent; sliderRegionSize = jmax (1, sliderRect.getHeight() - indent * 2); sliderRect.setBounds (sliderRect.getX(), sliderRegionStart, sliderRect.getWidth(), sliderRegionSize); } else { sliderRegionStart = 0; sliderRegionSize = 100; } if (style == IncDecButtons) { Rectangle<int> buttonRect (sliderRect); if (textBoxPos == TextBoxLeft || textBoxPos == TextBoxRight) buttonRect.expand (-2, 0); else buttonRect.expand (0, -2); incDecButtonsSideBySide = buttonRect.getWidth() > buttonRect.getHeight(); if (incDecButtonsSideBySide) { decButton->setBounds (buttonRect.removeFromLeft (buttonRect.getWidth() / 2)); decButton->setConnectedEdges (Button::ConnectedOnRight); incButton->setConnectedEdges (Button::ConnectedOnLeft); } else { decButton->setBounds (buttonRect.removeFromBottom (buttonRect.getHeight() / 2)); decButton->setConnectedEdges (Button::ConnectedOnTop); incButton->setConnectedEdges (Button::ConnectedOnBottom); } incButton->setBounds (buttonRect); } } void Slider::focusOfChildComponentChanged (FocusChangeType) { repaint(); } namespace SliderHelpers { double smallestAngleBetween (double a1, double a2) noexcept { return jmin (std::abs (a1 - a2), std::abs (a1 + double_Pi * 2.0 - a2), std::abs (a2 + double_Pi * 2.0 - a1)); } void sliderMenuCallback (int result, Slider* slider) { if (slider != nullptr) { switch (result) { case 1: slider->setVelocityBasedMode (! slider->getVelocityBasedMode()); break; case 2: slider->setSliderStyle (Slider::Rotary); break; case 3: slider->setSliderStyle (Slider::RotaryHorizontalDrag); break; case 4: slider->setSliderStyle (Slider::RotaryVerticalDrag); break; default: break; } } } } void Slider::showPopupMenu() { menuShown = true; PopupMenu m; m.setLookAndFeel (&getLookAndFeel()); m.addItem (1, TRANS ("velocity-sensitive mode"), true, isVelocityBased); m.addSeparator(); if (style == Rotary || style == RotaryHorizontalDrag || style == RotaryVerticalDrag) { PopupMenu rotaryMenu; rotaryMenu.addItem (2, TRANS ("use circular dragging"), true, style == Rotary); rotaryMenu.addItem (3, TRANS ("use left-right dragging"), true, style == RotaryHorizontalDrag); rotaryMenu.addItem (4, TRANS ("use up-down dragging"), true, style == RotaryVerticalDrag); m.addSubMenu (TRANS ("rotary mode"), rotaryMenu); } m.showMenuAsync (PopupMenu::Options(), ModalCallbackFunction::forComponent (SliderHelpers::sliderMenuCallback, this)); } int Slider::getThumbIndexAt (const MouseEvent& e) { const bool isTwoValue = (style == TwoValueHorizontal || style == TwoValueVertical); const bool isThreeValue = (style == ThreeValueHorizontal || style == ThreeValueVertical); if (isTwoValue || isThreeValue) { const float mousePos = (float) (isVertical() ? e.y : e.x); const float normalPosDistance = std::abs (getLinearSliderPos (currentValue.getValue()) - mousePos); const float minPosDistance = std::abs (getLinearSliderPos (valueMin.getValue()) - 0.1f - mousePos); const float maxPosDistance = std::abs (getLinearSliderPos (valueMax.getValue()) + 0.1f - mousePos); if (isTwoValue) return maxPosDistance <= minPosDistance ? 2 : 1; if (normalPosDistance >= minPosDistance && maxPosDistance >= minPosDistance) return 1; else if (normalPosDistance >= maxPosDistance) return 2; } return 0; } void Slider::mouseDown (const MouseEvent& e) { mouseWasHidden = false; incDecDragged = false; mouseDragStartPos = mousePosWhenLastDragged = e.getPosition(); if (isEnabled()) { if (e.mods.isPopupMenu() && menuEnabled) { showPopupMenu(); } else if (maximum > minimum) { menuShown = false; if (valueBox != nullptr) valueBox->hideEditor (true); sliderBeingDragged = getThumbIndexAt (e); minMaxDiff = (double) valueMax.getValue() - (double) valueMin.getValue(); lastAngle = rotaryStart + (rotaryEnd - rotaryStart) * valueToProportionOfLength (currentValue.getValue()); valueWhenLastDragged = (sliderBeingDragged == 2 ? valueMax : (sliderBeingDragged == 1 ? valueMin : currentValue)).getValue(); valueOnMouseDown = valueWhenLastDragged; if (popupDisplayEnabled) { PopupDisplayComponent* const popup = new PopupDisplayComponent (*this); popupDisplay = popup; if (parentForPopupDisplay != nullptr) parentForPopupDisplay->addChildComponent (popup); else popup->addToDesktop (0); popup->setVisible (true); } sendDragStart(); mouseDrag (e); } } } void Slider::mouseUp (const MouseEvent&) { if (isEnabled() && (! menuShown) && (maximum > minimum) && (style != IncDecButtons || incDecDragged)) { restoreMouseIfHidden(); if (sendChangeOnlyOnRelease && valueOnMouseDown != (double) currentValue.getValue()) triggerChangeMessage (false); sendDragEnd(); popupDisplay = nullptr; if (style == IncDecButtons) { incButton->setState (Button::buttonNormal); decButton->setState (Button::buttonNormal); } } else if (popupDisplay != nullptr) { popupDisplay->startTimer (2000); } } void Slider::restoreMouseIfHidden() { if (mouseWasHidden) { mouseWasHidden = false; for (int i = Desktop::getInstance().getNumMouseSources(); --i >= 0;) Desktop::getInstance().getMouseSource(i)->enableUnboundedMouseMovement (false); const double pos = sliderBeingDragged == 2 ? getMaxValue() : (sliderBeingDragged == 1 ? getMinValue() : (double) currentValue.getValue()); Point<int> mousePos; if (style == RotaryHorizontalDrag || style == RotaryVerticalDrag) { mousePos = Desktop::getLastMouseDownPosition(); if (style == RotaryHorizontalDrag) { const double posDiff = valueToProportionOfLength (pos) - valueToProportionOfLength (valueOnMouseDown); mousePos += Point<int> (roundToInt (pixelsForFullDragExtent * posDiff), 0); } else { const double posDiff = valueToProportionOfLength (valueOnMouseDown) - valueToProportionOfLength (pos); mousePos += Point<int> (0, roundToInt (pixelsForFullDragExtent * posDiff)); } } else { const int pixelPos = (int) getLinearSliderPos (pos); mousePos = localPointToGlobal (Point<int> (isHorizontal() ? pixelPos : (getWidth() / 2), isVertical() ? pixelPos : (getHeight() / 2))); } Desktop::setMousePosition (mousePos); } } void Slider::modifierKeysChanged (const ModifierKeys& modifiers) { if (isEnabled() && style != IncDecButtons && style != Rotary && isVelocityBased == modifiers.isAnyModifierKeyDown()) { restoreMouseIfHidden(); } } void Slider::handleRotaryDrag (const MouseEvent& e) { const int dx = e.x - sliderRect.getCentreX(); const int dy = e.y - sliderRect.getCentreY(); if (dx * dx + dy * dy > 25) { double angle = std::atan2 ((double) dx, (double) -dy); while (angle < 0.0) angle += double_Pi * 2.0; if (rotaryStop && ! e.mouseWasClicked()) { if (std::abs (angle - lastAngle) > double_Pi) { if (angle >= lastAngle) angle -= double_Pi * 2.0; else angle += double_Pi * 2.0; } if (angle >= lastAngle) angle = jmin (angle, (double) jmax (rotaryStart, rotaryEnd)); else angle = jmax (angle, (double) jmin (rotaryStart, rotaryEnd)); } else { while (angle < rotaryStart) angle += double_Pi * 2.0; if (angle > rotaryEnd) { if (SliderHelpers::smallestAngleBetween (angle, rotaryStart) <= SliderHelpers::smallestAngleBetween (angle, rotaryEnd)) angle = rotaryStart; else angle = rotaryEnd; } } const double proportion = (angle - rotaryStart) / (rotaryEnd - rotaryStart); valueWhenLastDragged = proportionOfLengthToValue (jlimit (0.0, 1.0, proportion)); lastAngle = angle; } } void Slider::handleAbsoluteDrag (const MouseEvent& e) { const int mousePos = (isHorizontal() || style == RotaryHorizontalDrag) ? e.x : e.y; double scaledMousePos = (mousePos - sliderRegionStart) / (double) sliderRegionSize; if (style == RotaryHorizontalDrag || style == RotaryVerticalDrag || style == IncDecButtons || ((style == LinearHorizontal || style == LinearVertical || style == LinearBar) && ! snapsToMousePos)) { const int mouseDiff = (style == RotaryHorizontalDrag || style == LinearHorizontal || style == LinearBar || (style == IncDecButtons && incDecDragDirectionIsHorizontal())) ? e.x - mouseDragStartPos.x : mouseDragStartPos.y - e.y; double newPos = valueToProportionOfLength (valueOnMouseDown) + mouseDiff * (1.0 / pixelsForFullDragExtent); valueWhenLastDragged = proportionOfLengthToValue (jlimit (0.0, 1.0, newPos)); if (style == IncDecButtons) { incButton->setState (mouseDiff < 0 ? Button::buttonNormal : Button::buttonDown); decButton->setState (mouseDiff > 0 ? Button::buttonNormal : Button::buttonDown); } } else { if (isVertical()) scaledMousePos = 1.0 - scaledMousePos; valueWhenLastDragged = proportionOfLengthToValue (jlimit (0.0, 1.0, scaledMousePos)); } } void Slider::handleVelocityDrag (const MouseEvent& e) { const int mouseDiff = (isHorizontal() || style == RotaryHorizontalDrag || (style == IncDecButtons && incDecDragDirectionIsHorizontal())) ? e.x - mousePosWhenLastDragged.x : e.y - mousePosWhenLastDragged.y; const double maxSpeed = jmax (200, sliderRegionSize); double speed = jlimit (0.0, maxSpeed, (double) abs (mouseDiff)); if (speed != 0) { speed = 0.2 * velocityModeSensitivity * (1.0 + std::sin (double_Pi * (1.5 + jmin (0.5, velocityModeOffset + jmax (0.0, (double) (speed - velocityModeThreshold)) / maxSpeed)))); if (mouseDiff < 0) speed = -speed; if (isVertical() || style == RotaryVerticalDrag || (style == IncDecButtons && ! incDecDragDirectionIsHorizontal())) speed = -speed; const double currentPos = valueToProportionOfLength (valueWhenLastDragged); valueWhenLastDragged = proportionOfLengthToValue (jlimit (0.0, 1.0, currentPos + speed)); e.source.enableUnboundedMouseMovement (true, false); mouseWasHidden = true; } } void Slider::mouseDrag (const MouseEvent& e) { if (isEnabled() && (! menuShown) && (maximum > minimum) && ! (style == LinearBar && e.mouseWasClicked() && valueBox != nullptr && valueBox->isEditable())) { if (style == Rotary) { handleRotaryDrag (e); } else { if (style == IncDecButtons && ! incDecDragged) { if (e.getDistanceFromDragStart() < 10 || e.mouseWasClicked()) return; incDecDragged = true; mouseDragStartPos = e.getPosition(); } if (isVelocityBased == (userKeyOverridesVelocity && e.mods.testFlags (ModifierKeys::ctrlModifier | ModifierKeys::commandModifier | ModifierKeys::altModifier)) || (maximum - minimum) / sliderRegionSize < interval) handleAbsoluteDrag (e); else handleVelocityDrag (e); } valueWhenLastDragged = jlimit (minimum, maximum, valueWhenLastDragged); if (sliderBeingDragged == 0) { setValue (snapValue (valueWhenLastDragged, true), ! sendChangeOnlyOnRelease, true); } else if (sliderBeingDragged == 1) { setMinValue (snapValue (valueWhenLastDragged, true), ! sendChangeOnlyOnRelease, false, true); if (e.mods.isShiftDown()) setMaxValue (getMinValue() + minMaxDiff, false, false, true); else minMaxDiff = (double) valueMax.getValue() - (double) valueMin.getValue(); } else if (sliderBeingDragged == 2) { setMaxValue (snapValue (valueWhenLastDragged, true), ! sendChangeOnlyOnRelease, false, true); if (e.mods.isShiftDown()) setMinValue (getMaxValue() - minMaxDiff, false, false, true); else minMaxDiff = (double) valueMax.getValue() - (double) valueMin.getValue(); } mousePosWhenLastDragged = e.getPosition(); } } void Slider::mouseDoubleClick (const MouseEvent&) { if (doubleClickToValue && isEnabled() && style != IncDecButtons && minimum <= doubleClickReturnValue && maximum >= doubleClickReturnValue) { sendDragStart(); setValue (doubleClickReturnValue, true, true); sendDragEnd(); } } void Slider::mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY) { if (scrollWheelEnabled && isEnabled() && style != TwoValueHorizontal && style != TwoValueVertical) { if (maximum > minimum && ! e.mods.isAnyMouseButtonDown()) { if (valueBox != nullptr) valueBox->hideEditor (false); const double value = (double) currentValue.getValue(); const double proportionDelta = (wheelIncrementX != 0 ? -wheelIncrementX : wheelIncrementY) * 0.15f; const double currentPos = valueToProportionOfLength (value); const double newValue = proportionOfLengthToValue (jlimit (0.0, 1.0, currentPos + proportionDelta)); double delta = (newValue != value) ? jmax (std::abs (newValue - value), interval) : 0; if (value > newValue) delta = -delta; sendDragStart(); setValue (snapValue (value + delta, false), true, true); sendDragEnd(); } } else { Component::mouseWheelMove (e, wheelIncrementX, wheelIncrementY); } } void SliderListener::sliderDragStarted (Slider*) // (can't write Slider::Listener due to idiotic VC2005 bug) { } void SliderListener::sliderDragEnded (Slider*) { } END_JUCE_NAMESPACE
[ "ow3nskip" ]
[ [ [ 1, 1423 ] ] ]
a8a10caa7185ec00902781ed9e71c8c9371140df
880e5a47c23523c8e5ba1602144ea1c48c8c8f9a
/enginesrc/operating_system/windows/windowssystemwindow.cpp
593bc14b98471d044236f15787d0b247e47c30b4
[]
no_license
kfazi/Engine
050cb76826d5bb55595ecdce39df8ffb2d5547f8
0cedfb3e1a9a80fd49679142be33e17186322290
refs/heads/master
2020-05-20T10:02:29.050190
2010-02-11T17:45:42
2010-02-11T17:45:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,729
cpp
#ifdef WINDOWS #include "windowssystemwindow.hpp" #include "../../useful.hpp" namespace engine { LRESULT CALLBACK CWindowsSystemWindow::WindowProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) { CWindowsSystemWindow *pObject = reinterpret_cast<CWindowsSystemWindow *>(GetWindowLongPtr(hWnd, GWL_USERDATA)); switch (iMessage) { case WM_DESTROY: return 0; case WM_CLOSE: if (pObject->OnClose()) DestroyWindow(pObject->m_sWindowData.pHWND); return 0; case WM_SYSCOMMAND: switch (wParam) { case SC_MINIMIZE: if (pObject->OnMinimalize()) ::ShowWindow(pObject->m_sWindowData.pHWND, SW_MINIMIZE); return 0; case SC_RESTORE: if (pObject->OnRestore()) ::ShowWindow(pObject->m_sWindowData.pHWND, SW_RESTORE); return 0; } break; default: break; } return DefWindowProc(hWnd, iMessage, wParam, lParam); } CWindowsSystemWindow::CWindowsSystemWindow(int iX, int iY, unsigned int iWidth, unsigned int iHeight, const CString &cCaption, bool bCaptionBar, bool bCloseButton, bool bMaximalizeButton, bool bMinimalizeButton): CSystemWindow(iX, iY, iWidth, iHeight, cCaption, bCaptionBar, bCloseButton, bMaximalizeButton, bMinimalizeButton) { WNDCLASSEX sWindowClass; HINSTANCE hInstance = ::GetModuleHandle(NULL); CString cClassName = (Format("%1%_%2%") % GAME_NAME % this).str(); m_pClassName = new wchar_t[cClassName.length() + 1]; ::memcpy(m_pClassName, cClassName.ToWCHAR().c_str(), (cClassName.length() + 1) * sizeof(wchar_t)); sWindowClass.cbSize = sizeof(WNDCLASSEX); sWindowClass.style = CS_HREDRAW | CS_VREDRAW; sWindowClass.lpfnWndProc = WindowProc; sWindowClass.cbClsExtra = 0; sWindowClass.cbWndExtra = 0; sWindowClass.hInstance = hInstance; sWindowClass.hIcon = NULL; sWindowClass.hCursor = LoadCursor(NULL, IDC_ARROW); sWindowClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); sWindowClass.lpszMenuName = NULL; sWindowClass.lpszClassName = m_pClassName; sWindowClass.hIconSm = NULL; if (!RegisterClassEx(&sWindowClass)) Error(Format("Call to RegisterClassEx failed! (%1%)") % GetLastError()); int iStyle = 0; if (bCaptionBar) { iStyle |= WS_OVERLAPPED | WS_CAPTION; if (bCloseButton || bMaximalizeButton || bMinimalizeButton) iStyle |= WS_SYSMENU; if (bMaximalizeButton) iStyle |= WS_MAXIMIZEBOX; if (bMinimalizeButton) iStyle |= WS_MINIMIZEBOX; } else iStyle |= WS_POPUP; m_sWindowData.pHWND = ::CreateWindow(m_pClassName, cCaption.ToWCHAR().c_str(), iStyle, iX, iY, iWidth, iHeight, NULL, NULL, hInstance, NULL); if (!m_sWindowData.pHWND) Error(Format("Call to CreateWindow failed! (%1%)") % GetLastError()); if (bCaptionBar && !bCloseButton) { HMENU hMenu = ::GetSystemMenu(m_sWindowData.pHWND, FALSE); ::EnableMenuItem(hMenu, SC_CLOSE, MF_GRAYED); } SetWindowLongPtr(m_sWindowData.pHWND, GWLP_USERDATA, reinterpret_cast<LONG>(this)); ::UpdateWindow(m_sWindowData.pHWND); } CWindowsSystemWindow::~CWindowsSystemWindow() { delete [] m_pClassName; } void CWindowsSystemWindow::ProcessEvents() { MSG sMessage; if (::PeekMessage(&sMessage, m_sWindowData.pHWND, 0, 0, PM_REMOVE)) { ::TranslateMessage(&sMessage); ::DispatchMessage(&sMessage); } } const SSystemSpecificWindowData *CWindowsSystemWindow::GetSystemSpecificData() const { return &m_sWindowData; } void CWindowsSystemWindow::Show() { CSystemWindow::Show(); ::ShowWindow(m_sWindowData.pHWND, true); ::UpdateWindow(m_sWindowData.pHWND); } void CWindowsSystemWindow::Hide() { CSystemWindow::Hide(); ::ShowWindow(m_sWindowData.pHWND, false); ::UpdateWindow(m_sWindowData.pHWND); } } #endif /* WINDOWS */ /* EOF */
[ [ [ 1, 123 ] ] ]
82f250e2a2a5769f6ccc70f6c890ca72ae329063
38664d844d9fad34e88160f6ebf86c043db9f1c5
/branches/tags/mfc-import/controls/hbutton.h
1663f17a8abced7c615122c141dfcd68e9436ceb
[]
no_license
cnsuhao/jezzitest
84074b938b3e06ae820842dac62dae116d5fdaba
9b5f6cf40750511350e5456349ead8346cabb56e
refs/heads/master
2021-05-28T23:08:59.663581
2010-11-25T13:44:57
2010-11-25T13:44:57
null
0
0
null
null
null
null
GB18030
C++
false
false
14,236
h
#pragma once #include <tmschema.h> #include <atlmisc.h> #include "../base/SkinDraw.h" namespace Skin{ class ButtonDraw; #if 0 class ATL_NO_VTABLE ButtonConfig : public CComTearOffObjectBase<ButtonDraw> , public ISkinConfig { public: typedef ButtonConfig thisType; BEGIN_COM_MAP(thisType) COM_INTERFACE_ENTRY_IID(IID_ISkinConfig, ISkinConfig) END_COM_MAP() STDMETHOD_(LPCSTR, GetName)(int iPartId, int iStateId, BOOL* fUseDefault) { #if 1 SKINCONFIG_BEGIN_PART(BP_PUSHBUTTON) SKINCONFIG_ITEM(PBS_DEFAULTED, "button_default") SKINCONFIG_ITEM(PBS_DISABLED, "button_disable") SKINCONFIG_ITEM(PBS_HOT, "button_focus") SKINCONFIG_ITEM(PBS_NORMAL, "button_normal") SKINCONFIG_ITEM(PBS_PRESSED, "button_down") SKINCONFIG_USE_DEFAULT(fUseDefault) SKINCONFIG_END_PART() SKINCONFIG_BEGIN_PART(BP_CHECKBOX) SKINCONFIG_ITEM(CBS_CHECKEDDISABLED, "checkbox_checked_disable") SKINCONFIG_ITEM(CBS_CHECKEDHOT, "checkbox_checked") SKINCONFIG_ITEM(CBS_CHECKEDNORMAL, "checkbox_checked") SKINCONFIG_ITEM(CBS_CHECKEDPRESSED, "checkbox_checked_down") SKINCONFIG_ITEM(CBS_UNCHECKEDDISABLED, "checkbox_disable") SKINCONFIG_ITEM(CBS_UNCHECKEDHOT, "checkbox_notchecked") SKINCONFIG_ITEM(CBS_UNCHECKEDNORMAL, "checkbox_notchecked") SKINCONFIG_ITEM(CBS_UNCHECKEDPRESSED, "checkbox_notchecked_down") SKINCONFIG_USE_DEFAULT(fUseDefault) SKINCONFIG_END_PART() SKINCONFIG_BEGIN_PART(BP_RADIOBUTTON) SKINCONFIG_ITEM(RBS_CHECKEDDISABLED, "radio_selected_disable") SKINCONFIG_ITEM(RBS_CHECKEDHOT, "radio_selected") SKINCONFIG_ITEM(RBS_CHECKEDNORMAL, "radio_selected") SKINCONFIG_ITEM(RBS_CHECKEDPRESSED, "radio_selected_down") SKINCONFIG_ITEM(RBS_UNCHECKEDDISABLED, "radio_disable") SKINCONFIG_ITEM(RBS_UNCHECKEDHOT, "radio_normal") SKINCONFIG_ITEM(RBS_UNCHECKEDNORMAL, "radio_normal") SKINCONFIG_ITEM(RBS_UNCHECKEDPRESSED , "radio_normal_down") SKINCONFIG_USE_DEFAULT(fUseDefault) SKINCONFIG_END_PART() #else if(xPart == iPartId) { if(xState == iStateId) return xName; *fUseDefault = FALSE; } #endif return 0; } // 实现时本函数可以不实现的,不支持增长 STDMETHOD(AddItem)(int iPartId, int iStateId, LPCSTR szItemName) { return E_NOTIMPL; } STDMETHOD_(LPCSTR, GetColor)(int iPartId, int iStateId, BOOL* fUseDefault) { #if 1 SKINCONFIG_BEGIN_PART(BP_PUSHBUTTON) SKINCONFIG_ITEM(PBS_DEFAULTED, "button_text_normal") SKINCONFIG_ITEM(PBS_DISABLED, "button_text_disable") SKINCONFIG_ITEM(PBS_HOT, "button_text_focus") SKINCONFIG_ITEM(PBS_NORMAL, "button_text_normal") SKINCONFIG_ITEM(PBS_PRESSED, "button_text_normal") SKINCONFIG_USE_DEFAULT(fUseDefault) SKINCONFIG_END_PART() SKINCONFIG_BEGIN_PART(BP_CHECKBOX) SKINCONFIG_ITEM(CBS_CHECKEDDISABLED, "button_text_disable") SKINCONFIG_ITEM(CBS_CHECKEDHOT, "button_text_focus") SKINCONFIG_ITEM(CBS_CHECKEDNORMAL, "button_text_normal") SKINCONFIG_ITEM(CBS_CHECKEDPRESSED, "button_text_normal") SKINCONFIG_ITEM(CBS_UNCHECKEDDISABLED, "button_text_disable") SKINCONFIG_ITEM(CBS_UNCHECKEDHOT, "button_text_focus") SKINCONFIG_ITEM(CBS_UNCHECKEDNORMAL, "button_text_normal") SKINCONFIG_ITEM(CBS_UNCHECKEDPRESSED, "button_text_normal") SKINCONFIG_USE_DEFAULT(fUseDefault) SKINCONFIG_END_PART() SKINCONFIG_BEGIN_PART(BP_RADIOBUTTON) SKINCONFIG_ITEM(RBS_CHECKEDDISABLED, "button_text_disable") SKINCONFIG_ITEM(RBS_CHECKEDHOT, "button_text_focus") SKINCONFIG_ITEM(RBS_CHECKEDNORMAL, "button_text_normal") SKINCONFIG_ITEM(RBS_CHECKEDPRESSED, "button_text_normal") SKINCONFIG_ITEM(RBS_UNCHECKEDDISABLED, "button_text_disable") SKINCONFIG_ITEM(RBS_UNCHECKEDHOT, "button_text_focus") SKINCONFIG_ITEM(RBS_UNCHECKEDNORMAL, "button_text_normal") SKINCONFIG_ITEM(RBS_UNCHECKEDPRESSED , "button_text_normal") SKINCONFIG_USE_DEFAULT(fUseDefault) SKINCONFIG_END_PART() #else if(xPart == iPartId) { if(xState == iStateId) return xName; *fUseDefault = FALSE; } #endif return 0; } // 实现时本函数可以不实现的,不支持增长 STDMETHOD(AddColor)(int iPartId, int iStateId, LPCSTR szItemName) { return E_NOTIMPL; } }; #endif // #if 0 class ATL_NO_VTABLE ButtonDraw : public CComObjectRoot , public SkinDrawImpl<ButtonDraw, SKINCTL_BUTTON> { public: typedef ButtonDraw thisType; BEGIN_COM_MAP(thisType) COM_INTERFACE_ENTRY_IID(IID_ISkinDraw, ISkinDraw) END_COM_MAP() DECLARE_GET_CONTROLLING_UNKNOWN() DECLARE_PROTECT_FINAL_CONSTRUCT() HRESULT FinalConstruct() { return S_OK; } void FinalRelease() { } STDMETHOD_(HBRUSH, GetColorBrush)(int iStateId) { return 0; } STDMETHOD_(BOOL, IsThemeBackgroundPartiallyTransparent)(int iPartId, int iStateId) { // TODO: 可以从配置文件中得到该值。 return TRUE; } STDMETHOD(DrawBackground)(HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect) { if( iPartId == BP_PUSHBUTTON ) return DrawPushButtonBackground(hdc, iPartId, iStateId, pRect, pClipRect); else if( iPartId == BP_CHECKBOX ) return DrawCheckBackground(hdc, iPartId, iStateId, pRect, pClipRect); else if( iPartId == BP_RADIOBUTTON ) return DrawCheckBackground(hdc, iPartId, iStateId, pRect, pClipRect); return S_FALSE; } STDMETHOD(DrawText)(HDC hdc, int iPartId, int iStateId, LPCSTR szText, DWORD dwTextFlags, DWORD dwTextFlags2, const RECT *pRect) { if( iPartId == BP_PUSHBUTTON ) return DrawPushButtonText(hdc, iPartId, iStateId, szText, dwTextFlags, dwTextFlags2, pRect); else if( iPartId == BP_CHECKBOX ) return DrawCheckText(hdc, iPartId, iStateId, szText, dwTextFlags, dwTextFlags2, pRect); else if( iPartId == BP_RADIOBUTTON ) return DrawCheckText(hdc, iPartId, iStateId, szText, dwTextFlags, dwTextFlags2, pRect); return S_FALSE; } STDMETHOD(DrawParentBackground)(HWND hwnd, HDC hdc, RECT *prc) { // TODO: SetClip use prc CWindow wndparent( GetParent(hwnd) ); CWindow wndchild(hwnd); #if 0 if( wndparent.GetStyle() & WS_CLIPCHILDREN ) { LRESULT lRes = wndparent.SendMessage(WM_CTLCOLORDLG, (WPARAM)(HDC)hdc, (LPARAM)wndparent.m_hWnd); if( lRes ) FillRect(hdc, prc, (HBRUSH)lRes); } else { CRect rcparent; wndparent.GetClientRect(&rcparent); // memory dc HDC dcMem = ::CreateCompatibleDC(hdc); ASSERT( dcMem ); HBITMAP bmpMemBg = ::CreateCompatibleBitmap(hdc, rcparent.Width(), rcparent.Height()); ASSERT( bmpMemBg ); HGDIOBJ pOldBmp = ::SelectObject(dcMem, bmpMemBg); ASSERT( pOldBmp ); // 1绘制再memdc 上面 wndparent.SendMessage(WM_PRINTCLIENT, (WPARAM)dcMem, PRF_CLIENT | PRF_ERASEBKGND | PRF_CHECKVISIBLE); HDC h = GetDC(0); BitBlt(h, 10, 10, rcparent.Width(), rcparent.Height(), dcMem, 0, 0, SRCCOPY); ReleaseDC(0, h); // 2把memdc上的绘制到hdc上面 POINT pt; pt.x = prc->left; pt.y = prc->top; ClientToScreen(hwnd, &pt); wndparent.ScreenToClient(&pt); // memory dc ::BitBlt(hdc, prc->left, prc->top, prc->right - prc->left, prc->bottom - prc->top, dcMem, pt.x, pt.y, SRCCOPY); ::SelectObject(dcMem, pOldBmp); ::DeleteObject(bmpMemBg); ::DeleteDC(dcMem); } #endif // 直接使用纯色填充 HBRUSH br = (HBRUSH)wndparent.SendMessage(WM_CTLCOLORDLG, (WPARAM)hdc, (LPARAM)hwnd); if (br) FillRect(hdc, prc, br); // TODO: 检测 WM_PRINTCLIENT 返回值,确定 Dialog 是否有底图 #if 1 CRect rcparent; wndparent.GetClientRect(&rcparent); // memory dc HDC dcMem = ::CreateCompatibleDC(hdc); ASSERT( dcMem ); HBITMAP bmpMemBg = ::CreateCompatibleBitmap(hdc, rcparent.Width(), rcparent.Height()); ASSERT( bmpMemBg ); HGDIOBJ pOldBmp = ::SelectObject(dcMem, bmpMemBg); ASSERT( pOldBmp ); // 1绘制再memdc 上面 LRESULT lRes = wndparent.SendMessage(WM_PRINTCLIENT, (WPARAM)dcMem, PRF_CLIENT | PRF_ERASEBKGND | PRF_CHECKVISIBLE); // memory dc //::BitBlt(hdc, prc->left, prc->top, prc->right - prc->left, prc->bottom - prc->top, dcMem, pt.x, pt.y, SRCCOPY); ::SelectObject(dcMem, pOldBmp); ::DeleteObject(bmpMemBg); ::DeleteDC(dcMem); #endif return S_OK; } STDMETHOD(DrawPushButtonBackground)(HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect) { #if 0 CComPtr<ISkinMgr> spmgr; HRESULT hr = GetSkinMgr(&spmgr); if( FAILED(hr) ) return hr; ASSERT(spmgr); CComPtr<ISkinScheme> spss; hr = spmgr->GetCurentScheme(&spss); if( FAILED(hr) ) return hr; // TODO: 分多段绘制 LPCSTR szName = InternalGetName(iPartId, iStateId); CRect rc; spss->GetRect(szName, &rc); CRect rect(*pRect); int nMode = SetStretchBltMode(hdc, HALFTONE ); // 完全 BitBlt, 原大小 if (rc.Width() == rect.Width() && rc.Height() == rect.Height()) { spss->TransparentDraw(hdc, szName, rect.left, rect.top); } else if (rc.Height() == rect.Height())// 高度一致时,分3次绘制 { int step = rc.Width() / 3; spss->TransparentDraw(hdc, szName, rect.left, rect.top, step, rc.Height(), 0, 0, step, rc.Height()); spss->Draw(hdc, szName, step, rect.top, rect.right - 2 * step, rc.Height(), step, 0, step, rc.Height()); spss->TransparentDraw(hdc, szName, rect.right - step, rect.top, step, rc.Height(), rc.Width() - step, 0, step, rc.Height()); } else // 分 9 段绘制, 高度自适应 { const int step = rc.Height() / 3; // 左上角 spss->TransparentDraw(hdc, szName, rect.left, rect.top, step, step, 0, 0, step, step); // 上部中间 spss->Draw(hdc, szName, rect.left + step, rect.top, rect.Width() - 2 * step, step, step, 0, rc.Width() - 2 * step, step); // 上部右边 spss->TransparentDraw(hdc, szName, rect.right - step, rect.top, step, step, rc.Width() - step, 0, step, step); // 中间部分 左边 spss->Draw(hdc, szName, rect.left, rect.top + step, step, rect.Height() - 2 * step, 0, step, step, rc.Height() - 2 * step); // 中间部分 中部 spss->Draw(hdc, szName, rect.left + step, rect.top + step, rect.Width() - 2 * step, rect.Height() - 2 * step, step, step, step, step); // 中间部分 右边 spss->Draw(hdc, szName, rect.right - step , rect.top + step, step, rect.Height() - 2 * step, rc.Width() - step, step, step, step); // 下面部分 左边 spss->TransparentDraw(hdc, szName, rect.left, rect.bottom - step, step, step, 0, rc.Height() - step, step, step); // 下面部分 中间 spss->Draw(hdc, szName, step, rect.bottom - step, rect.right - 2 * step, step, step, rc.Height() - step, rc.Width() - 2 * step, step); // 下面部分 右边 spss->TransparentDraw(hdc, szName, rect.right - step , rect.bottom - step, step, step, rc.Width() - step, rc.Height() - step, step, step); } SetStretchBltMode(hdc, nMode ); // TODO: Region 策略 #endif // TODO: 应该可以支持透明/办透明的背景 return S_OK; } STDMETHOD(DrawCheckBackground)(HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect) { #if 0 CComPtr<ISkinMgr> spmgr; HRESULT hr = GetSkinMgr(&spmgr); if( FAILED(hr) ) return hr; ASSERT(spmgr); CComPtr<ISkinScheme> spss; hr = spmgr->GetCurentScheme(&spss); if( FAILED(hr) ) return hr; // TODO: 分多段绘制 LPCSTR szName = InternalGetName(iPartId, iStateId); CRect rc; spss->GetRect(szName, &rc); CRect rect(*pRect); RECT rt = rect; rt.top = (rect.Height() - rc.Width()) / 2; rt.right = rt.left + rc.Width(); rt.bottom = rt.top + rc.Height(); int nMode = SetStretchBltMode(hdc, HALFTONE ); spss->TransparentDraw(hdc, szName, rt.left, rt.top, rt.right - rt.left, rt.bottom - rt.top, 0, 0, rc.Width(), rc.Height()); SetStretchBltMode(hdc, nMode ); #endif return S_OK; } STDMETHOD(DrawPushButtonText)(HDC hdc, int iPartId, int iStateId, LPCSTR szText, DWORD dwTextFlags, DWORD dwTextFlags2, const RECT *pRect) { CComPtr<ISkinScheme> spss = GetCurrentScheme(); RECT rc = *pRect; ::DrawText(hdc, szText, -1, &rc, dwTextFlags); #if 0 CComPtr<ISkinMgr> spmgr; HRESULT hr = GetSkinMgr(&spmgr); if( FAILED(hr) ) return hr; ASSERT(spmgr); CComPtr<ISkinScheme> spss; hr = spmgr->GetCurentScheme(&spss); if( FAILED(hr) ) return hr; SetBkMode(hdc, TRANSPARENT); SetTextColor(hdc, spss->GetColor(InternalGetColor(iPartId, iStateId))); HGDIOBJ hOldFont = (HFONT)SelectObject(hdc,(HFONT)GetStockObject(DEFAULT_GUI_FONT)); RECT rc(*pRect); if (iStateId == PBS_PRESSED) { rc.left += 2; rc.top += 2; } ::DrawText(hdc, szText, -1, &rc, dwTextFlags); SelectObject(hdc,hOldFont); #endif return S_OK; } STDMETHOD(DrawCheckText)(HDC hdc, int iPartId, int iStateId, LPCSTR szText, DWORD dwTextFlags, DWORD dwTextFlags2, const RECT *pRect) { #if 0 CComPtr<ISkinMgr> spmgr; HRESULT hr = GetSkinMgr(&spmgr); if( FAILED(hr) ) return hr; ASSERT(spmgr); CComPtr<ISkinScheme> spss; hr = spmgr->GetCurentScheme(&spss); if( FAILED(hr) ) return hr; SetBkMode(hdc, TRANSPARENT); SetTextColor(hdc, spss->GetColor(InternalGetColor(iPartId, iStateId))); HGDIOBJ hOldFont = (HFONT)SelectObject(hdc,(HFONT)GetStockObject(DEFAULT_GUI_FONT)); LPCSTR szName = InternalGetName(iPartId, iStateId); CRect rcImage; spss->GetRect(szName, &rcImage); RECT rect(*pRect); rect.left += rcImage.Width() + 4; rect.top += 1; ::DrawText(hdc, szText, -1, &rect, DT_LEFT | DT_VCENTER | DT_SINGLELINE);//dwTextFlags); SelectObject(hdc,hOldFont); #endif return S_OK; } STDMETHOD(DrawIcon)(HDC, int iPartId, int iStateId, const RECT *pRect) { return S_OK; } STDMETHOD(DrawEdge)(HDC, int iPartId, int iStateId, const RECT *pDestRect, UINT uEdge, UINT uFlags, OPTIONAL OUT RECT *pContentRect) { return S_OK; } }; }; // namespace Skin
[ "ken.shao@ba8f1dc9-3c1c-0410-9eed-0f8a660c14bd" ]
[ [ [ 1, 447 ] ] ]
2e6330f5021d42d27b38a5b7745fff87c02aad18
a31e04e907e1d6a8b24d84274d4dd753b40876d0
/MortScript/DlgChoice.h
a2fce15e8a0aa72b3947043cc93d62054074ef5e
[]
no_license
RushSolutions/jscripts
23c7d6a82046dafbba3c4e060ebe3663821b3722
869cc681f88e1b858942161d9d35f4fbfedcfd6d
refs/heads/master
2021-01-10T15:31:24.018830
2010-02-26T07:41:17
2010-02-26T07:41:17
47,889,373
0
0
null
null
null
null
UTF-8
C++
false
false
1,698
h
#if !defined(AFX_DLGCHOICE_H__D9EE585E_6A4C_43C3_A43F_DCB8BA9CED2C__INCLUDED_) #define AFX_DLGCHOICE_H__D9EE585E_6A4C_43C3_A43F_DCB8BA9CED2C__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // DlgChoice.h : header file // ///////////////////////////////////////////////////////////////////////////// // CDlgChoice dialog class CDlgChoice : public CDialog { // Construction public: CDlgChoice(CWnd* pParent = NULL); // standard constructor // Dialog Data //{{AFX_DATA(CDlgChoice) enum { IDD = IDD_CHOICE }; CListBox m_Entries; CString m_Countdown; //}}AFX_DATA CStringArray m_Strings; CString m_Title; CString m_Info; int m_Selected; int m_Default, m_Timeout, countdown; int PressedKey; int SelType; // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CDlgChoice) public: virtual BOOL PreTranslateMessage(MSG* pMsg); protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: #ifndef DESKTOP CCeCommandBar m_wndCommandBar; #endif // Generated message map functions //{{AFX_MSG(CDlgChoice) virtual BOOL OnInitDialog(); virtual void OnOK(); virtual void OnCancel(); afx_msg void OnDblclkEntries(); afx_msg void OnTimer(UINT nIDEvent); afx_msg void OnSelchangeEntries(); afx_msg void OnSize(UINT nType, int cx, int cy); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_DLGCHOICE_H__D9EE585E_6A4C_43C3_A43F_DCB8BA9CED2C__INCLUDED_)
[ "frezgo@c2805876-21d7-11df-8c35-9da929d3dec4" ]
[ [ [ 1, 65 ] ] ]
fb852d336e512bc51e5fe64f76bbfb8b056a6c6b
d4b316c5dfe18916d6747e564a6bb8e814d4413a
/algorithms/transporting_problem_console/transporting_problem_console/transporting.h
62a2043be1cb7eca889dc656e89eeb7a5367429d
[]
no_license
artemshynkarenko/ilsdev
3c8b485beb66cd9d33c9b844758bf2e79c5ea94f
e6cc62f14aae409cc1e462ba03b8dcb2c1a6aa02
refs/heads/master
2016-09-06T08:30:25.052724
2009-06-19T16:35:14
2009-06-19T16:35:14
32,579,868
0
0
null
null
null
null
UTF-8
C++
false
false
826
h
#include <iostream> using namespace std; const int INF = 10000000; class Graph; class Transporting{ int m, n; int *a; int *b; int **c; int **x; int result; friend class Graph; public: Transporting():m(0), n(0){} Transporting(int x, int y):m(x), n(y){init();} friend istream & operator>>(istream & is, Transporting & t); void init(); void calc_defoult_plan(); void get_result(Graph &); void free(); void print_result(); }; class Graph{ int n; int **weight; int **cost; int **flow; int *parent; int source, dest; int m_, n_; friend class Transporting; void print_debug_result(); public: Graph(): n(0){} Graph(const Transporting &); void init_matrix(); void calc_defoult_plan(); int max_flow_min_const(); bool find_shortest_path(int s, int d); };
[ "kupjak@0d0ad13b-7e51-0410-977d-d3f3eabcdc60" ]
[ [ [ 1, 46 ] ] ]
e5b01916c231b6a5d75f84838e931a9729f35fe6
580738f96494d426d6e5973c5b3493026caf8b6a
/Include/Vcl/teefunci.hpp
d098f8d0cb3c3731d54668f1adec337f2e760f59
[]
no_license
bravesoftdz/cbuilder-vcl
6b460b4d535d17c309560352479b437d99383d4b
7b91ef1602681e094a6a7769ebb65ffd6f291c59
refs/heads/master
2021-01-10T14:21:03.726693
2010-01-11T11:23:45
2010-01-11T11:23:45
48,485,606
2
1
null
null
null
null
UTF-8
C++
false
false
7,020
hpp
// Borland C++ Builder // Copyright (c) 1995, 2002 by Borland Software Corporation // All rights reserved // (DO NOT EDIT: machine generated header) 'TeeFunci.pas' rev: 6.00 #ifndef TeeFunciHPP #define TeeFunciHPP #pragma delphiheader begin #pragma option push -w- #pragma option push -Vx #include <TeEngine.hpp> // Pascal unit #include <Classes.hpp> // Pascal unit #include <SysInit.hpp> // Pascal unit #include <System.hpp> // Pascal unit //-- user supplied ----------------------------------------------------------- namespace Teefunci { //-- type declarations ------------------------------------------------------- class DELPHICLASS TBasicTeeFunction; class PASCALIMPLEMENTATION TBasicTeeFunction : public Teengine::TTeeFunction { typedef Teengine::TTeeFunction inherited; public: #pragma option push -w-inl /* TTeeFunction.Create */ inline __fastcall virtual TBasicTeeFunction(Classes::TComponent* AOwner) : Teengine::TTeeFunction(AOwner) { } #pragma option pop public: #pragma option push -w-inl /* TComponent.Destroy */ inline __fastcall virtual ~TBasicTeeFunction(void) { } #pragma option pop }; class DELPHICLASS TAddTeeFunction; class PASCALIMPLEMENTATION TAddTeeFunction : public Teengine::TTeeFunction { typedef Teengine::TTeeFunction inherited; public: virtual double __fastcall Calculate(Teengine::TChartSeries* SourceSeries, int FirstIndex, int LastIndex); virtual double __fastcall CalculateMany(Classes::TList* SourceSeriesList, int ValueIndex); public: #pragma option push -w-inl /* TTeeFunction.Create */ inline __fastcall virtual TAddTeeFunction(Classes::TComponent* AOwner) : Teengine::TTeeFunction(AOwner) { } #pragma option pop public: #pragma option push -w-inl /* TComponent.Destroy */ inline __fastcall virtual ~TAddTeeFunction(void) { } #pragma option pop }; class DELPHICLASS TManySeriesTeeFunction; class PASCALIMPLEMENTATION TManySeriesTeeFunction : public Teengine::TTeeFunction { typedef Teengine::TTeeFunction inherited; protected: virtual double __fastcall CalculateValue(const double AResult, const double AValue) = 0 ; public: virtual double __fastcall CalculateMany(Classes::TList* SourceSeriesList, int ValueIndex); public: #pragma option push -w-inl /* TTeeFunction.Create */ inline __fastcall virtual TManySeriesTeeFunction(Classes::TComponent* AOwner) : Teengine::TTeeFunction(AOwner) { } #pragma option pop public: #pragma option push -w-inl /* TComponent.Destroy */ inline __fastcall virtual ~TManySeriesTeeFunction(void) { } #pragma option pop }; class DELPHICLASS TSubtractTeeFunction; class PASCALIMPLEMENTATION TSubtractTeeFunction : public TManySeriesTeeFunction { typedef TManySeriesTeeFunction inherited; protected: virtual double __fastcall CalculateValue(const double AResult, const double AValue); public: #pragma option push -w-inl /* TTeeFunction.Create */ inline __fastcall virtual TSubtractTeeFunction(Classes::TComponent* AOwner) : TManySeriesTeeFunction(AOwner) { } #pragma option pop public: #pragma option push -w-inl /* TComponent.Destroy */ inline __fastcall virtual ~TSubtractTeeFunction(void) { } #pragma option pop }; class DELPHICLASS TMultiplyTeeFunction; class PASCALIMPLEMENTATION TMultiplyTeeFunction : public TManySeriesTeeFunction { typedef TManySeriesTeeFunction inherited; protected: virtual double __fastcall CalculateValue(const double AResult, const double AValue); public: #pragma option push -w-inl /* TTeeFunction.Create */ inline __fastcall virtual TMultiplyTeeFunction(Classes::TComponent* AOwner) : TManySeriesTeeFunction(AOwner) { } #pragma option pop public: #pragma option push -w-inl /* TComponent.Destroy */ inline __fastcall virtual ~TMultiplyTeeFunction(void) { } #pragma option pop }; class DELPHICLASS TDivideTeeFunction; class PASCALIMPLEMENTATION TDivideTeeFunction : public TManySeriesTeeFunction { typedef TManySeriesTeeFunction inherited; protected: virtual double __fastcall CalculateValue(const double AResult, const double AValue); public: #pragma option push -w-inl /* TTeeFunction.Create */ inline __fastcall virtual TDivideTeeFunction(Classes::TComponent* AOwner) : TManySeriesTeeFunction(AOwner) { } #pragma option pop public: #pragma option push -w-inl /* TComponent.Destroy */ inline __fastcall virtual ~TDivideTeeFunction(void) { } #pragma option pop }; class DELPHICLASS THighTeeFunction; class PASCALIMPLEMENTATION THighTeeFunction : public Teengine::TTeeFunction { typedef Teengine::TTeeFunction inherited; public: virtual double __fastcall Calculate(Teengine::TChartSeries* SourceSeries, int FirstIndex, int LastIndex); virtual double __fastcall CalculateMany(Classes::TList* SourceSeriesList, int ValueIndex); public: #pragma option push -w-inl /* TTeeFunction.Create */ inline __fastcall virtual THighTeeFunction(Classes::TComponent* AOwner) : Teengine::TTeeFunction(AOwner) { } #pragma option pop public: #pragma option push -w-inl /* TComponent.Destroy */ inline __fastcall virtual ~THighTeeFunction(void) { } #pragma option pop }; class DELPHICLASS TLowTeeFunction; class PASCALIMPLEMENTATION TLowTeeFunction : public Teengine::TTeeFunction { typedef Teengine::TTeeFunction inherited; public: virtual double __fastcall Calculate(Teengine::TChartSeries* SourceSeries, int FirstIndex, int LastIndex); virtual double __fastcall CalculateMany(Classes::TList* SourceSeriesList, int ValueIndex); public: #pragma option push -w-inl /* TTeeFunction.Create */ inline __fastcall virtual TLowTeeFunction(Classes::TComponent* AOwner) : Teengine::TTeeFunction(AOwner) { } #pragma option pop public: #pragma option push -w-inl /* TComponent.Destroy */ inline __fastcall virtual ~TLowTeeFunction(void) { } #pragma option pop }; class DELPHICLASS TAverageTeeFunction; class PASCALIMPLEMENTATION TAverageTeeFunction : public Teengine::TTeeFunction { typedef Teengine::TTeeFunction inherited; public: virtual double __fastcall Calculate(Teengine::TChartSeries* SourceSeries, int FirstIndex, int LastIndex); virtual double __fastcall CalculateMany(Classes::TList* SourceSeriesList, int ValueIndex); public: #pragma option push -w-inl /* TTeeFunction.Create */ inline __fastcall virtual TAverageTeeFunction(Classes::TComponent* AOwner) : Teengine::TTeeFunction(AOwner) { } #pragma option pop public: #pragma option push -w-inl /* TComponent.Destroy */ inline __fastcall virtual ~TAverageTeeFunction(void) { } #pragma option pop }; //-- var, const, procedure --------------------------------------------------- } /* namespace Teefunci */ using namespace Teefunci; #pragma option pop // -w- #pragma option pop // -Vx #pragma delphiheader end. //-- end unit ---------------------------------------------------------------- #endif // TeeFunci
[ "bitscode@7bd08ab0-fa70-11de-930f-d36749347e7b" ]
[ [ [ 1, 217 ] ] ]
be8ed58c6ead00be2659b33dc8cf7ee96ec71f42
c5534a6df16a89e0ae8f53bcd49a6417e8d44409
/trunk/Dependencies/Xerces/include/xercesc/validators/schema/identity/ValueStore.cpp
08b629718f9e78e109e21dd83142a0b69c07f240
[]
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
10,840
cpp
/* * 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. */ /* * $Id: ValueStore.cpp 191054 2005-06-17 02:56:35Z jberry $ */ // --------------------------------------------------------------------------- // Includes // --------------------------------------------------------------------------- #include <xercesc/internal/XMLScanner.hpp> #include <xercesc/framework/XMLValidator.hpp> #include <xercesc/validators/datatype/DatatypeValidator.hpp> #include <xercesc/validators/schema/identity/FieldActivator.hpp> #include <xercesc/validators/schema/identity/ValueStore.hpp> #include <xercesc/validators/schema/identity/IC_Field.hpp> #include <xercesc/validators/schema/identity/IC_KeyRef.hpp> #include <xercesc/validators/schema/identity/ValueStoreCache.hpp> XERCES_CPP_NAMESPACE_BEGIN // --------------------------------------------------------------------------- // ValueStore: Constructors and Destructor // --------------------------------------------------------------------------- ValueStore::ValueStore(IdentityConstraint* const ic, XMLScanner* const scanner, MemoryManager* const manager) : fDoReportError(false) , fValuesCount(0) , fIdentityConstraint(ic) , fValues(manager) , fValueTuples(0) , fKeyValueStore(0) , fScanner(scanner) , fMemoryManager(manager) { fDoReportError = (scanner && scanner->getDoValidation()); } ValueStore::~ValueStore() { delete fValueTuples; } // --------------------------------------------------------------------------- // ValueStore: Helper methods // --------------------------------------------------------------------------- void ValueStore::addValue(IC_Field* const, DatatypeValidator* const, const XMLCh* const) { } void ValueStore::addValue(FieldActivator* const fieldActivator, IC_Field* const field, DatatypeValidator* const dv, const XMLCh* const value) { if (!fieldActivator->getMayMatch(field) && fDoReportError) { fScanner->getValidator()->emitError(XMLValid::IC_FieldMultipleMatch); } // do we even know this field? int index = fValues.indexOf(field); if (index == -1) { if (fDoReportError) { fScanner->getValidator()->emitError(XMLValid::IC_UnknownField); } return; } // store value if (!fValues.getDatatypeValidatorAt(index) && !fValues.getValueAt(index)) { fValuesCount++; } fValues.put(field, dv, value); if (fValuesCount == (int) fValues.size()) { // is this value as a group duplicated? if (contains(&fValues)) { duplicateValue(); } // store values if (!fValueTuples) { fValueTuples = new (fMemoryManager) RefVectorOf<FieldValueMap>(4, true, fMemoryManager); } fValueTuples->addElement(new (fMemoryManager) FieldValueMap(fValues)); } } void ValueStore::append(const ValueStore* const other) { if (!other->fValueTuples) { return; } unsigned int tupleSize = other->fValueTuples->size(); for (unsigned int i=0; i<tupleSize; i++) { FieldValueMap* valueMap = other->fValueTuples->elementAt(i); if (!contains(valueMap)) { if (!fValueTuples) { fValueTuples = new (fMemoryManager) RefVectorOf<FieldValueMap>(4, true, fMemoryManager); } fValueTuples->addElement(new (fMemoryManager) FieldValueMap(*valueMap)); } } } void ValueStore::startValueScope() { fValuesCount = 0; int count = fIdentityConstraint->getFieldCount(); for (int i = 0; i < count; i++) { fValues.put(fIdentityConstraint->getFieldAt(i), 0, 0); } } void ValueStore::endValueScope() { if (fValuesCount == 0) { if (fIdentityConstraint->getType() == IdentityConstraint::KEY && fDoReportError) { fScanner->getValidator()->emitError(XMLValid::IC_AbsentKeyValue, fIdentityConstraint->getElementName()); } return; } // do we have enough values? if ((fValuesCount != fIdentityConstraint->getFieldCount()) && fDoReportError) { switch (fIdentityConstraint->getType()) { case IdentityConstraint::UNIQUE: { fScanner->getValidator()->emitError(XMLValid::IC_UniqueNotEnoughValues, fIdentityConstraint->getElementName()); break; } case IdentityConstraint::KEY: { fScanner->getValidator()->emitError(XMLValid::IC_KeyNotEnoughValues, fIdentityConstraint->getElementName(), fIdentityConstraint->getIdentityConstraintName()); break; } case IdentityConstraint::KEYREF: { fScanner->getValidator()->emitError(XMLValid::IC_KeyRefNotEnoughValues, fIdentityConstraint->getElementName(), fIdentityConstraint->getIdentityConstraintName()); break; } } } } bool ValueStore::contains(const FieldValueMap* const other) { if (fValueTuples) { unsigned int otherSize = other->size(); unsigned int tupleSize = fValueTuples->size(); for (unsigned int i=0; i<tupleSize; i++) { FieldValueMap* valueMap = fValueTuples->elementAt(i); if (otherSize == valueMap->size()) { bool matchFound = true; for (unsigned int j=0; j<otherSize; j++) { if (!isDuplicateOf(valueMap->getDatatypeValidatorAt(j), valueMap->getValueAt(j), other->getDatatypeValidatorAt(j), other->getValueAt(j))) { matchFound = false; break; } } if (matchFound) { // found it return true; } } } } return false; } bool ValueStore::isDuplicateOf(DatatypeValidator* const dv1, const XMLCh* const val1, DatatypeValidator* const dv2, const XMLCh* const val2) { // if either validator's null, fall back on string comparison if(!dv1 || !dv2) { return (XMLString::equals(val1, val2)); } unsigned int val1Len = XMLString::stringLen(val1); unsigned int val2Len = XMLString::stringLen(val2); if (!val1Len && !val2Len) { if (dv1 == dv2) { return true; } return false; } if (!val1Len || !val2Len) { return false; } // are the validators equal? // As always we are obliged to compare by reference... if (dv1 == dv2) { return ((dv1->compare(val1, val2, fMemoryManager)) == 0); } // see if this.fValidator is derived from value.fValidator: DatatypeValidator* tempVal = dv1; for(; !tempVal || tempVal == dv2; tempVal = tempVal->getBaseValidator()) ; if (tempVal) { // was derived! return ((dv2->compare(val1, val2, fMemoryManager)) == 0); } // see if value.fValidator is derived from this.fValidator: for(tempVal = dv2; !tempVal || tempVal == dv1; tempVal = tempVal->getBaseValidator()) ; if(tempVal) { // was derived! return ((dv1->compare(val1, val2, fMemoryManager)) == 0); } // if we're here it means the types weren't related. Must fall back to strings: return (XMLString::equals(val1, val2)); } // --------------------------------------------------------------------------- // ValueStore: Docuement handling methods // --------------------------------------------------------------------------- void ValueStore::endDcocumentFragment(ValueStoreCache* const valueStoreCache) { if (fIdentityConstraint->getType() == IdentityConstraint::KEYREF) { // verify references // get the key store corresponding (if it exists): fKeyValueStore = valueStoreCache->getGlobalValueStoreFor(((IC_KeyRef*) fIdentityConstraint)->getKey()); if (!fKeyValueStore) { if (fDoReportError) { fScanner->getValidator()->emitError(XMLValid::IC_KeyRefOutOfScope, fIdentityConstraint->getIdentityConstraintName()); } return; } unsigned int count = (fValueTuples) ? fValueTuples->size() : 0; for (unsigned int i = 0; i < count; i++) { FieldValueMap* valueMap = fValueTuples->elementAt(i); if (!fKeyValueStore->contains(valueMap) && fDoReportError) { fScanner->getValidator()->emitError(XMLValid::IC_KeyNotFound, fIdentityConstraint->getElementName()); } } } } // --------------------------------------------------------------------------- // ValueStore: Error reporting methods // --------------------------------------------------------------------------- void ValueStore::reportNilError(IdentityConstraint* const ic) { if (fDoReportError && ic->getType() == IdentityConstraint::KEY) { fScanner->getValidator()->emitError(XMLValid::IC_KeyMatchesNillable, ic->getElementName()); } } void ValueStore::duplicateValue() { if (fDoReportError) { switch (fIdentityConstraint->getType()) { case IdentityConstraint::UNIQUE: { fScanner->getValidator()->emitError(XMLValid::IC_DuplicateUnique, fIdentityConstraint->getElementName()); break; } case IdentityConstraint::KEY: { fScanner->getValidator()->emitError(XMLValid::IC_DuplicateKey, fIdentityConstraint->getElementName()); break; } } } } XERCES_CPP_NAMESPACE_END /** * End of file ValueStore.cpp */
[ "Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57" ]
[ [ [ 1, 341 ] ] ]
4f26e16c200da33c23e9a37ef5b4ed96e207325f
0d561d014ed30f5ea38cffbad9b67e161f8d5e76
/fast_lattice2d.cpp
f5ac80281f8e0eb744c868b16ed5603c7261799a
[]
no_license
mchouza/lattice-boltzmann-sdl
1cf226940ef00ee4411264ea2e0719f2eea9e345
65a9ef54090b10a954c4eddad12f1c94b130a44e
refs/heads/master
2016-08-06T17:02:37.635344
2008-12-22T00:32:43
2008-12-22T00:32:43
35,064,801
0
0
null
null
null
null
UTF-8
C++
false
false
3,793
cpp
#include "fast_lattice2d.h" #include <algorithm> #include <cassert> namespace { const int propD[][2] = { { 0, 0}, { 1, 0}, { 1, 1}, { 0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, { 0, -1}, { 1, -1}, }; const real_t scD[] = { 4.0f / 9.0f, 1.0f / 9.0f, // E 1.0f / 36.0f, // NE 1.0f / 9.0f, // N 1.0f / 36.0f, // NW 1.0f / 9.0f, // W 1.0f / 36.0f, // SW 1.0f / 9.0f, // S 1.0f / 36.0f, // SE }; const real_t OMEGA = 0.5f; inline real_t getFEq(real_t rho, real_t ux, real_t uy, real_t uSqr, int i) { real_t dotProd = ux * propD[i][0] + uy * propD[i][1]; real_t eqF = scD[i] * rho * (1.0f + 3.0f * dotProd + 4.5f * dotProd * dotProd - 1.5f * uSqr); return eqF; } inline real_t sqr(real_t x) { return x * x; } } FastLattice2D::FastLattice2D(int n, void (*loader)(int x, int y, real_t& rho, real_t& ux, real_t& uy)) : n_(n), accumBufferUpdated_(false) { f_ = new real_t[n * n * Q]; accumBuffer_ = new real_t[(DIM + 1) * n * n]; for (int i = 0; i < Q; i++) for (int x = 0; x < n; x++) for (int y = 0; y < n; y++) { real_t rho, ux, uy, uSqr; loader(x, y, rho, ux, uy); uSqr = ux * ux + uy * uy; f_[x + y * n + i * n * n] = getFEq(rho, ux, uy, uSqr, i); }; for (int i = 0; i < Q; i++) offsets_[i] = 0; } FastLattice2D::~FastLattice2D() { delete[] f_; delete[] accumBuffer_; } void FastLattice2D::makeCollisions() { const real_t* accumBuffer = getData(); const int srcBlockSize = n_ * n_; for (int i = 0; i < Q; i++) { real_t* dataBlock = f_ + i * srcBlockSize; int j, k; real_t uSqr; for (j = offsets_[i], k = 0; j < srcBlockSize; j++, k++) { uSqr = sqr(accumBuffer[3 * j + 1]) + sqr(accumBuffer[3 * j + 2]); dataBlock[k] *= (1 - OMEGA); dataBlock[k] += getFEq(accumBuffer[3 * j], accumBuffer[3 * j + 1], accumBuffer[3 * j + 2], uSqr, i) * OMEGA; } for (j = 0; k < srcBlockSize; j++, k++) { uSqr = sqr(accumBuffer[3 * j + 1]) + sqr(accumBuffer[3 * j + 2]); dataBlock[k] *= (1 - OMEGA); dataBlock[k] += getFEq(accumBuffer[3 * j], accumBuffer[3 * j + 1], accumBuffer[3 * j + 2], uSqr, i) * OMEGA; } } } void FastLattice2D::makePropagation() { const int blockSize = n_ * n_; for (int i = 0; i < Q; i++) { offsets_[i] += propD[i][0] + n_ * propD[i][1]; offsets_[i] %= blockSize; if (offsets_[i] < 0) offsets_[i] += blockSize; } accumBufferUpdated_ = false; } void FastLattice2D::step() { makeCollisions(); makePropagation(); } void FastLattice2D::updAccumBuffer() const { int srcBlockSize = n_ * n_; for (int j = 0; j < srcBlockSize; j++) { accumBuffer_[3 * j] = f_[j]; accumBuffer_[3 * j + 1] = (real_t)0.0; accumBuffer_[3 * j + 2] = (real_t)0.0; } for (int i = 1; i < Q; i++) { real_t propDX = (real_t)propD[i][0]; real_t propDY = (real_t)propD[i][1]; real_t* srcData = f_ + i * srcBlockSize; int j, k; for (j = offsets_[i], k = 0; j < srcBlockSize; j++, k++) { accumBuffer_[3 * j] += srcData[k]; accumBuffer_[3 * j + 1] += propDX * srcData[k]; accumBuffer_[3 * j + 2] += propDY * srcData[k]; } for (j = 0; k < srcBlockSize; j++, k++) { accumBuffer_[3 * j] += srcData[k]; accumBuffer_[3 * j + 1] += propDX * srcData[k]; accumBuffer_[3 * j + 2] += propDY * srcData[k]; } } for (int j = 0; j < srcBlockSize; j++) { accumBuffer_[3 * j + 1] /= accumBuffer_[3 * j]; accumBuffer_[3 * j + 2] /= accumBuffer_[3 * j]; } accumBufferUpdated_ = true; } const real_t* FastLattice2D::getData() const { if (!accumBufferUpdated_) updAccumBuffer(); return accumBuffer_; }
[ "mchouza@0a8d345c-bf43-11dd-919e-5d69a936ce07" ]
[ [ [ 1, 176 ] ] ]
e354c46f29450b0568248f578786a6a05b4c4368
f9ed86de48cedc886178f9e8c7ee4fae816ed42d
/src/models/pillar.h
dbfa8e950bc338d4b348e4368b7dd25505a529b3
[ "MIT" ]
permissive
rehno-lindeque/Flower-of-Persia
bf78d144c8e60a6f30955f099fe76e4a694ec51a
b68af415a09b9048f8b8f4a4cdc0c65b46bcf6d2
refs/heads/master
2021-01-25T04:53:04.951376
2011-01-29T11:41:38
2011-01-29T11:41:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,443
h
#ifndef __PILLAR_H__ #define __PILLAR_H__ class Pillar : public Model { public: GLuint displayList; virtual void build() { uint segments = 20; float pillarHeight = 9.4f; float pillars[][3] = { // left side {-20.0f, 0.8f, -20.0f}, {-20.0f, 0.8f, -12.0f}, {-20.0f, 0.8f, -4.0f}, {-12.0f, 0.8f, -4.0f}, {-20.0f, 0.8f, 4.0f}, {-12.0f, 0.8f, 4.0f}, //right side { 20.0f, 0.8f, -20.0f}, { 20.0f, 0.8f, -12.0f}, { 20.0f, 0.8f, -4.0f}, { 12.0f, 0.8f, -4.0f}, { 20.0f, 0.8f, 4.0f}, { 12.0f, 0.8f, 4.0f} }; float rads[] = { 0.5f, 0.7f, 0.75f, 0.7f, 0.4f, 0.5f, 0.3f }; float heights[] = { 0.45f, 0.6f, 0.75f, 0.9f, 1.05f, 1.25f, 1.35f }; displayList = glGenLists(1); glNewList(displayList, GL_COMPILE); glColor3f(0.6f, 0.5f, 0.4f); glPushMatrix(); glBindTexture(GL_TEXTURE_2D, textures.get(6)); glBegin(GL_QUADS); for(int c = 0; c < 12; c++) { extrudeYCylinder(pillars[c], segments, rads, heights, 6); drawYCylinder(Vector3(0.0f, heights[6], 0.0f) + pillars[c], rads[6], pillarHeight-heights[6]*2.0f, segments); extrudeReverseYCylinder(Vector3(0.0f, pillarHeight, 0.0f) + pillars[c], segments, rads, heights, 6); } glEnd(); //glBindTexture(GL_TEXTURE_2D, textures.get(0)); glBegin(GL_QUADS); for(int c = 0; c < 12; c++) { drawYBlock(pillars[c], 0.81f, heights[0]); drawReverseYBlock(Vector3(0.0f, pillarHeight, 0.0f) + pillars[c], 0.81f, -heights[0]); glBindTexture(GL_TEXTURE_2D, textures.get(6)); extrudeYCylinder(pillars[c], segments, rads, heights, 6); drawYCylinder(Vector3(0.0f, heights[6], 0.0f) + pillars[c], rads[6], pillarHeight-heights[6]*2.0f, segments); extrudeReverseYCylinder(Vector3(0.0f, pillarHeight, 0.0f) + pillars[c], segments, rads, heights, 6); /*removed4debug: BUG (THIS SEEMS TO CRASH!) glBindTexture(GL_TEXTURE_2D, textures.get(0));//*/ } glEnd(); glPopMatrix(); glColor3f(1.0f, 1.0f, 1.0f); glEndList(); } virtual void render() { //draw railing glCallList(displayList); } virtual void renderNormals() { } }; #endif
[ [ [ 1, 85 ] ] ]
5ee6155fb37de25f38c2e2c8d10ba69b1d139f68
4b116281b895732989336f45dc65e95deb69917b
/Code Base/GSP410-Project2/Renderable.h
23ba1039e60d77f7fd456098fae86b7c58c8bb0e
[]
no_license
Pavani565/gsp410-spaceshooter
1f192ca16b41e8afdcc25645f950508a6f9a92c6
c299b03d285e676874f72aa062d76b186918b146
refs/heads/master
2021-01-10T00:59:18.499288
2011-12-12T16:59:51
2011-12-12T16:59:51
33,170,205
0
0
null
null
null
null
UTF-8
C++
false
false
827
h
#pragma once #include <d3d9.h> #include <d3dx9.h> #include "Definitions.h" // pass a pointer of type Renderable to DXFrame to render our objects // also pass the number of objects to be rendered // in render, loop through all the objects drawing them to the screen // in LoadQuad we need to build the array of renderables and we need // to set the number of objects too. when one gets destroyed, we // change the number and the array. class CRenderable { public: // Sprite Information // virtual int GetTextureType(void) = 0; virtual RECT GetRect(void) = 0; virtual D3DXVECTOR3 GetCenter(void) = 0; virtual D3DCOLOR GetColor(void) = 0; // Transformation Information // virtual float GetScale(void) = 0; virtual float GetRotation(void) = 0; virtual D3DXVECTOR3 GetPosition(void) = 0; };
[ "[email protected]@7eab73fc-b600-5548-9ef9-911d97763ba7" ]
[ [ [ 1, 28 ] ] ]
4de00a64ed20eb951464299110fa8e492880b09d
1011fc798115b628a8f3b6612a34ca4c0b0b85c7
/src/CompletionPopup.cpp
ec39444148e73d468492d43cde748b86b20e89ad
[]
no_license
joeri/e
b2781991f1eaec2e6d549ee8d3ffdc4060ce13d5
e10f306a2c6c25e2cedd9b5139d164cc38c2bafc
refs/heads/master
2021-01-16T20:54:42.629110
2009-05-15T07:57:01
2009-05-15T07:57:01
190,426
2
0
null
null
null
null
UTF-8
C++
false
false
4,672
cpp
/******************************************************************************* * * Copyright (C) 2009, Alexander Stigsen, e-texteditor.com * * This software is licensed under the Open Company License as described * in the file license.txt, which you should have received as part of this * distribution. The terms are also available at http://opencompany.org/license. * * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * ******************************************************************************/ #include "CompletionPopup.h" #include "EditorCtrl.h" CompletionPopup::CompletionPopup(EditorCtrl& parent, const wxPoint& pos, const wxPoint& topPos, const wxString& target, const wxArrayString& completions) : wxDialog(&parent, wxID_ANY, wxEmptyString, pos, wxDefaultSize, wxNO_BORDER) { // Create ctrl CompletionList* clist = new CompletionList(*this, parent, target, completions); // Create Layout wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); mainSizer->Add(clist, 1, wxEXPAND); SetSizerAndFit(mainSizer); // Make sure that there is room for dialog const int screenHeight = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y); const wxSize size = GetSize(); if (pos.y + size.y > screenHeight) { Move(pos.x, topPos.y - size.y); } Show(); clist->SetFocus(); } BEGIN_EVENT_TABLE(CompletionList, wxListBox) EVT_KILL_FOCUS(CompletionList::OnKillFocus) EVT_CHAR(CompletionList::OnChar) EVT_LEFT_DOWN(CompletionList::OnLeftDown) END_EVENT_TABLE() CompletionList::CompletionList(wxDialog& parent, EditorCtrl& editorCtrl, const wxString& target, const wxArrayString& completions) : wxListBox(&parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, completions, wxSIMPLE_BORDER|wxLB_SINGLE|wxWANTS_CHARS), m_parentDlg(parent), m_editorCtrl(editorCtrl), m_target(target), m_completions(completions) { // editorCtrl has text cursor as default SetCursor(wxCursor(wxCURSOR_ARROW)); // We want the editorCtrl to keep showing the caret m_editorCtrl.KeepCaretAlive(); Show(); if (!completions.IsEmpty()) SetSelection(0); } CompletionList::~CompletionList() { // Restore editorCtrls caret handling m_editorCtrl.KeepCaretAlive(false); } void CompletionList::OnKillFocus(wxFocusEvent& WXUNUSED(event)) { EndCompletion(); } void CompletionList::OnLeftDown(wxMouseEvent& event) { const int hit = HitTest(event.GetPosition()); if (hit != wxNOT_FOUND) { const wxString& word = GetString(hit); m_editorCtrl.ReplaceCurrentWord(word); m_editorCtrl.ReDraw(); EndCompletion(); } } void CompletionList::OnChar(wxKeyEvent& event) { const int keyCode = event.GetKeyCode(); switch (keyCode) { case WXK_UP: case WXK_DOWN: case WXK_PAGEUP: case WXK_PAGEDOWN: // Let the control itself handle up/down event.Skip(); return; case WXK_SPACE: if (event.ControlDown()) { // Cycle through options unsigned int sel = GetSelection(); ++sel; if (sel == GetCount()) sel = 0; SetSelection(sel); return; } // Fallthrough case WXK_TAB: case WXK_RETURN: // Select { const int sel = GetSelection(); if (sel != wxNOT_FOUND) { const wxString& word = GetString(sel); m_editorCtrl.ReplaceCurrentWord(word); if (keyCode == WXK_SPACE) { m_editorCtrl.InsertChar(wxT(' ')); } m_editorCtrl.ReDraw(); } EndCompletion(); } return; case WXK_ESCAPE: EndCompletion(); return; } // Pass event on to editorCtrl m_editorCtrl.ProcessEvent(event); // Adapt list to new target const wxChar key = event.GetUnicodeKey(); if (wxIsalnum(key) || key == wxT('_') || keyCode == WXK_BACK) { Update(); } else EndCompletion(); // end completion } void CompletionList::Update() { const wxString target = m_editorCtrl.GetCurrentWord(); if (target.empty()) EndCompletion(); else { if (target.StartsWith(m_target)) { // Shrink the list to match new word wxArrayString completions; for (unsigned int i = 0; i < m_completions.GetCount(); ++i) { const wxString& word = m_completions[i]; if (word.StartsWith(target)) completions.Add(word); } SetCompletions(completions); } else { // Build new completion list m_target = target; m_completions = m_editorCtrl.GetCompletionList(); SetCompletions(m_completions); } } } void CompletionList::SetCompletions(const wxArrayString& completions) { if (completions.IsEmpty()) EndCompletion(); else { Clear(); InsertItems(completions, 0); SetSelection(0); } }
[ [ [ 1, 168 ] ] ]
4d5d3f2d78b1a71b1e21324dcbb4a286ccb6b37e
0b66a94448cb545504692eafa3a32f435cdf92fa
/tags/cms/cbear.berlios.de/windows/com/uint.hpp
3873888303d11e8765782721f608c25f86f082bf
[ "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
341
hpp
#ifndef CBEAR_BERLIOS_DE_WINDOWS_COM_UINT_HPP_INCLUDED #define CBEAR_BERLIOS_DE_WINDOWS_COM_UINT_HPP_INCLUDED #include <cbear.berlios.de/windows/com/traits.hpp> namespace cbear_berlios_de { namespace windows { namespace com { CBEAR_BERLIOS_DE_WINDOWS_COM_DECLARE_DEFAULT_TRAITS(uint_t, vartype_t::uint); } } } #endif
[ "sergey_shandar@e6e9985e-9100-0410-869a-e199dc1b6838" ]
[ [ [ 1, 19 ] ] ]
f0b2d468eba332b75c141ea67741cbbc573feb79
477cd2cf408d0367d15beddfc53795dfbfbc0b53
/OSCPlugin/Source/IniReader.h
4c2b24c299dc3b40ce7dacd4bf42fe74cf0374d9
[]
no_license
argl/eternal-track-cycle
14e8763f95ca483474f5a1453f87f217ee3b6c08
17aef4af7cdee62d50a6df7331b9fda6124831a8
refs/heads/master
2016-09-01T22:52:56.344931
2010-06-15T16:04:48
2010-06-15T16:04:48
606,870
1
0
null
null
null
null
UTF-8
C++
false
false
530
h
#ifndef INIREADER_H #define INIREADER_H class CIniReader { public: CIniReader(const char* szFileName) ; int ReadInteger(const char* szSection, const char* szKey, int iDefaultValue) ; float ReadFloat(const char* szSection, const char* szKey, float fltDefaultValue) ; bool ReadBoolean(const char* szSection, const char* szKey, bool bolDefaultValue) ; char* ReadString(const char* szSection, const char* szKey, const char* szDefaultValue) ; private: char m_szFileName[ MAX_PATH + 1 ]; }; #endif//INIREADER_H
[ [ [ 1, 17 ] ] ]
968c805c2bb9618cbce0a4a79c317bdeb692c070
27d5670a7739a866c3ad97a71c0fc9334f6875f2
/CPP/Modules/include/NavServerComEnums.h
a31ccee6154276714044dea767ff5205d023cff5
[ "BSD-3-Clause" ]
permissive
ravustaja/Wayfinder-S60-Navigator
ef506c418b8c2e6498ece6dcae67e583fb8a4a95
14d1b729b2cea52f726874687e78f17492949585
refs/heads/master
2021-01-16T20:53:37.630909
2010-06-28T09:51:10
2010-06-28T09:51:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
30,181
h
/* Copyright (c) 1999 - 2010, Vodafone Group Services Ltd 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 Vodafone Group Services Ltd 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT HOLDER OR CONTRIBUTORS 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. */ #ifndef NAVSERVERCOMENUMS_H #define NAVSERVERCOMENUMS_H namespace isab{ namespace NavServerComEnums{ /* These values are the ones used between the server and */ /* the navigator and should not be confused with the */ /* internal values or the values used between navigator */ /* and PDA. */ enum SearchType { SEARCH_TYPE_NORMAL = 0, SEARCH_TYPE_ROUTE, }; /// Used in search requests to specify what kind of /// overviewmatches we want enum LocationSearchType{ /// A municipal. SEARCH_MUNICIPAL = 0x20, /// A built up area. SEARCH_BUILT_UP_AREA = 0x40, /// A part of a city. SEARCH_CITY_PART = 0x80, /// A zip code area. SEARCH_ZIP_CODE = 0x100, /// A named zip area. SEARCH_ZIP_AREA = 0x200, }; /// Used in search requests to specify what kind of matches we want. enum MatchSearchType{ /// A street. SEARCH_STREET = 0x01, /// A point of interest. SEARCH_POI = 0x02, /// A category, expand to get categories or companies if leaf /// of category tree. SEARCH_CATEGORY = 0x04, /// A different type of item. Currently parks, lakes and some more. SEARCH_MISC = 0x08, }; /// Generate route for what? enum VehicleType { /// Passenger car. passengerCar = 0x01, // Pedestrian. pedestrian = 0x02, /// Emergency vehicle. emergencyVehicle = 0x03, /// Taxi. taxi = 0x04, /// Public bus. publicBus = 0x05, // Delivery truck. deliveryTruck = 0x06, /// Transport truck. transportTruck = 0x07, /// Car with more than 2 passengers. highOccupancyVehicle = 0x08, /// Bicycle. bicycle = 0x09, /// Public transportation. publicTransportation = 0x0a, /// invalid, let the server decide. invalidVehicleType = 0xff }; /// Optimize route for what? enum RouteCostType { /// DISTANCE, optimize length of route. DISTANCE = 0, /// TIME, optimize time of route. TIME = 1, /** * TIME_WITH_DISTURBANCES, optimize time of route with * disturbances. */ TIME_WITH_DISTURBANCES = 2, ///Invalid, let the server decide. INAVLID = 0xff }; /// How to handle toll roads enum RouteTollRoads { TollRoadsAllow = 0, TollRoadsDeny = 1, }; /// How to handle highways enum RouteHighways { HighwaysAllow = 0, HighwaysDeny = 1, }; ///How fleshed out route to send back. enum routeType { ///Preferred by the GPS-less mode. Sends enough ///information that an itinerary can be generated by ///the client. slim = 1, ///Preferred by the GPS mode. Plenty of coordinates ///ensures good route following, distance and time to ///goal calculation, and off track detection. full = 2, }; /** Enumerates the reasons for a reroute. */ enum RerouteReason { /** */ unknown = 0, /** The route was truncated, the next piece is needed. */ truncated_route = 1, /** The user went off track and needs a new route.*/ off_track = 2, /** The route should be updated with new traffic info. */ traffic_info_update = 3, /** The user requested a reroute. */ user_request = 4, }; /// Used in search requests to specify different kinds of matching. enum MatchType { /// All letters must match but match may contain more letters. ExactMatch = 0x00, /// Close match. CloseMatch = 0x01, /// All letter must match and length of string miust be same. FullMatch = 0x02, /// Match things that sounds alike. PhoneticMatch = 0x03, /// Match strings allowing for a few misspellings. EditdistanceMatch = 0x04, }; /// Used in search requests to specify the type of word mathing to use. enum WordMatchType { Beginning = 0x00, /// Starts matching at begining of string. Anywhere = 0x01, /// String may match anywhere in match. }; /// Used in search requests to specify sort order of search matches. enum SortTypes { /// The result will not be sorted. NoSort = 0x00, /// Matches are sorted in alphabetical order. AlfaSort = 0x01, /// Matches are sorted by confidence, attempting to place the /// most probable matches on top of the match list. ConfidenceSort = 0x02, /// Matches are sorted by their distance from the current coordinate. DistanceSort = 0x04, }; ///Language for replies from server. enum languageCode { ENGLISH = 0, /// English SWEDISH = 1, /// Swedish GERMAN = 2, /// German DANISH = 3, /// Danish FINNISH = 4, /// Finnish NORWEGIAN = 5, /// Norwegian ITALIAN = 6, /// Italian DUTCH = 7, /// Dutch SPANISH = 8, /// Spanish FRENCH = 9, /// French WELCH = 10, /// Welsh PORTUGUESE = 11, /// Portuguese CZECH = 12, /// Czech AMERICAN_ENGLISH = 13, /// American English HUNGARIAN = 14, /// Hungarian GREEK = 15, /// Greek POLISH = 16, /// Polish SLOVAK = 17, /// Slovak RUSSIAN = 18, /// Russian SLOVENIAN = 19, /// Slovenian TURKISH = 20, /// Turkish ARABIC = 21, /// Arabic SWISS_FRENCH = 22, SWISS_GERMAN = 23, ICELANDIC = 24, BELGIAN_FLEMISH = 25, AUSTRALIAN_ENGLISH = 26, BELGIAN_FRENCH = 27, AUSTRIAN_GERMAN = 28, NEW_ZEALAND_ENGLISH= 29, CHINESE_TAIWAN = 30, CHINESE_HONG_KONG = 31, CHINESE_PRC = 32, JAPANESE = 33, THAI = 34, AFRIKAANS = 35, ALBANIAN = 36, AMHARIC = 37, ARMENIAN = 38, TAGALOG = 39, BELARUSIAN = 40, BENGALI = 41, BULGARIAN = 42, BURMESE = 43, CATALAN = 44, CROATIAN = 45, CANADIAN_ENGLISH = 46, SOUTH_AFRICAN_ENGLISH=47, ESTONIAN = 48, FARSI = 49, CANADIAN_FRENCH = 50, GAELIC = 51, GEORGIAN = 52, GREEK_CYPRUS = 53, GUJARATI = 54, HEBREW = 55, HINDI = 56, INDONESIAN = 57, IRISH = 58, SWISS_ITALIAN = 59, KANNADA = 60, KAZAKH = 61, KHMER = 62, KOREAN = 63, LAO = 64, LATVIAN = 65, LITHUANIAN = 66, MACEDONIAN = 67, MALAY = 68, MALAYALAM = 69, MARATHI = 70, MOLDOVIAN = 71, MONGOLIAN = 72, NYNORSK = 73, BRAZILIAN_PORTUGUESE=74, PUNJABI = 75, ROMANIAN = 76, SERBIAN = 77, SINHALESE = 78, SOMALI = 79, LATIN_AMERICAN_SPANISH=80, SWAHILI = 81, FINNISH_SWEDISH = 82, TAMIL = 83, TELUGU = 84, TIBETAN = 85, TIGRINYA = 86, CYPRUS_TURKISH = 87, TURKMEN = 88, UKRAINIAN = 89, URDU = 90, VIETNAMESE = 91, ZULU = 92, SESOTHO = 93, BASQUE = 94, GALICIAN = 95, ASIA_PACIFIC_ENGLISH=96, TAIWAN_ENGLISH = 97, HONG_KONG_ENGLISH = 98, CHINA_ENGLISH = 99, JAPAN_ENGLISH = 100, THAI_ENGLISH = 101, ASIA_PACIFIC_MALAY = 102, }; ///Common request status codes. enum ReplyStatus { /// All is well NAV_STATUS_OK = 0x00, /// Something is not that well NAV_STATUS_NOT_OK = 0x01, /// Server internal timeout NAV_STATUS_REQUEST_TIMEOUT = 0x02, /// Server didn't receive parameter request as first request /// in the session. NAV_STATUS_PARAM_REQ_NOT_FIRST = 0x03, /// The server doesn't have map coverage of that area. NAV_STATUS_OUTSIDE_MAP = 0x04, /// The server doesn't understand that protocol version NAV_STATUS_PROTOVER_NOT_SUPPORTED= 0x05, /// The user hasn't payed for that map. NAV_STATUS_OUTSIDE_ALLOWED_AREA = 0x06, /// The user have no transactions left. NAV_STATUS_NO_TRANSACTIONS_LEFT = 0x07, // Unauthorized and other user has this phone's license NAV_STATUS_UNAUTH_OTHER_HAS_LICENSE=0x17, // The error is in the extened error code. NAV_STATUS_EXTENDED_ERROR = 0x18, /// Used to mask request specific status codes. NAV_STATUS_REQUEST_SPECIFIC_MASK = 0x80, }; #define REQUEST_SPECIFIC NAV_STATUS_REQUEST_SPECIFIC_MASK ///Request specific status messages for poll requests enum PollReplyStatus { POLL_SERVER_FINAL = (0x02|REQUEST_SPECIFIC) }; ///Request specific status messages for parameter requests enum ParamReplyStatus { ///User login is ok but subscription is expired. Tell user to ///pay on time every time. PARAM_REPLY_EXPIRED_USER = (0x01|REQUEST_SPECIFIC), ///User login not ok, wrong password or invalid MSISDN and ///key pair. PARAM_REPLY_UNAUTHORIZED_USER=(0x02|REQUEST_SPECIFIC), ///Server moved, connect to it instead. Server list is in ///parametrers. PARAM_REPLY_REDIRECT = (0x03|REQUEST_SPECIFIC), ///Client must upgrade! Send new Parameter Request with ///update parameter. PARAM_REPLY_UPDATE_NEEDED = (0x04|REQUEST_SPECIFIC), ///Client says it is of a higher Wayfinder type than the ///server allows it to be. PARAM_REPLY_WF_TYPE_TOO_HIGH = (0x05|REQUEST_SPECIFIC), /// Other has your IMEI PARAM_REPLY_UNAUTH_OTHER_HAS_LICENSE = (0x17 | REQUEST_SPECIFIC), CHANGED_LICENSE_REPLY_OLD_LICENSE_NOT_IN_ACCOUNT = 0xF1, CHANGED_LICENSE_REPLY_MANY_USERS_WITH_OLD_LICENSE = 0xF2, CHANGED_LICENSE_REPLY_MANY_USERS_WITH_NEW_LICENSE = 0xF3, CHANGED_LICENSE_REPLY_OLD_LICENSE_IN_OTHER_ACCOUNT = 0xF4, UPGRADE_REPLY_MUST_CHOOSE_REGION = 0xFA, }; ///Request specific status messages for route requests enum RouteReplyStatus { ///No route could be found to the destination. ROUTE_REPLY_NO_ROUTE_FOUND = (0x01|REQUEST_SPECIFIC), ///Route is too far to go for the vehicle used. Mostly used ///for pedestrian routes that are too long. ROUTE_REPLY_TOO_FAR_FOR_VEHICLE = (0x02|REQUEST_SPECIFIC), ///Can not make out origin. ROUTE_REPLY_PROBLEM_WITH_ORIGIN = (0x03|REQUEST_SPECIFIC), ///Can not make out destination. ROUTE_REPLY_PROBLEM_WITH_DEST = (0x04|REQUEST_SPECIFIC), ///No auto destination and auto destination used as ///destination. ROUTE_REPLY_NO_AUTO_DEST = (0x05|REQUEST_SPECIFIC), ROUTE_REPLY_NO_ORIGIN = (0x06|REQUEST_SPECIFIC), ROUTE_REPLY_NO_DESTINATION = (0x07|REQUEST_SPECIFIC), //This status may be returned by reroute requests. If it is //set, it means that the route has not changed and the client //should keep using the old route. ROUTE_REPLY_NO_ROUTE_CHANGE = (0x08|REQUEST_SPECIFIC), }; /** 32bit values specifing the type of binary data tranferred * between the client and the server. Specified in the * 'Binary Transfers to the Navigator Server' document. * These enums comply with version 1.00 of that protocol. */ enum BinaryTransferType { CrossingMapData = 0x10, /// Crossing maps SyncFavoritesRequest = 0x11, /// Destination sync MapData = 0x12, /// ??? TopRegionListData = 0x13, /// Top Region list CategoriesFile = 0x15, LatestNewsFile = 0x16, LogfileData = 0x20, /// ??? }; ///Current status of server communication session. Used in ///statusreportmessages. enum ComStatus{ /** Invalid. */ invalid = 0, /** connecting to server. */ connecting, /** connected to server. */ connected, /** Sending data to server. */ sendingData, /** Downloading data from server. */ downloadingData, /** Session complete, shutting down connection. */ done, /** Connection disrupted. */ disconnectionError, /** unknown error caused the session to terminate.*/ unknownError, /** No data has been received for a while. */ connectionTimedOut, /// Sentinel value. numberOfStatuses, }; enum TransactionType{ transactions = 0, daysLeftTransactions = 2, }; #ifdef I_AM_DISPLAY_SERIAL_AND_IN_DIRE_NEED_OF_OUTDATED_ENUMS enum NavOutError { /* Phone call could not be made (busy, no answer etc) */ nav_out_no_carrier = 0x0, /** Navigator server said "route not ok". */ nav_out_not_ok_route_req = 0x1, /** Navigator server said "where am I not ok". */ nav_out_not_ok_where_am_i_req = 0x2, /** Navigator server said "Search not ok". */ nav_out_not_ok_search_req = 0x3, /** Server could not sync destinations. */ nav_out_not_ok_sync_destinations_req = 0x4, /** No phone connected. */ nav_out_no_phone = 0x5, /** GPS quality too low. */ nav_out_no_gps = 0x6, /** Other error. */ nav_out_other_error = 0x7, /** Protocol error. */ nav_pda_protocol_error = 0x8, /** The GPS positions are nowhere near the route, * we can't even check the distance to the closest point... */ nav_out_outside_route_area = 0x10, /** Unknown packet from PDA. */ nav_out_unknown_packet = 0x11, /* Unexpected DATA_CHUNK packet from PDA. */ nav_out_unexpected_data_chunk = 0x12, /* Start tunnel setup failed. */ nav_out_start_tunnel_fail = 0x13, /* Binary upload failed in some way. */ nav_out_binary_upload_fail = 0x14, /*------- Phone status (may arrive at any time) */ /** No phone was connected to navigator, or phone went away. */ STATUS_NO_PHONE = 0x20, // Error /** Sim card not inserted in phone, or sim revoked. */ STATUS_NO_SIM_CARD = 0x21, // Error /** Weak signal to GSM network. */ STATUS_PHONE_NO_NET = 0x22, // Error /*------- From phone when trying to connect */ /** Phone is not answering to commands */ STATUS_PHONE_NOT_RESPONDING = 0x23, // Error /** Phone is off hook (call in progress) */ STATUS_PHONE_NOT_IDLE = 0x24, // Error /** Server modem was busy. */ STATUS_PHONE_BUSY_SIGNAL = 0x25, // Error /** Server modem does not answer. */ STATUS_PHONE_NO_ANSWER = 0x26, // Error /** Phone is now available. */ STATUS_PHONE_READY = 0x27, /** Dialling number. */ STATUS_PHONE_DIALING = 0x28, /** Connecting to modem */ STATUS_PHONE_CONNECTING = 0x29, /** Modem connection established. */ STATUS_PHONE_CONNECTED = 0x2a, /** No data for a long time in online mode */ STATUS_PHONE_NO_DATA = 0x2b, // Error /** Disconnecting from remote modem. */ STATUS_PHONE_DISCONNECTING = 0x2c, /*------ From Navigator when trying to connect. */ /** Sending data to server */ STATUS_NSC_SENDING_REQUEST = 0x40, /** Waiting for server answer. */ STATUS_NSC_WAITING_FOR_ANSWER = 0x41, /** Receving data from server. */ STATUS_NSC_RECEIVING_ANSWER = 0x42, /** Call disconnected before we got all data in answer */ STATUS_NSC_TRUNCATED_ANSWER = 0x43, // Error /** Server timed out without answer. */ STATUS_NSC_TIMEOUT_SERVER = 0x44, // Error /** Phone timed out when sending. */ STATUS_NSC_TIMEOUT_PHONE = 0x45, // Error /*------ From Navigator Server */ /** Username or password was wrong */ STATUS_NS_AUTH_FAIL_LOGIN = 0x60, // Error /** The server is not allowing logins. */ STATUS_NS_AUTH_FAIL_FORBIDDEN = 0x61, // Error /** The account was closed by ISAB */ STATUS_NS_AUTH_CLOSED_ACCOUNT = 0x62, // Error /** Server version is incompatible with client. */ STATUS_NS_SERVER_VERSION_INCOMPATIBLE = 0x63,// Error /** New version of client is available. */ STATUS_NS_NEW_CLIENT_AVAILABLE = 0x64, /*------- The below errors should never reach the client. */ nav_out_ok_sync_destinations_req = 0x80, nav_out_ok_search_req = 0x81, nav_out_ok_where_am_i_req = 0x82, nav_out_ok_route_req = 0x83, nav_out_server_status_ok = 0x84, nav_out_server_status_not_ok = 0x85, nav_out_send_download_data = 0xfd, nav_out_message = 0xfe, nav_out_no_error = 0xff, }; /** List of errors possible when doing server communication? */ enum NavErrorType { nav_error_type_no_error = 0x0, /* GPS quality does not admit request. */ nav_error_type_no_gps = 0x1, /* Phone not connected. */ nav_error_type_no_phone = 0x2, /* Server does not even pick up phone. */ nav_error_type_no_server_answer = 0x3, /* Server picks up phone but does not answer requests. */ nav_error_type_no_server_connection = 0x4, /* Route download was interrupted. */ nav_error_type_route_download = 0x5, /* Route downloaded but format was wrong. */ nav_error_type_route_format = 0x6, /* The navigator server could not route. */ nav_error_type_routeing = 0x7, /* Search download was interrupted. */ nav_error_type_search_download = 0x8, /* Search downloaded but format was wrong. */ nav_error_type_search_format = 0x9, /* The navigator server could not search. */ nav_error_type_searching = 0xa, /* Where am I download interrupted. */ nav_error_type_where_am_i_download = 0xb, /* Where am I downloaded but format was wrong. */ nav_error_type_where_am_i_format = 0xc, /* The navigator server could not perform the Where am I action. */ nav_error_type_where_am_i = 0xd, /* Reply from server was too large. */ nav_error_type_reply_too_large = 0xe, /* Call was disconnected. */ nav_error_type_call_disconnected = 0xf, /* The GPS positions are nowhere near the route, */ /* we can't even check the distance to the closest point... */ nav_error_type_outside_route_area = 0x10, /* Unknown packet from PDA. */ nav_error_type_unknown_packet = 0x11, /** Not really an error, canceled on request. */ nav_error_type_canceled_on_request = 0x12, /* Memory problems, no buffers, bugs etc. */ nav_error_type_internal_nav_display_serial = 0x80, nav_error_type_internal_nav_ctrl = 0x81, nav_error_type_internal_nav_task = 0x82, nav_error_type_internal_nav_server_com = 0x83, nav_error_type_internal_plexor = 0x84, nav_error_type_internal_driv_phone_eri520 = 0x85, }; /** Enumeration of values in the status byte of server replies.*/ enum ServerStatus { /** All is well with the world. */ nav_server_status_ok = 0x0, /** Something went wrong. */ nav_server_status_not_ok = 0x1, /** This was the final poll reply. No more data available.*/ nav_server_status_poll_final = 0x2, /** Invalid. Used as placeholder when the error wasn't server related.*/ nav_server_invalid }; #endif /** The types of messages to send to and receive from the server.*/ enum MessageType{ /** Placeholder. */ NAV_SERVER_INVALID = 0x00, /** Unused. */ NAV_SERVER_PICK_ME_UP_REQ = 0x01, /** Unused. */ NAV_SERVER_PICK_ME_UP_REPLY = 0x02, /** Unused. */ NAV_SERVER_PICK_UP_REQ = 0x03, /** Unused. */ NAV_SERVER_PICK_UP_REPLY = 0x04, /** Request for a route. Sent from Navigator to Server.*/ NAV_SERVER_ROUTE_REQ = 0x05, /** A Reply for a route request. Sent from Server to Navigator. */ NAV_SERVER_ROUTE_REPLY = 0x06, /** A search request. Sent from Navigator to Server.*/ NAV_SERVER_SEARCH_REQ = 0x07, /** A Reply for a search request. Sent from Server to Navigator. */ NAV_SERVER_SEARCH_REPLY = 0x08, /** Request for destination synchronization. Presently not used. Sent from Navigator to Server.*/ NAV_SERVER_DEST_REQ = 0x09, /** A Reply to a destination synchronization request. Presently not used. Sent from Server to Navigator. */ NAV_SERVER_DEST_REPLY = 0x0a, /** Request for a convertion of gps coordinates to a real world address. Sent from Navigator to Server.*/ NAV_SERVER_GPS_ADDRESS_REQ = 0x0b, /** A Reply to a request for an address. Sent from Server to Navigator. */ NAV_SERVER_GPS_ADDRESS_REPLY = 0x0c, /** Request for navigator to receive one gps position poer second from the Navigator. Sent from Navigator to Server.*/ NAV_SERVER_GPS_POS_REQ = 0x0d, /** A Reply indicating whether the Server is ready to receive gps positions from the Navigator. Sent from Server to Navigator. */ NAV_SERVER_GPS_POS_REPLY = 0x0e, /** Request for more data from the server. Sent from the Navigator to the Server.*/ NAV_SERVER_POLL_SERVER_REQ = 0x10, /** Extra data from the Server. Sent from the Server to the Navigator. */ NAV_SERVER_POLL_SERVER_REPLY = 0x11, /** Request a map image from the server.*/ NAV_SERVER_MAP_REQ = 0x12, /** A map image from the server.*/ NAV_SERVER_MAP_REPLY = 0x13, /** Request Extra info about search items.*/ NAV_SERVER_INFO_REQ = 0x16, /** Contains Extra info about search items. */ NAV_SERVER_INFO_REPLY = 0x17, /** Asks server to send messages */ NAV_SERVER_MESSAGE_REQ = 0x18, /** Reply*/ NAV_SERVER_MESSAGE_REPLY = 0x19, /** Submit license key*/ NAV_SERVER_UPGRADE_REQ = 0x1a, /** Registration results. */ NAV_SERVER_UPGRADE_REPLY = 0x1b, /** Request Vector Map Chunk.*/ NAV_SERVER_VECTOR_MAP_REQ = 0x1c, /**Vector map chunk from server.*/ NAV_SERVER_VECTOR_MAP_REPLY = 0x1d, /** Request multiple Vector Maps from the server limited by * total size..*/ NAV_SERVER_MULTI_VECTOR_MAP_REQ = 0x1e, /** Multiple vector map reply. */ NAV_SERVER_MULTI_VECTOR_MAP_REPLY= 0x1f, /** Parameters from the Navigator and the NavClient to the server. Sent from Navigator to server.*/ NAV_SERVER_PARAMETER_REQ = 0x20, /** Parameters from the server to the Navigator. Sent from Server to Navigator. */ NAV_SERVER_PARAMETER_REPLY = 0x21, NAV_SERVER_CELL_REPORT = 0x22, NAV_SERVER_CELL_CONFIRM = 0x23, /** Request for GPS almanac. Sent from Navigator to server.*/ NAV_SERVER_GPS_INIT_REQ = 0x30, /** Reply with GPS almanac. Sent from Server to Navigator.*/ NAV_SERVER_GPS_INIT_REPLY = 0x31, /** Sending a binary block to the server. Sent from Navigator to server. */ NAV_SERVER_BINARY_UPLOAD_REQ = 0x32, /** Reply acknowledging a binary block. Sent from server to Navigator.*/ NAV_SERVER_BINARY_UPLOAD_REPLY = 0x33, /** Alarm information. Sent from Navigator to server. */ NAV_SERVER_ALARM_REQ = 0x40, /** Acknowledge of alarm info. Sent from server to navigator.*/ NAV_SERVER_ALARM_REPLY = 0x41, /** A NPG request */ NAV_REQUEST = 0x50, /** A NPG reply */ NAV_REPLY = 0x51, }; } } #endif
[ [ [ 1, 685 ] ] ]
5941eb4653445431e0cc913da4bbbbb96cf98445
a36fcac2b8224325125203475fedea5e8ee8af7d
/KnihaJazd/KnihaJazd.cpp
bd67a33d4a8da77bd38d512135f1fc9becd96a4e
[]
no_license
mareqq/knihajazd
e000a04dbed8417e32f8a1ba3dce59e35892e3bb
e99958dd9bed7cfda6b7e8c50c86ea798c4e754e
refs/heads/master
2021-01-19T08:25:50.761893
2008-05-26T09:11:56
2008-05-26T09:11:56
32,898,594
0
0
null
null
null
null
UTF-8
C++
false
false
1,432
cpp
#include "stdafx.h" #include "KnihaJazd.h" #include "KnihaJazdDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #endif BEGIN_MESSAGE_MAP(CKnihaJazdApp, CWinApp) ON_COMMAND(ID_HELP, &CWinApp::OnHelp) END_MESSAGE_MAP() CKnihaJazdApp::CKnihaJazdApp() { } CKnihaJazdApp theApp; BOOL CKnihaJazdApp::InitInstance() { // InitCommonControlsEx() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // Set this to include all the common control classes you want to use // in your application. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); // Call parent's InitInstance. CWinApp::InitInstance(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need // Change the registry key under which our settings are stored SetRegistryKey(_T("KnihaJazd")); // Zobrazenie nasho dialogu. CKnihaJazdDlg dlg; m_pMainWnd = &dlg; dlg.DoModal(); // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }
[ "mareqq@d4c424c1-354d-0410-9d05-3f146b4bb521" ]
[ [ [ 1, 49 ] ] ]
82c20e7443c15fc9b0ef2ae8a2fb14aa5289bd56
af127c40e6e0e408e66212fd28467ee380fa8bbf
/src/src/Info_usuario.cpp
808cfa09429281c82b6339b6b21129f6a1004e7f
[]
no_license
sergiomona89/qtInventory
a8e03abfa29aa1ca2410d3eb8dee72e5af4673f4
e1dc75ee7e0f3ba8107baf7c23e710a8c5b9e977
refs/heads/master
2021-01-19T16:37:00.695129
2011-06-07T03:36:05
2011-06-07T03:36:05
1,796,227
0
0
null
null
null
null
UTF-8
C++
false
false
565
cpp
#include "Usuario.h" #include "Info_usuario.h" Info_usuario::Info_usuario(Usuario &usr, QWidget *parent) : QWidget(parent) { setupUi(this); setUsuario(usr); connect(AceptarPushButton, SIGNAL(clicked(void)), this, SLOT(close())); } void Info_usuario::setUsuario(Usuario &usr) { IdLabel->setText(QString::number(usr.getId())); NombreLabel->setText(usr.getNombre()); CargoLabel->setText(usr.getCargo()); EmailLabel->setText(usr.getEmail()); TelefonoLabel->setText(QString::number(usr.getTelefono())); }
[ "[email protected]", "sergio.mona@lis-desktop.(none)" ]
[ [ [ 1, 1 ], [ 3, 22 ] ], [ [ 2, 2 ], [ 23, 23 ] ] ]
96da63a607715e24cca2434d76db6fad69dce5b4
7442395e399e1f544f8a08da82ac3659d0d7abf3
/src/exp.cpp
597bfd390a7dc34bfefce399e3f779b816bfd24b
[ "Apache-2.0" ]
permissive
MartinMReed/xenimus-calc-cplusplus
be7d848ddcf76320a90b971100e6e9344873e5b9
33f891c81ec03c35f43a8cb3e5f2b37a32088827
refs/heads/master
2016-09-06T11:30:58.601115
2006-06-22T16:38:00
2006-06-22T16:38:00
12,097,390
1
0
null
null
null
null
UTF-8
C++
false
false
4,384
cpp
/************************************************************************/ /** CPlusPlus Stat Calculator /** Xenimus Open Source Group /** /** Additons to this file: /** -[insert name] /** --[insert additions descriptions] /** /** Original copy by: /** Halloween (06/15/05 ) /** /** All previous names must stay included when making additions. /************************************************************************/ #include "stdafx.h" #include "calc.h" #include "calcDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif //------------------------------------------------------- // EXPERIENCE //------------------------------------------------------- LPCTSTR CCalcDlg::exp( int level ) { if ( level == 1 ) { return "0"; } else if ( level == 2 ) { return "200"; } else if ( level == 3 ) { return "1,000"; } else if ( level == 4 ) { return "2,000"; } else if ( level == 5 ) { return "4,000"; } else if ( level == 6 ) { return "7,000"; } else if ( level == 7 ) { return "12,000"; } else if ( level == 8 ) { return "22,000"; } else if ( level == 9 ) { return "35,000"; } else if ( level == 10 ) { return "50,000"; } else if ( level == 11 ) { return "70,000"; } else if ( level == 12 ) { return "100,000"; } else if ( level == 13 ) { return "150,000"; } else if ( level == 14 ) { return "250,000"; } else if ( level == 15 ) { return "450,000"; } else if ( level == 16 ) { return "750,000"; } else if ( level == 17 ) { return "1,250,000"; } else if ( level == 18 ) { return "1,750,000"; } else if ( level == 19 ) { return "2,250,000"; } else if ( level == 20 ) { return "2,750,000"; } else if ( level == 21 ) { return "3,500,000"; } else if ( level == 22 ) { return "4,250,000"; } else if ( level == 23 ) { return "5,000,000"; } else if ( level == 24 ) { return "6,000,000"; } else if ( level == 25 ) { return "7,000,000"; } else if ( level == 26 ) { return "8,000,000"; } else if ( level == 27 ) { return "10,000,000"; } else if ( level == 28 ) { return "12,000,000"; } else if ( level == 29 ) { return "14,500,000"; } else if ( level == 30 ) { return "17,000,000"; } else if ( level == 31 ) { return "19,500,000"; } else if ( level == 32 ) { return "22,000,000"; } else if ( level == 33 ) { return "25,000,000"; } else if ( level == 34 ) { return "28,000,000"; } else if ( level == 35 ) { return "32,000,000"; } else if ( level == 36 ) { return "37,000,000"; } else if ( level == 37 ) { return "42,000,000"; } else if ( level == 38 ) { return "48,000,000"; } else if ( level == 39 ) { return "54,000,000"; } else if ( level == 40 ) { return "60,000,000"; } else if ( level == 41 ) { return "67,000,000"; } else if ( level == 42 ) { return "74,000,000"; } else if ( level == 43 ) { return "82,000,000"; } else if ( level == 44 ) { return "90,000,000"; } else if ( level == 45 ) { return "98,000,000"; } else if ( level == 46 ) { return "108,000,000"; } else if ( level == 47 ) { return "118,000,000"; } else if ( level == 48 ) { return "130,000,000"; } else if ( level == 49 ) { return "150,000,000"; } else if ( level == 50 ) { return "160,000,000"; } else if ( level == 51 ) { return "180,000,000"; } else if ( level == 52 ) { return "200,000,000"; } else if ( level == 53 ) { return "230,000,000"; } else if ( level == 54 ) { return "260,000,000"; } else if ( level == 55 ) { return "290,000,000"; } else if ( level == 56 ) { return "320,000,000"; } else if ( level == 57 ) { return "350,500,000"; } else if ( level == 58 ) { return "400,000,000"; } else if ( level == 59 ) { return "450,000,000"; } else if ( level == 60 ) { return "500,000,000"; } else if ( level == 61 ) { return "600,000,000"; } else if ( level == 62 ) { return "700,000,000"; } else if ( level == 63 ) { return "800,000,000"; } else if ( level == 64 ) { return "1,000,000,000"; } else if ( level == 65 ) { return "1,200,000,000"; } else { return "?,???,???,???"; } }
[ [ [ 1, 228 ] ] ]
085fdceae42413847687e0e8e3a02da61c1599fb
b5ad65ebe6a1148716115e1faab31b5f0de1b493
/src/AranDx9/ResourceMan.cpp
0f4658bb3fc38a836f8cfc7ae8b4949f3737d4ff
[]
no_license
gasbank/aran
4360e3536185dcc0b364d8de84b34ae3a5f0855c
01908cd36612379ade220cc09783bc7366c80961
refs/heads/master
2021-05-01T01:16:19.815088
2011-03-01T05:21:38
2011-03-01T05:21:38
1,051,010
1
0
null
null
null
null
UTF-8
C++
false
false
2,682
cpp
#include "AranDx9PCH.h" #include "ResourceMan.h" #include "VideoMan.h" #include "ModelReader.h" IMPLEMENT_SINGLETON(ResourceMan) #ifndef _LogWrite #define _LogWrite(a,b) #endif ResourceMan::ResourceMan(void) { } ResourceMan::~ResourceMan(void) { unregisterAllModels(); } HRESULT ResourceMan::registerModel( MODELID id, const char* modelFileName ) { //TCHAR logMessage[128]; ModelMap::iterator it = m_models.find( id ); ModelMap::iterator itEnd = m_models.end(); if ( it == itEnd ) // registration valid (not exist already) { ModelReader* pModelReader = ModelReader::create(modelFileName, false); pModelReader->SetFileName( modelFileName ); m_models.insert( ModelMap::value_type( id, pModelReader ) ); //_stprintf_s( logMessage, TCHARSIZE(logMessage), _T("%s%s"), _T( "Model Loading: " ), modelFileName ); //_LogWrite( logMessage, LOG_OKAY ); return S_OK; } else { // already exist... //_stprintf_s( logMessage, TCHARSIZE(logMessage), _T("%s%s"), _T( "Model Loading: " ), modelFileName ); //_LogWrite( logMessage, LOG_FAIL ); return E_FAIL; } } HRESULT ResourceMan::unregisterModel( MODELID id ) { ModelMap::iterator it = m_models.find( id ); ModelMap::iterator itEnd = m_models.end(); if ( it != itEnd ) { delete it->second; m_models.erase( it ); return S_OK; } else { return E_FAIL; // not exist! } } int ResourceMan::initializeAll() { ModelMap::iterator it = m_models.begin(); ModelMap::iterator itEnd = m_models.end(); int initedCount = 0; initedCount = 0; for ( ; it != itEnd; ++it ) { ModelReader* pMR = it->second; if ( !pMR->IsInitialized() ) { HRESULT hr = E_FAIL; /* hr = pMR->Initialize( VideoMan::getSingleton().GetDev(), ARN_VDD::ARN_VDD_FVF, 0, 0, FALSE ); */ if ( FAILED( hr ) ) { _LogWrite( _T( "Model Loading Error!" ), LOG_FAIL ); return -1; } else { ARN_THROW_NOT_IMPLEMENTED_ERROR //pMR->AdvanceTime( 0.001f ); //++initedCount; } } } _LogWrite( _T( "Model Initialization" ), LOG_OKAY ); return S_OK; } HRESULT ResourceMan::unregisterAllModels() { while ( m_models.size() ) { ModelMap::iterator it = m_models.begin(); ModelReader* pMR = it->second; SAFE_DELETE( pMR ); m_models.erase(it); } return S_OK; } const ModelReader* ResourceMan::getModel( MODELID id ) const { ModelMap::const_iterator it = m_models.find( id ); ModelMap::const_iterator itEnd = m_models.end(); if ( it != itEnd ) { return it->second; } else { return 0; // not exist! } }
[ [ [ 1, 135 ] ] ]
05590d4a5a084520bf4bbaa009e1918b43ad1c16
1bbd5854d4a2efff9ee040e3febe3f846ed3ecef
/src/scrview/scrcollector.cpp
3f36c8a28f4ae78bdd7e54ef4c63bfa9f80c6a75
[]
no_license
amanuelg3/screenviewer
2b896452a05cb135eb7b9eb919424fe6c1ce8dd7
7fc4bb61060e785aa65922551f0e3ff8423eccb6
refs/heads/master
2021-01-01T18:54:06.167154
2011-12-21T02:19:10
2011-12-21T02:19:10
37,343,569
0
0
null
null
null
null
UTF-8
C++
false
false
722
cpp
#include "scrcollector.h" #include "client.h" #include "confirmpacket.h" ScrCollector::ScrCollector(QMutex* mutex, Client *client) { this->mutex = mutex; this->client = client; } void ScrCollector::run() { ConfirmPacket* packet = new ConfirmPacket(); stoped = false; mutex->lock(); while(!stoped) { mutex->lock(); //new data qDebug() << "Gavau ekrana size: " << (int)data->getScreen()->size(); client->sendPacket(*packet->makeAndGetPacket()); mutex->unlock(); mutex->lock(); } mutex->unlock(); delete packet; } void ScrCollector::newData(Screenshot* data) { delete this->data; this->data = data; }
[ "JuliusR@localhost", "j.salkevicius@localhost" ]
[ [ [ 1, 1 ], [ 4, 4 ], [ 29, 29 ] ], [ [ 2, 3 ], [ 5, 28 ] ] ]
4b7e4e249027ec1ed1ac276832eb4e9dc30c3142
c2abb873c8b352d0ec47757031e4a18b9190556e
/src/ogreIncludes/OgreMemoryAllocatedObject.h
d44ec26755f0048b8b9ee8f676142264400fe966
[]
no_license
twktheainur/vortex-ee
70b89ec097cd1c74cde2b75f556448965d0d345d
8b8aef42396cbb4c9ce063dd1ab2f44d95e994c6
refs/heads/master
2021-01-10T02:26:21.913972
2009-01-30T12:53:21
2009-01-30T12:53:21
44,046,528
0
0
null
null
null
null
UTF-8
C++
false
false
4,610
h
/* ----------------------------------------------------------------------------- This source file is part of OGRE (Object-oriented Graphics Rendering Engine) For the latest info, see http://www.ogre3d.org/ Copyright (c) 2000-2008 Torus Knot Software Ltd Also see acknowledgements in Readme.html This program 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 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, or go to http://www.gnu.org/copyleft/lesser.txt. You may alternatively use this source under the terms of a specific version of the OGRE Unrestricted License provided you have obtained such a license from Torus Knot Software Ltd --------------------------------------------------------------------------- */ #ifndef __AllocatedObject_H__ #define __AllocatedObject_H__ #include "OgrePrerequisites.h" // Anything that has done a #define new <blah> will screw operator new definitions up // so undefine #ifdef new # undef new #endif #ifdef delete # undef delete #endif namespace Ogre { /** Superclass for all objects that wish to use custom memory allocators when their new / delete operators are called. Requires a template parameter identifying the memory allocator policy to use (e.g. see StdAllocPolicy). */ template <class Alloc> class _OgreExport AllocatedObject { public: explicit AllocatedObject() { } ~AllocatedObject() { } /// operator new, with debug line info void* operator new(size_t sz, const char* file, int line, const char* func); void* operator new(size_t sz); /// placement operator new void* operator new(size_t sz, void* ptr); /// array operator new, with debug line info void* operator new[] ( size_t sz, const char* file, int line, const char* func ); void* operator new[] ( size_t sz ); void operator delete( void* ptr ); // only called if there is an exception in corresponding 'new' void operator delete( void* ptr, const char* , int , const char* ); void operator delete[] ( void* ptr ); void operator delete[] ( void* ptr, const char* , int , const char* ); }; /* Ugh, I wish I didn't have to do this. The problem is that operator new/delete are *implicitly* static. We have to instantiate them for each combination exactly once throughout all the compilation units that are linked together, and this appears to be the only way to do it. At least I can do it via templates. */ /// operator new, with debug line info template <class Alloc> void* AllocatedObject<Alloc >::operator new(size_t sz, const char* file, int line, const char* func) { return Alloc::allocateBytes(sz, file, line, func); } template <class Alloc> void* AllocatedObject<Alloc >::operator new(size_t sz) { return Alloc::allocateBytes(sz); } /// placement operator new template <class Alloc> void* AllocatedObject<Alloc >::operator new(size_t sz, void* ptr) { return ptr; } /// array operator new, with debug line info template <class Alloc> void* AllocatedObject<Alloc >::operator new[] ( size_t sz, const char* file, int line, const char* func ) { return Alloc::allocateBytes(sz, file, line, func); } template <class Alloc> void* AllocatedObject<Alloc >::operator new[] ( size_t sz ) { return Alloc::allocateBytes(sz); } template <class Alloc> void AllocatedObject<Alloc >::operator delete( void* ptr ) { Alloc::deallocateBytes(ptr); } // only called if there is an exception in corresponding 'new' template <class Alloc> void AllocatedObject<Alloc >::operator delete( void* ptr, const char* , int , const char* ) { Alloc::deallocateBytes(ptr); } template <class Alloc> void AllocatedObject<Alloc >::operator delete[] ( void* ptr ) { Alloc::deallocateBytes(ptr); } template <class Alloc> void AllocatedObject<Alloc >::operator delete[] ( void* ptr, const char* , int , const char* ) { Alloc::deallocateBytes(ptr); } } #endif
[ "seb.owk@37e2baaa-b253-11dd-9381-bf584fb1fa83" ]
[ [ [ 1, 151 ] ] ]
93bffe25ade1070b075c571a4fa8cfda4ca6fd95
6629f18d84dc8d5a310b95fedbf5be178b00da92
/SDK-2008-05-27/foobar2000/SDK/console.h
1809c2ceb202f315516664962f7f97952b836fb7
[]
no_license
thenfour/WMircP
317f7b36526ebf8061753469b10f164838a0a045
ad6f4d1599fade2ae4e25656a95211e1ca70db31
refs/heads/master
2021-01-01T17:42:20.670266
2008-07-11T03:10:48
2008-07-11T03:10:48
16,931,152
3
0
null
null
null
null
UTF-8
C++
false
false
1,445
h
#ifndef _CONSOLE_H_ #define _CONSOLE_H_ //! Namespace with functions for sending text to console. All functions are fully multi-thread safe, though they must not be called during dll initialization or deinitialization (e.g. static object constructors or destructors) when service system is not available. namespace console { void info(const char * p_message); void error(const char * p_message); void warning(const char * p_message); void info_location(const playable_location & src); void info_location(const metadb_handle_ptr & src); void print_location(const playable_location & src); void print_location(const metadb_handle_ptr & src); void print(const char*); void printf(const char*,...); void printfv(const char*,va_list p_arglist); //! Usage: console::formatter() << "blah " << somenumber << " asdf" << somestring; class formatter : public pfc::string_formatter { public: ~formatter() {if (!is_empty()) console::print(get_ptr());} }; void complain(const char * what, const char * msg); void complain(const char * what, std::exception const & e); }; //! Interface receiving console output. Do not reimplement or call directly; use console namespace functions instead. class NOVTABLE console_receiver : public service_base { public: virtual void print(const char * p_message,t_size p_message_length) = 0; FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(console_receiver); }; #endif
[ "carl@72871cd9-16e1-0310-933f-800000000000" ]
[ [ [ 1, 37 ] ] ]
6adc77d9dc2e9b42f735587c3a1f986d772bd740
49c376677d3e8200b468ad25f3c73d234bdd7181
/ruby-handlersocket/handlersocket.cpp
13542bdde83190cc92fd1f4d3cf473b5c05530ec
[]
no_license
ColinDKelley/MyNoSql
6d4adb5f31deb98e045539582a25a22ef16e1ae9
88a002c787d349630094b6569539db833dc7479e
refs/heads/master
2021-01-18T04:35:40.191084
2010-11-19T07:34:43
2010-11-19T07:34:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
12,521
cpp
#include <handlersocket/hstcpcli.hpp> #include "handlersocket.h" namespace { void ary2vec(VALUE ary, std::vector<dena::string_ref>& vec) { int len = RARRAY_LEN(ary); for (int i = 0; i < len; i++) { VALUE entry = rb_ary_entry(ary, i); if (NIL_P(entry)) { vec.push_back(dena::string_ref()); } else { entry = rb_check_convert_type(entry, T_STRING, "String", "to_s"); char *s = StringValuePtr(entry); vec.push_back(dena::string_ref(s, strlen(s))); } } } struct HandlerSocket { dena::hstcpcli_i *tcpcli; static void free(HandlerSocket *p) { if (p->tcpcli) { delete p->tcpcli; } delete p; } static VALUE alloc(VALUE klass) { HandlerSocket *p; p = new HandlerSocket; p->tcpcli = NULL; return Data_Wrap_Struct(klass, 0, &free, p); } static VALUE initialize(int argc, VALUE *argv, VALUE self) { HandlerSocket *p; VALUE host, port, timeout, listen_backlog, verbose_level; rb_scan_args(argc, argv, "05", &host, &port, &timeout, &listen_backlog, &verbose_level); dena::config conf; if (NIL_P(host)) { conf["host"] = "localhost"; } else { Check_Type(host, T_STRING); conf["host"] = RSTRING_PTR(host); } if (NIL_P(port)) { conf["port"] = "9998"; } else { Check_Type(port, T_FIXNUM); port = rb_check_convert_type(port, T_STRING, "String", "to_s"); conf["port"] = StringValuePtr(port); } if (NIL_P(timeout)) { conf["timeout"] = "600"; } else { Check_Type(timeout, T_FIXNUM); timeout = rb_check_convert_type(timeout, T_STRING, "String", "to_s"); conf["timeout"] = StringValuePtr(timeout); } if (NIL_P(listen_backlog)) { conf["listen_backlog"] = "256"; } else { Check_Type(listen_backlog, T_FIXNUM); listen_backlog = rb_check_convert_type(listen_backlog, T_STRING, "String", "to_s"); conf["listen_backlog"] = StringValuePtr(listen_backlog); } if (!NIL_P(verbose_level)) { dena::verbose_level = NUM2INT(verbose_level); } dena::socket_args sargs; sargs.set(conf); dena::hstcpcli_ptr tcpcli_ptr = dena::hstcpcli_i::create(sargs); Data_Get_Struct(self, HandlerSocket, p); p->tcpcli = tcpcli_ptr.get(); tcpcli_ptr.release(); return Qnil; } static VALUE close(VALUE self) { HandlerSocket *p; Data_Get_Struct(self, HandlerSocket, p); Check_TcpCli(p); p->tcpcli->close(); return Qnil; } static VALUE reconnect(VALUE self) { HandlerSocket *p; Data_Get_Struct(self, HandlerSocket, p); Check_TcpCli(p); int retval = p->tcpcli->reconnect(); return INT2FIX(retval); } static VALUE stable_point(VALUE self) { HandlerSocket *p; Data_Get_Struct(self, HandlerSocket, p); Check_TcpCli(p); bool retval = p->tcpcli->stable_point(); return retval ? Qtrue : Qfalse; } static VALUE get_error_code(VALUE self) { HandlerSocket *p; Data_Get_Struct(self, HandlerSocket, p); Check_TcpCli(p); int retval = p->tcpcli->get_error_code(); return INT2FIX(retval); } static VALUE get_error(VALUE self) { HandlerSocket *p; Data_Get_Struct(self, HandlerSocket, p); Check_TcpCli(p); std::string s = p->tcpcli->get_error(); return rb_str_new(s.data(), s.size()); } static VALUE open_index(VALUE self, VALUE id, VALUE db, VALUE table, VALUE index, VALUE fields) { HandlerSocket *p; Data_Get_Struct(self, HandlerSocket, p); Check_TcpCli(p); Check_Type(id, T_FIXNUM); Check_Type(db, T_STRING); Check_Type(table, T_STRING); Check_Type(index, T_STRING); Check_Type(fields, T_STRING); do { p->tcpcli->request_buf_open_index( FIX2INT(id), RSTRING_PTR(db), RSTRING_PTR(table), RSTRING_PTR(index),RSTRING_PTR(fields)); if (p->tcpcli->request_send() != 0) { break; } size_t nflds = 0; p->tcpcli->response_recv(nflds); int e = p->tcpcli->get_error_code(); if (e >= 0) { p->tcpcli->response_buf_remove(); } } while (0); int retval = p->tcpcli->get_error_code(); return INT2FIX(retval); } static VALUE execute_single(int argc, VALUE *argv, VALUE self) { VALUE id, op, keys, limit, skip, modo, modvals; char *modop = NULL; rb_scan_args(argc, argv, "34", &id, &op, &keys, &limit, &skip, &modo, &modvals); if (NIL_P(limit)) { limit = INT2FIX(0); } if (NIL_P(skip)) { skip = INT2FIX(0); } if (!NIL_P(modo)) { Check_Type(modo, T_STRING); Check_Type(modvals, T_ARRAY); modop = RSTRING_PTR(modo); } return execute_internal(self, id, op, keys, limit, skip, modop, modvals); } static VALUE execute_multi(VALUE self, VALUE args) { return execute_multi_internal(self, args); } static VALUE execute_update(VALUE self, VALUE id, VALUE op, VALUE keys, VALUE limit, VALUE skip, VALUE modvals) { return execute_internal(self, id, op, keys, limit, skip, "U", modvals); } static VALUE execute_delete(VALUE self, VALUE id, VALUE op, VALUE keys, VALUE limit, VALUE skip) { return execute_internal(self, id, op, keys, limit, skip, "D", rb_ary_new()); } static VALUE execute_insert(VALUE self, VALUE id, VALUE fvals) { VALUE op = rb_str_new("+", 1); char *modop = NULL; return execute_internal(self, id, op, fvals, INT2FIX(0), INT2FIX(0), modop, Qnil); } static void init() { VALUE rb_cHandlerSocket = rb_define_class("HandlerSocket", rb_cObject); rb_define_alloc_func(rb_cHandlerSocket, &alloc); rb_define_method(rb_cHandlerSocket, "initialize", __F(&initialize), -1); rb_define_method(rb_cHandlerSocket, "close", __F(&close), 0); rb_define_method(rb_cHandlerSocket, "reconnect", __F(&reconnect), 0); rb_define_method(rb_cHandlerSocket, "stable_point", __F(&stable_point), 0); rb_define_method(rb_cHandlerSocket, "get_error_code", __F(&get_error_code), 0); rb_define_method(rb_cHandlerSocket, "get_error", __F(&get_error), 0); rb_define_method(rb_cHandlerSocket, "open_index", __F(&open_index), 5); rb_define_method(rb_cHandlerSocket, "execute_single", __F(&execute_single), -1); rb_define_method(rb_cHandlerSocket, "execute_find", __F(&execute_single), -1); rb_define_method(rb_cHandlerSocket, "execute_multi", __F(&execute_multi), 1); rb_define_method(rb_cHandlerSocket, "execute_update", __F(&execute_update), 6); rb_define_method(rb_cHandlerSocket, "execute_delete", __F(&execute_delete), 5); rb_define_method(rb_cHandlerSocket, "execute_insert", __F(&execute_insert), 2); } private: static VALUE execute_internal(VALUE self, VALUE v_id, VALUE v_op, VALUE v_keys, VALUE v_limit, VALUE v_skip, char *modop, VALUE v_modvals) { HandlerSocket *p; VALUE retval = Qnil; Data_Get_Struct(self, HandlerSocket, p); Check_TcpCli(p); Check_Type(v_id, T_FIXNUM); Check_Type(v_op, T_STRING); Check_Type(v_keys, T_ARRAY); Check_Type(v_limit, T_FIXNUM); Check_Type(v_skip, T_FIXNUM); do { dena::hstcpcli_i *tcpcli = p->tcpcli; int id = FIX2INT(v_id); dena::string_ref op = dena::string_ref(RSTRING_PTR(v_op), RSTRING_LEN(v_op)); std::vector<dena::string_ref> keyarr, mvarr; ary2vec(v_keys, keyarr); dena::string_ref modop_ref; if (modop) { modop_ref = dena::string_ref(modop, strlen(modop)); ary2vec(v_modvals, mvarr); } int limit = FIX2INT(v_limit); int skip = FIX2INT(v_skip); tcpcli->request_buf_exec_generic( id, op, &keyarr[0], keyarr.size(), limit, skip, modop_ref, &mvarr[0], mvarr.size()); if (tcpcli->request_send() != 0) { break; } size_t nflds = 0; tcpcli->response_recv(nflds); int e = tcpcli->get_error_code(); retval = rb_ary_new(); rb_ary_push(retval, INT2FIX(e)); if (e != 0) { std::string s = tcpcli->get_error(); rb_ary_push(retval, rb_str_new(s.data(), s.size())); } else { const dena::string_ref *row = 0; while ((row = tcpcli->get_next_row()) != 0) { for (size_t i = 0; i < nflds; i++) { const dena::string_ref& v = row[i]; if (v.begin() != 0) { VALUE s = rb_str_new(v.begin(), v.size()); rb_ary_push(retval, s); } else { rb_ary_push(retval, Qnil); } } } } if (e >= 0) { tcpcli->response_buf_remove(); } } while(0); return retval; } static VALUE execute_multi_internal(VALUE self, VALUE args) { HandlerSocket *p; VALUE rvs = Qnil; Data_Get_Struct(self, HandlerSocket, p); Check_TcpCli(p); Check_Type(args, T_ARRAY); dena::hstcpcli_i *tcpcli = p->tcpcli; size_t num_args = RARRAY_LEN(args); for (size_t args_index = 0; args_index < num_args; args_index++) { VALUE v_arg = rb_ary_entry(args, args_index); Check_Type(v_arg, T_ARRAY); VALUE v_id = rb_ary_entry(v_arg, 0); VALUE v_op = rb_ary_entry(v_arg, 1); VALUE v_keys = rb_ary_entry(v_arg, 2); VALUE v_limit = rb_ary_entry(v_arg, 3); VALUE v_skip = rb_ary_entry(v_arg, 4); VALUE v_modo = rb_ary_entry(v_arg, 5); VALUE v_modvals = rb_ary_entry(v_arg, 6); Check_Type(v_id, T_FIXNUM); Check_Type(v_op, T_STRING); Check_Type(v_keys, T_ARRAY); Check_Type(v_limit, T_FIXNUM); Check_Type(v_skip, T_FIXNUM); if (!NIL_P(v_modo)) { Check_Type(v_modo, T_STRING); Check_Type(v_modvals, T_ARRAY); } } for (size_t args_index = 0; args_index < num_args; args_index++) { VALUE v_arg = rb_ary_entry(args, args_index); VALUE v_id = rb_ary_entry(v_arg, 0); VALUE v_op = rb_ary_entry(v_arg, 1); VALUE v_keys = rb_ary_entry(v_arg, 2); VALUE v_limit = rb_ary_entry(v_arg, 3); VALUE v_skip = rb_ary_entry(v_arg, 4); VALUE v_modo = rb_ary_entry(v_arg, 5); VALUE v_modvals = rb_ary_entry(v_arg, 6); int id = FIX2INT(v_id); dena::string_ref op = dena::string_ref(RSTRING_PTR(v_op), RSTRING_LEN(v_op)); std::vector<dena::string_ref> keyarr, mvarr; ary2vec(v_keys, keyarr); dena::string_ref modop_ref; if (!NIL_P(v_modo)) { modop_ref = dena::string_ref(RSTRING_PTR(v_modo), RSTRING_LEN(v_modo)); ary2vec(v_modvals, mvarr); } int limit = FIX2INT(v_limit); int skip = FIX2INT(v_skip); tcpcli->request_buf_exec_generic( id, op, &keyarr[0], keyarr.size(), limit, skip, modop_ref, &mvarr[0], mvarr.size()); } rvs = rb_ary_new(); if (tcpcli->request_send() < 0) { VALUE retval = rb_ary_new(); rb_ary_push(rvs, retval); rb_ary_push(retval, INT2FIX(tcpcli->get_error_code())); const std::string& s = tcpcli->get_error(); rb_ary_push(retval, rb_str_new(s.data(), s.size())); return rvs; } for (size_t args_index = 0; args_index < num_args; args_index++) { VALUE retval = rb_ary_new(); rb_ary_push(rvs, retval); size_t nflds = 0; int e = tcpcli->response_recv(nflds); rb_ary_push(retval, INT2FIX(e)); if (e != 0) { const std::string& s = tcpcli->get_error(); rb_ary_push(retval, rb_str_new(s.data(), s.size())); } else { const dena::string_ref *row = 0; while ((row = tcpcli->get_next_row()) != 0) { for (size_t i = 0; i < nflds; i++) { const dena::string_ref& v = row[i]; if (v.begin() != 0) { VALUE s = rb_str_new(v.begin(), v.size()); rb_ary_push(retval, s); } else { rb_ary_push(retval, Qnil); } } } } if (e >= 0) { tcpcli->response_buf_remove(); } if (e < 0) { return rvs; } } return rvs; } }; } // namespace void Init_handlersocket() { HandlerSocket::init(); }
[ [ [ 1, 437 ] ] ]
8b8724d684f20ccd18de253e83c4c6ec273b8c30
478570cde911b8e8e39046de62d3b5966b850384
/apicompatanamdw/bcdrivers/os/shortlinksrv/Bluetooth/T_BTSdpAPI/src/T_DataSdpAttrValue.cpp
65fa879291c4dd9648f79176aa0f0082c77aeac8
[]
no_license
SymbianSource/oss.FCL.sftools.ana.compatanamdw
a6a8abf9ef7ad71021d43b7f2b2076b504d4445e
1169475bbf82ebb763de36686d144336fcf9d93b
refs/heads/master
2020-12-24T12:29:44.646072
2010-11-11T14:03:20
2010-11-11T14:03:20
72,994,432
0
0
null
null
null
null
UTF-8
C++
false
false
13,308
cpp
/* * Copyright (c) 2007 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: * */ #include "T_DataSdpAttrValue.h" #include "T_BTUtil.h" /*@{*/ //Parameters _LIT(KExpected, "expected"); _LIT(KExpectedRes, "expectedVisitorResult"); _LIT(KExpectedLL, "expectedLL"); _LIT(KExpectedLH, "expectedLH"); _LIT(KExpectedHL, "expectedHL"); _LIT(KExpectedHH, "expectedHH"); //Commands _LIT(KCmdAcceptVisitorL, "AcceptVisitorL"); _LIT(KCmdBool, "Bool"); _LIT(KCmdDataSize, "DataSize"); _LIT(KCmdDes, "Des"); _LIT(KCmdDoesIntFit, "DoesIntFit"); _LIT(KCmdInt, "Int"); _LIT(KCmdType, "Type"); _LIT(KCmdUint, "Uint"); _LIT(KCmdUUID, "UUID"); _LIT(KCmdMSAVV_ExtensionInterfaceL, "MSAVV_ExtensionInterfaceL"); /*@}*/ const TInt KAttrValueStringBufLen = 256; const TInt KVisitorResLen = 512; const TInt KMaxDataSize = 4; ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CT_DataSdpAttrValue::CT_DataSdpAttrValue() : iVisitorResult(new TUint16[KVisitorResLen],KVisitorResLen) { } /** * Process a command read from the ini file * * @param aCommand The command to process * @param aSection The section in the ini containing data for the command * @param aAsyncErrorIndex Command index for async calls to return errors to * * @return ETrue if the command is processed * * @leave System wide error */ TBool CT_DataSdpAttrValue::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/) { TBool ret = ETrue; if ( aCommand==KCmdAcceptVisitorL ) { DoCmdAcceptVisitor(aSection); } else if ( aCommand==KCmdBool ) { DoCmdBool(aSection); } else if ( aCommand==KCmdDataSize ) { DoCmdDataSize(aSection); } else if ( aCommand==KCmdDes ) { DoCmdDes(aSection); } else if ( aCommand==KCmdDoesIntFit ) { DoCmdDoesIntFit(aSection); } else if ( aCommand==KCmdInt ) { DoCmdInt(aSection); } else if ( aCommand==KCmdType ) { DoCmdType(aSection); } else if ( aCommand==KCmdUint ) { DoCmdUint(aSection); } else if ( aCommand==KCmdUUID ) { DoCmdUUID(aSection); } else if ( aCommand==KCmdMSAVV_ExtensionInterfaceL ) { DoCmdMSAVV_ExtensionInterfaceL(); } else { ret=EFalse; } return ret; } void CT_DataSdpAttrValue::DoCmdAcceptVisitor(const TDesC& aSection) { TRAPD(err, GetSdpAttrValue()->AcceptVisitorL(*this)); if ( err!=KErrNone ) { ERR_PRINTF2(_L("CSdpAttrValue::AcceptVisitorL failed with error %d"), err); SetError(err); return; } TPtrC expected; if(GetStringFromConfig(aSection, KExpectedRes(), expected)) { TPtr actual = GetVisitorResult(); INFO_PRINTF1(_L("Check result. Actual value:")); INFO_PRINTF1(actual); if(actual != expected) { INFO_PRINTF1(_L("CSdpAttrValue::AcceptVisitorL, Result is not as expected !")); SetBlockResult(EFail); } else { INFO_PRINTF1(_L("CSdpAttrValue::AcceptVisitorL, Result is correct !")); } } else { ERR_PRINTF2(_L("Missing expected value %S"), &KExpectedRes()); SetBlockResult(EFail); } } void CT_DataSdpAttrValue::DoCmdBool(const TDesC& aSection) { TBool actual = GetSdpAttrValue()->Bool(); INFO_PRINTF2(_L("CSdpAttrValue::Bool = %d"), actual); TBool expected; if ( GetBoolFromConfig(aSection, KExpected(), expected) ) { if ( actual!=expected ) { ERR_PRINTF1(_L("Bool is not as expected!")); SetBlockResult(EFail); } } else { ERR_PRINTF2(_L("Missing expected value %S"), &KExpected()); SetBlockResult(EFail); } } void CT_DataSdpAttrValue::DoCmdDataSize(const TDesC& aSection) { TUint actual = GetSdpAttrValue()->DataSize(); INFO_PRINTF2(_L("CSdpAttrValue::Size = %d"), actual); TInt expected; if (GetIntFromConfig(aSection, KExpected(), expected)) { if(actual!=expected ) { ERR_PRINTF1(_L("DataSize is not as expected!")); SetBlockResult(EFail); } } else { ERR_PRINTF2(_L("Missing expected value %S"), &KExpected()); SetBlockResult(EFail); } } void CT_DataSdpAttrValue::DoCmdDes(const TDesC& aSection) { TPtrC8 actual=GetSdpAttrValue()->Des(); HBufC* buffer=HBufC::NewLC(actual.Length()); TPtr bufferPtr=buffer->Des(); bufferPtr.Copy(actual); INFO_PRINTF1(_L("CSdpAttrValue::Des result:")); INFO_PRINTF1(bufferPtr); TPtrC expected; if ( GetStringFromConfig(aSection, KExpected(), expected) ) { if ( bufferPtr!=expected ) { ERR_PRINTF1(_L("Des is not as expected!")); SetBlockResult(EFail); } } else { ERR_PRINTF2(_L("Missing expected value %S"), &KExpected()); SetBlockResult(EFail); } CleanupStack::PopAndDestroy(buffer); } void CT_DataSdpAttrValue::DoCmdDoesIntFit(const TDesC& aSection) { TBool actual=GetSdpAttrValue()->DoesIntFit(); TBool expected; if ( GetBoolFromConfig(aSection, KExpected(), expected) ) { if ( actual!=expected ) { ERR_PRINTF1(_L("DoesIntFit is not as expected!")); SetBlockResult(EFail); } } else { ERR_PRINTF2(_L("Missing expected value %S"), &KExpected()); SetBlockResult(EFail); } } void CT_DataSdpAttrValue::DoCmdInt(const TDesC& aSection) { TInt actual = GetSdpAttrValue()->Int(); INFO_PRINTF2(_L("CSdpAttrValue::Int = %d"), actual); TInt expected; if ( GetIntFromConfig(aSection, KExpected(), expected) ) { if ( actual!=expected ) { ERR_PRINTF1(_L("Int is not as expected!")); SetBlockResult(EFail); } } else { ERR_PRINTF2(_L("Missing expected value %S"), &KExpected()); SetBlockResult(EFail); } } void CT_DataSdpAttrValue::DoCmdType(const TDesC& aSection) { TSdpElementType actual=GetSdpAttrValue()->Type(); INFO_PRINTF2(_L("CSdpAttrValue::Type = %d"), actual); TSdpElementType expected; if ( CT_BTUtil::ReadSdpElementType(*this, expected, aSection, KExpected()) ) { if ( actual!=expected ) { ERR_PRINTF1(_L("Type is not as expected!")); SetBlockResult(EFail); } } else { ERR_PRINTF1(_L("Missing expected value Type")); SetBlockResult(EFail); } } void CT_DataSdpAttrValue::DoCmdUint(const TDesC& aSection) { TInt actual = static_cast<TInt>(GetSdpAttrValue()->Uint()); INFO_PRINTF2(_L("CSdpAttrValue::Uint = %d"), actual); TInt expected; if ( GetIntFromConfig(aSection, KExpected(), expected) ) { if ( actual!=expected ) { ERR_PRINTF1(_L("Uint is not as expected!")); SetBlockResult(EFail); } } else { ERR_PRINTF2(_L("Missing expected value %S"), &KExpected()); SetBlockResult(EFail); } } void CT_DataSdpAttrValue::DoCmdUUID(const TDesC& aSection) { TBool ifexpectedExit = EFalse; TBool ifexpectedHHExit = EFalse; TBool ifexpectedHLExit = EFalse; TBool ifexpectedLHExit = EFalse; TBool ifexpectedLLExit = EFalse; TInt expected = 0; TInt expectedHH = 0; TInt expectedHL = 0; TInt expectedLH = 0; TInt expectedLL = 0; TUUID actualUUid = NULL; TInt actualIntUUid = NULL; actualUUid = GetSdpAttrValue()->UUID(); actualIntUUid = CT_BTUtil::ConvertUUID32toInt(actualUUid); if ( GetIntFromConfig(aSection, KExpected(), expected) ) { INFO_PRINTF2(_L("CSdpAttrValue::UUID call actual result: %d"), actualIntUUid); ifexpectedExit=ETrue; } else //to get four input values for 128-bit TUUID object { if ( GetIntFromConfig(aSection, KExpectedHH(), expectedHH)) { ifexpectedHHExit=ETrue; } else { ERR_PRINTF2(_L("Missing expected value %S"), &KExpectedHH()); SetBlockResult(EFail); } if ( GetIntFromConfig(aSection, KExpectedHL(), expectedHL)) { ifexpectedHLExit=ETrue; } else { ERR_PRINTF2(_L("Missing expected value %S"), &KExpectedHL()); SetBlockResult(EFail); } if ( GetIntFromConfig(aSection, KExpectedLH(), expectedLH)) { ifexpectedLHExit=ETrue; } else { ERR_PRINTF2(_L("Missing expected value %S"), &KExpectedLH()); SetBlockResult(EFail); } if ( GetIntFromConfig(aSection, KExpectedLL(), expectedLL)) { ifexpectedLLExit=ETrue; } else { ERR_PRINTF2(_L("Missing expected value %S"), &KExpectedLL()); SetBlockResult(EFail); } } if (ifexpectedExit) { if ( actualIntUUid!=expected ) { ERR_PRINTF1(_L("UUID is not as expected!")); SetBlockResult(EFail); } } else if(ifexpectedHHExit && ifexpectedHLExit && ifexpectedLHExit && ifexpectedLLExit)//to compare four values with input { INFO_PRINTF2(_L("expected Highest order word (HH bits 96 - 127): %d"), expectedHH); INFO_PRINTF2(_L("expected Second highest order word (HL bits 64 - 95): %d"), expectedHL); INFO_PRINTF2(_L("expected Second lowest order word (LH bits 32 - 63): %d"), expectedLH); INFO_PRINTF2(_L("expected Low order word (LL bits 0 - 31): %d"), expectedLL); TUUID expectedUUID(expectedHH,expectedHL,expectedLH,expectedLL); if ( actualUUid!=expectedUUID ) { ERR_PRINTF1(_L("128 bits of UUID is not as expected!")); SetBlockResult(EFail); } } } void CT_DataSdpAttrValue::VisitAttributeValueL(CSdpAttrValue& aValue, TSdpElementType aType) { INFO_PRINTF1(_L("MSdpAttributeValueVisitor VisitAttributeValueL Call")); HBufC16* string16 = HBufC16::NewLC(KAttrValueStringBufLen); switch (aType) { case ETypeNil: INFO_PRINTF1(_L("TSdpElementType is ETypeNil")); iVisitorResult.Append(_L("&type=Nil")); break; case ETypeUint: if( aValue.DataSize() <= (static_cast<TUint>(KMaxDataSize)) ) { INFO_PRINTF2(_L("TSdpElementType is ETypeUint. Value = %d"), aValue.Uint()); iVisitorResult.Append(_L("&type=Uint&value=")); iVisitorResult.AppendNum(aValue.Uint()); } else { string16->Des().Copy(aValue.Des()); TPtrC16 tprStringUint = string16->Des(); INFO_PRINTF1(_L("TSdpElementType is ETypeUint. Value = ")); INFO_PRINTF1(tprStringUint); iVisitorResult.Append(_L("&type=Uint&value=")); iVisitorResult.Append(tprStringUint); } break; case ETypeInt: INFO_PRINTF2(_L("TSdpElementType is ETypeInt. Value = %d"), aValue.Int()); iVisitorResult.Append(_L("&type=Int&value=")); iVisitorResult.AppendNum(aValue.Int()); break; case ETypeUUID: { TUUID uUid = aValue.UUID(); TUint intUUid= CT_BTUtil::ConvertUUID32toInt(uUid); INFO_PRINTF2(_L("TSdpElementType is ETypeUUID: Value is %d"),intUUid); iVisitorResult.Append(_L("&type=UUID&value=")); iVisitorResult.AppendNum(intUUid); } break; case ETypeString: { string16->Des().Copy(aValue.Des()); TPtrC16 tprString = string16->Des(); INFO_PRINTF1(_L("TSdpElementType is ETypeString. Value = ")); INFO_PRINTF1(tprString); iVisitorResult.Append(_L("&type=String&value=")); iVisitorResult.Append(tprString); } break; case ETypeBoolean: INFO_PRINTF2(_L("TSdpElementType is ETypeBoolean. Value = %d"), aValue.Bool()); iVisitorResult.Append(_L("&type=Boolean&value=")); iVisitorResult.AppendNum(aValue.Bool()); break; case ETypeDES: INFO_PRINTF1(_L("TSdpElementType is ETypeDES")); iVisitorResult.Append(_L("&type=DES")); break; case ETypeDEA: INFO_PRINTF1(_L("TSdpElementType is ETypeDEA")); iVisitorResult.Append(_L("&type=DEA")); break; case ETypeURL: { string16->Des().Copy(aValue.Des()); TPtrC16 tprStringURL = string16->Des(); INFO_PRINTF1(_L("TSdpElementType is ETypeURL. Value = ")); INFO_PRINTF1(tprStringURL); iVisitorResult.Append(_L("&type=URL&value=")); iVisitorResult.Append(tprStringURL); } break; case ETypeEncoded: INFO_PRINTF1(_L("TSdpElementType is ETypeEncoded")); iVisitorResult.Append(_L("&type=Encoded")); break; default: INFO_PRINTF2(_L("TSdpElementType is Unknown %d"), aType); iVisitorResult.Append(_L("&type=Unknown")); break; } CleanupStack::PopAndDestroy(string16); } TPtr CT_DataSdpAttrValue::GetVisitorResult() { return iVisitorResult; } void CT_DataSdpAttrValue::ResetVisitorResult() { iVisitorResult.Zero(); } void CT_DataSdpAttrValue::StartListL(CSdpAttrValueList& /*aList*/) { } void CT_DataSdpAttrValue::EndListL() { } void CT_DataSdpAttrValue::DoCmdMSAVV_ExtensionInterfaceL() { INFO_PRINTF1(_L("MSdpAttributeValueVisitor MSAVV_ExtensionInterfaceL call")); void* tmpVoid; TRAPD(err, this->MSAVV_ExtensionInterfaceL(KNullUid, tmpVoid)); if(err != KErrNone) { ERR_PRINTF2(_L("MSdpAttributeValueVisitor MSAVV_ExtensionInterfaceL failed with error %d"), err); SetError(err); } }
[ "none@none" ]
[ [ [ 1, 513 ] ] ]
b537f413e5e3e4dd376e25e32fbdc26f4e0c6a95
bfcc0f6ef5b3ec68365971fd2e7d32f4abd054ed
/kguibig.cpp
940756c249f864a4f87eaecc6137e8d2500a2f08
[]
no_license
cnsuhao/kgui-1
d0a7d1e11cc5c15d098114051fabf6218f26fb96
ea304953c7f5579487769258b55f34a1c680e3ed
refs/heads/master
2021-05-28T22:52:18.733717
2011-03-10T03:10:47
2011-03-10T03:10:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
15,056
cpp
/**********************************************************************************/ /* kGUI - kguibig.cpp */ /* */ /* Programmed by Kevin Pickell */ /* */ /* http://code.google.com/p/kgui/ */ /* */ /* kGUI 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; version 2. */ /* */ /* kGUI 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. */ /* */ /* http://www.gnu.org/licenses/lgpl.txt */ /* */ /* You should have received a copy of the GNU General Public License */ /* along with kGUI; if not, write to the Free Software */ /* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /**********************************************************************************/ /*! @file kguibig.cpp @brief This is the stand along console app for bigfile generation and extraction. As well as the regular commands like adding, deleting and extracting files from within bigfiles it can also be used to synchronize two bigfiles. It can also be used to add files to encrypted bigfiles or extract files from encrypted bigfiles */ #include "kgui.h" #include "kguiprot.h" typedef struct { time_t time; char root; }FDATA; bool optrecursive; bool optverify; bool optcompress; bool optdelete; bool optmissing; enum { SOURCE_FILE, SOURCE_DIR, SOURCE_BIG }; bool g_userabort=false; #if defined(LINUX) || defined(MACINTOSH) #include <signal.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #elif defined(MINGW) #include <signal.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #elif defined(WIN32) #include <io.h> #include <sys/stat.h> #include <signal.h> #else #error #endif #include "kguidir.cpp" #ifndef S_ISDIR #define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR) #endif bool MS_IsDir (const char *file) { struct stat sb; if (stat(file, &sb) < 0) return (false); return (S_ISDIR(sb.st_mode)); } class kGUISystemBig : public kGUISystem { public: void FileShow(const char *filename) {} void ShellExec(const char *program,const char *parms,const char *dir) {} void Copy(kGUIString *s) {} void Paste(kGUIString *s) {} void Sleep(int ms) {} bool MakeDirectory(const char *name) {return false;} long FileTime(const char *fn); void HideWindow(void) {} void ShowWindow(void) {} void ReDraw(void) {} void ChangeMouse(void) {} void ShowMouse(bool show) {} void GetWindowPos(int *x,int *y,int *w,int *h) {} void SetWindowPos(int x,int y) {} void SetWindowSize(int w,int h) {} void Minimize(void) {} void MoveWindowPos(int dx,int dy) {} void AdjustMouse(int dx,int dy) {} bool IsDir(const char *fn) {return MS_IsDir(fn);} bool NeedRotatedSurfaceForPrinting(void) {return false;} unsigned int GetNumPrinters(void) {return 0;} void GetPrinterInfo(const char *name,int *pw,int *ph,int *ppih,int *ppiv) {} int GetDefPrinterNum(void) {return 0;} kGUIPrinter *GetPrinterObj(int pid) {return 0;} class kGUIPrintJob *AllocPrintJob(void) {return 0;} private: }; kGUISystem *kGUI::m_sys; long FileSize(const char *filename) { FILE *fp; long fs; fp=fopen(filename,"rb"); if(!fp) return(0); fseek(fp,0,SEEK_END); fs=ftell(fp); fclose(fp); return(fs); } /**********************************************************************/ static void sigint_handler(int sig) //static declaration { // printf("MANAGER : Signal Detected.! (%d)\n",sig); switch (sig) { // interrupt signal detected case SIGINT: g_userabort=true; break; } } //Debug\kguibig _data.big big big/ int main(int argc, char* argv[]) { int i; int nums; FDATA fdata; Hash AddHash; BigFile DestBigFile; BigFile SourceBigFile; BigFileEntry *bfe; int numok,numnew,numupdated; int sourcetype; bool update; char *p1=0; char *p2=0; char *p3=0; int tosspath=0; DataHandle addhandle; int vargc; char **vargv; vargc=argc; vargv=argv; /* handle encrypted file */ kGUIProt DestProt; bool usedestprot; kGUIProt SourceProt; bool usesourceprot; kGUISystemBig sysbig; kGUI::SetSystem(&sysbig); signal(SIGINT, sigint_handler); optcompress=false; optrecursive=true; optverify=false; optdelete=false; optmissing=false; usedestprot=false; usesourceprot=false; #if 0 p1="/source/kgui/_data.big"; p2="/source/kgui/big"; p3="/source/kgui/big/"; optverify=true; #endif for(i=1;i<vargc;++i) { if(vargv[i][0]=='-') { switch(vargv[i][1]) { case 'c': optcompress=true; break; case 'd': optdelete=true; break; case 'm': optmissing=true; /* delete missing files from subdir */ break; case 'v': optverify=true; break; case 'r': optrecursive=false; break; case 'k': if(vargv[i][2]=='d') /* encryption key on destination file */ { printf("using dest key\n"); if(DestProt.SetKey(vargv[i+1],atoi(vargv[i+2]),atoi(vargv[i+3]),true)==false) { printf("Error loading dest keyfile '%s'\n",vargv[i+1]); return(0); } usedestprot=true; i+=3; } else if(vargv[i][2]=='s') /* encryption key on source file */ { printf("using source key\n"); if(SourceProt.SetKey(vargv[i+1],atoi(vargv[i+2]),atoi(vargv[i+3]),true)==false) { printf("Error loading source keyfile '%s'\n",vargv[i+1]); return(0); } usesourceprot=true; i+=3; } optrecursive=false; break; default: printf("Unknown parm '%s'\n",vargv[i]); return(0); break; } } else { if(!p1) p1=vargv[i]; else if(!p2) p2=vargv[i]; else if(!p3) { p3=vargv[i]; tosspath=(int)strlen(p3); } else { printf("Unknown parm '%s'\n",vargv[i]); return(0); } } } /* need at least 1 parm */ if(!p1) { printf("kguibig: (c) 2005 Kevin Pickelll\n"); printf("usage: kguibig bigfile.big path [root]\n"); printf(" -c = compress\n"); printf(" -v = verify\n"); printf(" -r = don't recurse\n"); printf(" -k[d,s] = filename offset len // source/dest key\n"); return(0); } DestBigFile.SetFilename(p1); if(usedestprot==true) DestBigFile.SetEncryption(&DestProt); DestBigFile.Load(true); if(DestBigFile.IsBad()==true) { printf("Dest file exists and is not a bigfile, or decryption key is incorrect!\n"); return(0); } /* list, verify or compress ? */ if(!p2) { if(optcompress) { } else { unsigned long crc; unsigned long vfsize; BigFileEntry *sfe; unsigned char copybuf[65536]; DataHandle checkhandle; /* verify or list */ nums=DestBigFile.GetNumEntries(); for(i=0;((i<nums) && (g_userabort==false));++i) { sfe=(BigFileEntry *)DestBigFile.GetEntry(i); if(optverify) { /* check crc and print if no match */ printf("%d%c",i,13); vfsize=sfe->m_size; crc=0; DestBigFile.CopyArea(&checkhandle,sfe->m_offset,sfe->m_size,sfe->m_time); checkhandle.Open(); while(vfsize>sizeof(copybuf)) { checkhandle.Read(&copybuf,(unsigned long)sizeof(copybuf)); crc=DestBigFile.CrcBuffer(crc,copybuf,sizeof(copybuf)); vfsize-=sizeof(copybuf); }; /* write remainder */ if(vfsize>0) { checkhandle.Read(&copybuf,vfsize); crc=DestBigFile.CrcBuffer(crc,copybuf,vfsize); } checkhandle.Close(); if(crc!=sfe->m_crc) printf("CRC Error on file '%s' %06x<>%06x\n",sfe->GetName()->GetString(),(int)crc,sfe->m_crc); } else /* assume list if verify is not set */ printf("%s, len=%d,crc=%06x\n",sfe->GetName()->GetString(),sfe->m_size,sfe->m_crc); } } return(0); } AddHash.Init(16,sizeof(FDATA)); /* is p2 a bigfile? */ if(strstr(p2,".big")) { SourceBigFile.SetFilename(p2); if(usesourceprot==true) SourceBigFile.SetEncryption(&SourceProt); SourceBigFile.Load(true); if(SourceBigFile.IsBad()==false) sourcetype=SOURCE_BIG; else { printf("Source file exists and is not a bigfile, or decryption key is incorrect!\n"); return(0); } } else if(kGUI::IsDir(p2)==false) { fdata.time=kGUI::SysFileTime(p2); //fdata.root=p3; AddHash.Add(p2,&fdata); sourcetype=SOURCE_FILE; } else { unsigned int df; const char *name; kGUIDir dir; printf("loading directory!\n"); dir.LoadDir(p2,true,true); for(df=0;df<dir.GetNumFiles();++df) { name=dir.GetFilename(df); fdata.time=kGUI::SysFileTime(name); AddHash.Add(name,&fdata); } // scandir(&AddHash,p2); sourcetype=SOURCE_DIR; } /* now, look for differences between bigfile and files in the addhash list */ numok=0; numnew=0; numupdated=0; /* todo: optdelete function */ /* add from source bigfile to dest bigfile will not work */ /* if source is encrypted so I need to rewrite addfile to use a datahandle */ /* instead of a filestream */ if(sourcetype==SOURCE_BIG) { BigFileEntry *sfe; nums=SourceBigFile.GetNumEntries(); for(i=0;((i<nums) && (g_userabort==false));++i) { sfe=(BigFileEntry *)SourceBigFile.GetEntry(i); bfe=DestBigFile.Locate(sfe->GetName()->GetString()); if(!bfe) { // printf("File '%s' not in destination set!\n",she->m_string); update=true; ++numnew; } else { if(sfe->m_time==bfe->m_time) { update=false; ++numok; } else { int deltatime; deltatime=abs(sfe->m_time-bfe->m_time); if(deltatime==46400 || deltatime==3600) { update=false; ++numok; } else { printf("File '%s' %d,%d times are different!(%d)\n",sfe->GetName()->GetString(),sfe->m_time,bfe->m_time,deltatime); ++numupdated; update=true; } } } if(update==true) { SourceBigFile.CopyArea(&addhandle,sfe->m_offset,sfe->m_size,sfe->m_time); // addsize=sfe->m_size; // addtime=sfe->m_time; // fseek(addhandle,sfe->m_offset,SEEK_SET); /* add the file to the bigfile */ DestBigFile.AddFile(sfe->GetName()->GetString(),&addhandle,false); } } DestBigFile.UpdateDir(); } else { HashEntry *she; FDATA *sfdata; nums=AddHash.GetNum(); she=AddHash.GetFirst(); for(i=0;((i<nums) && (g_userabort==false));++i) { sfdata=(FDATA *)she->m_data; bfe=DestBigFile.Locate(she->m_string+tosspath); if(!bfe) { // printf("File '%s' not in destination set!\n",she->m_string+tosspath); ++numnew; update=true; } else { if(sfdata->time==bfe->m_time) { update=false; ++numok; } else { int deltatime; deltatime=(abs((int)sfdata->time-bfe->m_time)); if(deltatime==46400 || deltatime==3600) { update=false; ++numok; } else { printf("File '%s' %d,%d times are different!(%d)\n",she->m_string+tosspath,(int)sfdata->time,bfe->m_time,deltatime); ++numupdated; update=true; } } } if(update==true) { addhandle.SetFilename(she->m_string); /* add the file to the bigfile */ DestBigFile.AddFile(she->m_string+tosspath,&addhandle,false); } she=she->m_next; } DestBigFile.UpdateDir(); } printf("numok=%d,numnew=%d,numupdated=%d\n",numok,numnew,numupdated); return 0; } /*******************************************************/ /** select functions duplicated from the kgui library **/ /*******************************************************/ long kGUISystemBig::FileTime(const char *fn) { #if defined(LINUX) || defined(MINGW) || defined(MACINTOSH) int result; struct stat buf; result=stat(fn,&buf); if(result==-1) return(0); return(buf.st_mtime); #elif defined(WIN32) struct __stat64 buf; int result; result = _stat64( fn, &buf ); /* Check if statistics are valid: */ if( result != 0 ) return(0); else return((long)buf.st_mtime); #else #error #endif } unsigned char *kGUI::LoadFile(const char *filename,unsigned long *filesize) { unsigned char *fm; unsigned long fs; DataHandle dh; if(filesize) filesize[0]=0; dh.SetFilename(filename); if(dh.Open()==false) { printf("Error: cannot open file '%s'\n",filename); return(0); /* file not found or empty file */ } fs=dh.GetLoadableSize(); /* allocate space for file to load info */ fm=new unsigned char[fs+1]; if(!fm) { dh.Close(); return(0); } fm[fs]=0; /* allocate an extra byte and put a null at the end */ dh.Read(fm,fs); dh.Close(); if(filesize) { //todo: if filesize>32 bits, then assert, else return ok filesize[0]=fs; } return(fm); } unsigned char strcmpin(const char *lword,const char *sword,int n) { int i; unsigned char delta; for(i=0;i<n;++i) { delta=lc(lword[i])-lc(sword[i]); if(delta) return(delta); } return(0); /* match! */ } char lc(char c) { if(c>='A' && c<='Z') return((c-'A')+'a'); return(c); } char *strstri(const char *lword,const char *sword) { int i,j,p; int delta; int llen=(int)strlen(lword); int slen=(int)strlen(sword); p=(llen-slen)+1; /* number of possible positions to compare */ if(p<0) return(0); /* can't match! as lword needs to >=len of sword */ for(j=0;j<p;++j) { delta=0; for(i=0;((i<slen) && (!delta));++i) delta=lc(lword[j+i])-lc(sword[i]); if(!delta) return((char *)(lword+j)); /* match occured here! */ } return(0); /* no matches */ } void fatalerror(const char *string) { printf("%s",string); fflush(stdout); exit(1); }
[ "[email protected]@4b35e2fd-144d-0410-91a6-811dcd9ab31d" ]
[ [ [ 1, 626 ] ] ]
86d2e6e87706eae7429cda850c796e8026b8bc16
29241c06548ec3ac6ef859ba32656cb60d8b89bf
/coolsb_mfctest/MainFrm.cpp
d45818ba4c867074891a25360026d1e7a56e3977
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
jsleroy/CoolSB
791fbc80619762d81a4ae21145c4892a6c1210c1
472051497f176f5853eae03677f63260ad4eed44
refs/heads/master
2021-01-16T21:49:36.856083
2009-06-17T14:52:35
2009-06-17T14:52:35
249,513
3
2
null
null
null
null
UTF-8
C++
false
false
2,059
cpp
// MainFrm.cpp : implementation of the CMainFrame class // #include "stdafx.h" #include "coolsb_mfctest.h" #include "MainFrm.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMainFrame IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) //{{AFX_MSG_MAP(CMainFrame) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code ! ON_WM_CREATE() //}}AFX_MSG_MAP END_MESSAGE_MAP() static UINT indicators[] = { ID_SEPARATOR, // status line indicator ID_INDICATOR_CAPS, ID_INDICATOR_NUM, ID_INDICATOR_SCRL, }; ///////////////////////////////////////////////////////////////////////////// // CMainFrame construction/destruction CMainFrame::CMainFrame() { // TODO: add member initialization code here } CMainFrame::~CMainFrame() { } int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } return 0; } BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { if( !CFrameWnd::PreCreateWindow(cs) ) return FALSE; // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs cs.cx = 350; cs.cy = 200; return TRUE; } ///////////////////////////////////////////////////////////////////////////// // CMainFrame diagnostics #ifdef _DEBUG void CMainFrame::AssertValid() const { CFrameWnd::AssertValid(); } void CMainFrame::Dump(CDumpContext& dc) const { CFrameWnd::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CMainFrame message handlers
[ [ [ 1, 96 ] ] ]
ee28e610bb70fbf161585b02c7aa4d3fa3faf946
3ec3b97044e4e6a87125470cfa7eef535f26e376
/cltatman-mountain_valley/code/Source/back/Component.cpp
2e721ffae133d4869f3bd9bf42ccec3eb744d89a
[]
no_license
strategist922/TINS-Is-not-speedhack-2010
6d7a43ebb9ab3b24208b3a22cbcbb7452dae48af
718b9d037606f0dbd9eb6c0b0e021eeb38c011f9
refs/heads/master
2021-01-18T14:14:38.724957
2010-10-17T14:04:40
2010-10-17T14:04:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
101
cpp
#include "Component.h" Component::Component( const std::string& _type ) : type( _type ) {}
[ [ [ 1, 6 ] ] ]
e2c49ee8940e6aff96264bdcd0c95b21b37a39f1
9c62af23e0a1faea5aaa8dd328ba1d82688823a5
/rl/tags/techdemo2/engine/ui/include/MainMenuEngineWindow.h
d6096edbdfeaaf9112d7b7628684d684f1e02f19
[ "ClArtistic", "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
jacmoe/dsa-hl-svn
55b05b6f28b0b8b216eac7b0f9eedf650d116f85
97798e1f54df9d5785fb206c7165cd011c611560
refs/heads/master
2021-04-22T12:07:43.389214
2009-11-27T22:01:03
2009-11-27T22:01:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,013
h
/* This source file is part of Rastullahs Lockenpracht. * Copyright (C) 2003-2005 Team Pantheon. http://www.team-pantheon.de * * This program is free software; you can redistribute it and/or modify * it under the terms of the Clarified Artistic License. * * 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 * Clarified Artistic License for more details. * * You should have received a copy of the Clarified Artistic License * along with this program; if not you can get it here * http://www.jpaulmorrison.com/fbp/artistic2.htm. */ #ifndef __MainMenuEngineWindow_H__ #define __MainMenuEngineWindow_H__ #include "UiPrerequisites.h" #include "CeGuiWindow.h" namespace rl { class ContentModule; class _RlUiExport MainMenuEngineWindow : public CeGuiWindow { public: MainMenuEngineWindow(); }; } #endif
[ "tanis@4c79e8ff-cfd4-0310-af45-a38c79f83013" ]
[ [ [ 1, 34 ] ] ]
8d66309550b84df78f2ff261101531bc22684366
1e299bdc79bdc75fc5039f4c7498d58f246ed197
/App/ClientSubSystem.h
6534161cc01f4fae544b016a0e832d0c267d22bd
[]
no_license
moosethemooche/Certificate-Server
5b066b5756fc44151b53841482b7fa603c26bf3e
887578cc2126bae04c09b2a9499b88cb8c7419d4
refs/heads/master
2021-01-17T06:24:52.178106
2011-07-13T13:27:09
2011-07-13T13:27:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,508
h
//-------------------------------------------------------------------------------- // // Copyright (c) 2000 MarkCare Solutions // // Programming by Rich Schonthal // //-------------------------------------------------------------------------------- #if !defined(AFX_CLIENTSUBSYSTEM_H__3FFF6999_C933_11D3_AF10_005004A1C5F3__INCLUDED_) #define AFX_CLIENTSUBSYSTEM_H__3FFF6999_C933_11D3_AF10_005004A1C5F3__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 //-------------------------------------------------------------------------------- #include "SSSubSystem.h" //-------------------------------------------------------------------------------- class CSecuritySystem; class CSSConfigClientHandler; class CClientConnectThread; class CSSIOSubSystem; class CCertificateMaster; class CMagicNumber; class CConnection; class CConnectionPool; //-------------------------------------------------------------------------------- class CClientSubSystem : public CSSSubSystem<CThreadPoolSubSystem> { public: DECLARE_DYNAMIC(CClientSubSystem); protected: CSSConfigClientHandler* m_pConfig; CClientConnectThread* m_pConnectionThread; public: enum { MSG_NEWCONNECTION = WM_USER }; public: CClientSubSystem(CSecuritySystem*); virtual ~CClientSubSystem(); CSSIOSubSystem* GetIO(); CMagicNumber* GetMagNumGen() const; }; #endif // !defined(AFX_CLIENTSUBSYSTEM_H__3FFF6999_C933_11D3_AF10_005004A1C5F3__INCLUDED_)
[ [ [ 1, 54 ] ] ]
53c29ca7e22c3a68ec2803e984c569ee624702cb
b8fe0ddfa6869de08ba9cd434e3cf11e57d59085
/NxOgre/build/source/NxOgreUtil.cpp
9df29a9044f08b78887e28a23f26fd4b0cfbccbc
[]
no_license
juanjmostazo/ouan-tests
c89933891ed4f6ad48f48d03df1f22ba0f3ff392
eaa73fb482b264d555071f3726510ed73bef22ea
refs/heads/master
2021-01-10T20:18:35.918470
2010-06-20T15:45:00
2010-06-20T15:45:00
38,101,212
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
3,261
cpp
/** File: NxOgreUtil.cpp Created on: 11-Apr-09 Author: Robin Southern "betajaen" © Copyright, 2008-2009 by Robin Southern, http://www.nxogre.org This file is part of NxOgre. NxOgre 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. NxOgre 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 NxOgre. If not, see <http://www.gnu.org/licenses/>. */ #include "NxOgreStable.h" #include "NxOgreUtil.h" #include "NxOgreSimple.h" #include "NxOgreFunctions.h" #include "NxOgreRay.h" #include "NxPhysics.h" namespace NxOgre { namespace Util { bool SimpleBoxContainsPoint(const SimpleBox& oBox, const Vec3& oP) { NxBox box; Functions::SimpleBoxToNxBox(oBox, box); NxVec3 p; Functions::XYZ<Vec3, NxVec3>(oP, p); return NxGetUtilLib()->NxBoxContainsPoint(box, p); } SimpleBox NxOgrePublicFunction createSimpleBox(const Bounds3& aabb, const Matrix44& trans) { SimpleBox out; NxBounds3 bounds; bounds.max.x = aabb.max.x; bounds.max.y = aabb.max.y; bounds.max.z = aabb.max.z; bounds.min.x = aabb.min.x; bounds.min.y = aabb.min.y; bounds.min.z = aabb.min.z; NxMat34 mat; mat.setColumnMajor44(trans.ptr()); NxBox box; NxGetUtilLib()->NxCreateBox(box, bounds, mat); Functions::NxBoxToSimpleBox(box, out); return out; } SimplePlane NxOgrePublicFunction createSimplePlane(const Vec3& normal, const Real& distance) { SimplePlane plane; plane.mDistance = distance; plane.mNormal = normal; return plane; } bool NxOgrePublicFunction RayPlaneIntersect(const Ray& ray, const SimplePlane& simplePlane, Real& distance, Vec3& pointOnPlane) { NxPlane plane; plane.d = simplePlane.mDistance; Functions::XYZ<Vec3, NxVec3>(simplePlane.mNormal, plane.normal); NxRay inRay; Functions::XYZ<Vec3, NxVec3>(ray.mDirection, inRay.dir); Functions::XYZ<Vec3, NxVec3>(ray.mOrigin, inRay.orig); NxVec3 physxPointOnPlane; bool result = NxGetUtilLib()->NxRayPlaneIntersect(inRay, plane, distance, physxPointOnPlane); Functions::XYZ<NxVec3, Vec3>(physxPointOnPlane, pointOnPlane); return result; } } } // namespace NxOgre
[ "ithiliel@6899d1ce-2719-11df-8847-f3d5e5ef3dde" ]
[ [ [ 1, 106 ] ] ]
3f48dac6900f3d66ad2fc5524a8976f8fa14a5c8
7b4e708809905ae003d0cb355bf53e4d16c9cbbc
/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp
66a64cd50802be07e20f685ab7329aca25aba92b
[]
no_license
sonic59/JulesText
ce6507014e4cba7fb0b67597600d1cee48a973a5
986cbea68447ace080bf34ac2b94ac3ab46faca4
refs/heads/master
2016-09-06T06:10:01.815928
2011-11-18T01:19:26
2011-11-18T01:19:26
2,796,827
0
0
null
null
null
null
UTF-8
C++
false
false
89,558
cpp
/* ============================================================================== This file is part of the JUCE library - "Jules' Utility Class Extensions" Copyright 2004-11 by Raw Material Software Ltd. ------------------------------------------------------------------------------ JUCE can be redistributed and/or modified under the terms of the GNU General Public License (Version 2), as published by the Free Software Foundation. A copy of the license is included in the JUCE distribution, or can be found online at www.gnu.org/licenses. JUCE 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. ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are available: visit www.rawmaterialsoftware.com/juce for more information. ============================================================================== */ #if JUCE_PLUGINHOST_VST #include "../../juce_audio_plugin_client/utility/juce_IncludeSystemHeaders.h" //============================================================================== #if ! (JUCE_MAC && JUCE_64BIT) BEGIN_JUCE_NAMESPACE #if JUCE_MAC && JUCE_SUPPORT_CARBON #include "../../juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h" #endif #if JUCE_MAC static bool makeFSRefFromPath (FSRef* destFSRef, const String& path) { return FSPathMakeRef (reinterpret_cast <const UInt8*> (path.toUTF8().getAddress()), destFSRef, 0) == noErr; } #endif //============================================================================== #undef PRAGMA_ALIGN_SUPPORTED #define VST_FORCE_DEPRECATED 0 #if JUCE_MSVC #pragma warning (push) #pragma warning (disable: 4996) #endif /* Obviously you're going to need the Steinberg vstsdk2.4 folder in your include path if you want to add VST support. If you're not interested in VSTs, you can disable them by setting the JUCE_PLUGINHOST_VST flag to 0. */ #include <pluginterfaces/vst2.x/aeffectx.h> #if JUCE_MSVC #pragma warning (pop) #endif //============================================================================== #if JUCE_LINUX #define Font juce::Font #define KeyPress juce::KeyPress #define Drawable juce::Drawable #define Time juce::Time #endif #include "juce_VSTMidiEventList.h" #if ! JUCE_WINDOWS static void _fpreset() {} static void _clearfp() {} #endif //============================================================================== const int fxbVersionNum = 1; struct fxProgram { long chunkMagic; // 'CcnK' long byteSize; // of this chunk, excl. magic + byteSize long fxMagic; // 'FxCk' long version; long fxID; // fx unique id long fxVersion; long numParams; char prgName[28]; float params[1]; // variable no. of parameters }; struct fxSet { long chunkMagic; // 'CcnK' long byteSize; // of this chunk, excl. magic + byteSize long fxMagic; // 'FxBk' long version; long fxID; // fx unique id long fxVersion; long numPrograms; char future[128]; fxProgram programs[1]; // variable no. of programs }; struct fxChunkSet { long chunkMagic; // 'CcnK' long byteSize; // of this chunk, excl. magic + byteSize long fxMagic; // 'FxCh', 'FPCh', or 'FBCh' long version; long fxID; // fx unique id long fxVersion; long numPrograms; char future[128]; long chunkSize; char chunk[8]; // variable }; struct fxProgramSet { long chunkMagic; // 'CcnK' long byteSize; // of this chunk, excl. magic + byteSize long fxMagic; // 'FxCh', 'FPCh', or 'FBCh' long version; long fxID; // fx unique id long fxVersion; long numPrograms; char name[28]; long chunkSize; char chunk[8]; // variable }; namespace { long vst_swap (const long x) noexcept { #ifdef JUCE_LITTLE_ENDIAN return (long) ByteOrder::swap ((uint32) x); #else return x; #endif } float vst_swapFloat (const float x) noexcept { #ifdef JUCE_LITTLE_ENDIAN union { uint32 asInt; float asFloat; } n; n.asFloat = x; n.asInt = ByteOrder::swap (n.asInt); return n.asFloat; #else return x; #endif } double getVSTHostTimeNanoseconds() { #if JUCE_WINDOWS return timeGetTime() * 1000000.0; #elif JUCE_LINUX timeval micro; gettimeofday (&micro, 0); return micro.tv_usec * 1000.0; #elif JUCE_MAC UnsignedWide micro; Microseconds (&micro); return micro.lo * 1000.0; #endif } } //============================================================================== typedef AEffect* (VSTCALLBACK *MainCall) (audioMasterCallback); static VstIntPtr VSTCALLBACK audioMaster (AEffect* effect, VstInt32 opcode, VstInt32 index, VstIntPtr value, void* ptr, float opt); static int shellUIDToCreate = 0; static int insideVSTCallback = 0; class IdleCallRecursionPreventer { public: IdleCallRecursionPreventer() : isMessageThread (MessageManager::getInstance()->isThisTheMessageThread()) { if (isMessageThread) ++insideVSTCallback; } ~IdleCallRecursionPreventer() { if (isMessageThread) --insideVSTCallback; } private: const bool isMessageThread; JUCE_DECLARE_NON_COPYABLE (IdleCallRecursionPreventer); }; class VSTPluginWindow; //============================================================================== // Change this to disable logging of various VST activities #ifndef VST_LOGGING #define VST_LOGGING 1 #endif #if VST_LOGGING #define log(a) Logger::writeToLog(a); #else #define log(a) #endif //============================================================================== #if JUCE_MAC && JUCE_PPC static void* NewCFMFromMachO (void* const machofp) noexcept { void* result = (void*) new char[8]; ((void**) result)[0] = machofp; ((void**) result)[1] = result; return result; } #endif //============================================================================== #if JUCE_LINUX extern Display* display; extern XContext windowHandleXContext; typedef void (*EventProcPtr) (XEvent* ev); static bool xErrorTriggered; namespace { int temporaryErrorHandler (Display*, XErrorEvent*) { xErrorTriggered = true; return 0; } int getPropertyFromXWindow (Window handle, Atom atom) { XErrorHandler oldErrorHandler = XSetErrorHandler (temporaryErrorHandler); xErrorTriggered = false; int userSize; unsigned long bytes, userCount; unsigned char* data; Atom userType; XGetWindowProperty (display, handle, atom, 0, 1, false, AnyPropertyType, &userType, &userSize, &userCount, &bytes, &data); XSetErrorHandler (oldErrorHandler); return (userCount == 1 && ! xErrorTriggered) ? *reinterpret_cast<int*> (data) : 0; } Window getChildWindow (Window windowToCheck) { Window rootWindow, parentWindow; Window* childWindows; unsigned int numChildren; XQueryTree (display, windowToCheck, &rootWindow, &parentWindow, &childWindows, &numChildren); if (numChildren > 0) return childWindows [0]; return 0; } void translateJuceToXButtonModifiers (const MouseEvent& e, XEvent& ev) noexcept { if (e.mods.isLeftButtonDown()) { ev.xbutton.button = Button1; ev.xbutton.state |= Button1Mask; } else if (e.mods.isRightButtonDown()) { ev.xbutton.button = Button3; ev.xbutton.state |= Button3Mask; } else if (e.mods.isMiddleButtonDown()) { ev.xbutton.button = Button2; ev.xbutton.state |= Button2Mask; } } void translateJuceToXMotionModifiers (const MouseEvent& e, XEvent& ev) noexcept { if (e.mods.isLeftButtonDown()) ev.xmotion.state |= Button1Mask; else if (e.mods.isRightButtonDown()) ev.xmotion.state |= Button3Mask; else if (e.mods.isMiddleButtonDown()) ev.xmotion.state |= Button2Mask; } void translateJuceToXCrossingModifiers (const MouseEvent& e, XEvent& ev) noexcept { if (e.mods.isLeftButtonDown()) ev.xcrossing.state |= Button1Mask; else if (e.mods.isRightButtonDown()) ev.xcrossing.state |= Button3Mask; else if (e.mods.isMiddleButtonDown()) ev.xcrossing.state |= Button2Mask; } void translateJuceToXMouseWheelModifiers (const MouseEvent& e, const float increment, XEvent& ev) noexcept { if (increment < 0) { ev.xbutton.button = Button5; ev.xbutton.state |= Button5Mask; } else if (increment > 0) { ev.xbutton.button = Button4; ev.xbutton.state |= Button4Mask; } } } #endif //============================================================================== class ModuleHandle : public ReferenceCountedObject { public: //============================================================================== File file; MainCall moduleMain; String pluginName; static Array <ModuleHandle*>& getActiveModules() { static Array <ModuleHandle*> activeModules; return activeModules; } //============================================================================== static ModuleHandle* findOrCreateModule (const File& file) { for (int i = getActiveModules().size(); --i >= 0;) { ModuleHandle* const module = getActiveModules().getUnchecked(i); if (module->file == file) return module; } _fpreset(); // (doesn't do any harm) const IdleCallRecursionPreventer icrp; shellUIDToCreate = 0; log ("Attempting to load VST: " + file.getFullPathName()); ScopedPointer <ModuleHandle> m (new ModuleHandle (file)); if (! m->open()) m = nullptr; _fpreset(); // (doesn't do any harm) return m.release(); } //============================================================================== ModuleHandle (const File& file_) : file (file_), moduleMain (0) #if JUCE_MAC , fragId (0), resHandle (0), bundleRef (0), resFileId (0) #endif { getActiveModules().add (this); #if JUCE_WINDOWS || JUCE_LINUX fullParentDirectoryPathName = file_.getParentDirectory().getFullPathName(); #elif JUCE_MAC FSRef ref; makeFSRefFromPath (&ref, file_.getParentDirectory().getFullPathName()); FSGetCatalogInfo (&ref, kFSCatInfoNone, 0, 0, &parentDirFSSpec, 0); #endif } ~ModuleHandle() { getActiveModules().removeValue (this); close(); } //============================================================================== #if JUCE_WINDOWS || JUCE_LINUX DynamicLibrary module; String fullParentDirectoryPathName; bool open() { #if JUCE_WINDOWS static bool timePeriodSet = false; if (! timePeriodSet) { timePeriodSet = true; timeBeginPeriod (2); } #endif pluginName = file.getFileNameWithoutExtension(); module.open (file.getFullPathName()); moduleMain = (MainCall) module.getFunction ("VSTPluginMain"); if (moduleMain == nullptr) moduleMain = (MainCall) module.getFunction ("main"); return moduleMain != nullptr; } void close() { _fpreset(); // (doesn't do any harm) module.close(); } void closeEffect (AEffect* eff) { eff->dispatcher (eff, effClose, 0, 0, 0, 0); } #else CFragConnectionID fragId; Handle resHandle; CFBundleRef bundleRef; FSSpec parentDirFSSpec; short resFileId; bool open() { bool ok = false; const String filename (file.getFullPathName()); if (file.hasFileExtension (".vst")) { const char* const utf8 = filename.toUTF8().getAddress(); CFURLRef url = CFURLCreateFromFileSystemRepresentation (0, (const UInt8*) utf8, strlen (utf8), file.isDirectory()); if (url != 0) { bundleRef = CFBundleCreate (kCFAllocatorDefault, url); CFRelease (url); if (bundleRef != 0) { if (CFBundleLoadExecutable (bundleRef)) { moduleMain = (MainCall) CFBundleGetFunctionPointerForName (bundleRef, CFSTR("main_macho")); if (moduleMain == 0) moduleMain = (MainCall) CFBundleGetFunctionPointerForName (bundleRef, CFSTR("VSTPluginMain")); if (moduleMain != 0) { CFTypeRef name = CFBundleGetValueForInfoDictionaryKey (bundleRef, CFSTR("CFBundleName")); if (name != 0) { if (CFGetTypeID (name) == CFStringGetTypeID()) { char buffer[1024]; if (CFStringGetCString ((CFStringRef) name, buffer, sizeof (buffer), CFStringGetSystemEncoding())) pluginName = buffer; } } if (pluginName.isEmpty()) pluginName = file.getFileNameWithoutExtension(); resFileId = CFBundleOpenBundleResourceMap (bundleRef); ok = true; } } if (! ok) { CFBundleUnloadExecutable (bundleRef); CFRelease (bundleRef); bundleRef = 0; } } } } #if JUCE_PPC else { FSRef fn; if (FSPathMakeRef ((UInt8*) filename.toUTF8().getAddress(), &fn, 0) == noErr) { resFileId = FSOpenResFile (&fn, fsRdPerm); if (resFileId != -1) { const int numEffs = Count1Resources ('aEff'); for (int i = 0; i < numEffs; ++i) { resHandle = Get1IndResource ('aEff', i + 1); if (resHandle != 0) { OSType type; Str255 name; SInt16 id; GetResInfo (resHandle, &id, &type, name); pluginName = String ((const char*) name + 1, name[0]); DetachResource (resHandle); HLock (resHandle); Ptr ptr; Str255 errorText; OSErr err = GetMemFragment (*resHandle, GetHandleSize (resHandle), name, kPrivateCFragCopy, &fragId, &ptr, errorText); if (err == noErr) { moduleMain = (MainCall) newMachOFromCFM (ptr); ok = true; } else { HUnlock (resHandle); } break; } } if (! ok) CloseResFile (resFileId); } } } #endif return ok; } void close() { #if JUCE_PPC if (fragId != 0) { if (moduleMain != 0) disposeMachOFromCFM ((void*) moduleMain); CloseConnection (&fragId); HUnlock (resHandle); if (resFileId != 0) CloseResFile (resFileId); } else #endif if (bundleRef != 0) { CFBundleCloseBundleResourceMap (bundleRef, resFileId); if (CFGetRetainCount (bundleRef) == 1) CFBundleUnloadExecutable (bundleRef); if (CFGetRetainCount (bundleRef) > 0) CFRelease (bundleRef); } } void closeEffect (AEffect* eff) { #if JUCE_PPC if (fragId != 0) { Array<void*> thingsToDelete; thingsToDelete.add ((void*) eff->dispatcher); thingsToDelete.add ((void*) eff->process); thingsToDelete.add ((void*) eff->setParameter); thingsToDelete.add ((void*) eff->getParameter); thingsToDelete.add ((void*) eff->processReplacing); eff->dispatcher (eff, effClose, 0, 0, 0, 0); for (int i = thingsToDelete.size(); --i >= 0;) disposeMachOFromCFM (thingsToDelete[i]); } else #endif { eff->dispatcher (eff, effClose, 0, 0, 0, 0); } } #if JUCE_PPC static void* newMachOFromCFM (void* cfmfp) { if (cfmfp == 0) return nullptr; UInt32* const mfp = new UInt32[6]; mfp[0] = 0x3d800000 | ((UInt32) cfmfp >> 16); mfp[1] = 0x618c0000 | ((UInt32) cfmfp & 0xffff); mfp[2] = 0x800c0000; mfp[3] = 0x804c0004; mfp[4] = 0x7c0903a6; mfp[5] = 0x4e800420; MakeDataExecutable (mfp, sizeof (UInt32) * 6); return mfp; } static void disposeMachOFromCFM (void* ptr) { delete[] static_cast <UInt32*> (ptr); } void coerceAEffectFunctionCalls (AEffect* eff) { if (fragId != 0) { eff->dispatcher = (AEffectDispatcherProc) newMachOFromCFM ((void*) eff->dispatcher); eff->process = (AEffectProcessProc) newMachOFromCFM ((void*) eff->process); eff->setParameter = (AEffectSetParameterProc) newMachOFromCFM ((void*) eff->setParameter); eff->getParameter = (AEffectGetParameterProc) newMachOFromCFM ((void*) eff->getParameter); eff->processReplacing = (AEffectProcessProc) newMachOFromCFM ((void*) eff->processReplacing); } } #endif #endif private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ModuleHandle); }; //============================================================================== /** An instance of a plugin, created by a VSTPluginFormat. */ class VSTPluginInstance : public AudioPluginInstance, private Timer, private AsyncUpdater { public: //============================================================================== ~VSTPluginInstance(); //============================================================================== // AudioPluginInstance methods: void fillInPluginDescription (PluginDescription& desc) const { desc.name = name; { char buffer [512] = { 0 }; dispatch (effGetEffectName, 0, 0, buffer, 0); desc.descriptiveName = String (buffer).trim(); if (desc.descriptiveName.isEmpty()) desc.descriptiveName = name; } desc.fileOrIdentifier = module->file.getFullPathName(); desc.uid = getUID(); desc.lastFileModTime = module->file.getLastModificationTime(); desc.pluginFormatName = "VST"; desc.category = getCategory(); { char buffer [kVstMaxVendorStrLen + 8] = { 0 }; dispatch (effGetVendorString, 0, 0, buffer, 0); desc.manufacturerName = buffer; } desc.version = getVersion(); desc.numInputChannels = getNumInputChannels(); desc.numOutputChannels = getNumOutputChannels(); desc.isInstrument = (effect != nullptr && (effect->flags & effFlagsIsSynth) != 0); } void* getPlatformSpecificData() { return effect; } const String getName() const { return name; } int getUID() const; bool acceptsMidi() const { return wantsMidiMessages; } bool producesMidi() const { return dispatch (effCanDo, 0, 0, (void*) "sendVstMidiEvent", 0) > 0; } //============================================================================== // AudioProcessor methods: void prepareToPlay (double sampleRate, int estimatedSamplesPerBlock); void releaseResources(); void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages); bool hasEditor() const { return effect != nullptr && (effect->flags & effFlagsHasEditor) != 0; } AudioProcessorEditor* createEditor(); const String getInputChannelName (int index) const; bool isInputChannelStereoPair (int index) const; const String getOutputChannelName (int index) const; bool isOutputChannelStereoPair (int index) const; //============================================================================== int getNumParameters() { return effect != nullptr ? effect->numParams : 0; } float getParameter (int index); void setParameter (int index, float newValue); const String getParameterName (int index); const String getParameterText (int index); bool isParameterAutomatable (int index) const; //============================================================================== int getNumPrograms() { return effect != nullptr ? effect->numPrograms : 0; } int getCurrentProgram() { return dispatch (effGetProgram, 0, 0, 0, 0); } void setCurrentProgram (int index); const String getProgramName (int index); void changeProgramName (int index, const String& newName); //============================================================================== void getStateInformation (MemoryBlock& destData); void getCurrentProgramStateInformation (MemoryBlock& destData); void setStateInformation (const void* data, int sizeInBytes); void setCurrentProgramStateInformation (const void* data, int sizeInBytes); //============================================================================== void timerCallback(); void handleAsyncUpdate(); VstIntPtr handleCallback (VstInt32 opcode, VstInt32 index, VstInt32 value, void *ptr, float opt); private: //============================================================================== friend class VSTPluginWindow; friend class VSTPluginFormat; AEffect* effect; String name; CriticalSection lock; bool wantsMidiMessages, initialised, isPowerOn; mutable StringArray programNames; AudioSampleBuffer tempBuffer; CriticalSection midiInLock; MidiBuffer incomingMidi; VSTMidiEventList midiEventsToSend; VstTimeInfo vstHostTime; ReferenceCountedObjectPtr <ModuleHandle> module; //============================================================================== int dispatch (const int opcode, const int index, const int value, void* const ptr, float opt) const; bool restoreProgramSettings (const fxProgram* const prog); const String getCurrentProgramName(); void setParamsInProgramBlock (fxProgram* const prog); void updateStoredProgramNames(); void initialise(); void handleMidiFromPlugin (const VstEvents* const events); void createTempParameterStore (MemoryBlock& dest); void restoreFromTempParameterStore (const MemoryBlock& mb); const String getParameterLabel (int index) const; bool usesChunks() const noexcept { return effect != nullptr && (effect->flags & effFlagsProgramChunks) != 0; } void getChunkData (MemoryBlock& mb, bool isPreset, int maxSizeMB) const; void setChunkData (const char* data, int size, bool isPreset); bool loadFromFXBFile (const void* data, int numBytes); bool saveToFXBFile (MemoryBlock& dest, bool isFXB, int maxSizeMB); int getVersionNumber() const noexcept { return effect != nullptr ? effect->version : 0; } String getVersion() const; String getCategory() const; void setPower (const bool on); VSTPluginInstance (const ReferenceCountedObjectPtr <ModuleHandle>& module); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VSTPluginInstance); }; //============================================================================== VSTPluginInstance::VSTPluginInstance (const ReferenceCountedObjectPtr <ModuleHandle>& module_) : effect (nullptr), name (module_->pluginName), wantsMidiMessages (false), initialised (false), isPowerOn (false), tempBuffer (1, 1), module (module_) { try { const IdleCallRecursionPreventer icrp; _fpreset(); log ("Creating VST instance: " + name); #if JUCE_MAC if (module->resFileId != 0) UseResFile (module->resFileId); #if JUCE_PPC if (module->fragId != 0) { static void* audioMasterCoerced = nullptr; if (audioMasterCoerced == nullptr) audioMasterCoerced = NewCFMFromMachO ((void*) &audioMaster); effect = module->moduleMain ((audioMasterCallback) audioMasterCoerced); } else #endif #endif { effect = module->moduleMain (&audioMaster); } if (effect != nullptr && effect->magic == kEffectMagic) { #if JUCE_PPC module->coerceAEffectFunctionCalls (effect); #endif jassert (effect->resvd2 == 0); jassert (effect->object != 0); _fpreset(); // some dodgy plugs fuck around with this } else { effect = nullptr; } } catch (...) {} } VSTPluginInstance::~VSTPluginInstance() { const ScopedLock sl (lock); if (effect != nullptr && effect->magic == kEffectMagic) { try { #if JUCE_MAC if (module->resFileId != 0) UseResFile (module->resFileId); #endif // Must delete any editors before deleting the plugin instance! jassert (getActiveEditor() == 0); _fpreset(); // some dodgy plugs fuck around with this module->closeEffect (effect); } catch (...) {} } module = nullptr; effect = nullptr; } //============================================================================== void VSTPluginInstance::initialise() { if (initialised || effect == 0) return; log ("Initialising VST: " + module->pluginName); initialised = true; dispatch (effIdentify, 0, 0, 0, 0); if (getSampleRate() > 0) dispatch (effSetSampleRate, 0, 0, 0, (float) getSampleRate()); if (getBlockSize() > 0) dispatch (effSetBlockSize, 0, jmax (32, getBlockSize()), 0, 0); dispatch (effOpen, 0, 0, 0, 0); setPlayConfigDetails (effect->numInputs, effect->numOutputs, getSampleRate(), getBlockSize()); if (getNumPrograms() > 1) setCurrentProgram (0); else dispatch (effSetProgram, 0, 0, 0, 0); int i; for (i = effect->numInputs; --i >= 0;) dispatch (effConnectInput, i, 1, 0, 0); for (i = effect->numOutputs; --i >= 0;) dispatch (effConnectOutput, i, 1, 0, 0); updateStoredProgramNames(); wantsMidiMessages = dispatch (effCanDo, 0, 0, (void*) "receiveVstMidiEvent", 0) > 0; setLatencySamples (effect->initialDelay); } //============================================================================== void VSTPluginInstance::prepareToPlay (double sampleRate_, int samplesPerBlockExpected) { setPlayConfigDetails (effect->numInputs, effect->numOutputs, sampleRate_, samplesPerBlockExpected); setLatencySamples (effect->initialDelay); vstHostTime.tempo = 120.0; vstHostTime.timeSigNumerator = 4; vstHostTime.timeSigDenominator = 4; vstHostTime.sampleRate = sampleRate_; vstHostTime.samplePos = 0; vstHostTime.flags = kVstNanosValid; /*| kVstTransportPlaying | kVstTempoValid | kVstTimeSigValid*/; initialise(); if (initialised) { wantsMidiMessages = wantsMidiMessages || (dispatch (effCanDo, 0, 0, (void*) "receiveVstMidiEvent", 0) > 0); if (wantsMidiMessages) midiEventsToSend.ensureSize (256); else midiEventsToSend.freeEvents(); incomingMidi.clear(); dispatch (effSetSampleRate, 0, 0, 0, (float) sampleRate_); dispatch (effSetBlockSize, 0, jmax (16, samplesPerBlockExpected), 0, 0); tempBuffer.setSize (jmax (1, effect->numOutputs), samplesPerBlockExpected); if (! isPowerOn) setPower (true); // dodgy hack to force some plugins to initialise the sample rate.. if ((! hasEditor()) && getNumParameters() > 0) { const float old = getParameter (0); setParameter (0, (old < 0.5f) ? 1.0f : 0.0f); setParameter (0, old); } dispatch (effStartProcess, 0, 0, 0, 0); } } void VSTPluginInstance::releaseResources() { if (initialised) { dispatch (effStopProcess, 0, 0, 0, 0); setPower (false); } tempBuffer.setSize (1, 1); incomingMidi.clear(); midiEventsToSend.freeEvents(); } void VSTPluginInstance::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages) { const int numSamples = buffer.getNumSamples(); if (initialised) { AudioPlayHead* playHead = getPlayHead(); if (playHead != nullptr) { AudioPlayHead::CurrentPositionInfo position; playHead->getCurrentPosition (position); vstHostTime.tempo = position.bpm; vstHostTime.timeSigNumerator = position.timeSigNumerator; vstHostTime.timeSigDenominator = position.timeSigDenominator; vstHostTime.ppqPos = position.ppqPosition; vstHostTime.barStartPos = position.ppqPositionOfLastBarStart; vstHostTime.flags |= kVstTempoValid | kVstTimeSigValid | kVstPpqPosValid | kVstBarsValid; if (position.isPlaying) vstHostTime.flags |= kVstTransportPlaying; else vstHostTime.flags &= ~kVstTransportPlaying; } vstHostTime.nanoSeconds = getVSTHostTimeNanoseconds(); if (wantsMidiMessages) { midiEventsToSend.clear(); midiEventsToSend.ensureSize (1); MidiBuffer::Iterator iter (midiMessages); const uint8* midiData; int numBytesOfMidiData, samplePosition; while (iter.getNextEvent (midiData, numBytesOfMidiData, samplePosition)) { midiEventsToSend.addEvent (midiData, numBytesOfMidiData, jlimit (0, numSamples - 1, samplePosition)); } try { effect->dispatcher (effect, effProcessEvents, 0, 0, midiEventsToSend.events, 0); } catch (...) {} } _clearfp(); if ((effect->flags & effFlagsCanReplacing) != 0) { try { effect->processReplacing (effect, buffer.getArrayOfChannels(), buffer.getArrayOfChannels(), numSamples); } catch (...) {} } else { tempBuffer.setSize (effect->numOutputs, numSamples); tempBuffer.clear(); try { effect->process (effect, buffer.getArrayOfChannels(), tempBuffer.getArrayOfChannels(), numSamples); } catch (...) {} for (int i = effect->numOutputs; --i >= 0;) buffer.copyFrom (i, 0, tempBuffer.getSampleData (i), numSamples); } } else { // Not initialised, so just bypass.. for (int i = getNumInputChannels(); i < getNumOutputChannels(); ++i) buffer.clear (i, 0, buffer.getNumSamples()); } { // copy any incoming midi.. const ScopedLock sl (midiInLock); midiMessages.swapWith (incomingMidi); incomingMidi.clear(); } } //============================================================================== void VSTPluginInstance::handleMidiFromPlugin (const VstEvents* const events) { if (events != nullptr) { const ScopedLock sl (midiInLock); VSTMidiEventList::addEventsToMidiBuffer (events, incomingMidi); } } //============================================================================== static Array <VSTPluginWindow*> activeVSTWindows; //============================================================================== class VSTPluginWindow : public AudioProcessorEditor, #if ! JUCE_MAC public ComponentMovementWatcher, #endif public Timer { public: //============================================================================== VSTPluginWindow (VSTPluginInstance& plugin_) : AudioProcessorEditor (&plugin_), #if ! JUCE_MAC ComponentMovementWatcher (this), #endif plugin (plugin_), isOpen (false), recursiveResize (false), pluginWantsKeys (false), pluginRefusesToResize (false), alreadyInside (false) { #if JUCE_WINDOWS sizeCheckCount = 0; pluginHWND = 0; #elif JUCE_LINUX pluginWindow = None; pluginProc = None; #else addAndMakeVisible (innerWrapper = new InnerWrapperComponent (*this)); #endif activeVSTWindows.add (this); setSize (1, 1); setOpaque (true); setVisible (true); } ~VSTPluginWindow() { #if JUCE_MAC innerWrapper = nullptr; #else closePluginWindow(); #endif activeVSTWindows.removeValue (this); plugin.editorBeingDeleted (this); } //============================================================================== #if ! JUCE_MAC void componentMovedOrResized (bool /*wasMoved*/, bool /*wasResized*/) { if (recursiveResize) return; Component* const topComp = getTopLevelComponent(); if (topComp->getPeer() != nullptr) { const Point<int> pos (topComp->getLocalPoint (this, Point<int>())); recursiveResize = true; #if JUCE_WINDOWS if (pluginHWND != 0) MoveWindow (pluginHWND, pos.getX(), pos.getY(), getWidth(), getHeight(), TRUE); #elif JUCE_LINUX if (pluginWindow != 0) { XResizeWindow (display, pluginWindow, getWidth(), getHeight()); XMoveWindow (display, pluginWindow, pos.getX(), pos.getY()); XMapRaised (display, pluginWindow); } #endif recursiveResize = false; } } void componentVisibilityChanged() { if (isShowing()) openPluginWindow(); else closePluginWindow(); componentMovedOrResized (true, true); } void componentPeerChanged() { closePluginWindow(); openPluginWindow(); } #endif //============================================================================== bool keyStateChanged (bool) { return pluginWantsKeys; } bool keyPressed (const KeyPress&) { return pluginWantsKeys; } //============================================================================== #if JUCE_MAC void paint (Graphics& g) { g.fillAll (Colours::black); } #else void paint (Graphics& g) { if (isOpen) { ComponentPeer* const peer = getPeer(); if (peer != nullptr) { const Point<int> pos (getScreenPosition() - peer->getScreenPosition()); peer->addMaskedRegion (pos.getX(), pos.getY(), getWidth(), getHeight()); #if JUCE_LINUX if (pluginWindow != 0) { const Rectangle<int> clip (g.getClipBounds()); XEvent ev = { 0 }; ev.xexpose.type = Expose; ev.xexpose.display = display; ev.xexpose.window = pluginWindow; ev.xexpose.x = clip.getX(); ev.xexpose.y = clip.getY(); ev.xexpose.width = clip.getWidth(); ev.xexpose.height = clip.getHeight(); sendEventToChild (&ev); } #endif } } else { g.fillAll (Colours::black); } } #endif //============================================================================== void timerCallback() { #if JUCE_WINDOWS if (--sizeCheckCount <= 0) { sizeCheckCount = 10; checkPluginWindowSize(); } #endif try { static bool reentrant = false; if (! reentrant) { reentrant = true; plugin.dispatch (effEditIdle, 0, 0, 0, 0); reentrant = false; } } catch (...) {} } //============================================================================== void mouseDown (const MouseEvent& e) { #if JUCE_LINUX if (pluginWindow == 0) return; toFront (true); XEvent ev = { 0 }; ev.xbutton.display = display; ev.xbutton.type = ButtonPress; ev.xbutton.window = pluginWindow; ev.xbutton.root = RootWindow (display, DefaultScreen (display)); ev.xbutton.time = CurrentTime; ev.xbutton.x = e.x; ev.xbutton.y = e.y; ev.xbutton.x_root = e.getScreenX(); ev.xbutton.y_root = e.getScreenY(); translateJuceToXButtonModifiers (e, ev); sendEventToChild (&ev); #elif JUCE_WINDOWS (void) e; toFront (true); #endif } void broughtToFront() { activeVSTWindows.removeValue (this); activeVSTWindows.add (this); #if JUCE_MAC dispatch (effEditTop, 0, 0, 0, 0); #endif } //============================================================================== private: VSTPluginInstance& plugin; bool isOpen, recursiveResize; bool pluginWantsKeys, pluginRefusesToResize, alreadyInside; #if JUCE_WINDOWS HWND pluginHWND; void* originalWndProc; int sizeCheckCount; #elif JUCE_LINUX Window pluginWindow; EventProcPtr pluginProc; #endif //============================================================================== #if JUCE_MAC void openPluginWindow (WindowRef parentWindow) { if (isOpen || parentWindow == 0) return; isOpen = true; ERect* rect = nullptr; dispatch (effEditGetRect, 0, 0, &rect, 0); dispatch (effEditOpen, 0, 0, parentWindow, 0); // do this before and after like in the steinberg example dispatch (effEditGetRect, 0, 0, &rect, 0); dispatch (effGetProgram, 0, 0, 0, 0); // also in steinberg code // Install keyboard hooks pluginWantsKeys = (dispatch (effKeysRequired, 0, 0, 0, 0) == 0); // double-check it's not too tiny int w = 250, h = 150; if (rect != nullptr) { w = rect->right - rect->left; h = rect->bottom - rect->top; if (w == 0 || h == 0) { w = 250; h = 150; } } w = jmax (w, 32); h = jmax (h, 32); setSize (w, h); startTimer (18 + juce::Random::getSystemRandom().nextInt (5)); repaint(); } #else void openPluginWindow() { if (isOpen || getWindowHandle() == 0) return; log ("Opening VST UI: " + plugin.name); isOpen = true; ERect* rect = nullptr; dispatch (effEditGetRect, 0, 0, &rect, 0); dispatch (effEditOpen, 0, 0, getWindowHandle(), 0); // do this before and after like in the steinberg example dispatch (effEditGetRect, 0, 0, &rect, 0); dispatch (effGetProgram, 0, 0, 0, 0); // also in steinberg code // Install keyboard hooks pluginWantsKeys = (dispatch (effKeysRequired, 0, 0, 0, 0) == 0); #if JUCE_WINDOWS originalWndProc = 0; pluginHWND = GetWindow ((HWND) getWindowHandle(), GW_CHILD); if (pluginHWND == 0) { isOpen = false; setSize (300, 150); return; } #pragma warning (push) #pragma warning (disable: 4244) originalWndProc = (void*) GetWindowLongPtr (pluginHWND, GWLP_WNDPROC); if (! pluginWantsKeys) SetWindowLongPtr (pluginHWND, GWLP_WNDPROC, (LONG_PTR) vstHookWndProc); #pragma warning (pop) int w, h; RECT r; GetWindowRect (pluginHWND, &r); w = r.right - r.left; h = r.bottom - r.top; if (rect != nullptr) { const int rw = rect->right - rect->left; const int rh = rect->bottom - rect->top; if ((rw > 50 && rh > 50 && rw < 2000 && rh < 2000 && rw != w && rh != h) || ((w == 0 && rw > 0) || (h == 0 && rh > 0))) { // very dodgy logic to decide which size is right. if (abs (rw - w) > 350 || abs (rh - h) > 350) { SetWindowPos (pluginHWND, 0, 0, 0, rw, rh, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER); GetWindowRect (pluginHWND, &r); w = r.right - r.left; h = r.bottom - r.top; pluginRefusesToResize = (w != rw) || (h != rh); w = rw; h = rh; } } } #elif JUCE_LINUX pluginWindow = getChildWindow ((Window) getWindowHandle()); if (pluginWindow != 0) pluginProc = (EventProcPtr) getPropertyFromXWindow (pluginWindow, XInternAtom (display, "_XEventProc", False)); int w = 250, h = 150; if (rect != nullptr) { w = rect->right - rect->left; h = rect->bottom - rect->top; if (w == 0 || h == 0) { w = 250; h = 150; } } if (pluginWindow != 0) XMapRaised (display, pluginWindow); #endif // double-check it's not too tiny w = jmax (w, 32); h = jmax (h, 32); setSize (w, h); #if JUCE_WINDOWS checkPluginWindowSize(); #endif startTimer (18 + juce::Random::getSystemRandom().nextInt (5)); repaint(); } #endif //============================================================================== #if ! JUCE_MAC void closePluginWindow() { if (isOpen) { log ("Closing VST UI: " + plugin.getName()); isOpen = false; dispatch (effEditClose, 0, 0, 0, 0); #if JUCE_WINDOWS #pragma warning (push) #pragma warning (disable: 4244) if (pluginHWND != 0 && IsWindow (pluginHWND)) SetWindowLongPtr (pluginHWND, GWLP_WNDPROC, (LONG_PTR) originalWndProc); #pragma warning (pop) stopTimer(); if (pluginHWND != 0 && IsWindow (pluginHWND)) DestroyWindow (pluginHWND); pluginHWND = 0; #elif JUCE_LINUX stopTimer(); pluginWindow = 0; pluginProc = 0; #endif } } #endif //============================================================================== int dispatch (const int opcode, const int index, const int value, void* const ptr, float opt) { return plugin.dispatch (opcode, index, value, ptr, opt); } //============================================================================== #if JUCE_WINDOWS void checkPluginWindowSize() { RECT r; GetWindowRect (pluginHWND, &r); const int w = r.right - r.left; const int h = r.bottom - r.top; if (isShowing() && w > 0 && h > 0 && (w != getWidth() || h != getHeight()) && ! pluginRefusesToResize) { setSize (w, h); sizeCheckCount = 0; } } // hooks to get keyboard events from VST windows.. static LRESULT CALLBACK vstHookWndProc (HWND hW, UINT message, WPARAM wParam, LPARAM lParam) { for (int i = activeVSTWindows.size(); --i >= 0;) { const VSTPluginWindow* const w = activeVSTWindows.getUnchecked (i); if (w->pluginHWND == hW) { if (message == WM_CHAR || message == WM_KEYDOWN || message == WM_SYSKEYDOWN || message == WM_KEYUP || message == WM_SYSKEYUP || message == WM_APPCOMMAND) { SendMessage ((HWND) w->getTopLevelComponent()->getWindowHandle(), message, wParam, lParam); } return CallWindowProc ((WNDPROC) (w->originalWndProc), (HWND) w->pluginHWND, message, wParam, lParam); } } return DefWindowProc (hW, message, wParam, lParam); } #endif #if JUCE_LINUX //============================================================================== // overload mouse/keyboard events to forward them to the plugin's inner window.. void sendEventToChild (XEvent* event) { if (pluginProc != 0) { // if the plugin publishes an event procedure, pass the event directly.. pluginProc (event); } else if (pluginWindow != 0) { // if the plugin has a window, then send the event to the window so that // its message thread will pick it up.. XSendEvent (display, pluginWindow, False, 0L, event); XFlush (display); } } void mouseEnter (const MouseEvent& e) { if (pluginWindow != 0) { XEvent ev = { 0 }; ev.xcrossing.display = display; ev.xcrossing.type = EnterNotify; ev.xcrossing.window = pluginWindow; ev.xcrossing.root = RootWindow (display, DefaultScreen (display)); ev.xcrossing.time = CurrentTime; ev.xcrossing.x = e.x; ev.xcrossing.y = e.y; ev.xcrossing.x_root = e.getScreenX(); ev.xcrossing.y_root = e.getScreenY(); ev.xcrossing.mode = NotifyNormal; // NotifyGrab, NotifyUngrab ev.xcrossing.detail = NotifyAncestor; // NotifyVirtual, NotifyInferior, NotifyNonlinear,NotifyNonlinearVirtual translateJuceToXCrossingModifiers (e, ev); sendEventToChild (&ev); } } void mouseExit (const MouseEvent& e) { if (pluginWindow != 0) { XEvent ev = { 0 }; ev.xcrossing.display = display; ev.xcrossing.type = LeaveNotify; ev.xcrossing.window = pluginWindow; ev.xcrossing.root = RootWindow (display, DefaultScreen (display)); ev.xcrossing.time = CurrentTime; ev.xcrossing.x = e.x; ev.xcrossing.y = e.y; ev.xcrossing.x_root = e.getScreenX(); ev.xcrossing.y_root = e.getScreenY(); ev.xcrossing.mode = NotifyNormal; // NotifyGrab, NotifyUngrab ev.xcrossing.detail = NotifyAncestor; // NotifyVirtual, NotifyInferior, NotifyNonlinear,NotifyNonlinearVirtual ev.xcrossing.focus = hasKeyboardFocus (true); // TODO - yes ? translateJuceToXCrossingModifiers (e, ev); sendEventToChild (&ev); } } void mouseMove (const MouseEvent& e) { if (pluginWindow != 0) { XEvent ev = { 0 }; ev.xmotion.display = display; ev.xmotion.type = MotionNotify; ev.xmotion.window = pluginWindow; ev.xmotion.root = RootWindow (display, DefaultScreen (display)); ev.xmotion.time = CurrentTime; ev.xmotion.is_hint = NotifyNormal; ev.xmotion.x = e.x; ev.xmotion.y = e.y; ev.xmotion.x_root = e.getScreenX(); ev.xmotion.y_root = e.getScreenY(); sendEventToChild (&ev); } } void mouseDrag (const MouseEvent& e) { if (pluginWindow != 0) { XEvent ev = { 0 }; ev.xmotion.display = display; ev.xmotion.type = MotionNotify; ev.xmotion.window = pluginWindow; ev.xmotion.root = RootWindow (display, DefaultScreen (display)); ev.xmotion.time = CurrentTime; ev.xmotion.x = e.x ; ev.xmotion.y = e.y; ev.xmotion.x_root = e.getScreenX(); ev.xmotion.y_root = e.getScreenY(); ev.xmotion.is_hint = NotifyNormal; translateJuceToXMotionModifiers (e, ev); sendEventToChild (&ev); } } void mouseUp (const MouseEvent& e) { if (pluginWindow != 0) { XEvent ev = { 0 }; ev.xbutton.display = display; ev.xbutton.type = ButtonRelease; ev.xbutton.window = pluginWindow; ev.xbutton.root = RootWindow (display, DefaultScreen (display)); ev.xbutton.time = CurrentTime; ev.xbutton.x = e.x; ev.xbutton.y = e.y; ev.xbutton.x_root = e.getScreenX(); ev.xbutton.y_root = e.getScreenY(); translateJuceToXButtonModifiers (e, ev); sendEventToChild (&ev); } } void mouseWheelMove (const MouseEvent& e, float incrementX, float incrementY) { if (pluginWindow != 0) { XEvent ev = { 0 }; ev.xbutton.display = display; ev.xbutton.type = ButtonPress; ev.xbutton.window = pluginWindow; ev.xbutton.root = RootWindow (display, DefaultScreen (display)); ev.xbutton.time = CurrentTime; ev.xbutton.x = e.x; ev.xbutton.y = e.y; ev.xbutton.x_root = e.getScreenX(); ev.xbutton.y_root = e.getScreenY(); translateJuceToXMouseWheelModifiers (e, incrementY, ev); sendEventToChild (&ev); // TODO - put a usleep here ? ev.xbutton.type = ButtonRelease; sendEventToChild (&ev); } } #endif #if JUCE_MAC //============================================================================== #if ! JUCE_SUPPORT_CARBON #error "To build VSTs, you need to enable the JUCE_SUPPORT_CARBON flag in your config!" #endif class InnerWrapperComponent : public CarbonViewWrapperComponent { public: InnerWrapperComponent (VSTPluginWindow& owner_) : owner (owner_), alreadyInside (false) { } ~InnerWrapperComponent() { deleteWindow(); } HIViewRef attachView (WindowRef windowRef, HIViewRef rootView) { owner.openPluginWindow (windowRef); return 0; } void removeView (HIViewRef) { if (owner.isOpen) { owner.isOpen = false; owner.dispatch (effEditClose, 0, 0, 0, 0); owner.dispatch (effEditSleep, 0, 0, 0, 0); } } bool getEmbeddedViewSize (int& w, int& h) { ERect* rect = nullptr; owner.dispatch (effEditGetRect, 0, 0, &rect, 0); w = rect->right - rect->left; h = rect->bottom - rect->top; return true; } void mouseDown (int x, int y) { if (! alreadyInside) { alreadyInside = true; getTopLevelComponent()->toFront (true); owner.dispatch (effEditMouse, x, y, 0, 0); alreadyInside = false; } else { PostEvent (::mouseDown, 0); } } void paint() { ComponentPeer* const peer = getPeer(); if (peer != nullptr) { const Point<int> pos (getScreenPosition() - peer->getScreenPosition()); ERect r; r.left = pos.getX(); r.right = r.left + getWidth(); r.top = pos.getY(); r.bottom = r.top + getHeight(); owner.dispatch (effEditDraw, 0, 0, &r, 0); } } private: VSTPluginWindow& owner; bool alreadyInside; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (InnerWrapperComponent); }; friend class InnerWrapperComponent; ScopedPointer <InnerWrapperComponent> innerWrapper; void resized() { if (innerWrapper != nullptr) innerWrapper->setSize (getWidth(), getHeight()); } #endif private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VSTPluginWindow); }; //============================================================================== AudioProcessorEditor* VSTPluginInstance::createEditor() { if (hasEditor()) return new VSTPluginWindow (*this); return nullptr; } //============================================================================== void VSTPluginInstance::handleAsyncUpdate() { // indicates that something about the plugin has changed.. updateHostDisplay(); } //============================================================================== bool VSTPluginInstance::restoreProgramSettings (const fxProgram* const prog) { if (vst_swap (prog->chunkMagic) == 'CcnK' && vst_swap (prog->fxMagic) == 'FxCk') { changeProgramName (getCurrentProgram(), prog->prgName); for (int i = 0; i < vst_swap (prog->numParams); ++i) setParameter (i, vst_swapFloat (prog->params[i])); return true; } return false; } bool VSTPluginInstance::loadFromFXBFile (const void* const data, const int dataSize) { if (dataSize < 28) return false; const fxSet* const set = (const fxSet*) data; if ((vst_swap (set->chunkMagic) != 'CcnK' && vst_swap (set->chunkMagic) != 'KncC') || vst_swap (set->version) > fxbVersionNum) return false; if (vst_swap (set->fxMagic) == 'FxBk') { // bank of programs if (vst_swap (set->numPrograms) >= 0) { const int oldProg = getCurrentProgram(); const int numParams = vst_swap (((const fxProgram*) (set->programs))->numParams); const int progLen = sizeof (fxProgram) + (numParams - 1) * sizeof (float); for (int i = 0; i < vst_swap (set->numPrograms); ++i) { if (i != oldProg) { const fxProgram* const prog = (const fxProgram*) (((const char*) (set->programs)) + i * progLen); if (((const char*) prog) - ((const char*) set) >= dataSize) return false; if (vst_swap (set->numPrograms) > 0) setCurrentProgram (i); if (! restoreProgramSettings (prog)) return false; } } if (vst_swap (set->numPrograms) > 0) setCurrentProgram (oldProg); const fxProgram* const prog = (const fxProgram*) (((const char*) (set->programs)) + oldProg * progLen); if (((const char*) prog) - ((const char*) set) >= dataSize) return false; if (! restoreProgramSettings (prog)) return false; } } else if (vst_swap (set->fxMagic) == 'FxCk') { // single program const fxProgram* const prog = (const fxProgram*) data; if (vst_swap (prog->chunkMagic) != 'CcnK') return false; changeProgramName (getCurrentProgram(), prog->prgName); for (int i = 0; i < vst_swap (prog->numParams); ++i) setParameter (i, vst_swapFloat (prog->params[i])); } else if (vst_swap (set->fxMagic) == 'FBCh' || vst_swap (set->fxMagic) == 'hCBF') { // non-preset chunk const fxChunkSet* const cset = (const fxChunkSet*) data; if (vst_swap (cset->chunkSize) + sizeof (fxChunkSet) - 8 > (unsigned int) dataSize) return false; setChunkData (cset->chunk, vst_swap (cset->chunkSize), false); } else if (vst_swap (set->fxMagic) == 'FPCh' || vst_swap (set->fxMagic) == 'hCPF') { // preset chunk const fxProgramSet* const cset = (const fxProgramSet*) data; if (vst_swap (cset->chunkSize) + sizeof (fxProgramSet) - 8 > (unsigned int) dataSize) return false; setChunkData (cset->chunk, vst_swap (cset->chunkSize), true); changeProgramName (getCurrentProgram(), cset->name); } else { return false; } return true; } //============================================================================== void VSTPluginInstance::setParamsInProgramBlock (fxProgram* const prog) { const int numParams = getNumParameters(); prog->chunkMagic = vst_swap ('CcnK'); prog->byteSize = 0; prog->fxMagic = vst_swap ('FxCk'); prog->version = vst_swap (fxbVersionNum); prog->fxID = vst_swap (getUID()); prog->fxVersion = vst_swap (getVersionNumber()); prog->numParams = vst_swap (numParams); getCurrentProgramName().copyToUTF8 (prog->prgName, sizeof (prog->prgName) - 1); for (int i = 0; i < numParams; ++i) prog->params[i] = vst_swapFloat (getParameter (i)); } bool VSTPluginInstance::saveToFXBFile (MemoryBlock& dest, bool isFXB, int maxSizeMB) { const int numPrograms = getNumPrograms(); const int numParams = getNumParameters(); if (usesChunks()) { MemoryBlock chunk; getChunkData (chunk, ! isFXB, maxSizeMB); if (isFXB) { const size_t totalLen = sizeof (fxChunkSet) + chunk.getSize() - 8; dest.setSize (totalLen, true); fxChunkSet* const set = (fxChunkSet*) dest.getData(); set->chunkMagic = vst_swap ('CcnK'); set->byteSize = 0; set->fxMagic = vst_swap ('FBCh'); set->version = vst_swap (fxbVersionNum); set->fxID = vst_swap (getUID()); set->fxVersion = vst_swap (getVersionNumber()); set->numPrograms = vst_swap (numPrograms); set->chunkSize = vst_swap ((long) chunk.getSize()); chunk.copyTo (set->chunk, 0, chunk.getSize()); } else { const size_t totalLen = sizeof (fxProgramSet) + chunk.getSize() - 8; dest.setSize (totalLen, true); fxProgramSet* const set = (fxProgramSet*) dest.getData(); set->chunkMagic = vst_swap ('CcnK'); set->byteSize = 0; set->fxMagic = vst_swap ('FPCh'); set->version = vst_swap (fxbVersionNum); set->fxID = vst_swap (getUID()); set->fxVersion = vst_swap (getVersionNumber()); set->numPrograms = vst_swap (numPrograms); set->chunkSize = vst_swap ((long) chunk.getSize()); getCurrentProgramName().copyToUTF8 (set->name, sizeof (set->name) - 1); chunk.copyTo (set->chunk, 0, chunk.getSize()); } } else { if (isFXB) { const int progLen = sizeof (fxProgram) + (numParams - 1) * sizeof (float); const int len = (sizeof (fxSet) - sizeof (fxProgram)) + progLen * jmax (1, numPrograms); dest.setSize (len, true); fxSet* const set = (fxSet*) dest.getData(); set->chunkMagic = vst_swap ('CcnK'); set->byteSize = 0; set->fxMagic = vst_swap ('FxBk'); set->version = vst_swap (fxbVersionNum); set->fxID = vst_swap (getUID()); set->fxVersion = vst_swap (getVersionNumber()); set->numPrograms = vst_swap (numPrograms); const int oldProgram = getCurrentProgram(); MemoryBlock oldSettings; createTempParameterStore (oldSettings); setParamsInProgramBlock ((fxProgram*) (((char*) (set->programs)) + oldProgram * progLen)); for (int i = 0; i < numPrograms; ++i) { if (i != oldProgram) { setCurrentProgram (i); setParamsInProgramBlock ((fxProgram*) (((char*) (set->programs)) + i * progLen)); } } setCurrentProgram (oldProgram); restoreFromTempParameterStore (oldSettings); } else { const int totalLen = sizeof (fxProgram) + (numParams - 1) * sizeof (float); dest.setSize (totalLen, true); setParamsInProgramBlock ((fxProgram*) dest.getData()); } } return true; } void VSTPluginInstance::getChunkData (MemoryBlock& mb, bool isPreset, int maxSizeMB) const { if (usesChunks()) { void* data = nullptr; const int bytes = dispatch (effGetChunk, isPreset ? 1 : 0, 0, &data, 0.0f); if (data != nullptr && bytes <= maxSizeMB * 1024 * 1024) { mb.setSize (bytes); mb.copyFrom (data, 0, bytes); } } } void VSTPluginInstance::setChunkData (const char* data, int size, bool isPreset) { if (size > 0 && usesChunks()) { dispatch (effSetChunk, isPreset ? 1 : 0, size, (void*) data, 0.0f); if (! isPreset) updateStoredProgramNames(); } } //============================================================================== void VSTPluginInstance::timerCallback() { if (dispatch (effIdle, 0, 0, 0, 0) == 0) stopTimer(); } int VSTPluginInstance::dispatch (const int opcode, const int index, const int value, void* const ptr, float opt) const { int result = 0; if (effect != nullptr) { const ScopedLock sl (lock); const IdleCallRecursionPreventer icrp; try { #if JUCE_MAC if (module->resFileId != 0) UseResFile (module->resFileId); #endif result = effect->dispatcher (effect, opcode, index, value, ptr, opt); #if JUCE_MAC module->resFileId = CurResFile(); #endif } catch (...) {} } return result; } //============================================================================== namespace { static const int defaultVSTSampleRateValue = 44100; static const int defaultVSTBlockSizeValue = 512; // handles non plugin-specific callbacks.. VstIntPtr handleGeneralCallback (VstInt32 opcode, VstInt32 index, VstInt32 value, void *ptr, float opt) { (void) index; (void) value; (void) opt; switch (opcode) { case audioMasterCanDo: { static const char* canDos[] = { "supplyIdle", "sendVstEvents", "sendVstMidiEvent", "sendVstTimeInfo", "receiveVstEvents", "receiveVstMidiEvent", "supportShell", "shellCategory" }; for (int i = 0; i < numElementsInArray (canDos); ++i) if (strcmp (canDos[i], (const char*) ptr) == 0) return 1; return 0; } case audioMasterVersion: return 0x2400; case audioMasterCurrentId: return shellUIDToCreate; case audioMasterGetNumAutomatableParameters: return 0; case audioMasterGetAutomationState: return 1; case audioMasterGetVendorVersion: return 0x0101; case audioMasterGetVendorString: case audioMasterGetProductString: { String hostName ("Juce VST Host"); if (JUCEApplication::getInstance() != nullptr) hostName = JUCEApplication::getInstance()->getApplicationName(); hostName.copyToUTF8 ((char*) ptr, jmin (kVstMaxVendorStrLen, kVstMaxProductStrLen) - 1); break; } case audioMasterGetSampleRate: return (VstIntPtr) defaultVSTSampleRateValue; case audioMasterGetBlockSize: return (VstIntPtr) defaultVSTBlockSizeValue; case audioMasterSetOutputSampleRate: return 0; default: DBG ("*** Unhandled VST Callback: " + String ((int) opcode)); break; } return 0; } } // handles callbacks for a specific plugin VstIntPtr VSTPluginInstance::handleCallback (VstInt32 opcode, VstInt32 index, VstInt32 value, void *ptr, float opt) { switch (opcode) { case audioMasterAutomate: sendParamChangeMessageToListeners (index, opt); break; case audioMasterProcessEvents: handleMidiFromPlugin ((const VstEvents*) ptr); break; case audioMasterGetTime: #if JUCE_MSVC #pragma warning (push) #pragma warning (disable: 4311) #endif return (VstIntPtr) &vstHostTime; #if JUCE_MSVC #pragma warning (pop) #endif break; case audioMasterIdle: if (insideVSTCallback == 0 && MessageManager::getInstance()->isThisTheMessageThread()) { const IdleCallRecursionPreventer icrp; #if JUCE_MAC if (getActiveEditor() != nullptr) dispatch (effEditIdle, 0, 0, 0, 0); #endif Timer::callPendingTimersSynchronously(); handleUpdateNowIfNeeded(); for (int i = ComponentPeer::getNumPeers(); --i >= 0;) ComponentPeer::getPeer (i)->performAnyPendingRepaintsNow(); } break; case audioMasterUpdateDisplay: triggerAsyncUpdate(); break; case audioMasterTempoAt: // returns (10000 * bpm) break; case audioMasterNeedIdle: startTimer (50); break; case audioMasterSizeWindow: if (getActiveEditor() != nullptr) getActiveEditor()->setSize (index, value); return 1; case audioMasterGetSampleRate: return (VstIntPtr) (getSampleRate() > 0 ? getSampleRate() : defaultVSTSampleRateValue); case audioMasterGetBlockSize: return (VstIntPtr) (getBlockSize() > 0 ? getBlockSize() : defaultVSTBlockSizeValue); case audioMasterWantMidi: wantsMidiMessages = true; break; case audioMasterGetDirectory: #if JUCE_MAC return (VstIntPtr) (void*) &module->parentDirFSSpec; #else return (VstIntPtr) (pointer_sized_uint) module->fullParentDirectoryPathName.toUTF8().getAddress(); #endif case audioMasterGetAutomationState: // returns 0: not supported, 1: off, 2:read, 3:write, 4:read/write break; case audioMasterPinConnected: if (value == 0) // input { if (index < getNumInputChannels()) return 0; } else // output { if (index < getNumOutputChannels()) return 0; } return 1; // (not connected) // none of these are handled (yet).. case audioMasterBeginEdit: case audioMasterEndEdit: case audioMasterSetTime: case audioMasterGetParameterQuantization: case audioMasterIOChanged: case audioMasterGetInputLatency: case audioMasterGetOutputLatency: case audioMasterGetPreviousPlug: case audioMasterGetNextPlug: case audioMasterWillReplaceOrAccumulate: case audioMasterGetCurrentProcessLevel: case audioMasterOfflineStart: case audioMasterOfflineRead: case audioMasterOfflineWrite: case audioMasterOfflineGetCurrentPass: case audioMasterOfflineGetCurrentMetaPass: case audioMasterVendorSpecific: case audioMasterSetIcon: case audioMasterGetLanguage: case audioMasterOpenWindow: case audioMasterCloseWindow: break; default: return handleGeneralCallback (opcode, index, value, ptr, opt); } return 0; } // entry point for all callbacks from the plugin static VstIntPtr VSTCALLBACK audioMaster (AEffect* effect, VstInt32 opcode, VstInt32 index, VstIntPtr value, void* ptr, float opt) { try { if (effect != nullptr && effect->resvd2 != 0) { return ((VSTPluginInstance*)(effect->resvd2)) ->handleCallback (opcode, index, value, ptr, opt); } return handleGeneralCallback (opcode, index, value, ptr, opt); } catch (...) { return 0; } } //============================================================================== String VSTPluginInstance::getVersion() const { unsigned int v = dispatch (effGetVendorVersion, 0, 0, 0, 0); String s; if (v == 0 || v == -1) v = getVersionNumber(); if (v != 0) { int versionBits[4]; int n = 0; while (v != 0) { versionBits [n++] = (v & 0xff); v >>= 8; } s << 'V'; while (n > 0) { s << versionBits [--n]; if (n > 0) s << '.'; } } return s; } int VSTPluginInstance::getUID() const { int uid = effect != nullptr ? effect->uniqueID : 0; if (uid == 0) uid = module->file.hashCode(); return uid; } String VSTPluginInstance::getCategory() const { const char* result = nullptr; switch (dispatch (effGetPlugCategory, 0, 0, 0, 0)) { case kPlugCategEffect: result = "Effect"; break; case kPlugCategSynth: result = "Synth"; break; case kPlugCategAnalysis: result = "Analysis"; break; case kPlugCategMastering: result = "Mastering"; break; case kPlugCategSpacializer: result = "Spacial"; break; case kPlugCategRoomFx: result = "Reverb"; break; case kPlugSurroundFx: result = "Surround"; break; case kPlugCategRestoration: result = "Restoration"; break; case kPlugCategGenerator: result = "Tone generation"; break; default: break; } return result; } //============================================================================== float VSTPluginInstance::getParameter (int index) { if (effect != nullptr && isPositiveAndBelow (index, (int) effect->numParams)) { try { const ScopedLock sl (lock); return effect->getParameter (effect, index); } catch (...) { } } return 0.0f; } void VSTPluginInstance::setParameter (int index, float newValue) { if (effect != nullptr && isPositiveAndBelow (index, (int) effect->numParams)) { try { const ScopedLock sl (lock); if (effect->getParameter (effect, index) != newValue) effect->setParameter (effect, index, newValue); } catch (...) { } } } const String VSTPluginInstance::getParameterName (int index) { if (effect != nullptr) { jassert (index >= 0 && index < effect->numParams); char nm [256] = { 0 }; dispatch (effGetParamName, index, 0, nm, 0); return String (nm).trim(); } return String::empty; } const String VSTPluginInstance::getParameterLabel (int index) const { if (effect != nullptr) { jassert (index >= 0 && index < effect->numParams); char nm [256] = { 0 }; dispatch (effGetParamLabel, index, 0, nm, 0); return String (nm).trim(); } return String::empty; } const String VSTPluginInstance::getParameterText (int index) { if (effect != nullptr) { jassert (index >= 0 && index < effect->numParams); char nm [256] = { 0 }; dispatch (effGetParamDisplay, index, 0, nm, 0); return String (nm).trim(); } return String::empty; } bool VSTPluginInstance::isParameterAutomatable (int index) const { if (effect != nullptr) { jassert (index >= 0 && index < effect->numParams); return dispatch (effCanBeAutomated, index, 0, 0, 0) != 0; } return false; } void VSTPluginInstance::createTempParameterStore (MemoryBlock& dest) { dest.setSize (64 + 4 * getNumParameters()); dest.fillWith (0); getCurrentProgramName().copyToUTF8 ((char*) dest.getData(), 63); float* const p = (float*) (((char*) dest.getData()) + 64); for (int i = 0; i < getNumParameters(); ++i) p[i] = getParameter(i); } void VSTPluginInstance::restoreFromTempParameterStore (const MemoryBlock& m) { changeProgramName (getCurrentProgram(), (const char*) m.getData()); float* p = (float*) (((char*) m.getData()) + 64); for (int i = 0; i < getNumParameters(); ++i) setParameter (i, p[i]); } //============================================================================== void VSTPluginInstance::setCurrentProgram (int newIndex) { if (getNumPrograms() > 0 && newIndex != getCurrentProgram()) dispatch (effSetProgram, 0, jlimit (0, getNumPrograms() - 1, newIndex), 0, 0); } const String VSTPluginInstance::getProgramName (int index) { if (index == getCurrentProgram()) { return getCurrentProgramName(); } else if (effect != nullptr) { char nm [256] = { 0 }; if (dispatch (effGetProgramNameIndexed, jlimit (0, getNumPrograms(), index), -1, nm, 0) != 0) { return String (CharPointer_UTF8 (nm)).trim(); } } return programNames [index]; } void VSTPluginInstance::changeProgramName (int index, const String& newName) { if (index == getCurrentProgram()) { if (getNumPrograms() > 0 && newName != getCurrentProgramName()) dispatch (effSetProgramName, 0, 0, (void*) newName.substring (0, 24).toUTF8().getAddress(), 0.0f); } else { jassertfalse; // xxx not implemented! } } void VSTPluginInstance::updateStoredProgramNames() { if (effect != nullptr && getNumPrograms() > 0) { char nm [256] = { 0 }; // only do this if the plugin can't use indexed names.. if (dispatch (effGetProgramNameIndexed, 0, -1, nm, 0) == 0) { const int oldProgram = getCurrentProgram(); MemoryBlock oldSettings; createTempParameterStore (oldSettings); for (int i = 0; i < getNumPrograms(); ++i) { setCurrentProgram (i); getCurrentProgramName(); // (this updates the list) } setCurrentProgram (oldProgram); restoreFromTempParameterStore (oldSettings); } } } const String VSTPluginInstance::getCurrentProgramName() { if (effect != nullptr) { char nm [256] = { 0 }; dispatch (effGetProgramName, 0, 0, nm, 0); const int index = getCurrentProgram(); if (programNames[index].isEmpty()) { while (programNames.size() < index) programNames.add (String::empty); programNames.set (index, String (nm).trim()); } return String (nm).trim(); } return String::empty; } //============================================================================== const String VSTPluginInstance::getInputChannelName (int index) const { if (index >= 0 && index < getNumInputChannels()) { VstPinProperties pinProps; if (dispatch (effGetInputProperties, index, 0, &pinProps, 0.0f) != 0) return String (pinProps.label, sizeof (pinProps.label)); } return String::empty; } bool VSTPluginInstance::isInputChannelStereoPair (int index) const { if (index < 0 || index >= getNumInputChannels()) return false; VstPinProperties pinProps; if (dispatch (effGetInputProperties, index, 0, &pinProps, 0.0f) != 0) return (pinProps.flags & kVstPinIsStereo) != 0; return true; } const String VSTPluginInstance::getOutputChannelName (int index) const { if (index >= 0 && index < getNumOutputChannels()) { VstPinProperties pinProps; if (dispatch (effGetOutputProperties, index, 0, &pinProps, 0.0f) != 0) return String (pinProps.label, sizeof (pinProps.label)); } return String::empty; } bool VSTPluginInstance::isOutputChannelStereoPair (int index) const { if (index < 0 || index >= getNumOutputChannels()) return false; VstPinProperties pinProps; if (dispatch (effGetOutputProperties, index, 0, &pinProps, 0.0f) != 0) return (pinProps.flags & kVstPinIsStereo) != 0; return true; } //============================================================================== void VSTPluginInstance::setPower (const bool on) { dispatch (effMainsChanged, 0, on ? 1 : 0, 0, 0); isPowerOn = on; } //============================================================================== const int defaultMaxSizeMB = 64; void VSTPluginInstance::getStateInformation (MemoryBlock& destData) { saveToFXBFile (destData, true, defaultMaxSizeMB); } void VSTPluginInstance::getCurrentProgramStateInformation (MemoryBlock& destData) { saveToFXBFile (destData, false, defaultMaxSizeMB); } void VSTPluginInstance::setStateInformation (const void* data, int sizeInBytes) { loadFromFXBFile (data, sizeInBytes); } void VSTPluginInstance::setCurrentProgramStateInformation (const void* data, int sizeInBytes) { loadFromFXBFile (data, sizeInBytes); } //============================================================================== //============================================================================== VSTPluginFormat::VSTPluginFormat() { } VSTPluginFormat::~VSTPluginFormat() { } void VSTPluginFormat::findAllTypesForFile (OwnedArray <PluginDescription>& results, const String& fileOrIdentifier) { if (! fileMightContainThisPluginType (fileOrIdentifier)) return; PluginDescription desc; desc.fileOrIdentifier = fileOrIdentifier; desc.uid = 0; ScopedPointer <VSTPluginInstance> instance (dynamic_cast <VSTPluginInstance*> (createInstanceFromDescription (desc))); if (instance == 0) return; try { #if JUCE_MAC if (instance->module->resFileId != 0) UseResFile (instance->module->resFileId); #endif instance->fillInPluginDescription (desc); VstPlugCategory category = (VstPlugCategory) instance->dispatch (effGetPlugCategory, 0, 0, 0, 0); if (category != kPlugCategShell) { // Normal plugin... results.add (new PluginDescription (desc)); instance->dispatch (effOpen, 0, 0, 0, 0); } else { // It's a shell plugin, so iterate all the subtypes... for (;;) { char shellEffectName [64] = { 0 }; const int uid = instance->dispatch (effShellGetNextPlugin, 0, 0, shellEffectName, 0); if (uid == 0) { break; } else { desc.uid = uid; desc.name = shellEffectName; desc.descriptiveName = shellEffectName; bool alreadyThere = false; for (int i = results.size(); --i >= 0;) { PluginDescription* const d = results.getUnchecked(i); if (d->isDuplicateOf (desc)) { alreadyThere = true; break; } } if (! alreadyThere) results.add (new PluginDescription (desc)); } } } } catch (...) { // crashed while loading... } } AudioPluginInstance* VSTPluginFormat::createInstanceFromDescription (const PluginDescription& desc) { ScopedPointer <VSTPluginInstance> result; if (fileMightContainThisPluginType (desc.fileOrIdentifier)) { File file (desc.fileOrIdentifier); const File previousWorkingDirectory (File::getCurrentWorkingDirectory()); file.getParentDirectory().setAsCurrentWorkingDirectory(); const ReferenceCountedObjectPtr <ModuleHandle> module (ModuleHandle::findOrCreateModule (file)); if (module != nullptr) { shellUIDToCreate = desc.uid; result = new VSTPluginInstance (module); if (result->effect != nullptr) { result->effect->resvd2 = (VstIntPtr) (pointer_sized_int) (VSTPluginInstance*) result; result->initialise(); } else { result = nullptr; } } previousWorkingDirectory.setAsCurrentWorkingDirectory(); } return result.release(); } bool VSTPluginFormat::fileMightContainThisPluginType (const String& fileOrIdentifier) { const File f (fileOrIdentifier); #if JUCE_MAC if (f.isDirectory() && f.hasFileExtension (".vst")) return true; #if JUCE_PPC FSRef fileRef; if (makeFSRefFromPath (&fileRef, f.getFullPathName())) { const short resFileId = FSOpenResFile (&fileRef, fsRdPerm); if (resFileId != -1) { const int numEffects = Count1Resources ('aEff'); CloseResFile (resFileId); if (numEffects > 0) return true; } } #endif return false; #elif JUCE_WINDOWS return f.existsAsFile() && f.hasFileExtension (".dll"); #elif JUCE_LINUX return f.existsAsFile() && f.hasFileExtension (".so"); #endif } String VSTPluginFormat::getNameOfPluginFromIdentifier (const String& fileOrIdentifier) { return fileOrIdentifier; } bool VSTPluginFormat::doesPluginStillExist (const PluginDescription& desc) { return File (desc.fileOrIdentifier).exists(); } StringArray VSTPluginFormat::searchPathsForPlugins (const FileSearchPath& directoriesToSearch, const bool recursive) { StringArray results; for (int j = 0; j < directoriesToSearch.getNumPaths(); ++j) recursiveFileSearch (results, directoriesToSearch [j], recursive); return results; } void VSTPluginFormat::recursiveFileSearch (StringArray& results, const File& dir, const bool recursive) { // avoid allowing the dir iterator to be recursive, because we want to avoid letting it delve inside // .component or .vst directories. DirectoryIterator iter (dir, false, "*", File::findFilesAndDirectories); while (iter.next()) { const File f (iter.getFile()); bool isPlugin = false; if (fileMightContainThisPluginType (f.getFullPathName())) { isPlugin = true; results.add (f.getFullPathName()); } if (recursive && (! isPlugin) && f.isDirectory()) recursiveFileSearch (results, f, true); } } FileSearchPath VSTPluginFormat::getDefaultLocationsToSearch() { #if JUCE_MAC return FileSearchPath ("~/Library/Audio/Plug-Ins/VST;/Library/Audio/Plug-Ins/VST"); #elif JUCE_WINDOWS const String programFiles (File::getSpecialLocation (File::globalApplicationsDirectory).getFullPathName()); return FileSearchPath (programFiles + "\\Steinberg\\VstPlugins"); #elif JUCE_LINUX return FileSearchPath ("/usr/lib/vst"); #endif } END_JUCE_NAMESPACE #endif #undef log #endif
[ [ [ 1, 2918 ] ] ]
690ab93b25d6e6da5ecc578fc64d5dc1f45a6fcb
f54dca64cbc02f9c0ebdfe57333fe4f63bed7fa1
/libneural/RPROPSupervisor.h
c566a53bc5f6d727844e41f7e6acc9a5dadbec4e
[]
no_license
tom3q/cowiek-maupa
f67b590e500d417e16277a979d063d0969808e3e
6ce9330ce3252f0ed6961ec09dd9a0dcb83e4c18
refs/heads/master
2019-01-02T08:48:26.605680
2011-12-11T18:08:47
2011-12-11T18:08:47
32,119,555
0
0
null
null
null
null
UTF-8
C++
false
false
674
h
#ifndef RPROP_SUPERVISOR_H #define RPROP_SUPERVISOR_H #include <vector> #include "Supervisor.h" #include "Matrix2D.h" class RPROPSupervisor : public Supervisor { public: RPROPSupervisor(); RPROPSupervisor(double min, double max, double a, double b); virtual void train(); void setNMin(double val); void setNMax(double val); void setA(double val); void setB(double val); double getNMin() const; double getNMax() const; double getA() const; double getB() const; private: void buildData(); std::vector<Matrix2D> n_, errorDrv_, prevDrv_; std::vector<std::vector<double> > delta_; double nMax_, nMin_, a_, b_; }; #endif
[ [ [ 1, 4 ], [ 6, 8 ], [ 10, 12 ], [ 14, 14 ], [ 16, 16 ], [ 27, 27 ], [ 30, 35 ] ], [ [ 5, 5 ], [ 9, 9 ], [ 13, 13 ], [ 15, 15 ], [ 17, 26 ], [ 28, 29 ] ] ]
75e3b863e147051bb4c3431c5a5abb5cfd1e6908
f8403b6b1005f80d2db7fad9ee208887cdca6aec
/JuceLibraryCode/modules/juce_graphics/colour/juce_PixelFormats.h
f2ed0114c32c28de6f62f50a2715312f5b44aca0
[]
no_license
sonic59/JuceText
25544cb07e5b414f9d7109c0826a16fc1de2e0d4
5ac010ffe59c2025d25bc0f9c02fc829ada9a3d2
refs/heads/master
2021-01-15T13:18:11.670907
2011-10-29T19:03:25
2011-10-29T19:03:25
2,507,112
0
0
null
null
null
null
UTF-8
C++
false
false
19,220
h
/* ============================================================================== This file is part of the JUCE library - "Jules' Utility Class Extensions" Copyright 2004-11 by Raw Material Software Ltd. ------------------------------------------------------------------------------ JUCE can be redistributed and/or modified under the terms of the GNU General Public License (Version 2), as published by the Free Software Foundation. A copy of the license is included in the JUCE distribution, or can be found online at www.gnu.org/licenses. JUCE 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. ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are available: visit www.rawmaterialsoftware.com/juce for more information. ============================================================================== */ #ifndef __JUCE_PIXELFORMATS_JUCEHEADER__ #define __JUCE_PIXELFORMATS_JUCEHEADER__ //============================================================================== #ifndef DOXYGEN #if JUCE_MSVC #pragma pack (push, 1) #define PACKED #elif JUCE_GCC #define PACKED __attribute__((packed)) #else #define PACKED #endif #endif class PixelRGB; class PixelAlpha; //============================================================================== /** Represents a 32-bit ARGB pixel with premultiplied alpha, and can perform compositing operations with it. This is used internally by the imaging classes. @see PixelRGB */ class JUCE_API PixelARGB { public: /** Creates a pixel without defining its colour. */ PixelARGB() noexcept {} ~PixelARGB() noexcept {} /** Creates a pixel from a 32-bit argb value. */ PixelARGB (const uint32 argb_) noexcept : argb (argb_) { } PixelARGB (const uint8 a, const uint8 r, const uint8 g, const uint8 b) noexcept { components.b = b; components.g = g; components.r = r; components.a = a; } forcedinline uint32 getARGB() const noexcept { return argb; } forcedinline uint32 getUnpremultipliedARGB() const noexcept { PixelARGB p (argb); p.unpremultiply(); return p.getARGB(); } forcedinline uint32 getRB() const noexcept { return 0x00ff00ff & argb; } forcedinline uint32 getAG() const noexcept { return 0x00ff00ff & (argb >> 8); } forcedinline uint8 getAlpha() const noexcept { return components.a; } forcedinline uint8 getRed() const noexcept { return components.r; } forcedinline uint8 getGreen() const noexcept { return components.g; } forcedinline uint8 getBlue() const noexcept { return components.b; } /** Blends another pixel onto this one. This takes into account the opacity of the pixel being overlaid, and blends it accordingly. */ forcedinline void blend (const PixelARGB& src) noexcept { uint32 sargb = src.getARGB(); const uint32 alpha = 0x100 - (sargb >> 24); sargb += 0x00ff00ff & ((getRB() * alpha) >> 8); sargb += 0xff00ff00 & (getAG() * alpha); argb = sargb; } /** Blends another pixel onto this one. This takes into account the opacity of the pixel being overlaid, and blends it accordingly. */ forcedinline void blend (const PixelAlpha& src) noexcept; /** Blends another pixel onto this one. This takes into account the opacity of the pixel being overlaid, and blends it accordingly. */ forcedinline void blend (const PixelRGB& src) noexcept; /** Blends another pixel onto this one, applying an extra multiplier to its opacity. The opacity of the pixel being overlaid is scaled by the extraAlpha factor before being used, so this can blend semi-transparently from a PixelRGB argument. */ template <class Pixel> forcedinline void blend (const Pixel& src, uint32 extraAlpha) noexcept { ++extraAlpha; uint32 sargb = ((extraAlpha * src.getAG()) & 0xff00ff00) | (((extraAlpha * src.getRB()) >> 8) & 0x00ff00ff); const uint32 alpha = 0x100 - (sargb >> 24); sargb += 0x00ff00ff & ((getRB() * alpha) >> 8); sargb += 0xff00ff00 & (getAG() * alpha); argb = sargb; } /** Blends another pixel with this one, creating a colour that is somewhere between the two, as specified by the amount. */ template <class Pixel> forcedinline void tween (const Pixel& src, const uint32 amount) noexcept { uint32 drb = getRB(); drb += (((src.getRB() - drb) * amount) >> 8); drb &= 0x00ff00ff; uint32 dag = getAG(); dag += (((src.getAG() - dag) * amount) >> 8); dag &= 0x00ff00ff; dag <<= 8; dag |= drb; argb = dag; } /** Copies another pixel colour over this one. This doesn't blend it - this colour is simply replaced by the other one. */ template <class Pixel> forcedinline void set (const Pixel& src) noexcept { argb = src.getARGB(); } /** Replaces the colour's alpha value with another one. */ forcedinline void setAlpha (const uint8 newAlpha) noexcept { components.a = newAlpha; } /** Multiplies the colour's alpha value with another one. */ forcedinline void multiplyAlpha (int multiplier) noexcept { ++multiplier; argb = ((multiplier * getAG()) & 0xff00ff00) | (((multiplier * getRB()) >> 8) & 0x00ff00ff); } forcedinline void multiplyAlpha (const float multiplier) noexcept { multiplyAlpha ((int) (multiplier * 256.0f)); } /** Sets the pixel's colour from individual components. */ void setARGB (const uint8 a, const uint8 r, const uint8 g, const uint8 b) noexcept { components.b = b; components.g = g; components.r = r; components.a = a; } /** Premultiplies the pixel's RGB values by its alpha. */ forcedinline void premultiply() noexcept { const uint32 alpha = components.a; if (alpha < 0xff) { if (alpha == 0) { components.b = 0; components.g = 0; components.r = 0; } else { components.b = (uint8) ((components.b * alpha + 0x7f) >> 8); components.g = (uint8) ((components.g * alpha + 0x7f) >> 8); components.r = (uint8) ((components.r * alpha + 0x7f) >> 8); } } } /** Unpremultiplies the pixel's RGB values. */ forcedinline void unpremultiply() noexcept { const uint32 alpha = components.a; if (alpha < 0xff) { if (alpha == 0) { components.b = 0; components.g = 0; components.r = 0; } else { components.b = (uint8) jmin ((uint32) 0xff, (components.b * 0xff) / alpha); components.g = (uint8) jmin ((uint32) 0xff, (components.g * 0xff) / alpha); components.r = (uint8) jmin ((uint32) 0xff, (components.r * 0xff) / alpha); } } } forcedinline void desaturate() noexcept { if (components.a < 0xff && components.a > 0) { const int newUnpremultipliedLevel = (0xff * ((int) components.r + (int) components.g + (int) components.b) / (3 * components.a)); components.r = components.g = components.b = (uint8) ((newUnpremultipliedLevel * components.a + 0x7f) >> 8); } else { components.r = components.g = components.b = (uint8) (((int) components.r + (int) components.g + (int) components.b) / 3); } } //============================================================================== /** The indexes of the different components in the byte layout of this type of colour. */ #if JUCE_BIG_ENDIAN enum { indexA = 0, indexR = 1, indexG = 2, indexB = 3 }; #else enum { indexA = 3, indexR = 2, indexG = 1, indexB = 0 }; #endif private: //============================================================================== union { uint32 argb; struct { #if JUCE_BIG_ENDIAN uint8 a : 8, r : 8, g : 8, b : 8; #else uint8 b, g, r, a; #endif } PACKED components; }; } #ifndef DOXYGEN PACKED #endif ; //============================================================================== /** Represents a 24-bit RGB pixel, and can perform compositing operations on it. This is used internally by the imaging classes. @see PixelARGB */ class JUCE_API PixelRGB { public: /** Creates a pixel without defining its colour. */ PixelRGB() noexcept {} ~PixelRGB() noexcept {} /** Creates a pixel from a 32-bit argb value. (The argb format is that used by PixelARGB) */ PixelRGB (const uint32 argb) noexcept { r = (uint8) (argb >> 16); g = (uint8) (argb >> 8); b = (uint8) (argb); } forcedinline uint32 getARGB() const noexcept { return 0xff000000 | b | (g << 8) | (r << 16); } forcedinline uint32 getUnpremultipliedARGB() const noexcept { return getARGB(); } forcedinline uint32 getRB() const noexcept { return b | (uint32) (r << 16); } forcedinline uint32 getAG() const noexcept { return (uint32) (0xff0000 | g); } forcedinline uint8 getAlpha() const noexcept { return 0xff; } forcedinline uint8 getRed() const noexcept { return r; } forcedinline uint8 getGreen() const noexcept { return g; } forcedinline uint8 getBlue() const noexcept { return b; } /** Blends another pixel onto this one. This takes into account the opacity of the pixel being overlaid, and blends it accordingly. */ forcedinline void blend (const PixelARGB& src) noexcept { uint32 sargb = src.getARGB(); const uint32 alpha = 0x100 - (sargb >> 24); sargb += 0x00ff00ff & ((getRB() * alpha) >> 8); sargb += 0x0000ff00 & (g * alpha); r = (uint8) (sargb >> 16); g = (uint8) (sargb >> 8); b = (uint8) sargb; } forcedinline void blend (const PixelRGB& src) noexcept { set (src); } forcedinline void blend (const PixelAlpha& src) noexcept; /** Blends another pixel onto this one, applying an extra multiplier to its opacity. The opacity of the pixel being overlaid is scaled by the extraAlpha factor before being used, so this can blend semi-transparently from a PixelRGB argument. */ template <class Pixel> forcedinline void blend (const Pixel& src, uint32 extraAlpha) noexcept { ++extraAlpha; const uint32 srb = (extraAlpha * src.getRB()) >> 8; const uint32 sag = extraAlpha * src.getAG(); uint32 sargb = (sag & 0xff00ff00) | (srb & 0x00ff00ff); const uint32 alpha = 0x100 - (sargb >> 24); sargb += 0x00ff00ff & ((getRB() * alpha) >> 8); sargb += 0x0000ff00 & (g * alpha); b = (uint8) sargb; g = (uint8) (sargb >> 8); r = (uint8) (sargb >> 16); } /** Blends another pixel with this one, creating a colour that is somewhere between the two, as specified by the amount. */ template <class Pixel> forcedinline void tween (const Pixel& src, const uint32 amount) noexcept { uint32 drb = getRB(); drb += (((src.getRB() - drb) * amount) >> 8); uint32 dag = getAG(); dag += (((src.getAG() - dag) * amount) >> 8); b = (uint8) drb; g = (uint8) dag; r = (uint8) (drb >> 16); } /** Copies another pixel colour over this one. This doesn't blend it - this colour is simply replaced by the other one. Because PixelRGB has no alpha channel, any alpha value in the source pixel is thrown away. */ template <class Pixel> forcedinline void set (const Pixel& src) noexcept { b = src.getBlue(); g = src.getGreen(); r = src.getRed(); } /** This method is included for compatibility with the PixelARGB class. */ forcedinline void setAlpha (const uint8) noexcept {} /** Multiplies the colour's alpha value with another one. */ forcedinline void multiplyAlpha (int) noexcept {} /** Sets the pixel's colour from individual components. */ void setARGB (const uint8, const uint8 r_, const uint8 g_, const uint8 b_) noexcept { r = r_; g = g_; b = b_; } /** Premultiplies the pixel's RGB values by its alpha. */ forcedinline void premultiply() noexcept {} /** Unpremultiplies the pixel's RGB values. */ forcedinline void unpremultiply() noexcept {} forcedinline void desaturate() noexcept { r = g = b = (uint8) (((int) r + (int) g + (int) b) / 3); } //============================================================================== /** The indexes of the different components in the byte layout of this type of colour. */ #if JUCE_MAC enum { indexR = 0, indexG = 1, indexB = 2 }; #else enum { indexR = 2, indexG = 1, indexB = 0 }; #endif private: //============================================================================== #if JUCE_MAC uint8 r, g, b; #else uint8 b, g, r; #endif } #ifndef DOXYGEN PACKED #endif ; forcedinline void PixelARGB::blend (const PixelRGB& src) noexcept { set (src); } //============================================================================== /** Represents an 8-bit single-channel pixel, and can perform compositing operations on it. This is used internally by the imaging classes. @see PixelARGB, PixelRGB */ class JUCE_API PixelAlpha { public: /** Creates a pixel without defining its colour. */ PixelAlpha() noexcept {} ~PixelAlpha() noexcept {} /** Creates a pixel from a 32-bit argb value. (The argb format is that used by PixelARGB) */ PixelAlpha (const uint32 argb) noexcept { a = (uint8) (argb >> 24); } forcedinline uint32 getARGB() const noexcept { return (((uint32) a) << 24) | (((uint32) a) << 16) | (((uint32) a) << 8) | a; } forcedinline uint32 getUnpremultipliedARGB() const noexcept { return (((uint32) a) << 24) | 0xffffff; } forcedinline uint32 getRB() const noexcept { return (((uint32) a) << 16) | a; } forcedinline uint32 getAG() const noexcept { return (((uint32) a) << 16) | a; } forcedinline uint8 getAlpha() const noexcept { return a; } forcedinline uint8 getRed() const noexcept { return 0; } forcedinline uint8 getGreen() const noexcept { return 0; } forcedinline uint8 getBlue() const noexcept { return 0; } /** Blends another pixel onto this one. This takes into account the opacity of the pixel being overlaid, and blends it accordingly. */ template <class Pixel> forcedinline void blend (const Pixel& src) noexcept { const int srcA = src.getAlpha(); a = (uint8) ((a * (0x100 - srcA) >> 8) + srcA); } /** Blends another pixel onto this one, applying an extra multiplier to its opacity. The opacity of the pixel being overlaid is scaled by the extraAlpha factor before being used, so this can blend semi-transparently from a PixelRGB argument. */ template <class Pixel> forcedinline void blend (const Pixel& src, uint32 extraAlpha) noexcept { ++extraAlpha; const int srcAlpha = (int) ((extraAlpha * src.getAlpha()) >> 8); a = (uint8) ((a * (0x100 - srcAlpha) >> 8) + srcAlpha); } /** Blends another pixel with this one, creating a colour that is somewhere between the two, as specified by the amount. */ template <class Pixel> forcedinline void tween (const Pixel& src, const uint32 amount) noexcept { a += ((src,getAlpha() - a) * amount) >> 8; } /** Copies another pixel colour over this one. This doesn't blend it - this colour is simply replaced by the other one. */ template <class Pixel> forcedinline void set (const Pixel& src) noexcept { a = src.getAlpha(); } /** Replaces the colour's alpha value with another one. */ forcedinline void setAlpha (const uint8 newAlpha) noexcept { a = newAlpha; } /** Multiplies the colour's alpha value with another one. */ forcedinline void multiplyAlpha (int multiplier) noexcept { ++multiplier; a = (uint8) ((a * multiplier) >> 8); } forcedinline void multiplyAlpha (const float multiplier) noexcept { a = (uint8) (a * multiplier); } /** Sets the pixel's colour from individual components. */ forcedinline void setARGB (const uint8 a_, const uint8 /*r*/, const uint8 /*g*/, const uint8 /*b*/) noexcept { a = a_; } /** Premultiplies the pixel's RGB values by its alpha. */ forcedinline void premultiply() noexcept { } /** Unpremultiplies the pixel's RGB values. */ forcedinline void unpremultiply() noexcept { } forcedinline void desaturate() noexcept { } //============================================================================== /** The indexes of the different components in the byte layout of this type of colour. */ enum { indexA = 0 }; private: //============================================================================== uint8 a : 8; } #ifndef DOXYGEN PACKED #endif ; forcedinline void PixelRGB::blend (const PixelAlpha& src) noexcept { blend (PixelARGB (src.getARGB())); } forcedinline void PixelARGB::blend (const PixelAlpha& src) noexcept { uint32 sargb = src.getARGB(); const uint32 alpha = 0x100 - (sargb >> 24); sargb += 0x00ff00ff & ((getRB() * alpha) >> 8); sargb += 0xff00ff00 & (getAG() * alpha); argb = sargb; } #if JUCE_MSVC #pragma pack (pop) #endif #undef PACKED #endif // __JUCE_PIXELFORMATS_JUCEHEADER__
[ [ [ 1, 610 ] ] ]
abbd27678e55d6520d28c1f49e0fd0ab723ed953
ce262ae496ab3eeebfcbb337da86d34eb689c07b
/SEFoundation/SECollision/SEBoxBVTree.cpp
2a8948f804cba4ed426d0321301e43a23c3de19c
[]
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
3,264
cpp
// 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 #include "SEFoundationPCH.h" #include "SEBoxBVTree.h" #include "SEContBox3.h" using namespace Swing; SE_IMPLEMENT_INITIALIZE(SEBoxBVTree); //SE_REGISTER_INITIALIZE(SEBoxBVTree); //---------------------------------------------------------------------------- void SEBoxBVTree::Initialize() { ms_aoCreateModelBound[SEBoundingVolume::BV_BOX] = &SEBoxBVTree::CreateModelBound; ms_aoCreateWorldBound[SEBoundingVolume::BV_BOX] = &SEBoxBVTree::CreateWorldBound; } //---------------------------------------------------------------------------- SEBoxBVTree::SEBoxBVTree(const SETriMesh* pMesh, int iMaxTrisPerLeaf, bool bStoreInteriorTris) : SEBoundingVolumeTree(SEBoundingVolume::BV_BOX, pMesh, iMaxTrisPerLeaf, bStoreInteriorTris) { } //---------------------------------------------------------------------------- SEBoundingVolume* SEBoxBVTree::CreateModelBound(const SETriMesh* pMesh, int i0, int i1, int* aiISplit, SELine3f& rLine) { // 标记出在当前子网格中用过的那些顶点. int iVCount = pMesh->VBuffer->GetVertexCount(); const int* aiIndex = pMesh->IBuffer->GetData(); bool* abValid = SE_NEW bool[iVCount]; memset(abValid, 0, iVCount*sizeof(bool)); int i; for( i = i0; i <= i1; i++ ) { int j = 3 * aiISplit[i]; abValid[aiIndex[j++]] = true; abValid[aiIndex[j++]] = true; abValid[aiIndex[j++]] = true; } // 创建一个针对当前子网格的连续顶点数组. std::vector<SEVector3f> tempMeshVertices; for( i = 0; i < iVCount; i++ ) { if( abValid[i] ) { tempMeshVertices.push_back(pMesh->VBuffer->Position3(i)); } } SE_DELETE[] abValid; SEBoxBV* pModelBound = SE_NEW SEBoxBV; pModelBound->Box() = ContOBBf((int)tempMeshVertices.size(), &tempMeshVertices.front()); // 待检查. rLine.Origin = pModelBound->Box().Center; rLine.Direction = pModelBound->Box().Axis[2]; return pModelBound; } //---------------------------------------------------------------------------- SEBoundingVolume* SEBoxBVTree::CreateWorldBound() { return SE_NEW SEBoxBV; } //----------------------------------------------------------------------------
[ "[email protected]@876e9856-8d94-11de-b760-4d83c623b0ac" ]
[ [ [ 1, 92 ] ] ]
58676d4726e887b5d8abce1c12ff825c9e31b96d
668dc83d4bc041d522e35b0c783c3e073fcc0bd2
/fbide-rw/sdk/utilities.h
5ed89918f110217689b8459ab93f13c2597117f5
[]
no_license
albeva/fbide-old-svn
4add934982ce1ce95960c9b3859aeaf22477f10b
bde1e72e7e182fabc89452738f7655e3307296f4
refs/heads/master
2021-01-13T10:22:25.921182
2009-11-19T16:50:48
2009-11-19T16:50:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,406
h
/* * This file is part of FBIde project * * FBIde 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 3 of the License, or * (at your option) any later version. * * FBIde 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 FBIde. If not, see <http://www.gnu.org/licenses/>. * * Author: Albert Varaksin <[email protected]> * Copyright (C) The FBIde development team */ #pragma once #include <unordered_map> namespace fb { /** * Declare non copyable class */ struct NonCopyable { // disable copy NonCopyable (const NonCopyable &) = delete; NonCopyable & operator = (const NonCopyable &) = delete; // default protected constructor and destructor protected : NonCopyable() = default; ~NonCopyable() = default; }; /** * String hash map */ typedef std::unordered_map< wxString, wxString, wxStringHash, wxStringEqual > StringMap; }
[ "vongodric@957c6b5c-1c3a-0410-895f-c76cfc11fbc7" ]
[ [ [ 1, 51 ] ] ]
ec7547a43f1d11071545643b97cd0dd02358f4ec
119ba245bea18df8d27b84ee06e152b35c707da1
/unreal/branches/robots/qrgui/interpreters/robots/details/robotImplementations/brickImplementations/unrealBrickImplementation.h
31b69449d94f30e9bd4b6ef4d1cb6c9d23315b9b
[]
no_license
nfrey/qreal
05cd4f9b9d3193531eb68ff238d8a447babcb3d2
71641e6c5f8dc87eef9ec3a01cabfb9dd7b0e164
refs/heads/master
2020-04-06T06:43:41.910531
2011-05-30T19:30:09
2011-05-30T19:30:09
1,634,768
0
0
null
null
null
null
UTF-8
C++
false
false
599
h
#pragma once #include <QtCore/QObject> #include "abstractBrickImplementation.h" #include "../../d2RobotModel/d2RobotModel.h" namespace qReal { namespace interpreters { namespace robots { namespace details { namespace robotImplementations { namespace brickImplementations { class UnrealBrickImplementation : public AbstractBrickImplementation { Q_OBJECT public: UnrealBrickImplementation(d2Model::D2RobotModel *d2Model); virtual void beep(unsigned time); virtual void playTone(unsigned freq, unsigned time); private: d2Model::D2RobotModel *mD2Model; }; } } } } } }
[ [ [ 1, 28 ] ] ]
187be7f5e553efd751469a2c9db9eb5365c7f8e8
51c71b06d7fa1aa97df4ffe6782e9a4924480a33
/Calibration/Camera.h
3f8784a7abcaa1fba0b2ee5f8d381b7096c503ff
[]
no_license
alonf01/open-light
9eb8d185979cfa16797f9d2201cf192b3e91f270
685f974fcd7cc29b6bec00fa17804c5f2b7a83c3
refs/heads/master
2020-05-30T15:24:08.579565
2010-12-14T00:56:32
2010-12-14T00:56:32
35,759,673
0
0
null
null
null
null
UTF-8
C++
false
false
1,711
h
// ************************************************************* // Abstracted Camera Class // // Brett Jones 2009 // ************************************************************* #pragma once #include "Common.h" #include "CameraConfigParams.h" #include "CalibrationExceptions.h" class Camera { public: virtual void Init(CameraConfigParams* camParams) = 0; virtual void StartCapture() = 0; virtual void EndCapture() = 0; //////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Return a color image of the current camera frame. </summary> /// /// <returns> IplImage ptr of the current camera image. </returns> //////////////////////////////////////////////////////////////////////////////////////////////////// virtual IplImage* QueryFrame() = 0; IplImage* QueryFrameSafe(int delayFrames=0); IplImage* QueryFrameRGB(int delayFrames=0); IplImage* QueryFrameR(int delayFrames=0); IplImage* QueryFrameG(int delayFrames=0); IplImage* QueryFrameB(int delayFrames=0); IplImage* QueryFrameGray(int delayFrames=0); // Accessor methods int GetWidth() { return mWidth; }; int GetHeight() {return mHeight; }; protected: /// <summary> width of the image. </summary> int mWidth; /// <summary> height of the image. </summary> int mHeight; /// <summary> the current frame. </summary> IplImage* mCurFrame; /// <summary> Camera configuration parameters </summary> CameraConfigParams* mCamParams; /// <summary> Did everything load and is the camera enabled. </summary> bool mEnabled; };
[ "b.jonessoda@8a600b9a-ddf7-11de-b878-c5ec750a8c44" ]
[ [ [ 1, 56 ] ] ]
361f891b0dbec8737e858357ea129498d68dbdf7
e31046aee3ad2d4600c7f35aaeeba76ee2b99039
/trunk/libs/bullet/includes/LinearMath/btQuickprof.h
fa994471e4cbcdc203d140deda37a634d312ff44
[]
no_license
BackupTheBerlios/trinitas-svn
ddea265cf47aff3e8853bf6d46861e0ed3031ea1
7d3ff64a7d0e5ba37febda38e6ce0b2d0a4b6cca
refs/heads/master
2021-01-23T08:14:44.215249
2009-02-18T19:37:51
2009-02-18T19:37:51
40,749,519
0
0
null
null
null
null
UTF-8
C++
false
false
9,632
h
/*************************************************************************************************** ** ** Real-Time Hierarchical Profiling for Game Programming Gems 3 ** ** by Greg Hjelstrom & Byon Garrabrant ** ***************************************************************************************************/ // Credits: The Clock class was inspired by the Timer classes in // Ogre (www.ogre3d.org). #ifndef QUICK_PROF_H #define QUICK_PROF_H #include "btScalar.h" #include "LinearMath/btAlignedAllocator.h" #include <new> //To disable built-in profiling, please comment out next line //#define BT_NO_PROFILE 1 //if you don't need btClock, you can comment next line #define USE_BT_CLOCK 1 #ifdef USE_BT_CLOCK #ifdef __CELLOS_LV2__ #include <sys/sys_time.h> #include <sys/time_util.h> #include <stdio.h> #endif #if defined (SUNOS) || defined (__SUNOS__) #include <stdio.h> #endif #if defined(WIN32) || defined(_WIN32) #define USE_WINDOWS_TIMERS #define WIN32_LEAN_AND_MEAN #define NOWINRES #define NOMCX #define NOIME #ifdef _XBOX #include <Xtl.h> #else #include <windows.h> #endif #include <time.h> #else #include <sys/time.h> #endif #define mymin(a,b) (a > b ? a : b) ///The btClock is a portable basic clock that measures accurate time in seconds, use for profiling. class btClock { public: btClock() { #ifdef USE_WINDOWS_TIMERS QueryPerformanceFrequency(&mClockFrequency); #endif reset(); } ~btClock() { } /// Resets the initial reference time. void reset() { #ifdef USE_WINDOWS_TIMERS QueryPerformanceCounter(&mStartTime); mStartTick = GetTickCount(); mPrevElapsedTime = 0; #else #ifdef __CELLOS_LV2__ typedef uint64_t ClockSize; ClockSize newTime; //__asm __volatile__( "mftb %0" : "=r" (newTime) : : "memory"); SYS_TIMEBASE_GET( newTime ); mStartTime = newTime; #else gettimeofday(&mStartTime, 0); #endif #endif } /// Returns the time in ms since the last call to reset or since /// the btClock was created. unsigned long int getTimeMilliseconds() { #ifdef USE_WINDOWS_TIMERS LARGE_INTEGER currentTime; QueryPerformanceCounter(&currentTime); LONGLONG elapsedTime = currentTime.QuadPart - mStartTime.QuadPart; // Compute the number of millisecond ticks elapsed. unsigned long msecTicks = (unsigned long)(1000 * elapsedTime / mClockFrequency.QuadPart); // Check for unexpected leaps in the Win32 performance counter. // (This is caused by unexpected data across the PCI to ISA // bridge, aka south bridge. See Microsoft KB274323.) unsigned long elapsedTicks = GetTickCount() - mStartTick; signed long msecOff = (signed long)(msecTicks - elapsedTicks); if (msecOff < -100 || msecOff > 100) { // Adjust the starting time forwards. LONGLONG msecAdjustment = mymin(msecOff * mClockFrequency.QuadPart / 1000, elapsedTime - mPrevElapsedTime); mStartTime.QuadPart += msecAdjustment; elapsedTime -= msecAdjustment; // Recompute the number of millisecond ticks elapsed. msecTicks = (unsigned long)(1000 * elapsedTime / mClockFrequency.QuadPart); } // Store the current elapsed time for adjustments next time. mPrevElapsedTime = elapsedTime; return msecTicks; #else #ifdef __CELLOS_LV2__ uint64_t freq=sys_time_get_timebase_frequency(); double dFreq=((double) freq) / 1000.0; typedef uint64_t ClockSize; ClockSize newTime; SYS_TIMEBASE_GET( newTime ); //__asm __volatile__( "mftb %0" : "=r" (newTime) : : "memory"); return (unsigned long int)((double(newTime-mStartTime)) / dFreq); #else struct timeval currentTime; gettimeofday(&currentTime, 0); return (currentTime.tv_sec - mStartTime.tv_sec) * 1000 + (currentTime.tv_usec - mStartTime.tv_usec) / 1000; #endif //__CELLOS_LV2__ #endif } /// Returns the time in us since the last call to reset or since /// the Clock was created. unsigned long int getTimeMicroseconds() { #ifdef USE_WINDOWS_TIMERS LARGE_INTEGER currentTime; QueryPerformanceCounter(&currentTime); LONGLONG elapsedTime = currentTime.QuadPart - mStartTime.QuadPart; // Compute the number of millisecond ticks elapsed. unsigned long msecTicks = (unsigned long)(1000 * elapsedTime / mClockFrequency.QuadPart); // Check for unexpected leaps in the Win32 performance counter. // (This is caused by unexpected data across the PCI to ISA // bridge, aka south bridge. See Microsoft KB274323.) unsigned long elapsedTicks = GetTickCount() - mStartTick; signed long msecOff = (signed long)(msecTicks - elapsedTicks); if (msecOff < -100 || msecOff > 100) { // Adjust the starting time forwards. LONGLONG msecAdjustment = mymin(msecOff * mClockFrequency.QuadPart / 1000, elapsedTime - mPrevElapsedTime); mStartTime.QuadPart += msecAdjustment; elapsedTime -= msecAdjustment; } // Store the current elapsed time for adjustments next time. mPrevElapsedTime = elapsedTime; // Convert to microseconds. unsigned long usecTicks = (unsigned long)(1000000 * elapsedTime / mClockFrequency.QuadPart); return usecTicks; #else #ifdef __CELLOS_LV2__ uint64_t freq=sys_time_get_timebase_frequency(); double dFreq=((double) freq)/ 1000000.0; typedef uint64_t ClockSize; ClockSize newTime; //__asm __volatile__( "mftb %0" : "=r" (newTime) : : "memory"); SYS_TIMEBASE_GET( newTime ); return (unsigned long int)((double(newTime-mStartTime)) / dFreq); #else struct timeval currentTime; gettimeofday(&currentTime, 0); return (currentTime.tv_sec - mStartTime.tv_sec) * 1000000 + (currentTime.tv_usec - mStartTime.tv_usec); #endif//__CELLOS_LV2__ #endif } private: #ifdef USE_WINDOWS_TIMERS LARGE_INTEGER mClockFrequency; DWORD mStartTick; LONGLONG mPrevElapsedTime; LARGE_INTEGER mStartTime; #else #ifdef __CELLOS_LV2__ uint64_t mStartTime; #else struct timeval mStartTime; #endif #endif //__CELLOS_LV2__ }; #endif //USE_BT_CLOCK ///A node in the Profile Hierarchy Tree class CProfileNode { public: CProfileNode( const char * name, CProfileNode * parent ); ~CProfileNode( void ); CProfileNode * Get_Sub_Node( const char * name ); CProfileNode * Get_Parent( void ) { return Parent; } CProfileNode * Get_Sibling( void ) { return Sibling; } CProfileNode * Get_Child( void ) { return Child; } void CleanupMemory(); void Reset( void ); void Call( void ); bool Return( void ); const char * Get_Name( void ) { return Name; } int Get_Total_Calls( void ) { return TotalCalls; } float Get_Total_Time( void ) { return TotalTime; } protected: const char * Name; int TotalCalls; float TotalTime; unsigned long int StartTime; int RecursionCounter; CProfileNode * Parent; CProfileNode * Child; CProfileNode * Sibling; }; ///An iterator to navigate through the tree class CProfileIterator { public: // Access all the children of the current parent void First(void); void Next(void); bool Is_Done(void); bool Is_Root(void) { return (CurrentParent->Get_Parent() == 0); } void Enter_Child( int index ); // Make the given child the new parent void Enter_Largest_Child( void ); // Make the largest child the new parent void Enter_Parent( void ); // Make the current parent's parent the new parent // Access the current child const char * Get_Current_Name( void ) { return CurrentChild->Get_Name(); } int Get_Current_Total_Calls( void ) { return CurrentChild->Get_Total_Calls(); } float Get_Current_Total_Time( void ) { return CurrentChild->Get_Total_Time(); } // Access the current parent const char * Get_Current_Parent_Name( void ) { return CurrentParent->Get_Name(); } int Get_Current_Parent_Total_Calls( void ) { return CurrentParent->Get_Total_Calls(); } float Get_Current_Parent_Total_Time( void ) { return CurrentParent->Get_Total_Time(); } protected: CProfileNode * CurrentParent; CProfileNode * CurrentChild; CProfileIterator( CProfileNode * start ); friend class CProfileManager; }; ///The Manager for the Profile system class CProfileManager { public: static void Start_Profile( const char * name ); static void Stop_Profile( void ); static void CleanupMemory(void) { Root.CleanupMemory(); } static void Reset( void ); static void Increment_Frame_Counter( void ); static int Get_Frame_Count_Since_Reset( void ) { return FrameCounter; } static float Get_Time_Since_Reset( void ); static CProfileIterator * Get_Iterator( void ) { return new CProfileIterator( &Root ); } static void Release_Iterator( CProfileIterator * iterator ) { delete ( iterator); } private: static CProfileNode Root; static CProfileNode * CurrentNode; static int FrameCounter; static unsigned long int ResetTime; }; ///ProfileSampleClass is a simple way to profile a function's scope ///Use the BT_PROFILE macro at the start of scope to time class CProfileSample { public: CProfileSample( const char * name ) { CProfileManager::Start_Profile( name ); } ~CProfileSample( void ) { CProfileManager::Stop_Profile(); } }; #if !defined(BT_NO_PROFILE) #define BT_PROFILE( name ) CProfileSample __profile( name ) #else #define BT_PROFILE( name ) #endif #endif //QUICK_PROF_H
[ "paradoxon@ab3bda7c-5b37-0410-9911-e7f4556ba333" ]
[ [ [ 1, 358 ] ] ]
45b3689f5e5121c1c8528c6ac3fecd6ddd60c6af
b505ef7eb1a6c58ebcb73267eaa1bad60efb1cb2
/sample/0010stringtest/main.cpp
c519926abbe609c0cf6a5de6944a31b892fc8598
[]
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
748
cpp
/* Maid2 で使用している文字列は独自文字コードになっています なので、それを扱うためのサンプル */ #include"../../source/auxiliary/string.h" using namespace Maid; void main() { { // これはおまじないです。 String::Initialize(); } String str_m; // 文字列を代入するとき str_m = MAIDTEXT( "aあいうo" ); // いつもの連結も可能 str_m += MAIDTEXT( "かきkけこ" ); { // こうゆう書き方でもOK String tmp(MAIDTEXT( "さしすせそ" )); str_m += tmp; } { // 出力時に変換するならこうする std::string str_s; str_s = String::ConvertMAIDtoSJIS( str_m ); } }
[ [ [ 1, 45 ] ] ]
b055952527fcec7d3f34f644207718a1cb7799fd
73861c79fbe4cb57e6f4a75369519cbe43a0406e
/KTB_Mortgage/ResultReload.cpp
a3c404bffca2be07b42a8fc1faf70a24a1e011fe
[]
no_license
hunganhu/dac
5d8cc276601fa8e7e23fa84ae003da51128c48af
a48c7a58578b3503edd564b9ca23eed1926d9642
refs/heads/master
2022-07-28T04:50:00.442444
2007-10-26T02:41:58
2007-10-26T02:41:58
266,997,798
0
0
null
null
null
null
BIG5
C++
false
false
4,793
cpp
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "ResultReload.h" #include "LoanTypeSelection.h" #include "dm.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TfrmReloadResult *frmReloadResult; extern AnsiString case_sn; extern AnsiString connection_string_module; //--------------------------------------------------------------------------- __fastcall TfrmReloadResult::TfrmReloadResult(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TfrmReloadResult::btnNextClick(TObject *Sender) { frmSelection->Show(); frmReloadResult->Hide(); } //--------------------------------------------------------------------------- void __fastcall TfrmReloadResult::btnScoreClick(TObject *Sender) { init(case_sn); char c_message[256]; int return_code = 0; AnsiString message = lblExecution->Caption; return_code = FM_Reload(case_sn.c_str(), connection_string_module.c_str(), c_message); if(return_code != 0){ message += static_cast<AnsiString>(c_message); lblExecution->Caption = message; } else{ message += "評分完成\n"; lblExecution->Caption = message; try{ fill_result(Data->query, case_sn); } catch(Exception &Err){ message += Err.Message; lblExecution->Caption = message; }; }; frmReloadResult->Refresh(); }; //--------------------------------------------------------------------------- void __fastcall TfrmReloadResult::fill_result(TADOQuery *query, const AnsiString &case_sn) { AnsiString sql_stmt; unsigned int amount; double rate1, rate2, rate3; sql_stmt = "SELECT * FROM APP_RESULT AS A INNER JOIN APP_INFO AS B "; sql_stmt += "ON A.CASE_NO = B.CASE_NO WHERE A.CASE_NO = :case_sn"; sql_stmt = sql_stmt.UpperCase(); query->Close(); query->SQL->Clear(); query->SQL->Add(sql_stmt); query->Parameters->ParamValues["case_sn"] = case_sn; query->Open(); if(query->RecordCount == 0) lblExecution->Caption = "程式錯誤,沒有找到評分結果,請聯絡DAC\n"; else{ amount = query->FieldValues["APPROVED_AMOUNT"].IsNull() ? 0 : query->FieldValues["APPROVED_AMOUNT"]; amount /= 10000; if(amount == 0) lblAmount->Caption = ""; else lblAmount->Caption = amount; if(query->FieldValues["MIN_RATE1"].IsNull()) rate1 = 0; else rate1 = query->FieldValues["MIN_RATE1"]; rate1 *= 100; if(query->FieldValues["MIN_RATE1"].IsNull()) lblRate1->Caption = ""; else lblRate1->Caption = rate1; if(query->FieldValues["MIN_RATE2"].IsNull()) rate2 = 0; else rate2 = query->FieldValues["MIN_RATE2"]; rate2 *= 100; if(query->FieldValues["MIN_RATE2"].IsNull()) lblRate2->Caption = ""; else lblRate2->Caption = rate2; if(query->FieldValues["MIN_RATE3"].IsNull()) rate3 = 0; else rate3 = query->FieldValues["MIN_RATE3"]; rate3 *= 100; if(query->FieldValues["MIN_RATE3"].IsNull()) lblRate3->Caption = ""; else lblRate3->Caption = rate3; if(query->FieldValues["SEG1"].IsNull() || rate1 == 0) lblPeriod1->Caption = ""; else lblPeriod1->Caption = query->FieldValues["SEG1"]; if(query->FieldValues["SEG2"].IsNull() || rate2 == 0) lblPeriod2->Caption = ""; else lblPeriod2->Caption = query->FieldValues["SEG2"]; if(query->FieldValues["SEG3"].IsNull() || rate3 == 0) lblPeriod3->Caption = ""; else lblPeriod3->Caption = query->FieldValues["SEG3"]; if(query->FieldValues["SUGG_MSG"].IsNull()) lblSuggestion1->Caption = ""; else lblSuggestion1->Caption = query->FieldValues["SUGG_MSG"]; if(query->FieldValues["REASON_MSG"].IsNull()) lblSuggestion2->Caption = ""; else lblSuggestion2->Caption = query->FieldValues["REASON_MSG"]; }; frmReloadResult->Refresh(); }; void __fastcall TfrmReloadResult::init(const AnsiString &case_sn) { lblSN->Caption = case_sn; lblAmount->Caption = ""; lblPeriod1->Caption = ""; lblPeriod2->Caption = ""; lblPeriod3->Caption = ""; lblRate1->Caption = ""; lblRate2->Caption = ""; lblRate3->Caption = ""; lblSuggestion1->Caption = ""; lblSuggestion2->Caption = ""; lblExecution->Caption = "模組評分中\n"; frmReloadResult->Refresh(); }; void __fastcall TfrmReloadResult::Button1Click(TObject *Sender) { Application->Terminate(); } //---------------------------------------------------------------------------
[ "oliver" ]
[ [ [ 1, 147 ] ] ]
e56dececd47fcfd208b32bb32890de129617183f
cbdc078b00041668dd740917e1e781f74b6ea9f4
/GiftFactory/src/Camera.hpp
d5c49ca86a8a7eb710cb4666c05e6e3f89b3ca26
[]
no_license
mireidril/gift-factory
f30d8075575af6a00a42d54bfdd4ad4c953f1936
4888b59b1ee25a107715742d0495e40b81752051
refs/heads/master
2020-04-13T07:19:09.351853
2011-12-16T11:36:05
2011-12-16T11:36:05
32,514,347
0
0
null
null
null
null
UTF-8
C++
false
false
723
hpp
#ifndef __CAMERA_HPP__ #define __CAMERA_HPP__ #include "Utils.hpp" class Spline; class Camera { public : Camera(); ~Camera(); void lookAt(GLfloat * c, GLfloat * aim, GLfloat * up); void updateView(); void moveForward(); inline GLfloat* getView () {return _view;}; void setPosition (GLfloat* position); static const float focalDistance; static const float focalRange; private : // View Data GLfloat _position[3]; // Camera position GLfloat _xAxis[3]; // Camera axis x : right side GLfloat _yAxis[3]; // Camera axis y : up GLfloat _zAxis[3]; // Camera axis z : backward GLfloat _view[16]; GLfloat _aim[3]; Spline* _spline; }; #endif
[ "celine.cogny@369dbe5e-add6-1733-379f-dc396ee97aaa", "marjory.gaillot@369dbe5e-add6-1733-379f-dc396ee97aaa", "delau.eleonore@369dbe5e-add6-1733-379f-dc396ee97aaa" ]
[ [ [ 1, 3 ], [ 8, 13 ], [ 27, 27 ], [ 39, 41 ] ], [ [ 4, 7 ], [ 14, 23 ], [ 26, 26 ], [ 28, 37 ] ], [ [ 24, 25 ], [ 38, 38 ] ] ]
5520059c79e3f1bb572e40a7bfc3ce1957fdc861
fbe2cbeb947664ba278ba30ce713810676a2c412
/iptv_root/iptv_wboard/include/iptv_wboard/WBoardFrame.h
4c6d26446f4ea110c28ec4d434d52661539155c7
[]
no_license
abhipr1/multitv
0b3b863bfb61b83c30053b15688b070d4149ca0b
6a93bf9122ddbcc1971dead3ab3be8faea5e53d8
refs/heads/master
2020-12-24T15:13:44.511555
2009-06-04T17:11:02
2009-06-04T17:11:02
41,107,043
0
0
null
null
null
null
UTF-8
C++
false
false
23,355
h
#ifndef _WBOARDFRAME_H_ #define _WBOARDFRAME_H_ /*! * Includes */ ////@begin includes #include "wx/wx.h" ////@end includes #include "wx/print.h" /*! * Forward declarations */ ////@begin forward declarations ////@end forward declarations #include "Resource.h" #include "WBoardBridge.h" ////@begin forward declarations class CWBMain; class wxFlexGridSizer; class CWBToolBox; class CWBMenuBar; class CWBScreen; class wxGridSizer; class CWBEdit; ////@end forward declarations /*! * Control identifiers */ #define SYMBOL_CWBFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxMINIMIZE_BOX|wxMAXIMIZE_BOX|wxCLOSE_BOX #define SYMBOL_CWBFRAME_TITLE _("White Board") #define SYMBOL_CWBFRAME_IDNAME ID_WBOARDFRAME #define SYMBOL_CWBFRAME_SIZE wxSize(800, 600) #define SYMBOL_CWBFRAME_POSITION wxDefaultPosition #define SYMBOL_CWBMAIN_STYLE wxNO_BORDER|wxTAB_TRAVERSAL #define SYMBOL_CWBMAIN_IDNAME wxID_ANY #define SYMBOL_CWBMAIN_SIZE wxDefaultSize #define SYMBOL_CWBMAIN_POSITION wxDefaultPosition #define SYMBOL_CWBTOOLBOX_STYLE wxNO_BORDER|wxTAB_TRAVERSAL #define SYMBOL_CWBTOOLBOX_IDNAME wxID_ANY #define SYMBOL_CWBTOOLBOX_SIZE wxSize(600, 40) #define SYMBOL_CWBTOOLBOX_POSITION wxPoint(0, 40) #define SYMBOL_CWBMENUBAR_STYLE wxNO_BORDER|wxTAB_TRAVERSAL #define SYMBOL_CWBMENUBAR_IDNAME wxID_ANY #define SYMBOL_CWBMENUBAR_SIZE wxSize(70, 400) #define SYMBOL_CWBMENUBAR_POSITION wxPoint(70, 0) #define SYMBOL_CWBSCREEN_STYLE wxSUNKEN_BORDER|wxHSCROLL|wxVSCROLL|wxALWAYS_SHOW_SB #define SYMBOL_CWBSCREEN_IDNAME wxID_ANY #define SYMBOL_CWBSCREEN_SIZE wxSize(100, 100) #define SYMBOL_CWBSCREEN_POSITION wxDefaultPosition #define SYMBOL_CWBEDIT_STYLE wxSIMPLE_BORDER|wxTAB_TRAVERSAL #define SYMBOL_CWBEDIT_IDNAME IDW_WB_EDIT #define SYMBOL_CWBEDIT_SIZE wxSize(800, 600) #define SYMBOL_CWBEDIT_POSITION wxPoint(0, 0) /*! * CWBFrame class declaration */ class CWBFrame: public wxFrame, public WBProcessRef { DECLARE_CLASS( CWBFrame ) DECLARE_EVENT_TABLE() public: /// Constructors CWBFrame(); CWBFrame( wxWindow* parent, IWBProcess* pProcess, wxWindowID id = SYMBOL_CWBFRAME_IDNAME, const wxString& caption = SYMBOL_CWBFRAME_TITLE, const wxPoint& pos = SYMBOL_CWBFRAME_POSITION, const wxSize& size = SYMBOL_CWBFRAME_SIZE, long style = SYMBOL_CWBFRAME_STYLE ); bool Create( wxWindow* parent, IWBProcess* pProcess, wxWindowID id = SYMBOL_CWBFRAME_IDNAME, const wxString& caption = SYMBOL_CWBFRAME_TITLE, const wxPoint& pos = SYMBOL_CWBFRAME_POSITION, const wxSize& size = SYMBOL_CWBFRAME_SIZE, long style = SYMBOL_CWBFRAME_STYLE ); /// Destructor ~CWBFrame(); /// Initialises member variables void Init(); /// Creates the controls and sizers void CreateControls(); ////@begin CWBFrame event handler declarations /// wxEVT_COMMAND_MENU_SELECTED event handler for IDM_WB_NEW void OnMWbNewClick( wxCommandEvent& event ); /// wxEVT_COMMAND_MENU_SELECTED event handler for IDM_WB_SAVE void OnMWbSaveClick( wxCommandEvent& event ); /// wxEVT_COMMAND_MENU_SELECTED event handler for ID_WB_PRINT void OnWbPrintClick( wxCommandEvent& event ); /// wxEVT_COMMAND_MENU_SELECTED event handler for ID_WB_PAGE_SETUP void OnWbPageSetupClick( wxCommandEvent& event ); /// wxEVT_COMMAND_MENU_SELECTED event handler for IDM_WB_CLOSE void OnMWbCloseClick( wxCommandEvent& event ); /// wxEVT_COMMAND_MENU_SELECTED event handler for IDM_WB_UNDO void OnMWbUndoClick( wxCommandEvent& event ); /// wxEVT_COMMAND_MENU_SELECTED event handler for IDM_WB_CUT void OnMWbCutClick( wxCommandEvent& event ); /// wxEVT_COMMAND_MENU_SELECTED event handler for IDM_WB_IMG_STOP void OnMWbImgStopClick( wxCommandEvent& event ); /// wxEVT_COMMAND_MENU_SELECTED event handler for IDM_WB_HELP_TOPICS void OnMWbHelpTopicsClick( wxCommandEvent& event ); /// wxEVT_COMMAND_MENU_SELECTED event handler for IDM_WB_ABOUT void OnMWbAboutClick( wxCommandEvent& event ); /// wxEVT_CLOSE_WINDOW event handler for ID_WBOARDFRAME void OnCloseWindow( wxCloseEvent& event ); ////@end CWBFrame event handler declarations ////@begin CWBFrame member function declarations /// Retrieves bitmap resources wxBitmap GetBitmapResource( const wxString& name ); /// Retrieves icon resources wxIcon GetIconResource( const wxString& name ); ////@end CWBFrame member function declarations /// Should we show tooltips? static bool ShowToolTips(); ////@begin CWBFrame member variables ////@end CWBFrame member variables IWBInterface* GetInterfacePtr(); bool Resize(RcPos* pRc); void ShowWnd(bool bOp); void EnableWnd(bool bOp); void EnableImgCtrl( bool bOp ); void EnableImgStop( bool bOp ); private: wxMenuBar* m_pMenuBar; wxMenu* m_pMenuFile; wxMenu* m_pMenuEdit; wxMenu* m_pMenuCtrl; wxMenu* m_pMenuHelp; CWBMain* m_pwbMain; }; /*! * CWBMenuBar class declaration */ class CWBMenuBar: public wxPanel, public WBProcessRef { DECLARE_DYNAMIC_CLASS( CWBMenuBar ) DECLARE_EVENT_TABLE() public: /// Constructors CWBMenuBar(); CWBMenuBar(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxPoint(70, 0), const wxSize& size = wxSize(600, 40), long style = wxNO_BORDER|wxTAB_TRAVERSAL); /// Creation bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxPoint(70, 0), const wxSize& size = wxSize(600, 40), long style = wxNO_BORDER|wxTAB_TRAVERSAL); /// Destructor ~CWBMenuBar(); /// Initialises member variables void Init(); /// Creates the controls and sizers void CreateControls(); ////@begin CWBMenuBar event handler declarations /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_NEW void OnWbNewClick( wxCommandEvent& event ); /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_SAVE void OnWbSaveClick( wxCommandEvent& event ); /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_PRINT void OnWbPrintClick( wxCommandEvent& event ); /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_CUT void OnWbCutClick( wxCommandEvent& event ); /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_UNDO void OnWbUndoClick( wxCommandEvent& event ); /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_FTPSTOP void OnWbFtpstopClick( wxCommandEvent& event ); ////@end CWBMenuBar event handler declarations ////@begin CWBMenuBar member function declarations /// Retrieves bitmap resources wxBitmap GetBitmapResource( const wxString& name ); /// Retrieves icon resources wxIcon GetIconResource( const wxString& name ); void ImgStopEnable( bool bOp); ////@end CWBMenuBar member function declarations /// Should we show tooltips? static bool ShowToolTips(); ////@begin CWBMenuBar member variables wxBitmapButton* m_mbNew; wxBitmapButton* m_mbSave; wxBitmapButton* m_mbPrint; wxBitmapButton* m_mbCut; wxBitmapButton* m_mbUndo; wxBitmapButton* m_mbImgStop; ////@end CWBMenuBar member variables }; /*! * CWBToolBox class declaration */ class CWBToolBox: public wxPanel, public WBProcessRef { DECLARE_DYNAMIC_CLASS( CWBToolBox ) DECLARE_EVENT_TABLE() public: /// Constructors CWBToolBox(); CWBToolBox(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxPoint(0, 40), const wxSize& size = wxSize(70, 400), long style = wxNO_BORDER|wxTAB_TRAVERSAL); /// Creation bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxPoint(0, 40), const wxSize& size = wxSize(70, 400), long style = wxNO_BORDER|wxTAB_TRAVERSAL); /// Destructor ~CWBToolBox(); /// Initialises member variables void Init(); /// Creates the controls and sizers void CreateControls(); ////@begin CWBToolBox event handler declarations /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_CUR void OnWbPosClick( wxCommandEvent& event ); /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_DEL void OnWbDelClick( wxCommandEvent& event ); /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_TXT void OnWbTxtClick( wxCommandEvent& event ); /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_MRK void OnWbMrkClick( wxCommandEvent& event ); /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_PTR void OnWbPtrClick( wxCommandEvent& event ); /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_IMG void OnWbImgClick( wxCommandEvent& event ); /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_PEN void OnWbPenClick( wxCommandEvent& event ); /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_LIN void OnWbLinClick( wxCommandEvent& event ); /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_SQR void OnWbSqrClick( wxCommandEvent& event ); /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_SQF void OnWbSqfClick( wxCommandEvent& event ); /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_CRC void OnWbCrcClick( wxCommandEvent& event ); /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_CRF void OnWbCrfClick( wxCommandEvent& event ); /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_LINE1 void OnWbLine1Click( wxCommandEvent& event ); /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_LINE2 void OnWbLine2Click( wxCommandEvent& event ); /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_LINE3 void OnWbLine3Click( wxCommandEvent& event ); /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_LINE4 void OnWbLine4Click( wxCommandEvent& event ); /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_COLOR_SEL void OnWbColorSelClick( wxCommandEvent& event ); /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_FONT_SEL void OnWbFontSelClick( wxCommandEvent& event ); ////@end CWBToolBox event handler declarations ////@begin CWBToolBox member function declarations /// Retrieves bitmap resources wxBitmap GetBitmapResource( const wxString& name ); /// Retrieves icon resources wxIcon GetIconResource( const wxString& name ); ////@end CWBToolBox member function declarations /// Should we show tooltips? static bool ShowToolTips(); wxBitmap m_tbPSize1Bitmap; wxBitmap m_tbPSize1BitmapSel; wxBitmap m_tbPSize2Bitmap; wxBitmap m_tbPSize2BitmapSel; wxBitmap m_tbPSize3Bitmap; wxBitmap m_tbPSize3BitmapSel; wxBitmap m_tbPSize4Bitmap; wxBitmap m_tbPSize4BitmapSel; wxBitmap m_tbPosBitmap; wxBitmap m_tbPosBitmapSel; wxBitmap m_tbDelBitmap; wxBitmap m_tbDelBitmapSel; wxBitmap m_tbTxtBitmap; wxBitmap m_tbTxtBitmapSel; wxBitmap m_tbMRKBitmap; wxBitmap m_tbMRKBitmapSel; wxBitmap m_tbPtrBitmap; wxBitmap m_tbPtrBitmapSel; wxBitmap m_tbImgBitmap; wxBitmap m_tbImgBitmapSel; wxBitmap m_tbPenBitmap; wxBitmap m_tbPenBitmapSel; wxBitmap m_tbLinBitmap; wxBitmap m_tbLinBitmapSel; wxBitmap m_tbSqrBitmap; wxBitmap m_tbSqrBitmapSel; wxBitmap m_tbSqfBitmap; wxBitmap m_tbSqfBitmapSel; wxBitmap m_tbCrcBitmap; wxBitmap m_tbCrcBitmapSel; wxBitmap m_tbCrfBitmap; wxBitmap m_tbCrfBitmapSel; ////@begin CWBToolBox member variables wxBitmapButton* m_tbPos; wxBitmapButton* m_tbDel; wxBitmapButton* m_tbTxt; wxBitmapButton* m_tbMRK; wxBitmapButton* m_tbPtr; wxBitmapButton* m_tbImg; wxBitmapButton* m_tbPen; wxBitmapButton* m_tbLin; wxBitmapButton* m_tbSqr; wxBitmapButton* m_tbSqf; wxBitmapButton* m_tbCrc; wxBitmapButton* m_tbCrf; wxBitmapButton* m_tbPSize1; wxBitmapButton* m_tbPSize2; wxBitmapButton* m_tbPSize3; wxBitmapButton* m_tbPSize4; wxStaticText* m_tbColor; wxButton* m_tbColorSel; wxStaticText* m_tbFont; wxStaticText* m_tbFontLen; wxButton* m_tbFontSel; wxStaticBox* m_tbPSBox; ////@end CWBToolBox member variables void SelectItem(int nId); void EnableItem(int nId, bool bOp); void SelectPenSize(int nId); void SelectColour(wxColour& colour); void SelectFont(wxFont& font); private: int m_CurItemId; int m_CurPenSize; wxColour m_Colour; wxFont m_Font; }; /*! * CWBMain class declaration */ class CWBMain: public wxPanel, public IWBInterface, public WBProcessRef { DECLARE_DYNAMIC_CLASS( CWBMain ) DECLARE_EVENT_TABLE() public: /// Constructors CWBMain(); CWBMain(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxNO_BORDER|wxTAB_TRAVERSAL); /// Creation bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxNO_BORDER|wxTAB_TRAVERSAL); /// Destructor ~CWBMain(); /// Initialises member variables void Init(); /// Creates the controls and sizers void CreateControls(); ////@begin CWBMain event handler declarations ////@end CWBMain event handler declarations ////@begin CWBMain member function declarations /// Retrieves bitmap resources wxBitmap GetBitmapResource( const wxString& name ); /// Retrieves icon resources wxIcon GetIconResource( const wxString& name ); ////@end CWBMain member function declarations /// Should we show tooltips? static bool ShowToolTips(); ////@begin CWBMain member variables wxFlexGridSizer* m_MainSizer; ////@end CWBMain member variables void SetProcessObj(IWBProcess* pProcess); IWBInterface* GetInterfacePtr(); ///////////////////////////////////////////////// // IWBInterface class functions void ToolBoxItemSel( int nId ); void ToolBoxItemEnable( int nId, bool bOp); void ToolBoxPenSizeSel( int nId ); void ToolBoxColorSel( ColorDef& color ); void ToolBoxFontSel( FontDef& font ); bool MenuBarNewExec( bool bChanged, bool bRepaint ); void MenuBarSaveExec( ); void MenuBarPrintExec( ); void MenuBarPageSetup( ); void MenuBarCutExec( ); void MenuBarUndoExec( ); void MenuBarImageStopExec( ); void MenuBarImageStopEnable( bool bOp ); void EdtSelArea( PtPos& pt1, PtPos& pt2 ); void EdtSelRect( PtPos& pt1, PtPos& pt2 ); void EdtSelEllipse( PtPos& pt1, PtPos& pt2 ); void EdtSelLine( PtPos& pt1, PtPos& pt2 ); void EdtDrawArea( PtPos& pt1, PtPos& pt2 ); void EdtKillArea( ); void EdtRepaint( ); void ScrScrollWindow( int dx, int dy ); void ScrSetScrollPos( int posx, int posy ); void CtlDrawRect( PtPos& pt1, PtPos& pt2, int nLin, ColorDef& color, bool bFull, WB_BYTE flags ); void CtlDrawEllipse( PtPos& pt1, PtPos& pt2, int nLin, ColorDef& color, bool bFull, WB_BYTE flags ); void CtlDrawLine( PtPos& pt1, PtPos& pt2, int nLin, ColorDef& color, bool bMask, WB_BYTE flags ); void CtlDrawIndicator( PtPos& pt, WB_BYTE flags ); void CtlDrawImage( WB_PCSTR szFile, PtPos& pt1, PtPos& pt2, WB_BYTE flags ); void CtlDrawTxt( WB_PCSTR szText, PtPos& pt1, PtPos& pt2, FontDef& font, ColorDef& color, WB_BYTE flags ); void CtlEditTxt( PtPos& pt1, PtPos& pt2, FontDef& font, ColorDef& color ); void CtlGetTxt( WB_PSTR szText ); ///////////////////////////////////////////////// protected: // void private: CWBToolBox* m_pwbToolBox; CWBMenuBar* m_pwbMenuBar; CWBScreen* m_pwbScreen; CWBEdit* m_pwbEdit; }; /*! * CWBScreen class declaration */ class CWBScreen: public wxScrolledWindow, public WBProcessRef { DECLARE_DYNAMIC_CLASS( CWBScreen ) DECLARE_EVENT_TABLE() public: /// Constructors CWBScreen(); CWBScreen(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(100, 100), long style = wxSUNKEN_BORDER|wxHSCROLL|wxVSCROLL|wxALWAYS_SHOW_SB); /// Creation bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(100, 100), long style = wxSUNKEN_BORDER|wxHSCROLL|wxVSCROLL|wxALWAYS_SHOW_SB); /// Destructor ~CWBScreen(); /// Initialises member variables void Init(); /// Creates the controls and sizers void CreateControls(); CWBEdit* GetWBEdit() { return m_pwbEdit; } ////@begin CWBScreen event handler declarations /// EVT_SCROLLWIN_LINEUP event handler for wxID_ANY void OnScrLineUp( wxScrollWinEvent& event ); /// EVT_SCROLLWIN_LINEDOWN event handler for wxID_ANY void OnScrLineDown( wxScrollWinEvent& event ); /// EVT_SCROLLWIN_PAGEUP event handler for wxID_ANY void OnScrPageUp( wxScrollWinEvent& event ); /// EVT_SCROLLWIN_PAGEDOWN event handler for wxID_ANY void OnScrPageDown( wxScrollWinEvent& event ); /// EVT_SCROLLWIN_THUMBRELEASE event handler for wxID_ANY void OnScrThumbRelease( wxScrollWinEvent& event ); /// wxEVT_SIZE event handler for wxID_ANY void OnSize( wxSizeEvent& event ); /// wxEVT_PAINT event handler for wxID_ANY void OnPaint( wxPaintEvent& event ); ////@end CWBScreen event handler declarations ////@begin CWBScreen member function declarations /// Retrieves bitmap resources wxBitmap GetBitmapResource( const wxString& name ); /// Retrieves icon resources wxIcon GetIconResource( const wxString& name ); ////@end CWBScreen member function declarations /// Should we show tooltips? static bool ShowToolTips(); ////@begin CWBScreen member variables wxGridSizer* m_EditSizer; bool m_bIsScrolled; ////@end CWBScreen member variables void ScrollWnd(int dx, int dy); void AdjScrollPos(); private: CWBEdit* m_pwbEdit; }; /*! * CWBEdit class declaration */ class CWBEdit: public wxPanel, public WBProcessRef { DECLARE_DYNAMIC_CLASS( CWBEdit ) DECLARE_EVENT_TABLE() public: /// Constructors CWBEdit(); CWBEdit(wxWindow* parent, wxWindowID id = IDW_WB_EDIT, const wxPoint& pos = wxPoint(0, 0), const wxSize& size = wxSize(800, 600), long style = wxSIMPLE_BORDER|wxTAB_TRAVERSAL); /// Creation bool Create(wxWindow* parent, wxWindowID id = IDW_WB_EDIT, const wxPoint& pos = wxPoint(0, 0), const wxSize& size = wxSize(800, 600), long style = wxSIMPLE_BORDER|wxTAB_TRAVERSAL); /// Destructor ~CWBEdit(); /// Initialises member variables void Init(); /// Creates the controls and sizers void CreateControls(); void SetControl(int nId); void SetPenSize(int nId); void SetFrgColour(wxColour& colour); void SetTxtFont(wxFont& font); void DrawArea( PtPos& pt1, PtPos& pt2 ); void KillArea( ); void Repaint( ); void DrawRect( PtPos& pt1, PtPos& pt2, int nLin, ColorDef& color, bool bFull, WB_BYTE flags ); void DrawEllipse( PtPos& pt1, PtPos& pt2, int nLin, ColorDef& color, bool bFull, WB_BYTE flags ); void DrawLine( PtPos& pt1, PtPos& pt2, int nLin, ColorDef& color, bool bMask, WB_BYTE flags ); void DrawIndicator( PtPos& pt, WB_BYTE flags ); void DrawImage( WB_PCSTR szFile, PtPos& pt1, PtPos& pt2, WB_BYTE flags ); void DrawTxt( WB_PCSTR szText, PtPos& pt1, PtPos& pt2, FontDef& font, ColorDef& color, WB_BYTE flags ); void EditTxt( PtPos& pt1, PtPos& pt2, FontDef& font, ColorDef& color ); void GetTxt( WB_PSTR szText ); bool NewExec( bool bChanged, bool bRepaint ); void SaveExec( ); void PrintExec( ); void PageSetup( ); void CutExec( ); void SelArea( PtPos& pt1, PtPos& pt2 ); void SelRect( PtPos& pt1, PtPos& pt2 ); void SelEllipse( PtPos& pt1, PtPos& pt2 ); void SelLine( PtPos& pt1, PtPos& pt2 ); bool SelImage(); void SetScrollPos( int posx, int posy ); ////@begin CWBEdit event handler declarations /// wxEVT_LEFT_DOWN event handler for IDW_WB_EDIT void OnLeftDown( wxMouseEvent& event ); /// wxEVT_LEFT_UP event handler for IDW_WB_EDIT void OnLeftUp( wxMouseEvent& event ); /// wxEVT_MOTION event handler for IDW_WB_EDIT void OnMotion( wxMouseEvent& event ); /// wxEVT_PAINT event handler for wxID_ANY void OnPaint( wxPaintEvent& event ); /// wxEVT_SET_FOCUS event handler void OnSetFocus( wxFocusEvent& event ); /// wxEVT_COMMAND_TEXT_UPDATED event handler void OnCtlTextUpdated( wxCommandEvent &event ); ////@end CWBEdit event handler declarations ////@begin CWBEdit member function declarations /// Retrieves bitmap resources wxBitmap GetBitmapResource( const wxString& name ); /// Retrieves icon resources wxIcon GetIconResource( const wxString& name ); /// Retrieves cursor resources wxCursor GetCursorResource( const wxString& name ); ////@end CWBEdit member function declarations /// Should we show tooltips? static bool ShowToolTips(); ////@begin CWBEdit member variables ////@end CWBEdit member variables protected: wxFont GetTextFont(FontDef& fd); void WrapText(const wxString& src, wxDC& dc, wxRect& rect, wxString& dest); void AdjClipRect(); void AdjScroll(RcPos& rc); private: wxPen m_Pen; wxColour m_Colour; wxFont m_Font; wxCursor m_Cursor, m_curPos, m_curDel, m_curTxt, m_curMRK, m_curPtr, m_curImg, m_curPen, m_curLin, m_curCrc, m_curCrf, m_curSqr, m_curSqf; wxBitmap m_bmpPtr; int m_scrPosX, m_scrPosY; wxRect m_rcClipRect; bool m_bAreaSelected; PtPos m_AreaPos1, m_AreaPos2; wxBitmap m_bmpEdit; wxTextCtrl* m_pText; wxPrintData* m_printData; wxPageSetupDialogData* m_pageSetupData; }; class CWBPrintout: public wxPrintout { public: CWBPrintout(const wxChar *title); void SetPageSetupData(wxPageSetupDialogData* pData) { m_pageSetupData = pData; } void SetPageImage(wxBitmap* pBmp) { m_bmpImage = pBmp; } bool OnPrintPage(int page); bool HasPage(int page); bool OnBeginDocument(int startPage, int endPage); void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo); void DrawPage(); private: wxBitmap* m_bmpImage; wxPageSetupDialogData* m_pageSetupData; }; #endif // _WBOARDFRAME_H_
[ "heineck@c016ff2c-3db2-11de-a81c-fde7d73ceb89" ]
[ [ [ 1, 743 ] ] ]
cc5e353688e5810beea97dcf7c9468d04a11519f
164ad25eca017ebc51ae72d46dd1f19f722c0c21
/include/Viewer/SkyTransform.h
4dcd7cc6a4cd4b661d07b8394752a793c2d7129e
[]
no_license
jaro-prokop/3dsoftviz
5cdcaa15158acdb335a441073ca2d26e1cd5b46d
77332ef847529a8617247754c94621ebc6a90d2c
refs/heads/master
2021-01-16T20:23:24.894745
2011-05-02T09:00:39
2011-05-02T09:00:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,499
h
/** * SkyTransform.h * Projekt 3DVisual */ #ifndef VIEWER_SKY_TRANSFORM_DEF #define VIEWER_SKY_TRANSFORM_DEF 1 namespace Vwr { /** * \class SkyTransform * \brief Handles sky transformations * \author Unknown * \date 29. 4. 2010 */ class SkyTransform : public osg::Transform { public: /** * \fn inline public virtual constant computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) * \brief computes local to world transformation matrix * \param matrix local matrix * \param nv node visitor * \return bool always true */ virtual bool computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const { osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(nv); if (cv) { osg::Vec3 eyePointLocal = cv->getEyeLocal(); matrix.preMultTranslate(eyePointLocal); } return true; } /** * \fn inline public virtual constant computeWorldToLocalMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) * \brief computes world to local transformation matrix * \param matrix world matrix * \param nv node visitor * \return bool always true */ virtual bool computeWorldToLocalMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const { osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(nv); if (cv) { osg::Vec3 eyePointLocal = cv->getEyeLocal(); matrix.postMultTranslate(-eyePointLocal); } return true; } }; } #endif
[ "kapec@genepool.(none)" ]
[ [ [ 1, 59 ] ] ]
7c80d73fab04ab88431651d6f89213aafd0359d4
0f8559dad8e89d112362f9770a4551149d4e738f
/Wall_Destruction/Havok/Source/Physics/Collide/Agent/CompoundAgent/BvTreeStream/hkpBvTreeStreamAgent.h
06852f624a4fba24974ef22b44e8e9355c5ccd56
[]
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
5,333
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 HK_COLLIDE2_BV_TREE_SHAPE_STREAM_AGENT_H #define HK_COLLIDE2_BV_TREE_SHAPE_STREAM_AGENT_H #include <Physics/Collide/Agent/CompoundAgent/BvTree/hkpBvTreeAgent.h> #include <Physics/Collide/Agent3/Machine/1n/hkpAgent1nTrack.h> /// This agent deals with collisions between hkBvTreeShapes and other shapes. It traverses the bounding volume tree and dispatches /// collision agents for those child shapes that are found to be collision candidates with the other shape. /// The difference to hkpBvTreeAgent is that this agent uses a memory stream to store the agents. /// As a result, memory consumption and fragmentation is reduced significantly. /// However only hkPredGskAgent3 and hkCapsuleTriangleAgent3 are supporting this technology. /// This Agent as well handles welding of inner landscape edges. class hkpBvTreeStreamAgent : public hkpCollisionAgent { public: /// Registers this agent with the collision dispatcher. static void HK_CALL registerAgent(hkpCollisionDispatcher* dispatcher); static void HK_CALL registerConvexListAgent(hkpCollisionDispatcher* dispatcher); static void HK_CALL registerMultiRayAgent(hkpCollisionDispatcher* dispatcher); // hkpCollisionAgent interface implementation. virtual void processCollision(const hkpCdBody& bodyA, const hkpCdBody& bodyB, const hkpProcessCollisionInput& input, hkpProcessCollisionOutput& result); // hkpCollisionAgent interface implementation. virtual void cleanup(hkCollisionConstraintOwner& info); // hkpCollisionAgent interface implementation. virtual void getPenetrations( const hkpCdBody& bodyA, const hkpCdBody& bodyB, const hkpCollisionInput& input, hkpCdBodyPairCollector& collector ); // hkpCollisionAgent interface implementation. virtual void getClosestPoints( const hkpCdBody& bodyA, const hkpCdBody& bodyB, const hkpCollisionInput& input, hkpCdPointCollector& collector ) ; // hkpCollisionAgent interface implementation. virtual void linearCast( const hkpCdBody& bodyA, const hkpCdBody& bodyB, const hkpLinearCastCollisionInput& input, hkpCdPointCollector& collector, hkpCdPointCollector* startCollector ); // hkpCollisionAgent interface implementation. virtual void updateShapeCollectionFilter( const hkpCdBody& bodyA, const hkpCdBody& bodyB, const hkpCollisionInput& input, hkCollisionConstraintOwner& constraintOwner ); // hkpCollisionAgent interface implementation. virtual void invalidateTim( const hkpCollisionInput& input); // hkpCollisionAgent interface implementation. virtual void warpTime(hkTime oldTime, hkTime newTime, const hkpCollisionInput& input); protected: hkResult prepareCollisionPartnersProcess( hkpAgent3ProcessInput& input, hkArray<hkpShapeKey>& hitList ); /// Constructor, called by the agent creation function. hkpBvTreeStreamAgent( const hkpCdBody& bodyA, const hkpCdBody& bodyB, const hkpCollisionInput& input, hkpContactMgr* mgr ); ///Destructor, called by cleanup(). ~hkpBvTreeStreamAgent(){} void calcContentStatistics( hkStatisticsCollector* collector, const hkClass* cls) const; public: /// Agent creation function used by the hkpCollisionDispatcher. static hkpCollisionAgent* HK_CALL createShapeBvAgent( const hkpCdBody& bodyA, const hkpCdBody& bodyB, const hkpCollisionInput& input, hkpContactMgr* mgr ); /// Agent creation function used by the hkpCollisionDispatcher. static hkpCollisionAgent* HK_CALL createBvTreeShapeAgent( const hkpCdBody& bodyA, const hkpCdBody& bodyB, const hkpCollisionInput& input, hkpContactMgr* mgr ); // Extra convex list dispatch functions static hkpCollisionAgent* HK_CALL dispatchBvTreeConvexList( const hkpCdBody& bodyA, const hkpCdBody& bodyB, const hkpCollisionInput& input, hkpContactMgr* mgr ); static hkpCollisionAgent* HK_CALL dispatchConvexListBvTree( const hkpCdBody& bodyA, const hkpCdBody& bodyB, const hkpCollisionInput& input, hkpContactMgr* mgr ); protected: hkpCollisionDispatcher* m_dispatcher; hkAabb m_cachedAabb; hkpAgent1nTrack m_agentTrack; }; #endif // HK_COLLIDE2_BV_TREE_SHAPE_STREAM_AGENT_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. * */
[ [ [ 1, 103 ] ] ]
da6543215fd4d2e11204617c6e63e4691aab6bdb
011359e589f99ae5fe8271962d447165e9ff7768
/src/burn/neogeo/romsave.cpp
5b2f1d6ebfafd828225a038e6cdbc8e877189fba
[]
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
5,417
cpp
// FB Alpha Plus! Neo-Geo ROMs saving driver module // Module version: v0.4a // Whole driver module written by IQ_132 - http://neosource.1emulation.com/. // =============================================================== // Revision History: // - Version 0.4a // Trimmed C-Saving routine and optimized it (Thanks to IQ_132). // --------------------------------------------------------------- // - Version 0.4 // Renamed some kludges and added routines for some new games. // --------------------------------------------------------------- // - Version 0.3 // Fixed svcchaos c1 and c2 code (again, thanks to Jimmy_Page) // Added a code to save a 16mb V1-ROM for kof2003 (thanks to Jimmy_page) // --------------------------------------------------------------- // - Version 0.2 // Fixed C-Decryption for svcchaos. // Added the hability for naming the files from the cartridge ID. // Fixed interleaving for using less RAM. // Changed V-ROM saving routine. // --------------------------------------------------------------- // - Version 0.1 // First version. // Added some tweaks for C-Decryption saving. // =============================================================== #include "neogeo.h" int bsavedecryptedcs = 0; int bsavedecryptedps = 0; int bsavedecrypteds1 = 0; int bsavedecryptedvs = 0; int bsavedecryptedm1 = 0; // 8 C-ROMs for standard ROMsets, number will vary void SaveDecCROMs() { extern unsigned int nSpriteSize; if (NeoSpriteROM == NULL) return; char szNames[64] = ""; char name[64] = ""; int divby = 0x1000000; BurnUpdateProgress(0.0, "Initializing save routine...", 0); if (!(nSpriteSize & 0xFFFFFF)) { if (!strcmp(BurnDrvGetTextA(DRV_NAME), "svcpcb")) divby = 0x4000000; if (!strcmp(BurnDrvGetTextA(DRV_NAME), "kf2k3pcb")) divby = 0x2000000; for (unsigned int i = 0; i < (nSpriteSize / divby); i++) { sprintf(szNames, "Saving decrypted C%d and C%d ROMs...", ((i*2)+1), ((i*2)+2)); BurnUpdateProgress(0.0, szNames, 0); sprintf(name, "%X%2.2X-c%d_decrypted.bin", Neo68KROM[0x109], Neo68KROM[0x108], ((i*2)+1)); FILE* C1 = fopen(name, "wb"); sprintf(name, "%X%2.2X-c%d_decrypted.bin", Neo68KROM[0x109], Neo68KROM[0x108], ((i*2)+2)); FILE* C2 = fopen(name, "wb"); if (C1 && C2) { for (int j = 0; j < divby; j += 2) { fwrite(NeoSpriteROM + i * divby + j + 0, 1, 1, C1); fwrite(NeoSpriteROM + i * divby + j + 1, 1, 1, C2); } fclose(C1); fclose(C2); } } return; } } // For compatibility issues, only 1 P-ROM will be saved void SaveDecPROM() { extern unsigned int nCodeSize; char name[64] = ""; BurnUpdateProgress(0.0, "Saving decrypted P-ROM...", 0); sprintf (name, "%X%2.2X-p1_decrypted.bin", Neo68KROM[0x109], Neo68KROM[0x108]); FILE* file = fopen(name, "wb"); if (file) { fwrite(Neo68KROM, 1, nCodeSize, file); fclose(file); } } // Either extracted from C Data or descrambled text roms void SaveDecSROM() { char name[64] = ""; BurnUpdateProgress(0.0, "Saving decrypted S1-ROM...", 0); sprintf (name, "%X%2.2X-s1_decrypted.bin", Neo68KROM[0x109], Neo68KROM[0x108]); FILE* file = fopen(name, "wb"); if (file) { fwrite(NeoTextROM + 0x020000, 1, nNeoTextROMSize, file); fclose(file); } } // Standard decrypted samples are saved with this void SaveDecVROMs(int nNumber) { extern unsigned char* YM2610ADPCMAROM; extern int nYM2610ADPCMASize; char name[64] = ""; // Special handler for unique V-ROM if (nNumber == 1) { BurnUpdateProgress(0.0, "Saving decrypted V1 ROM...", 0); sprintf (name, "%X%2.2X-v1_decrypted.bin", Neo68KROM[0x109], Neo68KROM[0x108]); FILE* V1ROM = fopen(name, "wb"); if (V1ROM) { fwrite(YM2610ADPCMAROM, 1, nYM2610ADPCMASize, V1ROM); fclose(V1ROM); } } else if (nNumber == 3) { BurnUpdateProgress(0.0, "Saving decrypted V1 V2 V3 ROM...", 0); sprintf (name, "%X%2.2X-v1_decrypted.bin", Neo68KROM[0x109], Neo68KROM[0x108]); FILE* V1ROM = fopen(name, "wb"); if (V1ROM) { fwrite(YM2610ADPCMAROM, 1, 0x400000, V1ROM); fclose(V1ROM); } sprintf (name, "%X%2.2X-v2_decrypted.bin", Neo68KROM[0x109], Neo68KROM[0x108]); FILE* V2ROM = fopen(name, "wb"); if (V2ROM) { fwrite(YM2610ADPCMAROM + 0x400000, 1, 0x400000, V2ROM); fclose(V2ROM); } sprintf (name, "%X%2.2X-v3_decrypted.bin", Neo68KROM[0x109], Neo68KROM[0x108]); FILE* V3ROM = fopen(name, "wb"); if (V3ROM) { fwrite(YM2610ADPCMAROM + 0x800000, 1, 0x200000, V3ROM); fclose(V3ROM); } } else { BurnUpdateProgress(0.0, "Saving decrypted V1 and V2 ROMs...", 0); sprintf (name, "%X%2.2X-v1_decrypted.bin", Neo68KROM[0x109], Neo68KROM[0x108]); FILE* V1ROM = fopen(name, "wb"); if (V1ROM) { fwrite(YM2610ADPCMAROM, 1, 0x800000, V1ROM); fclose(V1ROM); } sprintf (name, "%X%2.2X-v2_decrypted.bin", Neo68KROM[0x109], Neo68KROM[0x108]); FILE* V2ROM = fopen(name, "wb"); if (V2ROM) { fwrite(YM2610ADPCMAROM + 0x800000, 1, 0x800000, V2ROM); fclose(V2ROM); } } } void SaveDecM1ROM() { char name[64] = ""; BurnUpdateProgress(0.0, "Saving decrypted M1-ROM...", 0); sprintf (name, "%X%2.2X-m1_decrypted.bin", Neo68KROM[0x109], Neo68KROM[0x108]); FILE* file = fopen(name, "wb"); if (file) { fwrite(NeoZ80ROM, 1, nNeoM1ROMSize, file); fclose(file); } }
[ [ [ 1, 171 ] ] ]
c3a165ca693d6bcf171c5953304af96668edc2e1
2ca3ad74c1b5416b2748353d23710eed63539bb0
/Src/Lokapala/Operator/DecisionManager.h
1afb942dd1d7bb84d461fbd63795ad3f160976a8
[]
no_license
sjp38/lokapala
5ced19e534bd7067aeace0b38ee80b87dfc7faed
dfa51d28845815cfccd39941c802faaec9233a6e
refs/heads/master
2021-01-15T16:10:23.884841
2009-06-03T14:56:50
2009-06-03T14:56:50
32,124,140
0
0
null
null
null
null
UTF-8
C++
false
false
1,565
h
/**@file DecisionManager.h * @brief CDecisionManager 클래스를 정의한다. * @author siva */ #ifndef DECISION_MANAGER_H #define DECISION_MANAGER_H /**@ingroup GroupDCM * @class CDecisionManager * @brief DCM의 실질적인 행동을 한다.\n * 추후, 데이터 처리, 명령, 판결로 클래스를 나눌것. */ class CDecisionManager { public : static CDecisionManager *Instance() { if(!m_instance) { m_instance = new CDecisionManager(); } return m_instance; } void HostConnected(void *a_hostData); void HostDisconnected(void *a_hostData); void ReportStatusTo(CString *a_hostAddress); void JudgeLoginRequest(void *a_loginRequestData); void JudgeUserExecutedProcess(void *a_executedProcessData); void PresentStatusReport(void *a_statusReportData); void ShutdownHost(void *a_argument); void RebootHost(void *a_argument); void BanUser(void *a_argument); void ExecuteHostProcess(void *a_argument); void KillHostProcess(void *a_argument); void GenocideHostProcess(void *a_argument); void WarnHost(void *a_argument); void SubmitStatusReportToHost(void *a_statusReport); void TerminateRaptorOnHost(void *a_argument); protected : CDecisionManager(){} ~CDecisionManager(){} private : static CDecisionManager *m_instance; void ControlRaptor(void *a_controlAction); void DoReactionsTo(void *a_executedProcess, void *a_rules); void DoReactionTo(void *a_executedProcess, void *a_rule); void RemoveFromAcceptedUser(CString a_hostAddress); }; #endif
[ "nilakantha38@b9e76448-5c52-0410-ae0e-a5aea8c5d16c" ]
[ [ [ 1, 60 ] ] ]
086b72a64cc39c662e69680d80536dd8c2a21921
c95a83e1a741b8c0eb810dd018d91060e5872dd8
/Game/ObjectDLL/ObjectShared/AIGoalAttackProne.h
ae50c16a925ad22581234ae164484151071cf070
[]
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,317
h
// ----------------------------------------------------------------------- // // // MODULE : AIGoalAttackProne.h // // PURPOSE : AIGoalAttackProne class definition // // CREATED : 6/25/02 // // (c) 2002 Monolith Productions, Inc. All Rights Reserved // ----------------------------------------------------------------------- // #ifndef __AIGOAL_ATTACK_PRONE_H__ #define __AIGOAL_ATTACK_PRONE_H__ #include "AIGoalAbstractStimulated.h" class CAIGoalAttackProne : public CAIGoalAbstractStimulated { typedef CAIGoalAbstractStimulated super; public: DECLARE_AI_FACTORY_CLASS_SPECIFIC(Goal, CAIGoalAttackProne, kGoal_AttackProne); CAIGoalAttackProne(); virtual void InitGoal(CAI* pAI); // Save / Load virtual void Save(ILTMessage_Write *pMsg); virtual void Load(ILTMessage_Read *pMsg); // Activation. virtual void ActivateGoal(); virtual void DeactivateGoal(); // Updating. void UpdateGoal(); // Damage Handling. virtual HMODELANIM GetAlternateDeathAnimation(); // Sense Handling. virtual LTBOOL HandleGoalSenseTrigger(AISenseRecord* pSenseRecord); protected: // State Handling. void HandleStateAttackProne(); protected: LTFLOAT m_fProneTimeLimit; LTFLOAT m_fMinDistSqr; }; #endif
[ [ [ 1, 65 ] ] ]
cefaf14e674c73769d6bac504519c87bade8be08
ce262ae496ab3eeebfcbb337da86d34eb689c07b
/SEFoundation/SESceneGraph/SEUnculledSet.cpp
a531194674d5fb047565894a09a4a4bee6d2d35c
[]
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
UTF-8
C++
false
false
2,687
cpp
// 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 #include "SEFoundationPCH.h" #include "SEUnculledSet.h" using namespace Swing; //---------------------------------------------------------------------------- SEUnculledSet::SEUnculledSet(int iMaxCount, int iGrowBy) { m_pUnculled = 0; Resize(iMaxCount, iGrowBy); } //---------------------------------------------------------------------------- SEUnculledSet::~SEUnculledSet() { SE_DELETE[] m_pUnculled; } //---------------------------------------------------------------------------- void SEUnculledSet::Insert(SESpatial* pObject, SEEffect* pGlobalEffect) { if( ++m_iCount > m_iMaxCount ) { int iNewMaxCount = m_iMaxCount + m_iGrowBy; SEUnculledObject* pNewVisible = SE_NEW SEUnculledObject[iNewMaxCount]; size_t uiSize = m_iCount * sizeof(SEUnculledObject); SESystem::SE_Memcpy(pNewVisible, uiSize, m_pUnculled, uiSize); SE_DELETE[] m_pUnculled; m_pUnculled = pNewVisible; m_iMaxCount = iNewMaxCount; } int iIndex = m_iCount-1; m_pUnculled[iIndex].Object = pObject; m_pUnculled[iIndex].GlobalEffect = pGlobalEffect; } //---------------------------------------------------------------------------- void SEUnculledSet::Resize(int iMaxCount, int iGrowBy) { if( iMaxCount > 0 ) { m_iMaxCount = iMaxCount; } else { m_iMaxCount = US_DEFAULT_MAX_COUNT; } if( iGrowBy > 0 ) { m_iGrowBy = iGrowBy; } else { m_iGrowBy = US_DEFAULT_GROWBY; } SE_DELETE[] m_pUnculled; m_iCount = 0; m_pUnculled = SE_NEW SEUnculledObject[m_iMaxCount]; } //----------------------------------------------------------------------------
[ "[email protected]@876e9856-8d94-11de-b760-4d83c623b0ac" ]
[ [ [ 1, 80 ] ] ]
ccf985cdf025c89e7dbeeeeb9af566d9bf3a9288
3daaefb69e57941b3dee2a616f62121a3939455a
/mgllib/src/graphic_extends/MglImageFader.h
f5d1be23e973ca152f661f084c06bf264d0673db
[]
no_license
myun2ext/open-mgl-legacy
21ccadab8b1569af8fc7e58cf494aaaceee32f1e
8faf07bad37a742f7174b454700066d53a384eae
refs/heads/master
2016-09-06T11:41:14.108963
2009-12-28T12:06:58
2009-12-28T12:06:58
null
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
1,340
h
#ifndef __MglImageFader_H__ #define __MglImageFader_H__ #include "MglGraphicManager.h" #include "MglImage.h" #include "MglImageManager.h" // クラス宣言 class DLL_EXP CMglImageFader { protected: /*CMglImageManager* m_pImgMgr; string m_strName;*/ int m_nFadeSpeed; int m_x, m_y; D3DCOLOR m_color; RECT m_rect; int m_nFrameCounter; //int m_nFadeInStart; int m_nFadeOutStart; CMglImage *m_pImage; // こっちじゃね // → Cacher管理にした方がヨサゲかも // 内部メソッド(チェック用) void InitCheck() { //if ( m_pImgMgr == NULL ) if ( m_pImage == NULL ) MyuThrow( 0, "CMglImageFader::Setup()が呼ばれていません。" ); } public: // コンストラクタ・デストラクタ CMglImageFader(); virtual ~CMglImageFader(); /*void Setup( CMglImageManager* pImageManager, const char* szName, int nFadeSpeed, int x=0, int y=0, CONST RECT *srcRect=NULL, D3DCOLOR color=D3DCOLOR_WHITE );*/ void Setup( CMglImage* pImage, int nFadeSpeed, int x=0, int y=0, CONST RECT *srcRect=NULL, D3DCOLOR color=D3DCOLOR_WHITE ); /*void FadeIn( int nFadeSpeed=0 ); void FadeOut( int nFadeSpeed=0 );*/ void FadeIn(){ m_nFrameCounter = 0; } void FadeOut(){ m_nFadeOutStart = m_nFrameCounter; } void DoDraw(); }; #endif//__MglImageFader_H__
[ "myun2@6d62ff88-fa28-0410-b5a4-834eb811a934" ]
[ [ [ 1, 48 ] ] ]
75f99a1d15d72fc134e67b5d868b77a30c2fc0d5
6131815bf1b62accfc529c2bc9db21194c7ba545
/FrameworkApp/d3dTexturedCube.h
c79bb0bfbc8aa5e1d5ceb16a10206f982a034202
[]
no_license
dconefourseven/honoursproject
b2ee664ccfc880c008f29d89aad03d9458480fc8
f26b967fda8eb6937f574fd6f3eb76c8fecf072a
refs/heads/master
2021-05-29T07:14:35.261586
2011-05-15T18:27:49
2011-05-15T18:27:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,175
h
#ifndef _D3DTEXTUREDCUBE_H #define _D3DTEXTUREDCUBE_H //#include "d3dlitcube.h" #include <d3d9.h> #include <d3dx9.h> //The textured vertex struct TexturedVertexStruct { TexturedVertexStruct(float _x, float _y, float _z, float _nx, float _ny, float _nz, float _u, float _v) { x = _x; y = _y; z = _z; nx = _nx; ny = _ny; nz = _nz; u = _u; v=_v; } float x, y, z; float nx, ny, nz; float u, v; }; //Inherits from the lit cube class class D3DTexturedCube { public: //The textured cube constructor D3DTexturedCube(); //The destructor ~D3DTexturedCube(); //The set buffers function that sets up the cube, a wrapper for the initBuffers() function void setBuffers(IDirect3DDevice9 * Device); //The render function void Render(IDirect3DDevice9 * Device, ID3DXEffect *mFX); //The release function void Release(); public: private: //The initialise function void initBuffers(IDirect3DDevice9 * Device); private: // A structure for our custom vertex type #define D3DFVF_TEXTUREDVERTEX D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1 //The vertex buffer IDirect3DVertexBuffer9 *VB; }; #endif
[ "davidclarke1990@fa56ba20-0011-6cdf-49b4-5b20436119f6" ]
[ [ [ 1, 59 ] ] ]
f02afe337788caf45b96ed6ae73e3aa8098f6146
3daaefb69e57941b3dee2a616f62121a3939455a
/mgllib/src/2d/MglMotionLayer.h
1a71b9245603ba1a85e26208dfea07d54f0b7b58
[]
no_license
myun2ext/open-mgl-legacy
21ccadab8b1569af8fc7e58cf494aaaceee32f1e
8faf07bad37a742f7174b454700066d53a384eae
refs/heads/master
2016-09-06T11:41:14.108963
2009-12-28T12:06:58
2009-12-28T12:06:58
null
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
1,577
h
#ifndef __MglMotionLayer_H__ #define __MglMotionLayer_H__ #include "MglLayerBase4.h" // クラス宣言 //template <typename TBase> class CMglStraightMoveLayer : public TBase template <typename TBase> class CMglStraightMoveLayer : public CMgEffectLayerBase<TBase> { private: int m_nCounter; float m_fMoveX; float m_fMoveY; void _Init(){ m_nCounter = 0; m_fMoveX = 0.0f; m_fMoveY = 0.0f; } public: // コンストラクタ CMglMotionLayer(){ _Init(); } CMglMotionLayer(bool isShouldDeletePtr){ _Init(); m_isShouldDeletePtr=isShouldDeletePtr; } // パラメータ指定つきコンストラクタ CMglMotionLayer(float fMoveX, float fMoveY) { Init(fMoveX,fMoveY); } CMglMotionLayer(float fMoveX, float fMoveY, bool isShouldDeletePtr) { Init(fMoveX,fMoveY); m_isShouldDeletePtr=isShouldDeletePtr; } // 初期化 void Init( float fMoveX, float fMoveY) { m_nCounter = 0; m_fMoveX = fMoveX; m_fMoveY = fMoveY; //if ( } // implement void Draw( float x, float y, CONST RECT *srcRect=NULL, D3DCOLOR color=D3DCOLOR_FULLWHITE, float fScaleX=1.0f, float fScaleY=1.0f, float fRotationCenterX=0.5f, float fRotationCenterY=0.5f, float fAngle=0.0f ) { TBase::Draw( x + m_fMoveX*m_nCounter, y + m_fMoveY*m_nCounter, srcRect,color,fScaleX,fScaleY,fRotationCenterX,fRotationCenterY,fAngle); } virtual BOOL OnFrame(){ m_nCounter++; //m_nCounter = m_nCounter % (m_nShowFrame+m_nHideFrame); return TRUE; } }; #endif//__MglMotionLayer_H__
[ "myun2@6d62ff88-fa28-0410-b5a4-834eb811a934" ]
[ [ [ 1, 67 ] ] ]
dd734d8dfd8284cd32b02c1201ffd447c1ef17eb
d81bbe5a784c804f59f643fcbf84be769abf2bc9
/Gosling/src/GosSpectrumCircle.cpp
f38ca6748054e73ef3486e5b95c23b327b17eb86
[]
no_license
songuke/goslingviz
9d071691640996ee88171d36f7ca8c6c86b64156
f4b7f71e31429e32b41d7a20e0c151be30634e4f
refs/heads/master
2021-01-10T03:36:25.995930
2010-04-16T08:49:27
2010-04-16T08:49:27
36,341,765
0
0
null
null
null
null
UTF-8
C++
false
false
2,879
cpp
#include "GosSpectrumCircle.h" #include "GosChunk.h" namespace Gos { SpectrumCircle::SpectrumCircle(void) { } SpectrumCircle::~SpectrumCircle(void) { } void SpectrumCircle::render(Chunk& c, Rect r) { float width = r.right - r.left; float height = r.top - r.bottom; int nbBars = 32; float logBase = 2; float logStep = log((float) kChunkSize) / log(logBase); float centerX = width / 2; float centerY = height / 2; float angleStep = M_PI / nbBars; Float4 lime(168.0f / 255, 230.0f / 255, 29.0f / 255, 1.0f); Float4 red(237.0f / 255, 28.0f / 255, 36.0f / 255, 1.0f); if (c.beat > 0) { lime = lime * 1.5f; red = red * 1.5f; } // TODO: I'll optimize the rendering with Vertex Buffer Object later. float angle = 0; int startSample; int endSample; for (int i = 0; i < nbBars; i++) { startSample = (int) floor(pow(logBase, logStep * i / nbBars)) - 1; endSample = (int) ceil(pow(logBase, logStep * (i + 1) / nbBars)) - 1; float combined = 0; for (int j = startSample; j < endSample; j++) { combined += pow(c.magnitude[j][1], 2); } float intensity = std::min(1.0f, combined * 0.0002f); Float4 curRed = lime * (1.0f - intensity) + red * intensity; glBegin(GL_QUADS); glColor4f(lime.x, lime.y, lime.z, lime.w); // bottom glVertex2f(centerX, centerY); glVertex2f(centerX + (intensity * sin(angle) / 2 * centerX), centerY + (intensity * cos(angle) / 2 * centerY)); glColor4f(curRed.x, curRed.y, curRed.z, curRed.w); // top glVertex2f(centerX + (intensity * sin(angle + (angleStep / 2)) * centerX), centerY + (intensity * cos(angle + (angleStep / 2))) * centerY); glColor4f(lime.x, lime.y, lime.z, lime.w); glVertex2f(centerX + (intensity * sin(angle + angleStep) / 2 * centerX), centerY + (intensity * cos(angle + angleStep) / 2) * centerY); glEnd(); angle += M_PI; combined = 0; for (int j = startSample; j < endSample; j++) { combined += pow(c.magnitude[j][0], 2); } intensity = std::min(1.0f, combined * 0.0002f); curRed = lime * (1.0f - intensity) + red * intensity; glBegin(GL_QUADS); glColor4f(lime.x, lime.y, lime.z, lime.w); // bottom glVertex2f(centerX, centerY); glVertex2f(centerX + (intensity * sin(angle) / 2 * centerX), centerY + (intensity * cos(angle) / 2 * centerY)); glColor4f(curRed.x, curRed.y, curRed.z, curRed.w); // top glVertex2f(centerX + (intensity * sin(angle + (angleStep / 2)) * centerX), centerY + (intensity * cos(angle + (angleStep / 2))) * centerY); glColor4f(lime.x, lime.y, lime.z, lime.w); glVertex2f(centerX + (intensity * sin(angle + angleStep) / 2 * centerX), centerY + (intensity * cos(angle + angleStep) / 2) * centerY); glEnd(); angle -= M_PI; angle += angleStep; } } void SpectrumCircle::onFileChanged(const Gos::String &file) { } }
[ "yjianqing@00dcdb3d-b287-7056-8bd8-84a1afe327dc", "songuke@00dcdb3d-b287-7056-8bd8-84a1afe327dc" ]
[ [ [ 1, 82 ], [ 86, 86 ] ], [ [ 83, 85 ] ] ]
e511250ce934b0d8235f1bb1a76a00918237c05d
3aafc3c40c1464fc2a32d1b6bba23818903a4ec9
/TagCloud/TagCloud/stdafx.cpp
fbb5c537c76e7db33a0c1e96e8e5f18d3ba39d76
[]
no_license
robintw/rlibrary
13930416649ec38196bfd38e0980616e9f5454c8
3e55d49acba665940828e26c8bff60863a86246f
refs/heads/master
2020-09-22T10:31:55.561804
2009-01-24T19:05:19
2009-01-24T19:05:19
34,583,564
0
1
null
null
null
null
UTF-8
C++
false
false
208
cpp
// stdafx.cpp : source file that includes just the standard includes // TagCloud.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h"
[ "[email protected]@02cab514-f24f-0410-a9ea-a7698ff47c65" ]
[ [ [ 1, 7 ] ] ]
cdb1ec9222b92c67d828ba5e8ba3ae5a26a08f62
1e01b697191a910a872e95ddfce27a91cebc57dd
/GrfRemoveLastElement.cpp
d4441eedabdf4240612c76a71d7710f53a7f9c49
[]
no_license
canercandan/codeworker
7c9871076af481e98be42bf487a9ec1256040d08
a68851958b1beef3d40114fd1ceb655f587c49ad
refs/heads/master
2020-05-31T22:53:56.492569
2011-01-29T19:12:59
2011-01-29T19:12:59
1,306,254
7
5
null
null
null
null
IBM852
C++
false
false
1,706
cpp
/* "CodeWorker": a scripting language for parsing and generating text. Copyright (C) 1996-1997, 1999-2010 CÚdric Lemaire This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA To contact the author: [email protected] */ #ifdef WIN32 #pragma warning (disable : 4786) #endif #include "ScpStream.h" #include "CppCompilerEnvironment.h" #include "CGRuntime.h" #include "DtaScriptVariable.h" #include "ExprScriptVariable.h" #include "GrfRemoveLastElement.h" namespace CodeWorker { GrfRemoveLastElement::~GrfRemoveLastElement() { delete _pList; } SEQUENCE_INTERRUPTION_LIST GrfRemoveLastElement::executeInternal(DtaScriptVariable& visibility) { DtaScriptVariable* pList = visibility.getExistingVariable(*_pList); return CGRuntime::removeLastElement(pList); } void GrfRemoveLastElement::compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const { CW_BODY_INDENT << "CGRuntime::removeLastElement("; _pList->compileCpp(theCompilerEnvironment); CW_BODY_STREAM << ");"; CW_BODY_ENDL; } }
[ "cedric.p.r.lemaire@28b3f5f3-d42e-7560-b87f-5f53cf622bc4" ]
[ [ [ 1, 49 ] ] ]
fdad5d4d5ddf491a35703e4041db3820224eb5f0
96fefafdfbb413a56e0a2444fcc1a7056afef757
/MQ2Chat/ISXEQChat.cpp
8c3551e00d2785d05fcf68a0eb9c9968a09ad04b
[]
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
6,041
cpp
// // ISXEQChat // #pragma warning(disable:4996) #include "../ISXEQClient.h" #include "ISXEQChat.h" // The mandatory pre-setup function. Our name is "ISXEQChat", and the class is ISXEQChat. // This sets up a "ModulePath" variable which contains the path to this module in case we want it, // and a "PluginLog" variable, which contains the path and filename of what we should use for our // debug logging if we need it. It also sets up a variable "pExtension" which is the pointer to // our instanced class. ISXPreSetup("ISXEQChat",ISXEQChat); // Basic LavishScript datatypes, these get retrieved on startup by our initialize function, so we can // use them in our Top-Level Objects or custom datatypes LSType *pStringType=0; LSType *pIntType=0; LSType *pBoolType=0; LSType *pFloatType=0; LSType *pTimeType=0; LSType *pByteType=0; ISInterface *pISInterface=0; HISXSERVICE hPulseService=0; HISXSERVICE hMemoryService=0; HISXSERVICE hServicesService=0; HISXSERVICE hEQChatService=0; HISXSERVICE hEQUIService=0; HISXSERVICE hEQGamestateService=0; HISXSERVICE hEQSpawnService=0; HISXSERVICE hEQZoneService=0; // Forward declarations of callbacks //void __cdecl PulseService(bool Broadcast, unsigned int MSG, void *lpData); //void __cdecl MemoryService(bool Broadcast, unsigned int MSG, void *lpData); void __cdecl ServicesService(bool Broadcast, unsigned int MSG, void *lpData); // Initialize is called by Inner Space when the extension should initialize. bool ISXEQChat::Initialize(ISInterface *p_ISInterface) { pISInterface=p_ISInterface; // retrieve basic ISData types pStringType=pISInterface->FindLSType("string"); pIntType=pISInterface->FindLSType("int"); pBoolType=pISInterface->FindLSType("bool"); pFloatType=pISInterface->FindLSType("float"); pTimeType=pISInterface->FindLSType("time"); pByteType=pISInterface->FindLSType("byte"); pISInterface->OpenSettings(XMLFileName); LoadSettings(); ConnectServices(); RegisterCommands(); RegisterAliases(); RegisterDataTypes(); RegisterTopLevelObjects(); RegisterServices(); WriteChatf("ISXEQChat Loaded"); return true; } // shutdown sequence void ISXEQChat::Shutdown() { // save settings, if you changed them and want to save them now. You should normally save // changes immediately. //pISInterface->SaveSettings(XMLFileName); pISInterface->UnloadSettings(XMLFileName); DisconnectServices(); UnRegisterServices(); UnRegisterTopLevelObjects(); UnRegisterDataTypes(); UnRegisterAliases(); UnRegisterCommands(); } void ISXEQChat::ConnectServices() { // connect to any services. Here we connect to "Pulse" which receives a // message every frame (after the frame is displayed) and "Memory" which // wraps "detours" and memory modifications // hPulseService=pISInterface->ConnectService(this,"Pulse",PulseService); // hMemoryService=pISInterface->ConnectService(this,"Memory",MemoryService); hServicesService=pISInterface->ConnectService(this,"Services",ServicesService); } void ISXEQChat::RegisterCommands() { // add any commands // pISInterface->AddCommand("MyCommand",MyCommand,true,false); } void ISXEQChat::RegisterAliases() { // add any aliases } void ISXEQChat::RegisterDataTypes() { // add any datatypes // pMyType = new MyType; // pISInterface->AddLSType(*pMyType); } void ISXEQChat::RegisterTopLevelObjects() { // add any Top-Level Objects // pISInterface->AddTopLevelObject("MapSpawn",tloMapSpawn); } void ISXEQChat::RegisterServices() { // register any services. Here we demonstrate a service that does not use a // callback // set up a 1-way service (broadcast only) // hISXEQChatService=pISInterface->RegisterService(this,"ISXEQChat Service",0); // broadcast a message, which is worthless at this point because nobody will receive it // (nobody has had a chance to connect) // pISInterface->ServiceBroadcast(this,hISXEQChatService,ISXSERVICE_MSG+1,0); } void ISXEQChat::DisconnectServices() { // gracefully disconnect from services if (hServicesService) pISInterface->DisconnectService(this,hServicesService); } void ISXEQChat::UnRegisterCommands() { // remove commands // pISInterface->RemoveCommand("MyCommand"); } void ISXEQChat::UnRegisterAliases() { // remove aliases } void ISXEQChat::UnRegisterDataTypes() { // remove data types //if (pMyType) //{ // pISInterface->RemoveLSType(*pMyType); // delete pMyType; //} } void ISXEQChat::UnRegisterTopLevelObjects() { // remove Top-Level Objects // pISInterface->RemoveTopLevelObject("MapSpawn"); } void ISXEQChat::UnRegisterServices() { // shutdown our own services // if (hISXEQChatService) // pISInterface->ShutdownService(this,hISXEQChatService); } void ISXEQChat::LoadSettings() { } void __cdecl EQChatService(bool Broadcast, unsigned int MSG, void *lpData) { #define pChat ((_EQChat*)lpData) switch(MSG) { case CHATSERVICE_OUTGOING: // same as OnWriteChatColor CHAR Stripped[MAX_STRING]; StripMQChat(pChat->Line,Stripped); if (gFilterMacro == FILTERMACRO_NONE) return; if (!ppEverQuest) return; if (gGameState!=GAMESTATE_INGAME) return; if (!pEverQuest) return; dsp_chat_no_events(Stripped,pChat->Color,1); break; case CHATSERVICE_INCOMING: // same as OnIncomingChat break; } #undef pChat } // This uses the Services service to connect to ISXEQ services void __cdecl ServicesService(bool Broadcast, unsigned int MSG, void *lpData) { #define Name ((char*)lpData) switch(MSG) { case SERVICES_ADDED: if (!stricmp(Name,"EQ Chat Service")) { hEQChatService=pISInterface->ConnectService(pExtension,Name,EQChatService); } break; case SERVICES_REMOVED: if (!stricmp(Name,"EQ Chat Service")) { if (hEQChatService) { pISInterface->DisconnectService(pExtension,hEQChatService); hEQChatService=0; } } break; } #undef Name }
[ "[email protected]@39408780-f958-9dab-a28b-4b240efc9052" ]
[ [ [ 1, 232 ] ] ]
8f26229b83f799e4249e3ec1c37ce5de9859ff45
6712f8313dd77ae820aaf400a5836a36af003075
/dummyBC.cpp
da1cf56ffe84d947726ce29f6b3602e88c163c48
[]
no_license
AdamTT1/bdScript
d83c7c63c2c992e516dca118cfeb34af65955c14
5483f239935ec02ad082666021077cbc74d1790c
refs/heads/master
2021-12-02T22:57:35.846198
2010-08-08T22:32:02
2010-08-08T22:32:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,269
cpp
/* * Program dummyBC.cpp * * This module defines a loopback barcode interface * for Linux. * * It accepts barcode requests on a TCP socket, and responds * with dummy responses (generally approved). * * enter<tab>identifier<tab>symbology<tab>barcode * exit<tab>identifier<tab>symbology<tab>barcode * retrieval<tab>identifier<tab>symbology<tab>barcode * * The identifier is passed to the Javascript side in matched * responses. * * Change History : * * $Log: dummyBC.cpp,v $ * Revision 1.6 2003-08-24 22:06:52 ericn * -no linger, reuse address, signal handler\n * * Revision 1.5 2003/07/04 04:26:18 ericn * -no, really. Host IP, then port * * Revision 1.4 2003/07/04 02:42:04 ericn * -added support for hostIP (for compatibility) * * Revision 1.3 2003/03/19 21:59:07 ericn * -removed hardcoded port * * Revision 1.2 2003/02/10 01:17:38 ericn * -modified to support retrieval * * Revision 1.1 2003/02/09 02:25:07 ericn * -added dummy barcode approval program * * * Copyright Boundary Devices, 2002 */ #include <stdio.h> #include <unistd.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <string.h> #include <string> #include <sys/time.h> #include <fcntl.h> #include <signal.h> #include <stdlib.h> static unsigned const maxRxSize = 0x200 ; static char const usage[] = { "Usage: enter|exit|retrieve\\tidentifier\\tsymbology\\tbarcode\n" }; static char const enterMsgs[] = { "\tentry messages\tgo here" }; static char const exitMsgs[] = { "\texit messages\tgo here" }; static char const reportMsgs[] = { "\thistory report\t\tmessages go here\t\tnormally history of barcode" }; static char const approved[] = { "\tapproved\trGF" }; static char const denied[] = { "\tdenied\tRgf" }; static char const report[] = { "\treport\t " }; static void processCmd( std::string const &cmdLine, int fd ) { std::string writeable( cmdLine ); std::string parts[4]; char *next = (char *)writeable.c_str(); unsigned i ; for( i = 0 ; i < 4 ; i++ ) { char *savePtr ; char const *tok = strtok_r( next, "\t", &savePtr ); if( tok ) { parts[i] = tok ; next = 0 ; } else break; } if( 4 == i ) { char const *cmd = parts[0].c_str(); char const *approval = 0 ; char const *msgs = 0 ; if( 0 == strcmp( "enter", cmd ) ) { approval = approved ; msgs = enterMsgs ; } else if( 0 == strcmp( "exit", cmd ) ) { approval = approved ; msgs = exitMsgs ; } else if( 0 == strcmp( "retrieve", cmd ) ) { approval = report ; msgs = reportMsgs ; } else fprintf( stderr, "unknown barcode cmd %s\n", cmd ); if( 0 != approval ) { std::string responseString ; responseString = parts[1]; responseString += approval ; responseString += msgs ; responseString += '\r' ; write( fd, responseString.c_str(), responseString.size() ); } else fprintf( stderr, usage ); } else fprintf( stderr, usage ); } static void unconfirmedAcknowledge( char const *bc, sockaddr_in const &from ) { printf( "unconfirmed ack %s\n", bc ); } static void process( int fd ) { std::string curCmd ; while( 1 ) { char inBuf[256]; int numRead = read( fd, inBuf, sizeof( inBuf ) - 1 ); if( 0 < numRead ) { inBuf[numRead] = '\0' ; for( int i = 0 ; i < numRead ; i++ ) { char const c = inBuf[i]; if( ( '\r' == c ) || ( '\n' == c ) ) { if( 0 < curCmd.size() ) { processCmd( curCmd, fd ); curCmd = "" ; } } else curCmd += c ; } // parse for complete lines } else break; // eof } } int tcpFd = -1 ; static void closeHandle( void ) { printf( "closing TCP socket\n" ); fflush( stdout ); if( 0 <= tcpFd ) close( tcpFd ); printf( "done closing TCP socket\n" ); fflush( stdout ); } static struct sigaction sa; static void closeOnSignal( int sig ) { printf( "signal %d\n", sig ); closeHandle(); } int main( int argc, char const *const argv[] ) { if( 3 == argc ) { atexit( closeHandle ); tcpFd = socket( AF_INET, SOCK_STREAM, 0 ); if( 0 <= tcpFd ) { // Initialize the sa structure sa.sa_handler = closeOnSignal ; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; // Set up the signal handler sigaction(SIGHUP, &sa, NULL); sigaction(SIGABRT, &sa, NULL); sigaction(SIGSEGV, &sa, NULL); sigaction(SIGKILL, &sa, NULL); int doit = 1 ; int result = setsockopt( tcpFd, SOL_SOCKET, SO_REUSEADDR, &doit, sizeof( doit ) ); if( 0 != result ) fprintf( stderr, "SO_REUSEADDR:%d:%m\n", result ); struct linger linger; /* allow a lingering, graceful close; */ linger.l_onoff = 0 ; linger.l_linger = 0 ; result = setsockopt( tcpFd, SOL_SOCKET, SO_LINGER, &linger, sizeof( linger ) ); if( 0 != result ) fprintf( stderr, "SO_REUSEADDR:%d:%m\n", result ); fcntl( tcpFd, F_SETFD, FD_CLOEXEC ); sockaddr_in myAddress ; memset( &myAddress, 0, sizeof( myAddress ) ); myAddress.sin_family = AF_INET; myAddress.sin_addr.s_addr = 0 ; // local myAddress.sin_port = htons( (unsigned short)strtoul( argv[2], 0, 0 ) ); if( 0 == bind( tcpFd, (struct sockaddr *) &myAddress, sizeof( myAddress ) ) ) { while( true ) { if( 0 == listen( tcpFd, 20 ) ) { struct sockaddr_in clientAddr ; socklen_t sockAddrSize = sizeof( clientAddr ); int newFd = ::accept( tcpFd, (struct sockaddr *)&clientAddr, &sockAddrSize ); if( 0 <= newFd ) { doit = 1 ; fcntl( newFd, F_SETFD, FD_CLOEXEC ); process( newFd ); close( newFd ); } else { fprintf( stderr, "accept:%m\n" ); break; } } else { fprintf( stderr, "listen:%m\n" ); break; } } } else fprintf( stderr, ":bind %s:%m\n", argv[2] ); } else fprintf( stderr, ":socket:%m\n" ); } else fprintf( stderr, "Usage : bc hostIP port#\n" ); return 0 ; }
[ "ericn", "ericn@ericsony.(none)" ]
[ [ [ 1, 51 ], [ 53, 280 ] ], [ [ 52, 52 ] ] ]
2db5e73f44a86b3d1cee855c18ad83eafc9f4b9d
6dac9369d44799e368d866638433fbd17873dcf7
/src/branches/01032005/include/mesh/Overlay.h
ef845ae46743b5d210d76f5f6a3c0a1f5fa4069a
[]
no_license
christhomas/fusionengine
286b33f2c6a7df785398ffbe7eea1c367e512b8d
95422685027bb19986ba64c612049faa5899690e
refs/heads/master
2020-04-05T22:52:07.491706
2006-10-24T11:21:28
2006-10-24T11:21:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,500
h
#ifndef _OVERLAY_H_ #define _OVERLAY_H_ #include <mesh/Mesh.h> class Rect; // Overlay stretch types #define STRETCH_TOP 2 // stretches an overlay upwards #define STRETCH_BOTTOM 4 // stretches an overlay downwards #define STRETCH_LEFT 8 // stretches an overlay to the left #define STRETCH_RIGHT 16 // stretches an overlay to the right #define STRETCH_CENTRE 32 // stretches an overlay in all directions /** @ingroup Mesh_Graphics_Group * @brief Derived Mesh class which serves as a base class for all Overlay objects */ class Overlay: public Mesh{ protected: /** @var std::vector<Vector2f *> m_texcoords * @brief An array of Texture coordinate arrays * * To allow the overlay to have animations you hold * multiple sets of texture coordinates, to update * the animation of the overlay, set the mesh's * texture coordinate pointer to another set of coordinates * * Think of animation frames contained within one image, each * animation frame == one set of texture coordinates(one rectangle in the image). * To change animation frame, simply set the mesh's texture coordinates to * the frame of animation requested */ std::vector<Vertex2f *> m_texcoords; public: Overlay (); virtual ~Overlay (); virtual void AddFrame (Rect *tr=NULL); virtual void SetFrame (unsigned int frameid); virtual void SetTexture (ITexture *texture); virtual void Stretch (int Direction, float amt); }; #endif // #ifndef _OVERLAY_H_
[ "chris_a_thomas@1bf15c89-c11e-0410-aefd-b6ca7aeaabe7" ]
[ [ [ 1, 43 ] ] ]
cd2d77381c9105e0b20938d7505dea1e902bc340
94ba1891ad689a7ef0c10d327111cc07f99ed20b
/TtHideTools/MaskListBox.cpp
0360f4d5418af7b55d8a6333160719477399ee68
[]
no_license
tetu-dc5/TTHideTools
0ca93e078c4009f61ecaf8edce6cc8f8266ebd0f
9b3d36d2d489a5752dae326918068ab1f610d48e
refs/heads/master
2020-03-30T01:10:03.073950
2010-05-11T14:18:28
2010-05-11T14:18:28
null
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
3,372
cpp
// MaskListBox.cpp : 実装ファイル // #include "stdafx.h" #include "TtHideTools.h" #include "MaskListBox.h" // CMaskListBox IMPLEMENT_DYNAMIC(CMaskListBox, CListBox) CMaskListBox::CMaskListBox() : m_mask(_T("")) , m_items(NULL) , m_Match(NULL) { } CMaskListBox::~CMaskListBox() { } BEGIN_MESSAGE_MAP(CMaskListBox, CListBox) END_MESSAGE_MAP() // CMaskListBox メッセージ ハンドラ void CMaskListBox::MeasureItem(LPMEASUREITEMSTRUCT /*lpMeasureItemStruct*/) { } void CMaskListBox::GetItemName(LPCTSTR src, CString& dst, bool lower) { dst = src; int pos = dst.Find(_T("//")); if(pos>=0){ dst = dst.Left(pos); } if(lower) dst.MakeLower(); } void CMaskListBox::GetItemComment(LPCTSTR src, CString& dst, bool lower) { dst = src; int pos = dst.Find(_T("//")); if(pos>=0){ dst = dst.Mid(pos+2); } if(lower) dst.MakeLower(); } void CMaskListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); pDC->SetBkMode(TRANSPARENT); COLORREF text_color; if(lpDrawItemStruct->itemState & ODS_SELECTED){ pDC->FillSolidRect(&lpDrawItemStruct->rcItem, GetSysColor(COLOR_HIGHLIGHT)); text_color=GetSysColor(COLOR_HIGHLIGHTTEXT); } else{ pDC->FillSolidRect(&lpDrawItemStruct->rcItem, GetSysColor(COLOR_WINDOW)); text_color=GetSysColor(COLOR_WINDOWTEXT); } pDC->SetTextColor(text_color); CString name; int no = GetItemData(lpDrawItemStruct->itemID) + 1; GetItemName(m_items->GetAt(lpDrawItemStruct->itemData), name, true); int len = 0; int pos = 0; pos = m_Match->Find((LPCTSTR)name,(LPCTSTR)m_mask,len); int rlen = name.GetLength() - (pos+len); int x = lpDrawItemStruct->rcItem.left+4; int y = lpDrawItemStruct->rcItem.top+2; CString tmp; CSize size; // オリジナルの名前に戻す GetItemName(m_items->GetAt(lpDrawItemStruct->itemData), name, false); // 番号描画 tmp.Format("%d", no); size = pDC->GetOutputTextExtent(tmp); int num_x = size.cx; int count = m_items->GetCount(); if(count>1000){ size = pDC->GetOutputTextExtent(_T("0000"),4); } else if(count>100){ size = pDC->GetOutputTextExtent(_T("000"),3); } else{ size = pDC->GetOutputTextExtent(_T("00"),2); } int num_width = size.cx; if(no>=0){ pDC->SetTextColor(RGB(0xD0,0xD0,0xD0)); pDC->TextOut(x+(num_width-num_x),y,(LPCTSTR)tmp); pDC->SetTextColor(text_color); } size = pDC->GetOutputTextExtent(_T("0"),1); x+=num_width+size.cx; if(len && pos>=0){ // 強引にBOLDフォント作成 CFont* old; CFont dummy; dummy.CreatePointFont(140,_T("FixedSys"),pDC); old = pDC->SelectObject(&dummy); CFont bold; LOGFONT log; old->GetLogFont(&log); log.lfWeight=FW_BLACK; bold.CreateFontIndirect(&log); pDC->SelectObject(old); // 左側 if(pos!=0){ tmp = name.Left(pos); pDC->TextOut(x,y,(LPCTSTR)tmp); size = pDC->GetOutputTextExtent(tmp); x+=size.cx; } // 真ん中 { old = pDC->SelectObject(&bold); tmp = name.Mid(pos,len); pDC->TextOut(x,y,(LPCTSTR)tmp); size = pDC->GetOutputTextExtent(tmp); x+=size.cx; pDC->SelectObject(old); } // 右側 if(rlen){ tmp = name.Right(rlen); pDC->TextOut(x, y,(LPCTSTR)tmp); } } else{ pDC->TextOut(x,y,(LPCTSTR)name); } }
[ [ [ 1, 147 ] ] ]
d8af36a456192092a658d3727085e1cbad81207b
99b30621fc8449afbf11613bb3a8f805b8f567a9
/draw.cpp
410ac00adf4737007eeca610f97a11e548a34ad4
[]
no_license
earlyhacker/maze3dgame
93b7856245efc133b7d44c405d612a29565c9898
833d6a317e7a4c43a790bd06fda5bd6ea8f0cf49
refs/heads/master
2016-09-14T03:23:09.389982
2011-05-13T15:51:37
2011-05-13T15:51:37
56,211,067
0
0
null
null
null
null
UTF-8
C++
false
false
19,769
cpp
// This file is released under the terms of the GNU General Public License v3. // Copyright 2011 Danila Bespalov <[email protected]>, // Gleb Devlikamov <[email protected]> // // Contains rendering and video initialization code. #include "maze.h" void TheVideo::Draw() { ThePlayer& player = TheGame::Get()->player; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); //glColor3f(0.7, 0.5, 0.7); //glColor3f(0.7, 0.7, 0.7); GLfloat light_pos[] = { 0.0, 0.0, 0.0, 1.0 }; glLightfv(GL_LIGHT0, GL_POSITION, light_pos); glRotatef(player.yaw, 0, cos(player.pitch * M_PI/180), sin(player.pitch * M_PI/180)); glRotatef(player.pitch, 1, 0, 0); glTranslatef(-player.xpos, -player.ypos, -player.zpos); // TODO: move this out of here to TheSound and have it // called from another place. ALfloat orient_vec[] = { cos(player.yaw * M_PI/180), 0, -sin(player.yaw * M_PI/180), 0, 1, 0 }; alListenerfv(AL_ORIENTATION, orient_vec); // There is a great deal of difference between an eager man who wants to // read a book and a tired man who wants a book to read. // (c) Chesterton, Essays player.current_section->Draw(); if(player.current_section->links[0]) RunThrough(player.current_section->links[0]); if(player.current_section->links[1]) RunThrough(player.current_section->links[1]); if(player.current_section->links[3]) RunThrough(player.current_section->links[3]); if(player.current_section->links[2]) RunThrough(player.current_section, true); glPushMatrix(); glLoadIdentity(); glTranslatef(0.05, -0.12, -0.29); glRotatef(180, 0, 1, 0); glRotatef(6, -1, 0, 0); glRotatef(8, 0, 1, 0); glColor3f(0.4, 0.4, 0.46); flashlight.Render(); glPopMatrix(); /*glPushMatrix(); glLoadIdentity(); glTranslatef(0, 0.0, -15.3); glRotatef(player.yaw, 0, 1, 0); glRotatef(player.pitch, 1, 0, 0); rat.Render(); glPopMatrix();*/ glFlush(); SDL_GL_SwapBuffers(); } // Still can be improved but now it's at least of satisfactory quality. // Working quality, not coding quality or readability. void TheVideo::RunThrough(TubeSection* section, bool backwards) { TubeSection* sec = section; glPushMatrix(); if(!backwards) { glTranslatef(sec->trans.x, 0, sec->trans.z); glRotatef(sec->rot, 0, 1, 0); sec->Draw(); } else { glRotatef(-sec->rot, 0, 1, 0); glTranslatef(-sec->trans.x, 0, -sec->trans.z); sec->links[2]->Draw(); sec = sec->links[2]; } while(1) { if(sec->links[1] && sec->links[1] != section) { glPushMatrix(); glTranslatef(sec->links[1]->trans.x, 0, sec->links[1]->trans.z); glRotatef(sec->links[1]->rot, 0, 1, 0); sec->links[1]->Draw(); glPopMatrix(); } if(sec->links[3] && sec->links[3] != section) { glPushMatrix(); glTranslatef(sec->links[3]->trans.x, 0, sec->links[3]->trans.z); glRotatef(sec->links[3]->rot, 0, 1, 0); sec->links[3]->Draw(); glPopMatrix(); } if(!backwards) { if(sec->links[0]) { glTranslatef(sec->links[0]->trans.x, 0, sec->links[0]->trans.z); glRotatef(sec->links[0]->rot, 0, 1, 0); sec->links[0]->Draw(); sec = sec->links[0]; if(sec->type == TubeSection::FORK) { // I don't want another call to RunThrough() just for that glPushMatrix(); glTranslatef(sec->links[1]->trans.x, 0, sec->links[1]->trans.z); glRotatef(sec->links[1]->rot, 0, 1, 0); sec->links[1]->Draw(); glPopMatrix(); glPushMatrix(); glTranslatef(sec->links[3]->trans.x, 0, sec->links[3]->trans.z); glRotatef(sec->links[3]->rot, 0, 1, 0); sec->links[3]->Draw(); glPopMatrix(); } } else break; } else { if(sec->links[2]) { if(sec->links[2]->links[0] != sec) { glRotatef(-sec->rot, 0, 1, 0); glTranslatef(-sec->trans.x, 0, -sec->trans.z); sec->links[2]->Draw(); break; } glRotatef(-sec->rot, 0, 1, 0); glTranslatef(-sec->trans.x, 0, -sec->trans.z); sec->links[2]->Draw(); sec = sec->links[2]; } else break; } } glPopMatrix(); } // Draws a plank with the given width and height, level of detail and the number // of textures fitting vertically and horizontally. Origin is at the half-height // of the plank. At lod=1.0 you have 8 rectangles per one unit, at lod=1.5 you // have 12 and so on. static void draw_plank(float w, float h, int wtex, int htex, float lod=1.0) { float h_off = -h/2; lod *= 8; int hnum = (int)round(h * lod); int wnum = (int)round(w * lod); float dh = h / hnum; float dw = -w / wnum; glBegin(GL_QUADS); for(int i = 0; i < hnum; i++) for(int j = 0; j < wnum; j++) { glTexCoord2f(-wtex*j*dw/w, htex*i*dh/h); glVertex3f(0, h_off + i * dh, j * dw); glTexCoord2f(-wtex*(j+1)*dw/w, htex*i*dh/h); glVertex3f(0, h_off + i * dh, (j+1) * dw); glTexCoord2f(-wtex*(j+1)*dw/w, htex*(i+1)*dh/h); glVertex3f(0, h_off + (i+1) * dh, (j+1) * dw); glTexCoord2f(-wtex*j*dw/w, htex*(i+1)*dh/h); glVertex3f(0, h_off + (i+1) * dh, j * dw); } glEnd(); } void TheVideo::CreateLists() { flashlight.LoadOBJ("Data/flashlight.obj", 0.046); Uint32 started = SDL_GetTicks(); GLuint start_index = glGenLists(6); for(int i = 0; i < LIST_COUNT; i++) dlists[i] = start_index + i; float d, d2; // d stands for delta GLuint wall = GetTexture("wall.jpg"); //GLuint wall2 = GetTexture("wall2.jpg"); // Having walls and the like in separate display lists helps to minimize // memory use. // A wall glNewList(dlists[LIST_WALL], GL_COMPILE); glColor3f(0.7, 0.7, 0.7); glBindTexture(GL_TEXTURE_2D, wall); draw_plank(10, 5 - 2*crn_off, 20, 10); glEndList(); // A corner cut glNewList(dlists[LIST_CORNER], GL_COMPILE); glColor3f(0.7, 0.7, 0.7); glBindTexture(GL_TEXTURE_2D, wall); glPushMatrix(); glTranslatef(crn_off/2.0, crn_off/2.0, 0); glRotatef(45, 0, 0, -1); glNormal3f(1, 0, 0); draw_plank(10, sqrt(2*crn_off*crn_off), 40, 2); glPopMatrix(); glEndList(); // DUDE! The current normal is transformed by the modelview matrix // at the point of specifying a vertex. No. Freakin. Earlier. // Straight pass-thru glNewList(dlists[LIST_STRAIGHT_PASS], GL_COMPILE); glColor3f(0.7, 0.7, 0.7); glBindTexture(GL_TEXTURE_2D, wall); glNormal3f(1, 0, 0); glPushMatrix(); glTranslatef(-2.5, 2.5, 0); glCallList(dlists[LIST_WALL]); glNormal3f(-1, 0, 0); glTranslatef(5, 0, 0); glCallList(dlists[LIST_WALL]); glPopMatrix(); glPushMatrix(); glRotatef(90, 0, 0, 1); glNormal3f(1, 0, 0); glCallList(dlists[LIST_WALL]); glTranslatef(5, 0, 0); glNormal3f(-1, 0, 0); glCallList(dlists[LIST_WALL]); glPopMatrix(); glPushMatrix(); glTranslatef(-2.5, 5 - crn_off, 0); glCallList(dlists[LIST_CORNER]); glTranslatef(5, 0, 0); glScalef(-1, 1, 1); glCallList(dlists[LIST_CORNER]); glPopMatrix(); glPushMatrix(); glTranslatef(-2.5, crn_off, 0); glScalef(1, -1, 1); glCallList(dlists[LIST_CORNER]); glTranslatef(5, 0, 0); glScalef(-1, 1, 1); glCallList(dlists[LIST_CORNER]); glPopMatrix(); glEndList(); // A dead-end glNewList(dlists[LIST_DEAD_END], GL_COMPILE); glColor3f(0.7, 0.7, 0.7); glBindTexture(GL_TEXTURE_2D, wall); glCallList(dlists[LIST_STRAIGHT_PASS]); glPushMatrix(); glTranslatef(-2.5, 2.5, -10); glRotatef(-90, 0, 1, 0); glNormal3f(1, 0, 0); draw_plank(5, 5, 10, 10); glPopMatrix(); glEndList(); // A block used to build two-way passages glNewList(dlists[LIST_WALL_BRANCH], GL_COMPILE); glColor3f(0.7, 0.7, 0.7); glBindTexture(GL_TEXTURE_2D, wall); glNormal3f(1, 0, 0); draw_plank(2.5 - trn_off, 5 - 2*crn_off, 5, 10); glPushMatrix(); glTranslatef(0, 0, -2.5 + trn_off); glPushMatrix(); glTranslatef(-trn_off/2.0, -2.5 + crn_off, -trn_off/2.0); glRotatef(90, 1, 0, 0); glRotatef(45, 0, 0, -1); draw_plank(5 - 2*crn_off, sqrt(2*trn_off*trn_off), 20, 1); glPopMatrix(); // TODO: It should be a single block glBegin(GL_QUADS); d = (crn_off + trn_off) / 5; for(float i = 0; i < crn_off + trn_off; i += d) { glNormal3f(0, 1, 0); glTexCoord2f(0, 0); glVertex3f(crn_off - i, -2.5, -i); glTexCoord2f(1, 0); glVertex3f(crn_off, -2.5, -i); glTexCoord2f(1, 1); glVertex3f(crn_off, -2.5, -i - d); glTexCoord2f(0, 1); glVertex3f(crn_off - i -d, -2.5, -i - d); glNormal3f(0, -1, 0); glTexCoord2f(0, 0); glVertex3f(crn_off - i, 2.5, -i); glTexCoord2f(1, 0); glVertex3f(crn_off, 2.5, -i); glTexCoord2f(1, 1); glVertex3f(crn_off, 2.5, -i - d); glTexCoord2f(0, 1); glVertex3f(crn_off - i -d, 2.5, -i - d); } glEnd(); // Way to go, the light will be broken on those glBegin(GL_QUADS); glNormal3f(cos(-M_PI/4)*cos(M_PI/4), sin(-M_PI/4), -cos(-M_PI/4)*sin(M_PI/4)); glTexCoord2f(1, 1); glVertex3f(crn_off, 2.5, 0); glTexCoord2f(0, 1); glVertex3f(0, 2.5 - crn_off, 0); glTexCoord2f(0, 0); glVertex3f(-trn_off, 2.5 - crn_off, -trn_off); glTexCoord2f(1, 0); glVertex3f(-trn_off, 2.5, -trn_off - crn_off); glNormal3f(cos(M_PI/4)*cos(M_PI/4), sin(M_PI/4), -cos(M_PI/4)*sin(M_PI/4)); glTexCoord2f(1, 1); glVertex3f(crn_off, -2.5, 0); glTexCoord2f(0, 1); glVertex3f(0, -2.5 + crn_off, 0); glTexCoord2f(0, 0); glVertex3f(-trn_off, -2.5 + crn_off, -trn_off); glTexCoord2f(1, 0); glVertex3f(-trn_off, -2.5, -trn_off - crn_off); glEnd(); glPopMatrix(); glPushMatrix(); glTranslatef(crn_off/2.0, 2.5 - crn_off/2.0, 0); glRotatef(45, 0, 0, -1); glNormal3f(1, 0, 0); draw_plank(2.5 - trn_off, sqrt(2*crn_off*crn_off), 10, 2); glPopMatrix(); glPushMatrix(); glTranslatef(crn_off/2.0, -2.5 + crn_off/2.0, 0); glRotatef(-45, 0, 0, -1); draw_plank(2.5 - trn_off, sqrt(2*crn_off*crn_off), 10, 2); glPopMatrix(); glEndList(); // A passage with a left turn glNewList(dlists[LIST_LEFT_BRANCH], GL_COMPILE); glColor3f(0.7, 0.7, 0.7); glBindTexture(GL_TEXTURE_2D, wall); glPushMatrix(); glTranslatef(-2.5, 2.5, 0); glCallList(dlists[LIST_WALL_BRANCH]); glPushMatrix(); glTranslatef(0, 0, -10); glScalef(1, 1, -1); glCallList(dlists[LIST_WALL_BRANCH]); glPopMatrix(); glTranslatef(5, 0, 0); glNormal3f(-1, 0, 0); glCallList(dlists[LIST_WALL]); glPopMatrix(); glPushMatrix(); glRotatef(90, 0, 0, 1); glNormal3f(1, 0, 0); glCallList(dlists[LIST_WALL]); glTranslatef(5, 0, 0); glNormal3f(-1, 0, 0); glCallList(dlists[LIST_WALL]); glPopMatrix(); glPushMatrix(); glTranslatef(2.5, 5 - crn_off, 0); glScalef(-1, 1, 1); glNormal3f(0.7071, -0.7071, 0); glCallList(dlists[LIST_CORNER]); glTranslatef(0, -5 + 2*crn_off, 0); glScalef(1, -1, 1); glCallList(dlists[LIST_CORNER]); glPopMatrix(); glPushMatrix(); glTranslatef(-2.5 + crn_off/2 - trn_off/2, 0, -2.5 - crn_off); glRotatef(90, 0, 0, -1); glNormal3f(-1, 0, 0); draw_plank(5 - 2*crn_off, trn_off + crn_off, 20, 2); glTranslatef(-5, 0, 0); glNormal3f(1, 0, 0); draw_plank(5 - 2*crn_off, trn_off + crn_off, 20, 2); glPopMatrix(); glEndList(); glNewList(dlists[LIST_RIGHT_BRANCH], GL_COMPILE); glPushMatrix(); glScalef(-1, 1, 1); glCallList(dlists[LIST_LEFT_BRANCH]); glPopMatrix(); glEndList(); // Left turn // TODO: get rid of scaling glNewList(dlists[LIST_LEFT_TURN], GL_COMPILE); glColor3f(0.7, 0.7, 0.7); glBindTexture(GL_TEXTURE_2D, wall); glPushMatrix(); glTranslatef(-2.5, 2.5, 0); glCallList(dlists[LIST_WALL_BRANCH]); glTranslatef(5, 0, 0); glNormal3f(-1, 0, 0); glScalef(1, 1, 0.75); glCallList(dlists[LIST_WALL]); glTranslatef(-2.5, 2.5, 0); glRotatef(90, 0, 0, 1); glNormal3f(-1, 0, 0); glCallList(dlists[LIST_WALL]); glTranslatef(-5, 0, 0); glNormal3f(1, 0, 0); glCallList(dlists[LIST_WALL]); glPopMatrix(); glPushMatrix(); glTranslatef(2.5, 5 - crn_off, 0); glScalef(-1, 1, 0.75); glNormal3f(0.7071, -0.7071, 0); glCallList(dlists[LIST_CORNER]); glTranslatef(0, -5 + 2*crn_off, 0); glScalef(1, -1, 1); glCallList(dlists[LIST_CORNER]); glPopMatrix(); glPushMatrix(); glTranslatef(2.5, 2.5, -7.5); glRotatef(90, 0, 1, 0); glNormal3f(-1, 0, 0); draw_plank(5 + trn_off, 5, 10, 10); glPopMatrix(); glPushMatrix(); glTranslatef(-2.5 + crn_off/2 - trn_off/2, 0, -2.5 - crn_off); glRotatef(90, 0, 0, -1); glNormal3f(-1, 0, 0); draw_plank(5 - 2*crn_off, trn_off + crn_off, 20, 2); glTranslatef(-5, 0, 0); glNormal3f(1, 0, 0); draw_plank(5 - 2*crn_off, trn_off + crn_off, 20, 2); glPopMatrix(); glPushMatrix(); glTranslatef(-2.5 + crn_off, 2.5, -7.5); glBegin(GL_TRIANGLES); glNormal3f(1, 0, 0); glTexCoord2f(0, 0); glVertex3f(0, -2.5, 0); glTexCoord2f(1, 1); glVertex3f(0, -2.5 + crn_off, 0); glTexCoord2f(1, 0); glVertex3f(0, -2.5, crn_off); glTexCoord2f(0, 0); glVertex3f(0, 2.5, 0); glTexCoord2f(1, 1); glVertex3f(0, 2.5 - crn_off, 0); glTexCoord2f(1, 0); glVertex3f(0, 2.5, crn_off); glEnd(); glRotatef(90, 0, 1, 0); glTranslatef(0, -2.5, 0); glPushMatrix(); glTranslatef(-crn_off/2.0, crn_off/2.0, 0); glRotatef(45, 0, 0, -1); glNormal3f(-1, 0, 0); draw_plank(crn_off + trn_off, sqrt(2*crn_off*crn_off), 2, 2); glPopMatrix(); glPushMatrix(); glTranslatef(-crn_off/2.0, 5 - crn_off/2.0, 0); glRotatef(45, 0, 0, 1); draw_plank(crn_off + trn_off, sqrt(2*crn_off*crn_off), 2, 2); glPopMatrix(); glPopMatrix(); glPushMatrix(); glTranslatef(-2.5 - trn_off, 2.5, -2.5); glRotatef(90, 0, 1, 0); glNormal3f(1, 0, 0); draw_plank(2.5 - trn_off, 5 - 2*crn_off, 5, 10); glPushMatrix(); glTranslatef(5, 0, 0); glNormal3f(-1, 0, 0); draw_plank(2.5 - trn_off, 5 - 2*crn_off, 5, 10); glTranslatef(-2.5, -2.5, 0); glRotatef(90, 0, 0, 1); glNormal3f(1, 0, 0); draw_plank(2.5 - trn_off, 5 - 2*crn_off, 5, 10); glTranslatef(5, 0, 0); glNormal3f(-1, 0, 0); draw_plank(2.5 - trn_off, 5 - 2*crn_off, 5, 10); glPopMatrix(); glPushMatrix(); glTranslatef(crn_off/2.0, 2.5 - crn_off/2.0, 0); glRotatef(45, 0, 0, -1); glNormal3f(1, 0, 0); draw_plank(2.5 - trn_off, sqrt(2*crn_off*crn_off), 10, 2); glPopMatrix(); glPushMatrix(); glTranslatef(crn_off/2.0, -2.5 + crn_off/2.0, 0); glRotatef(45, 0, 0, 1); draw_plank(2.5 - trn_off, sqrt(2*crn_off*crn_off), 10, 2); glPopMatrix(); glTranslatef(5, 0, 0); glPushMatrix(); glTranslatef(-crn_off/2.0, 2.5 - crn_off/2.0, 0); glRotatef(45, 0, 0, 1); glNormal3f(-1, 0, 0); draw_plank(2.5 - trn_off, sqrt(2*crn_off*crn_off), 10, 2); glPopMatrix(); glPushMatrix(); glTranslatef(-crn_off/2.0, -2.5 + crn_off/2.0, 0); glRotatef(45, 0, 0, -1); draw_plank(2.5 - trn_off, sqrt(2*crn_off*crn_off), 10, 2); glPopMatrix(); glPopMatrix(); glEndList(); glNewList(dlists[LIST_RIGHT_TURN], GL_COMPILE); glPushMatrix(); glScalef(-1, 1, 1); glCallList(dlists[LIST_LEFT_TURN]); glPopMatrix(); glEndList(); glNewList(dlists[LIST_FORK], GL_COMPILE); glPushMatrix(); glTranslatef(5, 0, -2.5 - trn_off); glRotatef(90, 0, 1, 0); glCallList(dlists[LIST_LEFT_BRANCH]); glPopMatrix(); glEndList(); glNewList(dlists[LIST_START], GL_COMPILE); glPushMatrix(); glTranslatef(0, 0, -10); glScalef(1, 1, -1); glCallList(dlists[LIST_DEAD_END]); glPopMatrix(); glEndList(); cout << "Lists created, took " << SDL_GetTicks() - started << " ms.\n"; } void TheVideo::Init() { const MazeSettings& cfg = TheGame::Get()->GetSettings(); if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER| SDL_INIT_AUDIO) < 0) throw MazeException(string("SDL initialization failed")+SDL_GetError()); atexit(SDL_Quit); unsigned int flags = SDL_OPENGL | SDL_DOUBLEBUF; if(cfg.fullscreen) flags |= SDL_FULLSCREEN; SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); if(SDL_SetVideoMode(cfg.wnd_width, cfg.wnd_height, 32, flags) == NULL) throw MazeException(string("Could not set video mode") + SDL_GetError(), true); glViewport(0, 0, cfg.wnd_width, cfg.wnd_height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0, cfg.wnd_width / cfg.wnd_height, 0.1, 45.0); glMatrixMode(GL_MODELVIEW); glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); glEnable(GL_COLOR_MATERIAL); SDL_WM_SetCaption("Maze 3d version undefined","ex1"); //SDL_WM_SetIcon(SDL_LoadBMP("icon.bmp"), NULL); glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); glClearColor(0.0, 0.0, 0.0, 1.0); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); GLfloat no_ambient[] = { 0.07, 0.07, 0.07, 1 }; // well, almost glLightModelfv(GL_LIGHT_MODEL_AMBIENT, no_ambient); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0); glEnable(GL_FOG); glFogf(GL_FOG_DENSITY, 0.096); glDisable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_TEXTURE_2D); //glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); CreateLists(); start = maze_build(cfg.difficulty, cfg.difficulty); ThePlayer& player = TheGame::Get()->player; player.ypos = 2.5; player.zpos = -1.5; player.current_section = start; player.ChangeLight(3); } // Returns an OpenGL texture ID if it's already loaded or loads it otherwise. // Gets the name of the texture which is the name of a file in Data/tex/ folder. GLuint TheVideo::GetTexture(const string& name) { if(tex.count(name)) return tex[name]; GLuint tex_id; SDL_Surface* orig_img; SDL_Surface* tex_img; SDL_PixelFormat* fmt = new SDL_PixelFormat; // 32 bit BGRA fmt->BitsPerPixel = 32; fmt->BytesPerPixel = 4; fmt->Bmask = 0x000000ff; fmt->Gmask = 0x0000ff00; fmt->Rmask = 0x00ff0000; fmt->Amask = 0xff000000; fmt->palette = NULL; glGenTextures(1, &tex_id); glBindTexture(GL_TEXTURE_2D, tex_id); orig_img = IMG_Load((TheGame::Get()->data_path + "/tex/" + name).c_str()); if(orig_img == NULL) throw MazeException(string("Could not load texture: ") + name); tex_img = SDL_ConvertSurface(orig_img, fmt, SDL_SWSURFACE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); //gluBuild2DMipmaps(GL_TEXTURE_2D, 4, tex_img->w, tex_img->h, GL_BGRA, // GL_UNSIGNED_BYTE, tex_img->pixels); glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); glTexImage2D(GL_TEXTURE_2D, 0, 4, tex_img->w, tex_img->h, 0, GL_BGRA, GL_UNSIGNED_BYTE, tex_img->pixels); SDL_FreeSurface(orig_img); SDL_FreeSurface(tex_img); tex[name] = tex_id; return tex_id; } void FinalSection::Draw() { glCallList(list); glDisable(GL_LIGHTING); glEnable(GL_BLEND); glDisable(GL_TEXTURE_2D); glColor4f(0.2, 0.94, 0.2, 0.26); glBegin(GL_QUADS); glNormal3f(0, 0, 1); glVertex3f(-2.5, 5, -6); glVertex3f(-2.5, 0, -6); glVertex3f(2.5, 0, -6); glVertex3f(2.5, 5, -6); glEnd(); glEnable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); glDisable(GL_BLEND); } StartSection::StartSection(const TubeSection& sec) : TubeSection(sec) { paintover.push_back(PaintOverRect(0x0, -2.5, -brd_off, 5, brd_off)); } void StartSection::Draw() { glPushMatrix(); glNormal3f(1, 0, 0); glTranslatef(2.5, 2.5, 0); glRotatef(90, 0, 1, 0); glColor3f(0.7, 0.7, 0.7); draw_plank(5, 5, 10, 10); glPopMatrix(); glCallList(list); }
[ [ [ 1, 8 ], [ 10, 566 ], [ 568, 568 ], [ 570, 593 ], [ 597, 622 ], [ 624, 668 ], [ 670, 705 ] ], [ [ 9, 9 ], [ 567, 567 ], [ 569, 569 ], [ 594, 596 ], [ 623, 623 ], [ 669, 669 ] ] ]
e0c4db329ecbdb91a2adeb7b64303020d64a9025
b84a38aad619acf34c22ed6e6caa0f7b00ebfa0a
/Code/TootleGui/Qt/Tree.h
7f5b0815f85a2f32849dcfc43f4b62d71767c84c
[]
no_license
SoylentGraham/Tootle
4ae4e8352f3e778e3743e9167e9b59664d83b9cb
17002da0936a7af1f9b8d1699d6f3e41bab05137
refs/heads/master
2021-01-24T22:44:04.484538
2010-11-03T22:53:17
2010-11-03T22:53:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,074
h
/* * TTree.h * TootleGui * * Created by Graham Reeves on 28/01/2010. * Copyright 2010 __MyCompanyName__. All rights reserved. * */ #if !defined(TL_ENABLE_QT) #error Should only be built in QT only build #endif // TL_ENABLE_QT #pragma once #include "../TTree.h" #include "Window.h" #include <QTCore/QAbstractItemModel> #include <QTGui/QTreeView> namespace Qt { class Tree; class TreeDataModel; // data model for the tree } //---------------------------------------------------------- // overloaded data model class - do as little work as possible in this class and // put the majority of the functionality in wx::Tree, just so it keeps most of the code in one place // don't bother making anything in this class protected, it should only be used by the wx::Tree anyway //---------------------------------------------------------- class Qt::TreeDataModel : public QAbstractItemModel { Q_OBJECT public: TreeDataModel(const TArray<TRef>& Columns,Qt::Tree& Owner); Qt::Tree& GetOwner() { return *m_pOwner; } const Qt::Tree& GetOwner() const { return *m_pOwner; } const TArray<TRef>& GetColumns() const { return m_Columns; } // qt model virtuals virtual QModelIndex index(int row, int column,const QModelIndex &parent) const; virtual QModelIndex parent(const QModelIndex &child) const; virtual int rowCount(const QModelIndex &parent) const; virtual int columnCount(const QModelIndex &parent) const; virtual QVariant data(const QModelIndex &index, int role) const; virtual QVariant headerData(int section, Qt::Orientation orientation,int role) const; virtual Qt::ItemFlags flags(const QModelIndex &index) const; virtual bool setData(const QModelIndex &index, const QVariant &value, int role); bool OnItemAdding(TLGui::TTreeItem& Item,TLGui::TTreeItem* pParent); // added item bool OnItemAdded(TLGui::TTreeItem& Item); // added item bool OnItemRemoving(TLGui::TTreeItem& Item); bool OnItemRemoved(TLGui::TTreeItem& Item); bool OnItemMoving(TLGui::TTreeItem& OldParent,TLGui::TTreeItem& Item); bool OnItemMoved(TLGui::TTreeItem& OldParent,TLGui::TTreeItem& Item); bool OnItemChanged(TLGui::TTreeItem& Item,TRefRef Data); TPtr<TLGui::TTreeItem>& GetRootItem(); const TPtr<TLGui::TTreeItem>& GetRootItem() const; public: TLGui::TTreeItem* GetTreeItem(const QModelIndex& ModelIndex); const TLGui::TTreeItem* GetTreeItem(const QModelIndex& ModelIndex) const; QModelIndex GetModelIndex(const TLGui::TTreeItem& TreeItem,int Column=0); protected: THeapArray<TRef> m_Columns; // data-column -> binarydata-on-item lookup. column[N] = TreeItem.GetData(Ref) bool m_RootItemAdded; // we have to pretend the root item doesn't exist until it's added private: Qt::Tree* m_pOwner; // store owner for node access - never null }; //----------------------------------------------------------- // qt tree control handling, which is mostly a wrapper to the model //----------------------------------------------------------- class Qt::Tree : public QTreeView, public TLGui::TTree, public Qt::TWidgetWrapper, public Qt::TMenuHandler, public TLMessaging::TPublisher { Q_OBJECT friend class Qt::TreeDataModel; public: Tree(TRefRef ControlRef,TPtr<TLGui::TTreeItem>& pRootItem,const TArray<TRef>& Columns); virtual bool Initialise(TLGui::TWindow& Parent); // initialise - this is seperated from the constructor so we can use virtual functions virtual bool OnItemAdding(TPtr<TLGui::TTreeItem>& pItem,TLGui::TTreeItem* pParent); virtual bool OnItemAdded(TPtr<TLGui::TTreeItem>& pItem); virtual bool OnItemRemoving(TLGui::TTreeItem& Item); virtual bool OnItemRemoved(TLGui::TTreeItem& Item); virtual bool OnItemMoving(TPtr<TLGui::TTreeItem>& pOldParent,TPtr<TLGui::TTreeItem>& pItem); virtual bool OnItemMoved(TPtr<TLGui::TTreeItem>& pOldParent,TPtr<TLGui::TTreeItem>& pItem); virtual bool OnItemChanged(TLGui::TTreeItem& Item,TRefRef Data); protected: virtual QWidget& GetWidget() { return *this; } virtual TLMessaging::TPublisher& GetPublisher() { return *this; } virtual void BindAction(QAction& Action); virtual QMenu* AllocMenu(const TLAsset::TMenu& Menu); virtual TMenuHandler* GetMenuHandler() { return this; } virtual TRefRef GetPublisherRef() const { return GetRef(); } protected slots: virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected); void OnItemClicked(const QModelIndex& index); void OnAction() { TMenuHandler::Slot_OnAction(static_cast<QAction*>( sender() ) ); } private: TreeDataModel m_DataModel; // data model for the view control }; FORCEINLINE TPtr<TLGui::TTreeItem>& Qt::TreeDataModel::GetRootItem() { return GetOwner().GetRootItem(); } FORCEINLINE const TPtr<TLGui::TTreeItem>& Qt::TreeDataModel::GetRootItem() const { return GetOwner().GetRootItem(); }
[ [ [ 1, 127 ] ] ]
ce21bc4379f399103986bc30bb2a47f481a47f5a
3ec3b97044e4e6a87125470cfa7eef535f26e376
/cltatman-mountain_valley/code/Include/back/Frame.hpp
200494dc72ec3bf01e751101a3ae9a1cd9b18e07
[]
no_license
strategist922/TINS-Is-not-speedhack-2010
6d7a43ebb9ab3b24208b3a22cbcbb7452dae48af
718b9d037606f0dbd9eb6c0b0e021eeb38c011f9
refs/heads/master
2021-01-18T14:14:38.724957
2010-10-17T14:04:40
2010-10-17T14:04:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,121
hpp
#ifndef FRAME_HPP #define FRAME_HPP #include <string> #include <OpenLayer.hpp> /** @brief Defines a single frame. * * Defines a single graphic frame including positional information, scaling, * tinting, duration and opacity. */ class Frame { public: /** @brief Constructor. * * @param file The path to the image file. * @param time The duration of the frame, in system ticks. */ Frame( const std::string& imageFile = "load failed", double time = 1.0 ); /** @brief Sets the placement. * * Sets the position and rotation of the frame, relative to the containing * sprite. * * @param x X offset from sprite position. * @param y Y offset from sprite position. * @param rotation Rotation relative to sprite rotation. */ void setPlacement( double x, double y, double rotation = 0.0 ); /** @brief Sets the scale by factors. * * Sets the scale of the frame by an x and y factor. Values are clamped * to a 0 minimum. * * @param x Horizontal scaling factor. * @param y Vertical scaling factor. */ void setScale( double x, double y ); /** @brief Sets the scale by size. * * A convenience function to allow scaling to an arbitrary size. This * function calls setScaleByFactors, and so negative values will be clamped * to 0. This function also grabs a copy of the image from the ImageBank, * which may be relatively expensive. * * @param w The desired width of the image. * @param h The desired height of the image. */ void setSize( double w, double h ); /** @brief Sets the tinting of the frame. * * Sets the tinting of the frame based on four color components. Values * should be between 0 and 1 inclusive, and will be clamped to this range. * * @param r Red component. * @param g Green component. * @param b Blue component. * @param a Alpha component. */ void setTint( double r, double g, double b, double a ); /** @brief Sets the opacity. * * Sets the opacity with which the frame should be drawn, given a value * between 0 and 1 inclusive. * * @param value The desired opacity. */ void setOpacity( double value ); /** @brief Draws the frame. * * This draws the frame with appropriate position, rotation, tinting, * scaling and opacity. This should not be called directly under normal * circumstances. This function is used by the renderer. See the Sprite * class for appropriate drawing functions. */ void draw(); void load( std::ifstream& file ); void save( std::ofstream& file ); /** @brief The filepath of the image. */ std::string _imageFile; ol::Placement _placement; ol::Vec2D _scale; ol::Rgba _tint; double _z, _time, _opacity, _width, _height; }; #endif
[ [ [ 1, 112 ] ] ]
a7b00a3eeb88cfb76148c34aa8f7bc4641618707
119ba245bea18df8d27b84ee06e152b35c707da1
/unreal/branches/robots/qrgui/interpreters/robots/details/robotImplementations/nullRobotModelImplementation.h
74ca83aee1cb0d37e0ce983b989ee12480e2dcdc
[]
no_license
nfrey/qreal
05cd4f9b9d3193531eb68ff238d8a447babcb3d2
71641e6c5f8dc87eef9ec3a01cabfb9dd7b0e164
refs/heads/master
2020-04-06T06:43:41.910531
2011-05-30T19:30:09
2011-05-30T19:30:09
1,634,768
0
0
null
null
null
null
UTF-8
C++
false
false
1,972
h
#pragma once #include <QtCore/QTimer> #include "abstractRobotModelImplementation.h" #include "brickImplementations/nullBrickImplementation.h" #include "motorImplementations/nullMotorImplementation.h" #include "sensorImplementations/nullTouchSensorImplementation.h" #include "sensorImplementations/nullSonarSensorImplementation.h" #include "sensorImplementations/nullColorSensorImplementation.h" namespace qReal { namespace interpreters { namespace robots { namespace details { namespace robotImplementations { class NullRobotModelImplementation : public AbstractRobotModelImplementation { Q_OBJECT public: NullRobotModelImplementation(); virtual ~NullRobotModelImplementation() {}; virtual void init(); virtual void stopRobot(); virtual brickImplementations::NullBrickImplementation &brick(); virtual sensorImplementations::NullTouchSensorImplementation *touchSensor(inputPort::InputPortEnum const &port) const; virtual sensorImplementations::NullSonarSensorImplementation *sonarSensor(inputPort::InputPortEnum const &port) const; virtual sensorImplementations::NullColorSensorImplementation *colorSensor(inputPort::InputPortEnum const &port) const; virtual motorImplementations::NullMotorImplementation &motorA(); virtual motorImplementations::NullMotorImplementation &motorB(); virtual motorImplementations::NullMotorImplementation &motorC(); private slots: void timerTimeout(); private: QTimer mActiveWaitingTimer; brickImplementations::NullBrickImplementation mBrick; motorImplementations::NullMotorImplementation mMotorA; motorImplementations::NullMotorImplementation mMotorB; motorImplementations::NullMotorImplementation mMotorC; virtual void addTouchSensor(inputPort::InputPortEnum const &port); virtual void addSonarSensor(inputPort::InputPortEnum const &port); virtual void addColorSensor(inputPort::InputPortEnum const &port, lowLevelSensorType::SensorTypeEnum mode); }; } } } } }
[ [ [ 1, 52 ] ] ]
f84a9c35ffa419652ff48ef6a1f5be936fef5f75
dadf8e6f3c1adef539a5ad409ce09726886182a7
/airplay/ext/TinyOpenEngine.Net/h/toeNet.h
c112f00cf261726e4c203a33edabd45abb1b19d7
[]
no_license
sarthakpandit/toe
63f59ea09f2c1454c1270d55b3b4534feedc7ae3
196aa1e71e9f22f2ecfded1c3da141e7a75b5c2b
refs/heads/master
2021-01-10T04:04:45.575806
2011-06-09T12:56:05
2011-06-09T12:56:05
53,861,788
0
0
null
null
null
null
UTF-8
C++
false
false
279
h
#pragma once #include "toeScriptingSubsystem.h" namespace TinyOpenEngine { class CtoeNet { public: //Get scriptable class declaration static CtoeScriptableClassDeclaration* GetClassDescription(); static std::string DownloadString(const char* s); }; }
[ [ [ 1, 15 ] ] ]
b6b443ba50499d4d72aa7ec80eafa993b109b50c
6b3fa487428d3e2c66376572fd3c6dd3501b282c
/sapien190/trunk/source/Sandbox/Sapien/rpy/ExtOutAnalogue.h
b8a70d5a271a609d18b71f42a390e7638e674263
[]
no_license
kimbjerge/iirtsf10grp5
8626a10b23ee5cdde9944280c3cd06833e326adb
3cbdd2ded74369d2cd455f63691abc834edfb95c
refs/heads/master
2021-01-25T06:36:48.487881
2010-06-03T09:26:19
2010-06-03T09:26:19
32,920,746
0
0
null
null
null
null
UTF-8
C++
false
false
2,712
h
/********************************************************************* Rhapsody : 7.5 Login : KBE Component : DefaultComponent Configuration : DefaultConfig Model Element : ExtOutAnalogue //! Generated Date : Fri, 30, Apr 2010 File Path : DefaultComponent/DefaultConfig/ExtOutAnalogue.h *********************************************************************/ #ifndef ExtOutAnalogue_H #define ExtOutAnalogue_H //#[ ignore #ifdef _MSC_VER // disable Microsoft compiler warning (debug information truncated) #pragma warning(disable: 4786) #endif //#] //## auto_generated #include <oxf/oxf.h> //## auto_generated #include <string> //## auto_generated #include <algorithm> //## auto_generated #include "math.h" //## link itsSignal class Signal; //## package AbstractHW //## class ExtOutAnalogue class ExtOutAnalogue { //// Constructors and destructors //// public : //## auto_generated ExtOutAnalogue(); //## auto_generated ~ExtOutAnalogue(); //// Operations //// //## operation OutputSample(int) void OutputSample(int sample); //// Additional operations //// //## auto_generated Signal* getItsSignal() const; //## auto_generated void setItsSignal(Signal* p_Signal); protected : //## auto_generated void cleanUpRelations(); private : //## auto_generated int getResolution() const; //## auto_generated void setResolution(int p_resolution); //## auto_generated int getSampleRate() const; //## auto_generated void setSampleRate(int p_sampleRate); //// Attributes //// protected : int resolution; //## attribute resolution int sampleRate; //## attribute sampleRate //// Relations and components //// Signal* itsSignal; //## link itsSignal //// Framework operations //// public : //## auto_generated void __setItsSignal(Signal* p_Signal); //## auto_generated void _setItsSignal(Signal* p_Signal); //## auto_generated void _clearItsSignal(); //## operation ExtOutAnalogue(int) ExtOutAnalogue(int ch); private : //## auto_generated int getChannel() const; //## auto_generated void setChannel(int p_channel); protected : int channel; //## attribute channel }; #endif /********************************************************************* File Path : DefaultComponent/DefaultConfig/ExtOutAnalogue.h *********************************************************************/
[ "bjergekim@49e60964-1571-11df-9d2a-2365f6df44e6" ]
[ [ [ 1, 122 ] ] ]
4b5ba3f78f29ebf5d6849cb7caf01fccc8f7d49f
3e69b159d352a57a48bc483cb8ca802b49679d65
/tags/release-2005-12-22/pcbnew/pcbtexte.cpp
22311358342a7e104d2425c85d1c8b770d57ea1c
[]
no_license
BackupTheBerlios/kicad-svn
4b79bc0af39d6e5cb0f07556eb781a83e8a464b9
4c97bbde4b1b12ec5616a57c17298c77a9790398
refs/heads/master
2021-01-01T19:38:40.000652
2006-06-19T20:01:24
2006-06-19T20:01:24
40,799,911
0
0
null
null
null
null
UTF-8
C++
false
false
11,703
cpp
/**************************************************/ /* traitement des editions des textes sur modules */ /**************************************************/ #include "fctsys.h" #include "gr_basic.h" #include "common.h" #include "pcbnew.h" #include "protos.h" #define L_MIN_DESSIN 1 /* seuil de largeur des segments pour trace autre que filaire */ /* Routines Locales */ static void Move_Texte_Pcb(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) ; static void Exit_Texte_Pcb(WinEDA_DrawFrame * frame, wxDC *DC) ; /* Variables locales : */ static wxPoint old_pos; // position originelle du texte selecte enum id_TextPCB_properties { ID_ACCEPT_TEXTE_PCB_PROPERTIES = 1900, ID_CLOSE_TEXTE_PCB_PROPERTIES, ID_TEXTPCB_SELECT_LAYER }; /************************************/ /* class WinEDA_TextPCBPropertiesFrame */ /************************************/ class WinEDA_TextPCBPropertiesFrame: public wxDialog { private: WinEDA_PcbFrame * m_Parent; wxDC * m_DC; TEXTE_PCB * CurrentTextPCB; WinEDA_EnterText * m_Name; WinEDA_PositionCtrl * m_TxtPosCtrl; WinEDA_SizeCtrl * m_TxtSizeCtrl; WinEDA_ValueCtrl * m_TxtWidthCtlr; wxRadioBox * m_Orient; wxRadioBox * m_Mirror; wxComboBox * m_SelLayerBox; public: // Constructor and destructor WinEDA_TextPCBPropertiesFrame(WinEDA_PcbFrame *parent, TEXTE_PCB * TextPCB, wxDC * DC, const wxPoint & pos); ~WinEDA_TextPCBPropertiesFrame(void) { } private: void TextPCBPropertiesAccept(wxCommandEvent& event); void OnQuit(wxCommandEvent& event); DECLARE_EVENT_TABLE() }; BEGIN_EVENT_TABLE(WinEDA_TextPCBPropertiesFrame, wxDialog) EVT_BUTTON(ID_ACCEPT_TEXTE_PCB_PROPERTIES, WinEDA_TextPCBPropertiesFrame::TextPCBPropertiesAccept) EVT_BUTTON(ID_CLOSE_TEXTE_PCB_PROPERTIES, WinEDA_TextPCBPropertiesFrame::OnQuit) END_EVENT_TABLE() /********************************************************************/ void WinEDA_PcbFrame::InstallTextPCBOptionsFrame(TEXTE_PCB * TextPCB, wxDC * DC, const wxPoint & pos) /********************************************************************/ { DrawPanel->m_IgnoreMouseEvents = TRUE; WinEDA_TextPCBPropertiesFrame * frame = new WinEDA_TextPCBPropertiesFrame(this, TextPCB, DC, pos); frame->ShowModal(); frame->Destroy(); DrawPanel->m_IgnoreMouseEvents = FALSE; } /************************************************************************************/ WinEDA_TextPCBPropertiesFrame::WinEDA_TextPCBPropertiesFrame(WinEDA_PcbFrame *parent, TEXTE_PCB * TextPCB,wxDC * DC, const wxPoint & framepos): wxDialog(parent, -1, _("TextPCB properties"), framepos, wxSize(390, 340), DIALOG_STYLE) /************************************************************************************/ { wxPoint pos; int xx, yy; wxButton * Button; #define VPOS0 10 m_Parent = parent; SetFont(*g_DialogFont); m_DC = DC; Centre(); CurrentTextPCB = TextPCB; /* Creation des boutons de commande */ pos.x = 270; pos.y = VPOS0; Button = new wxButton(this, ID_ACCEPT_TEXTE_PCB_PROPERTIES, _("Ok"), pos); Button->SetForegroundColour(*wxRED); pos.y += Button->GetDefaultSize().y + 10; Button = new wxButton(this, ID_CLOSE_TEXTE_PCB_PROPERTIES, _("Cancel"), pos); Button->SetForegroundColour(*wxBLUE); pos.x = 5; pos.y = VPOS0 + 10; m_Name = new WinEDA_EnterText(this, _("Text:"), TextPCB->m_Text, pos, wxSize( 200, -1) ); pos.y += 25 + m_Name->GetDimension().y; m_TxtSizeCtrl = new WinEDA_SizeCtrl(this, _("Size"), TextPCB->m_Size, UnitMetric, pos, m_Parent->m_InternalUnits); pos.x += 15 + m_TxtSizeCtrl->GetDimension().x; m_TxtWidthCtlr = new WinEDA_ValueCtrl(this, _("Width"), TextPCB->m_Width, UnitMetric, pos, m_Parent->m_InternalUnits); pos.x = 5; pos.y += 25 + m_TxtSizeCtrl->GetDimension().y; m_TxtPosCtrl = new WinEDA_PositionCtrl(this, _("Position"), TextPCB->m_Pos, UnitMetric, pos, m_Parent->m_InternalUnits); pos.x += 15 + m_TxtPosCtrl->GetDimension().x; m_SelLayerBox = new wxComboBox(this, ID_TEXTPCB_SELECT_LAYER, wxEmptyString, pos, wxDefaultSize, 0, NULL, wxCB_READONLY); int ii; for ( ii = 0; ii < 29 ; ii ++ ) { m_SelLayerBox->Append(ReturnPcbLayerName(ii)); } m_SelLayerBox->SetSelection( TextPCB->m_Layer ); pos.x = 270; pos.y = VPOS0 + 80; wxString orient_msg[4] = { wxT("0"), wxT("90"), wxT("180"), wxT("-90") }; m_Orient = new wxRadioBox(this, -1, _("Orientation"), pos, wxSize(-1,-1), 4, orient_msg, 1, wxRA_SPECIFY_COLS ); switch(TextPCB->m_Orient ) { default: m_Orient->SetSelection(0); break; case 900: m_Orient->SetSelection(1); break; case 1800: m_Orient->SetSelection(2); break; case 2700: m_Orient->SetSelection(3); break; } m_Orient->GetSize(&xx, &yy); pos.y += 15 + yy; wxString display_msg[2] = { _("Normal"), _("Mirror") }; m_Mirror = new wxRadioBox(this, -1, _("Display"), pos, wxSize(-1,-1), 2, display_msg, 1, wxRA_SPECIFY_COLS ); if ( ! TextPCB->m_Miroir ) m_Mirror->SetSelection(1);; } /**********************************************************************/ void WinEDA_TextPCBPropertiesFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) /**********************************************************************/ { // true is to force the frame to close Close(true); } /**************************************************************************************/ void WinEDA_TextPCBPropertiesFrame::TextPCBPropertiesAccept(wxCommandEvent& event) /**************************************************************************************/ { if ( m_DC ) // Effacement ancien texte { CurrentTextPCB->Draw(m_Parent->DrawPanel, m_DC, wxPoint(0, 0), GR_XOR); } if ( ! m_Name->GetData().IsEmpty() ) { CurrentTextPCB->m_Text = m_Name->GetData(); } CurrentTextPCB->m_Pos = m_TxtPosCtrl->GetCoord(); CurrentTextPCB->m_Size = m_TxtSizeCtrl->GetCoord(); CurrentTextPCB->m_Width = m_TxtWidthCtlr->GetValue(); CurrentTextPCB->m_Miroir = (m_Mirror->GetSelection() == 0) ? 1 : 0; CurrentTextPCB->m_Orient = m_Orient->GetSelection() * 900; CurrentTextPCB->m_Layer = m_SelLayerBox->GetSelection(); CurrentTextPCB->CreateDrawData(); if ( m_DC ) // Affichage nouveau texte { /* Redessin du Texte */ CurrentTextPCB->Draw(m_Parent->DrawPanel, m_DC, wxPoint(0, 0), GR_OR); } m_Parent->m_CurrentScreen->SetModify(); Close(TRUE); } /******************************************************/ void Exit_Texte_Pcb(WinEDA_DrawFrame * frame, wxDC * DC) /*******************************************************/ /* Routine de sortie du menu edit texte Pcb Si un texte est selectionne, ses coord initiales sont regenerees */ { TEXTE_PCB * TextePcb; TextePcb = (TEXTE_PCB *) frame->m_CurrentScreen->m_CurrentItem; if ( TextePcb ) { TextePcb->Draw(frame->DrawPanel, DC, wxPoint(0, 0), GR_XOR) ; TextePcb->m_Pos = old_pos; TextePcb->Draw(frame->DrawPanel, DC, wxPoint(0, 0), GR_OR) ; TextePcb->m_Flags = 0; } frame->m_CurrentScreen->ManageCurseur = NULL; frame->m_CurrentScreen->ForceCloseManageCurseur = NULL; frame->m_CurrentScreen->m_CurrentItem = NULL; } /*********************************************************************/ void WinEDA_PcbFrame::Place_Texte_Pcb(TEXTE_PCB * TextePcb, wxDC * DC) /*********************************************************************/ /* Routine de placement du texte en cours de deplacement */ { if( TextePcb == NULL ) return; TextePcb->CreateDrawData(); TextePcb->Draw(DrawPanel, DC, wxPoint(0, 0), GR_OR) ; m_CurrentScreen->ManageCurseur = NULL; m_CurrentScreen->ForceCloseManageCurseur = NULL; m_CurrentScreen->m_CurrentItem = NULL; m_CurrentScreen->SetModify(); TextePcb->m_Flags = 0; } /***********************************************************************/ void WinEDA_PcbFrame::StartMoveTextePcb(TEXTE_PCB * TextePcb, wxDC * DC) /***********************************************************************/ /* Routine de preparation du deplacement d'un texte */ { if( TextePcb == NULL ) return; old_pos = TextePcb->m_Pos; TextePcb->Draw(DrawPanel, DC, wxPoint(0, 0), GR_XOR) ; TextePcb->m_Flags |= IS_MOVED; Affiche_Infos_PCB_Texte(this, TextePcb); m_CurrentScreen->ManageCurseur = Move_Texte_Pcb; m_CurrentScreen->ForceCloseManageCurseur = Exit_Texte_Pcb; m_CurrentScreen->m_CurrentItem = TextePcb; m_CurrentScreen->ManageCurseur( DrawPanel, DC, FALSE); } /*************************************************************************/ static void Move_Texte_Pcb(WinEDA_DrawPanel * panel, wxDC *DC, bool erase ) /*************************************************************************/ /* Routine deplacant le texte PCB suivant le curseur de la souris */ { TEXTE_PCB * TextePcb = (TEXTE_PCB *) panel->m_Parent->m_CurrentScreen->m_CurrentItem; if (TextePcb == NULL ) return ; /* effacement du texte : */ if ( erase ) TextePcb->Draw(panel, DC, wxPoint(0, 0), GR_XOR) ; TextePcb->m_Pos = panel->m_Parent->m_CurrentScreen->m_Curseur; /* Redessin du Texte */ TextePcb->Draw(panel, DC, wxPoint(0, 0), GR_XOR) ; } /**********************************************************************/ void WinEDA_PcbFrame::Delete_Texte_Pcb(TEXTE_PCB * TextePcb, wxDC * DC) /**********************************************************************/ { if( TextePcb == NULL ) return; TextePcb->Draw(DrawPanel, DC, wxPoint(0, 0), GR_XOR); /* Suppression du texte en Memoire*/ DeleteStructure(TextePcb); m_CurrentScreen->ManageCurseur = NULL; m_CurrentScreen->ForceCloseManageCurseur = NULL; m_CurrentScreen->m_CurrentItem = NULL; } /*******************************************************/ TEXTE_PCB * WinEDA_PcbFrame::Create_Texte_Pcb( wxDC * DC) /*******************************************************/ { TEXTE_PCB * TextePcb; TextePcb = new TEXTE_PCB(m_Pcb); /* Chainage de la nouvelle structure en debut de liste */ TextePcb->Pnext = m_Pcb->m_Drawings; TextePcb->Pback = (EDA_BaseStruct * )m_Pcb; if( m_Pcb->m_Drawings) m_Pcb->m_Drawings->Pback = (EDA_BaseStruct*) TextePcb; m_Pcb->m_Drawings = (EDA_BaseStruct*) TextePcb; /* Mise a jour des caracteristiques */ TextePcb->m_Flags = IS_NEW; TextePcb->m_Layer = GetScreen()->m_Active_Layer; TextePcb->m_Miroir = 1; if(TextePcb->m_Layer == CUIVRE_N) TextePcb->m_Miroir = 0; TextePcb->m_Size = g_DesignSettings.m_PcbTextSize; TextePcb->m_Pos = m_CurrentScreen->m_Curseur; TextePcb->m_Width = g_DesignSettings.m_PcbTextWidth; InstallTextPCBOptionsFrame(TextePcb, DC, TextePcb->m_Pos); if ( TextePcb->m_Text.IsEmpty() ) { DeleteStructure(TextePcb); TextePcb = NULL; } else StartMoveTextePcb(TextePcb, DC); return TextePcb; } /***********************************************************************/ void WinEDA_PcbFrame::Rotate_Texte_Pcb(TEXTE_PCB * TextePcb, wxDC * DC) /***********************************************************************/ { int angle = 900; int drawmode = GR_XOR; if( TextePcb == NULL ) return; /* effacement du texte : */ TextePcb->Draw(DrawPanel, DC, wxPoint(0, 0), GR_XOR) ; TextePcb->m_Orient += angle; if(TextePcb->m_Orient >= 3600) TextePcb->m_Orient -= 3600 ; if(TextePcb->m_Orient < 0) TextePcb->m_Orient += 3600 ; TextePcb->CreateDrawData(); /* Redessin du Texte */ TextePcb->Draw(DrawPanel, DC, wxPoint(0, 0), drawmode); Affiche_Infos_PCB_Texte(this, TextePcb); m_CurrentScreen->SetModify(); }
[ "bokeoa@244deca0-f506-0410-ab94-f4f3571dea26" ]
[ [ [ 1, 382 ] ] ]
693995a1247d8cfaf9489a8d7a763bc9bc106e4a
b2c66c8de198d9915dfc63b8c60cb82e57643a6b
/UnitTest/trunk/ScoreCalculatorTest.cpp
529b3669e6a375e43a339e79a2c96ae557402eb6
[]
no_license
feleio/words-with-friends-exhaustive-cheater
88d6d401c28ef7bb82099c0cd9d77459828b89ca
bc198ee2677be02fc935fb8bb8e74b580f0540df
refs/heads/master
2021-01-02T08:54:47.975272
2011-05-10T14:51:06
2011-05-10T14:51:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,269
cpp
#include "TestHarness.h" #include "ScoreCalculator.h" #include "Board.h" #include "Dictionary.h" #include "TrieDictionary.h" #include <fstream> #include <iostream> #include <string> #include <time.h> #include <vector> namespace { const std::string TEST_DATA = "../TestData/ScoreCalculatorTest/"; bool LoadTestCase( std::ifstream& file, Board& board, bool& expRtn, int& expScore ) { expScore = 0; std::vector<PlacedTileInfo> placedTiles; if( board.ParseFileBoard( file, placedTiles ) ) { for( std::vector<PlacedTileInfo>::iterator itr = placedTiles.begin(); itr != placedTiles.end(); ++itr ) { board.Place( itr->m_row, itr->m_col, itr->m_placedChar ); } std::string str; if( getline( file, str, '\n' ) ) { if( str == "true") expRtn = true; else if( str == "false" ) expRtn = false; } file >> expScore; return true; } return false; } } TEST( ScoreCalculator, TestDriven ) { std::ifstream file ( TEST_DATA + "isStringValid.txt", std::ios_base::in ); if( !file ) return; Board board; TrieDictionary dict( TEST_DATA + "../RealDictionary/enable1.txt" ); ScoreCalculator subject( &board, &dict ); int numTestCase = 0; clock_t start, finish; start = clock(); while( 1 ) { board.Reset(); int score = 0; bool expRtn = false; int expScore = 0; if( LoadTestCase( file, board, expRtn, expScore ) ) { ++numTestCase; //board.printToStream( std::cout, 0,0 ); //std::cout<<expRtn<<std::endl; //std::cout<<expScore<<std::endl; CHECK( expRtn == subject.Calculate( score ) ); if( expRtn ) CHECK( score == expScore ); } else break; } finish = clock(); std::cout << double(finish - start)/CLOCKS_PER_SEC << "ms taken for running " << numTestCase << " cases." << std::endl; }
[ "[email protected]@2165158a-c2d0-8582-d542-857db5896f79" ]
[ [ [ 1, 85 ] ] ]