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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0837a9420563708d3ba8d186d555a05d8ff1d69e | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/mpl/test/range_c.cpp | 10cb58802a387a4326391a97cca3700227ad7a93 | [
"BSL-1.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | willrebuild/flyffsf | e5911fb412221e00a20a6867fd00c55afca593c7 | d38cc11790480d617b38bb5fc50729d676aef80d | refs/heads/master | 2021-01-19T20:27:35.200154 | 2011-02-10T12:34:43 | 2011-02-10T12:34:43 | 32,710,780 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,019 | cpp |
// Copyright Aleksey Gurtovoy 2000-2004
//
// Distributed under the Boost Software License,Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/mpl for documentation.
// $Source: /cvsroot/boost/boost/libs/mpl/test/range_c.cpp,v $
// $Date: 2004/11/28 03:35:12 $
// $Revision: 1.5 $
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/advance.hpp>
#include <boost/mpl/distance.hpp>
#include <boost/mpl/empty.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/back.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef range_c<int,0,0> range0;
typedef range_c<int,0,1> range1;
typedef range_c<int,0,10> range10;
MPL_ASSERT_RELATION( size<range0>::value, ==, 0 );
MPL_ASSERT_RELATION( size<range1>::value, ==, 1 );
MPL_ASSERT_RELATION( size<range10>::value, ==, 10 );
MPL_ASSERT(( empty<range0> ));
MPL_ASSERT_NOT(( empty<range1> ));
MPL_ASSERT_NOT(( empty<range10> ));
MPL_ASSERT(( is_same< begin<range0>::type, end<range0>::type > ));
MPL_ASSERT_NOT(( is_same<begin<range1>::type, end<range1>::type > ));
MPL_ASSERT_NOT(( is_same<begin<range10>::type, end<range10>::type > ));
MPL_ASSERT_RELATION( front<range1>::type::value, ==, 0 );
MPL_ASSERT_RELATION( back<range1>::type::value, ==, 0 );
MPL_ASSERT_RELATION( front<range10>::type::value, ==, 0 );
MPL_ASSERT_RELATION( back<range10>::type::value, ==, 9 );
}
MPL_TEST_CASE()
{
typedef range_c<unsigned char,0,10> r;
typedef begin<r>::type first;
typedef end<r>::type last;
MPL_ASSERT(( is_same< advance_c<first,10>::type, last > ));
MPL_ASSERT(( is_same< advance_c<last,-10>::type, first > ));
MPL_ASSERT_RELATION( ( mpl::distance<first,last>::value ), ==, 10 );
typedef advance_c<first,5>::type iter;
MPL_ASSERT_RELATION( deref<iter>::type::value, ==, 5 );
}
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
] | [
[
[
1,
60
]
]
] |
cc982823d345995255c2435c68283e9a8c77616c | b505ef7eb1a6c58ebcb73267eaa1bad60efb1cb2 | /source/graphics/core/win32/opengl/deviceopengl.h | ffe496099b46957afe87e09effeda030a97fba37 | [] | 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 | 3,324 | h | /*!
@file
@brief レンダリングドライバ OpenGL Ver.
*/
#ifndef maid2_graphics_core_win32_opengl_deviceopengl_h
#define maid2_graphics_core_win32_opengl_deviceopengl_h
#include"../../../../config/define.h"
#include"../../../../config/typedef.h"
#include"../../idevice.h"
#include"../../../../framework/win32/window.h"
#include"../../../../framework/win32/dllwrapper.h"
#include"../../../../auxiliary/thread/win32/threadmutex.h"
#include"../../../../auxiliary/functionresult.h"
#include"common.h"
#include<vector>
namespace Maid { namespace Graphics {
class DeviceOpenGL
: public IDevice
{
public:
DeviceOpenGL( Window& Windw );
void Initialize();
void Finalize();
virtual void SetFullScreenState( bool IsFullScreen );
virtual bool IsFullScreen() const;
virtual void SerchSwapChainSurfaceFormat( std::vector<PIXELFORMAT>& mode ) const;
virtual void SetSwapChainFormat( const SWAPCHAINFORMAT& mode );
virtual void SerchEnableFormat( ENABLEFORMAT& caps ) const;
virtual float GetTexelMapValue() const;
virtual void Present();
virtual SWAPCHAINFORMAT GetSwapChainFormat() const;
virtual SIZE2DI GetDisplayAspect() const;
virtual SPINPUTLAYOUT CreateInputLayout( const INPUT_ELEMENT* Element, int Count, const void* pShaderBytecodeWithInputSignature, size_t BytecodeLength );
virtual SPBUFFER CreateBuffer( const CREATEBUFFERPARAM& param, const SUBRESOURCE* data );
virtual SPTEXTURE2D CreateTexture2D( const CREATERETEXTURE2DPARAM& param, const SUBRESOURCE* data );
virtual SPRENDERTARGET CreateRenderTarget( const SPRESOURCE& resource, const CREATERENDERTARGETPARAM* param );
virtual SPDEPTHSTENCIL CreateDepthStencil( const SPRESOURCE& resource, const CREATEDEPTHSTENCILPARAM* param );
virtual SPMATERIAL CreateMaterial( const SPRESOURCE& resource, const CREATEMATERIALPARAM* param );
virtual SPVERTEXSHADER CreateVertexShader( const void* pData, size_t Length );
virtual SPPIXELSHADER CreatePixelShader( const void* pData, size_t Length );
virtual SPSAMPLERSTATE CreateSamplerState( const SAMPLERSTATEPARAM& Option );
virtual SPRASTERIZERSTATE CreateRasterizerState( const RASTERIZERSTATEPARAM& Option );
virtual SPDEPTHSTENCILSTATE CreateDepthStencilState( const DEPTHSTENCILSTATEPARAM& Option );
virtual SPBLENDSTATE CreateBlendState( const BLENDSTATEPARAM& Option );
virtual SPDRAWCOMMANDEXECUTE GetDrawCommandExecute()const;
virtual SPDRAWCOMMANDCAPTURE CreateDrawCommandCapture();
virtual SPRENDERTARGET GetCurrentRenderTarget()const;
virtual bool CompileShaderLanguage( const String& Source, CODETYPE type, std::vector<unt08>& Binary, String& ErrorMessage );
private:
void CreateDefaultVertexShader( int no, std::string& Binary );
void CreateDefaultPixelShader( int no, std::string& Binary );
void UpdateDisplayAspect();
private:
Window& m_Window;
OpenGL32DLL m_OpenGLDLL;
OpenGLExtension m_OpenGLExtension;
HDC m_hDC;
HGLRC m_hGLContext;
SIZE2DI m_DisplayAspect;
SPDRAWCOMMANDEXECUTE m_pDrawCommandExecute;
SWAPCHAINFORMAT m_SwapChainFormat;
};
}}
#endif
| [
"renji2000@471aaf9e-aa7b-11dd-9b86-41075523de00"
] | [
[
[
1,
96
]
]
] |
ed61a361220834829a0d3d78fefdd396ef08811c | 1e299bdc79bdc75fc5039f4c7498d58f246ed197 | /stdobj/PlatformInfo.h | 62b0d7df6a7e9f2af2fcc8542061d0cb522444e7 | [] | 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 | 2,774 | h | //--------------------------------------------------------------------------------
//
// Copyright (c) 1999 MarkCare Solutions
//
// Programming by Rich Schonthal
//
//--------------------------------------------------------------------------------
// PlatformInfo.h: interface for the CPlatformInfo class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_PLATFORMINFO_H__BDF13295_1838_11D3_87B1_00104B9E6286__INCLUDED_)
#define AFX_PLATFORMINFO_H__BDF13295_1838_11D3_87B1_00104B9E6286__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "result.h"
//--------------------------------------------------------------------------------
class CPlatformInfo : public OSVERSIONINFO, public CResult
{
private:
// -1 when not yet looked for
// 0 when not available (pre OS2R Win95)
// > 1 when available
static int m_bGetDiskFreeSpaceExFound;
static CDWordArray m_nP3SerialNumbers;
static UINT SerialNumberThread(void*);
public:
enum
{
VER_WIN31,
VER_WIN95,
VER_WIN98,
VER_WINNT4,
VER_WIN2000,
VER_WINNEWER
};
public:
CPlatformInfo();
virtual ~CPlatformInfo();
int GetVersion();
void GetVersion(CString&);
static void GetComputerName(CString&);
static void GetUserName(CString&);
static void GetSystemDirectory(CString&);
static void GetWindowsDirectory(CString&);
bool IsWin31();
bool IsWin95();
bool IsWin95OS2R();
bool IsWin98();
bool IsWinNT();
bool IsWin2000();
static void ExpandEnvironmentStrings(LPCTSTR, CString&);
static void ParseEnvironmentStrings(LPCTSTR, CStringArray&);
static void ParseEnvironmentStrings(const CString&, CStringArray&);
// file/dir utilities
static HANDLE GetDirHandle(LPCTSTR pPath, bool bLock = false);
static bool FileExists(LPCTSTR, bool bExcludeDir = false);
static void GetCurrentDirectory(CString&);
static bool SetCurrentDirectory(const CString&);
static DWORD GetDiskFreeSpace(LPCTSTR, ULARGE_INTEGER* = NULL);
static bool CreatePath(LPCTSTR);
static bool IsDirectory(LPCTSTR);
static bool GetLoadLibrarySearchPath(CStringArray&);
static bool GetProcessorSerialNumberOnCurrentThread(DWORD nId[3]);
static bool GetProcessorSerialNumber(DWORD nId[3], int nWhich);
static bool GetProcessorSerialNumber(CString&, int nWhich = 0);
static void GetProcessorSerialNumber(CString&, const DWORD nId[3]);
static CString GetTempPath();
static UINT GetTempFileName(LPCTSTR, LPCTSTR, UINT, CString&);
static CString GetTempFileName(LPCTSTR = NULL, LPCTSTR = "", UINT = 0);
};
#endif // !defined(AFX_PLATFORMINFO_H__BDF13295_1838_11D3_87B1_00104B9E6286__INCLUDED_)
| [
"[email protected]"
] | [
[
[
1,
92
]
]
] |
1b24fe8ea127513c7e231f585d3883e7247612a7 | b14d5833a79518a40d302e5eb40ed5da193cf1b2 | /cpp/extern/xercesc++/2.6.0/src/xercesc/dom/DOM.hpp | 4cb14371bcddc2b752c1eea6076eb35e0aaa06b7 | [
"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 | 2,978 | hpp | #ifndef DOMHEADER_GUARD_HPP
#define DOMHEADER_GUARD_HPP
/*
* Copyright 2001-2002,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: DOM.hpp,v 1.12 2004/09/08 13:55:38 peiyongz Exp $
*/
//
// This is the primary header file for inclusion in application
// programs using the C++ XML Document Object Model API.
//
#include <xercesc/dom/DOMAttr.hpp>
#include <xercesc/dom/DOMCDATASection.hpp>
#include <xercesc/dom/DOMCharacterData.hpp>
#include <xercesc/dom/DOMComment.hpp>
#include <xercesc/dom/DOMDocument.hpp>
#include <xercesc/dom/DOMDocumentFragment.hpp>
#include <xercesc/dom/DOMDocumentType.hpp>
#include <xercesc/dom/DOMElement.hpp>
#include <xercesc/dom/DOMEntity.hpp>
#include <xercesc/dom/DOMEntityReference.hpp>
#include <xercesc/dom/DOMException.hpp>
#include <xercesc/dom/DOMImplementation.hpp>
#include <xercesc/dom/DOMNamedNodeMap.hpp>
#include <xercesc/dom/DOMNode.hpp>
#include <xercesc/dom/DOMNodeList.hpp>
#include <xercesc/dom/DOMNotation.hpp>
#include <xercesc/dom/DOMProcessingInstruction.hpp>
#include <xercesc/dom/DOMText.hpp>
// Introduced in DOM Level 2
#include <xercesc/dom/DOMDocumentRange.hpp>
#include <xercesc/dom/DOMDocumentTraversal.hpp>
#include <xercesc/dom/DOMNodeFilter.hpp>
#include <xercesc/dom/DOMNodeIterator.hpp>
#include <xercesc/dom/DOMRange.hpp>
#include <xercesc/dom/DOMRangeException.hpp>
#include <xercesc/dom/DOMTreeWalker.hpp>
// Introduced in DOM Level 3
// Experimental - subject to change
#include <xercesc/dom/DOMBuilder.hpp>
#include <xercesc/dom/DOMConfiguration.hpp>
#include <xercesc/dom/DOMEntityResolver.hpp>
#include <xercesc/dom/DOMError.hpp>
#include <xercesc/dom/DOMErrorHandler.hpp>
#include <xercesc/dom/DOMImplementationLS.hpp>
#include <xercesc/dom/DOMImplementationRegistry.hpp>
#include <xercesc/dom/DOMImplementationSource.hpp>
#include <xercesc/dom/DOMInputSource.hpp>
#include <xercesc/dom/DOMLocator.hpp>
#include <xercesc/dom/DOMTypeInfo.hpp>
#include <xercesc/dom/DOMUserDataHandler.hpp>
#include <xercesc/dom/DOMWriter.hpp>
#include <xercesc/dom/DOMWriterFilter.hpp>
#include <xercesc/dom/DOMXPathEvaluator.hpp>
#include <xercesc/dom/DOMXPathNSResolver.hpp>
#include <xercesc/dom/DOMXPathException.hpp>
#include <xercesc/dom/DOMXPathExpression.hpp>
#include <xercesc/dom/DOMXPathResult.hpp>
#include <xercesc/dom/DOMXPathNamespace.hpp>
#endif
| [
"[email protected]"
] | [
[
[
1,
82
]
]
] |
13837205f58a29728fcb2f890ba903deca667bad | 4fdc157f7d6c5af784c3492909d848a0371e5877 | /Vision/Diagrams_argoUML/Generated_code/Camera.h | b782ca717f7df3e5624dd716cd5cc1c3597b8917 | [] | no_license | moumen19/robotiquecartemere | d969e50aedc53844bb7c512ff15e6812b8b469de | 8333bb0b5c1b1396e1e99a870af2f60c9db149b0 | refs/heads/master | 2020-12-24T17:17:14.273869 | 2011-02-11T15:44:38 | 2011-02-11T15:44:38 | 34,446,411 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 480 | h | #ifndef CAMERA_H
#define CAMERA_H
// FILE: D:/TRAVAIL/M2/Robotique_Avancee/SVN_partie_info/Vision/Diagrams_argoUML/Generated_code//Camera.h
#include "VideoSource.h"
class Camera : public VideoSource {
/* {src_lang=cpp}*/
// Operations
public:
virtual void Calibrate();
virtual void SaveMatrices();
virtual void LoadMatrices();
// Attributes
private:
int newAttr;
//end of class Camera
};
#endif // CAMERA_H
| [
"julien.delbergue@308fe9b9-b635-520e-12eb-2ef3f824b1b6"
] | [
[
[
1,
30
]
]
] |
46fecb2113c0767774f3c6b5e54ffc664d3cf7f9 | d6a28d9d845a20463704afe8ebe644a241dc1a46 | /tests/transparentMaterials.cpp | 9544d36ff2b8745f75373a7aa73a0df08bfdc0c9 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-other-permissive",
"Zlib"
] | permissive | marky0720/irrlicht-android | 6932058563bf4150cd7090d1dc09466132df5448 | 86512d871eeb55dfaae2d2bf327299348cc5202c | refs/heads/master | 2021-04-30T08:19:25.297407 | 2010-10-08T08:27:33 | 2010-10-08T08:27:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,386 | cpp | // Copyright (C) 2008-2009 Christian Stehno, Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
//! Check that EMT_TRANSPARENT_ALPHA_CHANNEL_REF works as expected
bool testTransparentAlphaChannelRef(video::E_DRIVER_TYPE driverType)
{
IrrlichtDevice* device = createDevice(driverType, core::dimension2d<u32>(160, 120), 32);
if(!device)
return true;
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
ISceneNode * backCube = smgr->addCubeSceneNode();
backCube->setPosition(vector3df(0, 0, 10));
backCube->setScale(vector3df(5, 5, 1));
backCube->setMaterialTexture(0, driver->getTexture("../media/wall.bmp"));
backCube->setMaterialType(video::EMT_SOLID);
backCube->setMaterialFlag(video::EMF_LIGHTING, false);
ISceneNode * frontCube = smgr->addCubeSceneNode();
frontCube->setMaterialTexture(0, driver->getTexture("../media/help.png"));
frontCube->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF);
frontCube->setMaterialFlag(video::EMF_LIGHTING, false);
(void)smgr->addCameraSceneNode(0, vector3df(0, 0, -15));
driver->beginScene(true, true, video::SColor(255,113,113,133));
smgr->drawAll();
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-transparentAlphaChannelRef.png", 99.18f);
device->drop();
return result;
}
//! Check that EMT_TRANSPARENT_ALPHA_CHANNEL works as expected
bool testTransparentAlphaChannel(video::E_DRIVER_TYPE driverType)
{
IrrlichtDevice* device = createDevice(driverType, core::dimension2d<u32>(160, 120), 32);
if(!device)
return true;
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
ISceneNode * backCube = smgr->addCubeSceneNode();
backCube->setPosition(vector3df(0, 0, 10));
backCube->setScale(vector3df(5, 5, 1));
backCube->setMaterialTexture(0, driver->getTexture("../media/wall.bmp"));
backCube->setMaterialType(video::EMT_SOLID);
backCube->setMaterialFlag(video::EMF_LIGHTING, false);
ISceneNode * frontCube = smgr->addCubeSceneNode();
frontCube->setMaterialTexture(0, driver->getTexture("../media/help.png"));
frontCube->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL);
frontCube->setMaterialFlag(video::EMF_LIGHTING, false);
(void)smgr->addCameraSceneNode(0, vector3df(0, 0, -15));
driver->beginScene(true, true, video::SColor(255,113,113,133));
smgr->drawAll();
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-transparentAlphaChannel.png");
device->drop();
return result;
}
//! Check that EMT_TRANSPARENT_VERTEX_ALPHA works as expected
bool testTransparentVertexAlpha(video::E_DRIVER_TYPE driverType)
{
IrrlichtDevice* device = createDevice(driverType, core::dimension2d<u32>(160, 120), 32);
if(!device)
return true;
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
ISceneNode * backCube = smgr->addCubeSceneNode();
backCube->setPosition(vector3df(0, 0, 10));
backCube->setScale(vector3df(5, 5, 1));
backCube->setMaterialTexture(0, driver->getTexture("../media/wall.bmp"));
// vertex color has alpha 255, hence solid
backCube->setMaterialType(video::EMT_TRANSPARENT_VERTEX_ALPHA);
backCube->setMaterialFlag(video::EMF_LIGHTING, false);
IMeshSceneNode * frontCube = smgr->addCubeSceneNode(10,0,-1,core::vector3df(-10,0,0));
frontCube->setMaterialTexture(0, driver->getTexture("../media/help.png"));
frontCube->setMaterialType(video::EMT_TRANSPARENT_VERTEX_ALPHA);
frontCube->setMaterialFlag(video::EMF_LIGHTING, false);
driver->getMeshManipulator()->setVertexColorAlpha(frontCube->getMesh(), 128);
frontCube = smgr->addCubeSceneNode(10,0,-1,core::vector3df(10,0,0));
frontCube->setMaterialTexture(0, driver->getTexture("../media/help.png"));
frontCube->setMaterialType(video::EMT_TRANSPARENT_VERTEX_ALPHA);
frontCube->setMaterialFlag(video::EMF_LIGHTING, false);
driver->getMeshManipulator()->setVertexColorAlpha(frontCube->getMesh(), 45);
(void)smgr->addCameraSceneNode(0, vector3df(0, 0, -15));
driver->beginScene(true, true, video::SColor(255,113,113,133));
smgr->drawAll();
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-transparentVertexAlpha.png", 98.76f);
device->drop();
return result;
}
//! Check that EMT_TRANSPARENT_REFLECTION_2_LAYER works as expected
bool testTransparentReflection2Layer(video::E_DRIVER_TYPE driverType)
{
IrrlichtDevice* device = createDevice(driverType, core::dimension2d<u32>(160, 120), 32);
if(!device)
return true;
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
ISceneNode * backCube = smgr->addCubeSceneNode();
backCube->setPosition(vector3df(0, 0, 10));
backCube->setScale(vector3df(5, 5, 1));
backCube->setMaterialTexture(0, driver->getTexture("../media/wall.bmp"));
backCube->setMaterialTexture(1, driver->getTexture("../media/water.jpg"));
// vertex color has alpha 255, hence solid
backCube->setMaterialType(video::EMT_TRANSPARENT_REFLECTION_2_LAYER);
backCube->setMaterialFlag(video::EMF_LIGHTING, false);
IMeshSceneNode * frontCube = smgr->addCubeSceneNode(10,0,-1,core::vector3df(-10,0,0));
frontCube->setMaterialTexture(0, driver->getTexture("../media/help.png"));
frontCube->setMaterialTexture(1, driver->getTexture("../media/water.jpg"));
frontCube->setMaterialType(video::EMT_TRANSPARENT_REFLECTION_2_LAYER);
frontCube->setMaterialFlag(video::EMF_LIGHTING, false);
driver->getMeshManipulator()->setVertexColorAlpha(frontCube->getMesh(), 128);
frontCube = smgr->addCubeSceneNode(10,0,-1,core::vector3df(10,0,0));
frontCube->setMaterialTexture(0, driver->getTexture("../media/help.png"));
frontCube->setMaterialTexture(1, driver->getTexture("../media/water.jpg"));
frontCube->setMaterialType(video::EMT_TRANSPARENT_REFLECTION_2_LAYER);
frontCube->setMaterialFlag(video::EMF_LIGHTING, false);
driver->getMeshManipulator()->setVertexColorAlpha(frontCube->getMesh(), 45);
(void)smgr->addCameraSceneNode(0, vector3df(0, 0, -15));
driver->beginScene(true, true, video::SColor(255,113,113,133));
smgr->drawAll();
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-transparentReflection2Layer.png");
device->drop();
return result;
}
//! Check that EMT_TRANSPARENT_ADD_COLOR works as expected
bool testTransparentAddColor(video::E_DRIVER_TYPE driverType)
{
IrrlichtDevice* device = createDevice(driverType, core::dimension2d<u32>(160, 120), 32);
if(!device)
return true;
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
ISceneNode * backCube = smgr->addCubeSceneNode();
backCube->setPosition(vector3df(0, 0, 10));
backCube->setScale(vector3df(5, 5, 1));
backCube->setMaterialTexture(0, driver->getTexture("../media/wall.bmp"));
backCube->setMaterialType(video::EMT_SOLID);
backCube->setMaterialFlag(video::EMF_LIGHTING, false);
IMeshSceneNode * frontCube = smgr->addCubeSceneNode();
frontCube->setMaterialTexture(0, driver->getTexture("../media/help.png"));
frontCube->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
frontCube->setMaterialFlag(video::EMF_LIGHTING, false);
(void)smgr->addCameraSceneNode(0, vector3df(0, 0, -15));
driver->beginScene(true, true, video::SColor(255,113,113,133));
smgr->drawAll();
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-transparentAddColor.png");
device->drop();
return result;
}
bool testTransparentVertexAlphaMore(E_DRIVER_TYPE driverType)
{
IrrlichtDevice *device = createDevice(driverType, dimension2d<u32>(160, 120));
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IAnimatedMesh* mesh = smgr->getMesh("../media/sydney.md2");
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
IMeshSceneNode* cube = smgr->addCubeSceneNode(10.0f,0,-1,vector3df(-5,3,-15));
if (node)
{
node->setMaterialFlag(EMF_LIGHTING, false);
node->setFrameLoop(0, 310);
node->setMaterialTexture( 0, driver->getTexture("../media/sydney.bmp") );
}
if (cube)
{
cube->getMaterial(0).MaterialType = EMT_TRANSPARENT_VERTEX_ALPHA;
cube->setMaterialTexture(0, driver->getTexture("../media/wall.bmp"));
cube->setMaterialFlag(EMF_LIGHTING, false);
smgr->getMeshManipulator()->setVertexColorAlpha(cube->getMesh(),128);
}
// second cube without texture
cube = smgr->addCubeSceneNode(10.0f,0,-1,vector3df(5,3,-15));
if (cube)
{
cube->getMaterial(0).MaterialType = EMT_TRANSPARENT_VERTEX_ALPHA;
cube->setMaterialFlag(EMF_LIGHTING, false);
smgr->getMeshManipulator()->setVertexColorAlpha(cube->getMesh(),128);
}
smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
driver->beginScene(true, true, SColor(0,200,200,200));
smgr->drawAll();
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-transparentVertexAlphaChannelMore.png", 99.18f);
device->drop();
return result;
}
bool transparentMaterials(void)
{
bool result = testTransparentAlphaChannel(EDT_DIRECT3D9);
result &= testTransparentAlphaChannel(EDT_OPENGL);
result &= testTransparentAlphaChannel(EDT_BURNINGSVIDEO);
result &= testTransparentAlphaChannelRef(EDT_DIRECT3D9);
result &= testTransparentAlphaChannelRef(EDT_OPENGL);
// FIXME Rogerborg 8-January-2009. Burning's video currently produces unexpected results,
// blending using the full alpha value instead of using a boolean mask. This test is being
// added now anyway to help verify the fix when it's done; it should just require an
// update of the reference image.
result &= testTransparentAlphaChannelRef(EDT_BURNINGSVIDEO);
result &= testTransparentVertexAlpha(EDT_DIRECT3D9);
result &= testTransparentVertexAlpha(EDT_OPENGL);
// This type seems to be broken as well for Burning's video.
result &= testTransparentVertexAlpha(EDT_BURNINGSVIDEO);
result &= testTransparentAddColor(EDT_DIRECT3D9);
result &= testTransparentAddColor(EDT_OPENGL);
result &= testTransparentAddColor(EDT_BURNINGSVIDEO);
result &= testTransparentReflection2Layer(EDT_DIRECT3D9);
result &= testTransparentReflection2Layer(EDT_OPENGL);
result &= testTransparentReflection2Layer(EDT_BURNINGSVIDEO);
result &= testTransparentVertexAlphaMore(EDT_DIRECT3D9);
result &= testTransparentVertexAlphaMore(EDT_OPENGL);
// This type seems to be broken as well for Burning's video.
result &= testTransparentVertexAlphaMore(EDT_BURNINGSVIDEO);
return result;
}
| [
"hybrid@dfc29bdd-3216-0410-991c-e03cc46cb475",
"Rogerborg@dfc29bdd-3216-0410-991c-e03cc46cb475"
] | [
[
[
1,
14
],
[
16,
275
],
[
277,
299
]
],
[
[
15,
15
],
[
276,
276
]
]
] |
92b455a9c44a9ceb3b39ab3df472761bef0cb4f0 | 2903e35dcf63506e9795087dfd66d0e062d39713 | /connectform.cpp | 70dd2d3e72a4fc9402ab1b626e3b24ce36a7e271 | [] | no_license | vavavr00m/decap | ee330b5e377b83d89afb489217158650bf434902 | b08588635e35b2cadd0c4ad0aca51f70f8ac2881 | refs/heads/master | 2021-03-12T22:46:22.562217 | 2007-09-13T04:13:02 | 2007-09-13T04:13:02 | 33,624,479 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 814 | cpp | #include "connectform.h"
connectForm::connectForm(QWidget *parent) : QWidget(parent) {
QLabel *hostLabel = new QLabel(QString("&Host:"), this);
QLabel *portLabel = new QLabel(QString("Por&t:"), this);
hostLineEdit = new QLineEdit(QString("irc.freenode.net"), this);
portLineEdit = new QLineEdit(QString("6667"), this);
hostLabel->setBuddy(hostLineEdit);
portLabel->setBuddy(portLineEdit);
QGridLayout *layout = new QGridLayout();
layout->addWidget(hostLabel,0,0);
layout->addWidget(portLabel,1,0);
layout->addWidget(hostLineEdit,0,1);
layout->addWidget(portLineEdit,1,1);
layout->setMargin(0);
setLayout(layout);
}
QString connectForm::getHost(void) const {
return hostLineEdit->text();
}
int connectForm::getPort(void) const {
return portLineEdit->text().toInt();
}
| [
"qartis@fcd88983-e633-0410-a744-516c3ff6c6e9"
] | [
[
[
1,
27
]
]
] |
8e574c139235b83950e4b06c8272cc0bcf156b4e | 5927f0908f05d3f58fe0adf4d5d20c27a4756fbe | /examples/chrome/profile.h | 9be34880ff52879f0e3ed35e6ba6d12ab08687d1 | [] | no_license | seasky013/x-framework | b5585505a184a7d00d229da8ab0f556ca0b4b883 | 575e29de5840ede157e0348987fa188b7205f54d | refs/heads/master | 2016-09-16T09:41:26.994686 | 2011-09-16T06:16:22 | 2011-09-16T06:16:22 | 41,719,436 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 6,139 | h |
#ifndef __profile_h__
#define __profile_h__
#include <string>
#include "base/logging.h"
namespace base
{
class Time;
}
class AutocompleteClassifier;
class BookmarkModel;
class FaviconService;
class FilePath;
class FindBarState;
class PrefService;
typedef int LocalProfileId;
class Profile
{
public:
class Delegate
{
public:
// Called when creation of the profile is finished.
virtual void OnProfileCreated(Profile* profile, bool success) = 0;
};
// Key used to bind profile to the widget with which it is associated.
static const char* const kProfileKey;
// Value that represents no local profile id.
static const LocalProfileId kInvalidLocalProfileId;
Profile();
virtual ~Profile() {}
// Profile prefs are registered as soon as the prefs are loaded for the first
// time.
static void RegisterUserPrefs(PrefService* prefs);
// Create a new profile given a path.
static Profile* CreateProfile(const FilePath& path);
// Same as above, but uses async initialization.
static Profile* CreateProfileAsync(const FilePath& path,
Delegate* delegate);
// content::BrowserContext implementation ------------------------------------
virtual FilePath GetPath() = 0;
// content::BrowserContext implementation ------------------------------------
// Returns the name associated with this profile. This name is displayed in
// the browser frame.
virtual std::string GetProfileName() = 0;
// Return the original "recording" profile. This method returns this if the
// profile is not incognito.
virtual Profile* GetOriginalProfile() = 0;
// Retrieves a pointer to the FaviconService associated with this
// profile. The FaviconService is lazily created the first time
// that this method is called.
//
// Although FaviconService is refcounted, this will not addref, and callers
// do not need to do any reference counting as long as they keep the pointer
// only for the local scope (which they should do anyway since the browser
// process may decide to shut down).
//
// |access| defines what the caller plans to do with the service. See
// the ServiceAccessType definition above.
virtual FaviconService* GetFaviconService() = 0;
// Retrieves a pointer to the AutocompleteClassifier associated with this
// profile. The AutocompleteClassifier is lazily created the first time that
// this method is called.
virtual AutocompleteClassifier* GetAutocompleteClassifier() = 0;
// Retrieves a pointer to the PrefService that manages the preferences
// for this user profile. The PrefService is lazily created the first
// time that this method is called.
virtual PrefService* GetPrefs() = 0;
// Returns the find bar state for this profile. The find bar state is lazily
// created the first time that this method is called.
virtual FindBarState* GetFindBarState() = 0;
// Returns true if the last time this profile was open it was exited cleanly.
virtual bool DidLastSessionExitCleanly() = 0;
// Returns the BookmarkModel, creating if not yet created.
virtual BookmarkModel* GetBookmarkModel() = 0;
// Return whether 2 profiles are the same. 2 profiles are the same if they
// represent the same profile. This can happen if there is pointer equality
// or if one profile is the incognito version of another profile (or vice
// versa).
virtual bool IsSameProfile(Profile* profile) = 0;
// Returns the time the profile was started. This is not the time the profile
// was created, rather it is the time the user started chrome and logged into
// this profile. For the single profile case, this corresponds to the time
// the user started chrome.
virtual base::Time GetStartTime() const = 0;
// Marks the profile as cleanly shutdown.
//
// NOTE: this is invoked internally on a normal shutdown, but is public so
// that it can be invoked when the user logs out/powers down (WM_ENDSESSION).
virtual void MarkAsCleanShutdown() = 0;
// Start up service that gathers data from a promo resource feed.
virtual void InitPromoResources() = 0;
// Returns the last directory that was chosen for uploading or opening a file.
virtual FilePath last_selected_directory() = 0;
virtual void set_last_selected_directory(const FilePath& path) = 0;
std::string GetDebugName();
// Returns whether it is a guest session.
static bool IsGuestSession();
// Did the user restore the last session? This is set by SessionRestore.
void set_restored_last_session(bool restored_last_session)
{
restored_last_session_ = restored_last_session;
}
bool restored_last_session() const
{
return restored_last_session_;
}
bool first_launched() const
{
return first_launched_;
}
// Stop sending accessibility events until ResumeAccessibilityEvents().
// Calls to Pause nest; no events will be sent until the number of
// Resume calls matches the number of Pause calls received.
void PauseAccessibilityEvents()
{
accessibility_pause_level_++;
}
void ResumeAccessibilityEvents()
{
DCHECK(accessibility_pause_level_ > 0);
accessibility_pause_level_--;
}
bool ShouldSendAccessibilityEvents()
{
return 0 == accessibility_pause_level_;
}
private:
bool restored_last_session_;
// True only for the very first profile launched in a Chrome session.
bool first_launched_;
// Accessibility events will only be propagated when the pause
// level is zero. PauseAccessibilityEvents and ResumeAccessibilityEvents
// increment and decrement the level, respectively, rather than set it to
// true or false, so that calls can be nested.
int accessibility_pause_level_;
};
#endif //__profile_h__ | [
"[email protected]"
] | [
[
[
1,
177
]
]
] |
1cadfc11eafd8aa79a7ef894850fc8e35151bd56 | f3001cd56567b121736343b480a1abf9cba1cd52 | /MkIIProtocolHack/usbdrvCpp.h | 7da22ec77f962e07b0f5106a2bda545d7b4c29ec | [] | no_license | cjsatuforc/AvrProjects | 257f0594740b215ff2db2abaa79ec718cd14d647 | a9f70a87a28e426ee4a558ca5ddc198f97a1ebdb | refs/heads/master | 2020-04-13T19:00:06.609001 | 2011-03-18T16:01:42 | 2011-03-18T16:01:42 | null | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 4,355 | h | #pragma once
namespace UsbInt
{
extern "C"
{
#include "usbdrv.h"
}
}
namespace Usb
{
using namespace UsbInt;
// values for UsbConfigurationDescriptor.bmAttributes
enum ConfigAttributes
{
BusPowered = 0,
SelfPowered = (1 << 6) | (1 << 7) ,
RemoteWakeup = (1 << 5) | (1 << 7)
};
enum EndpointAttributes
{
Control = 0,
Isochronous = (1 << 0),
Bulk = (1 << 1),
Interrupt = (1 << 0) | (1 << 1),
};
enum DescriptorTypes
{
DeviceDescriptor = 0x01,
ConfigurationDescriptor = 0x02,
StringDescriptor = 0x03,
InterfaceDescriptor = 0x04,
EndpointDescriptor = 0x05
};
struct DeviceDescriptorT
{
uint8_t bLength; // 0x12 The size of this descriptor is 18 bytes
uint8_t bDescriptorType; // 0x01 DEVICE Descriptor Type
uint16_t bcdUSB;
uint8_t bDeviceClass;
uint8_t bDeviceSubClass;
uint8_t bDeviceProtocol;
uint8_t bMaxPacketSize0;
uint16_t idVendor;
uint16_t idProduct;
uint16_t bcdDevice;
uint8_t iManufacturer;
uint8_t iProduct;
uint8_t iSerialNumber;
uint8_t bNumConfigurations;
};
struct ConfigurationDescriptorT
{
uint8_t bLength; // 0x09 The size of this descriptor is 9 bytes
uint8_t bDescriptorType; // 0x02 CONFIGURATION Descriptor Type
uint16_t wTotalLength; // The total length of data for this configuration is 32. This includes the combined length of all the descriptors returned
uint8_t bNumInterfaces;
uint8_t bConfigurationValue;
uint8_t iConfiguration; // 0x00 The device doesn't have the string descriptor describing this configuration
uint8_t bmAttributes; // Configuration characteristics:Bit 7: Reserved
uint8_t MaxPower; // Maximum power consumption of the device in this configuration is 500 mA
};
struct InterfaceDescriptorT
{
uint8_t bLength; // 0x09 The size of this descriptor is 9 bytes
uint8_t bDescriptorType; // 0x04 INTERFACE Descriptor Type
uint8_t bInterfaceNumber; // 0x00 The number of this interface is 0
uint8_t bAlternateSetting; // 0x00 The value used to select alternate setting for this interface is 0
uint8_t bNumEndpoints; // 0x02 The number of endpoints used by this interface is 2(excluding endpoint zero)
uint8_t bInterfaceClass; // 0xFF The interface class is vendor-specific
uint8_t bInterfaceSubClass; // 0x00 The subclass code is 0x00
uint8_t bInterfaceProtocol; // 0x00 The interface doesn't use any class-specific protocols
uint8_t iInterface; // 0x00 The device doesn't have the string descriptor describing this interface
};
struct EndpointDescriptorT
{
uint8_t bLength; // 0x07 The size of this descriptor is 7 bytes
uint8_t bDescriptorType; // 0x05 ENDPOINT Descriptor Type
uint8_t bEndpointAddress; // 0x02 This is an OUT endpoint with address (endpoint number) 2
uint8_t bmAttributes; // 0x02 Types –Transfer:BULKSync:No SyncUsage:Data EP
uint16_t wMaxPacketSize; // Maximum packet size value for this endpoint is 0x40(Bits 12-11: Addtl. Transactions/frame)
uint8_t bInterval; // 0x0A bInterval:10. The polling interval value is bInterval or 2**(bInterval-1)
};
template<class DataSource>
void SetStreamDataGeneric(DataSource &ds, uchar len, usbTxStatus_t *txStatus)
{
uchar *p, c;
#if USB_CFG_IMPLEMENT_HALT
if(usbTxLen1 == USBPID_STALL)
return;
#endif
if(txStatus->len & 0x10)// packet buffer was empty
{
txStatus->buffer[0] ^= USBPID_DATA0 ^ USBPID_DATA1; // toggle token
}
else
{
txStatus->len = USBPID_NAK; // avoid sending outdated (overwritten) interrupt data
}
p = txStatus->buffer + 1;
for(uint8_t i=len; i--;)
{
ds.Read(c);
*p++ = c;
}
usbCrc16Append(&txStatus->buffer[1], len);
txStatus->len = len + 4; // len must be given including sync byte
}
template<class DataSource>
void SetStreamData(DataSource &ds, uchar len)
{
SetStreamDataGeneric(ds, len, &usbTxStatus1);
}
inline uint8_t InterruptIsReady()
{
return (usbTxLen1 & 0x10);
}
}
#define STRING_DESCRIPTOR(name, value) \
struct \
{\
uint8_t bLength;\
uint8_t bDescriptorType;\
wchar_t bString[sizeof(value)];\
} name = \
{\
sizeof(L##value) + 2,\
Usb::StringDescriptor,\
L##value\
}\
| [
"[email protected]"
] | [
[
[
1,
149
]
]
] |
5278c44729e077a473d583d6e33a5fa2f93d9ca0 | cb621dee2a0f09a9a2d5d14ffaac7df0cad666a0 | /http/parsers/response.hpp | 1670ac46c4bd1254c222871eb167ebc5b46b4900 | [
"BSL-1.0"
] | permissive | ssiloti/http | a15fb43c94c823779f11fb02e147f023ca77c932 | 9cdeaa5cf2ef2848238c6e4c499ebf80e136ba7e | refs/heads/master | 2021-01-01T19:10:36.886248 | 2011-11-07T19:29:22 | 2011-11-07T19:29:22 | 1,021,325 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,854 | hpp | //
// response.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2011 Steven Siloti ([email protected])
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef HTTP_PARSERS_RESPONSE_HPP
#define HTTP_PARSERS_RESPONSE_HPP
#include <http/basic_response.hpp>
#include <http/parsers/basic_rules.hpp>
#include <http/parsers/version_number.hpp>
#include <boost/spirit/home/qi/numeric/uint.hpp>
#include <boost/spirit/home/qi/directive/omit.hpp>
#include <boost/spirit/home/qi/parse.hpp>
namespace http {
template <typename Headers, typename Body>
template <typename Iterator>
struct basic_response<Headers, Body>::status_line_grammar
: boost::spirit::qi::grammar<Iterator, tuple_type()>
{
status_line_grammar() : status_line_grammar::base_type(status_line)
{
using namespace boost::spirit;
status_line %= version_number_g >> qi::omit[b.sp]
>> qi::uint_parser<unsigned, 10, 3, 3>() >> qi::omit[b.sp]
>> reason_phrase;
reason_phrase %= *( b.wsp | b.vchar | b.obs_text );
}
parsers::basic_rules<Iterator> b;
parsers::version_number_grammar<Iterator> version_number_g;
boost::spirit::qi::rule<Iterator, std::string()> reason_phrase;
boost::spirit::qi::rule<Iterator, tuple_type()> status_line;
};
template <typename Headers, typename Body>
template <typename InputIterator>
bool basic_response<Headers, Body>::parse_start_line(InputIterator begin, InputIterator end)
{
reason.clear();
tuple_type tuple(this->version, status, reason);
return boost::spirit::qi::parse(
begin,
end,
status_line_grammar<InputIterator>(),
tuple
);
}
}
#endif
| [
"[email protected]"
] | [
[
[
1,
61
]
]
] |
c67b1f607efbda0cb4324b5501d44a5ea34afae9 | 0f40e36dc65b58cc3c04022cf215c77ae31965a8 | /src/apps/vis/properties/vis_graphics_property_set.h | 3db20f9a578d463dcd51a4ebb094ea4af704ae3d | [
"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 | 2,238 | h | /************************************************************************
** 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. **
************************************************************************/
#ifndef __SHAWN_TUBSAPPS_VIS_GRAPHICS_PROPERTY_SET_H
#define __SHAWN_TUBSAPPS_VIS_GRAPHICS_PROPERTY_SET_H
#include "../buildfiles/_apps_enable_cmake.h"
#ifdef ENABLE_VIS
#include "sys/vec.h"
#include "apps/vis/properties/vis_drawable_property_set.h"
namespace vis
{
/**
* This class defines the properties of a DrawableGraphics object. See vis::PropertySet
* for further informations on creating, extending and using property sets.
*/
class GraphicsPropertySet
: public DrawablePropertySet
{
public:
///@name construction/deconstruction
///@{
GraphicsPropertySet();
virtual ~GraphicsPropertySet();
///@}
/// Initializes the property set
virtual void init( const Element& ) throw( std::runtime_error );
/// Position of the image
DECL_PROPERTY( position, shawn::Vec );
/// Anchor
DECL_PROPERTY( anchor, shawn::Vec );
/// Scales the image size
DECL_PROPERTY( scale, double );
DECL_PROPERTY( scale_is_network, double );
DECL_PROPERTY( position_is_network, double );
/// Blends image with background
DECL_PROPERTY( blend, double );
};
}
#endif
#endif
/*-----------------------------------------------------------------------
* Source $Source: /cvs/shawn/shawn/tubsapps/vis/properties/vis_graphics_property_set.h,v $
* Version $Revision: 1.1 $
* Date $Date: 2006/02/14 21:53:10 $
*-----------------------------------------------------------------------
* $Log: vis_graphics_property_set.h,v $
* Revision 1.1 2006/02/14 21:53:10 ali
* *** empty log message ***
*
*-----------------------------------------------------------------------*/
| [
"[email protected]"
] | [
[
[
1,
62
]
]
] |
64e8a6bf1d42dae8fddc18ab68833060b45eefea | d752d83f8bd72d9b280a8c70e28e56e502ef096f | /FugueDLL/Virtual Machine/Operations/Variables/StringOps.cpp | b550f455ba2f1ca606cd18eee2c7bc9aa5437e44 | [] | no_license | apoch/epoch-language.old | f87b4512ec6bb5591bc1610e21210e0ed6a82104 | b09701714d556442202fccb92405e6886064f4af | refs/heads/master | 2021-01-10T20:17:56.774468 | 2010-03-07T09:19:02 | 2010-03-07T09:19:02 | 34,307,116 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,169 | cpp | //
// The Epoch Language Project
// FUGUE Virtual Machine
//
// Operations for working with strings
//
#include "pch.h"
#include "Virtual Machine/Operations/Variables/StringOps.h"
#include "Virtual Machine/Core Entities/Variables/Variable.h"
#include "Virtual Machine/Core Entities/Variables/StringVariable.h"
#include "Virtual Machine/Core Entities/Scopes/ActivatedScope.h"
#include "Virtual Machine/Core Entities/Program.h"
using namespace VM;
using namespace VM::Operations;
//
// Concatenate two strings and return the result
//
RValuePtr Concatenate::ExecuteAndStoreRValue(ExecutionContext& context)
{
std::wstring ret;
if(NumParams == 1)
ret = OperateOnArray(context.Stack);
else if(NumParams == 2)
{
if(FirstIsArray && !SecondIsArray)
{
StringVariable var(context.Stack.GetCurrentTopOfStack());
std::wstring variableval = var.GetValue();
context.Stack.Pop(StringVariable::GetStorageSize());
ret = OperateOnArray(context.Stack) + variableval;
}
else if(!FirstIsArray && SecondIsArray)
{
ret = OperateOnArray(context.Stack);
StringVariable var(context.Stack.GetCurrentTopOfStack());
ret = var.GetValue() + ret;
context.Stack.Pop(StringVariable::GetStorageSize());
}
else if(FirstIsArray && SecondIsArray)
{
ret = OperateOnArray(context.Stack);
ret = OperateOnArray(context.Stack) + ret;
}
else
{
StringVariable twovar(context.Stack.GetCurrentTopOfStack());
StringVariable onevar(context.Stack.GetOffsetIntoStack(StringVariable::GetStorageSize()));
ret = onevar.GetValue() + twovar.GetValue();
context.Stack.Pop(StringVariable::GetStorageSize() * 2);
}
}
else
throw ExecutionException("Invalid set of parameters");
return RValuePtr(new StringRValue(ret));
}
void Concatenate::ExecuteFast(ExecutionContext& context)
{
ExecuteAndStoreRValue(context);
}
//
// Concatenate all members of an array
//
std::wstring Concatenate::OperateOnArray(StackSpace& stack) const
{
std::wstring ret;
IntegerVariable typevar(stack.GetCurrentTopOfStack());
IntegerVariable countvar(stack.GetOffsetIntoStack(IntegerVariable::GetStorageSize()));
IntegerVariable::BaseStorage type = typevar.GetValue();
IntegerVariable::BaseStorage count = countvar.GetValue();
stack.Pop(IntegerVariable::GetStorageSize() * 2);
if(type != EpochVariableType_String)
throw ExecutionException("concat() function expects an array of strings");
for(Integer32 i = 0; i < count; ++i)
{
StringVariable var(stack.GetCurrentTopOfStack());
ret += var.GetValue();
stack.Pop(StringVariable::GetStorageSize());
}
return ret;
}
//
// Retrieve a string's length
//
RValuePtr Length::ExecuteAndStoreRValue(ExecutionContext& context)
{
if(context.Scope.GetVariableType(VarName) != EpochVariableType_String)
throw ExecutionException("length() must be passed a string variable");
return RValuePtr(new IntegerRValue(static_cast<Integer32>(context.Scope.GetVariableRef<StringVariable>(VarName).GetValue().length())));
}
void Length::ExecuteFast(ExecutionContext& context)
{
// Nothing to do.
}
| [
"[email protected]",
"don.apoch@localhost"
] | [
[
[
1,
23
],
[
25,
28
],
[
30,
31
],
[
33,
33
],
[
35,
35
],
[
38,
38
],
[
40,
40
],
[
43,
43
],
[
45,
45
],
[
47,
47
],
[
50,
52
],
[
55,
55
],
[
57,
64
],
[
66,
66
],
[
68,
70
],
[
72,
72
],
[
74,
83
],
[
85,
99
],
[
101,
101
],
[
103,
104
],
[
106,
107
],
[
109,
112
]
],
[
[
24,
24
],
[
29,
29
],
[
32,
32
],
[
34,
34
],
[
36,
37
],
[
39,
39
],
[
41,
42
],
[
44,
44
],
[
46,
46
],
[
48,
49
],
[
53,
54
],
[
56,
56
],
[
65,
65
],
[
67,
67
],
[
71,
71
],
[
73,
73
],
[
84,
84
],
[
100,
100
],
[
102,
102
],
[
105,
105
],
[
108,
108
]
]
] |
97da5b417543637256c8976d05ec55dc2f5f2d28 | f6d5124e131c83f7b64dbeeb6b0d8a4bcaa09fdd | /branches/1.0b/TraumCheck/LibNode.h | 0dafaa7b07f391043a88759d5531ab63bce47e1f | [] | no_license | 5k0rp/traumlibcheck | 40bb4f16c533022f12c408c02e949f179e16cdfc | d20b56ad4f739bc867954dac2afd02e2caf2cb7a | refs/heads/master | 2021-01-01T06:54:05.354831 | 2010-12-13T23:08:39 | 2010-12-13T23:08:39 | 32,864,050 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,327 | h | #pragma once
#include <algorithm>
typedef unsigned long FileSizeType;
class LibNode
{
std::wstring path_;
std::wstring lpath_;
FileSizeType size_;
bool marked_;
public:
LibNode(const wchar_t* _path, FileSizeType _size);
void doMarked() { marked_ = true; }
bool isMarked() const { return marked_; }
const wchar_t* path() const { return path_.c_str(); }
FileSizeType size() const { return 1; }
void getFolder(std::wstring& out) const;
bool operator<(const LibNode& node) const { return lpath_ < node.lpath_; }
};
class LibNodeCalalog : public std::vector<LibNode>
{
public:
LibNodeCalalog(int reservesize = 15000);
bool isDot(const wchar_t *name)
{
return *name == L'.' && (!name[1] || name[1] == L'.' && !name[2]);
}
void add(const wchar_t *str, FileSizeType size);
void add(const std::wstring& str, FileSizeType size);
void sort();
iterator bsearch(const wchar_t* path) {
LibNode val(path, 0);
iterator it = std::lower_bound(begin(), end(), val);
if(it != end() && !(val < *it))
return it;
return end();
}
const_iterator bsearch(const wchar_t* path) const {
LibNode val(path, 0);
const_iterator it = std::lower_bound(begin(), end(), val);
if(it != end() && !(val < *it))
return it;
return end();
}
};
| [
"rakunov@f8c17eb4-c337-11de-8983-4d3ad078cb47"
] | [
[
[
1,
61
]
]
] |
f1a6df6d899433175070e5292438419618d36455 | aa5491d8b31750da743472562e85dd4987f1258a | /Main/server/ped.h | 8238efd084c8a8210f9828bd922bb6f2664ee067 | [] | no_license | LBRGeorge/jmnvc | d841ad694eaa761d0a45ab95b210758c50750d17 | 064402f0a9f1536229b99cf45f6e7536e1ae7bb5 | refs/heads/master | 2016-08-04T03:12:18.402941 | 2009-05-31T18:40:42 | 2009-05-31T18:40:42 | 39,416,169 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 934 | h | #pragma once
typedef struct _PED_SPAWN_INFO
{
BYTE bytePedType;
VECTOR vecPos;
float fRotation;
int iColor1;
int iColor2;
} PED_SPAWN_INFO;
class CPed
{
public:
BYTE m_bytePedID;
BYTE m_byteDriverID;
BYTE m_bytePassengers[7];
BOOL m_bIsActive;
BOOL m_bIsWasted;
PED_SPAWN_INFO m_SpawnInfo;
MATRIX4X4 m_matWorld;
VECTOR m_vecMoveSpeed;
VECTOR m_vecTurnSpeed;
float m_fHealth;
BOOL m_bHasHadUpdate;
CPed(BYTE byteModel,VECTOR *vecPos,float fRotation,int iColor1,int iColor2);
~CPed(){};
BOOL IsActive() { return m_bIsActive; };
BOOL IsWasted() { return m_bIsWasted; };
void SetID(BYTE bytePedID) { m_bytePedID = bytePedID; };
PED_SPAWN_INFO * GetSpawnInfo() { return &m_SpawnInfo; };
void SpawnForPlayer(BYTE byteForPlayerID);
void Update(BYTE bytePlayerID, MATRIX4X4 * matWorld,
VECTOR * vecMoveSpeed, float fHealth);
}; | [
"jacks.mini.net@45e629aa-34f5-11de-82fb-7f665ef830f7"
] | [
[
[
1,
41
]
]
] |
33a95be5f4018628d7bf682e2c2e6bf3cd32d5c3 | 2f72d621e6ec03b9ea243a96e8dd947a952da087 | /src/groupObject.cpp | 23ecf0fa5065244d50f8cde0e373f940fff837ac | [] | no_license | gspu/lol4fg | 752358c3c3431026ed025e8cb8777e4807eed7a0 | 12a08f3ef1126ce679ea05293fe35525065ab253 | refs/heads/master | 2023-04-30T05:32:03.826238 | 2011-07-23T23:35:14 | 2011-07-23T23:35:14 | 364,193,504 | 0 | 0 | null | null | null | null | ISO-8859-2 | C++ | false | false | 17,186 | cpp | #include "GroupObject.h"
#include "EditorApp.h"
#include "EditFrameListener.h"
#include "Level.h"
#include "functions.h"
GroupObject::GroupObject(Level *lvl,GameObject *first)
{
//mLog("Erstelle Gruppe mit ersten objekt "+ptrToString(first));
mNode = lvl->getSceneManager()->getRootSceneNode()->createChildSceneNode();//das ist die rootnode!
mArt = NULL;
mLevel = lvl;
mBody = NULL;
type = otGroup;
ID = "";
// name = "";
baseScale = first->getScale();
groupedObjects.push_back(first);
mLevel->registerObject(this);
EditorApp *app = (EditorApp*)StandardApplication::getSingletonPtr();
//fl = app->getFrameListener();
gl = app->qtApp->getGameLogic();
dissolveCalled = false;
deleteAllGrouped = true;
isSelected = false;
mNode->setPosition(first->getPosition());
mNode->setOrientation(first->getOrientation());
mNode->setScale(first->getScale());
}
//void GroupObject::addObject(GameObject *add)
//{
//
// std::vector<GameObject*>::const_iterator itr;
// for(itr = groupedObjects.begin();itr != groupedObjects.end();itr++)
// {
// //GameObject *cur = *itr;
// if(*itr == add)
// return;
// }
// groupedObjects.push_back(add);
//}
void GroupObject::addObject(GameObject *add)
{
//mLog("adde zur gruppe "+ptrToString(add));
if(add && !hasObject(add))
groupedObjects.push_back(add);
// updateRootValues();
}
void GroupObject::dissolveGroup()
{
//mLog("dissolve group");
/*if(fl->getSelected() == this)
{
fl->setSelected(NULL);
}*/
//einfach löschen
if(dissolveCalled)
return;
dissolveCalled = true;
if(!groupedObjects.empty() && isSelected)
{
gl->setSelected(groupedObjects[0]);
}
deleteAllGrouped = false;
mLevel->deleteObject(this);
}
GroupObject::~GroupObject()
{
//alles löschen
//mLog("lösche gruppe");
if(deleteAllGrouped && !mLevel->getDestructorCalled())
{
std::vector<GameObject*>::const_iterator itr;
for(itr = groupedObjects.begin();itr != groupedObjects.end();itr++)
{
GameObject *cur = *itr;
delete cur;
}
}
//mLevel->unregisterObject(this);
}
void GroupObject::removeObject(GameObject *obj)
{
//mLog("entferne aus gruppe "+ptrToString(obj));
std::vector<GameObject*>::iterator itr;
for(itr = groupedObjects.begin();itr != groupedObjects.end();itr++)
{
GameObject *cur = *itr;
if(cur == obj)
{
//delete cur;
groupedObjects.erase(itr);
break;
}
}
if(groupedObjects.size() == 1)
{
//nur noch 1 drin
dissolveGroup();
}
else if(groupedObjects.empty())
{
mLevel->deleteObject(this);
}
else
{
gl->setSelected(this);
}
//updateRootValues();
}
//void GroupObject::updateChild(GameObject *child)
//{
//
// Ogre::Vector3 parentPos;
// Ogre::Vector3 parentScale;
// Ogre::Quaternion parentOrnt;
// GameObject *parent = groupedObjects[0];
// parentScale = parent->getScale();
// parent->getPositionOrientation(parentPos,parentOrnt);
//
// Ogre::Vector3 mPos;
// Ogre::Vector3 mScale;
// Ogre::Quaternion mOrnt;
// mScale = child->getScale();
// child->getPositionOrientation(mPos,mOrnt);
// //CODE FRON OGRE::NODE
// // Update orientation
// Ogre::Vector3 connectionVector = oldPos-mPos;//verbindung parent->child
// /*Ogre::Vector3 rotatedOld = oldOrnt * connectionVector;
// Ogre::Vector3 rotatedNew= parentOrnt * connectionVector;*/
//
// Ogre::Quaternion rotBy = parentOrnt* oldOrnt.Inverse();//rotatedOld.getRotationTo(rotatedNew);
//
// // Combine orientation with that of parent
// Ogre::Quaternion mNewOrnt = /*parentOrnt*/rotBy * mOrnt;
//
//
//
//
// // Scale own position by parent scale, NB just combine
// // as equivalent axes, no shearing
// Ogre::Vector3 mNewScale = parentScale * mScale;
//
//
//
//
// // Change position vector based on parent's orientation & scale
// Ogre::Vector3 mNewPos = /*parentOrnt*/rotBy * ((parentScale * connectionVector));
//
// // Add altered position vector to parents
//
// mNewPos += parentPos;
// mDebugText(str(mNewPos));
// child->setScale(mNewScale);
// child->setPositionOrientation(mNewPos,mNewOrnt);
//
//}
void GroupObject::setPosition(Ogre::Vector3 pos)
{
//das erste objekt wird als parent angesehen
GameObject *parent = groupedObjects[0];
Ogre::Vector3 oldPos = parent->getPosition();
mNode->setPosition(pos);
std::vector<GameObject*>::const_iterator itr;
parent->setPosition(pos);
Ogre::Vector3 posChange = pos-oldPos;
for(itr = groupedObjects.begin();itr != groupedObjects.end();itr++)
{
GameObject *cur = *itr;
if(cur != parent)
cur->setPosition(cur->getPosition()+posChange);
}
}
//void GroupObject::updateRootValues()
//{
// if(groupedObjects.size() == 0)
// return;
// Ogre::Vector3 sum = Ogre::Vector3::ZERO;
// std::vector<GameObject*>::const_iterator itr;
// for(itr = groupedObjects.begin();itr != groupedObjects.end();itr++)
// {
// sum += (*itr)->getPosition();
// }
// mNode->setPosition(sum / groupedObjects.size());
// mNode->setOrientation(Ogre::Quaternion::IDENTITY);
// mNode->setScale(Ogre::Vector3::UNIT_SCALE);
//
//}
void GroupObject::setOrientation(Ogre::Quaternion ornt)
{
//das erste objekt wird als parent angesehen
GameObject *parent = groupedObjects[0];
// Ogre::Quaternion oldOrnt = mNode->getOrientation();
// Ogre::Vector3 oldScale = rootScale;
//Ogre::Vector3 oldPos = mNode->getPosition();
std::vector<GameObject*>::const_iterator itr;
Ogre::Vector3 oldPos;
Ogre::Quaternion oldOrnt;
Ogre::Vector3 oldScale = parent->getScale();
parent->getPositionOrientation(oldPos,oldOrnt);
parent->setOrientation(ornt);
Ogre::Quaternion rotBy = ornt * oldOrnt.Inverse();
for(itr = groupedObjects.begin();itr != groupedObjects.end();itr++)
{
GameObject *cur = *itr;
if(cur != parent)
{
Ogre::Quaternion newOrnt = rotBy * cur->getOrientation();
Ogre::Vector3 relPos = cur->getPosition()-oldPos;
relPos = rotBy * relPos;
cur->setPositionOrientation(relPos+oldPos,newOrnt);
}
//updateChild(cur);
}
mNode->setOrientation(ornt);
//rootOrientation = ornt;
}
void GroupObject::setPositionOrientation(Ogre::Vector3 pos,Ogre::Quaternion ornt)
{
setPosition(pos);
setOrientation(ornt);
}
//retrieves body position
Ogre::Vector3 GroupObject::getPosition()
{
//return mNode->getPosition();
return groupedObjects[0]->getPosition();
}
//retr. body orient
Ogre::Quaternion GroupObject::getOrientation()
{
return groupedObjects[0]->getOrientation();
}
//retr. both (false if fails)
bool GroupObject::getPositionOrientation( Ogre::Vector3& pos, Ogre::Quaternion& orient )
{
/*pos = getPosition();
orient = getOrientation();
return true;*/
return groupedObjects[0]->getPositionOrientation(pos,orient);
}
void GroupObject::setScale(Ogre::Vector3 scale)
{
GameObject *parent = groupedObjects[0];
std::vector<GameObject*>::const_iterator itr;
Ogre::Quaternion oldOrnt;
Ogre::Vector3 oldScale = parent->getScale();
Ogre::Vector3 oldPos;
parent->getPositionOrientation(oldPos,oldOrnt);
Ogre::Vector3 scaleBy = scale/oldScale;
parent->setScale(scale);
/*std::vector<GameObject*>::const_iterator itr;
Ogre::Quaternion oldOrnt = mNode->getOrientation();
Ogre::Vector3 oldScale = mNode->getScale();
Ogre::Vector3 oldPos = mNode->getPosition();
Ogre::Vector3 scaleBy = scale/oldScale;*/
//oldOrnt = oldOrnt.Inverse();
for(itr = groupedObjects.begin();itr != groupedObjects.end();itr++)
{
GameObject *cur = *itr;
if(cur != parent)
{
Ogre::Vector3 relPos = cur->getPosition()-oldPos;
//relPos = oldOrnt*relPos;
cur->modScale(scaleBy);
relPos = oldOrnt.Inverse()*relPos;
relPos *= scaleBy;
relPos = oldOrnt*relPos;
//relPos *= oldOrnt.Inverse()*relPos;
cur->setPosition(relPos+oldPos);
}
}
mNode->setScale(scale);
}
void GroupObject::modScale(Ogre::Vector3 scale)
{
GameObject *parent = groupedObjects[0];
std::vector<GameObject*>::const_iterator itr;
Ogre::Quaternion oldOrnt;
Ogre::Vector3 oldPos;
parent->getPositionOrientation(oldPos,oldOrnt);
parent->modScale(scale);
/*
std::vector<GameObject*>::const_iterator itr;
Ogre::Quaternion oldOrnt = mNode->getOrientation();
Ogre::Vector3 oldPos = mNode->getPosition();*/
for(itr = groupedObjects.begin();itr != groupedObjects.end();itr++)
{
GameObject *cur = *itr;
if(cur != parent)
{
Ogre::Vector3 relPos = cur->getPosition()-oldPos;
cur->modScale(scale);
relPos = oldOrnt.Inverse()*relPos;
relPos *= scale;
relPos = oldOrnt*relPos;
cur->setPosition(relPos+oldPos);
}
}
mNode->scale(scale);
}
Ogre::Vector3 GroupObject::getScale()
{
return groupedObjects[0]->getScale();
}
void GroupObject::updateBody()
{
std::vector<GameObject*>::const_iterator itr;
for(itr = groupedObjects.begin();itr != groupedObjects.end();itr++)
{
GameObject *cur = *itr;
cur->updateBody();
}
}
void GroupObject::markSelected(bool mark)
{
std::vector<GameObject*>::const_iterator itr;
isSelected = mark;
for(itr = groupedObjects.begin();itr != groupedObjects.end();itr++)
{
GameObject *cur = *itr;
cur->markSelected(mark);
}
}
void GroupObject::rotate(const Ogre::Vector3& axis, const Ogre::Radian& angle, Ogre::Node::TransformSpace relativeTo)
{
Ogre::Quaternion q;
q.FromAngleAxis(angle,axis);
rotate(q, relativeTo);
}
void GroupObject::rotate(const Ogre::Quaternion& q, Ogre::Node::TransformSpace relativeTo)
{
Ogre::Quaternion oldOrnt = getOrientation();
Ogre::Quaternion newOrnt;
switch(relativeTo)
{
case Ogre::Node::TS_WORLD:
case Ogre::Node::TS_PARENT:
// Rotations are normally relative to local axes, transform up
newOrnt = q * oldOrnt;
break;
case Ogre::Node::TS_LOCAL:
// Note the order of the mult, i.e. q comes after
newOrnt = oldOrnt * q;
break;
}
setOrientation(newOrnt);
}
//BACKUP
/*
GroupObject::GroupObject(Level *lvl,GameObject *first)
{
//mLog("Erstelle Gruppe mit ersten objekt "+ptrToString(first));
mNode = lvl->getSceneManager()->getRootSceneNode()->createChildSceneNode();//das ist die rootnode!
mArt = NULL;
mLevel = lvl;
mBody = NULL;
type = otGroup;
ID = "";
// name = "";
baseScale = first->getScale();
groupedObjects.push_back(first);
mLevel->registerObject(this);
EditorApp *app = (EditorApp*)StandardApplication::getSingletonPtr();
fl = app->getFrameListener();
dissolveCalled = false;
deleteAllGrouped = true;
isSelected = false;
}
void GroupObject::addObject(GameObject *add)
{
//mLog("adde zur gruppe "+ptrToString(add));
if(add && !hasObject(add))
groupedObjects.push_back(add);
updateRootValues();
}
void GroupObject::dissolveGroup()
{
//einfach löschen
if(dissolveCalled)
return;
dissolveCalled = true;
if(!groupedObjects.empty() && isSelected)
{
fl->setSelected(groupedObjects[0]);
}
deleteAllGrouped = false;
mLevel->deleteObject(this);
}
GroupObject::~GroupObject()
{
if(deleteAllGrouped && !mLevel->getDestructorCalled())
{
std::vector<GameObject*>::const_iterator itr;
for(itr = groupedObjects.begin();itr != groupedObjects.end();itr++)
{
GameObject *cur = *itr;
delete cur;
}
}
}
void GroupObject::removeObject(GameObject *obj)
{
std::vector<GameObject*>::iterator itr;
for(itr = groupedObjects.begin();itr != groupedObjects.end();itr++)
{
GameObject *cur = *itr;
if(cur == obj)
{
//delete cur;
groupedObjects.erase(itr);
break;
}
}
if(groupedObjects.size() == 1)
{
//nur noch 1 drin
dissolveGroup();
}
else if(groupedObjects.empty())
{
mLevel->deleteObject(this);
}
else
{
fl->setSelected(this);
}
updateRootValues();
}
void GroupObject::setPosition(Ogre::Vector3 pos)
{
Ogre::Vector3 oldPos = mNode->getPosition();// parent->getPosition();
mNode->setPosition(pos);
std::vector<GameObject*>::const_iterator itr;
//parent->setPosition(pos);
Ogre::Vector3 posChange = pos-oldPos;
for(itr = groupedObjects.begin();itr != groupedObjects.end();itr++)
{
GameObject *cur = *itr;
cur->setPosition(cur->getPosition()+posChange);
}
}
void GroupObject::updateRootValues()
{
if(groupedObjects.size() == 0)
return;
Ogre::Vector3 sum = Ogre::Vector3::ZERO;
std::vector<GameObject*>::const_iterator itr;
for(itr = groupedObjects.begin();itr != groupedObjects.end();itr++)
{
sum += (*itr)->getPosition();
}
mNode->setPosition(sum / groupedObjects.size());
mNode->setOrientation(Ogre::Quaternion::IDENTITY);
mNode->setScale(Ogre::Vector3::UNIT_SCALE);
}
void GroupObject::setOrientation(Ogre::Quaternion ornt)
{
//das erste objekt wird als parent angesehen
//GameObject *parent = groupedObjects[0];
Ogre::Quaternion oldOrnt = mNode->getOrientation();
//Ogre::Vector3 oldScale = rootScale;
Ogre::Vector3 oldPos = mNode->getPosition();
std::vector<GameObject*>::const_iterator itr;
Ogre::Quaternion rotBy = ornt * oldOrnt.Inverse();
for(itr = groupedObjects.begin();itr != groupedObjects.end();itr++)
{
GameObject *cur = *itr;
Ogre::Quaternion newOrnt = rotBy * cur->getOrientation();
Ogre::Vector3 relPos = cur->getPosition()-oldPos;
relPos = rotBy * relPos;
cur->setPositionOrientation(relPos+oldPos,newOrnt);
//updateChild(cur);
}
mNode->setOrientation(ornt);
//rootOrientation = ornt;
}
void GroupObject::setPositionOrientation(Ogre::Vector3 pos,Ogre::Quaternion ornt)
{
setPosition(pos);
setOrientation(ornt);
}
//retrieves body position
Ogre::Vector3 GroupObject::getPosition()
{
return mNode->getPosition();
//return groupedObjects[0]->getPosition();
}
//retr. body orient
Ogre::Quaternion GroupObject::getOrientation()
{
return mNode->getOrientation(); //groupedObjects[0]->getOrientation();
}
//retr. both (false if fails)
bool GroupObject::getPositionOrientation( Ogre::Vector3& pos, Ogre::Quaternion& orient )
{
pos = getPosition();
orient = getOrientation();
return true;
//return groupedObjects[0]->getPositionOrientation(pos,orient);
}
void GroupObject::setScale(Ogre::Vector3 scale)
{
std::vector<GameObject*>::const_iterator itr;
Ogre::Quaternion oldOrnt = mNode->getOrientation();
Ogre::Vector3 oldScale = mNode->getScale();
Ogre::Vector3 oldPos = mNode->getPosition();
Ogre::Vector3 scaleBy = scale/oldScale;
//oldOrnt = oldOrnt.Inverse();
for(itr = groupedObjects.begin();itr != groupedObjects.end();itr++)
{
GameObject *cur = *itr;
Ogre::Vector3 relPos = cur->getPosition()-oldPos;
//relPos = oldOrnt*relPos;
cur->modScale(scaleBy);
relPos = oldOrnt.Inverse()*relPos;
relPos *= scaleBy;
relPos = oldOrnt*relPos;
//relPos *= oldOrnt.Inverse()*relPos;
cur->setPosition(relPos+oldPos);
}
mNode->setScale(scale);
}
void GroupObject::modScale(Ogre::Vector3 scale)
{
std::vector<GameObject*>::const_iterator itr;
Ogre::Quaternion oldOrnt = mNode->getOrientation();
Ogre::Vector3 oldPos = mNode->getPosition();
for(itr = groupedObjects.begin();itr != groupedObjects.end();itr++)
{
GameObject *cur = *itr;
Ogre::Vector3 relPos = cur->getPosition()-oldPos;
cur->modScale(scale);
relPos = oldOrnt.Inverse()*relPos;
relPos *= scale;
relPos = oldOrnt*relPos;
cur->setPosition(relPos+oldPos);
}
mNode->setScale(rootScale * scale);
}
Ogre::Vector3 GroupObject::getScale()
{
return mNode->getScale();// groupedObjects[0]->getScale();
}
void GroupObject::updateBody()
{
std::vector<GameObject*>::const_iterator itr;
for(itr = groupedObjects.begin();itr != groupedObjects.end();itr++)
{
GameObject *cur = *itr;
cur->updateBody();
}
}
void GroupObject::markSelected(bool mark)
{
std::vector<GameObject*>::const_iterator itr;
isSelected = mark;
for(itr = groupedObjects.begin();itr != groupedObjects.end();itr++)
{
GameObject *cur = *itr;
cur->markSelected(mark);
}
}
void GroupObject::rotate(const Ogre::Vector3& axis, const Ogre::Radian& angle, Ogre::Node::TransformSpace relativeTo)
{
Ogre::Quaternion q;
q.FromAngleAxis(angle,axis);
rotate(q, relativeTo);
}
void GroupObject::rotate(const Ogre::Quaternion& q, Ogre::Node::TransformSpace relativeTo)
{
Ogre::Quaternion oldOrnt = rootOrientation;//getOrientation();
Ogre::Quaternion newOrnt;
switch(relativeTo)
{
case Ogre::Node::TS_WORLD:
case Ogre::Node::TS_PARENT:
// Rotations are normally relative to local axes, transform up
newOrnt = q * oldOrnt;
break;
case Ogre::Node::TS_LOCAL:
// Note the order of the mult, i.e. q comes after
newOrnt = oldOrnt * q;
break;
}
setOrientation(newOrnt);
}
*/ | [
"praecipitator@bd7a9385-7eed-4fd6-88b1-0096df50a1ac"
] | [
[
[
1,
715
]
]
] |
58b991c21e354d5cf78636554ec4ed0af2e8f494 | 3761dcce2ce81abcbe6d421d8729af568d158209 | /include/cybergarage/upnp/device/NotifyListener.h | a057d1376fd82ac343c60a993f326af5cf85301e | [
"BSD-3-Clause"
] | permissive | claymeng/CyberLink4CC | af424e7ca8529b62e049db71733be91df94bf4e7 | a1a830b7f4caaeafd5c2db44ad78fbb5b9f304b2 | refs/heads/master | 2021-01-17T07:51:48.231737 | 2011-04-08T15:10:49 | 2011-04-08T15:10:49 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 555 | h | /******************************************************************
*
* CyberLink for C++
*
* Copyright (C) Satoshi Konno 2002-2003
*
* File: NotifyListener.h
*
* Revision;
*
* 07/05/03
* - first revision
*
******************************************************************/
#ifndef _CLINK_NOTIFYLISTENER_H_
#define _CLINK_NOTIFYLISTENER_H_
#include <cybergarage/upnp/ssdp/SSDPPacket.h>
namespace CyberLink {
class NotifyListener
{
public:
virtual void deviceNotifyReceived(SSDPPacket *ssdpPacket) = 0;
};
}
#endif
| [
"skonno@b944b01c-6696-4570-ab44-a0e08c11cb0e"
] | [
[
[
1,
32
]
]
] |
954edfad18f0b6f70398c16f13c6645a25988d45 | 27687dfacdfa03f7a1f509e36e848fa1767f47b3 | /XLoader/config.cpp | 87294861054a9a30223ea0548865bb4d767acacf | [] | no_license | Gbps/gmod | 7f11a79e439c2c63233ad9dcc2e3c32e6c8ceb95 | 125f7c94e5732abc4dac441181bc3bad51c7aa23 | refs/heads/master | 2022-06-20T18:36:45.742134 | 2011-08-04T03:08:58 | 2011-08-04T03:08:58 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,882 | cpp | #include "config.h"
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
Config::Config(string name, string parentDebugInfo) {
debugInfo = parentDebugInfo + ", " + name;
}
Config::Config(string configFile, char** envp) {
while (*envp) {
string envEntry = *envp;
size_t pos = envEntry.find('=');
if (pos != string::npos) {
string name = envEntry.substr(0, pos);
string value = envEntry.substr(pos+1, string::npos);
envSymbols[name] = value;
}
++envp;
}
debugInfo = configFile;
groupStack.push_front(this);
FILE* in = fopen(configFile.c_str(), "r");
if (!in) {
cerr << "cannot open input file '" << configFile << "'" << endl;
exit(2);
}
char buff[1024];
while (fgets(buff, 1024, in)) {
string line=buff;
if ( (line.length() > 2) && (line[0] != '#') && (line.find(')') == string::npos) ) {
string name;
string value;
split(line, name, value, '=');
if (value == "(") {
Config* newGroup = new Config(name, debugInfo);
groupStack.front()->groups[name] = newGroup;
groupStack.push_front(newGroup);
} else {
for (list<Config*>::reverse_iterator i = groupStack.rbegin(); i != groupStack.rend(); ++i) {
(*i)->symbolExpand(value);
}
envSymbolExpand(value);
groupStack.front()->add(name, value);
}
}
if ( (line.length() > 0) && (line[0] != '#') && (line.find(')') != string::npos) ) {
groupStack.pop_front();
}
}
fclose(in);
}
Config::~Config() {
for (map<string, Config*>::iterator i = groups.begin(); i != groups.end(); ++i) {
delete i->second;
}
}
void Config::add(string name, string value) {
symbols[name] = value;
}
void Config::split(string in, string& left, string& right, char c) {
size_t pos = in.find_first_of(c);
if(pos == string::npos) {
left = in;
trim(left);
right = "";
} else if (pos <= 1) {
left = "";
right = in.substr(pos+1, string::npos);
trim(right);
} else {
left = in.substr(0, pos-1);
trim(left);
right = in.substr(pos+1, string::npos);
trim(right);
}
}
void Config::trim(string& s) {
while ( (s.length() > 1) && ( (s[0] == ' ') || (s[0] =='\t') ) ) {
s = s.substr(1, string::npos);
}
while ( (s.length() > 1) &&
( (s[s.length()-1] == ' ') ||
(s[s.length()-1] == '\t') ||
(s[s.length()-1] == '\n') ||
(s[s.length()-1] == '\r') ) ) {
s = s.substr(0, s.length()-1);
}
if ( (s.length() > 1) && (s[0] == '"') ) {
s = s.substr(1, string::npos);
}
if ( (s.length() > 1) && (s[s.length()-1] == '"') ) {
s = s.substr(0, s.length()-1);
}
}
void Config::symbolExpand(string& s) {
symbolExpand(symbols, s);
}
void Config::envSymbolExpand(string& s) {
symbolExpand(envSymbols, s);
}
void Config::symbolExpand(map<string, string>& symbols, string& s) {
bool expanded;
do {
expanded = false;
for (map<string, string>::iterator i = symbols.begin(); i != symbols.end(); ++i) {
string search = "%" + i->first + "%";
string replace = i->second;
size_t pos = s.find(search);
if (pos != string::npos) {
expanded = true;
s.replace(pos, search.length(), replace);
}
}
} while (expanded);
}
string Config::pString(string name) {
map<string, string>::iterator i = symbols.find(name);
if (i == symbols.end()) {
exit(4);
}
return i->second;
}
bool Config::pBool(string name) {
string val = pString(name);
if ( (val == "yes") ||
(val == "Yes") ||
(val == "YES") ||
(val == "true") ||
(val == "True") ||
(val == "TRUE"))
{
return true;
}
return false;
}
double Config::pDouble(string name) {
string val = pString(name);
return atof(val.c_str());
}
int Config::pInt(string name) {
string val = pString(name);
return atoi(val.c_str());
} | [
"cowmonkey111@ea4bc6c7-d654-2506-312e-aa9fc04bc719"
] | [
[
[
1,
168
]
]
] |
3c5d4a09da426fbc9009521742bb42fd8e938bbe | 478570cde911b8e8e39046de62d3b5966b850384 | /apicompatanamdw/bcdrivers/os/ossrv/stdcpp/apps/BCTypeInfo/src/BCTypeInfoBlocks.cpp | 9ea410c527b02305d7d718661f46d3776345f3d0 | [] | 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 | 4,465 | cpp | /*
* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/
// [INCLUDE FILES] - do not remove
#include <e32svr.h>
#include <StifParser.h>
#include <Stiftestinterface.h>
#include "BCTypeInfo.h"
//Headers exported from Type info API
#include <string>
#include <typeinfo.h>
#include <typeinfo>
// EXTERNAL DATA STRUCTURES
//extern ?external_data;
// EXTERNAL FUNCTION PROTOTYPES
//extern ?external_function( ?arg_type,?arg_type );
// CONSTANTS
//const ?type ?constant_var = ?constant;
// MACROS
//#define ?macro ?macro_def
// LOCAL CONSTANTS AND MACROS
//const ?type ?constant_var = ?constant;
//#define ?macro_name ?macro_def
// MODULE DATA STRUCTURES
//enum ?declaration
//typedef ?declaration
// LOCAL FUNCTION PROTOTYPES
//?type ?function_name( ?arg_type, ?arg_type );
// FORWARD DECLARATIONS
//class ?FORWARD_CLASSNAME;
// ============================= LOCAL FUNCTIONS ===============================
// -----------------------------------------------------------------------------
// ?function_name ?description.
// ?description
// Returns: ?value_1: ?description
// ?value_n: ?description_line1
// ?description_line2
// -----------------------------------------------------------------------------
//
/*
?type ?function_name(
?arg_type arg, // ?description
?arg_type arg) // ?description
{
?code // ?comment
// ?comment
?code
}
*/
// ============================ MEMBER FUNCTIONS ===============================
// -----------------------------------------------------------------------------
// CBCTypeInfo::Delete
// Delete here all resources allocated and opened from test methods.
// Called from destructor.
// -----------------------------------------------------------------------------
//
void CBCTypeInfo::Delete()
{
}
// -----------------------------------------------------------------------------
// CBCTypeInfo::RunMethodL
// Run specified method. Contains also table of test mothods and their names.
// -----------------------------------------------------------------------------
//
TInt CBCTypeInfo::RunMethodL(
CStifItemParser& aItem )
{
static TStifFunctionInfo const KFunctions[] =
{
// Copy this line for every implemented function.
// First string is the function name used in TestScripter script file.
// Second is the actual implementation member function.
ENTRY( "TestAPI", CBCTypeInfo::TestAPI ),
//ADD NEW ENTRY HERE
// [test cases entries] - Do not remove
};
const TInt count = sizeof( KFunctions ) /
sizeof( TStifFunctionInfo );
return RunInternalL( KFunctions, count, aItem );
}
// -----------------------------------------------------------------------------
// CBCTypeInfo::ExampleL
// Example test method function.
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
TInt CBCTypeInfo::TestAPI( CStifItemParser& aItem )
{
// Print to UI
_LIT( KBCTypeInfo, "BCTypeInfo" );
_LIT( KExample, "In Example" );
TestModuleIf().Printf( 0, KBCTypeInfo, KExample );
// Print to log file
iLog->Log( KExample );
_LIT( KResult, "No functions to be tested");
_LIT( KComment, "Type Info API has passed");
TestModuleIf().Printf( 0, KResult, KComment);
return KErrNone;
}
// -----------------------------------------------------------------------------
// CBCTypeInfo::?member_function
// ?implementation_description
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
/*
TInt CBCTypeInfo::?member_function(
CItemParser& aItem )
{
?code
}
*/
// ========================== OTHER EXPORTED FUNCTIONS =========================
// None
// [End of File] - Do not remove
| [
"none@none"
] | [
[
[
1,
161
]
]
] |
ea77d407b68debf2bf687c404949700dd60d7e40 | c13ef26a8b4b1e196c6c593a73520787a7c15b80 | /samples_atistream/Mandelbrot/Mandelbrot.hpp | cd1040c220e68870fba532005717b1edc3094382 | [] | no_license | ajaykumarkannan/simulation-opencl | 73072dcdacf5f3c93e0c038caedb60b479839327 | 53d00629358d3a2b1135f4daf0c327436fd9ed79 | refs/heads/master | 2021-01-23T08:39:00.347158 | 2010-03-09T15:43:50 | 2010-03-09T15:43:50 | 37,275,925 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,347 | hpp | /* ============================================================
Copyright (c) 2009 Advanced Micro Devices, Inc. All rights reserved.
Redistribution and use of this material is permitted under the following
conditions:
Redistributions must retain the above copyright notice and all terms of this
license.
In no event shall anyone redistributing or accessing or using this material
commence or participate in any arbitration or legal action relating to this
material against Advanced Micro Devices, Inc. or any copyright holders or
contributors. The foregoing shall survive any expiration or termination of
this license or any agreement or access or use related to this material.
ANY BREACH OF ANY TERM OF THIS LICENSE SHALL RESULT IN THE IMMEDIATE REVOCATION
OF ALL RIGHTS TO REDISTRIBUTE, ACCESS OR USE THIS MATERIAL.
THIS MATERIAL IS PROVIDED BY ADVANCED MICRO DEVICES, INC. AND ANY COPYRIGHT
HOLDERS AND CONTRIBUTORS "AS IS" IN ITS CURRENT CONDITION AND WITHOUT ANY
REPRESENTATIONS, GUARANTEE, OR WARRANTY OF ANY KIND OR IN ANY WAY RELATED TO
SUPPORT, INDEMNITY, ERROR FREE OR UNINTERRUPTED OPERA TION, OR THAT IT IS FREE
FROM DEFECTS OR VIRUSES. ALL OBLIGATIONS ARE HEREBY DISCLAIMED - WHETHER
EXPRESS, IMPLIED, OR STATUTORY - INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
ACCURACY, COMPLETENESS, OPERABILITY, QUALITY OF SERVICE, OR NON-INFRINGEMENT.
IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. OR ANY COPYRIGHT HOLDERS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, PUNITIVE,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, REVENUE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED OR BASED ON ANY THEORY OF LIABILITY
ARISING IN ANY WAY RELATED TO THIS MATERIAL, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE. THE ENTIRE AND AGGREGATE LIABILITY OF ADVANCED MICRO DEVICES,
INC. AND ANY COPYRIGHT HOLDERS AND CONTRIBUTORS SHALL NOT EXCEED TEN DOLLARS
(US $10.00). ANYONE REDISTRIBUTING OR ACCESSING OR USING THIS MATERIAL ACCEPTS
THIS ALLOCATION OF RISK AND AGREES TO RELEASE ADVANCED MICRO DEVICES, INC. AND
ANY COPYRIGHT HOLDERS AND CONTRIBUTORS FROM ANY AND ALL LIABILITIES,
OBLIGATIONS, CLAIMS, OR DEMANDS IN EXCESS OF TEN DOLLARS (US $10.00). THE
FOREGOING ARE ESSENTIAL TERMS OF THIS LICENSE AND, IF ANY OF THESE TERMS ARE
CONSTRUED AS UNENFORCEABLE, FAIL IN ESSENTIAL PURPOSE, OR BECOME VOID OR
DETRIMENTAL TO ADVANCED MICRO DEVICES, INC. OR ANY COPYRIGHT HOLDERS OR
CONTRIBUTORS FOR ANY REASON, THEN ALL RIGHTS TO REDISTRIBUTE, ACCESS OR USE
THIS MATERIAL SHALL TERMINATE IMMEDIATELY. MOREOVER, THE FOREGOING SHALL
SURVIVE ANY EXPIRATION OR TERMINATION OF THIS LICENSE OR ANY AGREEMENT OR
ACCESS OR USE RELATED TO THIS MATERIAL.
NOTICE IS HEREBY PROVIDED, AND BY REDISTRIBUTING OR ACCESSING OR USING THIS
MATERIAL SUCH NOTICE IS ACKNOWLEDGED, THAT THIS MATERIAL MAY BE SUBJECT TO
RESTRICTIONS UNDER THE LAWS AND REGULATIONS OF THE UNITED STATES OR OTHER
COUNTRIES, WHICH INCLUDE BUT ARE NOT LIMITED TO, U.S. EXPORT CONTROL LAWS SUCH
AS THE EXPORT ADMINISTRATION REGULATIONS AND NATIONAL SECURITY CONTROLS AS
DEFINED THEREUNDER, AS WELL AS STATE DEPARTMENT CONTROLS UNDER THE U.S.
MUNITIONS LIST. THIS MATERIAL MAY NOT BE USED, RELEASED, TRANSFERRED, IMPORTED,
EXPORTED AND/OR RE-EXPORTED IN ANY MANNER PROHIBITED UNDER ANY APPLICABLE LAWS,
INCLUDING U.S. EXPORT CONTROL LAWS REGARDING SPECIFICALLY DESIGNATED PERSONS,
COUNTRIES AND NATIONALS OF COUNTRIES SUBJECT TO NATIONAL SECURITY CONTROLS.
MOREOVER, THE FOREGOING SHALL SURVIVE ANY EXPIRATION OR TERMINATION OF ANY
LICENSE OR AGREEMENT OR ACCESS OR USE RELATED TO THIS MATERIAL.
NOTICE REGARDING THE U.S. GOVERNMENT AND DOD AGENCIES: This material is
provided with "RESTRICTED RIGHTS" and/or "LIMITED RIGHTS" as applicable to
computer software and technical data, respectively. Use, duplication,
distribution or disclosure by the U.S. Government and/or DOD agencies is
subject to the full extent of restrictions in all applicable regulations,
including those found at FAR52.227 and DFARS252.227 et seq. and any successor
regulations thereof. Use of this material by the U.S. Government and/or DOD
agencies is acknowledgment of the proprietary rights of any copyright holders
and contributors, including those of Advanced Micro Devices, Inc., as well as
the provisions of FAR52.227-14 through 23 regarding privately developed and/or
commercial computer software.
This license forms the entire agreement regarding the subject matter hereof and
supersedes all proposals and prior discussions and writings between the parties
with respect thereto. This license does not affect any ownership, rights, title,
or interest in, or relating to, this material. No terms of this license can be
modified or waived, and no breach of this license can be excused, unless done
so in a writing signed by all affected parties. Each term of this license is
separately enforceable. If any term of this license is determined to be or
becomes unenforceable or illegal, such term shall be reformed to the minimum
extent necessary in order for this license to remain in effect in accordance
with its terms as modified by such reformation. This license shall be governed
by and construed in accordance with the laws of the State of Texas without
regard to rules on conflicts of law of any state or jurisdiction or the United
Nations Convention on the International Sale of Goods. All disputes arising out
of this license shall be subject to the jurisdiction of the federal and state
courts in Austin, Texas, and all defenses are hereby waived concerning personal
jurisdiction and venue of these courts.
============================================================ */
#ifndef MANDELBROT_H_
#define MANDELBROT_H_
#include <CL/cl.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <SDKUtil/SDKCommon.hpp>
#include <SDKUtil/SDKApplication.hpp>
#include <SDKUtil/SDKCommandArgs.hpp>
#include <SDKUtil/SDKFile.hpp>
/**
* Mandelbrot
* Class implements OpenCL Mandelbrot sample
* Derived from SDKSample base class
*/
class Mandelbrot : public SDKSample
{
cl_uint seed; /**< Seed value for random number generation */
cl_double setupTime; /**< Time for setting up Opencl */
cl_double totalKernelTime; /**< Time for kernel execution */
cl_double totalProgramTime; /**< Time for program execution */
cl_double referenceKernelTime; /**< Time for reference implementation */
cl_int *verificationOutput; /**< Output array from reference implementation */
cl_int scale_int; /**< for command line arguments */
cl_float scale; /**< paramters of mandelbrot */
cl_uint maxIterations; /**< paramters of mandelbrot */
cl_context context; /**< CL context */
cl_device_id *devices; /**< CL device list */
cl_mem outputBuffer; /**< CL memory buffer */
cl_command_queue commandQueue; /**< CL command queue */
cl_program program; /**< CL program */
cl_kernel kernel; /**< CL kernel */
cl_int width; /**< width of the output image */
cl_int height; /**< height of the output image */
public:
cl_int *output; /**< Output array */
public:
/**
* Constructor
* Initialize member variables
* @param name name of sample (string)
*/
Mandelbrot(std::string name)
: SDKSample(name) {
seed = 123;
output = NULL;
verificationOutput = NULL;
scale = 3.0f;
scale_int = (int)scale;
maxIterations = 20;
width = 256;
setupTime = 0;
totalKernelTime = 0;
}
/**
* Constructor
* Initialize member variables
* @param name name of sample (const char*)
*/
Mandelbrot(const char* name)
: SDKSample(name) {
seed = 123;
output = NULL;
verificationOutput = NULL;
scale = 3.0f;
scale_int = (int)scale;
maxIterations = 20;
width = 256;
setupTime = 0;
totalKernelTime = 0;
}
/**
* Allocate and initialize host memory array with random values
* @return 1 on success and 0 on failure
*/
int setupMandelbrot();
/**
* OpenCL related initialisations.
* Set up Context, Device list, Command Queue, Memory buffers
* Build CL kernel program executable
* @return 1 on success and 0 on failure
*/
int setupCL();
/**
* Set values for kernels' arguments, enqueue calls to the kernels
* on to the command queue, wait till end of kernel execution.
* Get kernel start and end time if timing is enabled
* @return 1 on success and 0 on failure
*/
int runCLKernels();
/**
* Mandelbrot image generated with CPU reference implementation
* @param verificationOutput mandelbrot images is stored in this
* @param mandelbrotImage mandelbrot images is stored in this
* @param scale Represents the distance from which the fractal
* is being seen if this is greater more area and
* less detail is seen
* @param maxIterations More iterations gives more accurate mandelbrot image
* @param width size of the image
*/
void mandelbrotCPUReference(cl_int * verificationOutput,
cl_float scale,
cl_uint maxIterations,
cl_int width);
/**
* Override from SDKSample. Print sample stats.
*/
void printStats();
/**
* Override from SDKSample. Initialize
* command line parser, add custom options
*/
int initialize();
/**
* Override from SDKSample, adjust width and height
* of execution domain, perform all sample setup
*/
int setup();
/**
* Override from SDKSample
* Run OpenCL Mandelbrot Sample
*/
int run();
/**
* Override from SDKSample
* Cleanup memory allocations
*/
int cleanup();
/**
* Override from SDKSample
* Verify against reference implementation
*/
int verifyResults();
/*
* get window Width
*/
cl_uint getWidth(void);
/*
* get window Height
*/
cl_uint getHeight(void);
/*
* get pixels to be displayed
*/
cl_int * getPixels(void);
/*
* if showWindow returns true then a window with mandelbrot set is displayed
*/
cl_bool showWindow(void);
};
#endif
| [
"juergen.broder@c62875e2-cac2-11de-a9c8-2fbcfba63733"
] | [
[
[
1,
272
]
]
] |
31491afe76ae39cbac721a733ca56f954bd9d612 | 13314d3b1af22579685991a2cd7bfb68e67ba80e | /adware/ie/sysserver/Adware/stdafx.h | 82ed883b1a41edd02dee2cacd93b9f8cc048f2cc | [] | no_license | MZ-EUR/h4zy | f38c8e38d7e0c9770c42f429ff4f091604481826 | 2bcc791a0491f92cec03d538c5f7c01e76b1bb23 | refs/heads/master | 2021-01-12T00:03:03.815891 | 2011-05-26T01:21:54 | 2011-05-26T01:21:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 565 | h | // stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once
#ifndef STRICT
#define STRICT
#endif
#include "targetver.h"
#define _ATL_APARTMENT_THREADED
#define _ATL_NO_AUTOMATIC_NAMESPACE
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
#include "resource.h"
#include <atlbase.h>
#include <atlcom.h>
#include <atlctl.h>
#include <iepmapi.h>
#include <Wininet.h>
using namespace ATL;
| [
"[email protected]"
] | [
[
[
1,
25
]
]
] |
2a8c49d0a3a0328d7a973e9d094ab04b13a644c3 | fcdddf0f27e52ece3f594c14fd47d1123f4ac863 | /terralib/src/terralib/drivers/qt/TeQtAnimaThread.h | 15f28f272f3b2eec9400d007c70f96e36551f13c | [] | no_license | radtek/terra-printer | 32a2568b1e92cb5a0495c651d7048db6b2bbc8e5 | 959241e52562128d196ccb806b51fda17d7342ae | refs/heads/master | 2020-06-11T01:49:15.043478 | 2011-12-12T13:31:19 | 2011-12-12T13:31:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,069 | h | #ifndef __TERRALIB_INTERNAL_QTANIMATHREAD_H
#define __TERRALIB_INTERNAL_QTANIMATHREAD_H
#include <qthread.h>
#include<qdir.h>
#include<qstringlist.h>
#include <TeAppUtilsDefines.h>
class TeQtCanvas;
class Animation;
class TLAPPUTILS_DLL TeQtAnimaThread : public QThread
{
public:
TeQtAnimaThread(){
canvas_ = 0;
pause_ = false;
stop_ = true;
rate_ = 1;
frame_ = 0;
frames_ = 0;
pauseFrame_ = 0;
}
void run();
void stop();
void pause(bool b) {pause_ = b;}
bool pause() {return pause_;}
void frame(int n) {frame_ = n;}
int frame() {return frame_;}
void frames(int n) {frames_ = n;}
int frames() {return frames_;}
int pauseFrame(int pf) {return pauseFrame_ = pf;}
void canvas(TeQtCanvas* c) {canvas_ = c;}
void setAnimation(Animation* a, QDir d);
void showFrame(int i);
private:
bool pause_;
bool stop_;
int rate_;
int frame_;
int frames_;
int pauseFrame_;
TeQtCanvas* canvas_;
Animation* animation_;
QDir dir_;
QStringList fileList_;
void sleep(int t);
};
#endif
| [
"[email protected]@58180da6-ba8b-8960-36a5-00cc02a3ddec"
] | [
[
[
1,
51
]
]
] |
6269ad925dab2a4128d269437e84ac01a4a2f74e | 5a05acb4caae7d8eb6ab4731dcda528e2696b093 | /ThirdParty/luabind/luabind/detail/ref.hpp | e66653677ffde98f6c459564ee00c62180127d29 | [] | no_license | andreparker/spiralengine | aea8b22491aaae4c14f1cdb20f5407a4fb725922 | 36a4942045f49a7255004ec968b188f8088758f4 | refs/heads/master | 2021-01-22T12:12:39.066832 | 2010-05-07T00:02:31 | 2010-05-07T00:02:31 | 33,547,546 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,330 | hpp | // Copyright (c) 2003 Daniel Wallin and Arvid Norberg
// 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 LUABIND_REF_HPP_INCLUDED
#define LUABIND_REF_HPP_INCLUDED
#include <cassert>
#include <algorithm>
#include <luabind/config.hpp>
#include <luabind/lua_include.hpp>
struct lua_State;
namespace luabind
{
#if LUA_VERSION_NUM >= 501
#define LUA_REFNIL (-1)
#undef luaL_setn
#undef luaL_getn
#endif
namespace detail
{
int LUABIND_API ref( lua_State *L );
void LUABIND_API unref( lua_State *L, int ref );
inline void getref( lua_State* L, int r )
{
lua_rawgeti( L, LUA_REGISTRYINDEX, r );
}
struct lua_reference
{
lua_reference( lua_State* L_ = 0 )
: L( L_ )
, m_ref( LUA_NOREF )
{}
lua_reference( lua_reference const& r )
: L( r.L )
, m_ref( LUA_NOREF )
{
if ( !r.is_valid() )
return;
r.get( L );
set( L );
}
~lua_reference()
{
reset();
}
lua_State* state() const
{
return L;
}
void operator=( lua_reference const& r )
{
// TODO: self assignment problems
reset();
if ( !r.is_valid() )
return;
r.get( r.state() );
set( r.state() );
}
bool is_valid() const
{
return m_ref != LUA_NOREF;
}
void set( lua_State* L_ )
{
reset();
L = L_;
m_ref = ref( L );
}
void replace( lua_State* L_ )
{
lua_rawseti( L_, LUA_REGISTRYINDEX, m_ref );
}
// L may not be the same pointer as
// was used when creating this reference
// since it may be a thread that shares
// the same globals table.
void get( lua_State* L_ ) const
{
assert( m_ref != LUA_NOREF );
assert( L_ );
getref( L_, m_ref );
}
void reset()
{
if ( L && m_ref != LUA_NOREF )
unref( L, m_ref );
m_ref = LUA_NOREF;
}
void swap( lua_reference& r )
{
assert( r.L == L );
std::swap( r.m_ref, m_ref );
}
private:
lua_State* L;
int m_ref;
};
}
}
#endif // LUABIND_REF_HPP_INCLUDED
| [
"DreLnBrown@e933ee44-1dc6-11de-9e56-bf19dc6c588e"
] | [
[
[
1,
140
]
]
] |
3b754ba75ad1acc8955241b39101a38fc6559410 | 10904ee31435dcd301484b0e8337504ce87368e4 | /Face/Face/CheckDlg.h | 8817a8b628fb944b108e8d9ec87a45b2926cd46d | [] | no_license | foolin/fdetection | c8fea777321d7aa1d674d4402c43ba52d56cfa7c | b8827751db7deb2d5e10acc22e42d3494e4af30a | refs/heads/master | 2021-01-16T20:36:01.491468 | 2010-05-24T04:22:21 | 2010-05-24T04:22:21 | 32,785,465 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,231 | h | #pragma once
#include "Config.h"
#include "Check.h"
#include "Detect.h"
#include "afxcmn.h"
#include "afxwin.h"
#define SHOWIMAGE_WIDTH 128 //显示图片大小
#define SHOWIMAGE_HEIGHT 128
// CCheckDlg 对话框
class CCheckDlg : public CDialog
{
DECLARE_DYNAMIC(CCheckDlg)
public:
CCheckDlg(CWnd* pParent = NULL); // 标准构造函数
virtual ~CCheckDlg();
// 对话框数据
enum { IDD = IDD_CheckDlg };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()
public:
int picture_num; //为了实现依次打开3张图片,让picture_num统计当前打开第几张图
public:
afx_msg void OnBnClickedCheckdlgOpenpicture();
public:
void ShowImage( IplImage* img, UINT ID );
private:
IplImage* m_showImage;
CCheck m_objCheck;
CDetect m_objDetect;
CConfig m_objConfig;
CString m_strAppPath;
bool IsAddFace; //判断是否已加载人脸库
bool IsOpen; //判断开始识别之前,是否已将图片载入
public:
afx_msg void OnBnClickedCheckdlgShell();
virtual BOOL OnInitDialog();
afx_msg void OnBnClickedCheckdlgAddface();
CProgressCtrl m_AddFaceProgress;
CStatic m_AddFacesTips;
};
| [
"[email protected]@946ed153-6c77-64d3-6a7d-126bc18e93db",
"[email protected]@946ed153-6c77-64d3-6a7d-126bc18e93db"
] | [
[
[
1,
1
],
[
7,
7
],
[
10,
27
],
[
51,
51
]
],
[
[
2,
6
],
[
8,
9
],
[
28,
50
]
]
] |
8c3571982102e324fc60737e55572451dfe500fc | 7a0e9ebcfbad32f8346502195379e31fdbaf7b06 | /benchmark/sort-cpp.cpp | 47b466169a80f8b98d38662e123cecd4797d945e | [
"MIT"
] | permissive | erde74/gel2 | 77d88af4cbd05bbd2b02c268f6c7104d5c1a2073 | de0fe5bad795078c019f611937a2c074e34f02e8 | refs/heads/master | 2021-12-08T14:59:39.671775 | 2006-11-14T01:02:16 | 2006-11-14T01:02:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,034 | cpp | #include <assert.h>
#include <stdio.h>
#include <stdlib.h>
class Random {
static int r_;
public:
static int Next() {
r_ = r_ * 69069;
return r_;
}
};
/* static */ int Random::r_ = 1;
class Node {
public:
int i_;
Node *next_;
Node(int i, Node *next) { i_ = i; next_ = next; }
};
class Sort {
static Node *RandomList(int count) {
Node *first = NULL;
for (int x = 0 ; x < count ; ++x)
first = new Node(Random::Next(), first);
return first;
}
static Node *Merge(Node *a, Node *b) {
Node *head = NULL, *tail = NULL;
while (a != NULL && b != NULL) {
Node *top;
if (a->i_ < b->i_) {
top = a;
a = top->next_;
} else {
top = b;
b = top->next_;
}
top->next_ = NULL;
if (head == NULL)
head = tail = top;
else {
tail->next_ = top;
tail = top;
}
}
Node *rest = (a == NULL) ? b : a;
if (tail == NULL)
return rest;
tail->next_ = rest;
return head;
}
static Node *MergeSort(Node *a) {
if (a == NULL || a->next_ == NULL) return a;
Node *c = a;
Node *b = c->next_;
while (b != NULL && b->next_ != NULL) {
c = c->next_;
b = b->next_->next_;
}
Node *d = c->next_;
c->next_ = NULL;
return Merge(MergeSort(a), MergeSort(d));
}
public:
static void Main(int iterations) {
for (int iter = 1; iter <= iterations; ++iter) {
printf("iteration %d\n", iter);
Node *n = RandomList(1000000);
puts(" sorting...");
n = MergeSort(n);
puts(" deleting...");
while (n != NULL) {
Node *next = n->next_;
if (next != NULL && n->i_ > next->i_) {
puts("failed");
return;
}
delete n;
n = next;
}
}
puts("succeeded");
}
};
int main(int argc, char *argv[]) {
Sort::Main(argc >= 2 ? atoi(argv[1]) : 10);
return 0;
}
| [
"adamdingle@64e5f164-cc20-0410-b742-055ae0d6408a"
] | [
[
[
1,
98
]
]
] |
00cc2a837f771d4c16555738ea380fa15a8f5c85 | 0f8559dad8e89d112362f9770a4551149d4e738f | /Wall_Destruction/Havok/Source/Common/Base/Math/SweptTransform/hkSweptTransform.h | 8349472c8fb79a200d99916736d46e71f82c89e6 | [] | 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 | 4,312 | 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_MATH_SWEPTTRANSFORM_H
#define HK_MATH_SWEPTTRANSFORM_H
#ifndef HK_MATH_MATH_H
# error Please include Common/Base/hkBase.h instead of this file.
#endif
/// Represents a rotation and translation over time.
/// It basically stores the position of the mass center and the rotation at
/// two physics frames. In addition to this it also stores the time of those
/// frames and the center of mass in local space.
/// With that information, it is easy to interpolate the position between the
/// two frames.
/// See hkSweptTransformUtil for more functions.
class hkSweptTransform
{
public:
HK_DECLARE_REFLECTION();
HK_DECLARE_NONVIRTUAL_CLASS_ALLOCATOR(HK_MEMORY_CLASS_MATH, hkSweptTransform);
/// Default constructor - all elements are uninitialized. Use hkSweptTransform::initSweptTransform() to initialize
HK_FORCE_INLINE hkSweptTransform() { }
public:
/// inline version of approxTransformAt
HK_FORCE_INLINE void _approxTransformAt( hkTime time, hkTransform& transformOut ) const;
/// Approximate a transform for any given time T.
/// If T is between t0 and t1 of the motion state than the algorithm is doing in interpolation
/// otherwise the result is an extrapolation.
/// Note: This function works has a lower accuracy than hkSweptTransformUtil::lerp2 as used by Havoks collision detection
void approxTransformAt( hkTime time, hkTransform& transformOut ) const;
/// get an interpolation value from a given time
HK_FORCE_INLINE hkReal getInterpolationValue( hkTime t ) const;
// get an interpolation value from a given time= t+deltaTimeAddon. This has a higher precision than getInterpolationValue
HK_FORCE_INLINE hkReal getInterpolationValueHiAccuracy( hkTime t, hkReal deltaTimeAddon ) const;
/// Get time0
HK_FORCE_INLINE hkTime getBaseTime() const;
/// Get 1.0f/(time1-time0) if the object is active
/// (actually if it has been integrated since its activation, addition to hkpWorld, or
/// motion type change)
/// else 0.0f
HK_FORCE_INLINE hkReal getInvDeltaTime() const;
/// Initialized this class given a position and a rotation
void initSweptTransform( const hkVector4& position, const hkQuaternion& rotation );
public:
/// the position of the rotational center at t0 in world space. Note: the w component is used to store time 0
hkVector4 m_centerOfMass0;
/// the position of the rotational center at t1 in world space.
/// Note:
/// - If the object is moving active, the w component is used to store 1.0f/(time1 - time0)
/// - If the object is fixed or deactivated, the w component is set to 0.0f
hkVector4 m_centerOfMass1;
/// the orientation at t0
hkQuaternion m_rotation0;
/// the orientation at t1
hkQuaternion m_rotation1;
/// the rotational center = e.g. the center of mass) in local space
/// the .w component should be set to 0 if the center is 0 (allows for some platform optimizations)
/// and set to !=0 if the center is != 0
hkVector4 m_centerOfMassLocal;
};
#endif //HK_MATH_SWEPTTRANSFORM_H
/*
* Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20091222)
*
* Confidential Information of Havok. (C) Copyright 1999-2009
* Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok
* Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership
* rights, and intellectual property rights in the Havok software remain in
* Havok and/or its suppliers.
*
* Use of this software for evaluation purposes is subject to and indicates
* acceptance of the End User licence Agreement for this product. A copy of
* the license is included with this software and is also available at www.havok.com/tryhavok.
*
*/
| [
"[email protected]"
] | [
[
[
1,
100
]
]
] |
64f8215aaf8e8748d8a5944449aaff4595357c24 | 814b49df11675ac3664ac0198048961b5306e1c5 | /Code/Engine/Utilities/include/ComponentSoundListener.h | c88fa82324b7a61cbc3e9fe1a51818e124d7d320 | [] | no_license | Atridas/biogame | f6cb24d0c0b208316990e5bb0b52ef3fb8e83042 | 3b8e95b215da4d51ab856b4701c12e077cbd2587 | refs/heads/master | 2021-01-13T00:55:50.502395 | 2011-10-31T12:58:53 | 2011-10-31T12:58:53 | 43,897,729 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 829 | h | #pragma once
#ifndef __COMPONENT_SOUND_LISTENER__
#define __COMPONENT_SOUND_LISTENER__
#include "base.h"
#include "EntityDefines.h"
class CComponentObject3D;
class CComponent3rdPSCamera;
class CComponentSoundListener:
public CBaseComponent
{
public:
~CComponentSoundListener() {Done();}
CBaseComponent::Type GetType() {return CBaseComponent::ECT_SOUND_LISTENER;};
static CBaseComponent::Type GetStaticType() {return CBaseComponent::ECT_SOUND_LISTENER;};
static CComponentSoundListener* AddToEntity(CGameEntity* _pEntity);
void Update(float _fDeltaTime);
protected:
CComponentSoundListener():m_pO3D(0),m_pCamera(0) {};
bool Init(CGameEntity* _pEntity);
virtual void Release() {};
private:
CComponentObject3D* m_pO3D;
CComponent3rdPSCamera* m_pCamera;
};
#endif
| [
"sergivalls@576ee6d0-068d-96d9-bff2-16229cd70485"
] | [
[
[
1,
36
]
]
] |
465d00959189c6bb7fbc165d7dbecb164ee09651 | f2cf9ead30a7298b3c1ec672ac118429fbac0a40 | /Poc1/Source/Poc1.Fast/AssemblyInfo.cpp | 757b700b8bdf909ee6949ac43da16ccabd6de020 | [] | no_license | johann-gambolputty/robotbastards | 3af0b6cf5d948e8bb0450d596ecb5362bfe5a28d | 1874568ada150e04ba83fff2ea067f5a4b63f893 | refs/heads/master | 2021-01-10T09:52:51.773773 | 2009-08-08T00:19:33 | 2009-08-08T00:19:33 | 44,774,636 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,315 | cpp | #include "stdafx.h"
using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::CompilerServices;
using namespace System::Runtime::InteropServices;
using namespace System::Security::Permissions;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly:AssemblyTitleAttribute("Poc1Fast")];
[assembly:AssemblyDescriptionAttribute("")];
[assembly:AssemblyConfigurationAttribute("")];
[assembly:AssemblyCompanyAttribute("")];
[assembly:AssemblyProductAttribute("Poc1Fast")];
[assembly:AssemblyCopyrightAttribute("")];
[assembly:AssemblyTrademarkAttribute("")];
[assembly:AssemblyCultureAttribute("")];
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the value or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly:AssemblyVersionAttribute("1.0.*")];
[assembly:ComVisible(false)];
[assembly:CLSCompliantAttribute(true)];
[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];
| [
"fishy.coder@1e31eab0-7329-0410-87fb-016d5637cad0"
] | [
[
[
1,
41
]
]
] |
9aeae78d2b15b3033605740974e4f42e3ae0071f | b8abaaf2f7a1f94efe3bbc0d14ca49228471b43f | /libs/Box2D/Dynamics/Contacts/b2ContactSolver.cpp | ed17b873156ffd1b58e5d6dbc1317fb176697dcc | [
"Zlib"
] | permissive | julsam/Momoko-Engine | e8cf8a2ad4de6b3925c8c85dc66272e7602e7e73 | 7503a2a81d53bf569eb760c890158d4f38d9baf9 | refs/heads/master | 2021-01-22T12:08:41.642354 | 2011-04-12T11:12:21 | 2011-04-12T11:12:21 | 1,494,202 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 18,385 | cpp | /*
* Copyright (c) 2006-2009 Erin Catto http://www.gphysics.com
*
* 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.
*/
#include "b2ContactSolver.h"
#include "b2Contact.h"
#include "../b2Body.h"
#include "../b2Fixture.h"
#include "../b2World.h"
#include "../../Common/b2StackAllocator.h"
#define B2_DEBUG_SOLVER 0
b2ContactSolver::b2ContactSolver(b2Contact** contacts, int32 contactCount,
b2StackAllocator* allocator, float32 impulseRatio)
{
m_allocator = allocator;
m_constraintCount = contactCount;
m_constraints = (b2ContactConstraint*)m_allocator->Allocate(m_constraintCount * sizeof(b2ContactConstraint));
for (int32 i = 0; i < m_constraintCount; ++i)
{
b2Contact* contact = contacts[i];
b2Fixture* fixtureA = contact->m_fixtureA;
b2Fixture* fixtureB = contact->m_fixtureB;
b2Shape* shapeA = fixtureA->GetShape();
b2Shape* shapeB = fixtureB->GetShape();
float32 radiusA = shapeA->m_radius;
float32 radiusB = shapeB->m_radius;
b2Body* bodyA = fixtureA->GetBody();
b2Body* bodyB = fixtureB->GetBody();
b2Manifold* manifold = contact->GetManifold();
float32 friction = b2MixFriction(fixtureA->GetFriction(), fixtureB->GetFriction());
float32 restitution = b2MixRestitution(fixtureA->GetRestitution(), fixtureB->GetRestitution());
b2Vec2 vA = bodyA->m_linearVelocity;
b2Vec2 vB = bodyB->m_linearVelocity;
float32 wA = bodyA->m_angularVelocity;
float32 wB = bodyB->m_angularVelocity;
b2Assert(manifold->pointCount > 0);
b2WorldManifold worldManifold;
worldManifold.Initialize(manifold, bodyA->m_xf, radiusA, bodyB->m_xf, radiusB);
b2ContactConstraint* cc = m_constraints + i;
cc->bodyA = bodyA;
cc->bodyB = bodyB;
cc->manifold = manifold;
cc->normal = worldManifold.normal;
cc->pointCount = manifold->pointCount;
cc->friction = friction;
cc->localNormal = manifold->localNormal;
cc->localPoint = manifold->localPoint;
cc->radius = radiusA + radiusB;
cc->type = manifold->type;
for (int32 j = 0; j < cc->pointCount; ++j)
{
b2ManifoldPoint* cp = manifold->points + j;
b2ContactConstraintPoint* ccp = cc->points + j;
ccp->normalImpulse = impulseRatio * cp->normalImpulse;
ccp->tangentImpulse = impulseRatio * cp->tangentImpulse;
ccp->localPoint = cp->localPoint;
ccp->rA = worldManifold.points[j] - bodyA->m_sweep.c;
ccp->rB = worldManifold.points[j] - bodyB->m_sweep.c;
float32 rnA = b2Cross(ccp->rA, cc->normal);
float32 rnB = b2Cross(ccp->rB, cc->normal);
rnA *= rnA;
rnB *= rnB;
float32 kNormal = bodyA->m_invMass + bodyB->m_invMass + bodyA->m_invI * rnA + bodyB->m_invI * rnB;
b2Assert(kNormal > b2_epsilon);
ccp->normalMass = 1.0f / kNormal;
b2Vec2 tangent = b2Cross(cc->normal, 1.0f);
float32 rtA = b2Cross(ccp->rA, tangent);
float32 rtB = b2Cross(ccp->rB, tangent);
rtA *= rtA;
rtB *= rtB;
float32 kTangent = bodyA->m_invMass + bodyB->m_invMass + bodyA->m_invI * rtA + bodyB->m_invI * rtB;
b2Assert(kTangent > b2_epsilon);
ccp->tangentMass = 1.0f / kTangent;
// Setup a velocity bias for restitution.
ccp->velocityBias = 0.0f;
float32 vRel = b2Dot(cc->normal, vB + b2Cross(wB, ccp->rB) - vA - b2Cross(wA, ccp->rA));
if (vRel < -b2_velocityThreshold)
{
ccp->velocityBias = -restitution * vRel;
}
}
// If we have two points, then prepare the block solver.
if (cc->pointCount == 2)
{
b2ContactConstraintPoint* ccp1 = cc->points + 0;
b2ContactConstraintPoint* ccp2 = cc->points + 1;
float32 invMassA = bodyA->m_invMass;
float32 invIA = bodyA->m_invI;
float32 invMassB = bodyB->m_invMass;
float32 invIB = bodyB->m_invI;
float32 rn1A = b2Cross(ccp1->rA, cc->normal);
float32 rn1B = b2Cross(ccp1->rB, cc->normal);
float32 rn2A = b2Cross(ccp2->rA, cc->normal);
float32 rn2B = b2Cross(ccp2->rB, cc->normal);
float32 k11 = invMassA + invMassB + invIA * rn1A * rn1A + invIB * rn1B * rn1B;
float32 k22 = invMassA + invMassB + invIA * rn2A * rn2A + invIB * rn2B * rn2B;
float32 k12 = invMassA + invMassB + invIA * rn1A * rn2A + invIB * rn1B * rn2B;
// Ensure a reasonable condition number.
const float32 k_maxConditionNumber = 100.0f;
if (k11 * k11 < k_maxConditionNumber * (k11 * k22 - k12 * k12))
{
// K is safe to invert.
cc->K.col1.Set(k11, k12);
cc->K.col2.Set(k12, k22);
cc->normalMass = cc->K.GetInverse();
}
else
{
// The constraints are redundant, just use one.
// TODO_ERIN use deepest?
cc->pointCount = 1;
}
}
}
}
b2ContactSolver::~b2ContactSolver()
{
m_allocator->Free(m_constraints);
}
void b2ContactSolver::WarmStart()
{
// Warm start.
for (int32 i = 0; i < m_constraintCount; ++i)
{
b2ContactConstraint* c = m_constraints + i;
b2Body* bodyA = c->bodyA;
b2Body* bodyB = c->bodyB;
float32 invMassA = bodyA->m_invMass;
float32 invIA = bodyA->m_invI;
float32 invMassB = bodyB->m_invMass;
float32 invIB = bodyB->m_invI;
b2Vec2 normal = c->normal;
b2Vec2 tangent = b2Cross(normal, 1.0f);
for (int32 j = 0; j < c->pointCount; ++j)
{
b2ContactConstraintPoint* ccp = c->points + j;
b2Vec2 P = ccp->normalImpulse * normal + ccp->tangentImpulse * tangent;
bodyA->m_angularVelocity -= invIA * b2Cross(ccp->rA, P);
bodyA->m_linearVelocity -= invMassA * P;
bodyB->m_angularVelocity += invIB * b2Cross(ccp->rB, P);
bodyB->m_linearVelocity += invMassB * P;
}
}
}
void b2ContactSolver::SolveVelocityConstraints()
{
for (int32 i = 0; i < m_constraintCount; ++i)
{
b2ContactConstraint* c = m_constraints + i;
b2Body* bodyA = c->bodyA;
b2Body* bodyB = c->bodyB;
float32 wA = bodyA->m_angularVelocity;
float32 wB = bodyB->m_angularVelocity;
b2Vec2 vA = bodyA->m_linearVelocity;
b2Vec2 vB = bodyB->m_linearVelocity;
float32 invMassA = bodyA->m_invMass;
float32 invIA = bodyA->m_invI;
float32 invMassB = bodyB->m_invMass;
float32 invIB = bodyB->m_invI;
b2Vec2 normal = c->normal;
b2Vec2 tangent = b2Cross(normal, 1.0f);
float32 friction = c->friction;
b2Assert(c->pointCount == 1 || c->pointCount == 2);
// Solve tangent constraints
for (int32 j = 0; j < c->pointCount; ++j)
{
b2ContactConstraintPoint* ccp = c->points + j;
// Relative velocity at contact
b2Vec2 dv = vB + b2Cross(wB, ccp->rB) - vA - b2Cross(wA, ccp->rA);
// Compute tangent force
float32 vt = b2Dot(dv, tangent);
float32 lambda = ccp->tangentMass * (-vt);
// b2Clamp the accumulated force
float32 maxFriction = friction * ccp->normalImpulse;
float32 newImpulse = b2Clamp(ccp->tangentImpulse + lambda, -maxFriction, maxFriction);
lambda = newImpulse - ccp->tangentImpulse;
// Apply contact impulse
b2Vec2 P = lambda * tangent;
vA -= invMassA * P;
wA -= invIA * b2Cross(ccp->rA, P);
vB += invMassB * P;
wB += invIB * b2Cross(ccp->rB, P);
ccp->tangentImpulse = newImpulse;
}
// Solve normal constraints
if (c->pointCount == 1)
{
b2ContactConstraintPoint* ccp = c->points + 0;
// Relative velocity at contact
b2Vec2 dv = vB + b2Cross(wB, ccp->rB) - vA - b2Cross(wA, ccp->rA);
// Compute normal impulse
float32 vn = b2Dot(dv, normal);
float32 lambda = -ccp->normalMass * (vn - ccp->velocityBias);
// b2Clamp the accumulated impulse
float32 newImpulse = b2Max(ccp->normalImpulse + lambda, 0.0f);
lambda = newImpulse - ccp->normalImpulse;
// Apply contact impulse
b2Vec2 P = lambda * normal;
vA -= invMassA * P;
wA -= invIA * b2Cross(ccp->rA, P);
vB += invMassB * P;
wB += invIB * b2Cross(ccp->rB, P);
ccp->normalImpulse = newImpulse;
}
else
{
// Block solver developed in collaboration with Dirk Gregorius (back in 01/07 on Box2D_Lite).
// Build the mini LCP for this contact patch
//
// vn = A * x + b, vn >= 0, , vn >= 0, x >= 0 and vn_i * x_i = 0 with i = 1..2
//
// A = J * W * JT and J = ( -n, -r1 x n, n, r2 x n )
// b = vn_0 - velocityBias
//
// The system is solved using the "Total enumeration method" (s. Murty). The complementary constraint vn_i * x_i
// implies that we must have in any solution either vn_i = 0 or x_i = 0. So for the 2D contact problem the cases
// vn1 = 0 and vn2 = 0, x1 = 0 and x2 = 0, x1 = 0 and vn2 = 0, x2 = 0 and vn1 = 0 need to be tested. The first valid
// solution that satisfies the problem is chosen.
//
// In order to account of the accumulated impulse 'a' (because of the iterative nature of the solver which only requires
// that the accumulated impulse is clamped and not the incremental impulse) we change the impulse variable (x_i).
//
// Substitute:
//
// x = x' - a
//
// Plug into above equation:
//
// vn = A * x + b
// = A * (x' - a) + b
// = A * x' + b - A * a
// = A * x' + b'
// b' = b - A * a;
b2ContactConstraintPoint* cp1 = c->points + 0;
b2ContactConstraintPoint* cp2 = c->points + 1;
b2Vec2 a(cp1->normalImpulse, cp2->normalImpulse);
b2Assert(a.x >= 0.0f && a.y >= 0.0f);
// Relative velocity at contact
b2Vec2 dv1 = vB + b2Cross(wB, cp1->rB) - vA - b2Cross(wA, cp1->rA);
b2Vec2 dv2 = vB + b2Cross(wB, cp2->rB) - vA - b2Cross(wA, cp2->rA);
// Compute normal velocity
float32 vn1 = b2Dot(dv1, normal);
float32 vn2 = b2Dot(dv2, normal);
b2Vec2 b;
b.x = vn1 - cp1->velocityBias;
b.y = vn2 - cp2->velocityBias;
b -= b2Mul(c->K, a);
const float32 k_errorTol = 1e-3f;
B2_NOT_USED(k_errorTol);
for (;;)
{
//
// Case 1: vn = 0
//
// 0 = A * x' + b'
//
// Solve for x':
//
// x' = - inv(A) * b'
//
b2Vec2 x = - b2Mul(c->normalMass, b);
if (x.x >= 0.0f && x.y >= 0.0f)
{
// Resubstitute for the incremental impulse
b2Vec2 d = x - a;
// Apply incremental impulse
b2Vec2 P1 = d.x * normal;
b2Vec2 P2 = d.y * normal;
vA -= invMassA * (P1 + P2);
wA -= invIA * (b2Cross(cp1->rA, P1) + b2Cross(cp2->rA, P2));
vB += invMassB * (P1 + P2);
wB += invIB * (b2Cross(cp1->rB, P1) + b2Cross(cp2->rB, P2));
// Accumulate
cp1->normalImpulse = x.x;
cp2->normalImpulse = x.y;
#if B2_DEBUG_SOLVER == 1
// Postconditions
dv1 = vB + b2Cross(wB, cp1->rB) - vA - b2Cross(wA, cp1->rA);
dv2 = vB + b2Cross(wB, cp2->rB) - vA - b2Cross(wA, cp2->rA);
// Compute normal velocity
vn1 = b2Dot(dv1, normal);
vn2 = b2Dot(dv2, normal);
b2Assert(b2Abs(vn1 - cp1->velocityBias) < k_errorTol);
b2Assert(b2Abs(vn2 - cp2->velocityBias) < k_errorTol);
#endif
break;
}
//
// Case 2: vn1 = 0 and x2 = 0
//
// 0 = a11 * x1' + a12 * 0 + b1'
// vn2 = a21 * x1' + a22 * 0 + b2'
//
x.x = - cp1->normalMass * b.x;
x.y = 0.0f;
vn1 = 0.0f;
vn2 = c->K.col1.y * x.x + b.y;
if (x.x >= 0.0f && vn2 >= 0.0f)
{
// Resubstitute for the incremental impulse
b2Vec2 d = x - a;
// Apply incremental impulse
b2Vec2 P1 = d.x * normal;
b2Vec2 P2 = d.y * normal;
vA -= invMassA * (P1 + P2);
wA -= invIA * (b2Cross(cp1->rA, P1) + b2Cross(cp2->rA, P2));
vB += invMassB * (P1 + P2);
wB += invIB * (b2Cross(cp1->rB, P1) + b2Cross(cp2->rB, P2));
// Accumulate
cp1->normalImpulse = x.x;
cp2->normalImpulse = x.y;
#if B2_DEBUG_SOLVER == 1
// Postconditions
dv1 = vB + b2Cross(wB, cp1->rB) - vA - b2Cross(wA, cp1->rA);
// Compute normal velocity
vn1 = b2Dot(dv1, normal);
b2Assert(b2Abs(vn1 - cp1->velocityBias) < k_errorTol);
#endif
break;
}
//
// Case 3: vn2 = 0 and x1 = 0
//
// vn1 = a11 * 0 + a12 * x2' + b1'
// 0 = a21 * 0 + a22 * x2' + b2'
//
x.x = 0.0f;
x.y = - cp2->normalMass * b.y;
vn1 = c->K.col2.x * x.y + b.x;
vn2 = 0.0f;
if (x.y >= 0.0f && vn1 >= 0.0f)
{
// Resubstitute for the incremental impulse
b2Vec2 d = x - a;
// Apply incremental impulse
b2Vec2 P1 = d.x * normal;
b2Vec2 P2 = d.y * normal;
vA -= invMassA * (P1 + P2);
wA -= invIA * (b2Cross(cp1->rA, P1) + b2Cross(cp2->rA, P2));
vB += invMassB * (P1 + P2);
wB += invIB * (b2Cross(cp1->rB, P1) + b2Cross(cp2->rB, P2));
// Accumulate
cp1->normalImpulse = x.x;
cp2->normalImpulse = x.y;
#if B2_DEBUG_SOLVER == 1
// Postconditions
dv2 = vB + b2Cross(wB, cp2->rB) - vA - b2Cross(wA, cp2->rA);
// Compute normal velocity
vn2 = b2Dot(dv2, normal);
b2Assert(b2Abs(vn2 - cp2->velocityBias) < k_errorTol);
#endif
break;
}
//
// Case 4: x1 = 0 and x2 = 0
//
// vn1 = b1
// vn2 = b2;
x.x = 0.0f;
x.y = 0.0f;
vn1 = b.x;
vn2 = b.y;
if (vn1 >= 0.0f && vn2 >= 0.0f )
{
// Resubstitute for the incremental impulse
b2Vec2 d = x - a;
// Apply incremental impulse
b2Vec2 P1 = d.x * normal;
b2Vec2 P2 = d.y * normal;
vA -= invMassA * (P1 + P2);
wA -= invIA * (b2Cross(cp1->rA, P1) + b2Cross(cp2->rA, P2));
vB += invMassB * (P1 + P2);
wB += invIB * (b2Cross(cp1->rB, P1) + b2Cross(cp2->rB, P2));
// Accumulate
cp1->normalImpulse = x.x;
cp2->normalImpulse = x.y;
break;
}
// No solution, give up. This is hit sometimes, but it doesn't seem to matter.
break;
}
}
bodyA->m_linearVelocity = vA;
bodyA->m_angularVelocity = wA;
bodyB->m_linearVelocity = vB;
bodyB->m_angularVelocity = wB;
}
}
void b2ContactSolver::StoreImpulses()
{
for (int32 i = 0; i < m_constraintCount; ++i)
{
b2ContactConstraint* c = m_constraints + i;
b2Manifold* m = c->manifold;
for (int32 j = 0; j < c->pointCount; ++j)
{
m->points[j].normalImpulse = c->points[j].normalImpulse;
m->points[j].tangentImpulse = c->points[j].tangentImpulse;
}
}
}
struct b2PositionSolverManifold
{
void Initialize(b2ContactConstraint* cc, int32 index)
{
b2Assert(cc->pointCount > 0);
switch (cc->type)
{
case b2Manifold::e_circles:
{
b2Vec2 pointA = cc->bodyA->GetWorldPoint(cc->localPoint);
b2Vec2 pointB = cc->bodyB->GetWorldPoint(cc->points[0].localPoint);
if (b2DistanceSquared(pointA, pointB) > b2_epsilon * b2_epsilon)
{
normal = pointB - pointA;
normal.Normalize();
}
else
{
normal.Set(1.0f, 0.0f);
}
point = 0.5f * (pointA + pointB);
separation = b2Dot(pointB - pointA, normal) - cc->radius;
}
break;
case b2Manifold::e_faceA:
{
normal = cc->bodyA->GetWorldVector(cc->localNormal);
b2Vec2 planePoint = cc->bodyA->GetWorldPoint(cc->localPoint);
b2Vec2 clipPoint = cc->bodyB->GetWorldPoint(cc->points[index].localPoint);
separation = b2Dot(clipPoint - planePoint, normal) - cc->radius;
point = clipPoint;
}
break;
case b2Manifold::e_faceB:
{
normal = cc->bodyB->GetWorldVector(cc->localNormal);
b2Vec2 planePoint = cc->bodyB->GetWorldPoint(cc->localPoint);
b2Vec2 clipPoint = cc->bodyA->GetWorldPoint(cc->points[index].localPoint);
separation = b2Dot(clipPoint - planePoint, normal) - cc->radius;
point = clipPoint;
// Ensure normal points from A to B
normal = -normal;
}
break;
}
}
b2Vec2 normal;
b2Vec2 point;
float32 separation;
};
// Sequential solver.
bool b2ContactSolver::SolvePositionConstraints(float32 baumgarte)
{
float32 minSeparation = 0.0f;
for (int32 i = 0; i < m_constraintCount; ++i)
{
b2ContactConstraint* c = m_constraints + i;
b2Body* bodyA = c->bodyA;
b2Body* bodyB = c->bodyB;
float32 invMassA = bodyA->m_mass * bodyA->m_invMass;
float32 invIA = bodyA->m_mass * bodyA->m_invI;
float32 invMassB = bodyB->m_mass * bodyB->m_invMass;
float32 invIB = bodyB->m_mass * bodyB->m_invI;
// Solve normal constraints
for (int32 j = 0; j < c->pointCount; ++j)
{
b2PositionSolverManifold psm;
psm.Initialize(c, j);
b2Vec2 normal = psm.normal;
b2Vec2 point = psm.point;
float32 separation = psm.separation;
b2Vec2 rA = point - bodyA->m_sweep.c;
b2Vec2 rB = point - bodyB->m_sweep.c;
// Track max constraint error.
minSeparation = b2Min(minSeparation, separation);
// Prevent large corrections and allow slop.
float32 C = b2Clamp(baumgarte * (separation + b2_linearSlop), -b2_maxLinearCorrection, 0.0f);
// Compute the effective mass.
float32 rnA = b2Cross(rA, normal);
float32 rnB = b2Cross(rB, normal);
float32 K = invMassA + invMassB + invIA * rnA * rnA + invIB * rnB * rnB;
// Compute normal impulse
float32 impulse = K > 0.0f ? - C / K : 0.0f;
b2Vec2 P = impulse * normal;
bodyA->m_sweep.c -= invMassA * P;
bodyA->m_sweep.a -= invIA * b2Cross(rA, P);
bodyA->SynchronizeTransform();
bodyB->m_sweep.c += invMassB * P;
bodyB->m_sweep.a += invIB * b2Cross(rB, P);
bodyB->SynchronizeTransform();
}
}
// We can't expect minSpeparation >= -b2_linearSlop because we don't
// push the separation above -b2_linearSlop.
return minSeparation >= -1.5f * b2_linearSlop;
}
| [
"[email protected]"
] | [
[
[
1,
623
]
]
] |
a6e927235bb228eaaa303fbe104b1814d6ed645b | 305f56324b8c1625a5f3ba7966d1ce6c540e9d97 | /src/lister/TaskDefWin.h | 6b277c390d2d92b5685d4b9a980b416d2bd1f604 | [] | no_license | radtek/lister | be45f7ac67da72c1c2ac0d7cd878032c9648af7b | 71418c72b31823624f545ad86cc804c43b6e9426 | refs/heads/master | 2021-01-01T19:56:30.878680 | 2011-06-22T17:04:13 | 2011-06-22T17:04:13 | 41,946,076 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,351 | h | #ifndef _lister_lister_TaskDefWin_h_
#define _lister_lister_TaskDefWin_h_
#include "shared.h"
#include "shared_layout.h"
#include "Task.h"
#include <lister/Urp/UrpConfigWindow.h>
class Connection;
//==============================================================================================
class TaskDefWin : public WithTaskDefWinLayout<UrpConfigWindow> {
public:
typedef TaskDefWin CLASSNAME; // THISBACK won't work without this
Connection *connection;
// Define only one task at one time. Create Id BEFORE opening this window.
Task task;
// Let main program call TaskGrid
Callback1<Task&> WhenSaveTask;
TaskDefWin ();
virtual
void Open ();
virtual
void Open (Ctrl *owner);
virtual
void Close ();
void Build (Connection *pconnection);
void Load (Task &ptask);
void SaveTask ();
// Hack in Ctrl class required to make Xmlize virtual or this function
// will never be called.
virtual void Xmlize (XmlIO xml);
};
#endif
| [
"jeffshumphreys@97668ed5-8355-0e3d-284e-ab2976d7b0b4"
] | [
[
[
1,
40
]
]
] |
adb96424696f07629642c05aa932eb2a2c302123 | 724cded0e31f5fd52296d516b4c3d496f930fd19 | /inc/jrtp/rtpudpv4transmitter.h | e3af669461de56c17a2f1fd14e8ebfd5c60049ed | [] | no_license | yubik9/p2pcenter | 0c85a38f2b3052adf90b113b2b8b5b312fefcb0a | fc4119f29625b1b1f4559ffbe81563e6fcd2b4ea | refs/heads/master | 2021-08-27T15:40:05.663872 | 2009-02-19T00:13:33 | 2009-02-19T00:13:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,254 | h | /*
This file is a part of JRTPLIB
Copyright (c) 1999-2006 Jori Liesenborgs
Contact: [email protected]
This library was developed at the "Expertisecentrum Digitale Media"
(http://www.edm.uhasselt.be), a research center of the Hasselt University
(http://www.uhasselt.be). The library is based upon work done for
my thesis at the School for Knowledge Technology (Belgium/The Netherlands).
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 RTPUDPV4TRANSMITTER_H
#define RTPUDPV4TRANSMITTER_H
#include "rtpconfig.h"
#include "rtptransmitter.h"
#include "rtpipv4destination.h"
#include "rtphashtable.h"
#include "rtpkeyhashtable.h"
#include <list>
#ifdef RTP_SUPPORT_THREAD
#include "jmutex.h"
#endif // RTP_SUPPORT_THREAD
#define RTPUDPV4TRANS_HASHSIZE 8317
#define RTPUDPV4TRANS_DEFAULTPORTBASE 5000
class RTPUDPv4TransmissionParams : public RTPTransmissionParams
{
public:
RTPUDPv4TransmissionParams():RTPTransmissionParams(RTPTransmitter::IPv4UDPProto) { portbase = RTPUDPV4TRANS_DEFAULTPORTBASE; bindIP = 0; multicastTTL = 1; mcastifaceIP = 0; }
void SetBindIP(uint32_t ip) { bindIP = ip; }
void SetMulticastInterfaceIP(uint32_t ip) { mcastifaceIP = ip; }
void SetPortbase(uint16_t pbase) { portbase = pbase; }
void SetMulticastTTL(uint8_t mcastTTL) { multicastTTL = mcastTTL; }
void SetLocalIPList(std::list<uint32_t> &iplist) { localIPs = iplist; }
void ClearLocalIPList() { localIPs.clear(); }
uint32_t GetBindIP() const { return bindIP; }
uint32_t GetMulticastInterfaceIP() const { return mcastifaceIP; }
uint16_t GetPortbase() const { return portbase; }
uint8_t GetMulticastTTL() const { return multicastTTL; }
const std::list<uint32_t> &GetLocalIPList() const { return localIPs; }
private:
uint16_t portbase;
uint32_t bindIP, mcastifaceIP;
std::list<uint32_t> localIPs;
uint8_t multicastTTL;
};
class RTPUDPv4TransmissionInfo : public RTPTransmissionInfo
{
public:
#if ! (defined(WIN32) || defined(_WIN32_WCE))
RTPUDPv4TransmissionInfo(std::list<uint32_t> iplist,int rtpsock,int rtcpsock) : RTPTransmissionInfo(RTPTransmitter::IPv4UDPProto)
#else
RTPUDPv4TransmissionInfo(std::list<uint32_t> iplist,SOCKET rtpsock,SOCKET rtcpsock) : RTPTransmissionInfo(RTPTransmitter::IPv4UDPProto)
#endif // WIN32
{ localIPlist = iplist; rtpsocket = rtpsock; rtcpsocket = rtcpsock; }
~RTPUDPv4TransmissionInfo() { }
std::list<uint32_t> GetLocalIPList() const { return localIPlist; }
#if ! (defined(WIN32) || defined(_WIN32_WCE))
int GetRTPSocket() const { return rtpsocket; }
int GetRTCPSocket() const { return rtcpsocket; }
#else
SOCKET GetRTPSocket() const { return rtpsocket; }
SOCKET GetRTCPSocket() const { return rtcpsocket; }
#endif // WIN32
private:
std::list<uint32_t> localIPlist;
#if ! (defined(WIN32) || defined(_WIN32_WCE))
int rtpsocket,rtcpsocket;
#else
SOCKET rtpsocket,rtcpsocket;
#endif // WIN32
};
#ifdef RTP_SUPPORT_INLINETEMPLATEPARAM
inline int RTPUDPv4Trans_GetHashIndex_IPv4Dest(const RTPIPv4Destination &d) { return d.GetIP_HBO()%RTPUDPV4TRANS_HASHSIZE; }
inline int RTPUDPv4Trans_GetHashIndex_uint32_t(const uint32_t &k) { return k%RTPUDPV4TRANS_HASHSIZE; }
#else // No support for inline function as template parameter
int RTPUDPv4Trans_GetHashIndex_IPv4Dest(const RTPIPv4Destination &d);
int RTPUDPv4Trans_GetHashIndex_uint32_t(const uint32_t &k);
#endif // RTP_SUPPORT_INLINETEMPLATEPARAM
#define RTPUDPV4TRANS_HEADERSIZE (20+8)
class RTPUDPv4Transmitter : public RTPTransmitter
{
public:
RTPUDPv4Transmitter();
~RTPUDPv4Transmitter();
int Init(bool treadsafe);
int Create(size_t maxpacksize,const RTPTransmissionParams *transparams);
void Destroy();
RTPTransmissionInfo *GetTransmissionInfo();
int GetLocalHostName(uint8_t *buffer,size_t *bufferlength);
bool ComesFromThisTransmitter(const RTPAddress *addr);
size_t GetHeaderOverhead() { return RTPUDPV4TRANS_HEADERSIZE; }
int Poll();
int WaitForIncomingData(const RTPTime &delay,bool *dataavailable = 0);
int AbortWait();
int SendRTPData(const void *data,size_t len);
int SendRTCPData(const void *data,size_t len);
void ResetPacketCount();
uint32_t GetNumRTPPacketsSent();
uint32_t GetNumRTCPPacketsSent();
int AddDestination(const RTPAddress &addr);
int DeleteDestination(const RTPAddress &addr);
void ClearDestinations();
bool SupportsMulticasting();
int JoinMulticastGroup(const RTPAddress &addr);
int LeaveMulticastGroup(const RTPAddress &addr);
void LeaveAllMulticastGroups();
int SetReceiveMode(RTPTransmitter::ReceiveMode m);
int AddToIgnoreList(const RTPAddress &addr);
int DeleteFromIgnoreList(const RTPAddress &addr);
void ClearIgnoreList();
int AddToAcceptList(const RTPAddress &addr);
int DeleteFromAcceptList(const RTPAddress &addr);
void ClearAcceptList();
int SetMaximumPacketSize(size_t s);
bool NewDataAvailable();
RTPRawPacket *GetNextPacket();
#ifdef RTPDEBUG
void Dump();
#endif // RTPDEBUG
private:
int CreateLocalIPList();
bool GetLocalIPList_Interfaces();
void GetLocalIPList_DNS();
void AddLoopbackAddress();
void FlushPackets();
int PollSocket(bool rtp);
int ProcessAddAcceptIgnoreEntry(uint32_t ip,uint16_t port);
int ProcessDeleteAcceptIgnoreEntry(uint32_t ip,uint16_t port);
#ifdef RTP_SUPPORT_IPV4MULTICAST
bool SetMulticastTTL(uint8_t ttl);
#endif // RTP_SUPPORT_IPV4MULTICAST
bool ShouldAcceptData(uint32_t srcip,uint16_t srcport);
void ClearAcceptIgnoreInfo();
bool init;
bool created;
bool waitingfordata;
#if (defined(WIN32) || defined(_WIN32_WCE))
SOCKET rtpsock,rtcpsock;
#else // not using winsock
int rtpsock,rtcpsock;
#endif // WIN32
uint32_t bindIP, mcastifaceIP;
std::list<uint32_t> localIPs;
uint16_t portbase;
uint8_t multicastTTL;
RTPTransmitter::ReceiveMode receivemode;
uint8_t *localhostname;
size_t localhostnamelength;
RTPHashTable<const RTPIPv4Destination,RTPUDPv4Trans_GetHashIndex_IPv4Dest,RTPUDPV4TRANS_HASHSIZE> destinations;
#ifdef RTP_SUPPORT_IPV4MULTICAST
RTPHashTable<const uint32_t,RTPUDPv4Trans_GetHashIndex_uint32_t,RTPUDPV4TRANS_HASHSIZE> multicastgroups;
#endif // RTP_SUPPORT_IPV4MULTICAST
std::list<RTPRawPacket*> rawpacketlist;
bool supportsmulticasting;
size_t maxpacksize;
class PortInfo
{
public:
PortInfo() { all = false; }
bool all;
std::list<uint16_t> portlist;
};
RTPKeyHashTable<const uint32_t,PortInfo*,RTPUDPv4Trans_GetHashIndex_uint32_t,RTPUDPV4TRANS_HASHSIZE> acceptignoreinfo;
// notification descriptors for AbortWait (0 is for reading, 1 for writing)
#if (defined(WIN32) || defined(_WIN32_WCE))
SOCKET abortdesc[2];
#else
int abortdesc[2];
#endif // WIN32
int CreateAbortDescriptors();
void DestroyAbortDescriptors();
void AbortWaitInternal();
#ifdef RTP_SUPPORT_THREAD
JMutex mainmutex,waitmutex;
int threadsafe;
#endif // RTP_SUPPORT_THREAD
uint32_t rtppackcount,rtcppackcount;
};
#endif // RTPUDPV4TRANSMITTER_H
| [
"fuwenke@b5bb1052-fe17-11dd-bc25-5f29055a2a2d"
] | [
[
[
1,
230
]
]
] |
0ab5ea3f56b184db1524410f193bdada8415bef5 | 138a353006eb1376668037fcdfbafc05450aa413 | /source/ogre/OgreNewt/boost/mpl/size_t_fwd.hpp | 20c02c39757bcaa94efe5400f49687509220e63e | [] | no_license | sonicma7/choreopower | 107ed0a5f2eb5fa9e47378702469b77554e44746 | 1480a8f9512531665695b46dcfdde3f689888053 | refs/heads/master | 2020-05-16T20:53:11.590126 | 2009-11-18T03:10:12 | 2009-11-18T03:10:12 | 32,246,184 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 864 | hpp |
#ifndef BOOST_MPL_SIZE_T_FWD_HPP_INCLUDED
#define BOOST_MPL_SIZE_T_FWD_HPP_INCLUDED
// Copyright Aleksey Gurtovoy 2000-2004
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/mpl for documentation.
// $Source: /cvsroot/ogre/ogreaddons/ogrenewt/OgreNewt_Main/inc/boost/mpl/size_t_fwd.hpp,v $
// $Date: 2006/04/17 23:49:40 $
// $Revision: 1.1 $
#include <boost/mpl/aux_/adl_barrier.hpp>
#include <boost/config.hpp> // make sure 'size_t' is placed into 'std'
#include <cstddef>
BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE_OPEN
template< std::size_t N > struct size_t;
BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE_CLOSE
BOOST_MPL_AUX_ADL_BARRIER_DECL(size_t)
#endif // BOOST_MPL_SIZE_T_FWD_HPP_INCLUDED
| [
"Sonicma7@0822fb10-d3c0-11de-a505-35228575a32e"
] | [
[
[
1,
28
]
]
] |
7f4c664e984ab69e6d33d759bab884b9bb6e682f | 971b000b9e6c4bf91d28f3723923a678520f5bcf | /QTextPanelThread.r1/main.cpp | 5cfca315da68e71d8aedd9110cf68d22c50b6fea | [] | no_license | google-code-export/fop-miniscribus | 14ce53d21893ce1821386a94d42485ee0465121f | 966a9ca7097268c18e690aa0ea4b24b308475af9 | refs/heads/master | 2020-12-24T17:08:51.551987 | 2011-09-02T07:55:05 | 2011-09-02T07:55:05 | 32,133,292 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 354 | cpp | #include <QtCore>
#include <QDebug>
#include <QCoreApplication>
#include <QObject>
#include <QApplication>
#include "panel.h"
#include "qtextpanel.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Panel *w = new Panel();
w->show();
a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
return a.exec();
}
| [
"ppkciz@9af58faf-7e3e-0410-b956-55d145112073"
] | [
[
[
1,
18
]
]
] |
fba31ddc3d2ca108ddb8c7f80a15a82056242bb4 | 77aa13a51685597585abf89b5ad30f9ef4011bde | /dep/src/boost/boost/detail/sp_counted_base_sync.hpp | fc4086a263ad4068adba0aed63c963d3d53c4f49 | [] | no_license | Zic/Xeon-MMORPG-Emulator | 2f195d04bfd0988a9165a52b7a3756c04b3f146c | 4473a22e6dd4ec3c9b867d60915841731869a050 | refs/heads/master | 2021-01-01T16:19:35.213330 | 2009-05-13T18:12:36 | 2009-05-14T03:10:17 | 200,849 | 8 | 10 | null | null | null | null | UTF-8 | C++ | false | false | 3,125 | hpp | #ifndef BOOST_DETAIL_SP_COUNTED_BASE_SYNC_HPP_INCLUDED
#define BOOST_DETAIL_SP_COUNTED_BASE_SYNC_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// detail/sp_counted_base_sync.hpp - g++ 4.1+ __sync intrinsics
//
// Copyright (c) 2007 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/detail/sp_typeinfo.hpp>
#include <limits.h>
#if defined( __ia64__ ) && defined( __INTEL_COMPILER )
# include <ia64intrin.h>
#endif
namespace boost
{
namespace detail
{
#if INT_MAX >= 2147483647
typedef int sp_int32_t;
#else
typedef long sp_int32_t;
#endif
inline void atomic_increment( sp_int32_t * pw )
{
__sync_fetch_and_add( pw, 1 );
}
inline sp_int32_t atomic_decrement( sp_int32_t * pw )
{
return __sync_fetch_and_add( pw, -1 );
}
inline sp_int32_t atomic_conditional_increment( sp_int32_t * pw )
{
// long r = *pw;
// if( r != 0 ) ++*pw;
// return r;
sp_int32_t r = *pw;
for( ;; )
{
if( r == 0 )
{
return r;
}
sp_int32_t r2 = __sync_val_compare_and_swap( pw, r, r + 1 );
if( r2 == r )
{
return r;
}
else
{
r = r2;
}
}
}
class sp_counted_base
{
private:
sp_counted_base( sp_counted_base const & );
sp_counted_base & operator= ( sp_counted_base const & );
sp_int32_t use_count_; // #shared
sp_int32_t weak_count_; // #weak + (#shared != 0)
public:
sp_counted_base(): use_count_( 1 ), weak_count_( 1 )
{
}
virtual ~sp_counted_base() // nothrow
{
}
// dispose() is called when use_count_ drops to zero, to release
// the resources managed by *this.
virtual void dispose() = 0; // nothrow
// destroy() is called when weak_count_ drops to zero.
virtual void destroy() // nothrow
{
delete this;
}
virtual void * get_deleter( sp_typeinfo const & ti ) = 0;
void add_ref_copy()
{
atomic_increment( &use_count_ );
}
bool add_ref_lock() // true on success
{
return atomic_conditional_increment( &use_count_ ) != 0;
}
void release() // nothrow
{
if( atomic_decrement( &use_count_ ) == 1 )
{
dispose();
weak_release();
}
}
void weak_add_ref() // nothrow
{
atomic_increment( &weak_count_ );
}
void weak_release() // nothrow
{
if( atomic_decrement( &weak_count_ ) == 1 )
{
destroy();
}
}
long use_count() const // nothrow
{
return const_cast< sp_int32_t const volatile & >( use_count_ );
}
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_DETAIL_SP_COUNTED_BASE_SYNC_HPP_INCLUDED
| [
"pepsi1x1@a6a5f009-272a-4b40-a74d-5f9816a51f88"
] | [
[
[
1,
155
]
]
] |
029b3baba8d8705a5d7a19df55ce018d2cd96fb2 | aa825896cc7c672140405ab51634d00d28fad09b | /zomgatron/EncryptionUtils.h | fb6f04c4093e9c00e39b54f98bf3008d93b06524 | [] | no_license | kllrnohj/zomgatron | 856fa6693b924d629f166c82cdd4db7524f3255d | 099955f0ab84eb432ab87d351b8defd3123a8991 | refs/heads/master | 2021-01-10T08:26:13.826555 | 2009-01-27T17:21:45 | 2009-01-27T17:21:45 | 46,742,521 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 518 | h | #ifndef __ENCRYPTIONUTILS_H__
#define __ENCRYPTIONUTILS_H__
class EncryptionUtils{
public:
static void EncryptDecryptShort(short& val);
static void DecryptBuf(char* buf, int len);
static void EncryptBuf(char* buf, int len);
static unsigned long GetEncryptDecryptUL(unsigned long val);
static int GetEncryptedFloat(float val);
static float GetDecryptedFloat(int val);
static short GetEncryptDecryptShort(short val);
static unsigned int GetEncryptDecryptUI(unsigned int val);
};
#endif
| [
"Kivu.Rako@54144a58-e977-11dd-a550-c997509ed985"
] | [
[
[
1,
20
]
]
] |
488621b72bb47c388a75b2f92621f97d4ff4bba8 | 27d5670a7739a866c3ad97a71c0fc9334f6875f2 | /CPP/Targets/SupportWFLib/symbian/NetworkRegistrationNotifier.h | 759c3cdfb9e410d94df79a6b59113160541f1c4a | [
"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 | 3,678 | 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 NETWORK_REGISTRATION_NOTIFIER_H
#define NETWORK_REGISTRATION_NOTIFIER_H
#include <e32base.h>
#include <etel3rdparty.h>
class CNetworkRegistrationNotifier : public CActive
{
public:
static CNetworkRegistrationNotifier* NewLC(
class MNetworkRegistrationNotifierObserver* aObserver,
enum TPriority aPriority = EPriorityStandard);
static CNetworkRegistrationNotifier* NewL(
class MNetworkRegistrationNotifierObserver* aObserver,
enum TPriority aPriority = EPriorityStandard);
/**
* Class Destructor
*/
virtual ~CNetworkRegistrationNotifier();
/**
* This will start the actual observing.
*/
void Start();
/**
* returns the registration status
* @return The network registration status.
*/
CTelephony::TRegistrationStatus RegistrationStatus();
protected:
/**
* Class constructor
* @param aPriotiry The priority of the active object.
*/
CNetworkRegistrationNotifier(class MNetworkRegistrationNotifierObserver* aObserver,
enum TPriority aPriority);
private:
/**
* Symbian second stage ConstructL.
*/
void ConstructL();
protected: // From Base classes
/**
* CActive RunL function.
*/
virtual void RunL();
/**
* Called by framework call Cancel().
*/
virtual void DoCancel();
private:
/// The observer we will notify when a change happens.
class MNetworkRegistrationNotifierObserver* iObserver;
/// The object to get information from the phone.
CTelephony* iTelephony;
/// The result from the network registration change will end up here.
CTelephony::TNetworkRegistrationV1 iNetworkRegistrationV1;
/// Package container for iNetworkRegistrationV1.
CTelephony::TNetworkRegistrationV1Pckg iNetworkRegistrationV1Pckg;
/// Registration status of the phone (no service, roaming, busy, etc.).
CTelephony::TRegistrationStatus iRegStatus;
};
#endif // NETWORK_REGISTRATION_NOTIFIER_H
| [
"[email protected]"
] | [
[
[
1,
97
]
]
] |
f6ced67d1ea8751c39116a51838f0a4b7a3b9e1f | ce262ae496ab3eeebfcbb337da86d34eb689c07b | /SETools/SEMax8Exporter/SEMax8PluginSupport/SEMax8SceneExport.cpp | 6d3171ff2570e0d8f68a6c296fab3134cfad4a96 | [] | 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 | 20,008 | 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 "SEMax8SceneBuilder.h"
#include "SEMax8SceneExport.h"
#include "SEMax8Exporter.h"
#include "resource.h"
using namespace Swing;
//----------------------------------------------------------------------------
Max8SceneExport::Max8SceneExport()
{
}
//----------------------------------------------------------------------------
Max8SceneExport::~Max8SceneExport()
{
}
//----------------------------------------------------------------------------
int Max8SceneExport::ExtCount()
{
// 插件支持的导出文件扩展名.
// 只支持一种(*.seof).
return 1;
}
//----------------------------------------------------------------------------
const TCHAR* Max8SceneExport::Ext(int)
{
// 返回文件扩展名.
return _T("seof");
}
//----------------------------------------------------------------------------
const TCHAR* Max8SceneExport::LongDesc()
{
// 导出文件的长描述.
return Max8Exporter::ThePlugin.GetResourceString(IDS_LONGDESCRIPTION);
}
//----------------------------------------------------------------------------
const TCHAR* Max8SceneExport::ShortDesc()
{
// 导出文件的短描述.
return Max8Exporter::ThePlugin.GetResourceString(IDS_SHORTDESCRIPTION);
}
//----------------------------------------------------------------------------
const TCHAR* Max8SceneExport::AuthorName()
{
// 插件作者.
return Max8Exporter::ThePlugin.GetResourceString(IDS_AUTHORNAME);
}
//----------------------------------------------------------------------------
const TCHAR* Max8SceneExport::CopyrightMessage()
{
// 版权信息.
return
_T("Swing Tech. Copyright (c) 2007-2008. All Rights Reserved");
}
//----------------------------------------------------------------------------
const TCHAR* Max8SceneExport::OtherMessage1()
{
// 其他额外信息1.
return _T("");
}
//----------------------------------------------------------------------------
const TCHAR* Max8SceneExport::OtherMessage2()
{
// 其他额外信息2.
return _T("");
}
//----------------------------------------------------------------------------
unsigned int Max8SceneExport::Version()
{
// 返回导出器版本号.
return EXPORTER_VERSION;
}
//----------------------------------------------------------------------------
void Max8SceneExport::ShowAbout(HWND)
{
// 待实现.
// 显示插件的About对话框.
}
//----------------------------------------------------------------------------
BOOL Max8SceneExport::SupportsOptions(int, DWORD)
{
// Max调用这个函数获取插件支持给定文件扩展名的哪些选项.
// 当前支持所有选项.
return TRUE;
}
//----------------------------------------------------------------------------
int Max8SceneExport::DoExport(const TCHAR* acFilename, ExpInterface* pExport,
Interface* pMax, BOOL bSuppressPrompts, DWORD dwOptions)
{
// 从磁盘文件获取导出器的当前配置,
// 显示UI界面,根据当前配置,建立并且保存Swing Engine scene graph,
// 之后保存当前配置到磁盘文件.
// acFilename:
// 用户指定的Swing Engine scene graph文件名.
// pExport:
// 访问Max的导出器相关功能的接口指针.
// pMax:
// 访问Max相关功能的主接口指针.
// bSuppressPrompts:
// 允许,或禁止用户输入.
// dwOptions:
// 决定导出整个场景,或场景的选中部分.
m_pMax = pMax;
INode* pRootNode = NULL;
bool bExportSelected;
if( dwOptions == SCENE_EXPORT_SELECTED )
{
// 用户选择导出部分场景,
// 检查确保只能选中场景中的一个子节点,作为导出子场景的根节点.
if( m_pMax->GetSelNodeCount() != 1 )
{
assert( false );
return 0;
}
pRootNode = m_pMax->GetSelNode(0);
bExportSelected = true;
}
else
{
// 导出整个场景,
// 从Max场景的根节点开始.
pRootNode = m_pMax->GetRootNode();
bExportSelected = false;
}
// 获取导出器插件配置文件的路径.
m_StrConfigFile = m_pMax->GetDir(APP_PLUGCFG_DIR);
m_StrConfigFile += "\\Max8Exporter.cfg";
// 恢复先前导出器的配置.
ReadConfiguration();
// 显示导出器UI.
if( !bSuppressPrompts )
{
INT_PTR piResult = DialogBoxParam(Max8Exporter::ThePlugin.GetInstance(),
MAKEINTRESOURCE(IDD_PANEL), GetActiveWindow(), DialogProcedure,
(LPARAM)this);
if( !piResult )
return 1;
}
// 实际导出工作,将Max场景转换为Swing Engine场景并生成磁盘文件.
Max8SceneBuilder(acFilename, bExportSelected, &m_EffectiveSettings, pExport,
pMax, pRootNode);
// 保存导出器的本次配置.
WriteConfiguration();
return 1;
}
//----------------------------------------------------------------------------
void Max8SceneExport::ReadConfiguration()
{
// 从磁盘文件恢复导出器的配置情况.
// 该配置情况是用户上次操作导出器的配置结果.
// 如果配置文件不存在(比如第一次运行导出器),
// 则使用默认配置.
FILE* pConfig = SESystem::SE_Fopen(m_StrConfigFile, "rb");
if( pConfig == NULL )
{
return;
}
// 获取配置文件版本.
int iVersion;
if( fread(&iVersion, sizeof(int), 1, pConfig) != 1 )
{
// 文件不正确
assert( false );
fclose(pConfig);
return;
}
// 验证导出器版本和配置文件版本是否匹配.
if( iVersion != EXPORTER_VERSION )
{
// 不匹配
assert( false );
fclose(pConfig);
return;
}
// 获取配置信息.
Max8ExportSettings tempSettings;
if( fread(&tempSettings, sizeof(Max8ExportSettings), 1, pConfig) != 1 )
{
// 文件不正确
assert( false );
fclose(pConfig);
return;
}
fclose(pConfig);
// 覆盖默认配置信息.
memcpy(&m_Settings, &tempSettings, sizeof(Max8ExportSettings));
}
//----------------------------------------------------------------------------
void Max8SceneExport::WriteConfiguration()
{
FILE* pConfig = SESystem::SE_Fopen(m_StrConfigFile, "wb");
if( pConfig == NULL )
{
// 创建配置文件失败
assert( false );
return;
}
// 写入配置文件版本.
int iVersion = EXPORTER_VERSION;
if( fwrite(&iVersion, sizeof(int), 1, pConfig) != 1 )
{
// 写配置文件失败
assert( false );
fclose(pConfig);
return;
}
// 写入导出器配置信息.
if( fwrite(&m_Settings, sizeof(Max8ExportSettings), 1, pConfig) != 1 )
{
// 写配置文件失败
assert( false );
fclose(pConfig);
return;
}
fclose(pConfig);
}
//----------------------------------------------------------------------------
BOOL CALLBACK Max8SceneExport::DialogProcedure(HWND hWnd, UINT uiMsg,
WPARAM wParam, LPARAM lParam)
{
if( uiMsg == WM_INITDIALOG )
{
// 当对话框初始化时,Max通过LPARAM参数传递当前导出器实例的"this"指针进来.
// 保存这个指针供稍后使用.
SetWindowLongPtr(hWnd, GWLP_USERDATA, lParam);
// 调用对话框实例的初始化函数.
return ((Max8SceneExport*)lParam)->OnInitDialog(hWnd);
}
Max8SceneExport* pExporter = (Max8SceneExport*)GetWindowLongPtr(hWnd,
GWLP_USERDATA);
switch( uiMsg )
{
case WM_COMMAND:
// 用户操作UI产生了UI事件,
// 判断事件,做出相应响应.
switch( LOWORD(wParam) )
{
case IDC_CHECK_MESHES:
return pExporter->OnMeshChecked(hWnd,
IsDlgButtonChecked(hWnd, IDC_CHECK_MESHES));
case IDC_CHECK_OBJECTS:
return pExporter->OnObjectsChecked(hWnd,
IsDlgButtonChecked(hWnd, IDC_CHECK_OBJECTS));
case IDC_CHECK_MODIFIERS:
return pExporter->OnModifiersChecked(hWnd,
IsDlgButtonChecked(hWnd, IDC_CHECK_MODIFIERS));
case IDC_RADIO_ALLFRAMES:
case IDC_RADIO_KEYFRAMES:
return pExporter->OnEnableFrameSpinners(hWnd, TRUE);
case IDC_RADIO_CURRENTFRAME:
return pExporter->OnEnableFrameSpinners(hWnd, FALSE);
case IDOK:
pExporter->OnOK(hWnd);
EndDialog(hWnd, 1);
break;
case IDCANCEL:
EndDialog(hWnd, 0);
break;
default:
return FALSE;
}
break;
case CC_SPINNER_CHANGE:
// spinner控件的消息处理.
switch( LOWORD(wParam) )
{
case IDC_SPINNER_ENDFRAME:
return pExporter->OnEndFrameSpinnerChanged(hWnd);
case IDC_SPINNER_STARTFRAME:
return pExporter->OnStartFrameSpinnerChanged(hWnd);
}
break;
case WM_CLOSE:
EndDialog(hWnd, 0);
return TRUE;
}
return FALSE;
}
//----------------------------------------------------------------------------
BOOL Max8SceneExport::OnEnableFrameSpinners(HWND hWnd, BOOL bEnabled)
{
// 开启或关闭frame spinner控件.
ISpinnerControl* pSpinner = GetISpinner(GetDlgItem(hWnd,
IDC_SPINNER_STARTFRAME));
pSpinner->Enable(bEnabled);
ReleaseISpinner(pSpinner);
pSpinner = GetISpinner(GetDlgItem(hWnd, IDC_SPINNER_ENDFRAME));
pSpinner->Enable(bEnabled);
return TRUE;
}
//----------------------------------------------------------------------------
BOOL Max8SceneExport::OnEndFrameSpinnerChanged(HWND hWnd)
{
// 当用户修改表示导出动画结束桢的spinner控件时调用.
// 从spinner控件获取导出动画起始桢.
ISpinnerControl* pSpinner = GetISpinner(GetDlgItem(hWnd,
IDC_SPINNER_STARTFRAME));
int iStartFrame = pSpinner->GetIVal();
ReleaseISpinner(pSpinner);
// 确保导出动画结束桢大于等于导出动画起始桢.
pSpinner = GetISpinner(GetDlgItem(hWnd, IDC_SPINNER_ENDFRAME));
int iEndFrame = pSpinner->GetIVal();
if( iStartFrame > iEndFrame )
{
pSpinner->SetValue(iStartFrame, FALSE);
}
ReleaseISpinner(pSpinner);
return TRUE;
}
//----------------------------------------------------------------------------
BOOL Max8SceneExport::OnInitDialog(HWND hWnd)
{
// 当对话框接到WM_INITDIALOG消息时,进行导出器UI初始化工作.
CenterWindow(hWnd, GetParent(hWnd));
// 设置UI状态.
// 如果配置文件存在,则体现上次使用导出器后的配置文件的内容.
// 否则使用默认配置.
CheckDlgButton(hWnd,IDC_CHECK_OBJECTS, m_Settings.IncludeObjects);
CheckDlgButton(hWnd,IDC_CHECK_LIGHTS, m_Settings.IncludeLights);
CheckDlgButton(hWnd,IDC_CHECK_MESHES, m_Settings.IncludeMeshes);
CheckDlgButton(hWnd,IDC_CHECK_CAMERAS, m_Settings.IncludeCameras);
CheckDlgButton(hWnd,IDC_CHECK_NORMALS, m_Settings.IncludeNormals);
CheckDlgButton(hWnd,IDC_CHECK_MATERIALS, m_Settings.IncludeMaterials);
CheckDlgButton(hWnd,IDC_CHECK_VERTEXCOLS, m_Settings.IncludeVertexColors);
CheckDlgButton(hWnd,IDC_CHECK_TEXCOORDS, m_Settings.IncludeTexCoords);
CheckDlgButton(hWnd,IDC_CHECK_GENERATEMAPS, m_Settings.GenerateMaps);
CheckDlgButton(hWnd,IDC_CHECK_MODIFIERS, m_Settings.IncludeModifiers);
CheckDlgButton(hWnd,IDC_CHECK_SKINS, m_Settings.IncludeSkins);
CheckDlgButton(hWnd,IDC_CHECK_GPU, m_Settings.UseGPUSkin);
CheckDlgButton(hWnd,IDC_RADIO_CURRENTFRAME, m_Settings.IncludeCurrentFrame);
CheckDlgButton(hWnd,IDC_RADIO_KEYFRAMES, m_Settings.IncludeKeyFrames);
CheckDlgButton(hWnd,IDC_RADIO_ALLFRAMES, m_Settings.IncludeAllFrames);
CheckDlgButton(hWnd,IDC_CHECK_USELOCALTIME, m_Settings.UseLocalTime);
if( !m_Settings.IncludeObjects )
{
// 如果未选中"Object",则关闭其下属子选项.
OnObjectsChecked(hWnd, FALSE);
}
else if( !m_Settings.IncludeMeshes )
{
// 如果未选中"Mesh",则关闭其下属子选项.
OnMeshChecked(hWnd, FALSE);
}
// 如果未选中"Modifiers",则关闭其下属子选项.
if( !m_Settings.IncludeModifiers )
{
OnModifiersChecked(hWnd, FALSE);
}
// 获取Max场景中的动画桢数目.
int iNumFrames = m_pMax->GetAnimRange().Duration() / GetTicksPerFrame();
// 设置spinner控件.
ISpinnerControl* pSpinner = GetISpinner(GetDlgItem(hWnd,
IDC_SPINNER_STARTFRAME));
pSpinner->LinkToEdit(GetDlgItem(hWnd, IDC_EDIT_STARTFRAME), EDITTYPE_INT);
pSpinner->SetLimits(0, iNumFrames, TRUE);
pSpinner->SetScale(1.0f);
pSpinner->SetValue(0, FALSE);
if( m_Settings.IncludeCurrentFrame )
{
pSpinner->Enable(FALSE);
}
ReleaseISpinner(pSpinner);
pSpinner = GetISpinner(GetDlgItem(hWnd, IDC_SPINNER_ENDFRAME));
pSpinner->LinkToEdit(GetDlgItem(hWnd, IDC_EDIT_ENDFRAME), EDITTYPE_INT);
pSpinner->SetLimits(0, iNumFrames, TRUE);
pSpinner->SetScale(1.0f);
pSpinner->SetValue(iNumFrames, FALSE);
if( m_Settings.IncludeCurrentFrame )
{
pSpinner->Enable(FALSE);
}
ReleaseISpinner(pSpinner);
return TRUE;
}
//----------------------------------------------------------------------------
BOOL Max8SceneExport::OnMeshChecked(HWND hWnd, BOOL bEnabled)
{
// 点击"Mesh"时的动作.
EnableWindow(GetDlgItem(hWnd, IDC_CHECK_NORMALS), bEnabled);
EnableWindow(GetDlgItem(hWnd, IDC_CHECK_VERTEXCOLS), bEnabled);
EnableWindow(GetDlgItem(hWnd, IDC_CHECK_TEXCOORDS), bEnabled);
EnableWindow(GetDlgItem(hWnd, IDC_CHECK_MATERIALS), bEnabled);
EnableWindow(GetDlgItem(hWnd, IDC_CHECK_GENERATEMAPS), bEnabled);
return TRUE;
}
//----------------------------------------------------------------------------
BOOL Max8SceneExport::OnModifiersChecked(HWND hWnd, BOOL bEnabled)
{
// 点击"Modifiers"时的动作.
EnableWindow(GetDlgItem(hWnd, IDC_CHECK_SKINS), bEnabled);
EnableWindow(GetDlgItem(hWnd, IDC_CHECK_GPU), bEnabled);
return TRUE;
}
//----------------------------------------------------------------------------
BOOL Max8SceneExport::OnObjectsChecked(HWND hWnd, BOOL bEnabled)
{
// 点击"Objects"时的动作.
EnableWindow(GetDlgItem(hWnd, IDC_CHECK_MESHES), bEnabled);
EnableWindow(GetDlgItem(hWnd, IDC_CHECK_CAMERAS), bEnabled);
EnableWindow(GetDlgItem(hWnd, IDC_CHECK_LIGHTS), bEnabled);
// mesh及其子选项本身处在object子选项组中,因此传递给mesh组.
OnMeshChecked(hWnd, bEnabled && IsDlgButtonChecked(hWnd, IDC_CHECK_MESHES));
return TRUE;
}
//----------------------------------------------------------------------------
void Max8SceneExport::OnOK(HWND hWnd)
{
// 用户点击OK按钮.
// 在实际导出工作开始前,获取导出器UI上的相关选项配置数据并加以验证.
m_Settings.IncludeObjects =
IsDlgButtonChecked(hWnd, IDC_CHECK_OBJECTS);
m_Settings.IncludeLights =
IsDlgButtonChecked(hWnd, IDC_CHECK_LIGHTS);
m_Settings.IncludeCameras =
IsDlgButtonChecked(hWnd, IDC_CHECK_CAMERAS);
m_Settings.IncludeMeshes =
IsDlgButtonChecked(hWnd, IDC_CHECK_MESHES);
m_Settings.IncludeNormals =
IsDlgButtonChecked(hWnd, IDC_CHECK_NORMALS);
m_Settings.IncludeVertexColors =
IsDlgButtonChecked(hWnd, IDC_CHECK_VERTEXCOLS);
m_Settings.IncludeTexCoords =
IsDlgButtonChecked(hWnd, IDC_CHECK_TEXCOORDS);
m_Settings.IncludeMaterials =
IsDlgButtonChecked(hWnd, IDC_CHECK_MATERIALS);
m_Settings.GenerateMaps =
IsDlgButtonChecked(hWnd, IDC_CHECK_GENERATEMAPS);
m_Settings.IncludeModifiers =
IsDlgButtonChecked(hWnd, IDC_CHECK_MODIFIERS);
m_Settings.IncludeSkins =
IsDlgButtonChecked(hWnd, IDC_CHECK_SKINS);
m_Settings.UseGPUSkin =
IsDlgButtonChecked(hWnd, IDC_CHECK_GPU);
m_Settings.IncludeAllFrames =
IsDlgButtonChecked(hWnd, IDC_RADIO_ALLFRAMES);
m_Settings.IncludeKeyFrames =
IsDlgButtonChecked(hWnd, IDC_RADIO_KEYFRAMES);
m_Settings.IncludeCurrentFrame =
IsDlgButtonChecked(hWnd, IDC_RADIO_CURRENTFRAME);
m_Settings.UseLocalTime =
IsDlgButtonChecked(hWnd, IDC_CHECK_USELOCALTIME);
// 从相关spinner控件获取导出动画起始桢和结束桢.
if( m_Settings.IncludeAllFrames || m_Settings.IncludeKeyFrames )
{
ISpinnerControl* pSpinner = GetISpinner(GetDlgItem(hWnd,
IDC_SPINNER_STARTFRAME));
m_Settings.StartFrame = pSpinner->GetIVal();
ReleaseISpinner(pSpinner);
pSpinner = GetISpinner(GetDlgItem(hWnd, IDC_SPINNER_ENDFRAME));
m_Settings.EndFrame = pSpinner->GetIVal();
ReleaseISpinner(pSpinner);
}
// 进行UI选项配置合理性纠正.
m_EffectiveSettings = m_Settings;
if( !m_Settings.IncludeObjects )
{
m_EffectiveSettings.IncludeCameras = FALSE;
m_EffectiveSettings.IncludeLights = FALSE;
m_EffectiveSettings.IncludeMeshes = FALSE;
}
if( !m_EffectiveSettings.IncludeMeshes )
{
m_EffectiveSettings.IncludeNormals = FALSE;
m_EffectiveSettings.IncludeMaterials = FALSE;
m_EffectiveSettings.IncludeVertexColors = FALSE;
m_EffectiveSettings.IncludeTexCoords = FALSE;
m_EffectiveSettings.GenerateMaps = FALSE;
}
if( !m_Settings.IncludeModifiers )
{
m_Settings.IncludeSkins = FALSE;
}
}
//----------------------------------------------------------------------------
BOOL Max8SceneExport::OnStartFrameSpinnerChanged(HWND hWnd)
{
// 当用户修改起始桢spinner控件的数据时调用.
// 获取起始桢数据.
ISpinnerControl* pSpinner = GetISpinner(GetDlgItem(hWnd,
IDC_SPINNER_STARTFRAME));
int iStartFrame = pSpinner->GetIVal();
ReleaseISpinner(pSpinner);
// 获取结束桢数据,并确保其值大于等于起始桢值.
pSpinner = GetISpinner(GetDlgItem(hWnd,IDC_SPINNER_ENDFRAME));
int iEndFrame = pSpinner->GetIVal();
if( iEndFrame < iStartFrame )
pSpinner->SetValue(iStartFrame, FALSE);
ReleaseISpinner(pSpinner);
return TRUE;
}
//----------------------------------------------------------------------------
| [
"[email protected]@876e9856-8d94-11de-b760-4d83c623b0ac"
] | [
[
[
1,
573
]
]
] |
77fe7ba3b3ef82188e6fb6ff45f4b5e0357cd59c | 347fdd4d3b75c3ab0ecca61cf3671d2e6888e0d1 | /addons/vaNetwork/include/vaNetwork/NonCopyable.h | 74e4706b70a2acb155df8c767215a96acdd9a90f | [] | no_license | sanyaade/VirtualAwesome | 29688648aa3f191cdd756c826b5c84f6f841b93f | 05f3db98500366be1e79da16f5e353e366aed01f | refs/heads/master | 2020-12-01T03:03:51.561884 | 2010-11-08T00:17:44 | 2010-11-08T00:17:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,417 | h | ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila ([email protected])
//
// 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.
//
////////////////////////////////////////////////////////////
#ifndef VANETWORK_NONCOPYABLE
#define VANETWORK_NONCOPYABLE
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <vaNetwork/Config.h>
namespace vaNetwork {
////////////////////////////////////////////////////////////
/// \brief Utility class that makes any derived
/// class non-copyable
///
////////////////////////////////////////////////////////////
class SFML_API NonCopyable
{
protected :
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
/// Because this class has a copy constructor, the compiler
/// will not automatically generate the default constructor.
/// That's why we must define it explicitely.
///
////////////////////////////////////////////////////////////
NonCopyable() {}
private :
////////////////////////////////////////////////////////////
/// \brief Disabled copy constructor
///
/// By making the copy constructor private, the compiler will
/// trigger an error if anyone outside tries to use it.
/// To prevent NonCopyable or friend classes from using it,
/// we also give no definition, so that the linker will
/// produce an error if the first protection was inefficient.
///
////////////////////////////////////////////////////////////
NonCopyable(const NonCopyable&);
////////////////////////////////////////////////////////////
/// \brief Disabled assignment operator
///
/// By making the assignment operator private, the compiler will
/// trigger an error if anyone outside tries to use it.
/// To prevent NonCopyable or friend classes from using it,
/// we also give no definition, so that the linker will
/// produce an error if the first protection was inefficient.
///
////////////////////////////////////////////////////////////
NonCopyable& operator =(const NonCopyable&);
};
}
#endif
////////////////////////////////////////////////////////////
/// \class vaNetwork::NonCopyable
/// \ingroup system
///
/// This class makes its instances non-copyable, by explicitely
/// disabling its copy constructor and its assignment operator.
///
/// To create a non-copyable class, simply inherit from
/// vaNetwork::NonCopyable.
///
/// The type of inheritance (public or private) doesn't matter,
/// the copy constructor and assignment operator are declared private
/// in vaNetwork::NonCopyable so they will end up being inaccessible in both
/// cases. Thus you can use a shorter syntax for inheriting from it
/// see below).
///
/// Usage example:
/// \code
/// class MyNonCopyableClass : vaNetwork::NonCopyable
/// {
/// ...
/// };
/// \endcode
///
/// Deciding whether the instances of a class can be copied
/// or not is a very important design choice. You are strongly
/// encouraged to think about it before writing a class,
/// and to use vaNetwork::NonCopyable when necessary to prevent
/// many potential future errors when using it. This is also
/// a very important indication to users of your class.
///
////////////////////////////////////////////////////////////
| [
"[email protected]"
] | [
[
[
1,
118
]
]
] |
82e1acdbf27fe8550b927e9366a44b6611015a7b | e0cd16e9d5869dd21a5d45f838412b0e14c947fd | /code_reviews/mpi_cr/thresh/thresh.cpp | 540e3b12cac657bc8380beac87660f467e9e68de | [] | no_license | ptkila/cowichan | d193fdfc109bbf1b5dca802a65910d79b7f6d612 | 42ce55bbda400d839d5d5e4c22fda103556b3698 | refs/heads/master | 2021-01-01T05:59:27.199307 | 2010-12-09T03:07:55 | 2010-12-09T03:07:55 | 34,251,347 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,333 | cpp | /**
* Histogram thresholding
*
* \file vecdiff.cpp
* \author Andrew Borzenko
* \date 03-02-09
*/
#include "../include/main.h"
#ifdef IS_PARALLEL
#include "parallel.h"
#else
#include "serial.h"
#endif
int main(int argc, char* argv[])
{
#ifdef IS_PARALLEL
mpi::environment env(argc, argv);
mpi::communicator world;
#ifdef TEST_OUTPUT
printf ("I am process %d\n", world.rank ());
#endif
#endif
int2D* matrix;
bool2D* mask;
int nr, nc;
real fraction;
int i, j;
int limit;
nr = MAXEXT;
nc = MAXEXT;
limit = 10;
fraction = 0.5;
srand (222);
matrix = new int2D[MAXEXT];
for (i = 0; i < nr; i++) {
for (j = 0; j < nc; j++) {
matrix[i][j] = rand () % limit;
}
}
mask = new bool2D[MAXEXT];
#ifdef TEST_OUTPUT
printf ("Matrix is:\n");
print_matrix (matrix, nr, nc);
#endif
#ifdef TEST_TIME
INT64 start, end;
start = get_ticks ();
#endif
#ifdef IS_PARALLEL
thresh_mpi (world, matrix, mask, nr, nc, fraction);
#else
thresh (matrix, mask, nr, nc, fraction);
#endif
#ifdef TEST_TIME
end = get_ticks ();
print_elapsed_time (start, end);
#endif
#ifdef TEST_OUTPUT
printf ("Mask is:\n");
print_matrix (mask, nr, nc);
#endif
delete [] matrix;
delete [] mask;
return 0;
}
| [
"g7gorrie@766ed74a-8921-11de-91c6-75d7f44f5486"
] | [
[
[
1,
80
]
]
] |
b3fa6c90ce9b72983533f00b05d9311bc60aac6b | 709cd826da3ae55945fd7036ecf872ee7cdbd82a | /Term/WildMagic2/Source/Math/WmlGMatrix.cpp | 6a182eb6f4f3924edde7878f1598a1269220297c | [] | no_license | argapratama/kucgbowling | 20dbaefe1596358156691e81ccceb9151b15efb0 | 65e40b6f33c5511bddf0fa350c1eefc647ace48a | refs/heads/master | 2018-01-08T15:27:44.784437 | 2011-06-19T15:23:39 | 2011-06-19T15:23:39 | 36,738,655 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 19,354 | cpp | // Magic Software, Inc.
// http://www.magic-software.com
// http://www.wild-magic.com
// Copyright (c) 2003. All Rights Reserved
//
// The Wild Magic Library (WML) source code is supplied under the terms of
// the license agreement http://www.magic-software.com/License/WildMagic.pdf
// and may not be copied or disclosed except in accordance with the terms of
// that agreement.
#include "WmlGMatrix.h"
using namespace Wml;
//----------------------------------------------------------------------------
template <class Real>
GMatrix<Real>::GMatrix (int iRows, int iCols)
{
m_afData = 0;
m_aafEntry = 0;
SetSize(iRows,iCols);
}
//----------------------------------------------------------------------------
template <class Real>
GMatrix<Real>::GMatrix (int iRows, int iCols, const Real* afEntry)
{
m_afData = 0;
m_aafEntry = 0;
SetMatrix(iRows,iCols,afEntry);
}
//----------------------------------------------------------------------------
template <class Real>
GMatrix<Real>::GMatrix (int iRows, int iCols, const Real** aafMatrix)
{
m_afData = 0;
m_aafEntry = 0;
SetMatrix(iRows,iCols,aafMatrix);
}
//----------------------------------------------------------------------------
template <class Real>
GMatrix<Real>::GMatrix (const GMatrix& rkM)
{
m_iRows = 0;
m_iCols = 0;
m_iQuantity = 0;
m_afData = 0;
m_aafEntry = 0;
*this = rkM;
}
//----------------------------------------------------------------------------
template <class Real>
GMatrix<Real>::~GMatrix ()
{
Deallocate();
}
//----------------------------------------------------------------------------
template <class Real>
void GMatrix<Real>::Allocate (bool bSetToZero)
{
// assert: m_iRows, m_iCols, and m_iQuantity already initialized
m_afData = new Real[m_iQuantity];
if ( bSetToZero )
memset(m_afData,0,m_iQuantity*sizeof(Real));
m_aafEntry = new Real*[m_iRows];
for (int iRow = 0; iRow < m_iRows; iRow++)
m_aafEntry[iRow] = &m_afData[iRow*m_iCols];
}
//----------------------------------------------------------------------------
template <class Real>
void GMatrix<Real>::Deallocate ()
{
delete[] m_afData;
delete[] m_aafEntry;
}
//----------------------------------------------------------------------------
template <class Real>
void GMatrix<Real>::SetSize (int iRows, int iCols)
{
Deallocate();
if ( iRows > 0 && iCols > 0 )
{
m_iRows = iRows;
m_iCols = iCols;
m_iQuantity = m_iRows*m_iCols;
Allocate(true);
}
else
{
m_iRows = 0;
m_iCols = 0;
m_iQuantity = 0;
m_afData = 0;
m_aafEntry = 0;
}
}
//----------------------------------------------------------------------------
template <class Real>
void GMatrix<Real>::GetSize (int& riRows, int& riCols) const
{
riRows = m_iRows;
riCols = m_iCols;
}
//----------------------------------------------------------------------------
template <class Real>
int GMatrix<Real>::GetRows () const
{
return m_iRows;
}
//----------------------------------------------------------------------------
template <class Real>
int GMatrix<Real>::GetColumns () const
{
return m_iCols;
}
//----------------------------------------------------------------------------
template <class Real>
int GMatrix<Real>::GetQuantity () const
{
return m_iQuantity;
}
//----------------------------------------------------------------------------
template <class Real>
GMatrix<Real>::operator const Real* () const
{
return m_afData;
}
//----------------------------------------------------------------------------
template <class Real>
GMatrix<Real>::operator Real* ()
{
return m_afData;
}
//----------------------------------------------------------------------------
template <class Real>
const Real* GMatrix<Real>::operator[] (int iRow) const
{
assert( 0 <= iRow && iRow < m_iRows );
return m_aafEntry[iRow];
}
//----------------------------------------------------------------------------
template <class Real>
Real* GMatrix<Real>::operator[] (int iRow)
{
assert( 0 <= iRow && iRow < m_iRows );
return m_aafEntry[iRow];
}
//----------------------------------------------------------------------------
template <class Real>
void GMatrix<Real>::SwapRows (int iRow0, int iRow1)
{
assert( 0 <= iRow0 && iRow0 < m_iRows && 0 <= iRow1 && iRow1 < m_iRows );
Real* afSave = m_aafEntry[iRow0];
m_aafEntry[iRow0] = m_aafEntry[iRow1];
m_aafEntry[iRow1] = afSave;
}
//----------------------------------------------------------------------------
template <class Real>
Real GMatrix<Real>::operator() (int iRow, int iCol) const
{
return m_aafEntry[iRow][iCol];
}
//----------------------------------------------------------------------------
template <class Real>
Real& GMatrix<Real>::operator() (int iRow, int iCol)
{
assert( 0 <= iRow && iRow < m_iRows && 0 <= iCol && iCol <= m_iCols );
return m_aafEntry[iRow][iCol];
}
//----------------------------------------------------------------------------
template <class Real>
void GMatrix<Real>::SetRow (int iRow, const GVector<Real>& rkV)
{
assert( (0 <= iRow && iRow < m_iRows) && (rkV.GetSize() == m_iCols) );
for (int iCol = 0; iCol < m_iCols; iCol++)
m_aafEntry[iRow][iCol] = rkV[iCol];
}
//----------------------------------------------------------------------------
template <class Real>
GVector<Real> GMatrix<Real>::GetRow (int iRow) const
{
assert( 0 <= iRow && iRow < m_iRows );
GVector<Real> kV(m_iCols);
for (int iCol = 0; iCol < m_iCols; iCol++)
kV[iCol] = m_aafEntry[iRow][iCol];
return kV;
}
//----------------------------------------------------------------------------
template <class Real>
void GMatrix<Real>::SetColumn (int iCol, const GVector<Real>& rkV)
{
assert( (0 <= iCol && iCol < m_iCols) && (rkV.GetSize() == m_iRows) );
for (int iRow = 0; iRow < m_iRows; iRow++)
m_aafEntry[iRow][iCol] = rkV[iRow];
}
//----------------------------------------------------------------------------
template <class Real>
GVector<Real> GMatrix<Real>::GetColumn (int iCol) const
{
assert( 0 <= iCol && iCol < m_iCols );
GVector<Real> kV(m_iRows);
for (int iRow = 0; iRow < m_iRows; iRow++)
kV[iRow] = m_aafEntry[iRow][iCol];
return kV;
}
//----------------------------------------------------------------------------
template <class Real>
void GMatrix<Real>::SetMatrix (int iRows, int iCols, const Real* afData)
{
Deallocate();
if ( iRows > 0 && iCols > 0 )
{
m_iRows = iRows;
m_iCols = iCols;
m_iQuantity = m_iRows*m_iCols;
Allocate(false);
memcpy(m_afData,afData,m_iQuantity*sizeof(Real));
}
else
{
m_iRows = 0;
m_iCols = 0;
m_iQuantity = 0;
m_afData = 0;
m_aafEntry = 0;
}
}
//----------------------------------------------------------------------------
template <class Real>
void GMatrix<Real>::SetMatrix (int iRows, int iCols, const Real** aafEntry)
{
Deallocate();
if ( iRows > 0 && iCols > 0 )
{
m_iRows = iRows;
m_iCols = iCols;
m_iQuantity = m_iRows*m_iCols;
Allocate(false);
for (int iRow = 0; iRow < m_iRows; iRow++)
{
for (int iCol = 0; iCol < m_iCols; iCol++)
m_aafEntry[iRow][iCol] = aafEntry[iRow][iCol];
}
}
else
{
m_iRows = 0;
m_iCols = 0;
m_iQuantity = 0;
m_afData = 0;
m_aafEntry = 0;
}
}
//----------------------------------------------------------------------------
template <class Real>
void GMatrix<Real>::GetColumnMajor (Real* afCMajor) const
{
for (int iRow = 0, i = 0; iRow < m_iRows; iRow++)
{
for (int iCol = 0; iCol < m_iCols; iCol++)
afCMajor[i++] = m_aafEntry[iCol][iRow];
}
}
//----------------------------------------------------------------------------
template <class Real>
GMatrix<Real>& GMatrix<Real>::operator= (const GMatrix& rkM)
{
if ( rkM.m_iQuantity > 0 )
{
if ( m_iRows != rkM.m_iRows || m_iCols != rkM.m_iCols )
{
Deallocate();
m_iRows = rkM.m_iRows;
m_iCols = rkM.m_iCols;
m_iQuantity = rkM.m_iQuantity;
Allocate(false);
}
memcpy(m_afData,rkM.m_afData,m_iQuantity*sizeof(Real));
}
else
{
Deallocate();
m_iRows = 0;
m_iCols = 0;
m_iQuantity = 0;
m_afData = 0;
m_aafEntry = 0;
}
return *this;
}
//----------------------------------------------------------------------------
template <class Real>
bool GMatrix<Real>::operator== (const GMatrix& rkM) const
{
return memcmp(m_afData,rkM.m_afData,m_iQuantity*sizeof(Real)) == 0;
}
//----------------------------------------------------------------------------
template <class Real>
bool GMatrix<Real>::operator!= (const GMatrix& rkM) const
{
return memcmp(m_afData,rkM.m_afData,m_iQuantity*sizeof(Real)) != 0;
}
//----------------------------------------------------------------------------
template <class Real>
int GMatrix<Real>::CompareArrays (const GMatrix& rkM) const
{
for (int i = 0; i < m_iQuantity; i++)
{
unsigned int uiTest0 = *(unsigned int*)&m_afData[i];
unsigned int uiTest1 = *(unsigned int*)&rkM.m_afData[i];
if ( uiTest0 < uiTest1 )
return -1;
if ( uiTest0 > uiTest1 )
return +1;
}
return 0;
}
//----------------------------------------------------------------------------
template <class Real>
bool GMatrix<Real>::operator< (const GMatrix& rkM) const
{
return CompareArrays(rkM) < 0;
}
//----------------------------------------------------------------------------
template <class Real>
bool GMatrix<Real>::operator<= (const GMatrix& rkM) const
{
return CompareArrays(rkM) <= 0;
}
//----------------------------------------------------------------------------
template <class Real>
bool GMatrix<Real>::operator> (const GMatrix& rkM) const
{
return CompareArrays(rkM) > 0;
}
//----------------------------------------------------------------------------
template <class Real>
bool GMatrix<Real>::operator>= (const GMatrix& rkM) const
{
return CompareArrays(rkM) >= 0;
}
//----------------------------------------------------------------------------
template <class Real>
GMatrix<Real> GMatrix<Real>::operator+ (const GMatrix& rkM) const
{
GMatrix<Real> kSum(rkM.m_iRows,rkM.m_iCols);
for (int i = 0; i < m_iQuantity; i++)
kSum.m_afData[i] = m_afData[i] + rkM.m_afData[i];
return kSum;
}
//----------------------------------------------------------------------------
template <class Real>
GMatrix<Real> GMatrix<Real>::operator- (const GMatrix& rkM) const
{
GMatrix<Real> kDiff(rkM.m_iRows,rkM.m_iCols);
for (int i = 0; i < m_iQuantity; i++)
kDiff.m_afData[i] = m_afData[i] - rkM.m_afData[i];
return kDiff;
}
//----------------------------------------------------------------------------
template <class Real>
GMatrix<Real> GMatrix<Real>::operator* (const GMatrix& rkM) const
{
// 'this' is RxN, 'M' is NxC, 'product = this*M' is RxC
assert( m_iCols == rkM.m_iRows );
GMatrix<Real> kProd(m_iRows,rkM.m_iCols);
for (int iRow = 0; iRow < kProd.m_iRows; iRow++)
{
for (int iCol = 0; iCol < kProd.m_iCols; iCol++)
{
for (int iMid = 0; iMid < m_iCols; iMid++)
{
kProd.m_aafEntry[iRow][iCol] += m_aafEntry[iRow][iMid] *
rkM.m_aafEntry[iMid][iCol];
}
}
}
return kProd;
}
//----------------------------------------------------------------------------
template <class Real>
GMatrix<Real> GMatrix<Real>::operator* (Real fScalar) const
{
GMatrix<Real> kProd(m_iRows,m_iCols);
for (int i = 0; i < m_iQuantity; i++)
kProd.m_afData[i] = fScalar*m_afData[i];
return kProd;
}
//----------------------------------------------------------------------------
template <class Real>
GMatrix<Real> GMatrix<Real>::operator/ (Real fScalar) const
{
GMatrix<Real> kQuot(m_iRows,m_iCols);
int i;
if ( fScalar != (Real)0.0 )
{
Real fInvScalar = ((Real)1.0)/fScalar;
for (i = 0; i < m_iQuantity; i++)
kQuot.m_afData[i] = fInvScalar*m_afData[i];
}
else
{
for (i = 0; i < m_iQuantity; i++)
kQuot.m_afData[i] = Math<Real>::MAX_REAL;
}
return kQuot;
}
//----------------------------------------------------------------------------
template <class Real>
GMatrix<Real> GMatrix<Real>::operator- () const
{
GMatrix<Real> kNeg(m_iRows,m_iCols);
for (int i = 0; i < m_iQuantity; i++)
kNeg.m_afData[i] = -m_afData[i];
return kNeg;
}
//----------------------------------------------------------------------------
template <class Real>
GMatrix<Real> Wml::operator* (Real fScalar, const GMatrix<Real>& rkM)
{
GMatrix<Real> kProd(rkM.GetRows(),rkM.GetColumns());
const Real* afMEntry = rkM;
Real* afPEntry = kProd;
for (int i = 0; i < rkM.GetQuantity(); i++)
afPEntry[i] = fScalar*afMEntry[i];
return kProd;
}
//----------------------------------------------------------------------------
template <class Real>
GMatrix<Real>& GMatrix<Real>::operator+= (const GMatrix& rkM)
{
for (int i = 0; i < m_iQuantity; i++)
m_afData[i] += rkM.m_afData[i];
return *this;
}
//----------------------------------------------------------------------------
template <class Real>
GMatrix<Real>& GMatrix<Real>::operator-= (const GMatrix& rkM)
{
for (int i = 0; i < m_iQuantity; i++)
m_afData[i] -= rkM.m_afData[i];
return *this;
}
//----------------------------------------------------------------------------
template <class Real>
GMatrix<Real>& GMatrix<Real>::operator*= (Real fScalar)
{
for (int i = 0; i < m_iQuantity; i++)
m_afData[i] *= fScalar;
return *this;
}
//----------------------------------------------------------------------------
template <class Real>
GMatrix<Real>& GMatrix<Real>::operator/= (Real fScalar)
{
int i;
if ( fScalar != (Real)0.0 )
{
Real fInvScalar = ((Real)1.0)/fScalar;
for (i = 0; i < m_iQuantity; i++)
m_afData[i] *= fInvScalar;
}
else
{
for (i = 0; i < m_iQuantity; i++)
m_afData[i] = Math<Real>::MAX_REAL;
}
return *this;
}
//----------------------------------------------------------------------------
template <class Real>
GMatrix<Real> GMatrix<Real>::Transpose () const
{
GMatrix<Real> kTranspose(m_iCols,m_iRows);
for (int iRow = 0; iRow < m_iRows; iRow++)
{
for (int iCol = 0; iCol < m_iCols; iCol++)
kTranspose.m_aafEntry[iCol][iRow] = m_aafEntry[iRow][iCol];
}
return kTranspose;
}
//----------------------------------------------------------------------------
template <class Real>
GMatrix<Real> GMatrix<Real>::TransposeTimes (const GMatrix& rkM) const
{
// P = A^T*B, P[r][c] = sum_m A[m][r]*B[m][c]
assert( m_iRows == rkM.m_iRows );
GMatrix<Real> kProd(m_iCols,rkM.m_iCols);
for (int iRow = 0; iRow < kProd.m_iRows; iRow++)
{
for (int iCol = 0; iCol < kProd.m_iCols; iCol++)
{
for (int iMid = 0; iMid < m_iRows; iMid++)
{
kProd.m_aafEntry[iRow][iCol] += m_aafEntry[iMid][iRow] *
rkM.m_aafEntry[iMid][iCol];
}
}
}
return kProd;
}
//----------------------------------------------------------------------------
template <class Real>
GMatrix<Real> GMatrix<Real>::TimesTranspose (const GMatrix& rkM) const
{
// P = A*B^T, P[r][c] = sum_m A[r][m]*B[c][m]
assert( m_iCols == rkM.m_iCols );
GMatrix<Real> kProd(m_iRows,rkM.m_iRows);
for (int iRow = 0; iRow < kProd.m_iRows; iRow++)
{
for (int iCol = 0; iCol < kProd.m_iCols; iCol++)
{
for (int iMid = 0; iMid < m_iCols; iMid++)
{
kProd.m_aafEntry[iRow][iCol] += m_aafEntry[iRow][iMid] *
rkM.m_aafEntry[iCol][iRow];
}
}
}
return kProd;
}
//----------------------------------------------------------------------------
template <class Real>
GVector<Real> GMatrix<Real>::operator* (const GVector<Real>& rkV) const
{
assert( rkV.GetSize() == m_iCols );
GVector<Real> kProd(m_iRows);
for (int iRow = 0; iRow < m_iRows; iRow++)
{
for (int iCol = 0; iCol < m_iCols; iCol++)
kProd[iRow] += m_aafEntry[iRow][iCol]*rkV[iCol];
}
return kProd;
}
//----------------------------------------------------------------------------
template <class Real>
GVector<Real> Wml::operator* (const GVector<Real>& rkV,
const GMatrix<Real>& rkM)
{
assert( rkV.GetSize() == rkM.GetRows() );
GVector<Real> kProd(rkM.GetColumns());
Real* afPEntry = kProd;
for (int iCol = 0; iCol < rkM.GetColumns(); iCol++)
{
for (int iRow = 0; iRow < rkM.GetRows(); iRow++)
afPEntry[iCol] += rkV[iRow]*rkM[iRow][iCol];
}
return kProd;
}
//----------------------------------------------------------------------------
template <class Real>
Real GMatrix<Real>::QForm (const GVector<Real>& rkU, const GVector<Real>& rkV)
const
{
assert( rkU.GetSize() == m_iRows && rkV.GetSize() == m_iCols );
return rkU.Dot((*this)*rkV);
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
// explicit instantiation
//----------------------------------------------------------------------------
namespace Wml
{
template class WML_ITEM GMatrix<float>;
#ifdef WML_USING_VC6
template WML_ITEM GMatrix<float> operator* (float,
const GMatrix<float>&);
template WML_ITEM GVector<float> operator*
(const GVector<float>&, const GMatrix<float>&);
#else
template WML_ITEM GMatrix<float> operator*<float> (float,
const GMatrix<float>&);
template WML_ITEM GVector<float> operator*<float>
(const GVector<float>&, const GMatrix<float>&);
#endif
template class WML_ITEM GMatrix<double>;
#ifdef WML_USING_VC6
template WML_ITEM GMatrix<double> operator* (double,
const GMatrix<double>&);
template WML_ITEM GVector<double> operator*
(const GVector<double>&, const GMatrix<double>&);
#else
template WML_ITEM GMatrix<double> operator*<double> (double,
const GMatrix<double>&);
template WML_ITEM GVector<double> operator*<double>
(const GVector<double>&, const GMatrix<double>&);
#endif
}
//----------------------------------------------------------------------------
| [
"[email protected]"
] | [
[
[
1,
598
]
]
] |
30c2c16567960dfda92d7a2648e8eae7975461e9 | 1e01b697191a910a872e95ddfce27a91cebc57dd | /GrfPushItem.h | d6c41610c95d962b80f66eac9cafa593366d4db1 | [] | 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,606 | h | /* "CodeWorker": a scripting language for parsing and generating text.
Copyright (C) 1996-1997, 1999-2002 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]
*/
#ifndef _GrfPushItem_h_
#define _GrfPushItem_h_
#include "GrfCommand.h"
namespace CodeWorker {
class ExprScriptVariable;
class GrfPushItem : public GrfCommand {
private:
ExprScriptVariable* _pVariable;
ExprScriptExpression* _pValue;
public:
GrfPushItem() : _pVariable(NULL), _pValue(NULL) {}
virtual ~GrfPushItem();
inline void setVariable(ExprScriptVariable* pVariable) { _pVariable = pVariable; }
inline void setValue(ExprScriptExpression* pValue) { _pValue = pValue; }
virtual void compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const;
protected:
virtual SEQUENCE_INTERRUPTION_LIST executeInternal(DtaScriptVariable& visibility);
};
}
#endif
| [
"cedric.p.r.lemaire@28b3f5f3-d42e-7560-b87f-5f53cf622bc4"
] | [
[
[
1,
49
]
]
] |
29b1ffd2ec8ff0ec1a952e90f26c89e8f7c35431 | 619941b532c6d2987c0f4e92b73549c6c945c7e5 | /Include/Nuclex/GUI/ListWidget.h | 99c0a0748c1acb0160c5782711a3ea17c7b5104f | [] | no_license | dzw/stellarengine | 2b70ddefc2827be4f44ec6082201c955788a8a16 | 2a0a7db2e43c7c3519e79afa56db247f9708bc26 | refs/heads/master | 2016-09-01T21:12:36.888921 | 2008-12-12T12:40:37 | 2008-12-12T12:40:37 | 36,939,169 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,722 | h | // //
// # # ### # # -= Nuclex Library =- //
// ## # # # ## ## ListWidget.h - List GUI component //
// ### # # ### //
// # ### # ### A pressable button which fires an event when the user clicks on it //
// # ## # # ## ## //
// # # ### # # R1 (C)2002-2004 Markus Ewald -> License.txt //
// //
#ifndef NUCLEX_GUI_LISTWIDGET_H
#define NUCLEX_GUI_LISTWIDGET_H
#include "Nuclex/Nuclex.h"
#include "Nuclex/Support/Exception.h"
#include "Nuclex/GUI/Widget.h"
#include "Nuclex/GUI/SliderWidget.h"
#include "SigC++/SigC++.h"
#include <vector>
namespace Nuclex {
namespace Text { class Font; }
}
namespace Nuclex { namespace GUI {
// //
// Nuclex::GUI::ListWidget //
// //
/// GUI widget
/**
*/
class ListWidget :
public Widget {
public:
typedef SigC::Signal1<void, size_t> SelectSignal;
/// Painter for ListWidgets
NUCLEX_API static class Painter {
public:
/// Destructor
virtual ~Painter() {}
//
// Painter implementation
//
public:
/// Draw the list
NUCLEX_API virtual void operator ()(Video::VertexDrawer &VD, Theme &T,
ListWidget &TheList) {
T.drawCell(
VD, TheList.getStyle(), TheList.getRegion()
);
Box2<float> Region = TheList.getRegion();
Region.TL.Y -= TheList.getScrollOffset();
for(size_t Item = 0; Item < TheList.getItems().size(); ++Item) {
Region.BR.Y = Region.TL.Y + T.measureRegion(
TheList.getStyle(), TheList.getItems()[Item]
).getHeight() + 2;
if(Region.BR.Y >= TheList.getRegion().BR.Y)
break;
if(Region.TL.Y >= TheList.getRegion().TL.Y) {
T.drawText(
VD, TheList.getStyle(), Region, TheList.getItems()[Item]
);
}
Region.TL.Y = Region.BR.Y;
}
Region = TheList.getRegion();
Region.TL.Y += 1;
Region.BR.X -= 1;
Region.BR.Y -= 1;
Region.TL.X = Region.BR.X - 16;
TheList.getSlider()->setRegion(Region);
TheList.getSlider()->draw(VD, T);
}
} DefaultPainter;
/// Constructor
NUCLEX_API ListWidget(
const Box2<real> &Region, const std::vector<wstring> &Items = std::vector<wstring>(),
const string sStyle = "list",
Painter &ThePainter = DefaultPainter
);
/// Destructor
NUCLEX_API virtual ~ListWidget() {}
//
// ListWidget implementation
//
public:
/// Fired when the button is clicked
SelectSignal OnSelect;
/// Check whether the list is enabled or not
NUCLEX_API bool isEnabled() const { return m_bEnabled; }
/// Enable or disable the list
NUCLEX_API virtual void setEnabled(bool bEnabled = true) { m_bEnabled = bEnabled; }
/// Get the list's text
NUCLEX_API const std::vector<wstring> &getItems() const { return m_Items; }
/// Set the list's text
NUCLEX_API virtual void setItems(const std::vector<wstring> &Items);
NUCLEX_API const shared_ptr<SliderWidget> &getSlider() const { return m_spSlider; }
NUCLEX_API void setSlider(const shared_ptr<SliderWidget> &spSlider) { m_spSlider = spSlider; }
NUCLEX_API size_t getScrollOffset() const { return m_ScrollOffset; }
//
// Widget implementation
//
public:
/// Clone the widget
NUCLEX_API virtual shared_ptr<Widget> clone() const;
/// Returns whether the widget can get the input focus
NUCLEX_API bool canGetFocus() const { return m_bEnabled; }
/// Check whether the control was hit
NUCLEX_API virtual bool hitTest(const Point2<real> &Position) {
return (m_bEnabled && m_Region.intersects(Position));
}
/// Draws the widget
NUCLEX_API virtual void draw(Video::VertexDrawer &VD, Theme &T) {
m_Painter(VD, T, *this);
}
//
// InputReceiver implementation
//
public:
/// Process user input
NUCLEX_API virtual bool processInput(const Event &InputEvent);
protected:
bool m_bEnabled; ///< User interaction enabled ?
std::vector<wstring> m_Items; ///< List items
size_t m_ScrollOffset; ///< Scrolling offset
std::list<size_t> m_SelectedItems; ///< Currently selected items
bool m_bMouseHover; ///< Is mouse hovering over button ?
bool m_bPressed; ///< Is button pressed ?
Painter &m_Painter; ///< Painter for the button
shared_ptr<SliderWidget> m_spSlider; ///< The list's slider
};
}} // namespace Nuclex::GUI
#endif // NUCLEX_GUI_LISTWIDGET_H
| [
"ctuoMail@5f320639-c338-0410-82ad-c55551ec1e38"
] | [
[
[
1,
152
]
]
] |
f63cda553c510dee8fa65a42c476684e8103109f | be78c6c17e74febd81d3f89e88347a0d009f4c99 | /src/GoIO_cpp/GTextUtils.cpp | 495c5fd2d9725a07086c86a0f75720364b51713d | [] | no_license | concord-consortium/goio_sdk | 87b3f816199e0bc3bd03cf754e0daf2b6a10f792 | e371fd14b8962748e853f76a3a1b472063d12284 | refs/heads/master | 2021-01-22T09:41:53.246014 | 2011-07-14T21:33:34 | 2011-07-14T21:33:34 | 851,663 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 44,989 | cpp | // GTextUtils.cpp: implementation of the GTextUtils class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "GTextUtils.h"
//#include "GStreamTokenizer.h"
#include "GUtils.h"
//#include "GMessenger.h"
//#include "GMessages.h"
//#include "GApplicationBrain.h"
#ifdef _DEBUG
#include "GPlatformDebug.h" // for DEBUG_NEW definition
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/*MSVC10 fails if:*/
//using namespace std;
int GTextUtils::kSmallestFontSize = 8; // used in font size controls
int GTextUtils::kLargestFontSize = 72;
std::map<narrowstring, int> GTextUtils::m_mStringIndices;
std::vector<cppstring> GTextUtils::m_vStringData;
// all special chars are preceeded by this, then have a numerical code, then a semi colon. e.g. degree is "°"
// The numerical code is right out of the HTML4 Entity sets (pg. 425 of O'REILLY XML in a Nutshell)
const cppstring GTextUtils::kSpecialCharFlag = "&#";
StringVector GTextUtils::kvSpecialChar;
StringVector GTextUtils::kvSpecialCharCode;
StringVector GTextUtils::kvOutgoingSpecialChar;
StringVector GTextUtils::kvOutgoingSpecialCharCode;
/*
cppstring GTextUtils::RealToCPPString(real rNum, // the number to convert
int nPrecision, // The number or decimal places or sig figs to use. NOTE -1 ==> just use default processing
EFloatStyle eFloatStyle) // true ==> precision is decimal places, false ==> significant figures
{
// Returns a string representing real number according to nPrecision and
// eFloatStyle settings.
// get the current locale setting
cppstring sReturn;
if (!GUtils::OSIsValidNumber(rNum))
{ // this number is either a NAN or INF
sReturn = GSTD_STRING(IDSX_NOT_A_NUMBER);
}
else
{ // this number is good
if (eFloatStyle == kFloatStyle_preferred)
eFloatStyle = (nPrecision > 7) ? kFloatStyle_default : kFloatStyle_fixedPrecision;
// if (eFloatStyle == kFloatStyle_preferred)
// {
// if ((nPrecision > 7) && (fabs(rNum) < 100000))
// eFloatStyle = kFloatStyle_default;
// else
// eFloatStyle = kFloatStyle_fixedPrecision;
// }
// just make 1 string stream
cppsstream ssFixed;
ssFixed.imbue(GetAppBrain()->GetLocale());
cppsstream ssScientific;
ssScientific.imbue(GetAppBrain()->GetLocale());
cppsstream ssDefault;
ssDefault.imbue(GetAppBrain()->GetLocale());
if (eFloatStyle == kFloatStyle_fixedPrecision) // use fixed decimal precision
{
ssFixed.clear();
if (nPrecision == 0) // do not display the decimal point
ssFixed << fixed << uppercase << setprecision(nPrecision) << rNum;
else
ssFixed << fixed << uppercase << showpoint<< setprecision(nPrecision) << rNum;
cppstring sFixed = ssFixed.str();
// gspam
// char buffer[1024];
// sprintf(buffer, "%.*f", nPrecision, rNum);
// cppstring sFixed = buffer;
// get rid of "-" if the string is all zeros i.e (-0.0 -> 0.0)
if (rNum < 0.0 && rNum > -1.0)
{
if (sFixed.find_first_of(GSTD_S("123456789")) == cppstring::npos)
sFixed.replace(sFixed.find(GSTD_S("-")),1,GSTD_S("")); // get rid of "-"
}
ssScientific.clear();
if (nPrecision == 0) // Windows does not do scientific correctly for precision of 0 (Mac is OK) to work around the specification (scientific or fixed) is omitted and the system decides
ssScientific << uppercase << setprecision(0) << rNum;
else
ssScientific << scientific << uppercase << setprecision(nPrecision) << rNum;
cppstring sScientific = ssScientific.str();
// gspam
// sprintf(buffer, "%.*e", nPrecision, rNum);
// cppstring sScientific = buffer;
// return the shortest cppstring but make sure to check for 0 length, as the fixed string
// can be zero if really large >10e70 are used
if (sFixed.length() <= sScientific.length() && (sFixed.length() > 0))
sReturn = sFixed;
else
sReturn = sScientific;
}
else
if (eFloatStyle == kFloatStyle_fixedSigFigs)
{
cppstring sRounded = RealToCPPStringRoundedToSigDigits(rNum, nPrecision);
sReturn = sRounded;
// gspam
// char buffer[1024];
// sprintf(buffer, "%.*g", nPrecision, rNum);
// sReturn = buffer;
}
else
if (eFloatStyle == kFloatStyle_default)
{ // this block gets executed when editing cells or exporting data as text
// fixed or scientific is not specified below so
// setPrecision(n) can mean either n digits or n decimal places
// the default of 6 is not sufficient to handle data like 123456.78
// which gets exported as 123456.7 using the default
// so make it 12 to handle most cases
ssDefault.clear();
ssDefault << uppercase << setprecision(12) << rNum;
sReturn = ssDefault.str();
}
}
return sReturn;
}
cppstring GTextUtils::RealToCPPString(real rNum, int nPrecision, bool bPrecisionDecimal)
{ // RETURN converted number -- either with fixed or sigfigs
if (bPrecisionDecimal)
return RealToCPPString(rNum, nPrecision, kFloatStyle_fixedPrecision);
return RealToCPPString(rNum, nPrecision, kFloatStyle_fixedSigFigs);
}
cppstring GTextUtils::RealToDisplayCPPString(real rNum, int nDigits)
{ // RETURN converted number but don't display more than nDigits
real fPow = pow(10, nDigits);
rNum = floor(rNum * fPow + 0.5) / fPow;
return RealToCPPString(rNum);
}
cppstring GTextUtils::RealToCPPStringRoundedToSigDigits(real rNum , int nSigDigits)
{
cppstring sResult;
// get the user's preferred locale store in brain
#ifndef OPUS_DDK
locale langLocale = GetAppBrain()->GetLocale();
#else
locale langLocale;
#endif
cppsstream ss;
ss.imbue(langLocale);
//the next line converts the number to a string with appropriate rounding but
//does not include significant zeros so we have to put them back into sResult
ss << uppercase << setprecision(nSigDigits) << rNum;
sResult = ss.str();
long nEPosition = sResult.find(GSTD_S("E")); // is it scientific notation ?
// massage sResult padding with zeros if needed to get required number of digits
// count the digits up to the E or to the end if no E
// see if we need to pad with zero to get the required number of sig fig
int nEndPosition = 0;
if (nEPosition == cppstring::npos)
nEndPosition = sResult.length();
else
nEndPosition = nEPosition;
int numDigits = 0;
gchar ch;
gchar cDecimalPoint = '.';
GMessenger::AppMessage(GMsg::kGetDecimalPointChar, static_cast<void *>(&cDecimalPoint));
long nFirstNonZero = sResult.find_first_of(GSTD_S("123456789"));
// count the digits preceeding the E if there is an E or to the end otherwise
// but do not start counting until after the first non zero digit
if (nFirstNonZero == cppstring::npos || nFirstNonZero < 0)
return sResult;
for (int i = nFirstNonZero; i < nEndPosition ; i++)
{
ch = sResult.at(i);
if (ch != GSTD_S('-') && ch != cDecimalPoint) // only count digits
numDigits++;
}
if (numDigits < nSigDigits)
{ // the number of digits is less than the required number of sig figs so pad with zeros
cppstring sPadding;
int numZerosToPad = nSigDigits - numDigits;
if (nEPosition == cppstring::npos) // no E
{ // add a decimal point and pad with zeros after it (e.g. 3 becomes 3.00 for 3 sf)
if (sResult.find(cDecimalPoint) == cppstring::npos)
sPadding += cDecimalPoint;
for (int j = 0; j < numZerosToPad ; j++)
sPadding += GSTD_S('0');
sResult += sPadding;
}
else
{
if (sResult.find(cDecimalPoint) == cppstring::npos)
sPadding += cDecimalPoint; // Add a decimal point first, if we don't find one.
// Create the padding of 0's
for (int j = 0; j < numZerosToPad ; j++)
sPadding += GSTD_S('0');
// Insert before the E.
sResult.insert(nEPosition, sPadding);
}
}
return sResult;
}
*/
cppstring GTextUtils::LongToCPPString(long nNum) // REVISIT - add base-display arg
{
cppsstream ss;
ss << nNum;
return ss.str();
}
std::string GTextUtils::LongToString(long nNum) // REVISIT - add base-display arg
{
std::stringstream ss;
ss << nNum;
return ss.str();
}
/*
real GTextUtils::CPPStringToReal(const cppstring &sNumber)
{
real fResult;
GTextUtils::IsStringRealNumber(sNumber, &fResult); // just return the result
return fResult;
}
real GTextUtils::StringToReal(const narrowstring &sNumber)
{// not as robust as CPPStringToReal but does not need to be
real fValue;
std::stringstream ss;
ss << sNumber;
ss >> fValue;
return fValue;
}
*/
long GTextUtils::CPPStringToLong(const cppstring &sInteger)
{
long nResult = 0L;
if (GTextUtils::IsStringLong(sInteger))
nResult = GTextUtils::Gstrtol(sInteger.c_str(), NULL, 10);
return nResult;
}
long GTextUtils::StringToLong(const narrowstring &sInteger)
{
long nResult = 0L;
if (GTextUtils::IsNarrowStringLong(sInteger))
nResult = strtol(sInteger.c_str(), NULL, 10);
return nResult;
}
bool GTextUtils::StringIsAllDigits(const cppstring & sNumber)
{// returns true if sNumber is all digits ... no decimals, etc
bool bResult = true;
cppstring::const_iterator iChar = sNumber.begin();
bResult = (sNumber.length() > 0);
while(iChar != sNumber.end() && bResult)
{
if (!isdigit(*iChar))
{
bResult = false;
break;
}
iChar++;
}
return bResult;
}
cppstring GTextUtils::ExtractBaseName(const cppstring & sFullName, int * p_nOutNumberSuffix)
{
// ExtractBaseName expects a string in the form of [base sequenece][space character][digits]
// The base sequence is returned as a cppstring.
// The digits, if present, are converted to an integer value and stored
// on exit in the p_nOutNumberSuffix parameter if it is non-NULL.
cppstring sBase;
cppstring sNum;
unsigned long nLastSpacePos = sFullName.find_last_of(' ');
if (nLastSpacePos != cppstring::npos)
{
unsigned long ix;
for (ix = 0; ix < nLastSpacePos; ix++)
sBase += sFullName[ix];
for (ix = nLastSpacePos + 1; ix < sFullName.length(); ix++)
sNum += sFullName[ix];
bool bGotNum = (sNum.length() > 0 && IsStringLong(sNum));
if (!bGotNum)
sBase = sFullName;
if (p_nOutNumberSuffix != NULL)
{
if (bGotNum)
*p_nOutNumberSuffix = (int) GTextUtils::CPPStringToLong(sNum);
else
*p_nOutNumberSuffix = 0;
}
}
else
{
sBase = sFullName;
if (p_nOutNumberSuffix != NULL)
*p_nOutNumberSuffix = 0;
}
return sBase;
}
cppstring GTextUtils::MatchSubString(const cppstring & sFullName, const cppstring & sFormat, const cppstring & sSubName)
{
// MatchSubString determines whether sFullName matches sFormat (allowing sSubName to stand for a wildcard)
// For example, if the format is "Run %n" and "%n" is the wildcard, then "Run 1" will match and return "1".
cppstring sSubString;
// Find the starting character of the wildcard string (assume 0 if wildcard isn't found)
unsigned long nStartSub = sFormat.find(sSubName), nEndSub;
if (nStartSub != cppstring::npos)
{
nEndSub = nStartSub + sSubName.length();
// Break the format into two chunks surrounding the wildcard
cppstring sBeginFormat = sFormat.substr(0, nStartSub);
cppstring sEndFormat = sFormat.substr(nEndSub, sFormat.length() - sSubName.length());
// Now match the beginning and ending formats and extract the wildcard string
unsigned long nStartMatch = sFullName.find(sBeginFormat), nEndMatch;
if (nStartMatch != cppstring::npos)
{
nStartMatch += sBeginFormat.length();
nEndMatch = sFullName.rfind(sEndFormat);
if (nEndMatch != cppstring::npos)
sSubString = sFullName.substr(nStartMatch, nEndMatch - nStartMatch);
}
}
return sSubString;
}
/*
bool GTextUtils::IsStringRealNumber(cppstring sNumber, // string to test
real *pfValue) // [out] if != NULL return valid number here ONLY GOOD IF RETURN VALUE IS TRUE
{ // RETURN true if string is a real number
real fValue = NAN;
bool bOK = false;
bool bReadAllText;
if ((GetAppBrain() != NULL) && (GetAppBrain()->GetDecimalPointChar() == GSTD_S(',')))
sNumber = GTextUtils::StringReplace(sNumber, GSTD_S(","), GSTD_S(".")); // Handle locales where a comma is the decimal point
cppsstream ss;
ss << sNumber;
ss >> fValue;
bReadAllText = ss.eof();
if (!bReadAllText)
{ // make sure we are at the end of the number otherwise its really a string
// give ss a chance to skip any remaining white space
// but if any non-white space chars are left, its not a valid number
gchar c = 0;
ss >> c;
bReadAllText = (ss.eof() && (c == 0)); // we are now at EOF and there we no non-whitespace chars left in stream
}
if (bReadAllText && GUtils::OSIsValidNumber(fValue))
{
fValue = GUtils::RestrictReal(fValue);
bOK = true;
}
if (pfValue != NULL)
*pfValue = fValue;
return bOK;
}
*/
bool GTextUtils::IsStringLong(const cppstring & sNumber, // string to test
long *pnValue) // [out] if != NULL return valuid number here ONLY GOOD IF RETURN VALUE IS TRUE
{ // RETURN true if string is a long
bool bOK = false;
// if sNumber is not a number, then ss >> will not change the value of either nValue0 or nValue1
// so, if they are different, then sNumber is not a number!
long nValue0 = 0;
long nValue1 = 1;
cppsstream ss0;
ss0 << sNumber;
ss0 >> nValue0;
cppsstream ss1;
ss1 << sNumber;
ss1 >> nValue1;
if (nValue0 == nValue1)
bOK = true;
if (pnValue != NULL)
*pnValue = nValue0;
return bOK;
}
bool GTextUtils::IsNarrowStringLong(const narrowstring & sNumber, // string to test
long *pnValue) // [out] if != NULL return valuid number here ONLY GOOD IF RETURN VALUE IS TRUE
{ // RETURN true if string is a long
bool bOK = false;
// if sNumber is not a number, then ss >> will not change the value of either nValue0 or nValue1
// so, if they are different, then sNumber is not a number!
long nValue0 = 0;
long nValue1 = 1;
std::stringstream ss0;
ss0 << sNumber;
ss0 >> nValue0;
std::stringstream ss1;
ss1 << sNumber;
ss1 >> nValue1;
if (nValue0 == nValue1)
bOK = true;
if (pnValue != NULL)
*pnValue = nValue0;
return bOK;
}
cppstring GTextUtils::StringReplace(cppstring sBase, // string to search
const cppstring &sSearchFor, // substring to search for (to be replaced)
const cppstring &sReplaceWith) // string to replace sSearchFor with
{ // RETURN sBase with all instances of sSearchFor replaced by sReplaceWith
if (sBase.empty() || sSearchFor.empty())
return sBase;
int nStart = 0;
while (sBase.find(sSearchFor, nStart) != cppstring::npos)
{
nStart = sBase.find(sSearchFor, nStart);
int nEnd = sSearchFor.length();
sBase.replace(nStart, nEnd, sReplaceWith);
nStart += sReplaceWith.length();
}
return sBase;
}
std::string GTextUtils::AsciiStringReplace(std::string sBase, // string to search
const std::string &sSearchFor, // substring to search for (to be replaced)
const std::string &sReplaceWith) // string to replace sSearchFor with
{ // RETURN sBase with all instances of sSearchFor replaced by sReplaceWith
if (sBase.empty() || sSearchFor.empty())
return sBase;
int nStart = 0;
while (sBase.find(sSearchFor, nStart) != cppstring::npos)
{
nStart = sBase.find(sSearchFor, nStart);
int nEnd = sSearchFor.length();
sBase.replace(nStart, nEnd, sReplaceWith);
nStart += sReplaceWith.length();
}
return sBase;
}
/*
EImportTextFormat GTextUtils::ParseImportFormat(ifstream * pInStream)
{// looks for special format indicators in the ifstream generated from
// text import
EImportTextFormat eFileFormat = kImportFormat_None;
#ifndef OPUS_DDK
GStreamTokenizer lineTokenizer (pInStream);
lineTokenizer.SetDelimiters("\n\r");
//get the first line
std::string sFirstLine;
sFirstLine = lineTokenizer.NextToken();
std::string sLine = sFirstLine;
std::string sVernierFormat = GSTD_NARROWSTRING(IDSX_VERNIER_FORMAT2);
std::string sGA1Format = GSTD_NARROWSTRING(IDSX_GA_CONFIGURATION);
if (sFirstLine.find(sVernierFormat.c_str()) != std::string::npos)
eFileFormat = kImportFormat_LoggerPro2;
else
if (sFirstLine.find (sGA1Format.c_str()) != std::string::npos)
eFileFormat = kImportFormat_GA2Windows;
else
{ // check for 2 and only 2 integers on the first line
// these are most likely the numcols and numDatasets of a GA2MAc
// .TEXT file without its .TEXT extension
// and then make sure there are NOT 2 just 2 integers on the next line
int nNumberOfTokens = 0;
int nNumberOfIntegers= 0;
std::string sWord;
std::stringstream ssLineStream;
ssLineStream << sLine ;
GStreamTokenizer wordTokenizer (&ssLineStream);
wordTokenizer.SetDelimiters("\t,");
while ((sWord = wordTokenizer.NextToken()).size() != 0)
{// for each word we count the chars and digits
nNumberOfTokens += 1;
if (GTextUtils::StringIsAllDigits(GTextUtils::ConvertNarrowStringToWide(sWord)))
nNumberOfIntegers += 1;
}// end while
if (nNumberOfTokens == nNumberOfIntegers && nNumberOfTokens == 2)
{// this is almost surely kImportFormat_GA2Mac format but check the next line to make sure
sLine= lineTokenizer.NextToken();
ssLineStream << sLine ;
GStreamTokenizer wordTokenizer (&ssLineStream);
wordTokenizer.SetDelimiters("\t,");
nNumberOfTokens = 0;
nNumberOfIntegers = 0;
while ((sWord = wordTokenizer.NextToken()).size() != 0)
{// for each word we count the chars and digits
nNumberOfTokens += 1;
if (GTextUtils::StringIsAllDigits(GTextUtils::ConvertNarrowStringToWide(sWord)))
nNumberOfIntegers += 1;
}// end while
if (nNumberOfTokens == nNumberOfIntegers)
eFileFormat = kImportFormat_RawText;
else
eFileFormat = kImportFormat_GA2Mac;
}
else
eFileFormat = kImportFormat_RawText;
} // else block
#endif
return eFileFormat;
}
int GTextUtils::GetWordsPerLine(std::stringstream * pInStream )
{// gets the first line in the stream and returns the number of tab delimited values on that line
int nWordCount = 0;
#ifndef OPUS_DDK
long curPos = pInStream->tellg();
// create a Tokenizer for lines and get the first line
GStreamTokenizer lineTokenizer (pInStream);
lineTokenizer.SetDelimiters("\n\r");
std::string sLine = lineTokenizer.NextToken();
std::stringstream ss ;
ss << sLine << kOSNewlineString;
if (sLine.size() > 0)
{
GStreamTokenizer wordTokenizer (&ss );
wordTokenizer.SetDelimiters("\t,\r\n");
std::string sWord;
while ( (sWord = wordTokenizer.NextToken()).size() != 0)
nWordCount++;
}
// put the stream back to the starting position
pInStream->seekg(curPos);
#endif
return nWordCount;
}
*/
/*
cppstring GTextUtils::StripPathAndExtension(const cppstring &sPathAndName) // filename with path and possibly extension
{ // RETURN the name with path and extension stripped off
cppstring sStrippedName = sPathAndName;
cppstring sBeginning;
int nPosition;
nPosition = sPathAndName.rfind('.'); // strips the ext
if (nPosition != cppstring::npos)
sBeginning = sPathAndName.substr(0, nPosition);
else
sBeginning = sPathAndName;
cppstring sSep = GTextUtils::OSGetPathSeparator();
nPosition = sBeginning.find_last_of(sSep);
if (nPosition != cppstring::npos)
sStrippedName = sBeginning.substr(nPosition+1, sBeginning.length());
else
sStrippedName = sBeginning;
return sStrippedName;
}
cppstring GTextUtils::StripPath(const cppstring & sPathAndName) // Filename with path
{ // RETURN the name with path stripped off
cppstring sStrippedName = sPathAndName;
cppstring sSep = GTextUtils::OSGetPathSeparator();
int nPosition = sPathAndName.find_last_of(sSep);
if (nPosition != cppstring::npos)
sStrippedName = sPathAndName.substr(nPosition+1, sPathAndName.length());
return sStrippedName;
}
cppstring GTextUtils::GetPath(const cppstring &sFullFileName) // input fully qualified name
{ // RETURN just the path parth of the name (with trailing separator char)
cppstring sPath;
cppstring sSep = GTextUtils::OSGetPathSeparator();
int nPosition = sFullFileName.find_last_of(sSep);
if (nPosition != cppstring::npos)
sPath = sFullFileName.substr(0, nPosition+1);
return sPath;
}
bool GTextUtils::InvalidDataWorldName(const cppstring &sName)
{ // RETURN true if sName has invalid character(s) in it
bool bInvalid = false;
cppstring sSep = GSTD_STRING(IDSX_SEPARATOR);
if ((sName.find(sSep) != cppstring::npos) ||
(sName.find('\"') != cppstring::npos))
bInvalid = true;
return bInvalid;
}
cppstring GTextUtils::GetExtension(const cppstring &sFileName)
{ // RETURN the file name extension if there is one ... e.g Junk.txt returns .txt
int nPosition;
cppstring sExt;
nPosition = sFileName.find_last_of('.');
if (nPosition != cppstring::npos)
sExt = sFileName.substr(nPosition,sFileName.length());
return sExt;
}
cppstring GTextUtils::ParenthesizeString(const cppstring &s)
{
cppstring sOut = s;
if (sOut.length() != 0)
sOut = GSTD_S("(") + sOut + GSTD_S(")");
return sOut;
}
narrowstring GTextUtils::ParenthesizeNarrowString(const narrowstring &s)
{// in the narrow char app cppstring == narrowstring so overloaded functions appear to be duplicates
narrowstring sOut = s;
if (sOut.length() != 0)
sOut = "(" + sOut + ")";
return sOut;
}
cppstring GTextUtils::FilterOutChars(const cppstring &sInString, const cppstring &sFilterChars)
{
cppstring sOut;
for (int i = 0; i < sInString.length(); i++)
{
if (sFilterChars.find(sInString[i]) == cppstring::npos)
sOut += sInString[i]; //Not found in filter list, so pass char thru.
}
return sOut;
}
*/
/*
cppstring GTextUtils::ConvertToUppercase(const cppstring &sInString)
{
cppstring sOut;
GSTD_ASSERT(GetAppBrain() != NULL);
for (int i = 0; i < sInString.length(); i++)
sOut += std::toupper(sInString[i], GetAppBrain()->GetLocale());
return sOut;
}
bool GTextUtils::StringsEqualIgnoringCase(const cppstring &s1, const cppstring &s2)
{
return (ConvertToUppercase(s1) == ConvertToUppercase(s2));
}
cppstring GTextUtils::ConvertToOSSpecialChars(cppstring s)
{ // go through s and convert "&#xxx;" to a special OS character
StringVector *psvOSChars = GetOSSpecialChars();
StringVector *psvOSCharCodes = GetOSSpecialCharCodes();
GSTD_ASSERT( psvOSChars->size() == psvOSCharCodes->size() );
if (s.length() > 0)
{
char c1 = s[0];
int vOSSize = psvOSCharCodes->size();
for (int i=0; i<vOSSize; i++)
s = GTextUtils::StringReplace(s, psvOSCharCodes->at(i), psvOSChars->at(i));
char c2 = s[0];
}
return s;
}
cppstring GTextUtils::ConvertFromOSSpecialChars(cppstring s)
{ // go through s and convert any OS special chars to "&#xxx;"
// now that we set the charset when writing the output
// we don't need to special case these chars which are all
// included within the windows-1252 charset.
//
// we still read the html version on input streams without problem.
StringVector *psvOSChars = GetOSOutgoingSpecialChars();
StringVector *psvOSCharCodes = GetOSOutgoingSpecialCharCodes();
GSTD_ASSERT( psvOSChars->size() == psvOSCharCodes->size() );
if (s.length() > 0)
{
char c1 = s[0];
int vOSSize = psvOSCharCodes->size();
for (int i=0; i<vOSSize; i++)
s = GTextUtils::StringReplace(s, psvOSChars->at(i), psvOSCharCodes->at(i));
char c2 = s[0];
}
return s;
}
StringVector *GTextUtils::GetOSSpecialChars(void)
{ // RETURN a vector of strings where each string is one special character
// NOTE that these should match the special char codes returned in GetOSSpecialCharCodes
if (kvSpecialChar.size() == 0)
{
cppstring s;
s += kDegreeChar;
kvSpecialChar.push_back(s);
s = GSTD_S("");
s += kMuChar;
kvSpecialChar.push_back(s);
s = GSTD_S("");
s += kPlusOrMinusChar;
kvSpecialChar.push_back(s);
s = GSTD_S("");
s += kOneQuarter;
kvSpecialChar.push_back(s);
s = GSTD_S("");
s += kOneHalf;
kvSpecialChar.push_back(s);
s = GSTD_S("");
s += kThreeQuarters;
kvSpecialChar.push_back(s);
s = GSTD_S("");
s += kCapYAcute;
kvSpecialChar.push_back(s);
s = GSTD_S("");
s += kLwYAcute;
kvSpecialChar.push_back(s);
s = GSTD_S("");
s += kCapSCaron;
kvSpecialChar.push_back(s);
s = GSTD_S("");
s += kLwSCaron;
kvSpecialChar.push_back(s);
s = GSTD_S("");
s += kSuperScriptTwo;
kvSpecialChar.push_back(s);
s = GSTD_S("");
s += kGreaterThanChar;
kvSpecialChar.push_back(s);
s = GSTD_S("");
s += kLessThanChar;
kvSpecialChar.push_back(s);
s = GSTD_S("");
// insert new CharCodes here
// Ampersand MUST be last in list to ensure that if the user typed in an entity code it isn't converted to the entenity
// by converting '&' to & BEFORE we convert any other stings and turning it back into an ampersand AFTER we have done
// all other replacements we sure that if the user typed a string of the form &#<some number>; we don't convert it
// which we shouldn't since we don't conver all possible codes.
s += kAmpersandChar;
kvSpecialChar.push_back(s);
s = GSTD_S("");
}
return &kvSpecialChar;
}
StringVector *GTextUtils::GetOSSpecialCharCodes(void)
{
if (kvSpecialCharCode.size() == 0)
{
kvSpecialCharCode.push_back(GSTD_S("°")); // degree
kvSpecialCharCode.push_back(GSTD_S("µ")); // MuChar
kvSpecialCharCode.push_back(GSTD_S("±")); // Plus/Minus
kvSpecialCharCode.push_back(GSTD_S("¼")); // 1/4
kvSpecialCharCode.push_back(GSTD_S("½")); // 1/2
kvSpecialCharCode.push_back(GSTD_S("¾")); // 3/4
kvSpecialCharCode.push_back(GSTD_S("Ý")); // Y^ y acute
kvSpecialCharCode.push_back(GSTD_S("ý")); // y^
kvSpecialCharCode.push_back(GSTD_S("Š")); // S^ chron
kvSpecialCharCode.push_back(GSTD_S("š")); // s^
kvSpecialCharCode.push_back(GSTD_S("²")); // ^2
kvSpecialCharCode.push_back(GSTD_S(">")); // '>' (could also be >)
kvSpecialCharCode.push_back(GSTD_S("<")); // '<' (could also be <)
// insert new CharCodes here
// Ampersand MUST be last in list to ensure that if the user typed in an entity code it isn't converted to the entenity
// by converting '&' to & BEFORE we convert any other stings and turning it back into an ampersand AFTER we have done
// all other replacements we sure that if the user typed a string of the form &#<some number>; we don't convert it
// which we shouldn't since we don't conver all possible codes.
kvSpecialCharCode.push_back(GSTD_S("&")); // ampersand (could also be &)
}
return &kvSpecialCharCode;
}
// A routine that takes a path to a TXT file and
// adds the strings in the file to our internal database.
// The input TXT file should be of the form:
// IDSX_STRING_ID1 "String 1"
// IDSX_STRING_ID2 "String 2"
// IDSX_STRING_ID3 "String 3" // Comments are allowed here
// // or here, or anywhere really, with the standard C thing of "//".
bool GTextUtils::ReadStringsFromFile(cppstring sPath)
{
// Read in strings from the specified file
bool bResult = false;
int nIndex = m_vStringData.size();
GFileRef theFileRef;
theFileRef.SetFilePath(sPath);
theFileRef.SetCodecvtType(kCodecvtUTF8);
StringVector vsKeysSoFar; // To check for duplicate keys
if (theFileRef.OSOpenFStream(ios_base::binary | ios_base::in))
{
cppistream * piStream = dynamic_cast<cppistream *>(theFileRef.GetFStream());
if (piStream != NULL) // We opened the strings file
{
cppstring sLine;
while (getline(*piStream, sLine))
{
sLine = sLine.substr(0, sLine.find(GSTD_S("//"))); // strip off comments
if (!sLine.empty())
{ // We have a non-empty line to work with
int nWhiteSpace = sLine.find(GSTD_S(" "));
if (sLine.find(GSTD_S("\t")) < nWhiteSpace)
nWhiteSpace = sLine.find(GSTD_S("\t"));
cppstring sWord = sLine.substr(0, nWhiteSpace);
if (sWord.find(GSTD_S("IDSX")) != cppstring::npos)
{
#ifdef _DEBUG
for (size_t jx = 0; jx < vsKeysSoFar.size(); jx++)
if (sWord == vsKeysSoFar[jx])
{ // ERROR!!!! There are duplciate IDSX_XXX in the strings file!
GSTD_TRACE("Duplicate Key: " + sWord);
GMessenger::PostAsyncMessage(kStdObject_AppBrain, GMsg::kAssert, __FILE__, __LINE__);
}
vsKeysSoFar.push_back(sWord);
#endif
cppstring sBody;
if (sLine.find(GSTD_S('"')) != cppstring::npos)
{
int nFirstQuote = sLine.find(GSTD_S('"'));
int nLastQuote = sLine.find_last_of(GSTD_S('"'));
GSTD_ASSERT((nFirstQuote != nLastQuote) && (nFirstQuote != cppstring::npos) && (nLastQuote != cppstring::npos));
sBody = sLine.substr(nFirstQuote + 1, nLastQuote - nFirstQuote - 1);
sBody = GTextUtils::StringReplace(sBody, GSTD_S("\\\""), GSTD_S("\""));
sBody = GTextUtils::StringReplace(sBody, GSTD_S("\\n"), GSTD_S("\n"));
sBody = GTextUtils::StringReplace(sBody, GSTD_S("\\t"), GSTD_S("\t"));
sBody = GTextUtils::StringReplace(sBody, GSTD_S("\\\\"), GSTD_S("\\"));
m_mStringIndices[ ConvertWideStringToNarrow(sWord)] = nIndex++;
m_vStringData.push_back(sBody);
}
}
}
}
bResult = true;
}
theFileRef.OSCloseFStream();
}
return bResult;
}
*/
/*
void GTextUtils::FreeResourceStrings(void)
{
m_vStringData.clear();
m_mStringIndices.clear();
}
int GTextUtils::GetStringIndexByKey(const char * sKey)
{
if (m_vStringData.empty())
OSInitResourceStrings();
std::map<narrowstring, int>::iterator iter = m_mStringIndices.find(sKey);
GSTD_ASSERT(iter != m_mStringIndices.end());
return (iter->second);
}
cppstring GTextUtils::GetStringByKey(const char * sKey)
{
if (m_vStringData.empty())
OSInitResourceStrings();
std::map<narrowstring, int>::iterator iter = m_mStringIndices.find(sKey);
if (iter == m_mStringIndices.end())
{ // bad!
cppstring s = sKey;
GSTD_TRACE("Bad Key: " + s);
GSTD_ASSERT(false);
}
int nIndex = (iter->second);
if ((nIndex < 0) || (nIndex >= m_vStringData.size()))
{ // Bad!
cppstring s = sKey;
GSTD_TRACE("Bad Key: " + s);
GSTD_ASSERT(false);
}
cppstring sReturnString;
if ((nIndex >= 0) && (nIndex < m_vStringData.size()))
return m_vStringData[nIndex];
else
return sReturnString;
}
*/
//narrowstring GTextUtils::GetNarrowStringByKey(const char * sKey)
//{
// if (m_vStringData.empty())
// OSInitResourceStrings();
// std::map<narrowstring, int>::iterator iter = m_mStringIndices.find(sKey);
// GSTD_ASSERT(iter != m_mStringIndices.end());
// int nIndex = (iter->second);
// GSTD_ASSERT(nIndex >= 0 && nIndex < m_vStringData.size());
//
// cppstring s = m_vStringData[nIndex];
// /*
//#ifdef USE_WIDE_CHARS
// char *pmbcharbuf = (char *)malloc(MB_CUR_MAX);
// wcstombs(pmbcharbuf, m_vStringData[nIndex].c_str(), MB_CUR_MAX);
// s = *pmbcharbuf;
// free(pmbcharbuf);
//#endif
// */
// return GTextUtils::ConvertWideStringToNarrow(s);
//}
/*
cppstring GTextUtils::GetStringByIndex(int nID)
{
if (m_vStringData.empty())
OSInitResourceStrings();
GSTD_ASSERT(nID >= 0 && nID < m_vStringData.size());
return m_vStringData[nID];
}
*/
//narrowstring GTextUtils::GetNarrowStringByIndex(int nID)
//{
// if (m_vStringData.empty())
// OSInitResourceStrings();
// GSTD_ASSERT(nID >= 0 && nID < m_vStringData.size());
//
// cppstring s = m_vStringData[nID];
// /*
//#ifdef USE_WIDE_CHARS
// char *pmbcharbuf = (char *)malloc(MB_CUR_MAX);
// wcstombs(pmbcharbuf, m_vStringData[nID].c_str(), MB_CUR_MAX);
// s = *pmbcharbuf;
// free(pmbcharbuf);
//#endif
// */
// return ConvertWideStringToNarrow(s);
//}
/*
StringVector GTextUtils::GetRangeOfStrings(int nStartIndex, int nEndIndex)
{
StringVector vsResult;
for (int i = nStartIndex; i != nEndIndex; i++)
vsResult.push_back(GSTD_INDEXSTRING(i));
return vsResult;
}
narrowstring GTextUtils::RemoveSameRoot(AsciiStringVector *pvStrings)
{ // if all strings have the same root (i.e. text before the last '\') then remove it
// RETURN the root (or "" if strings have different roots)
bool bSameRoot = true;
narrowstring sRoot;
for (int i=0; i<pvStrings->size(); i++)
{ // See if all strings have the same root
narrowstring sTempRoot;
if (pvStrings->at(i).find_last_of('\\') != cppstring::npos)
sTempRoot = pvStrings->at(i).substr(0, pvStrings->at(i).find_last_of('\\')+1);
if (sRoot.empty())
sRoot = sTempRoot;
if (sRoot != sTempRoot)
{
bSameRoot = false;
sRoot = "";
break;
}
}
if ((bSameRoot) && !sRoot.empty())
{ // If all data objects have the same non-empty root, then strip it off
for (int i=0; i<pvStrings->size(); i++)
pvStrings->at(i) = pvStrings->at(i).substr(pvStrings->at(i).find_last_of('\\')+1, cppstring::npos);
}
return sRoot;
}
*/
/*
short GTextUtils::AdjustTextSizeByAppPref(short nOrigSize, bool bApplyNewSize, void * pOSData)
{
// This routine adjusts a text size based on application
// preference settings; the nOrigSize is considered the
// correct "medium" size.
// If the text size is "large", we increase smaller fonts slightly;
// If bApplyNewSize is true, GTextUtils::OSApplyTextSize() will be called.
short nNewSize = nOrigSize;
#ifndef OPUS_DDK
if (GetAppBrain()->IsLargeText())
{
switch(nOrigSize)
{
// we do not enlarge fonts that are larger than 14pt
case 14:
case 13:
nNewSize = 16;
break;
case 12:
case 11:
nNewSize = 14;
break;
case 10:
case 9:
nNewSize = 12;
break;
case 8:
case 7:
nNewSize += 2;
break;
default:
if (nOrigSize <= 6)
nNewSize = 8;
}
}
// apply the size change to the current port:
// this is the real OS-specific part...
if (bApplyNewSize)
GTextUtils::OSApplyTextSize(nNewSize, pOSData);
#endif // !OPUS_DDK
return nNewSize;
}
EFloatStyle GTextUtils::GetFloatStyle(bool bPrecisionDecimal)
{ // return a float style based on bPrecisionDecimal
EFloatStyle eStyle = kFloatStyle_fixedPrecision;
if (!bPrecisionDecimal)
eStyle = kFloatStyle_fixedSigFigs;
return eStyle;
}
cppstring GTextUtils::TranslatePathToFile(cppstring sPath)
{ // Write OS before fiel path so we can convert separators properly when we read
GSTD_ASSERT(GetAppBrain() != NULL);
if (GetAppBrain()->GetThisOSType() == kOSType_Windows)
sPath = GSTD_S("W") + sPath;
else
sPath = GSTD_S("M") + sPath;
return sPath;
}
cppstring GTextUtils::TranslatePathFromFile(cppstring sPath)
{ // Convert all separator characters from the proper OS
if (sPath.size() > 1)
{
GSTD_ASSERT(GetAppBrain() != NULL);
if ((GetAppBrain()->GetThisOSType() == kOSType_Windows) &&
(sPath[0] == 'M'))
sPath = GTextUtils::StringReplace(sPath, kMacPathSeparatorString, kWinPathSeparatorString);
if ((GetAppBrain()->GetThisOSType() != kOSType_Windows) &&
(sPath[0] == 'W'))
sPath = GTextUtils::StringReplace(sPath, kWinPathSeparatorString, kMacPathSeparatorString);
sPath = sPath.substr(1);
}
return sPath;
}
real GTextUtils::GetVersionFromBaseName(cppstring sFileName, // actual filename with real numbers
cppstring sBaseName) // base file name (with '*' instead of numbers)
{ // pulls out the version number from the filename using the basename as template, e.g. basename might be base*.hex
real fValue = 0;
// Strip off paths and extenstions so as not to confuse the issue
sFileName = GTextUtils::StripPathAndExtension(sFileName);
sBaseName = GTextUtils::StripPathAndExtension(sBaseName);
// Make a string that starts with the actual number
cppstring sNumber = sFileName.substr(sBaseName.find('*'));
// now extract the numbers, will stop when we reach an non number
fValue = GTextUtils::CPPStringToLong(sNumber);
// Divide number by 100000 so that non decimal number (as store din filename) will get converted properly
fValue /= 100000.0;
return fValue;
}
unsigned short GTextUtils::GetValueFromCharacterEscape(cppstring sCharEscape)
{
// sCharEscape should be a standard XML/HTML escape sequence in one of two formats:
// &#N; or &#xN;
// In the first case, nnn is a base-10 integer; in the second case, a hexadecimal integer.
// The method simply converts the value to an integer correctly according to base (presence of the "x"
// indicated hexadecimal).
// REQUIREMENT: remove whitespace before calling this method
unsigned short nChar = 0;
const gchar * k_sSpace = GSTD_S(" ");
if ((sCharEscape.length() >= 4) && (sCharEscape[0] == GSTD_S('&')) && (sCharEscape[1] == GSTD_S('#')))
{
long nBase = 10;
sCharEscape[0] = GSTD_S(' ');
sCharEscape[1] = GSTD_S(' ');
if (sCharEscape[2] == GSTD_S('x'))
sCharEscape[1] = GSTD_S('0');
#ifdef USE_WIDE_CHARS
nChar = (unsigned short) wcstoul(sCharEscape.c_str(), NULL, 0);
#else
nChar = (unsigned short) strtoul(sCharEscape.c_str(), NULL, 0);
#endif
}
return nChar;
}
cppstring GTextUtils::EncodeCharacterEscape(unsigned short nUTF8Char)
{
cppsstream ss;
ss << "&x" << hex << nUTF8Char << ";";
return ss.str();
}
*/
cppstring::cppstring(gchar c)
{
cppstring s = GSTD_S(" ");
s[0] = c;
*this = s;
}
gchar * GTextUtils::Gstrcpy(gchar * strDestination,const gchar * strSource )
{
gchar * pstrReturn;
#ifdef USE_WIDE_CHARS
pstrReturn = wcscpy(strDestination, strSource);
#else
pstrReturn = strcpy(strDestination, strSource);
#endif
return pstrReturn;
}
gchar * GTextUtils::Gstrncpy(gchar *strDestination,const gchar * strSource, size_t nCount)
{
gchar * pstrReturn;
#ifdef USE_WIDE_CHARS
pstrReturn = wcsncpy(strDestination, strSource,nCount);
#else
pstrReturn = strncpy(strDestination, strSource,nCount);
#endif
return pstrReturn;
}
long GTextUtils::Gstrtol(const gchar *nptr, gchar **endptr, int nbase)
{
long nLong;
#ifdef USE_WIDE_CHARS
nLong = wcstol(nptr,endptr,nbase);
#else
nLong = strtol(nptr,endptr,nbase);
#endif
return nLong;
}
int GTextUtils::Gisspace(const gint n)
{
#ifdef USE_WIDE_CHARS
return iswspace(n);
#else
return isspace(n);
#endif
}
int GTextUtils::Gisprint(const gint c)
{
#ifdef USE_WIDE_CHARS
return iswprint(c);
#else
return isprint(c);
#endif
}
int GTextUtils::Gisalpha(const gint c)
{
#ifdef USE_WIDE_CHARS
return iswalpha(c);
#else
return isalpha(c);
#endif
}
bool GTextUtils::IsEOF(int ch)
{
#ifdef USE_WIDE_CHARS
return ch == WEOF;
#else
return ch == EOF;
#endif
}
gint GTextUtils::GEOF()
{
#ifdef USE_WIDE_CHARS
return WEOF;
#else
return EOF;
#endif
}
double GTextUtils::Gstrtod(const gchar *nptr, gchar **endptr)
{
double fValue;
#ifdef USE_WIDE_CHARS
fValue = wcstod(nptr,endptr);
#else
fValue = strtod(nptr,endptr);
#endif
return fValue;
}
size_t GTextUtils::Gstrlen(const gchar * str)
{
size_t len = 0;
#ifdef USE_WIDE_CHARS
len = wcslen(str);
#else
len = strlen(str);
#endif
return len;
}
int GTextUtils::Gstrcmp(const gchar *str1,const gchar *str2)
{
int nReturn = 0;
#ifdef USE_WIDE_CHARS
nReturn = wcscmp(str1,str2);
#else
nReturn = strcmp(str1,str2);
#endif
return nReturn;
}
int GTextUtils::Gstrncmp(const gchar *str1,const gchar *str2, size_t nCount)
{
int nReturn = 0;
#ifdef USE_WIDE_CHARS
nReturn = wcsncmp(str1,str2,nCount);
#else
nReturn = strncmp(str1,str2,nCount);
#endif
return nReturn;
}
cppstring GTextUtils::ConvertNarrowStringToWide(const narrowstring sNarrow)
{
// input a narrow (ASCII )string ... it will not be multibyte
// convert to wide if USE_WIDE_CHARS
#ifdef USE_WIDE_CHARS
cppstring sResult(sNarrow.c_str());
#else
cppstring sResult(sNarrow); // the types are the same... does nothing
#endif
return sResult;
}
std::string GTextUtils::ConvertWideStringToNarrow(const cppstring sWide)
{
#ifdef USE_WIDE_CHARS
char * pMultiByteBuf;
pMultiByteBuf = (char *)malloc( sWide.length()*2 );
size_t i = wcstombs( pMultiByteBuf, sWide.c_str(), sWide.length()*2 );
std::string sNarrow (pMultiByteBuf);
delete pMultiByteBuf;
#else
std::string sNarrow(sWide); // since cppstring is already narrow there is nothing to do
#endif
return sNarrow;
}
/*
GDeviceRect GTextUtils::GetBestRectForText( cppstring sText, const GDeviceRect & maxRect, int nFontHeight, int nMinWidth)
{
// Given a quantity of text and current font size & face settings,
// calculate a good display rectangle. Note that the main usage
// for the routine is currently for a dynamically-sized messagebox.
// This isn't exactly "wrap" mode - this routine will
// constrain first-line width if width-to-height proportion is more than
// 20.
//
// In calculating height of rects that will require text wrap, this
// routine always adds 1 line to the total to account for additional
// blank space.
int nTextWidth = 0;
int nNumLines = 1;
int kMaxWidth = (maxRect.right - maxRect.left);
int kMaxHeight = (maxRect.bottom - maxRect.top);
int kTotalTextLength = sText.length();
int kMaxCharsPerLine = sText.length();
double kMaxProportion = 3.0; // max width-to-height proportion
int nNumNewlines = 0;
nTextWidth = GTextUtils::OSGetTextLength(sText);
if (nTextWidth < 0)
nTextWidth = kMaxWidth+1;
GDeviceRect bestRect(0,0,0,0);
cppstring sTempString = sText;
int nLongestLine = 0, nMaxLineWidth = 0;
// Count the number of newlines that occur in sText
int pos = 0;
cppstring sEnd = kOSNewlineString;
while (pos != cppstring::npos)
{
int nFound = sText.find(sEnd, pos);
if (nFound != cppstring::npos)
{
nNumNewlines++;
if (nFound - pos > nLongestLine)
nLongestLine = nFound - pos;
pos = nFound + 1;
}
else
break;
}
// Find out approximately how many characters are the max for
// given max width - we're not worried about exactness with non-proportional
// fonts etc.
if (nLongestLine == 0)
{
while ((kMaxCharsPerLine > 1) && (nTextWidth > kMaxWidth))
{
--kMaxCharsPerLine;
sTempString = GSTD_S("");
sTempString.insert(0, sText, 0, kMaxCharsPerLine);
nTextWidth = GTextUtils::OSGetTextLength(sTempString);
if (nTextWidth < 0)
nTextWidth = kMaxWidth + 1;
}
nLongestLine = kMaxCharsPerLine;
}
else
{
sTempString = GSTD_S("");
sTempString.insert(0, sText, 0, nLongestLine);
nTextWidth = GTextUtils::OSGetTextLength(sTempString);
if (nTextWidth < 0)
nTextWidth = kMaxWidth + 1;
nMaxLineWidth = nTextWidth;
}
// Now determine number of approximate number of lines
if (nNumNewlines > 0)
nNumNewlines--;
else
nNumNewlines = 1;
nNumLines = nNumNewlines + sText.length() / nLongestLine;
// Assign the dimensions we've found to bestRect, which is currently 0,0,0,0:
bestRect.bottom = bestRect.top + nFontHeight * nNumLines;
bestRect.right = bestRect.left + nTextWidth + 25;
// Now fix proportion - while bestRect is too wide, narrow it by
// a character-per-line at a time...
while ((double)nTextWidth > (double)(bestRect.bottom - bestRect.top) * kMaxProportion)
{
sTempString = sTempString.substr(0,sTempString.length() -1);
nTextWidth = GTextUtils::OSGetTextLength(sTempString);
if (nTextWidth < 0)
nTextWidth = kMaxWidth+1;
nLongestLine--;
if (nLongestLine < 1)
break;
// Add in a factor that accounts for automatic word wrap
int nWordWrapLines = max(0, (nMaxLineWidth / nTextWidth));
nNumLines = nNumNewlines + nWordWrapLines + sText.length() / nLongestLine;
bestRect.right = bestRect.left + nTextWidth + 25;
bestRect.bottom = bestRect.top + nFontHeight * nNumLines;
if (bestRect.Width() < nMinWidth)
break;
}
if (kMaxCharsPerLine < 1 || nTextWidth < 1)
{
// We did not get a good rect
bestRect.SetRect(0,0,0,0);
}
else
{
bestRect.bottom += nFontHeight; // add 1 more line for good measure
// make sure our bestRect is not bigger than maxRect
if (bestRect.top < maxRect.top) bestRect.top = maxRect.top;
if (bestRect.left < maxRect.left) bestRect.left = maxRect.left;
if (bestRect.bottom > maxRect.bottom) bestRect.bottom = maxRect.bottom;
if (bestRect.right > maxRect.right) bestRect.right = maxRect.right;
}
return bestRect;
}
*/
| [
"[email protected]",
"[email protected]"
] | [
[
[
1,
20
],
[
23,
431
],
[
433,
434
],
[
436,
1481
]
],
[
[
21,
22
],
[
432,
432
],
[
435,
435
]
]
] |
4430a40f6dc11033a7be4e15bfdb42f070662f89 | 439a44f7f5d7a6d6b79ff5706678f34fc899d0a6 | /testunit/sampleTestUnit.cpp | 568517e49247b9af179f2f0e8b2c34fbd657088a | [] | no_license | epibobby/test-jenkins | 8f3bbf988869a3d74f67ec5526472f76d8d28a64 | 1646c6c7cd423ad28f6285110ecf33c12dbcfa41 | refs/heads/master | 2021-01-22T17:57:37.034686 | 2011-10-06T16:01:29 | 2011-10-06T16:01:29 | 2,526,452 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,313 | cpp | #include "ctestplus.h"
#include <QtTest/QtTest>
#include <QtCore/QCoreApplication>
class TestCTestPlus: public QObject
{
Q_OBJECT
private slots:
void testMinus_data();
void testPlus();
void testMinus();
};
void TestCTestPlus::testPlus()
{
CTestPlus sobj;
QBENCHMARK {
sobj.value(3);
sobj.plus(4);
}
QCOMPARE(sobj.value(), int(7));
}
void TestCTestPlus::testMinus_data()
{
QTest::addColumn<int>("value");
QTest::addColumn<int>("minus");
QTest::addColumn<int>("result");
QTest::newRow("3-4") << 3 << 4 << -1;
QTest::newRow("-1+5") << -1 << -5 << 4;
QTest::newRow("-1+4") << -1 << -4 << 5; // error
QTest::newRow("-1+4") << -1 << -4 << 5;
QTest::newRow("4-3") << 4 << 3 << 1;
}
void TestCTestPlus::testMinus()
{
QFETCH(int, value);
QFETCH(int, minus);
QFETCH(int, result);
CTestPlus sobj;
sobj.value(value);
QCOMPARE(sobj.minus(minus), result);
}
#include "sampleTestUnit.moc"
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
TestCTestPlus test;
return QTest::qExec(&test, argc, argv);
}
| [
"root@.(none)"
] | [
[
[
1,
57
]
]
] |
3c53be4cf1b4ba3b2ff59c0a56359dee17815394 | 1e01b697191a910a872e95ddfce27a91cebc57dd | /GrfTraceObject.cpp | 7256c52317320ab5c555bc4072f03689d28f27f0 | [] | 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 | 2,019 | 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 "ExprScriptExpression.h"
#include "GrfTraceObject.h"
namespace CodeWorker {
GrfTraceObject::~GrfTraceObject() {
delete _pObject;
delete _pDepth;
}
SEQUENCE_INTERRUPTION_LIST GrfTraceObject::executeInternal(DtaScriptVariable& visibility) {
DtaScriptVariable* pObject = visibility.getVariable(*_pObject);
std::string sDepth = _pDepth->getValue(visibility);
int iDepth = atoi(sDepth.c_str());
return CGRuntime::traceObject(pObject, iDepth);
}
void GrfTraceObject::populateDefaultParameters() {
if (_pDepth == NULL) _pDepth = new ExprScriptConstant(0);
}
void GrfTraceObject::compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_INDENT << "CGRuntime::traceObject(";
_pObject->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
_pDepth->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ");";
CW_BODY_ENDL;
}
}
| [
"cedric.p.r.lemaire@28b3f5f3-d42e-7560-b87f-5f53cf622bc4"
] | [
[
[
1,
59
]
]
] |
19080ebc97d87035c9667cb01b09c6abbfb28de2 | 8419225504df0b4ffefba24fd34bcc32da55fc5a | /random/hltools/src/hlds_client.h | 9b722e8fe2f8e8930e7821f59bcaf969cb5c25bd | [] | no_license | Techlord-RCE/opcode0x90 | 8363195b7855a4c9027fbc70307a6ebc316f1177 | 51b2e0ab91ba347f171b0123f742e3a9ec0cadd6 | refs/heads/master | 2021-05-30T23:14:10.269795 | 2009-12-09T19:04:27 | 2009-12-09T19:04:27 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,762 | h | /*
* hlds_client.h - part of hltools project
*
* Header file for hlds_client.cpp
* by: opcode0x90
*
* Changelog:
* 0.0.1a - Initial version
*/
#ifndef __HLDS_H__
#define __HLDS_H__
/***********************************************************/
#include <string>
#include <boost/asio.hpp>
#include <boost/array.hpp>
/***********************************************************/
class hlds_client
{
public:
//
// type aliases
//
typedef boost::posix_time::time_duration::tick_type tick_type;
typedef boost::asio::ip::udp::endpoint endpoint;
//
// constructor
//
hlds_client(boost::asio::io_service& io_service, const std::string& hostname, const std::string& port = "27015");
//
// functions
//
tick_type ping(const float& timeout = 3.0);
//
// properties
//
inline const endpoint& getSenderEndpoint() const { return this->sender_endpoint; }
inline const endpoint& getReceiverEndpoint() const { return this->receiver_endpoint; }
private:
//
// fields
//
std::string hostname, port;
//
// boost::asio objects
//
boost::asio::ip::udp::socket socket;
boost::asio::ip::udp::endpoint sender_endpoint;
boost::asio::ip::udp::endpoint receiver_endpoint;
boost::asio::deadline_timer timeout_timer;
//
// predefined packets
//
static const boost::array<char, 5> A2A_PING;
static const boost::array<char, 5> A2A_PING_REPLY;
//
// internal functions
//
void __ping_handle_receive(const boost::system::error_code& error, std::size_t bytes_transferred);
void __ping_handle_timeout(const boost::system::error_code& error, bool& timedout);
};
/***********************************************************/
#endif /* __HLDS_H__ */
| [
"[email protected]@2bab5e99-5a50-0410-be44-f7b117531408"
] | [
[
[
1,
77
]
]
] |
7ed0320c06000f31c28a18b76af7da8e3640d0e9 | e1d76663bb020dc27abb53c8f8bb979b4738373f | /source/datamanager/smallobject/messageobject.cc | 15919a17bbbf1c62b0d5f85a56aead7137328d7a | [] | no_license | fanopi/autoFloderSync | 97e29f9aa24bc8bf78aa8325996e176572f46f8a | 5232e01f43c9cc31df349a8b474c5d35a1e92ac5 | refs/heads/master | 2020-06-03T15:28:13.583695 | 2011-09-19T13:52:25 | 2011-09-19T13:52:25 | 2,338,869 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 204 | cc | /*
* messageobject.cc
*
* Created on: 2011-4-27
* Author: FanOpi
*/
#include "messageobject.hpp"
namespace yf{
long MessageObj::class_message_sequence_ = 0;
} ///namespace yf
| [
"[email protected]"
] | [
[
[
1,
14
]
]
] |
27888ca4fa834553c284508f6e2c7c80d7dee219 | 59066f5944bffb953431bdae0482a2abfb75f49a | /trunk/ogreopcode/BSPExample/src/ogreOpcodeExample.cpp | 66074cd321d003ae75185440cec48872197519da | [] | no_license | BackupTheBerlios/conglomerate-svn | 5b1afdea5fbcdd8b3cdcc189770b1ad0f8027c58 | bbecac90353dca2ae2114d40f5a6697b18c435e5 | refs/heads/master | 2021-01-01T18:37:56.730293 | 2006-05-21T03:12:39 | 2006-05-21T03:12:39 | 40,668,508 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 18,081 | cpp | #include "ogreOpcodeExample.h"
#include "LoadingBar.h"
template<> OgreOpcodeExample* Ogre::Singleton<OgreOpcodeExample>::ms_Singleton = 0;
//-------------------------------------------------------------------------------------
OgreOpcodeExample::OgreOpcodeExample(void)
{
mRoot = 0;
}
//-------------------------------------------------------------------------------------
OgreOpcodeExample::~OgreOpcodeExample(void)
{
if (mInputTypeSwitchingOn)
{
delete mEventProcessor;
}
else
{
PlatformManager::getSingleton().destroyInputReader( mInputDevice );
}
delete mRoot;
}
//-------------------------------------------------------------------------------------
bool OgreOpcodeExample::configure(void)
{
// Show the configuration dialog and initialise the system
// You can skip this and use root.restoreConfig() to load configuration
// settings if you were sure there are valid ones saved in ogre.cfg
if(mRoot->restoreConfig() || mRoot->showConfigDialog())
{
// If returned true, user clicked OK so initialise
// Here we choose to let the system create a default rendering window by passing 'true'
mWindow = mRoot->initialise(true);
return true;
}
else
{
return false;
}
}
//-------------------------------------------------------------------------------------
void OgreOpcodeExample::chooseSceneManager(void)
{
// Get the SceneManager, in this case a generic one
mSceneMgr = mRoot->getSceneManager(ST_GENERIC);
}
//-------------------------------------------------------------------------------------
void OgreOpcodeExample::createCamera(void)
{
// Create the camera
mCamera = mSceneMgr->createCamera("PlayerCam");
// Position it at 500 in Z direction
mCamera->setPosition(Vector3(0,0,500));
// Look back along -Z
mCamera->lookAt(Vector3(0,0,-300));
mCamera->setNearClipDistance(5);
}
//-------------------------------------------------------------------------------------
void OgreOpcodeExample::createFrameListener(void)
{
mDebugOverlay = OverlayManager::getSingleton().getByName("Core/DebugOverlay");
mUseBufferedInputKeys = false;
mUseBufferedInputMouse = false;
mInputTypeSwitchingOn = mUseBufferedInputKeys || mUseBufferedInputMouse;
mRotateSpeed = 36;
mMoveSpeed = 100;
if (mInputTypeSwitchingOn)
{
mEventProcessor = new EventProcessor();
mEventProcessor->initialise(mWindow);
mEventProcessor->startProcessingEvents();
mEventProcessor->addKeyListener(this);
mInputDevice = mEventProcessor->getInputReader();
}
else
{
mInputDevice = PlatformManager::getSingleton().createInputReader();
mInputDevice->initialise(mWindow,true, true);
}
mStatsOn = true;
mNumScreenShots = 0;
mTimeUntilNextToggle = 0;
mSceneDetailIndex = 0;
mMoveScale = 0.0f;
mRotScale = 0.0f;
mTranslateVector = Vector3::ZERO;
mAniso = 1;
mFiltering = TFO_BILINEAR;
showDebugOverlay(true);
mRoot->addFrameListener(this);
}
//-------------------------------------------------------------------------------------
void OgreOpcodeExample::createScene(void)
{
// Set ambient light
mSceneMgr->setAmbientLight(ColourValue(0.2, 0.2, 0.2));
// Create a skydome
mSceneMgr->setSkyDome(true, "Examples/CloudySky", 5, 8);
// Create a light
Light* l = mSceneMgr->createLight("MainLight");
// Accept default settings: point light, white diffuse, just set position
// NB I could attach the light to a SceneNode if I wanted it to move automatically with
// other objects, but I don't
l->setPosition(20,80,50);
Entity *ent;
// Define a floor plane mesh
Plane p;
p.normal = Vector3::UNIT_Y;
p.d = 200;
MeshManager::getSingleton().createPlane(
"FloorPlane", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
p, 200000, 200000, 20, 20, true, 1, 50, 50, Vector3::UNIT_Z);
// Create an entity (the floor)
ent = mSceneMgr->createEntity("floor", "FloorPlane");
ent->setMaterialName("Examples/RustySteel");
// Attach to child of root node, better for culling (otherwise bounds are the combination of the 2)
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent);
// Add a head, give it it's own node
SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
ent = mSceneMgr->createEntity("head", "ogrehead.mesh");
headNode->attachObject(ent);
// Put in a bit of fog for the hell of it
mSceneMgr->setFog(FOG_EXP, ColourValue::White, 0.0002);
}
//-------------------------------------------------------------------------------------
void OgreOpcodeExample::destroyScene(void)
{
}
//-------------------------------------------------------------------------------------
void OgreOpcodeExample::createViewports(void)
{
// Create one viewport, entire window
Viewport* vp = mWindow->addViewport(mCamera);
vp->setBackgroundColour(ColourValue(0,0,0));
// Alter the camera aspect ratio to match the viewport
mCamera->setAspectRatio(
Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
}
//-------------------------------------------------------------------------------------
void OgreOpcodeExample::setupResources(void)
{
// Load resource paths from config file
ConfigFile cf;
cf.load("resources.cfg");
// Go through all sections & settings in the file
ConfigFile::SectionIterator seci = cf.getSectionIterator();
String secName, typeName, archName;
while (seci.hasMoreElements())
{
secName = seci.peekNextKey();
ConfigFile::SettingsMultiMap *settings = seci.getNext();
ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
ResourceGroupManager::getSingleton().addResourceLocation(
archName, typeName, secName);
}
}
}
//-------------------------------------------------------------------------------------
void OgreOpcodeExample::createResourceListener(void)
{
}
//-------------------------------------------------------------------------------------
void OgreOpcodeExample::loadResources(void)
{
mLoadingBar = new LoadingBar();
mLoadingBar->start(mWindow, 1, 1, 0.75);
// Turn off rendering of everything except overlays
mSceneMgr->clearSpecialCaseRenderQueues();
mSceneMgr->addSpecialCaseRenderQueue(RENDER_QUEUE_OVERLAY);
mSceneMgr->setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE);
// Initialise the rest of the resource groups, parse scripts etc
ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
ResourceGroupManager::getSingleton().loadResourceGroup(
ResourceGroupManager::getSingleton().getWorldResourceGroupName(),
false, true);
// Back to full rendering
mSceneMgr->clearSpecialCaseRenderQueues();
mSceneMgr->setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE);
mLoadingBar->finish();
delete mLoadingBar;
}
//-------------------------------------------------------------------------------------
void OgreOpcodeExample::go(void)
{
if (!setup())
return;
showDebugOverlay(true);
mRoot->startRendering();
// clean up
destroyScene();
}
//-------------------------------------------------------------------------------------
bool OgreOpcodeExample::setup(void)
{
mRoot = new Root();
setupResources();
bool carryOn = configure();
if (!carryOn) return false;
chooseSceneManager();
createCamera();
createViewports();
// Set default mipmap level (NB some APIs ignore this)
TextureManager::getSingleton().setDefaultNumMipmaps(5);
// Create any resource listeners (for loading screens)
createResourceListener();
// Load resources
loadResources();
// Create the scene
createScene();
createFrameListener();
return true;
};
//-------------------------------------------------------------------------------------
void OgreOpcodeExample::updateStats(void)
{
static String currFps = "Current FPS: ";
static String avgFps = "Average FPS: ";
static String bestFps = "Best FPS: ";
static String worstFps = "Worst FPS: ";
static String tris = "Triangle Count: ";
// update stats when necessary
try {
OverlayElement* guiAvg = OverlayManager::getSingleton().getOverlayElement("Core/AverageFps");
OverlayElement* guiCurr = OverlayManager::getSingleton().getOverlayElement("Core/CurrFps");
OverlayElement* guiBest = OverlayManager::getSingleton().getOverlayElement("Core/BestFps");
OverlayElement* guiWorst = OverlayManager::getSingleton().getOverlayElement("Core/WorstFps");
const RenderTarget::FrameStats& stats = mWindow->getStatistics();
guiAvg->setCaption(avgFps + StringConverter::toString(stats.avgFPS));
guiCurr->setCaption(currFps + StringConverter::toString(stats.lastFPS));
guiBest->setCaption(bestFps + StringConverter::toString(stats.bestFPS)
+" "+StringConverter::toString(stats.bestFrameTime)+" ms");
guiWorst->setCaption(worstFps + StringConverter::toString(stats.worstFPS)
+" "+StringConverter::toString(stats.worstFrameTime)+" ms");
OverlayElement* guiTris = OverlayManager::getSingleton().getOverlayElement("Core/NumTris");
guiTris->setCaption(tris + StringConverter::toString(stats.triangleCount));
OverlayElement* guiDbg = OverlayManager::getSingleton().getOverlayElement("Core/DebugText");
guiDbg->setCaption(mWindow->getDebugText());
}
catch(...)
{
// ignore
}
}
//-------------------------------------------------------------------------------------
bool OgreOpcodeExample::processUnbufferedKeyInput(const FrameEvent& evt)
{
if (mInputDevice->isKeyDown(KC_A))
{
// Move camera left
mTranslateVector.x = -mMoveScale;
}
if (mInputDevice->isKeyDown(KC_D))
{
// Move camera RIGHT
mTranslateVector.x = mMoveScale;
}
/* Move camera forward by keypress. */
if (mInputDevice->isKeyDown(KC_UP) || mInputDevice->isKeyDown(KC_W) )
{
mTranslateVector.z = -mMoveScale;
}
/* Move camera backward by keypress. */
if (mInputDevice->isKeyDown(KC_DOWN) || mInputDevice->isKeyDown(KC_S) )
{
mTranslateVector.z = mMoveScale;
}
if (mInputDevice->isKeyDown(KC_PGUP))
{
// Move camera up
mTranslateVector.y = mMoveScale;
}
if (mInputDevice->isKeyDown(KC_PGDOWN))
{
// Move camera down
mTranslateVector.y = -mMoveScale;
}
if (mInputDevice->isKeyDown(KC_RIGHT))
{
mCamera->yaw(-mRotScale);
}
if (mInputDevice->isKeyDown(KC_LEFT))
{
mCamera->yaw(mRotScale);
}
if( mInputDevice->isKeyDown( KC_ESCAPE) )
{
return false;
}
// see if switching is on, and you want to toggle
if (mInputTypeSwitchingOn && mInputDevice->isKeyDown(KC_M) && mTimeUntilNextToggle <= 0)
{
switchMouseMode();
mTimeUntilNextToggle = 1;
}
if (mInputTypeSwitchingOn && mInputDevice->isKeyDown(KC_K) && mTimeUntilNextToggle <= 0)
{
// must be going from immediate keyboard to buffered keyboard
switchKeyMode();
mTimeUntilNextToggle = 1;
}
if (mInputDevice->isKeyDown(KC_F) && mTimeUntilNextToggle <= 0)
{
mStatsOn = !mStatsOn;
showDebugOverlay(mStatsOn);
mTimeUntilNextToggle = 1;
}
if (mInputDevice->isKeyDown(KC_T) && mTimeUntilNextToggle <= 0)
{
switch(mFiltering)
{
case TFO_BILINEAR:
mFiltering = TFO_TRILINEAR;
mAniso = 1;
break;
case TFO_TRILINEAR:
mFiltering = TFO_ANISOTROPIC;
mAniso = 8;
break;
case TFO_ANISOTROPIC:
mFiltering = TFO_BILINEAR;
mAniso = 1;
break;
default:
break;
}
MaterialManager::getSingleton().setDefaultTextureFiltering(mFiltering);
MaterialManager::getSingleton().setDefaultAnisotropy(mAniso);
showDebugOverlay(mStatsOn);
mTimeUntilNextToggle = 1;
}
if (mInputDevice->isKeyDown(KC_SYSRQ) && mTimeUntilNextToggle <= 0)
{
char tmp[20];
sprintf(tmp, "screenshot_%d.png", ++mNumScreenShots);
mWindow->writeContentsToFile(tmp);
mTimeUntilNextToggle = 0.5;
mWindow->setDebugText(String("Wrote ") + tmp);
}
if (mInputDevice->isKeyDown(KC_R) && mTimeUntilNextToggle <=0)
{
mSceneDetailIndex = (mSceneDetailIndex+1)%3 ;
switch(mSceneDetailIndex) {
case 0 : mCamera->setPolygonMode(PM_SOLID) ; break ;
case 1 : mCamera->setPolygonMode(PM_WIREFRAME) ; break ;
case 2 : mCamera->setPolygonMode(PM_POINTS) ; break ;
}
mTimeUntilNextToggle = 0.5;
}
static bool displayCameraDetails = false;
if (mInputDevice->isKeyDown(KC_P) && mTimeUntilNextToggle <= 0)
{
displayCameraDetails = !displayCameraDetails;
mTimeUntilNextToggle = 0.5;
if (!displayCameraDetails)
mWindow->setDebugText("");
}
if (displayCameraDetails)
{
// Print camera details
mWindow->setDebugText("P: " + StringConverter::toString(mCamera->getDerivedPosition()) + " " +
"O: " + StringConverter::toString(mCamera->getDerivedOrientation()));
}
// Return true to continue rendering
return true;
}
//-------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------
bool OgreOpcodeExample::processUnbufferedMouseInput(const FrameEvent& evt)
{
/* Rotation factors, may not be used if the second mouse button is pressed. */
/* If the second mouse button is pressed, then the mouse movement results in
sliding the camera, otherwise we rotate. */
if( mInputDevice->getMouseButton( 1 ) )
{
mTranslateVector.x += mInputDevice->getMouseRelativeX() * 0.13;
mTranslateVector.y -= mInputDevice->getMouseRelativeY() * 0.13;
}
else
{
mRotX = Degree(-mInputDevice->getMouseRelativeX() * 0.13);
mRotY = Degree(-mInputDevice->getMouseRelativeY() * 0.13);
}
return true;
}
//-------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------
void OgreOpcodeExample::moveCamera()
{
// Make all the changes to the camera
// Note that YAW direction is around a fixed axis (freelook style) rather than a natural YAW (e.g. airplane)
mCamera->yaw(mRotX);
mCamera->pitch(mRotY);
mCamera->moveRelative(mTranslateVector);
}
//-------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------
void OgreOpcodeExample::showDebugOverlay(bool show)
{
if (mDebugOverlay)
{
if (show)
{
mDebugOverlay->show();
}
else
{
mDebugOverlay->hide();
}
}
}
//-------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------
bool OgreOpcodeExample::frameStarted(const FrameEvent& evt)
{
if(mWindow->isClosed())
return false;
if (!mInputTypeSwitchingOn)
{
mInputDevice->capture();
}
if ( !mUseBufferedInputMouse || !mUseBufferedInputKeys)
{
// one of the input modes is immediate, so setup what is needed for immediate mouse/key movement
if (mTimeUntilNextToggle >= 0)
mTimeUntilNextToggle -= evt.timeSinceLastFrame;
// If this is the first frame, pick a speed
if (evt.timeSinceLastFrame == 0)
{
mMoveScale = 1;
mRotScale = 0.1;
}
// Otherwise scale movement units by time passed since last frame
else
{
// Move about 100 units per second,
mMoveScale = mMoveSpeed * evt.timeSinceLastFrame;
// Take about 10 seconds for full rotation
mRotScale = mRotateSpeed * evt.timeSinceLastFrame;
}
mRotX = 0;
mRotY = 0;
mTranslateVector = Vector3::ZERO;
}
if (mUseBufferedInputKeys)
{
// no need to do any processing here, it is handled by event processor and
// you get the results as KeyEvents
}
else
{
if (processUnbufferedKeyInput(evt) == false)
{
return false;
}
}
if (mUseBufferedInputMouse)
{
// no need to do any processing here, it is handled by event processor and
// you get the results as MouseEvents
}
else
{
if (processUnbufferedMouseInput(evt) == false)
{
return false;
}
}
if ( !mUseBufferedInputMouse || !mUseBufferedInputKeys)
{
// one of the input modes is immediate, so update the movement vector
moveCamera();
}
return true;
}
//-------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------
bool OgreOpcodeExample::frameEnded(const FrameEvent& evt)
{
updateStats();
return true;
}
//-------------------------------------------------------------------------------------
void OgreOpcodeExample::switchMouseMode()
{
mUseBufferedInputMouse = !mUseBufferedInputMouse;
mInputDevice->setBufferedInput(mUseBufferedInputKeys, mUseBufferedInputMouse);
}
//-------------------------------------------------------------------------------------
void OgreOpcodeExample::switchKeyMode()
{
mUseBufferedInputKeys = !mUseBufferedInputKeys;
mInputDevice->setBufferedInput(mUseBufferedInputKeys, mUseBufferedInputMouse);
}
//-------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------
void OgreOpcodeExample::keyClicked(KeyEvent* e)
{
if (e->getKeyChar() == 'm')
{
switchMouseMode();
}
else if (e->getKeyChar() == 'k')
{
switchKeyMode();
}
}
//-------------------------------------------------------------------------------------
void OgreOpcodeExample::keyPressed(KeyEvent* e) {}
//-------------------------------------------------------------------------------------
void OgreOpcodeExample::keyReleased(KeyEvent* e) {}
//-------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------
| [
"jacmoe@4fa2dde5-35f3-0310-a95e-e112236e8438"
] | [
[
[
1,
594
]
]
] |
ac0766de2381ada4dcd7b102e2685d2367dc54da | 0eb6dae3844d1e57d7580d68b03550f312c0b88d | /Factory/demosystem/shell/shell.cc | bb917f828cb005a2d397a73daeda0cd1021a4123 | [] | no_license | glerchundi/vasik | da32f4dd04d6b55631493e92a14fa79263af5824 | 177646652f7af5fa2fbbc98e697675d780a41339 | refs/heads/master | 2021-01-10T20:07:51.441193 | 2009-06-16T10:39:09 | 2009-06-16T10:39:09 | 33,879,767 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,592 | cc | #include "shell.h"
#define BUFSIZE 64
static TList<char*> cmdHistory;
static char output[BUFSIZE];
static char buffer[BUFSIZE];
static char current[BUFSIZE];
static char errorStr[BUFSIZE];
static int bufferCnt, cmdPos;
static int
onKey(int key, int keystate) {
if(keystate) {
char cKey = (char)key;
if(key < 256) {
buffer[bufferCnt] = (char)key;
buffer[bufferCnt+1] = '\0';
bufferCnt++;
}
switch(key) {
case 283: // UP
if(cmdPos == cmdHistory.size()) {
snprintf(current,bufferCnt+1,"%s",buffer);
}
if(cmdPos) {
char *s = cmdHistory.get(--cmdPos);
snprintf(buffer,BUFSIZE,"%s",s);
bufferCnt = strlen(s);
}
break;
case 284: // DOWN
if(cmdPos == cmdHistory.size()-1) {
memset(buffer,' ',BUFSIZE);
snprintf(buffer,BUFSIZE,"%s",current);
bufferCnt = strlen(current);
cmdPos++;
}
if(cmdPos < cmdHistory.size()-1) {
char *s = cmdHistory.get(++cmdPos);
snprintf(buffer,BUFSIZE,"%s",s);
bufferCnt = strlen(s);
}
break;
case 285: // LEFT
break;
case 286: // RIGHT
break;
case 294: // ENTER
if(bufferCnt) {
// save string in history
char *s = new char[bufferCnt+1];
snprintf(s,bufferCnt+1,"%s",buffer);
cmdHistory.add(NULL, s);
cmdPos = cmdHistory.size();
// execute string in the script
TScript::dostring(buffer,errorStr);
memset(buffer,' ', BUFSIZE);
buffer[0] = '\0';
bufferCnt = 0;
}
break;
case 295: // BACKWARD
if(bufferCnt) {
buffer[--bufferCnt] = '\0';
}
break;
default:
break;
}
}
return 0;
}
WRAPPLUGIN(shell)
WRAPFUNC0(_int,render)
shell::shell() {
SHAREPLUGIN(shell);
SHAREFUNC(render);
}
shell::~shell() {
}
void
shell::initplugin(char *name, TPlugin *plugin) {
this->addplugin(name, plugin);
}
void
shell::init(void) {
cmdPos = 0;
bufferCnt = 0;
currentMs = 0;
lastBlinkMs = 0;
lastErrorMs = 0;
xOffset = 0;
yOffset = 0;
yPosition = 0;
blinkCursor = ' ';
vars[0]._pvoid = (void *)&onKey;
execute("window","addkeyboardcallback",vars);
ret = execute("window","getwidth",NULL);
windowWidth = ret->_int;
ret = execute("window","getheight",NULL);
windowHeight = ret->_int;
ret = execute("timer","createTimer",NULL);
timerId = ret->_int;
vars[0]._int = timerId;
execute("timer","start",vars);
vars[0]._pchar = SHELL_PREFIX;
ret = execute("font","getWidth",vars);
xOffset = ret->_int;
ret = execute("font","getHeight",NULL);
yOffset = ret->_int;
onBottom();
}
void
shell::quit(void) {
}
int
shell::onTop(void) {
yPosition = 0;
return 0;
}
int
shell::onBottom(void) {
yPosition = windowHeight - yOffset;
return 0;
}
int
shell::render(void) {
vars[0]._int = timerId;
ret = execute("timer","getMs",vars);
currentMs = ret->_int;
vars[0]._int = windowWidth;
vars[1]._int = windowHeight;
vars[2]._bool = true;
execute("window","setupview",vars);
// Shell commands
vars[0]._int = 0;
vars[1]._int = yPosition;
vars[2]._pchar = SHELL_PREFIX;
execute("font","drawText",vars);
if(currentMs-lastBlinkMs > 500) {
lastBlinkMs = currentMs;
blinkCursor = (blinkCursor == ' ') ? '_' : ' ';
}
snprintf(output,BUFSIZE,"%s%c",buffer,blinkCursor);
vars[0]._int = xOffset;
vars[1]._int = yPosition;
vars[2]._pchar = output;
execute("font","drawText",vars);
// Error messages
vars[0]._int = 0;
vars[1]._int = 0;
vars[2]._pchar = errorStr;
execute("font","drawText",vars);
return 0;
}
| [
"glertxundi@0aa467b6-4590-11de-a2ae-350cbd0950bb"
] | [
[
[
1,
182
]
]
] |
a2a39195f0d6ec329299553d5f0795b2644c43c5 | 388a262c60d0334096836741276e81ee0bff8ae6 | /code/Interfaces/Interface.h | e2a1aaa4e2fc3ee105a16030f60b6220836c3b62 | [] | no_license | charliep/Earlham-Smoke | 7278976edf0e7df7877722da6f2a649ad5e307b7 | 8757761fb4e02e2f0868142788d413ba68ccbbb6 | refs/heads/master | 2021-01-06T20:42:38.361713 | 2010-03-26T14:36:02 | 2010-03-26T14:36:02 | null | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 1,413 | h | // Copyright © 2008-2009 Intel Corporation
// All Rights Reserved
//
// Permission is granted to use, copy, distribute and prepare derivative works of this
// software for any purpose and without fee, provided, that the above copyright notice
// and this statement appear in all copies. Intel makes no representations about the
// suitability of this software for any purpose. THIS SOFTWARE IS PROVIDED "AS IS."
// INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, AND ALL LIABILITY,
// INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, FOR THE USE OF THIS SOFTWARE,
// INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY RIGHTS, AND INCLUDING THE
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Intel does not
// assume any responsibility for any errors which may appear in this software nor any
// responsibility to update it.
#pragma once
namespace Interface
{
#include "SystemTypes.h"
#include "Property.h"
#include "Platform.h"
#include "ChangeControl.h"
#include "TaskManager.h"
#include "Environment.h"
#include "Service.h"
#include "System.h"
#include "Generic.h"
#include "Geometry.h"
#include "Graphics.h"
#include "GUI.h"
#include "Contact.h"
#include "Behavior.h"
#include "Area.h"
#include "Move.h"
#include "Target.h"
}
using namespace Interface;
| [
"samuel@Chumbo.(none)"
] | [
[
[
1,
37
]
]
] |
7bc58257725727015e3455519ac0ffb2a431fd24 | f64b888affed8c6db2cc56d4618c72c923fe1a7c | /include/lockmgr/internal/syncprim_unix.hxx | 57e19aad215bd17949af0e7fbdf01cb56edb2766 | [
"BSD-2-Clause"
] | permissive | wilx/lockmgr | 64ca319f87ccf96214d9c4a3e1095f783fb355d8 | 9932287c6a49199730abfb4332f85c9ca05d9511 | refs/heads/master | 2021-01-10T02:19:35.039497 | 2008-06-09T11:24:32 | 2008-06-09T11:24:32 | 36,984,337 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,505 | hxx | // Copyright (c) 2008, Václav Haisman
//
// 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.
//
// 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.
#if ! defined (LOCKMANAGER_LOCKMGR_INTERNAL_SYNCPRIM_UNIX_HXX)
#define LOCKMANAGER_LOCKMGR_INTERNAL_SYNCPRIM_UNIX_HXX
#include <cassert>
#include <boost/utility.hpp>
#include <pthread.h>
namespace lockmgr
{
//
template <typename T>
class UnixSyncPrimitive
: boost::noncopyable
{
public:
typedef T primitive_type;
void
attach (primitive_type * p)
{
assert (! m_handle);
m_handle = p;
}
primitive_type *
get () const
{
return m_handle;
}
typedef primitive_type * (UnixSyncPrimitive::* boolean_type) ();
operator boolean_type () const
{
return static_cast<boolean_type>(m_handle);
}
protected:
UnixSyncPrimitive ()
: m_handle (0)
{ }
~UnixSyncPrimitive ()
{
delete m_handle;
}
primitive_type * m_handle;
};
//
class PthreadMutex
: public UnixSyncPrimitive<pthread_mutex_t>
{
public:
PthreadMutex ();
~PthreadMutex ();
void lock () const;
void unlock () const;
};
//
template <typename Primitive>
class UnixLockGuard
: boost::noncopyable
{
public:
explicit UnixLockGuard (Primitive const & prim)
: m_prim (&prim), m_locked (false)
{
lock ();
}
~UnixLockGuard ()
{
try
{
if (m_prim && m_locked)
m_prim->unlock ();
}
catch (...)
{
assert (0);
// We can't do much about it here.
}
}
void detach ()
{
m_prim = 0;
m_locked = false;
}
void lock ()
{
assert (m_prim);
assert (! m_locked);
m_prim->lock ();
m_locked = true;
}
void unlock ()
{
assert (m_prim);
assert (m_locked);
m_prim->unlock ();
m_locked = false;
}
private:
const Primitive * m_prim;
bool m_locked;
};
typedef UnixLockGuard<PthreadMutex> PthreadMutexGuard;
} // namespace lockmgr
#endif // LOCKMANAGER_LOCKMGR_INTERNAL_SYNCPRIM_UNIX_HXX
// Local Variables:
// mode: C++
// eval: (c-set-style "microsoft")
// End:
| [
"[email protected]"
] | [
[
[
1,
162
]
]
] |
111c6f2fbd8cfb78d71fd8bc189c842803d3fa05 | 744e9a2bf1d0aee245c42ee145392d1f6a6f65c9 | /tags/0.11.1-alpha/gui/ttcutmainwnd.h | 307e2b4f8756462350bbe00e758d3bbed79702ac | [] | no_license | BackupTheBerlios/ttcut-svn | 2b5d00c3c6d16aa118b4a58c7d0702cfcc0b051a | 958032e74e8bb144a96b6eb7e1d63bc8ae762096 | refs/heads/master | 2020-04-22T12:08:57.640316 | 2009-02-08T16:14:00 | 2009-02-08T16:14:00 | 40,747,642 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,884 | h | /*----------------------------------------------------------------------------*/
/* COPYRIGHT: TriTime (c) 2003/2005 / www.tritime.org */
/*----------------------------------------------------------------------------*/
/* PROJEKT : TTCUT 2005 */
/* FILE : ttcutmainwnd.h */
/*----------------------------------------------------------------------------*/
/* AUTHOR : b. altendorf (E-Mail: [email protected]) DATE: 02/23/2005 */
/* MODIFIED: b. altendorf DATE: 03/01/2005 */
/* MODIFIED: b. altendorf DATE: 03/19/2005 */
/* MODIFIED: b. altendorf DATE: 04/01/2005 */
/* MODIFIED: b. altendorf DATE: 06/22/2005 */
/* MODIFIED: DATE: */
/*----------------------------------------------------------------------------*/
// ----------------------------------------------------------------------------
// TTCUTMAINWND
// ----------------------------------------------------------------------------
/*----------------------------------------------------------------------------*/
/* This program is free software; you can redistribute it and/or modify it */
/* under the terms of the GNU General Public License as published by the Free */
/* Software Foundation; */
/* either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT*/
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
/* FITNESS FOR A PARTICULAR PURPOSE. */
/* See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along */
/* with this program; if not, write to the Free Software Foundation, */
/* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */
/*----------------------------------------------------------------------------*/
#ifndef TTCUTMAINWND_H
#define TTCUTMAINWND_H
#include <QMainWindow>
#include <QWheelEvent>
#include <QFocusEvent>
#include <QGridLayout>
#include <QKeyEvent>
#include <QHBoxLayout>
#include <QLabel>
#include <QVBoxLayout>
#include <QResizeEvent>
#include <QMenuBar>
#include <QFileDialog>
// gui
// -----------------------------------------------------------------------------
#include "ttcut.h" /*..global parameter..........................*/
#include "ttcutsettings.h" /*..settings dialog; load/save settings.......*/
#include "ttcutavcutdlg.h" /*..cut A/V settings/start dialog.............*/
#include "ttaudiolistview.h" /*..the audio files listview..................*/
#include "ttcutccrwnd.h" /*..cut-list/chapter/result (ccr) widget......*/
#include "ttcutlistview.h" /*..cut listview..............................*/
#include "ttprogressbar.h" /*..the progress dialog.......................*/
#include "ttcutpreview.h" /*..the cut preview window....................*/
#include "ttsearchframe.h" /*..frame search method.......................*/
#include "ttcutaboutdlg.h" /*..the everlasting about.....................*/
#include "ttcutproject.h" /*..project file..............................*/
// mpeg2window
// -----------------------------------------------------------------------------
#include "../mpeg2window/ttmpeg2window.h" /*..video output widget.............*/
// avstream
// -----------------------------------------------------------------------------
#include "../avstream/ttavtypes.h" /*..AV types (audio, video).......*/
#include "../avstream/ttmpeg2videostream.h" /*..AV stream objects.............*/
// avcut
// -----------------------------------------------------------------------------
#include "../avcut/ttavcutposition.h" /*..cut class...........................*/
//#include "../avcut/tvideoschnitt.h" /*..video cut processing stuff..........*/
//#include "../avcut/ttaudiocut.h" /*..audio cut processing stuff..........*/
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QSpacerItem;
class QAction;
class Q3ActionGroup;
class QScrollBar;
class QPushButton;
class Q3ListView;
class Q3ListViewItem;
class QLabel;
class QGroupBox;
class TTCutMainWnd : public QMainWindow
{
Q_OBJECT
public:
TTCutMainWnd( QWidget* parent=0, Qt::WFlags fl=Qt::WType_TopLevel );
~TTCutMainWnd();
void refreshCurrentPosition();
public slots:
void resizeEvent( QResizeEvent* re );
void focusInEvent( QFocusEvent* e );
void focusOutEvent( QFocusEvent* e );
void wheelEvent( QWheelEvent* e );
void keyPressEvent ( QKeyEvent * e );
// file-menu
virtual void fileNew();
virtual void fileOpen();
virtual void fileSave();
virtual void fileSaveAs();
virtual void fileRecent();
virtual void fileExit();
// action-menu
virtual void actionSave();
virtual void actionSettings();
// help menue
virtual void helpAbout();
// video stream section
virtual void openVideoFile();
virtual void refreshCutVideoLength();
// audio stream section
virtual void openAudioFile();
virtual void audioFileUp();
virtual void audioFileDown();
// cut out frame section
virtual void lastFramePrevious();
virtual void lastFrameNext();
virtual void searchFrame();
virtual void selectCutOut( TTAVCutPosition& cutPos );
virtual void showSlaveCutIn( TTAVCutPosition& cutPos );
virtual void showSlaveCutOut( TTAVCutPosition& cutPos );
// current frame section
virtual void playVideo();
// navigation section
virtual void gotoPrevIFrame();
virtual void gotoNextIFrame();
virtual void gotoPrevPFrame();
virtual void gotoNextPFrame();
virtual void gotoPrevFrame();
virtual void gotoNextFrame();
virtual void setCutInPoint();
virtual void setCutOutPoint();
virtual void gotoCutInPosition();
virtual void gotoCutOutPosition();
virtual void addRangeToCutList();
virtual void fastMotionOption();
virtual void cutProposition();
virtual void setMarker();
virtual void gotoMarker();
// video position slider
virtual void videoSliderChanged( int );
// cut section
virtual void cutPreview();
virtual void previewSingleCut( uint i_pos );
virtual void videoAudioCut();
virtual void audioCut();
virtual void moveCutEntryUp();
virtual void deleteCutEntry();
virtual void moveCutEntryDown();
virtual void editCutListEntry( TTAVCutPosition& cutPos );
void showVideoStreamInfo();
uint moveToMpeg2Index( uint i_pos, int f_type=0 );
void createAVStreams( );
void showCutInFrameAt( uint i_pos );
protected slots:
virtual void languageChange();
signals:
void cutOutIndexChanged( uint cut_out_index, QTime cut_out_time );
protected:
void enableNavigation();
void disableNavigation();
void checkCutPosition();
void refreshMarkerPosition();
void refreshCutOutPosition();
void refreshVideoLength();
// project section
void DateiAktualisieren( QFileInfo videoFInfo, QFileInfo audioFInfo );
void closeProject();
private:
// GUI
QWidget *centralWidget;
QWidget *widget;
QGridLayout *gridLayout;
QHBoxLayout *hboxLayout;
QGroupBox *gbCutOutFrame;
QGridLayout *gridLayout1;
QHBoxLayout *hboxLayout1;
QLabel *laCutOutFramePosition;
QPushButton *pbPrevCutOutFrame;
QPushButton *pbNextCutOutFrame;
QPushButton *pbSearchFrame;
QFrame *cutOutWnd;
QGroupBox *gbCurrentFrame;
QGridLayout *gridLayout2;
QHBoxLayout *hboxLayout2;
QPushButton *pbPlayVideo;
QLabel *tlCurrentPosition;
QFrame *curentFrameEnd;
QGroupBox *gbNavigation;
QWidget *widget1;
QWidget *widget2;
QGridLayout *gridLayout3;
QGridLayout *gridLayout4;
QSpacerItem *spacerItem;
QLabel *tlCutInPosition;
QPushButton *pbGotoCutOut;
QSpacerItem *spacerItem1;
QPushButton *pbNextPFrame;
QPushButton *pbGotoCutIn;
QSpacerItem *spacerItem2;
QPushButton *pbSetCutIn;
QPushButton *pbSetCutOut;
QPushButton *pbPrevIFrame;
QPushButton *pbPrevBFrame;
QSpacerItem *spacerItem3;
QPushButton *pbPrevPFrame;
QSpacerItem *spacerItem4;
QPushButton *pbNextBFrame;
QLabel *tlCutOutPosition;
QPushButton *pbNextIFrame;
QSpacerItem *spacerItem5;
QGridLayout *gridLayout5;
QPushButton *pbStreamPoints;
QPushButton *pbSetMarker;
QPushButton *pbGotoMarker;
QPushButton *pbAddCut;
QPushButton *pbQuickJump;
QLabel *tlMarkerPosition;
QGroupBox *gbAudioFiles;
QGridLayout *gridLayout6;
QVBoxLayout *vboxLayout;
QPushButton *pbOpenAudioFile;
QPushButton *pbAudioFileUp;
QPushButton *pbAudioFileDown;
QGroupBox *gbVideoFile;
QGridLayout *gridLayout7;
QGridLayout *gridLayout8;
QLabel *tlVideoFileName;
QLabel *laVbvBuffer;
QLabel *laBitRate;
QLabel *laFrameRate;
QLabel *tlVbvBuffer;
QLabel *tlBitRate;
QLabel *tlFrameRate;
QLabel *tlVideoAspect;
QLabel *tlResolution;
QLabel *tlVideoLen;
QLabel *laVideoAspect;
QLabel *laResolution;
QLabel *laVideoLen;
QLabel *laVideoFileName;
QPushButton *pbOpenVideoFile;
QHBoxLayout *hboxLayout3;
QVBoxLayout *vboxLayout1;
QSpacerItem *spacerItem6;
QPushButton *pbChapter;
QPushButton *pbCutPreview;
QPushButton *pbVideoAudioCut;
QPushButton *pbAudioCut;
QScrollBar *sbVideoPosition;
TTAudioListView* lvAudioFiles;
TTCutListView* cutListView;
TTCutCCRWnd* ccrTab;
QMenu* fileMenu;
QMenu* actionMenu;
QMenu* helpMenu;
QAction* fileNewAction;
QAction* fileOpenAction;
QAction* fileSaveAction;
QAction* fileSaveAsAction;
QAction* fileRecentAction;
QAction* fileExitAction;
QAction* actionSaveAction;
QAction* actionSettingsAction;
QAction* helpAboutAction;
TTMessageLogger* log;
// Progress bar
TTProgressBar* progress_bar;
// Settings; Settings dialog
TTCutSettings* settings;
TTCutSettingsDlg* settingsDlg;
// Cut A/V dialog
TTCutAVCutDlg* cutAVDlg;
// -------------------------------------------------------------------------
// Application
// -------------------------------------------------------------------------
QString video_file_name; /*..video file name..................*/
QString audio_file_name; /*..first audio file name............*/
QString project_file_name;
// AV type
// -------------------------------------------------------------------------
TTVideoType* video_type; /*..video type.......................*/
TTAudioType* audio_type; /*..audio type.......................*/
// stream objects
// -------------------------------------------------------------------------
TTMpeg2VideoStream* mpeg2_stream; /*..the mpeg2 video stream...........*/
TTMpeg2VideoStream* cut_out_stream; /*..stream copy for the cut-out frame*/
//TTAudioStream* audio_stream; /*..the first audio stream...........*/
TTMPEG2Window* cutOutFrameWnd; /*..mpeg2 window for cut-out frame...*/
TTMPEG2Window* currentFrameWnd; /*..mpeg2 window for cut-in frame....*/
bool sliderUpdateFrame;
long currentFramePos;
int iSliderPrev;
bool isCutInPos;
bool isCutOutPos;
bool firstCutOut;
long markerPosition;
uint num_index;
uint num_header;
uint current_frame_pos;
TTAVCutPosition* current_cut_pos;
TTAVCutList* avcut_list;
};
#endif // TTCUTMAINWND_H
| [
"tritime@7763a927-590e-0410-8f7f-dbc853b76eaa"
] | [
[
[
1,
355
]
]
] |
65088e3caff9cfda85c02a0d6c6c8ef54ed73a71 | 3971d26cbdfd1ca41e84754bdf21ff6fbc53182e | /trunk/src/ThumbnailStack.cpp | 22076c442747c8dd6008adfc66070e1186c26062 | [] | no_license | ppershing/mosaic-from-images | bd998004de1555f76777047000ac0642ace0c860 | 54a2f6c9cd3c37f118a133d4fce1eaf5678581d2 | refs/heads/master | 2020-04-25T00:26:40.707089 | 2011-01-06T17:59:11 | 2011-01-06T17:59:11 | 32,278,829 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,075 | cpp | // created and maintained by ppershing
// please report any bug or suggestion to ppershing<>fks<>sk
#include "ThumbnailStack.h"
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_rotozoom.h>
#include <string>
#include "MyAssert.h"
#include "Cache.h"
ThumbnailStack::ThumbnailStack(){
stack.resize(SIZE);
}
void ThumbnailStack::loadFromCache(CacheData& data, int minDivision){
std::string filename = data.getThumbnailFile();
SDL_Surface* tmpSurface = IMG_Load(filename.c_str());
Assert(tmpSurface, "problem with loading thumbnail "+filename);
SDL_Surface* surface = shrinkSurface(tmpSurface, 1<<minDivision,
1<<minDivision);
Assert(surface, "problem converting surface");
SDL_FreeSurface(tmpSurface);
loadFromSurfaceInternal(surface, minDivision);
SDL_FreeSurface(surface);
}
void ThumbnailStack::loadFromSurface(SDL_Surface* surface, int x,int y, int
initialDivision) {
SDL_Surface* tmpSurface = SDL_CreateRGBSurface(SDL_SWSURFACE,
Cache::getTileWidth(initialDivision),
Cache::getTileHeight(initialDivision),
32, 0,0,0,0);
Assert(tmpSurface, "");
SDL_Rect rect;
rect.x=x;
rect.y=y;
rect.w=Cache::getTileWidth(initialDivision);
rect.h=Cache::getTileHeight(initialDivision);
SDL_BlitSurface(surface, &rect, tmpSurface, NULL);
loadFromSurfaceInternal(tmpSurface, initialDivision);
SDL_FreeSurface(tmpSurface);
}
void ThumbnailStack::loadFromSurfaceInternal(SDL_Surface* surface, int
initialDivision) {
if (initialDivision >= SIZE) return;
int w=Cache::getTileWidth(initialDivision);
int h=Cache::getTileHeight(initialDivision);
Assert(surface->w == w, "");
Assert(surface->h == h, "");
stack[initialDivision].loadFromSurface(surface, 0, 0, w, h);
SDL_Surface* tmpSurface=shrinkSurface(surface, 2, 2);
Assert(tmpSurface, "");
loadFromSurfaceInternal(tmpSurface, initialDivision+1);
SDL_FreeSurface(tmpSurface);
}
| [
"ppershing@967e5cf6-af39-6869-9469-1a2409c1b03c"
] | [
[
[
1,
64
]
]
] |
6b208484c113701d8add0de7b57d6e7f7c8c45e5 | 74c8da5b29163992a08a376c7819785998afb588 | /NetAnimal/Game/wheel/MyWheelDirector/include/TableComponentKey.h | b9c80f0fe995514cf86368d5c0590f9965b9fe0a | [] | 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 | GB18030 | C++ | false | false | 575 | h | #ifndef __Orz_TableComponentKey_h__
#define __Orz_TableComponentKey_h__
//#include "CodingInterface.h"
namespace Orz
{
class F5TableInterface;
class TableComponentKey: public Component, public KeyListener
{
private:
public:
virtual ~TableComponentKey(void);
TableComponentKey(void);
///通知键盘按下事件
bool onKeyPressed(const KeyEvent & evt);
///通知键盘释放事件
bool onKeyReleased(const KeyEvent & evt);
private:
virtual ComponentInterface * _queryInterface(const TypeInfo & info);
};
}
#endif
| [
"[email protected]"
] | [
[
[
1,
30
]
]
] |
70f0c36a6f15586028a7fb59ecf98ba28a5fc4e2 | 463c3b62132d215e245a097a921859ecb498f723 | /lib/dlib/map/map_kernel_abstract.h | b36ea5c3b94169fadfb255fc64723e2d9449dd3d | [
"LicenseRef-scancode-unknown-license-reference",
"BSL-1.0"
] | permissive | athulan/cppagent | 58f078cee55b68c08297acdf04a5424c2308cfdc | 9027ec4e32647e10c38276e12bcfed526a7e27dd | refs/heads/master | 2021-01-18T23:34:34.691846 | 2009-05-05T00:19:54 | 2009-05-05T00:19:54 | 197,038 | 4 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 7,948 | h | // Copyright (C) 2003 Davis E. King ([email protected])
// License: Boost Software License See LICENSE.txt for the full license.
#undef DLIB_MAP_KERNEl_ABSTRACT_
#ifdef DLIB_MAP_KERNEl_ABSTRACT_
#include "../interfaces/map_pair.h"
#include "../interfaces/enumerable.h"
#include "../interfaces/remover.h"
#include "../serialize.h"
#include "../memory_manager/memory_manager_kernel_abstract.h"
#include <functional>
namespace dlib
{
template <
typename domain,
typename range,
typename mem_manager = memory_manager<char>::kernel_1a,
typename compare = std::less<domain>
>
class map : public enumerable<map_pair<domain,range> >,
public asc_pair_remover<domain,range,compare>
{
/*!
REQUIREMENTS ON domain
domain must be comparable by compare where compare is a functor compatible with std::less and
domain is swappable by a global swap() and
domain must have a default constructor
REQUIREMENTS ON range
range is swappable by a global swap() and
range must have a default constructor
REQUIREMENTS ON mem_manager
must be an implementation of memory_manager/memory_manager_kernel_abstract.h or
must be an implementation of memory_manager_global/memory_manager_global_kernel_abstract.h or
must be an implementation of memory_manager_stateless/memory_manager_stateless_kernel_abstract.h
mem_manager::type can be set to anything.
POINTERS AND REFERENCES TO INTERNAL DATA
swap(), is_in_domain(), and operator[] functions do not invalidate
pointers or references to internal data.
All other functions have no such guarantee.
INITIAL VALUE
size() == 0
ENUMERATION ORDER
The enumerator will iterate over the domain (and each associated
range element) elements in ascending order according to the compare functor.
(i.e. the elements are enumerated in sorted order)
WHAT THIS OBJECT REPRESENTS
map contains items of type domain and range
This object is similar an array. It maps items of type domain on to
items of type range.
Also note that unless specified otherwise, no member functions
of this object throw exceptions.
definition of equivalent:
a is equivalent to b if
a < b == false and
b < a == false
!*/
public:
typedef domain domain_type;
typedef range range_type;
typedef compare compare_type;
typedef mem_manager mem_manager_type;
map(
);
/*!
ensures
- #*this is properly initialized
throws
- std::bad_alloc or any exception thrown by domain's or range's
constructor.
!*/
virtual ~map(
);
/*!
ensures
- all memory associated with *this has been released
!*/
void clear(
);
/*!
ensures
- #*this has its initial value
throws
- std::bad_alloc or any exception thrown by domain's or range's
constructor.
if this exception is thrown then *this is unusable
until clear() is called and succeeds
!*/
void add (
domain& d,
range& r
);
/*!
requires
- &d != &r (i.e. d and r cannot be the same variable)
- is_in_domain(d) == false
ensures
- #is_in_domain(d) == true
- #operator[](d) == r
- #d and #r have initial values for their types
- #size() == size() + 1
- #at_start() == true
throws
- std::bad_alloc or any exception thrown by domain's or range's
constructor.
if add() throws then it has no effect
!*/
bool is_in_domain (
const domain& d
) const;
/*!
ensures
- returns whether or not an element equivalent to d is in the
domain of *this
!*/
void remove (
const domain& d,
domain& d_copy,
range& r
);
/*!
requires
- &d != &r (i.e. d and r cannot be the same variable)
- &d != &d_copy (i.e. d and d_copy cannot be the same variable)
- &r != &d_copy (i.e. r and d_copy cannot be the same variable)
- is_in_domain(d) == true
ensures
- #is_in_domain(d) == false
- #d_copy is equivalent to d
- the element in the range of *this associated with #d_copy has been
swapped into #r
- #size() == size() - 1
- #at_start() == true
!*/
void destroy (
const domain& d
);
/*!
requires
- is_in_domain(d) == true
ensures
- #is_in_domain(d) == false
- #size() == size() - 1
- #at_start() == true
!*/
range& operator[] (
const domain& d
);
/*!
requires
- is_in_domain(d) == true
ensures
- returns a non-const reference to the element in the range of *this
associated with the element equivalent to d
!*/
const range& operator[] (
const domain& d
) const;
/*!
requires
- is_in_domain(d) == true
ensures
- returns a const reference to the element in the range of *this
associated with the element equivalent to d
!*/
void swap (
map& item
);
/*!
ensures
- swaps *this and item
!*/
private:
// restricted functions
map(map&); // copy constructor
map& operator=(map&); // assignment operator
};
template <
typename domain,
typename range,
typename mem_manager,
typename compare
>
inline void swap (
map<domain,range,mem_manager,compare>& a,
map<domain,range,mem_manager,compare>& b
) { a.swap(b); }
/*!
provides a global swap function
!*/
template <
typename domain,
typename range,
typename mem_manager,
typename compare
>
void deserialize (
map<domain,range,mem_manager,compare>& item,
std::istream& in
);
/*!
provides deserialization support
!*/
}
#endif // DLIB_MAP_KERNEl_ABSTRACT_
| [
"jimmy@DGJ3X3B1.(none)"
] | [
[
[
1,
235
]
]
] |
1f846be374e467447034d562e291b3586fea33e0 | 10cc03f3afc9a9d28f45b6bf49e55acd60bf117b | /device.h | fbc9268f6c5b8b6bf3ab293f00cf447fdef93862 | [] | no_license | d235j/kcdread | 362c11511b680e18485f37db2f0f547174ef6069 | 0d382571b4a9a4ff36b5d7747bb77660b1eaacb2 | refs/heads/master | 2021-01-02T08:38:54.205228 | 2003-03-26T08:59:55 | 2003-03-26T08:59:55 | 99,041,210 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,777 | h | /*
KurzCdRead
read and decode media in native Kurzweil format
device.h - abstract base class for all types of devices that
can be used with KMSI_Direct. Feel free to derive your own
classes (i.e. direct SCSI communication).
Copyright (c) 2002 Marc Halbruegge
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact the author:
Marc Halbruegge
Auf Torf 21
49328 Melle
Germany
eMail: [email protected]
*/
class Device {
protected:
char *name;
char *vendor;
public:
Device () {name=NULL; vendor=NULL;};
virtual ~Device() {};
virtual char *getName () {return name;};
virtual char *getVendor () {return vendor;};
virtual int getType () = 0;
virtual int getBlockSize() {return 0;};
virtual int getBlockCount() {return 0;};
virtual char* ReadSector(int s) = 0;
virtual char* ReadSector(int s, int c) = 0;
virtual void RequestSense() = 0;
virtual int getSenseCode() = 0;
virtual int getAddSenseCode() = 0;
virtual int StartStopUnit(int condition, int start) = 0;
virtual int TestUnitReady() = 0;
virtual int Reserve() = 0;
virtual int Release() = 0;
};
| [
""
] | [
[
[
1,
58
]
]
] |
bec7c22d0e6bcd0bb6338607fe5e9adb1f6af2db | 94ba1891ad689a7ef0c10d327111cc07f99ed20b | /TtHideTools/FastStringArray.h | ae4e38835afaa3c03f6fbe5da34cf449eb6c6045 | [] | 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 | UTF-8 | C++ | false | false | 669 | h | #pragma once
class CFastStringArray
{
private:
int m_limit_count;
int m_count;
DWORD m_limit_size;
DWORD m_size;
DWORD m_step_size;
DWORD* m_index_list;
TCHAR* m_buffer;
private:
void GrowIndex(void);
void GrowBuffer(void);
public:
CFastStringArray(int init_count=100, DWORD init_size=0x10000, DWORD step_size=0x10000);
virtual ~CFastStringArray(void);
int Add(LPCTSTR str);
int AddList(LPTSTR str, LPCTSTR fs=_T(","));
int AddListFromFile(LPCTSTR fname);
LPCTSTR GetAt(int index);
LPCTSTR operator[](int index);
void RemoveAll(void) { m_count=0; m_size=0; }
int GetCount(void) { return m_count; }
};
| [
"[email protected]"
] | [
[
[
1,
29
]
]
] |
7ae6d7234021bec94345fe466d771627772e0470 | 2f72d621e6ec03b9ea243a96e8dd947a952da087 | /lol4/gui/InventoryWindow.cpp | 13a65ea99620e3615a1f9cda9e8524113b2a8d16 | [] | no_license | gspu/lol4fg | 752358c3c3431026ed025e8cb8777e4807eed7a0 | 12a08f3ef1126ce679ea05293fe35525065ab253 | refs/heads/master | 2023-04-30T05:32:03.826238 | 2011-07-23T23:35:14 | 2011-07-23T23:35:14 | 364,193,504 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,708 | cpp | #include "InventoryWindow.h"
#include <CEGUI.h>
#include <TypeConverter.h>
#include <GameApp.h>
#include <HoldingSlotWindow.h>
#include "Alchemy.h"
InventoryWindow::InventoryWindow()
{
mInv = NULL;
loadLayout("InventoryWindow.layout");
CEGUI::Window *wnd = getWindow("InventoryWindow/content");
slotView = new InventorySlotView(wnd,this);
eqView = new EquipmentView(getWindow("InventoryWindow/equipment"),this);
//add meself to root
slotView->setIgnoreEvents(true);
addToRoot();
slotView->setIgnoreEvents(false);
oldWndArea = CEGUI::URect(CEGUI::UDim(0,0),CEGUI::UDim(0,0),CEGUI::UDim(0,0),CEGUI::UDim(0,0));
oldWndAreaRect = CEGUI::Rect(0,0,0,0);
mWnd->subscribeEvent(CEGUI::FrameWindow::EventCloseClicked, CEGUI::Event::Subscriber(&InventoryWindow::eventCloseClicked, this));
mWnd->subscribeEvent(CEGUI::Window::EventMouseButtonUp, CEGUI::Event::Subscriber(&InventoryWindow::eventMouseUp, this));
mWnd->subscribeEvent(CEGUI::Window::EventShown, CEGUI::Event::Subscriber(&InventoryWindow::eventShown, this));
//TEST
slotView->updateView();
slotView->updateParentWindow();
}
InventoryWindow::~InventoryWindow()
{
delete slotView;
delete eqView;
destroyLayout();
//~GameWindow should be called after this and clean up
}
void InventoryWindow::inventoryChanged()
{
eqView->updateInventoryDisplay();
}
void InventoryWindow::show()
{
slotView->setIgnoreEvents(true);
GameWindow::show();
eqView->update();
slotView->setIgnoreEvents(false);
}
bool InventoryWindow::eventCloseClicked(const CEGUI::EventArgs& e)
{
GameApp::getSingletonPtr()->showInventory(false);
return true;
}
void InventoryWindow::showInventoryView()
{
mWnd->setProperty("SizingEnabled","True");
slotView->show();
resizeWindow(0,-inventoryDelta,true);
slotView->updateParentWindow();
}
void InventoryWindow::hideInventoryView()
{
mWnd->setProperty("SizingEnabled","False");
//inventoryWndArea = mWnd->getArea();
slotView->hide();
//now resize it
//CEGUI::URect newArea = eqView->getMainWindow()->getArea();
CEGUI::Rect innerEqArea = eqView->getMainWindow()->getUnclippedOuterRect();
CEGUI::Rect innerRect = mWnd->getUnclippedInnerRect();
CEGUI::Rect outerRect = mWnd->getUnclippedOuterRect();
float innerHeight = innerRect.d_bottom-innerRect.d_top;
//float outerHeight = outerRect.d_bottom-outerRect.d_top;
float eqHeight = innerEqArea.d_bottom-innerEqArea.d_top;
inventoryDelta = innerHeight - eqHeight;
resizeWindow(0,inventoryDelta,true);
/*CEGUI::UDim height = inventoryWndArea.getHeight();
inventoryWndArea.setHeight();*/
mWnd->setProperty("SizingEnabled","False");
}
| [
"praecipitator@bd7a9385-7eed-4fd6-88b1-0096df50a1ac"
] | [
[
[
1,
99
]
]
] |
998365c09b0e8c1acf910027f2a985fc2dc18410 | b4d726a0321649f907923cc57323942a1e45915b | /CODE/SHIP/afterburner.cpp | 0ce63685190e368a2fd96406eb1124815e4d46a7 | [] | no_license | chief1983/Imperial-Alliance | f1aa664d91f32c9e244867aaac43fffdf42199dc | 6db0102a8897deac845a8bd2a7aa2e1b25086448 | refs/heads/master | 2016-09-06T02:40:39.069630 | 2010-10-06T22:06:24 | 2010-10-06T22:06:24 | 967,775 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,451 | cpp | /*
* Copyright (C) Volition, Inc. 1999. All rights reserved.
*
* All source code herein is the property of Volition, Inc. You may not sell
* or otherwise commercially exploit the source or things you created based on the
* source.
*
*/
/*
* $Logfile: /Freespace2/code/Ship/Afterburner.cpp $
* $Revision: 1.1.1.1 $
* $Date: 2004/08/13 22:47:43 $
* $Author: Spearhawk $
*
* C file for managing the afterburners
*
* $Log: afterburner.cpp,v $
* Revision 1.1.1.1 2004/08/13 22:47:43 Spearhawk
* no message
*
* Revision 1.1.1.1 2004/08/13 21:12:10 Darkhill
* no message
*
* Revision 2.8 2004/03/05 09:01:51 Goober5000
* Uber pass at reducing #includes
* --Goober5000
*
* Revision 2.7 2004/01/31 03:56:46 phreak
* changed "now" to unsigned int
*
* Revision 2.6 2003/11/23 00:59:01 Goober5000
* fixed a bug introduced by Penguin for running with NO_NETWORK defined
* --Goober5000
*
* Revision 2.5 2003/09/13 06:02:03 Goober5000
* clean rollback of all of argv's stuff
* --Goober5000
*
* Revision 2.3 2003/08/21 06:11:32 Goober5000
* removed an extraneous thingy
* --Goober5000
*
* Revision 2.2 2003/08/06 17:37:08 phreak
* preliminary work on tertiary weapons. it doesn't really function yet, but i want to get something committed
*
* Revision 2.1 2002/08/01 01:41:09 penguin
* The big include file move
*
* Revision 2.0 2002/06/03 04:02:28 penguin
* Warpcore CVS sync
*
* Revision 1.2 2002/05/13 21:09:28 mharris
* I think the last of the networking code has ifndef NO_NETWORK...
*
* Revision 1.1 2002/05/02 18:03:12 mharris
* Initial checkin - converted filenames and includes to lower case
*
*
* 7 9/05/99 11:24p Jimb
* changed recharge rate for afterburners based on skill setting.
*
* 6 8/24/99 1:50a Dave
* Fixed client-side afterburner stuttering. Added checkbox for no version
* checking on PXO join. Made button info passing more friendly between
* client and server.
*
* 5 7/08/99 10:53a Dave
* New multiplayer interpolation scheme. Not 100% done yet, but still
* better than the old way.
*
* 4 11/05/98 5:55p Dave
* Big pass at reducing #includes
*
* 3 10/13/98 9:29a Dave
* Started neatening up freespace.h. Many variables renamed and
* reorganized. Added AlphaColors.[h,cpp]
*
* 2 10/07/98 10:53a Dave
* Initial checkin.
*
* 1 10/07/98 10:51a Dave
*
* 25 5/23/98 2:41p Mike
* Make Easy the default skill level and prevent old pilot's skill level
* from carrying into new pilot.
*
* 24 5/07/98 11:01a Lawrance
* Play afterburner fail sound once energy runs out (and key is still
* down)
*
* 23 5/04/98 11:08p Hoffoss
* Expanded on Force Feedback code, and moved it all into Joy_ff.cpp.
* Updated references everywhere to it.
*
* 22 4/18/98 9:12p Lawrance
* Added Aureal support.
*
* 21 4/13/98 2:11p Lawrance
* Change afterburners so they can't be activated any faster than once
* every 1.2 seconds
*
* 20 4/07/98 1:53p Lawrance
* Make energy system matter more.
*
* 19 3/31/98 5:18p John
* Removed demo/save/restore. Made NDEBUG defined compile. Removed a
* bunch of debug stuff out of player file. Made model code be able to
* unload models and malloc out only however many models are needed.
*
*
* 18 2/26/98 10:07p Hoffoss
* Rewrote state saving and restoring to fix bugs and simplify the code.
*
* 17 2/20/98 8:32p Lawrance
* Add radius parm to sound_play_3d()
*
* 16 12/28/97 5:52p Lawrance
* fix volume discontinuity bug when afterburners ran out
*
* 15 12/22/97 9:14p Allender
* fix up some code relating to afterburners in multiplayer. Clients now
* control their own afterburners
*
* 14 11/06/97 5:02p Dave
* Finished reworking standalone multiplayer sequencing. Added
* configurable observer-mode HUD
*
* 13 10/17/97 9:49a Lawrance
* remove debug output
*
* 12 10/16/97 5:37p Lawrance
* fix sound bug where AI afterburner was affecting player afterburner
* sounds
*
* 11 10/01/97 5:55p Lawrance
* change call to snd_play_3d() to allow for arbitrary listening position
*
* 10 9/16/97 2:27p Allender
* Removed unused Assert that will cause problems in the future
*
* 9 8/11/97 9:50a Allender
* fixed afterburner snafu
*
* 8 8/08/97 9:59a Allender
* added afterburner code into multiplayer. Required adding a new physics
* info flag to indicate afterburners ready to fire. (needed for
* multiplayer). Removed some now unused variables in afterburner.cpp
*
* 7 8/05/97 10:48a Lawrance
* save afterburner data for the player
*
* 6 7/27/97 5:14p Lawrance
* add afterburners to the player control info
*
* 5 7/25/97 5:02p Lawrance
* fix bug with afterburner sound
*
* 4 7/23/97 4:30p Lawrance
* improve how disengage of afterburner works
*
* 3 7/16/97 4:42p Mike
* Make afterburner shake viewer, not ship.
* Shake for limited time.
* Add timestamp_until() function to timer library.
*
* 2 7/11/97 8:57a Lawrance
* make afterburner work same for player and AI ships
*
* 1 7/10/97 2:24p Lawrance
*
* $NoKeywords: $
*/
#include "ship/afterburner.h"
#include "io/joy_ff.h"
#include "gamesnd/gamesnd.h"
#include "ship/ship.h"
#include "object/object.h"
#include "io/timer.h"
#include "render/3d.h" // needed for View_position, which is used when playing a 3D sound
#include "hud/hudets.h"
#include "freespace2/freespace.h"
#include "network/multi.h"
#include "hud/hudmessage.h"
#include "weapon/weapon.h"
// The minimum required fuel to engage afterburners
#define MIN_AFTERBURNER_FUEL_TO_ENGAGE 10
float Skill_level_afterburner_recharge_scale[NUM_SKILL_LEVELS] = {5.0f, 3.0f, 2.0f, 1.5f, 1.0f};
// ----------------------------------------------------------------------------
// afterburners_start() will be called when a ship engages the afterburners.
// This function should only be called once when afterburners first start. This is
// to start an appropriate sound effect and do any one-time initializations.
//
// parameters: *objp ==> pointer to the object starting afterburners
//
void afterburners_start(object *objp)
{
ship_info *sip;
ship *shipp;
Assert( objp != NULL );
shipp = &Ships[objp->instance];
Assert( shipp->ship_info_index >= 0 && shipp->ship_info_index < MAX_SHIP_TYPES );
sip = &Ship_info[shipp->ship_info_index];
if(objp->type == OBJ_OBSERVER)
return;
Assert( objp->type == OBJ_SHIP);
Assert( objp->instance >= 0 && objp->instance < MAX_SHIPS );
if (!(shipp->flags2 & SF2_POD_INSTALLED) && !(shipp->pod_weapon == TWT_SLAM)) {
return;
}
// Check if there is enough afterburner fuel
#ifndef NO_NETWORK
if ( (shipp->afterburner_fuel < MIN_AFTERBURNER_FUEL_TO_ENGAGE) && !MULTIPLAYER_CLIENT ) {
#else
if ( (shipp->afterburner_fuel < MIN_AFTERBURNER_FUEL_TO_ENGAGE) ) {
#endif
if ( objp == Player_obj ) {
snd_play( &Snds[SND_ABURN_FAIL] );
}
return;
}
objp->phys_info.flags |= PF_AFTERBURNER_ON;
snd_play(&Snds[shipp->pod_sound_engage], 0.0f, 1.0f, SND_PRIORITY_MUST_PLAY);
}
// ----------------------------------------------------------------------------
// afterburners_update()
//
// Update the state of the afterburner fuel remaining for an object using the
// afterburner.
//
// for the player ship, key_up_time() is called for the afterburner key to
// detect when afterburners disengage.
//
// input: *objp => pointer to the object starting afterburners
// fl_frametime => time in seconds of the last frame
//
void afterburners_update(object *objp, float fl_frametime)
{
Assert( objp != NULL );
Assert( objp->type == OBJ_SHIP );
Assert( objp->instance >= 0 && objp->instance < MAX_SHIPS );
ship_info *sip;
ship *shipp;
static int volume_chg_timer = 1;
shipp = &Ships[objp->instance];
Assert( shipp->ship_info_index >= 0 && shipp->ship_info_index < MAX_SHIP_TYPES );
sip = &Ship_info[shipp->ship_info_index];
if ( (objp->flags & OF_PLAYER_SHIP ) && (Game_mode & GM_DEAD) ) {
return;
}
if (!(shipp->flags2 & SF2_POD_INSTALLED) && !(shipp->pod_weapon == TWT_SLAM)) {
return;
}
// single player, multiplayer servers, and clients for their own ships
#ifndef NO_NETWORK
if(!(Game_mode & GM_MULTIPLAYER) || MULTIPLAYER_MASTER || (objp == Player_obj)){
#else
// changed from != to == by Goober5000... this seems to be a bug
if (objp == Player_obj) {
#endif
if ( !(objp->phys_info.flags & PF_AFTERBURNER_ON)) {
// Recover afterburner fuel
// float recover_rate=sip->afterburner_recover_rate;
if ( shipp->afterburner_fuel < shipp->afterburner_fuel_capacity ) {
float recharge_scale;
recharge_scale = Energy_levels[shipp->engine_recharge_index] * 2.0f * Skill_level_afterburner_recharge_scale[Game_skill_level];
shipp->afterburner_fuel += (shipp->afterburner_recover_rate * fl_frametime * recharge_scale);
if ( shipp->afterburner_fuel > shipp->afterburner_fuel_capacity){
shipp->afterburner_fuel = shipp->afterburner_fuel_capacity;
}
}
return;
}
else {
// Check if there is enough afterburner fuel
if ( shipp->afterburner_fuel <= 0 ) {
shipp->afterburner_fuel = 0.0f;
afterburners_stop(objp, 1);
return;
}
}
// afterburns are firing at this point
// Reduce the afterburner fuel
shipp->afterburner_fuel -= (shipp->afterburner_burn_rate * fl_frametime);
if ( shipp->afterburner_fuel < 0.0f ) {
shipp->afterburner_fuel = 0.0f;
}
}
float top_speed;
float desired_speed;
top_speed = objp->phys_info.max_vel.xyz.z * 2.0f;
float percent_throttle;
if ( Ships[objp->instance].current_max_speed == 0 ) {
percent_throttle = objp->phys_info.fspeed / sip->max_speed;
} else {
percent_throttle = objp->phys_info.fspeed / shipp->current_max_speed;
}
desired_speed = top_speed * percent_throttle;
if (desired_speed > top_speed)
desired_speed = top_speed;
objp->phys_info.afterburner_max_vel.xyz.z = desired_speed; //objp->phys_info.fspeed * 2;
}
// ----------------------------------------------------------------------------
// afterburners_stop() will be called when a ship disengages the afterburners.
//
// parameters: *objp => pointer to the object starting afterburners
// key_released => OPTIONAL parameter (default value 0)
// This is only used for the player object, to
// manage starting/stopping
//
void afterburners_stop(object *objp, int key_released)
{
Assert( objp != NULL );
Assert( objp->instance >= 0 && objp->instance < MAX_SHIPS );
ship_info *sip;
ship *shipp;
shipp = &Ships[objp->instance];
Assert( shipp->ship_info_index >= 0 && shipp->ship_info_index < MAX_SHIP_TYPES );
sip = &Ship_info[shipp->ship_info_index];
if ( !(objp->phys_info.flags & PF_AFTERBURNER_ON) ) {
return;
}
objp->phys_info.flags &= ~PF_AFTERBURNER_ON;
snd_play(&Snds[shipp->pod_sound_loop], 0.0f, 1.0f, SND_PRIORITY_MUST_PLAY);
// if slam ran out of power make sure its turned off
if (objp == Player_obj)
ship_fire_tertiary(objp);
}
| [
"[email protected]"
] | [
[
[
1,
376
]
]
] |
e6ee8974591b97e6a293485af6ddcce415295612 | 29792c63c345f87474136c8df87beb771f0a20a8 | /vcmp/bbfont.cpp | c6e40f3dc87df5513be0761e10f9e4847a78c002 | [] | no_license | uvbs/jvcmp | 244ba6c2ab14ce0a757f3f6044b5982287b01fae | 57225e1c52085216a0a4a9c4e33ed324c1c92d39 | refs/heads/master | 2020-12-29T00:25:39.180996 | 2009-06-24T14:52:39 | 2009-06-24T14:52:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,894 | cpp | // PUBLIC DOMAIN
/*
Based off code by DrunkenHyena - Many thanks :)
*/
#include "bbfont.h"
#include <stdio.h>
extern D3DMATRIX matView;
int i = 0;
CBBFont::CBBFont(IDirect3DDevice8* pDevice, char* pFileName)
{
m_pDevice = pDevice;
m_pTexture = NULL;
m_pVB = NULL;
m_dwSavedStates = 0;
m_dwFontStates = 0;
m_fCharWidth = 0.0f;
m_fCharHeight = 0.0f;
m_fScale = 0.01f;
m_pTextureFileName = (char*)malloc(strlen(pFileName) + 5);
sprintf(m_pTextureFileName, "%s.png", pFileName);
m_pMetricsFileName = (char*)malloc(strlen(pFileName) + 5);
sprintf(m_pMetricsFileName, "%s.dat", pFileName);
memset((void*)&m_Metrics, 0, sizeof(m_Metrics));
}
CBBFont::~CBBFont()
{
m_pDevice->DeleteStateBlock(m_dwSavedStates);
m_pDevice->DeleteStateBlock(m_dwFontStates);
free(m_pTextureFileName);
free(m_pMetricsFileName);
SAFE_RELEASE(m_pTexture);
SAFE_RELEASE(m_pVB);
}
BOOL CBBFont::Initialise()
{
if (!m_pDevice)
return FALSE;
D3DXCreateTextureFromFileEx(m_pDevice, m_pTextureFileName, D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &m_pTexture);
m_pDevice->CreateVertexBuffer(((cMaxChars*6)+1)*sizeof(sVertex), D3DUSAGE_WRITEONLY|D3DUSAGE_DYNAMIC, cVertexFVF, D3DPOOL_DEFAULT, &m_pVB);
D3DSURFACE_DESC desc;
m_pTexture->GetLevelDesc(0, &desc);
m_fCharWidth = desc.Width / 16.0f;
m_fCharHeight = desc.Height / 16.0f;
FILE* f = fopen(m_pMetricsFileName, "rb");
if (f)
{
fread(&m_Metrics, 256, 1, f);
fclose(f);
} else {
memset(&m_Metrics, (int)m_fCharWidth, sizeof(m_Metrics));
}
return TRUE;
}
float CBBFont::Draw(char* pText, float fYOffset, DWORD dwColor)
{
m_pDevice->SetRenderState(D3DRS_TEXTUREFACTOR, dwColor);
int len = (int)strlen(pText);
if (len > cMaxChars)
len = cMaxChars;
sVertex *vert_ptr;
m_pVB->Lock(0, 0, (BYTE**)&vert_ptr, D3DLOCK_DISCARD);
float fX = 0.0f;
for (i=0; i<len; i++)
{
fX += (float)m_Metrics[pText[i]] * m_fScale;
}
fX = -(fX / 2);
for (i=0; i<len; i++)
{
InitQuad(pText[i], fX, fYOffset, vert_ptr);
fX += (float)m_Metrics[pText[i]] * m_fScale;
vert_ptr += 6;
}
m_pVB->Unlock();
m_pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, len*2);
return fX;
}
void CBBFont::Begin()
{
if(!m_dwSavedStates || !m_dwFontStates)
{
m_pDevice->BeginStateBlock();
m_pDevice->SetRenderState(D3DRS_TEXTUREFACTOR, 0xFFFFFFFF);
m_pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
m_pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
m_pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_CURRENT);
m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
m_pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
m_pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
m_pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO);
m_pDevice->SetTexture(0, NULL);
m_pDevice->SetStreamSource(0, NULL, 0);
m_pDevice->SetVertexShader(cVertexFVF);
m_pDevice->EndStateBlock(&m_dwSavedStates);
m_pDevice->BeginStateBlock();
m_pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
m_pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
m_pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TFACTOR);
m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TFACTOR);
m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
m_pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
m_pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
m_pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
m_pDevice->SetTexture(0, m_pTexture);
m_pDevice->SetStreamSource(0, m_pVB, sizeof(sVertex));
m_pDevice->SetVertexShader(cVertexFVF);
m_pDevice->EndStateBlock(&m_dwFontStates);
}
m_pDevice->CaptureStateBlock(m_dwSavedStates);
m_pDevice->ApplyStateBlock(m_dwFontStates);
}
void CBBFont::End()
{
m_pDevice->ApplyStateBlock(m_dwSavedStates);
}
void CBBFont::InitQuad(char c, float x, float y2, sVertex* pVB)
{
float x2 = x + ((float)m_Metrics[c] * m_fScale);
float y = y2 + (m_fCharHeight * m_fScale);
float tu = (c % 16) / 16.0f;
float tu2 = tu + ((1 / 16.0f) * (m_Metrics[c] / m_fCharWidth));
float tv = (c - (c % 16)) / 256.0f;
float tv2 = tv + 1 / 16.0f;
// x y tu tv
pVB[0].Initialise(x, y2, tu, tv2);
pVB[1].Initialise(x, y, tu, tv);
pVB[2].Initialise(x2, y, tu2, tv);
pVB[3] = pVB[0];
pVB[4] = pVB[2];
pVB[5].Initialise(x2, y2, tu2, tv2);
} | [
"jacks.mini.net@43d76e2e-6035-11de-a55d-e76e375ae706"
] | [
[
[
1,
159
]
]
] |
1911f4bc66388aeddf0a314f4fde68409b9616c4 | f8b364974573f652d7916c3a830e1d8773751277 | /emulator/allegrex/disassembler/BGTZ.h | 670016792b8a0b243024c5e3d27574abd3ee2671 | [] | no_license | lemmore22/pspe4all | 7a234aece25340c99f49eac280780e08e4f8ef49 | 77ad0acf0fcb7eda137fdfcb1e93a36428badfd0 | refs/heads/master | 2021-01-10T08:39:45.222505 | 2009-08-02T11:58:07 | 2009-08-02T11:58:07 | 55,047,469 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 369 | h | /* BGTZ */
void AllegrexInstructionTemplate< 0x1c000000, 0xfc1f0000 >::disassemble(u32 address, u32 opcode, char *opcode_name, char *operands, char *comment)
{
using namespace Allegrex;
s32 imm = simm16(opcode);
::strcpy(opcode_name, "bgtz");
::sprintf(operands, "%s, 0x%08X", gpr_name[rs(opcode)], imm * 4 + address + 4);
::strcpy(comment, "");
}
| [
"[email protected]"
] | [
[
[
1,
10
]
]
] |
ff70a2f1109a5ff888f58064739bce683f6faca9 | 061348a6be0e0e602d4a5b3e0af28e9eee2d257f | /Examples/Tutorial/UserInterface/29Spinner.cpp | a60db51dc1536b63f0e8476d9d8eb41fdb8a3881 | [] | no_license | passthefist/OpenSGToolbox | 4a76b8e6b87245685619bdc3a0fa737e61a57291 | d836853d6e0647628a7dd7bb7a729726750c6d28 | refs/heads/master | 2023-06-09T22:44:20.711657 | 2010-07-26T00:43:13 | 2010-07-26T00:43:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,885 | cpp | // OpenSG Tutorial Example: Creating a Button Component
//
// This tutorial explains how to edit the basic features of
// a Button and a ToggleButtoncreated in the OSG User
// Interface library.
//
// Includes: Button PreferredSize, MaximumSize, MinimumSize, Font,
// Text,and adding a Button to a Scene. Also note that clicking
// the Button causes it to appear pressed
// General OpenSG configuration, needed everywhere
#include "OSGConfig.h"
// Methods to create simple geometry: boxes, spheres, tori etc.
#include "OSGSimpleGeometry.h"
// A little helper to simplify scene management and interaction
#include "OSGSimpleSceneManager.h"
#include "OSGNode.h"
#include "OSGGroup.h"
#include "OSGViewport.h"
// The general scene file loading handler
#include "OSGSceneFileHandler.h"
// Input
#include "OSGWindowUtils.h"
// UserInterface Headers
#include "OSGUIForeground.h"
#include "OSGInternalWindow.h"
#include "OSGUIDrawingSurface.h"
#include "OSGGraphics2D.h"
#include "OSGLookAndFeelManager.h"
// Activate the OpenSG namespace
OSG_USING_NAMESPACE
// The SimpleSceneManager to manage simple applications
SimpleSceneManager *mgr;
WindowEventProducerRefPtr TutorialWindow;
// Forward declaration so we can have the interesting stuff upfront
void display(void);
void reshape(Vec2f Size);
// 29Spinner Headers
#include "OSGFlowLayout.h"
#include "OSGLayers.h"
#include "OSGRadioButton.h"
#include "OSGRadioButtonGroup.h"
#include "OSGSpinner.h"
#include "OSGNumberSpinnerModel.h"
Int32SpinnerModelPtr TheModel(new Int32SpinnerModel());
class SingleIncrementButtonListener : public ButtonSelectedListener
{
public:
virtual void buttonSelected(const ButtonSelectedEventUnrecPtr e)
{
TheModel->setStepSize(1);
}
virtual void buttonDeselected(const ButtonSelectedEventUnrecPtr e)
{
TheModel->setStepSize(2);
}
};
class DoubleIncrementButtonListener : public ButtonSelectedListener
{
public:
virtual void buttonSelected(const ButtonSelectedEventUnrecPtr e)
{
TheModel->setStepSize(2);
}
virtual void buttonDeselected(const ButtonSelectedEventUnrecPtr e)
{
TheModel->setStepSize(1);
}
};
// Create a class to allow for the use of the Ctrl+q
class TutorialKeyListener : public KeyListener
{
public:
virtual void keyPressed(const KeyEventUnrecPtr e)
{
if(e->getKey() == KeyEvent::KEY_Q && e->getModifiers() & KeyEvent::KEY_MODIFIER_COMMAND)
{
TutorialWindow->closeWindow();
}
}
virtual void keyReleased(const KeyEventUnrecPtr e)
{
}
virtual void keyTyped(const KeyEventUnrecPtr e)
{
}
};
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
//Temp->setValue(0);
// Set up Window
TutorialWindow = createNativeWindow();
TutorialWindow->initWindow();
TutorialWindow->setDisplayCallback(display);
TutorialWindow->setReshapeCallback(reshape);
TutorialKeyListener TheKeyListener;
TutorialWindow->addKeyListener(&TheKeyListener);
// Make Torus Node (creates Torus in background of scene)
NodeRefPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);
// Make Main Scene Node and add the Torus
NodeRefPtr scene = OSG::Node::create();
scene->setCore(OSG::Group::create());
scene->addChild(TorusGeometryNode);
// Create the Graphics
GraphicsRefPtr TutorialGraphics = OSG::Graphics2D::create();
// Initialize the LookAndFeelManager to enable default settings
LookAndFeelManager::the()->getLookAndFeel()->init();
/******************************************************
Create a Spinner Model. This dictates
how the Spinner functions.
-setMaximum(int): Determine the Maximum
value the Spinner can have.
-setMinimum(int): Determine the Minimum
value the Spinner can have.
-setStepSize(int): Determine the
incremental step size.
-setValue(SharedFieldRefPtr(new SFInt32(int)):
Determine initial starting value
of the Spinner.
Note: the StepSize can be changed
dynamically as done in this
Tutorial with ButtonSelectedListeners.
******************************************************/
//Int32SpinnerModelPtr TheModel(new Int32SpinnerModel());
TheModel->setMaximum(100);
TheModel->setMinimum(-100);
TheModel->setStepSize(2);
TheModel->setValue(boost::any(Int32(0)));
/******************************************************
Create a Spinner and and assign it a
Model.
******************************************************/
SpinnerRefPtr ExampleSpinner = Spinner::create();
ExampleSpinner->setModel(TheModel);
/******************************************************
Create a RadioButtonPanel to allow
for certain characteristics of the
Spinner to be changed dynamically.
See 14RadioButton for more
information about RadioButtons.
******************************************************/
RadioButtonRefPtr SingleIncrementButton = RadioButton::create();
RadioButtonRefPtr DoubleIncrementButton = RadioButton::create();
SingleIncrementButton->setText("Increment by 1");
SingleIncrementButton->setPreferredSize(Vec2f(100, 50));
SingleIncrementButtonListener TheSingleIncrementButtonListener;
SingleIncrementButton->addButtonSelectedListener(&TheSingleIncrementButtonListener);
DoubleIncrementButton->setText("Increment by 2");
DoubleIncrementButton->setPreferredSize(Vec2f(100, 50));
DoubleIncrementButton->setSelected(true);
DoubleIncrementButtonListener TheDoubleIncrementButtonListener;
DoubleIncrementButton->addButtonSelectedListener(&TheDoubleIncrementButtonListener);
RadioButtonGroupRefPtr SelectionRadioButtonGroup = RadioButtonGroup::create();
SelectionRadioButtonGroup->addButton(SingleIncrementButton);
SelectionRadioButtonGroup->addButton(DoubleIncrementButton);
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(SingleIncrementButton);
MainInternalWindow->pushToChildren(DoubleIncrementButton);
MainInternalWindow->pushToChildren(ExampleSpinner);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
mgr->setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRefPtr TutorialViewport = mgr->getWindow()->getPort(0);
TutorialViewport->addForeground(TutorialUIForeground);
// Show the whole Scene
mgr->showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"29Spinner");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
// Callback functions
// Redraw the window
void display(void)
{
mgr->redraw();
}
// React to size changes
void reshape(Vec2f Size)
{
mgr->resize(Size.x(), Size.y());
}
| [
"[email protected]",
"[email protected]"
] | [
[
[
1,
23
],
[
25,
26
],
[
28,
29
],
[
31,
43
],
[
45,
47
],
[
50,
55
],
[
65,
65
],
[
71,
71
],
[
80,
80
],
[
85,
85
],
[
92,
113
],
[
115,
131
],
[
133,
134
],
[
136,
138
],
[
141,
141
],
[
156,
156
],
[
168,
168
],
[
170,
171
],
[
179,
179
],
[
192,
193
],
[
195,
195
],
[
200,
201
],
[
205,
207
],
[
209,
225
],
[
228,
228
],
[
230,
233
],
[
235,
236
],
[
238,
238
],
[
240,
241
],
[
243,
243
],
[
245,
245
],
[
247,
248
],
[
251,
267
],
[
269,
270
],
[
272,
276
],
[
278,
281
]
],
[
[
24,
24
],
[
27,
27
],
[
30,
30
],
[
44,
44
],
[
48,
49
],
[
56,
64
],
[
66,
70
],
[
72,
79
],
[
81,
84
],
[
86,
91
],
[
114,
114
],
[
132,
132
],
[
135,
135
],
[
139,
140
],
[
142,
155
],
[
157,
167
],
[
169,
169
],
[
172,
178
],
[
180,
191
],
[
194,
194
],
[
196,
199
],
[
202,
204
],
[
208,
208
],
[
226,
227
],
[
229,
229
],
[
234,
234
],
[
237,
237
],
[
239,
239
],
[
242,
242
],
[
244,
244
],
[
246,
246
],
[
249,
250
],
[
268,
268
],
[
271,
271
],
[
277,
277
]
]
] |
3d74b2e8bad5903629c2e02d2df9db811d44fbf5 | 33cdd09e352529963fe8b28b04e0d2e33483777b | /trunk/metabase_load_pok1/WordView.cpp | 31d8dfa67d09bd0abc7bab0c136a9387157e3ad0 | [] | no_license | BackupTheBerlios/reportasistent-svn | 20e386c86b6990abafb679eeb9205f2aef1af1ac | 209650c8cbb0c72a6e8489b0346327374356b57c | refs/heads/master | 2020-06-04T16:28:21.972009 | 2010-05-18T12:06:48 | 2010-05-18T12:06:48 | 40,804,982 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,328 | cpp | // WordView.cpp : implementation file
//
#include "stdafx.h"
#include "metabase_load_pok1.h"
#include "WordView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CWordView
CWordView::CWordView()
{
m_pDoc = new COleDocument();
m_pItem = new CMyOleClientItem(this, m_pDoc);
m_ptStartDrag.x = 0;
m_ptStartDrag.y = 0;
m_ptMove.x = 0;
m_ptMove.y = 0;
CLSID cid;
CLSIDFromProgID(L"Word.Document", & cid);
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//asi by se melo osetrit
//nebo nekam dat try blok
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
m_pItem->CreateNewItem(cid);
m_pItem->Activate(OLEIVERB_UIACTIVATE, NULL);
}
CWordView::~CWordView()
{
delete m_pItem;
delete m_pDoc;
}
BEGIN_MESSAGE_MAP(CWordView, CButton)
//{{AFX_MSG_MAP(CWordView)
ON_WM_PAINT()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CWordView message handlers
void CWordView::OnPaint()
{
CPaintDC dc(this); // device context for painting
RECT r;
GetClientRect(& r);
CBrush b(0xEFEFEF);
dc.FillRect(& r, & b);
CSize size;
CRect rect = r;
if (SUCCEEDED(m_pItem->GetExtent(&size, m_pItem->m_nDrawAspect)))
{
dc.HIMETRICtoLP(&size);
rect.right = size.cx + rect.left;
rect.bottom = size.cy + rect.top;
}
// rect.IntersectRect(rect,& r);
dc.IntersectClipRect(& r);
rect += m_ptMove;
m_pItem->Draw(& dc, & rect);
// Do not call CStatic::OnPaint() for painting messages
}
void CMyOleClientItem::OnChange(OLE_NOTIFICATION nCode, DWORD dwParam)
{
if (m_wdpParent->m_hWnd != 0) m_wdpParent->Invalidate();
COleClientItem::OnChange(nCode, dwParam);
}
LPOLEOBJECT CWordView::GetWordObject(void)
{
return m_pItem->m_lpObject;
}
void CWordView::OnLButtonDown(UINT nFlags, CPoint point)
{
m_ptStartDrag = point - m_ptMove;
SetCapture();
// SetCursor(LoadCursor(NULL, IDC_HAND));
// CButton::OnLButtonDown(nFlags, point);
}
void CWordView::OnLButtonUp(UINT nFlags, CPoint point)
{
m_ptStartDrag.x = 0;
m_ptStartDrag.y = 0;
ReleaseCapture();
// SetCursor(LoadCursor(NULL, IDC_ARROW));
// CButton::OnLButtonUp(nFlags, point);
}
void CWordView::OnMouseMove(UINT nFlags, CPoint point)
{
if ((m_ptStartDrag.x == 0) && (m_ptStartDrag.y == 0)) return;
CSize size;
CRect rect;
m_pItem->GetExtent(&size, m_pItem->m_nDrawAspect);
CDC * dc = GetDC();
dc->HIMETRICtoLP(&size);
ReleaseDC(dc);
GetClientRect(rect);
if ((rect.Width() >= size.cx) && (rect.Height() >= size.cy))
{
m_ptMove.x = m_ptMove.y = 0;
return ;
}
m_ptMove.x = point.x - m_ptStartDrag.x;
m_ptMove.y = point.y - m_ptStartDrag.y;
if (m_ptMove.x > 0) m_ptMove.x = 0;
if (m_ptMove.y > 0) m_ptMove.y = 0;
if (size.cx + m_ptMove.x < rect.Width()) m_ptMove.x = rect.Width() - size.cx;
if (size.cy + m_ptMove.y < rect.Height()) m_ptMove.y = rect.Height() - size.cy;
Invalidate();
// CButton::OnMouseMove(nFlags, point);
}
| [
"dedej1am@fded5620-0c03-0410-a24c-85322fa64ba0"
] | [
[
[
1,
165
]
]
] |
2d47e11ee4940073c4b49d6b846142c63ac07f24 | c2abb873c8b352d0ec47757031e4a18b9190556e | /src/MyGUIEngine/src/MyGUI_Button.cpp | 3912d9638495708697b0901d896d4801b8ebf7e0 | [] | 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 | MacCyrillic | C++ | false | false | 2,909 | cpp | /*!
@file
@author Albert Semenov
@date 11/2007
@module
*/
#include "MyGUI_Button.h"
#include "MyGUI_WidgetSkinInfo.h"
#include "MyGUI_StaticImage.h"
#include "MyGUI_CastWidget.h"
#include "MyGUI_InputManager.h"
namespace MyGUI
{
Ogre::String Button::WidgetTypeName = "Button";
Button::Button(const IntCoord& _coord, Align _align, const WidgetSkinInfoPtr _info, CroppedRectanglePtr _parent, WidgetCreator * _creator, const Ogre::String & _name) :
Widget(_coord, _align, _info, _parent, _creator, _name),
mIsPressed(false),
mIsFocus(false),
mIsStatePressed(false),
mImage(null)
{
// парсим свойства
const MapString & param = _info->getParams();
if (!param.empty()) {
MapString::const_iterator iter = param.find("ButtonPressed");
if (iter != param.end()) setButtonPressed(iter->second == "true");
}
for (VectorWidgetPtr::iterator iter=mWidgetChild.begin(); iter!=mWidgetChild.end(); ++iter) {
if ((*iter)->_getInternalString() == "Image") {
mImage = castWidget<StaticImage>(*iter);
}
}
}
void Button::_onMouseSetFocus(WidgetPtr _old)
{
_setMouseFocus(true);
// !!! ќЅя«ј“≈Ћ№Ќќ вызывать в конце метода
Widget::_onMouseSetFocus(_old);
}
void Button::_onMouseLostFocus(WidgetPtr _new)
{
_setMouseFocus(false);
// !!! ќЅя«ј“≈Ћ№Ќќ вызывать в конце метода
Widget::_onMouseLostFocus(_new);
}
void Button::_onMouseButtonPressed(int _left, int _top, MouseButton _id)
{
if (_id == MB_Left) {
mIsPressed = true;
updateButtonState();
}
// !!! ќЅя«ј“≈Ћ№Ќќ вызывать в конце метода
Widget::_onMouseButtonPressed(_left, _top, _id);
}
void Button::_onMouseButtonReleased(int _left, int _top, MouseButton _id)
{
if (_id == MB_Left) {
mIsPressed = false;
updateButtonState();
}
// !!! ќЅя«ј“≈Ћ№Ќќ вызывать в конце метода
Widget::_onMouseButtonReleased(_left, _top, _id);
}
void Button::setImageIndex(size_t _index)
{
if (mImage) mImage->setImageNum(_index);
}
void Button::setEnabled(bool _enabled)
{
mEnabled = _enabled;
for (VectorWidgetPtr::iterator iter = mWidgetChild.begin(); iter != mWidgetChild.end(); ++iter) {
(*iter)->setEnabled(_enabled);
}
updateButtonState();
if ( ! mEnabled) InputManager::getInstance()._unlinkWidget(this);
}
void Button::updateButtonState()
{
if ( ! mEnabled) {
if (mIsStatePressed) setState("disable_pressed");
else setState("disable");
}
else {
if (mIsFocus) {
if (mIsPressed || mIsStatePressed) setState("select");
else setState("active");
} else {
if (mIsPressed || mIsStatePressed) setState("pressed");
else setState("normal");
}
}
}
} // namespace MyGUI
| [
"twk.theainur@37e2baaa-b253-11dd-9381-bf584fb1fa83"
] | [
[
[
1,
109
]
]
] |
5ff3635a2ef4c1c8070b95668690b557b531c613 | b22c254d7670522ec2caa61c998f8741b1da9388 | /dependencies/OpenSceneGraph/include/osg/ArgumentParser | 71c618a2c55966d8de40a905382b154979115614 | [] | no_license | ldaehler/lbanet | 341ddc4b62ef2df0a167caff46c2075fdfc85f5c | ecb54fc6fd691f1be3bae03681e355a225f92418 | refs/heads/master | 2021-01-23T13:17:19.963262 | 2011-03-22T21:49:52 | 2011-03-22T21:49:52 | 39,529,945 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 9,465 | /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* 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
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_ARGUMENTPARSER
#define OSG_ARGUMENTPARSER 1
#include <osg/Export>
#include <osg/ref_ptr>
#include <osg/ApplicationUsage>
#include <map>
#include <string>
#include <ostream>
namespace osg {
class OSG_EXPORT ArgumentParser
{
public:
class OSG_EXPORT Parameter
{
public:
enum ParameterType
{
BOOL_PARAMETER,
FLOAT_PARAMETER,
DOUBLE_PARAMETER,
INT_PARAMETER,
UNSIGNED_INT_PARAMETER,
STRING_PARAMETER
};
union ValueUnion
{
bool* _bool;
float* _float;
double* _double;
int* _int;
unsigned int* _uint;
std::string* _string;
};
Parameter(bool& value) { _type = BOOL_PARAMETER; _value._bool = &value; }
Parameter(float& value) { _type = FLOAT_PARAMETER; _value._float = &value; }
Parameter(double& value) { _type = DOUBLE_PARAMETER; _value._double = &value; }
Parameter(int& value) { _type = INT_PARAMETER; _value._int = &value; }
Parameter(unsigned int& value) { _type = UNSIGNED_INT_PARAMETER; _value._uint = &value; }
Parameter(std::string& value) { _type = STRING_PARAMETER; _value._string = &value; }
Parameter(const Parameter& param) { _type = param._type; _value = param._value; }
Parameter& operator = (const Parameter& param) { _type = param._type; _value = param._value; return *this; }
bool valid(const char* str) const;
bool assign(const char* str);
protected:
ParameterType _type;
ValueUnion _value;
};
/** Return true if the specified string is an option in the form
* -option or --option. */
static bool isOption(const char* str);
/** Return true if string is non-NULL and not an option in the form
* -option or --option. */
static bool isString(const char* str);
/** Return true if specified parameter is a number. */
static bool isNumber(const char* str);
/** Return true if specified parameter is a bool. */
static bool isBool(const char* str);
public:
ArgumentParser(int* argc,char **argv);
void setApplicationUsage(ApplicationUsage* usage) { _usage = usage; }
ApplicationUsage* getApplicationUsage() { return _usage.get(); }
const ApplicationUsage* getApplicationUsage() const { return _usage.get(); }
/** Return the argument count. */
int& argc() { return *_argc; }
/** Return the argument array. */
char** argv() { return _argv; }
/** Return the char* argument at the specified position. */
char* operator [] (int pos) { return _argv[pos]; }
/** Return the const char* argument at the specified position. */
const char* operator [] (int pos) const { return _argv[pos]; }
/** Return the application name, as specified by argv[0] */
std::string getApplicationName() const;
/** Return the position of an occurrence of a string in the argument list.
* Return -1 if no string is found. */
int find(const std::string& str) const;
/** Return true if the specified parameter is an option in the form of
* -option or --option. */
bool isOption(int pos) const;
/** Return true if the specified parameter is a string not in
* the form of an option. */
bool isString(int pos) const;
/** Return true if the specified parameter is a number. */
bool isNumber(int pos) const;
bool containsOptions() const;
/** Remove one or more arguments from the argv argument list,
* and decrement the argc respectively. */
void remove(int pos,int num=1);
/** Return true if the specified argument matches the given string. */
bool match(int pos, const std::string& str) const;
/** Search for an occurrence of a string in the argument list. If found,
* remove that occurrence and return true. Otherwise, return false. */
bool read(const std::string& str);
bool read(const std::string& str, Parameter value1);
bool read(const std::string& str, Parameter value1, Parameter value2);
bool read(const std::string& str, Parameter value1, Parameter value2, Parameter value3);
bool read(const std::string& str, Parameter value1, Parameter value2, Parameter value3, Parameter value4);
bool read(const std::string& str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5);
bool read(const std::string& str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5, Parameter value6);
bool read(const std::string& str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5, Parameter value6, Parameter value7);
bool read(const std::string& str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5, Parameter value6, Parameter value7, Parameter value8);
/** If the argument value at the specified position matches the given string,
* and subsequent parameters are also matched, then set the parameter values,
* remove the arguments from the list, and return true. Otherwise, return false. */
bool read(int pos, const std::string& str);
bool read(int pos, const std::string& str, Parameter value1);
bool read(int pos, const std::string& str, Parameter value1, Parameter value2);
bool read(int pos, const std::string& str, Parameter value1, Parameter value2, Parameter value3);
bool read(int pos, const std::string& str, Parameter value1, Parameter value2, Parameter value3, Parameter value4);
bool read(int pos, const std::string& str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5);
bool read(int pos, const std::string& str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5, Parameter value6);
bool read(int pos, const std::string& str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5, Parameter value6, Parameter value7);
bool read(int pos, const std::string& str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5, Parameter value6, Parameter value7, Parameter value8);
enum ErrorSeverity
{
BENIGN = 0,
CRITICAL = 1
};
typedef std::map<std::string,ErrorSeverity> ErrorMessageMap;
/** Return the error flag, true if an error has occurred when reading arguments. */
bool errors(ErrorSeverity severity=BENIGN) const;
/** Report an error message by adding to the ErrorMessageMap. */
void reportError(const std::string& message,ErrorSeverity severity=CRITICAL);
/** For each remaining option, report it as unrecognized. */
void reportRemainingOptionsAsUnrecognized(ErrorSeverity severity=BENIGN);
/** Return the error message, if any has occurred. */
ErrorMessageMap& getErrorMessageMap() { return _errorMessageMap; }
/** Return the error message, if any has occurred. */
const ErrorMessageMap& getErrorMessageMap() const { return _errorMessageMap; }
/** Write error messages to the given ostream, if at or above the given severity. */
void writeErrorMessages(std::ostream& output,ErrorSeverity sevrity=BENIGN);
/** This convinience method handles help requests on the command line.
* Return the type(s) of help requested. The return value of this
* function is suitable for passing into getApplicationUsage()->write().
* If ApplicationUsage::NO_HELP is returned then no help commandline option
* was found on the command line. */
ApplicationUsage::Type readHelpType();
protected:
int* _argc;
char** _argv;
ErrorMessageMap _errorMessageMap;
ref_ptr<ApplicationUsage> _usage;
};
}
#endif
| [
"vdelage@3806491c-8dad-11de-9a8c-6d5b7d1e4d13"
] | [
[
[
1,
213
]
]
] |
|
afee14d8fa71d9d26b5ef77ccdfe0abe4bf99b98 | 27d5670a7739a866c3ad97a71c0fc9334f6875f2 | /CPP/Targets/WayFinder/symbian-r6/WFS60Util.cpp | 440504eef6af653de08ceef896e83c69c9f426af | [
"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 | 3,047 | cpp | /*
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.
*/
#include <f32file.h>
#include "WFS60Util.h"
/* For WML browser id (KWmlcHandler) */
#include <documenthandler.h>
/* For TApaTask and TApaTaskList */
#include <apgtask.h>
/* For CEikonEnv */
#include <eikenv.h>
/* For RApaLsSession */
#include <apgcli.h>
#include "WFTextUtil.h"
const TUid KPhoneUidWmlBrowser = { KWmlcHandler };
void
WFS60Util::LaunchWapBrowserL(const TDesC& aAddr,
RApaLsSession& aApaLsSession)
{
TUid id( KPhoneUidWmlBrowser );
TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
TApaTask task = taskList.FindApp( id );
if ( task.Exists() ) {
HBufC8* param8 = HBufC8::NewLC( aAddr.Length() );
param8->Des().Append( aAddr );
task.SendMessage( TUid::Uid( 0 ), *param8 ); // UID is not used
CleanupStack::PopAndDestroy( param8 );
} else {
if ( !aApaLsSession.Handle() )
{
User::LeaveIfError( aApaLsSession.Connect() );
}
TThreadId thread;
User::LeaveIfError( aApaLsSession.StartDocument( aAddr,
KPhoneUidWmlBrowser, thread ) );
}
}
void
WFS60Util::TDesReadResourceL(TDes& dst, TInt resource_id)
{
TDesReadResourceL(dst, resource_id, CCoeEnv::Static());
}
void
WFS60Util::TDesReadResourceL(TDes& dst, TInt resource_id,class CCoeEnv* aCoeEnv)
{
HBufC *tmp;
tmp = aCoeEnv->AllocReadResourceLC(resource_id);
WFTextUtil::TDesCopy(dst, *tmp);
CleanupStack::PopAndDestroy(tmp);
}
| [
"[email protected]"
] | [
[
[
1,
70
]
]
] |
c7b62e8e8756b5be5374c45ce3ef7a878342d99e | 097c5ec89727bca9c69964fdb0125174bd535387 | /src/menu.cpp | be4d2c4e92898449fa932a4c405487b74fcac136 | [] | no_license | jsj2008/Captain | 280501d3bc2dbd778519fddac3afe1d1fb14ebe8 | 099ee3f7cdd5e81ac741a7e6c69a131fcbccc7c6 | refs/heads/master | 2020-12-25T15:40:53.390224 | 2011-11-28T07:36:05 | 2011-11-28T07:36:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,714 | cpp | #include "menu.hpp"
#include "programManager.hpp"
#include "objectManager.hpp"
#include "inputManager.hpp"
#include <iostream>
typedef boost::shared_ptr<Sprite> SpritePtr;
typedef boost::shared_ptr<Text> TextPtr;
typedef boost::shared_ptr<Stars> StarsPtr;
/*
This class does the main menu only at the moment. Parts of it
are prepared for all sorts of menus though, but for now it's
all hardcoded for the main menu
*/
Menu::Menu()
{
}
// Construct a list of Text Sprites. The param is a vector of strings, such as
// { "play game", "options", "exit" }
Menu::Menu(std::vector<std::string> entries, bool useStars)
{
// Size of screen
int width = progmgr.getScreenX()/2;
int height = progmgr.getScreenY()/2-50; // Leave 50 pixels of border
// Size of text
int sizex = 0;
int sizey = 0;
for (int i = 0; i < entries.size(); i++)
{
sizex = entries[i].length()*15; // 7 pixels per character
sizey = 25; // 10 pixels high
TextPtr tempTextPtr(new Text(sizex, sizey, entries[i].c_str(), "ArcadeClassic.ttf", 50));
items.push_back(tempTextPtr);
std::cout << "Item " << entries[i].c_str() << " added to the list" << std::endl;
}
std::cout << "Creating logo" << std::endl;
TextPtr tempTextPtr2(new Text(300, 200, "CAPTAIN", "BulwarkNF.ttf", 70));
additionalTexts.push_back(tempTextPtr2);
TextPtr tempTextPtr(new Text(10, 10, "0", "ArcadeClassic.ttf", 30));
cursor = tempTextPtr;
assert(items.size() != 0);
step = height/items.size();
if (step > 40)
step = 40;
int posy = height;
int i = 0;
cursor->x = width-170;
cursor->y = height-step;
for (std::vector<TextPtr>::iterator iter = items.begin(); iter != items.end(); iter++)
{
(*iter)->x = width; // Draw to center
(*iter)->y = height - i*step; // Draw with a good spacing
i++;
}
// If we want background stars
if (useStars)
createMenuStars();
// Meh, let's just add this hack here
currentSelection = 1;
moveup();
}
Menu::~Menu()
{
}
// Tell ObjectManager to render the possible background things for the menu,
// Then render each of the text elements
void Menu::render()
{
if (backgroundStarsPtr != NULL)
backgroundStarsPtr->render();
// If there are additional graphics
for (std::vector<TextPtr>::iterator iter = additionalTexts.begin(); iter!= additionalTexts.end(); iter++)
{
(*iter)->render();
}
for (std::vector<TextPtr>::iterator iter = items.begin(); iter != items.end(); iter++)
{
(*iter)->render();
}
cursor->render();
}
// Move the cursor up one slot
void Menu::moveup()
{
currentSelection--;
if (currentSelection < 0)
currentSelection = items.size()-1;
TextPtr tempTextPtr = items[currentSelection];
cursor->y = tempTextPtr->y;
}
// Move the cursor down one slot
void Menu::movedown()
{
currentSelection++;
if (currentSelection > items.size()-1)
currentSelection = 0;
TextPtr tempTextPtr = items[currentSelection];
cursor->y = tempTextPtr->y;
}
// The user has pressed enter, and the currently pointed option will be
// selected. Currently hard-coded for the main menu
void Menu::select()
{
// Make stuff here for dynamic options
if (currentSelection == 0)
{
objectmgr.createNewArena();
}
if (currentSelection == 1)
{
// Go to options
}
if (currentSelection == 2)
{
// Display help
}
if (currentSelection == 3)
{
progmgr.setRunning(false);
}
}
// Create some stars to work as a background
void Menu::createMenuStars()
{
StarsPtr tempPtr(new Stars());
backgroundStarsPtr = tempPtr;
}
// Handle moving in the menu
void Menu::update()
{
inputmgr.handleMenuInput(*this);
}
| [
"[email protected]"
] | [
[
[
1,
155
]
]
] |
b5f76365933d5e021a9ce7ab0f94639b80a77be4 | f90b1358325d5a4cfbc25fa6cccea56cbc40410c | /src/GUI/proRataSearchDock.h | 03450b6244d8e3024e16a5a3e6e21118a983a51b | [] | no_license | ipodyaco/prorata | bd52105499c3fad25781d91952def89a9079b864 | 1f17015d304f204bd5f72b92d711a02490527fe6 | refs/heads/master | 2021-01-10T09:48:25.454887 | 2010-05-11T19:19:40 | 2010-05-11T19:19:40 | 48,766,766 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 820 | h | #ifndef PRORATASEARCHDOCK_H
#define PRORATASEARCHDOCK_H
#include <QVariant>
#include <QPushButton>
#include <QLabel>
#include <QLineEdit>
#include <QCheckBox>
#include <QLayout>
#include <QToolTip>
#include <QWhatsThis>
#include <QVariant>
#include <QDockWidget>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QSpacerItem;
class QLabel;
class QLineEdit;
class QPushButton;
class QCheckBox;
class ProRataSearchDock : public QDockWidget
{
Q_OBJECT
public:
ProRataSearchDock( QWidget* parent = 0, Qt::WFlags fl = 0 );
~ProRataSearchDock();
protected:
void buildUI();
QHBoxLayout* findLayout;
QLabel* qlFindLabel;
QLineEdit* qleSearchString;
QPushButton* qpbSearchButton;
QPushButton* qpbShowAll;
};
#endif // PRORATASEARCHDOCK_H
| [
"chongle.pan@c58cc1ec-c975-bb1e-ac29-6983d7497d3a"
] | [
[
[
1,
47
]
]
] |
bc5b1f594d8e005d92d211dc331709ff9190f8bc | deb8ef49795452ff607023c6bce8c3e8ed4c8360 | /Projects/UAlbertaBot/Source/base/BuildingData.cpp | efffb3f6dbdc8bd609e4942da9cd009dac4db6e3 | [] | no_license | timburr1/ou-skynet | f36ed7996c21f788a69e3ae643b629da7d917144 | 299a95fae4419429be1d04286ea754459a9be2d6 | refs/heads/master | 2020-04-19T22:58:46.259980 | 2011-12-06T20:10:34 | 2011-12-06T20:10:34 | 34,360,542 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,694 | cpp | #include "Common.h"
#include "BuildingData.h"
ConstructionData::ConstructionData()
{
// set up the buildings vector
buildings = std::vector< std::vector<Building> > (NumBuildingStates, std::vector<Building>());
// set up the index vector
buildingIndex = std::vector< size_t >(NumBuildingStates, 0);
}
bool ConstructionData::hasNextBuilding(BuildingState bs)
{
// is the current index valid
return buildingIndex[bs] < buildings[bs].size();
}
int ConstructionData::getNumBuildings(BuildingState bs)
{
return buildings[bs].size();
}
Building & ConstructionData::getNextBuilding(BuildingState bs)
{
// assert this index is valid
assert(hasNextBuilding(bs));
// get the building
Building & returnBuilding = buildings[bs][buildingIndex[bs]];
// increment the index
buildingIndex[bs]++;
// return the building
return returnBuilding;
}
void ConstructionData::begin(BuildingState bs)
{
// set the index to 0
buildingIndex[bs] = 0;
}
void ConstructionData::removeCurrentBuilding(BuildingState bs)
{
// erase the element of the vector 1 before where we are now
buildings[bs].erase(buildings[bs].begin() + buildingIndex[bs] - 1);
// set the index back one
buildingIndex[bs]--;
}
void ConstructionData::addBuilding(BuildingState bs, Building & b)
{
// add the building to the vector
buildings[bs].push_back(b);
}
bool ConstructionData::isBeingBuilt(BWAPI::UnitType type)
{
// for each building vector
BOOST_FOREACH (std::vector<Building> & buildingVector, buildings)
{
BOOST_FOREACH (Building & b, buildingVector)
{
if (b.type == type)
{
return true;
}
}
}
return false;
} | [
"[email protected]@ce23f72d-95c0-fd94-fabd-fc6dce850bd1"
] | [
[
[
1,
75
]
]
] |
9b414754466ce5170c0942e317a61df2bc764f1f | 668dc83d4bc041d522e35b0c783c3e073fcc0bd2 | /fbide-wx/sdk/include/sdk/DocManager.h | f96f2c79ad70f183a27a83a59c292f542f9e77aa | [] | 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,734 | 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
*/
#ifndef DOCMANAGER_H_INCLUDED
#define DOCMANAGER_H_INCLUDED
namespace fb
{
/**
* Forward references
*/
class CManager;
class CDocumentBase;
/**
* This manager handles the open documens.
* Keeps a list, forwards the save, open and etc
* events. Does not handle document specific logic.
*
* Can be accessed only through CManager class
*/
class DLLIMPORT CDocManager : public wxEvtHandler
{
public :
bool CloseAll ();
CDocumentBase * FindDocument (wxWindow * wnd);
CDocumentBase * Open (const wxString & filename, bool show = true);
void Open (const wxArrayString & filenames);
private :
friend class CManager;
CDocManager ();
~CDocManager ();
struct CData;
CData * m_data;
};
}
#endif // DOCMANAGER_H_INCLUDED
| [
"vongodric@957c6b5c-1c3a-0410-895f-c76cfc11fbc7"
] | [
[
[
1,
61
]
]
] |
4306d51c34fb7ef7084be4c7b1511329dc9401fd | 96e96a73920734376fd5c90eb8979509a2da25c0 | /BulletPhysics/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuContactResult.h | bc9a7d733888f8ddf59759dbe0664a7531fa2037 | [] | no_license | lianlab/c3de | 9be416cfbf44f106e2393f60a32c1bcd22aa852d | a2a6625549552806562901a9fdc083c2cacc19de | refs/heads/master | 2020-04-29T18:07:16.973449 | 2009-11-15T10:49:36 | 2009-11-15T10:49:36 | 32,124,547 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,382 | h | /*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
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.
*/
#ifndef SPU_CONTACT_RESULT2_H
#define SPU_CONTACT_RESULT2_H
#ifndef WIN32
#include <stdint.h>
#endif
#include "../SpuDoubleBuffer.h"
#include "LinearMath/btTransform.h"
#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
struct SpuCollisionPairInput
{
ppu_address_t m_collisionShapes[2];
void* m_spuCollisionShapes[2];
ppu_address_t m_persistentManifoldPtr;
btVector3 m_primitiveDimensions0;
btVector3 m_primitiveDimensions1;
int m_shapeType0;
int m_shapeType1;
float m_collisionMargin0;
float m_collisionMargin1;
btTransform m_worldTransform0;
btTransform m_worldTransform1;
bool m_isSwapped;
bool m_useEpa;
};
struct SpuClosestPointInput
{
SpuClosestPointInput()
:m_maximumDistanceSquared(float(BT_LARGE_FLOAT)),
m_stackAlloc(0)
{
}
btTransform m_transformA;
btTransform m_transformB;
float m_maximumDistanceSquared;
class btStackAlloc* m_stackAlloc;
struct SpuConvexPolyhedronVertexData* m_convexVertexData[2];
};
///SpuContactResult exports the contact points using double-buffered DMA transfers, only when needed
///So when an existing contact point is duplicated, no transfer/refresh is performed.
class SpuContactResult
{
btTransform m_rootWorldTransform0;
btTransform m_rootWorldTransform1;
ppu_address_t m_manifoldAddress;
btPersistentManifold* m_spuManifold;
bool m_RequiresWriteBack;
btScalar m_combinedFriction;
btScalar m_combinedRestitution;
bool m_isSwapped;
DoubleBuffer<btPersistentManifold, 1> g_manifoldDmaExport;
public:
SpuContactResult();
virtual ~SpuContactResult();
btPersistentManifold* GetSpuManifold() const
{
return m_spuManifold;
}
virtual void setShapeIdentifiers(int partId0,int index0, int partId1,int index1);
void setContactInfo(btPersistentManifold* spuManifold, ppu_address_t manifoldAddress,const btTransform& worldTrans0,const btTransform& worldTrans1, btScalar restitution0,btScalar restitution1, btScalar friction0,btScalar friction01, bool isSwapped);
void writeDoubleBufferedManifold(btPersistentManifold* lsManifold, btPersistentManifold* mmManifold);
virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth);
void flush();
};
#endif //SPU_CONTACT_RESULT2_H
| [
"caiocsabino@7e2be596-0d54-0410-9f9d-cf4183935158"
] | [
[
[
1,
112
]
]
] |
b7d3dfa15d91c718a9860e43dc6983c3bd239fbe | de98f880e307627d5ce93dcad1397bd4813751dd | /Sls/VlcWnd.h | 0a56a22d2726bdee8f830da5de6197a8c9875e19 | [] | no_license | weimingtom/sls | 7d44391bc0c6ae66f83ddcb6381db9ae97ee0dd8 | d0d1de9c05ecf8bb6e4eda8a260c7a2f711615dd | refs/heads/master | 2021-01-10T22:20:55.638757 | 2011-03-19T06:23:49 | 2011-03-19T06:23:49 | 44,464,621 | 2 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,102 | h | #ifndef VLC_WND_H_
#define VLC_WND_H_
#include <vlc/vlc.h>
class CVlcWnd
{
public:
CVlcWnd();
virtual ~CVlcWnd();
private:
libvlc_instance_t *m_pVlcInst;
libvlc_media_player_t *m_pVlcMediaPlayer;
libvlc_media_t *m_pVlcMedia;
libvlc_instance_t *m_pVlcInst2;
libvlc_media_player_t *m_pVlcMediaPlayer2;
libvlc_media_t *m_pVlcMedia2;
CWnd *iParentWnd;
HWND m_hVlcWnd;
HWND m_hOSDWnd;
BOOL m_bFlash;
BOOL m_bRecording;
float m_fZoom;
BLENDFUNCTION m_Blend;
typedef BOOL (WINAPI *MYFUNC)(HWND,HDC,POINT*,SIZE*,HDC,POINT*,COLORREF,BLENDFUNCTION*,DWORD);//该函数是windows的一个未公开API
//该函数是windows的一个未公开API
MYFUNC UpdateLayeredWindow;
//窗口消息分发处理函数
BOOL OnVlcWndMsg(UINT uMsg,WPARAM wParam,LPARAM lParam);
BOOL OnOsdWndMsg(UINT uMsg,WPARAM wParam,LPARAM lParam);
//窗口的回调函数
static BOOL CALLBACK VlcWndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
static BOOL CALLBACK OsdWndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
CString iPlayPath;
public:
VOID DrawOSD(LPVOID pGraph);
//在开始渲染透明窗口前,做好准备工作
VOID InitOSD();
//更新显示透明窗口
VOID UpdateDisplay(int Transparent=100);
virtual VOID Show(BOOL bShow);
// Function name : ZoomIn
// Description :
// Return type : BOOL
virtual BOOL ZoomIn();
// Function name : ZoomOut
// Description :
// Return type : BOOL
virtual BOOL ZoomOut();
// Function name : ZoomNormal
// Description :
// Return type : BOOL
virtual BOOL ZoomNormal();
// Function name : Capture
// Description :
// Return type : BOOL
// Argument : LPTSTR szPath
virtual BOOL Capture(LPTSTR szPath);
// Function name : Record
// Description : 录像
// Return type : BOOL
// Argument : LPTSTR szPath
virtual BOOL Record(LPTSTR szPath);
void SetParentWnd(CWnd *aParentWnd);
void SetPlayPath(CString aPath);
void Play();
void Stop();
void CreatePlayer();
};
#endif | [
"[email protected]"
] | [
[
[
1,
82
]
]
] |
542fdbc137b259801cd2f2df48e2de8982b9ab5b | 41c264ec05b297caa2a6e05e4476ce0576a8d7a9 | /OpenScrape/DialogEdit.h | 87a773f8f50def1285e10a0f34e64e3af036ca0b | [] | no_license | seawei/openholdem | cf19a90911903d7f4d07f956756bd7e521609af3 | ba408c835b71dc1a9d674eee32958b69090fb86c | refs/heads/master | 2020-12-25T05:40:09.628277 | 2009-01-25T01:17:10 | 2009-01-25T01:17:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 518 | h | #pragma once
#include "afxwin.h"
#include "resource.h"
// CDlgEdit dialog
class CDlgEdit : public CDialog
{
DECLARE_DYNAMIC(CDlgEdit)
public:
CDlgEdit(CWnd* pParent = NULL); // standard constructor
virtual ~CDlgEdit();
virtual BOOL OnInitDialog();
afx_msg void OnBnClickedOk();
enum { IDD = IDD_EDITDLG };
CString m_titletext;
CString m_result;
CEdit m_EditEntry;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
};
| [
"[email protected]"
] | [
[
[
1,
25
]
]
] |
6873b69785cbcc5f77391b866d232325a48108e1 | dadf8e6f3c1adef539a5ad409ce09726886182a7 | /airplay/src/toeApp.cpp | 591dc4b9689342f37823a8ae60343225b77b9533 | [] | 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 | 374 | cpp | #include "toeApp.h"
#include "TinyOpenEngine.h"
#include "s3eConfig.h"
using namespace TinyOpenEngine;
CtoeApp::CtoeApp()
{
}
CtoeApp::~CtoeApp()
{
}
void CtoeApp::Run()
{
char startgroup [S3E_CONFIG_STRING_MAX];
if (S3E_RESULT_SUCCESS == s3eConfigGetString("TOE", "startgroup", startgroup))
{
toeOpenGroupWorld("./menu/mainmenu.group");
}
}
| [
"[email protected]"
] | [
[
[
1,
22
]
]
] |
0da647bc45f4d7da08c2ad22012e5f82b6ab0885 | 04d69fa1d0f48adc2033912fe1cb9781a2ee8e8b | /src/SpecialAbility_SpeedUp.cpp | 4c00cf77c5a2728ff244081d618f62a538e54910 | [
"BSD-3-Clause"
] | permissive | foxostro/heroman | 63e4ed9d95bf02586df92c804e94902259734780 | 7831351af1b7bbad603b184fd25e030ece2d0657 | refs/heads/master | 2021-01-25T06:37:28.649485 | 2009-08-02T12:53:38 | 2009-08-02T12:53:38 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,867 | cpp | #include "stdafx.h"
#include "Filename.h"
#include "SpecialAbility.h"
#include "SpecialAbility_SpeedUp.h"
#include "ComponentMovement.h"
#include "ComponentHealth.h"
SpecialAbility_SpeedUp::SpecialAbility_SpeedUp(ActorPtr a, string n, World *w)
: SpecialAbility(a, n, w)
{
type = SpeedUp;
bIsActive = false;
bIsCharged = false;
}
SpecialAbility_SpeedUp::~SpecialAbility_SpeedUp(void)
{
}
bool SpecialAbility_SpeedUp::executeAbility()
{
//make sure ability is not already being executed and is fully charged
if (bIsActive || !bIsCharged)
return false;
ComponentMovement *movement = dynamic_cast<ComponentMovement *>(myActor->getComponent("Movement"));
//store the unmodified speed of the actor; update new speed
originalSpeed = movement->getTopSpeed();
originalCool = movement->getWeapon()->getCoolDown();
movement->setTopSpeed(originalSpeed * speedFactor);
movement->getWeapon()->setCoolDown(originalCool / speedFactor);
//set active, start countdown, and erase charge meter
timeLeft = duration;
currentCharge = 0.0f;
bIsActive = true;
bIsCharged = false;
return true;
}
void SpecialAbility_SpeedUp::display()
{
}
void SpecialAbility_SpeedUp::onLoad(const PropertyBag &data)
{
//load necessary data to build ability
speedFactor = data.getFloat("speedFactor");
duration = (unsigned int)data.getInt("duration");
}
void SpecialAbility_SpeedUp::update(float milliseconds)
{
//update countdown on effect if currently active
if (bIsActive)
{
timeLeft -= (int)milliseconds;
//check time has expired on effect; if so, reset necessary values
if (timeLeft <= 0)
{
ComponentMovement *movement = dynamic_cast<ComponentMovement *>(myActor->getComponent("Movement"));
movement->setTopSpeed(originalSpeed);
movement->getWeapon()->setCoolDown(originalCool);
currentCharge = (float)initialCharge;
bIsActive = false;
bIsCharged = false;
}
}
else if (!bIsCharged)
{
//update charge meter if it isn't full yet
chargeByType(milliseconds);
}
else
executeAbility();
lastHealth = (dynamic_cast<ComponentHealth *>(myActor->getComponent("Health")))->getHealth();
}
void SpecialAbility_SpeedUp::chargeByDamageReceived(float milliseconds)
{
int currentHealth = (dynamic_cast<ComponentHealth *>(myActor->getComponent("Health")))->getHealth();
int damage = lastHealth - currentHealth;
if (damage < 0)
damage = 0;
currentCharge += chargeTypes["ByDamageReceived"] * damage;
if (currentCharge >= chargeMeter)
{
bIsCharged = true;
currentCharge = 100.0;
}
/*
timePassed += milliseconds;
if (timePassed >= 1000.0)
{
timePassed = 0.0;
currentCharge += chargeTypes["ByTimePassed"];
if (currentCharge >= chargeMeter)
{
bIsCharged = true;
currentCharge = 100.0;
}
}
*/
}
| [
"[email protected]"
] | [
[
[
1,
114
]
]
] |
8eb7a56a96b27e50f17592ed214e3580b1b9f21f | bef7d0477a5cac485b4b3921a718394d5c2cf700 | /testLotsOfGuys/src/demo/IdlePlayer.cpp | ca1a1ed5d765eb7891d41a6166d5ec20bfa0acde | [
"MIT"
] | permissive | TomLeeLive/aras-p-dingus | ed91127790a604e0813cd4704acba742d3485400 | 22ef90c2bf01afd53c0b5b045f4dd0b59fe83009 | refs/heads/master | 2023-04-19T20:45:14.410448 | 2011-10-04T10:51:13 | 2011-10-04T10:51:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,321 | cpp | #include "stdafx.h"
#include "IdlePlayer.h"
#include "ComplexStuffEntity.h"
#include <dingus/utils/Random.h>
// --------------------------------------------------------------------------
void InitIdleConfig( IdleConfig& cfg )
{
cfg.mAnims.push_back( RGET_ANIM("ScrollerClock") );
cfg.mAnims.push_back( RGET_ANIM("ScrollerDance") );
cfg.mAnims.push_back( RGET_ANIM("ScrollerFly") );
cfg.mAnims.push_back( RGET_ANIM("ScrollerJumpOut") );
cfg.mAnims.push_back( RGET_ANIM("ScrollerTins") );
cfg.mAnims.push_back( RGET_ANIM("ScrollerViewer") );
}
// --------------------------------------------------------------------------
static float gGetNextDefAnimPlayTime()
{
return gRandom.getFloat( 2.0f, 8.0f );
}
IdlePlayer::IdlePlayer( const IdleConfig& cfg )
: mCfg( &cfg )
, mStartTime(0)
, mLocalTime(0)
, mDefAnimPlayedTime(0.0f)
, mDefAnimPlayTime( gGetNextDefAnimPlayTime() )
{
mAnimPlayCount.resize( cfg.mAnims.size(), 0 );
}
IdlePlayer::~IdlePlayer()
{
}
void IdlePlayer::startScrollerAnim( CComplexStuffEntity& character )
{
mDefAnimPlayTime = gGetNextDefAnimPlayTime();
mDefAnimPlayedTime = 0.0f;
// half-randomly select animation
int n = mCfg->mAnims.size();
int bestAnimIdx = gRandom.getUInt() % n;
int bestPlayCount = mAnimPlayCount[bestAnimIdx];
for( int i = 0; i < n / 2; ++i ) {
int idx = gRandom.getUInt() % n;
const CAnimationBunch* anim = mCfg->mAnims[idx];
if( mAnimPlayCount[idx] < bestPlayCount ) {
bestPlayCount = mAnimPlayCount[idx];
bestAnimIdx = idx;
}
}
++mAnimPlayCount[bestAnimIdx];
const CAnimationBunch* anim = mCfg->mAnims[bestAnimIdx];
character.getAnimator().playAnim( *anim, gGetAnimDuration(*anim,false), 0.5f, true, mLocalTime );
}
void IdlePlayer::update( CComplexStuffEntity& character, time_value demoTime )
{
// timing
time_value oldLocalTime = mLocalTime;
mLocalTime = demoTime - mStartTime;
float dtFromTimer = (mLocalTime-oldLocalTime).tosec();
// track how long we're playing idle anim
if( character.getAnimator().isPlayingDefaultAnim() ) {
mDefAnimPlayedTime += dtFromTimer;
// if too long - start scroller anim
if( mDefAnimPlayedTime >= mDefAnimPlayTime ) {
startScrollerAnim( character );
}
}
character.update( mLocalTime );
}
| [
"[email protected]"
] | [
[
[
1,
85
]
]
] |
ed5a60445c2de37ba7759c1db1b567d5091be499 | 6e4f9952ef7a3a47330a707aa993247afde65597 | /PROJECTS_ROOT/WireChanger/Webbrowser2.cpp | 70051bba1786a3f3fd146786da1d64351c797901 | [] | no_license | meiercn/wiredplane-wintools | b35422570e2c4b486c3aa6e73200ea7035e9b232 | 134db644e4271079d631776cffcedc51b5456442 | refs/heads/master | 2021-01-19T07:50:42.622687 | 2009-07-07T03:34:11 | 2009-07-07T03:34:11 | 34,017,037 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 5,656 | cpp | // Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++
// NOTE: Do not modify the contents of this file. If this class is regenerated by
// Microsoft Visual C++, your modifications will be overwritten.
#include "stdafx.h"
#include "webbrowser2.h"
////////////////////////////////////////////////////////////////////////////
// CWebBrowser2
IMPLEMENT_DYNCREATE(CWebBrowser2, CWnd)
////////////////////////////////////////////////////////////////////////////
// CWebBrowser2 operations
void CWebBrowser2::GoBack()
{
InvokeHelper(0x64, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
}
void CWebBrowser2::GoForward()
{
InvokeHelper(0x65, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
}
void CWebBrowser2::GoHome()
{
InvokeHelper(0x66, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
}
void CWebBrowser2::Navigate(LPCTSTR URL, VARIANT* Flags, VARIANT* TargetFrameName, VARIANT* PostData, VARIANT* Headers)
{
static BYTE parms[] =
VTS_BSTR VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT;
InvokeHelper(0x68, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
URL, Flags, TargetFrameName, PostData, Headers);
}
void CWebBrowser2::Refresh()
{
InvokeHelper(DISPID_REFRESH, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
}
void CWebBrowser2::Refresh2(VARIANT* Level)
{
static BYTE parms[] =
VTS_PVARIANT;
InvokeHelper(0x69, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
Level);
}
void CWebBrowser2::Stop()
{
InvokeHelper(0x6a, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
}
LPDISPATCH CWebBrowser2::GetApplication()
{
LPDISPATCH result=0;
try{
InvokeHelper(0xc8, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL);
}catch(...)
{
}
return result;
}
LPDISPATCH CWebBrowser2::GetDocument()
{
LPDISPATCH result=0;
try{
InvokeHelper(0xcb, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL);
}catch(...)
{
}
return result;
}
long CWebBrowser2::GetLeft()
{
long result=0;
InvokeHelper(0xce, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
return result;
}
void CWebBrowser2::SetLeft(long nNewValue)
{
static BYTE parms[] = VTS_I4;
InvokeHelper(0xce, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
nNewValue);
}
long CWebBrowser2::GetTop()
{
long result=0;
InvokeHelper(0xcf, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
return result;
}
void CWebBrowser2::SetTop(long nNewValue)
{
static BYTE parms[] =
VTS_I4;
InvokeHelper(0xcf, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
nNewValue);
}
long CWebBrowser2::GetWidth()
{
long result=0;
InvokeHelper(0xd0, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
return result;
}
void CWebBrowser2::SetWidth(long nNewValue)
{
try{
static BYTE parms[] =
VTS_I4;
InvokeHelper(0xd0, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
nNewValue);
}catch(...)
{
}
}
long CWebBrowser2::GetHeight()
{
long result=0;
InvokeHelper(0xd1, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
return result;
}
void CWebBrowser2::SetHeight(long nNewValue)
{
try{
static BYTE parms[] =
VTS_I4;
InvokeHelper(0xd1, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
nNewValue);
}catch(...)
{
}
}
CString CWebBrowser2::GetLocationName()
{
CString result="";
try{
InvokeHelper(0xd2, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
}catch(...)
{
}
return result;
}
CString CWebBrowser2::GetLocationURL()
{
CString result="";
try{
InvokeHelper(0xd3, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
}catch(...)
{
}
return result;
}
BOOL CWebBrowser2::GetBusy()
{
BOOL result=FALSE;
InvokeHelper(0xd4, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
return result;
}
void CWebBrowser2::Quit()
{
InvokeHelper(0x12c, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
}
void CWebBrowser2::ClientToWindow(long* pcx, long* pcy)
{
static BYTE parms[] =
VTS_PI4 VTS_PI4;
InvokeHelper(0x12d, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
pcx, pcy);
}
CString CWebBrowser2::GetName()
{
CString result="";
InvokeHelper(0x0, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
return result;
}
long CWebBrowser2::GetHwnd()
{
long result=0;
InvokeHelper(DISPID_HWND, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
return result;
}
void CWebBrowser2::Navigate2(VARIANT* URL, VARIANT* Flags, VARIANT* TargetFrameName, VARIANT* PostData, VARIANT* Headers)
{
try{
static BYTE parms[] =
VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT;
InvokeHelper(0x1f4, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
URL, Flags, TargetFrameName, PostData, Headers);
}catch(...)
{
}
}
long CWebBrowser2::QueryStatusWB(long cmdID)
{
long result=0;
static BYTE parms[] =
VTS_I4;
InvokeHelper(0x1f5, DISPATCH_METHOD, VT_I4, (void*)&result, parms,
cmdID);
return result;
}
void CWebBrowser2::ExecWB(long cmdID, long cmdexecopt, VARIANT* pvaIn, VARIANT* pvaOut)
{
static BYTE parms[] =
VTS_I4 VTS_I4 VTS_PVARIANT VTS_PVARIANT;
InvokeHelper(0x1f6, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
cmdID, cmdexecopt, pvaIn, pvaOut);
}
long CWebBrowser2::GetReadyState()
{
long result=0;
InvokeHelper(DISPID_READYSTATE, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
return result;
}
void CWebBrowser2::SetRegisterAsDropTarget(BOOL bNewValue)
{
static BYTE parms[] =
VTS_BOOL;
InvokeHelper(0x229, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
bNewValue);
}
CWebBrowser2::~CWebBrowser2()
{
//TRACE("void CWebBrowser2::~CWebBrowser2()\n");
} | [
"wplabs@3fb49600-69e0-11de-a8c1-9da277d31688"
] | [
[
[
1,
254
]
]
] |
002bac4cddedf58bbc57630fb8f0cead1a457372 | 478570cde911b8e8e39046de62d3b5966b850384 | /apicompatanamdw/bcdrivers/os/persistent_data/BCLogEngineTest/inc/BCLogEngineTest.h | 7e57b6ada31f90597d0ec8e613d8e8101852b1b1 | [] | 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,061 | h | /*
* Copyright (c) 2002 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: BCLogEngineTest test module.
*
*/
/* Changed by Vaibhav - 13Aug07 for Removing CodeScanner Warnings - High/medium */
#ifndef BCLOGENGINETEST_H
#define BCLOGENGINETEST_H
// INCLUDES
#include "StifTestModule.h"
#include <StifLogger.h>
#include <LogCli.h>
#include <LogWrap.h>
#include <LogView.h>
#include <LogClientChangeObserver.h>
#include <f32file.h>
#include <e32base.h>
// CONSTANTS
//const ?type ?constant_var = ?constant;
// MACROS
//#define ?macro ?macro_def
#define TEST_MODULE_VERSION_MAJOR 52
#define TEST_MODULE_VERSION_MINOR 9
#define TEST_MODULE_VERSION_BUILD 50
#define KTestEventId1 0x10005394
#define KTestEventId2 0x10005395
#define TEST(aValue, aExpected) ::Check(aValue, aExpected)
// Logging path
_LIT( KBCLogEngineTestLogPath, "\\logs\\testframework\\BCLogEngineTest\\" );
// Log file
_LIT( KBCLogEngineTestLogFile, "BCLogEngineTest.txt" );
// Function pointer related internal definitions
// Rounding known bug in GCC
#ifndef __GCC32__
#define GETPTR
#else
#define GETPTR &
#endif
#define ENTRY(str,func) {_S(str), GETPTR func,0,0,0}
#define FUNCENTRY(func) {_S(#func), GETPTR func,0,0,0}
#define OOM_ENTRY(str,func,a,b,c) {_S(str), GETPTR func,a,b,c}
#define OOM_FUNCENTRY(func,a,b,c) {_S(#func), GETPTR func,a,b,c}
// FUNCTION PROTOTYPES
//?type ?function_name(?arg_list);
// FORWARD DECLARATIONS
//class ?FORWARD_CLASSNAME;
class CBCLogEngineTest;
class CActiveLogEngine;
class CMyLogActive;
// DATA TYPES
//enum ?declaration
//typedef ?declaration
//extern ?data_type;
// A typedef for function that does the actual testing,
// function is a type
// TInt CBCLogEngineTest::<NameOfFunction> ( TTestResult& aResult )
typedef TInt (CBCLogEngineTest::* TestFunction)(TTestResult&);
// CLASS DECLARATION
/**
* An internal structure containing a test case name and
* the pointer to function doing the test
*
* @lib ?library
* @since ?Series60_version
*/
class TCaseInfoInternal
{
public:
const TText* iCaseName;
TestFunction iMethod;
TBool iIsOOMTest;
TInt iFirstMemoryAllocation;
TInt iLastMemoryAllocation;
};
// CLASS DECLARATION
/**
* A structure containing a test case name and
* the pointer to function doing the test
*
* @lib ?library
* @since ?Series60_version
*/
class TCaseInfo
{
public:
TPtrC iCaseName;
TestFunction iMethod;
TBool iIsOOMTest;
TInt iFirstMemoryAllocation;
TInt iLastMemoryAllocation;
TCaseInfo( const TText* a ) : iCaseName( (TText*) a )
{
};
};
// CLASS DECLARATION
/**
* This a BCLogEngineTest class.
* ?other_description_lines
*
* @lib ?library
* @since ?Series60_version
*/
NONSHARABLE_CLASS(CBCLogEngineTest) : public CTestModuleBase
{
public: // Constructors and destructor
/**
* Two-phased constructor.
*/
static CBCLogEngineTest* NewL();
/**
* Destructor.
*/
virtual ~CBCLogEngineTest();
public: // New functions
/**
* ?member_description.
* @since ?Series60_version
* @param ?arg1 ?description
* @return ?description
*/
public: // Functions from base classes
/**
* From CTestModuleBase InitL is used to initialize the
* BCLogEngineTest. It is called once for every instance of
* TestModuleBCLogEngineTest after its creation.
* @since ?Series60_version
* @param aIniFile Initialization file for the test module (optional)
* @param aFirstTime Flag is true when InitL is executed for first
* created instance of BCLogEngineTest.
* @return Symbian OS error code
*/
TInt InitL( TFileName& aIniFile, TBool aFirstTime );
/**
* From CTestModuleBase GetTestCasesL is used to inquiry test cases
* from BCLogEngineTest.
* @since ?Series60_version
* @param aTestCaseFile Test case file (optional)
* @param aTestCases Array of TestCases returned to test framework
* @return Symbian OS error code
*/
TInt GetTestCasesL( const TFileName& aTestCaseFile,
RPointerArray<TTestCaseInfo>& aTestCases );
/**
* From CTestModuleBase RunTestCaseL is used to run an individual
* test case.
* @since ?Series60_version
* @param aCaseNumber Test case number
* @param aTestCaseFile Test case file (optional)
* @param aResult Test case result returned to test framework (PASS/FAIL)
* @return Symbian OS error code (test case execution error, which is
* not reported in aResult parameter as test case failure).
*/
TInt RunTestCaseL( const TInt aCaseNumber,
const TFileName& aTestCaseFile,
TTestResult& aResult );
/**
* From CTestModuleBase; OOMTestQueryL is used to specify is particular
* test case going to be executed using OOM conditions
* @param aTestCaseFile Test case file (optional)
* @param aCaseNumber Test case number (optional)
* @param aFailureType OOM failure type (optional)
* @param aFirstMemFailure The first heap memory allocation failure value (optional)
* @param aLastMemFailure The last heap memory allocation failure value (optional)
* @return TBool
*/
virtual TBool OOMTestQueryL( const TFileName& /* aTestCaseFile */,
const TInt /* aCaseNumber */,
TOOMFailureType& aFailureType,
TInt& /* aFirstMemFailure */,
TInt& /* aLastMemFailure */ );
/**
* From CTestModuleBase; OOMTestInitializeL may be used to initialize OOM
* test environment
* @param aTestCaseFile Test case file (optional)
* @param aCaseNumber Test case number (optional)
* @return None
*/
virtual void OOMTestInitializeL( const TFileName& /* aTestCaseFile */,
const TInt /* aCaseNumber */ );
/**
* From CTestModuleBase; OOMHandleWarningL
* @param aTestCaseFile Test case file (optional)
* @param aCaseNumber Test case number (optional)
* @param aFailNextValue FailNextValue for OOM test execution (optional)
* @return None
*
* User may add implementation for OOM test warning handling. Usually no
* implementation is required.
*/
virtual void OOMHandleWarningL( const TFileName& /* aTestCaseFile */,
const TInt /* aCaseNumber */,
TInt& /* aFailNextValue */);
/**
* From CTestModuleBase; OOMTestFinalizeL may be used to finalize OOM
* test environment
* @param aTestCaseFile Test case file (optional)
* @param aCaseNumber Test case number (optional)
* @return None
*
*/
virtual void OOMTestFinalizeL( const TFileName& /* aTestCaseFile */,
const TInt /* aCaseNumber */ );
/**
* Method used to log version of test module
*/
void SendTestModuleVersion();
protected: // New functions
/**
* ?member_description.
* @since ?Series60_version
* @param ?arg1 ?description
* @return ?description
*/
//?type ?member_function( ?type ?arg1 );
protected: // Functions from base classes
/**
* From ?base_class ?member_description
*/
//?type ?member_function();
private:
/**
* C++ default constructor.
*/
CBCLogEngineTest();
/**
* By default Symbian 2nd phase constructor is private.
*/
void ConstructL();
// Prohibit copy constructor if not deriving from CBase.
// ?classname( const ?classname& );
// Prohibit assigment operator if not deriving from CBase.
// ?classname& operator=( const ?classname& );
/**
* Function returning test case name and pointer to test case function.
* @since ?Series60_version
* @param aCaseNumber test case number
* @return TCaseInfo
*/
const TCaseInfo Case ( const TInt aCaseNumber ) const;
/**
* Actual Hardcoded test case functions are listed below.
*/
TInt TestNotifyChangeL( TTestResult& aResult );
TInt TestNotifyChangeCancelL( TTestResult& aResult );
TInt TestLogClientL( TTestResult& aResult );
TInt TestLogBaseL( TTestResult& aResult );
TInt TestLogEventL( TTestResult& aResult );
TInt TestLogEventTypeL( TTestResult& aResult );
TInt TestLogFilterL( TTestResult& aResult );
TInt TestLogWrapperL( TTestResult& aResult );
TInt TestLogViewRecentL( TTestResult& aResult );
TInt TestLogViewEventL( TTestResult& aResult );
TInt TestLogFilterListL( TTestResult& aResult );
TInt TestLogViewDuplicateL( TTestResult& aResult );
TInt TestLogActiveL( TTestResult& aResult );
public: // Data
CActiveScheduler* myActiveScheduler;
private: // Data
// Pointer to test (function) to be executed
TestFunction iMethod;
// Pointer to logger
CStifLogger* iLog;
CActiveScheduler* iActiveScheduler;
// needed for using CLogClient
RFs iSession;
CLogClient* iLogClient;
CLogEvent* iLogEvent;
CLogEventType* iLogType;
CLogFilter* iLogFilter;
CLogWrapper* iLogWrapper;
CLogViewRecent* iLogViewRecent;
CLogViewEvent* iLogViewEvent;
CLogFilterList* iLogFilterList;
CLogViewDuplicate* iLogViewDuplicate;
};
class CActiveLogEngine : public CActive
{
public:
/**
* C++ default constructor.
*/
CActiveLogEngine( TInt aPriority = EPriorityIdle-100 );
/**
* Destructor.
*/
virtual ~CActiveLogEngine();
public:
/**
* Sends asynchronous request to log server to return
* last dialled number.
* @since 2.5
* @param None
* @return None
*/
void StartL();
private:
/**
* From CActive. Called when asynchronous request completes.
* @since 2.5
* @param None
* @return None
*/
void RunL();
/**
* From CActive. Cancels asynchronous request.
* @since 2.5
* @param None
* @return None
*/
void DoCancel();
private:
TRequestStatus iStoredStatus;
};
class CMyLogActive : public CLogActive
{
public:
CMyLogActive();
~CMyLogActive();
void StartL();
void Queue(TRequestStatus& aStatus)
{
CLogActive::Queue(aStatus);
}
void Complete(TInt aStatus)
{
CLogActive::Complete(aStatus);
}
private:
void RunL();
void DoCancel();
void DoRunL() { };
};
class CMyLogClient : public CLogBase
{
public:
CMyLogClient();
~CMyLogClient();
public:
void LoadResourcesL( RFs& aFs)
{
CLogBase::LoadResourcesL( aFs );
}
inline const CResourceFile *ResourceFile() const
{
return CLogBase::ResourceFile();
}
private:
void DoRunL();
};
class TClientObserverTestReceiver : public MLogClientChangeObserver
{
public:
TClientObserverTestReceiver(TBool& aFlag) : iCallCount(0), iFlag(aFlag) { }
public:
void HandleLogClientChangeEventL(TUid aChangeType, TInt /*aChangeParam1*/, TInt /*aChangeParam2*/, TInt /*aChangeParam3*/)
{
++iCallCount;
iFlag = (aChangeType == KLogClientChangeEventLogCleared);
}
inline TInt CallCount() const { return iCallCount; }
inline void Reset() { iCallCount = 0; iFlag = EFalse; }
private:
TInt iCallCount;
TBool& iFlag;
};
#endif // BCLOGENGINETEST_H
// End of File | [
"none@none"
] | [
[
[
1,
457
]
]
] |
1559bfc36bf5df7ba6ad02db49a9ab1409c673d8 | 7476d2c710c9a48373ce77f8e0113cb6fcc4c93b | /vaultmaster/MasterServer.cpp | c461b2c73a8dcef6a90b13747ad56bb6a9a207ba | [] | no_license | CmaThomas/Vault-Tec-Multiplayer-Mod | af23777ef39237df28545ee82aa852d687c75bc9 | 5c1294dad16edd00f796635edaf5348227c33933 | refs/heads/master | 2021-01-16T21:13:29.029937 | 2011-10-30T21:58:41 | 2011-10-30T22:00:12 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,900 | cpp | #include "MasterServer.h"
using namespace RakNet;
using namespace Data;
using namespace std;
RakPeerInterface* MasterServer::peer;
SocketDescriptor* MasterServer::sockdescr;
typedef map<SystemAddress, ServerEntry> ServerMap;
ServerMap MasterServer::serverList;
bool MasterServer::thread;
void MasterServer::TerminateThread()
{
thread = false;
}
void MasterServer::timestamp()
{
time_t ltime;
ltime = time( NULL );
char t[32];
snprintf( t, sizeof( t ), "[%s", asctime( localtime( <ime ) ) );
char* newline = strchr( t, '\n' );
*newline = ']';
strcat( t, " " );
printf( t );
}
void MasterServer::RemoveServer( SystemAddress addr )
{
map<SystemAddress, ServerEntry>::iterator i;
i = serverList.find( addr );
if ( i != serverList.end() )
serverList.erase( i );
}
DWORD WINAPI MasterServer::MasterThread( LPVOID data )
{
sockdescr = new SocketDescriptor( RAKNET_PORT, 0 );
peer = RakPeerInterface::GetInstance();
peer->Startup( RAKNET_CONNECTIONS, sockdescr, 1, THREAD_PRIORITY_NORMAL );
peer->SetMaximumIncomingConnections( RAKNET_CONNECTIONS );
peer->SetIncomingPassword( MASTER_VERSION, sizeof( MASTER_VERSION ) );
Packet* packet;
while ( thread )
{
for ( packet = peer->Receive(); packet; peer->DeallocatePacket( packet ), packet = peer->Receive() )
{
switch ( packet->data[0] )
{
case ID_NEW_INCOMING_CONNECTION:
timestamp();
printf( "New incoming connection from %s\n", packet->systemAddress.ToString() );
break;
case ID_DISCONNECTION_NOTIFICATION:
timestamp();
printf( "Client disconnected (%s)\n", packet->systemAddress.ToString() );
RemoveServer( packet->systemAddress );
break;
case ID_CONNECTION_LOST:
timestamp();
printf( "Lost connection (%s)\n", packet->systemAddress.ToString() );
RemoveServer( packet->systemAddress );
break;
case ID_MASTER_QUERY:
{
BitStream query;
query.Write( ( MessageID ) ID_MASTER_QUERY );
query.Write( ( unsigned int ) serverList.size() );
for ( map<SystemAddress, ServerEntry>::iterator i = serverList.begin(); i != serverList.end(); ++i )
{
SystemAddress addr = i->first;
ServerEntry entry = i->second;
RakString name( entry.GetServerName().c_str() );
RakString map( entry.GetServerMap().c_str() );
int players = entry.GetServerPlayers().first;
int playersMax = entry.GetServerPlayers().second;
unsigned char game = entry.GetGame();
std::map<string, string> rules = entry.GetServerRules();
query.Write( addr );
query.Write( name );
query.Write( map );
query.Write( players );
query.Write( playersMax );
query.Write( game );
query.Write( ( int ) rules.size() );
for ( std::map<string, string>::iterator k = rules.begin(); k != rules.end(); ++k )
{
RakString key( k->first.c_str() );
RakString value( k->second.c_str() );
query.Write( key );
query.Write( value );
}
}
peer->Send( &query, HIGH_PRIORITY, RELIABLE, 0, packet->systemAddress, false, 0 );
timestamp();
printf( "Query processed (%s)\n", packet->systemAddress.ToString() );
break;
}
case ID_MASTER_UPDATE:
{
BitStream query( packet->data, packet->length, false );
query.IgnoreBytes( sizeof( MessageID ) );
SystemAddress addr;
query.Read( addr );
query.Reset();
map<SystemAddress, ServerEntry>::iterator i;
i = serverList.find( addr );
query.Write( ( MessageID ) ID_MASTER_UPDATE );
query.Write( addr );
if ( i != serverList.end() )
{
ServerEntry entry = i->second;
RakString name( entry.GetServerName().c_str() );
RakString map( entry.GetServerMap().c_str() );
int players = entry.GetServerPlayers().first;
int playersMax = entry.GetServerPlayers().second;
unsigned char game = entry.GetGame();
std::map<string, string> rules = entry.GetServerRules();
query.Write( name );
query.Write( map );
query.Write( players );
query.Write( playersMax );
query.Write( game );
query.Write( ( int ) rules.size() );
for ( std::map<string, string>::iterator k = rules.begin(); k != rules.end(); ++k )
{
RakString key( k->first.c_str() );
RakString value( k->second.c_str() );
query.Write( key );
query.Write( value );
}
}
peer->Send( &query, HIGH_PRIORITY, RELIABLE, 0, packet->systemAddress, false, 0 );
timestamp();
printf( "Update processed (%s)\n", packet->systemAddress.ToString() );
break;
}
case ID_MASTER_ANNOUNCE:
{
BitStream query( packet->data, packet->length, false );
query.IgnoreBytes( sizeof( MessageID ) );
bool announce;
query.Read( announce );
map<SystemAddress, ServerEntry>::iterator i;
i = serverList.find( packet->systemAddress );
if ( announce )
{
RakString name, map;
int players, playersMax, rsize;
unsigned char game;
query.Read( name );
query.Read( map );
query.Read( players );
query.Read( playersMax );
query.Read( game );
query.Read( rsize );
ServerEntry* entry;
if ( i == serverList.end() )
{
std::pair<std::map<SystemAddress, ServerEntry>::iterator, bool> k;
k = serverList.insert( pair<SystemAddress, ServerEntry>( packet->systemAddress, ServerEntry( name.C_String(), map.C_String(), pair<int, int>( players, playersMax ), 999, game ) ) );
entry = &( k.first )->second;
}
else
{
entry = &i->second;
entry->SetServerName( name.C_String() );
entry->SetServerMap( map.C_String() );
entry->SetServerPlayers( pair<int, int>( players, playersMax ) );
}
for ( int j = 0; j < rsize; j++ )
{
RakString key, value;
query.Read( key );
query.Read( value );
entry->SetServerRule( key.C_String(), value.C_String() );
}
}
else if ( i != serverList.end() )
serverList.erase( i );
timestamp();
printf( "Announce processed (%s)\n", packet->systemAddress.ToString() );
break;
}
}
}
RakSleep( 2 );
}
peer->Shutdown( 300 );
RakPeerInterface::DestroyInstance( peer );
return ( ( DWORD ) data );
}
HANDLE MasterServer::InitalizeRakNet()
{
HANDLE hMasterThread;
DWORD MasterID;
thread = true;
hMasterThread = CreateThread( NULL, 0, MasterThread, ( LPVOID ) 0, 0, &MasterID );
return hMasterThread;
}
| [
"[email protected]",
"[email protected]"
] | [
[
[
1,
16
],
[
18,
21
],
[
30,
31
],
[
33,
33
],
[
36,
36
],
[
39,
40
],
[
42,
42
],
[
230,
233
],
[
236,
236
],
[
238,
238
],
[
240,
240
],
[
242,
242
]
],
[
[
17,
17
],
[
22,
29
],
[
32,
32
],
[
34,
35
],
[
37,
38
],
[
41,
41
],
[
43,
229
],
[
234,
235
],
[
237,
237
],
[
239,
239
],
[
241,
241
]
]
] |
37d17c59b79808b8baee13518a8a4f3f568d2dc7 | 4ab592fb354f75b42181d5375d485031960aaa7d | /DES_GOBSTG/DES_GOBSTG/Class/Chat.cpp | 37cb61f4697eb4098b0dc6b4e6fa9d15ea540fa5 | [] | no_license | CBE7F1F65/cca610e2e115c51cef211fafb0f66662 | 806ced886ed61762220b43300cb993ead00949dc | b3cdff63d689e2b1748e9cd93cedd7e8389a7057 | refs/heads/master | 2020-12-24T14:55:56.999923 | 2010-07-23T04:24:59 | 2010-07-23T04:24:59 | 32,192,699 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,694 | cpp | #include "../header/Chat.h"
#include "../header/BGLayer.h"
#include "../header/Player.h"
#include "../header/Bullet.h"
#include "../header/Fontsys.h"
#include "../header/Main.h"
#include "../header/Process.h"
#include "../header/SpriteItemManager.h"
#include "../header/FrontDisplay.h"
#include "../header/FrontDisplayName.h"
#include "../header/Enemy.h"
#include "../header/EventZone.h"
#include "../header/GameInput.h"
Chat Chat::chatitem;
#define _CHAT_LINECHARACTER 34
Chat::Chat()
{
Clear();
for (int i=0; i<CHATTERMAX; i++)
{
chatter[i] = NULL;
}
}
Chat::~Chat()
{
}
bool Chat::IsChatting()
{
return chatting;
}
void Chat::Clear()
{
col = 0x00000000;
pushtimer = 0xff;
chatting = false;
chatinit = false;
timer = 0;
chati = 0;
}
void Chat::Init()
{
Release();
leftsprite = SpriteItemManager::CreateNullSprite();
rightsprite = SpriteItemManager::CreateNullSprite();
textbox = SpriteItemManager::CreateSpriteByName(SI_FRONT_TEXT);
}
void Chat::Release()
{
Clear();
for (int i=0; i<CHATTERMAX; i++)
{
if (chatter[i])
{
SpriteItemManager::FreeSprite(&chatter[i]);
}
}
}
void Chat::Render()
{
if (!IsChatting())
{
return;
}
for(int i = 0; i < CHATTERMAX-1; i++)
{
if (chatter[i])
{
SpriteItemManager::RenderSpriteEx(chatter[i], x[i], y[i], 0, 0.8f);
}
}
if (textbox)
{
SpriteItemManager::RenderSpriteEx(textbox, x[CHATTER_TEXTBOX], y[CHATTER_TEXTBOX], ARC(9000), 80.0f/(textbox->GetWidth()), 352.0f/(textbox->GetHeight()));
}
fschat.SetColor(0xffffffff, 0xffffffff, col, col);
fschat.Render(M_CLIENT_CENTER_X-160, M_CLIENT_CENTER_Y+148, FONTSYS_DEFAULT_SHADOW);
}
bool Chat::chat(BYTE ID, BYTE chatsprite, const char * _text)
{
timer++;
if(!chatting)
{
timer = 0;
return true;
}
if(GameInput::GetKey(0, KSI_FIRE))
{
if(pushtimer < M_PUSH_FIRST)
pushtimer++;
else if(pushtimer == M_PUSH_FIRST)
pushtimer = M_PUSH_FIRST - M_PUSH_SKIP;
}
else
{
pushtimer = 0;
}
if(GameInput::GetKey(0, KSI_FIRE, DIKEY_DOWN) || pushtimer == M_PUSH_FIRST || timer == M_NOPUSH_SKIP)
{
chatinit = false;
timer = 0;
chati++;
return true;
}
if(chatinit)
{
return false;
}
if (timer == 1)
{
if(chatsprite & CHATSPRITE_LEFT)
{
leftsprite->SetColor(0xffffffff);
rightsprite->SetColor(0x80ffffff);
textbox->SetColor(0xff3333ff);
SpriteItemManager::ptFace(ID, leftsprite);
// leftsprite->SetFlip(chatsprite & CHATSPRITE_LEFTFLIP, false);
SpriteItemManager::SetSpriteFlip(leftsprite, chatsprite & CHATSPRITE_LEFTFLIP);
}
else
{
leftsprite->SetColor(0x80ffffff);
rightsprite->SetColor(0xffffffff);
textbox->SetColor(0xffff3333);
SpriteItemManager::ptFace(ID, rightsprite);
// rightsprite->SetFlip(chatsprite & CHATSPRITE_RIGHTFLIP, false);
SpriteItemManager::SetSpriteFlip(rightsprite, chatsprite & CHATSPRITE_RIGHTFLIP);
}
int line = 0;
int tlength = strlen(_text);
for(WORD i=0;i<tlength+1;i++)
{
if(i!=0 && !(i%_CHAT_LINECHARACTER) && i < tlength-1)
{
text[i+line] = '\n';
line++;
}
text[i+line] = _text[i];
}
fschat.SignUp(text, 1.25f);
if(chatsprite & CHATSPRITE_LEFT)
{
col = 0xff6699ff;
}
else
{
col = 0xffff6666;
}
}
else if (timer == 16)
{
chatinit = true;
}
else
{
float timerscale = timer/16.0f;
if (chatsprite & CHATSPRITE_LEFT)
{
x[CHATTER_LEFT] = INTER(x[CHATTER_LEFT], M_GAMESQUARE_CENTER_X_(0)+40, timerscale);
x[CHATTER_RIGHT] = INTER(x[CHATTER_RIGHT], M_GAMESQUARE_CENTER_X_(1), timerscale);
}
else
{
x[CHATTER_LEFT] = INTER(x[CHATTER_LEFT], M_GAMESQUARE_CENTER_X_(0), timerscale);
x[CHATTER_RIGHT] = INTER(x[CHATTER_RIGHT], M_GAMESQUARE_CENTER_X_(1)-40, timerscale);
}
}
return false;
}
bool Chat::chatOn(BYTE leftID, BYTE rightID, BYTE chatsprite)
{
timer++;
for (int i=0; i<M_PL_MATCHMAXPLAYER; i++)
{
Player::p[i].SetInfi(PLAYERINFI_CHAT);
}
chatinit = false;
if(timer == 1)
{
pushtimer = 0xff;
strcpy(text, "");
fschat.SignUp(text, 1.25f);
for (int i=0; i<M_PL_MATCHMAXPLAYER; i++)
{
EventZone::Build(EVENTZONE_TYPE_BULLETFADEOUT|EVENTZONE_CHECKTYPE_CIRCLE, i, Player::p[i].x, Player::p[i].y);
// Bullet::IzeBuild(i, BULLETIZE_FAITH, Player::p[i].x, Player::p[i].y);
}
chatting = true;
if (leftID != 0xff)
{
SpriteItemManager::ptFace(leftID, leftsprite);
// leftsprite->SetFlip(chatsprite & CHATSPRITE_LEFTFLIP, false);
SpriteItemManager::SetSpriteFlip(leftsprite, chatsprite & CHATSPRITE_LEFTFLIP);
}
else
{
SpriteItemManager::ptFace(-1, leftsprite);
}
if (rightID != 0xff)
{
SpriteItemManager::ptFace(rightID, rightsprite);
// rightsprite->SetFlip(chatsprite & CHATSPRITE_RIGHTFLIP, false);
SpriteItemManager::SetSpriteFlip(rightsprite, chatsprite & CHATSPRITE_RIGHTFLIP);
}
else
{
SpriteItemManager::ptFace(-1, rightsprite);
}
if (chatsprite & CHATSPRITE_LEFT)
{
textbox->SetColor(0xff3333ff);
}
else
{
textbox->SetColor(0xffff3333);
}
chati = 0;
}
if(timer <= 36)
{
float timerscale = timer / 36.0f;
x[CHATTER_LEFT] = INTER(M_CLIENT_LEFT-192, M_GAMESQUARE_CENTER_X_(0), timerscale);
y[CHATTER_LEFT] = INTER(M_CLIENT_BOTTOM, M_CLIENT_CENTER_Y+108, timerscale);
x[CHATTER_RIGHT] = INTER(M_CLIENT_RIGHT+192, M_GAMESQUARE_CENTER_X_(1), timerscale);
y[CHATTER_RIGHT] = INTER(M_CLIENT_BOTTOM, M_CLIENT_CENTER_Y+108, timerscale);
if(chatsprite & CHATSPRITE_LEFT)
{
rightsprite->SetColor(0x80ffffff);
}
else
{
leftsprite->SetColor(0x80ffffff);
}
x[CHATTER_TEXTBOX] = M_CLIENT_CENTER_X;
y[CHATTER_TEXTBOX] = M_CLIENT_BOTTOM+72-timer*4;
}
else
{
/*
if (leftID != 0xff)
{
x[CHATTER_LEFTNAME] = M_GAMESQUARE_CENTER_X_(0);
y[CHATTER_LEFTNAME] = M_CLIENT_CENTER_Y+108;
}
if (rightID != 0xff)
{
x[CHATTER_RIGHTNAME] = M_GAMESQUARE_CENTER_X_(1);
y[CHATTER_RIGHTNAME] = M_CLIENT_CENTER_Y+108;
}
match(CHATTER_LEFTNAME, leftsprite);
match(CHATTER_RIGHTNAME, rightsprite);
*/
timer = 0;
chati = 1;
return true;
}
return false;
}
bool Chat::chatOff()
{
timer++;
if(timer <= 32)
{
x[CHATTER_LEFT] -= timer * 15;
x[CHATTER_RIGHT] += timer * 15;
y[CHATTER_TEXTBOX] += timer * 4;
}
else
{
for (int i=0; i<M_PL_MATCHMAXPLAYER; i++)
{
Player::p[i].SetInfi(PLAYERINFI_CHAT, PLAYER_INFIUNSET);
}
timer = 0;
chatting = false;
chati = 0;
return true;
}
return false;
} | [
"CBE7F1F65@4a173d03-4959-223b-e14c-e2eaa5fc8a8b"
] | [
[
[
1,
302
]
]
] |
b025ede6531e1d1e0832c714f95f231503027958 | 6c8c4728e608a4badd88de181910a294be56953a | /CommunicationModule/TelepathyIM/ConnectionProvider.cpp | 195ac1f04b0bd357b103ce952a469b6eb13d8e1b | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | caocao/naali | 29c544e121703221fe9c90b5c20b3480442875ef | 67c5aa85fa357f7aae9869215f840af4b0e58897 | refs/heads/master | 2021-01-21T00:25:27.447991 | 2010-03-22T15:04:19 | 2010-03-22T15:04:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,687 | cpp | // For conditions of distribution and use, see copyright notice in license.txt
#include "StableHeaders.h"
#include "DebugOperatorNew.h"
#include <QtCore>
#include <QApplication>
#include <TelepathyQt4/Types>
#include <TelepathyQt4/PendingReady>
#include "ConnectionProvider.h"
#include "FarsightChannel.h"
#include <Poco/Environment.h>
#include "CoreDefines.h"
#include "CoreException.h"
#include "MemoryLeakCheck.h"
// #include <TelepathyQt4/Debug__> // disabled because header not found on Linux
namespace TelepathyIM
{
ConnectionProvider::ConnectionProvider(Foundation::Framework* framework): framework_(framework), dbus_daemon_(NULL), state_(STATE_INITIALIZING)
{
#ifdef WIN32
// We want to start dbus daemon only on Windows platform
InitializeDBusAndGabble();
InitializeGLib();
InitializeGStreamer();
StartGMainLoop();
#else
InitializeTelepathyConnectionManager("gabble");
#endif
}
void ConnectionProvider::StartGMainLoop()
{
g_main_loop_.start();
g_main_loop_.setPriority(QThread::NormalPriority);
}
void ConnectionProvider::InitializeGLib()
{
g_type_init();
}
void ConnectionProvider::InitializeGStreamer()
{
std::string fs_plugin_path = Poco::Path::current();
fs_plugin_path.append("gstreamer\\lib\\farsight2-0.0");
Poco::Environment::set("FS_PLUGIN_PATH", fs_plugin_path);
QString gst_plugin_path = QString(Poco::Path::current().c_str()).append("gstreamer\\lib\\gstreamer-0.10");
Poco::Environment::set("GST_PLUGIN_PATH", gst_plugin_path.toStdString().c_str());
const int ARGC = 5;
QString arg_gst_plugin_path(QString("--gst-plugin-path=").append(gst_plugin_path).append(""));
QString arg_gst_disable_registry_update("--gst-disable-registry-update");
QString arg_gst_disable_registry_fork("--gst-disable-registry-fork");
int argc = ARGC;
char* argv[ARGC];
std::string args[ARGC];
args[0] = ""; // first argument will be ignored
args[1] = arg_gst_plugin_path.toStdString();
args[2] = ""; //arg_gst_disable_registry_update.toStdString();
args[3] = arg_gst_disable_registry_fork.toStdString();
args[4] = ""; // "--gst-debug-level=3"; //arg_gst_disable_registry_fork.toStdString();
for (int i=0; i < ARGC; ++i)
{
argv[i] = (char*)args[i].c_str();
QString message = QString("gstreamer init arg: ").append(QString(args[i].c_str()));
LogDebug(message.toStdString());
}
char** p_argv = &argv[0];
GError error;
GError *p_error = &error;
if (!gst_init_check(&argc, &p_argv, &p_error))
{
QString error_message("Cannot initialize GStreamer: ");
error_message.append(p_error->message);
LogError(error_message.toStdString());
return;
}
guint major, minor, micro, nano;
gst_version (&major, &minor, µ, &nano);
QString text;
text.sprintf("GStreamer version %i.%i.%i.%i initialized.", major, minor, micro, nano);
LogInfo(text.toStdString());
}
void ConnectionProvider::InitializeDBusAndGabble()
{
// this will start signal&slot chain that will kill gabble and start
// dbus-daemon and gabble processes
ClearGabble();
}
ConnectionProvider::~ConnectionProvider()
{
DeleteConnections();
// We want to stop dbus daemon only on Windows platform
#ifdef WIN32
StopDBusDaemon();
g_main_loop_.StopLoop();
g_main_loop_.wait();
#endif
}
void ConnectionProvider::DeleteConnections()
{
for (ConnectionVector::iterator i = connections_.begin(); i != connections_.end(); ++i)
{
Connection* connection = *i;
//! @todo Check that there is enough time to actual close the connection to servers
connection->Close(); // <--- CRASH HERE when login is failed
SAFE_DELETE(connection);
}
connections_.clear();
}
QStringList ConnectionProvider::GetSupportedProtocols() const
{
return supported_protocols_;
}
Communication::ConnectionInterface* ConnectionProvider::OpenConnection(const Communication::CredentialsInterface& credentials)
{
if (state_ != STATE_READY)
{
LogError("Cannot open IM connection because Telepathy IM connection provider is not ready.");
throw Exception("Telepathy IM connection provider is not ready.");
}
Connection* connection = new Connection(tp_connection_manager_, credentials);
connections_.push_back(connection);
//! @todo FIX THESE
//connect(connection, SIGNAL( ConnectionReady(Communication::ConnectionInterface&) ), SLOT( OnConnectionReady(Communication::ConnectionInterface&) ));
//connect(connection, SIGNAL( ConnectionClosed(Communication::ConnectionInterface&) ), SLOT( OnConnectionClosed(Communication::ConnectionInterface&) ));
//connect(connection, SIGNAL( ConnectionError(Communication::ConnectionInterface&) ), SLOT( OnConnectionError(Communication::ConnectionInterface&) ));
return connection;
}
Communication::ConnectionVector ConnectionProvider::GetConnections() const
{
Communication::ConnectionVector v;
for (ConnectionVector::const_iterator i = connections_.begin(); i != connections_.end(); ++i)
{
Connection* connection = *i;
v.push_back(connection);
}
return v;
}
bool ConnectionProvider::SupportProtocol(QString &protocol) const
{
return supported_protocols_.contains(protocol);
}
void ConnectionProvider::StartDBusDaemon()
{
QString path = "dbus\\dbus-daemon.exe";
QString arguments = "--config-file=data\\session.conf";
dbus_daemon_ = new QProcess(this);
QStringList env = QProcess::systemEnvironment();
QString env_item = "DBUS_SESSION_BUS_ADDRESS=tcp:host=127.0.0.1,port=";
env_item.append( QString(DBUS_SESSION_PORT_, 10));
env << env_item;
dbus_daemon_->setEnvironment(env);
connect( dbus_daemon_, SIGNAL(readyReadStandardOutput()), SLOT(OnDBusDaemonStdout()) );
connect( dbus_daemon_, SIGNAL(finished(int)), SLOT(OnDBusDaemonExited(int)) );
QString command = path.append(" ").append(arguments);
dbus_daemon_->start(command);
bool ok = dbus_daemon_->waitForStarted(500);
if (!ok)
{
LogError("Cannot start dbus daemon process.");
throw Exception("Cannot start up dbus daemon process.");
}
LogDebug("DBus daemon is started.");
// wait some time so that dbus daemon have a time to start up properly
QTime wait_time = QTime::currentTime().addSecs(1);
while( QTime::currentTime() < wait_time )
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
InitializeTelepathyConnectionManager("gabble");
}
void ConnectionProvider::ClearGabble()
{
connect(&kill_old_gabble_, SIGNAL( finished(int, QProcess::ExitStatus) ), SLOT(ClearDBusDaemon() ));
connect(&kill_old_gabble_, SIGNAL( error(QProcess::ProcessError) ), SLOT(ClearDBusDaemon() ));
LogDebug("Try to kill gabble.exe process.");
kill_old_gabble_.start("taskkill /F /FI \"IMAGENAME eq gabble.exe");
}
void ConnectionProvider::ClearDBusDaemon()
{
connect(&kill_old_dbusdaemon_, SIGNAL( finished(int, QProcess::ExitStatus) ), SLOT(StartDBusDaemon() ));
connect(&kill_old_dbusdaemon_, SIGNAL( error(QProcess::ProcessError) ), SLOT(StartDBusDaemon() ));
LogDebug("Try to kill dbus-daemon.exe processs");
kill_old_dbusdaemon_.start("taskkill /F /FI \"IMAGENAME eq dbus-daemon.exe");
}
void ConnectionProvider::StopDBusDaemon()
{
if (dbus_daemon_)
{
dbus_daemon_->kill(); // terminate seems not to be enough
bool ok = dbus_daemon_->waitForFinished(1000);
if (!ok)
{
LogError("Cannot terminate dbus daemon process.");
return;
}
SAFE_DELETE(dbus_daemon_);
}
}
//! @todo support more that one connection manager
//! current implementation uses only gabble
void ConnectionProvider::InitializeTelepathyConnectionManager(const QString &name)
{
Tp::registerTypes();
qRegisterMetaType<TelepathyIM::FarsightChannel::Status>(); // for streamed media
tp_connection_manager_ = Tp::ConnectionManager::create(name);
connect(tp_connection_manager_->becomeReady(Tp::ConnectionManager::FeatureCore), SIGNAL( finished(Tp::PendingOperation *) ), SLOT( OnConnectionManagerReady(Tp::PendingOperation*) ));
}
void ConnectionProvider::OnConnectionManagerReady(Tp::PendingOperation *op)
{
if (op->isError())
{
std::string message = "Cannot initialize Telepathy ConnectionManager object: ";
message.append( op->errorMessage().toStdString() );
LogError( message );
QString reason;
reason.append(message.c_str());
state_ = STATE_ERROR;
return;
}
LogInfo("Telepathy connection provider is ready.");
state_ = STATE_READY;
supported_protocols_.append("jabber");
emit( ProtocolListUpdated(supported_protocols_) );
}
void ConnectionProvider::OnDBusDaemonStdout()
{
QString output = QString(dbus_daemon_->readAllStandardOutput());
output = output.midRef(0, 1000).toString();
LogDebug(QString("DBus daemon: ").append(output).toStdString());
}
void ConnectionProvider::OnDBusDaemonExited( int )
{
LogDebug("DBus daemon is exited.");
}
void ConnectionProvider::OnConnectionReady(Communication::ConnectionInterface &connection)
{
}
void ConnectionProvider::OnConnectionClosed(Communication::ConnectionInterface &connection)
{
}
void ConnectionProvider::OnConnectionError(Communication::ConnectionInterface &connection)
{
}
} // end of namespace: TelepathyIM
| [
"jonnenau@5b2332b8-efa3-11de-8684-7d64432d61a3",
"jujjyl@5b2332b8-efa3-11de-8684-7d64432d61a3",
"mattiku@5b2332b8-efa3-11de-8684-7d64432d61a3",
"[email protected]@5b2332b8-efa3-11de-8684-7d64432d61a3",
"Stinkfist0@5b2332b8-efa3-11de-8684-7d64432d61a3",
"[email protected]@5b2332b8-efa3-11de-8684-7d64432d61a3",
"[email protected]@5b2332b8-efa3-11de-8684-7d64432d61a3"
] | [
[
[
1,
3
],
[
5,
5
],
[
262,
262
]
],
[
[
4,
4
],
[
13,
14
],
[
16,
17
]
],
[
[
6,
11
],
[
15,
15
],
[
18,
21
],
[
24,
24
],
[
26,
28
],
[
30,
30
],
[
32,
32
],
[
34,
34
],
[
41,
47
],
[
74,
78
],
[
80,
97
],
[
101,
101
],
[
103,
103
],
[
107,
107
],
[
109,
109
],
[
114,
114
],
[
117,
117
],
[
151,
151
],
[
156,
161
],
[
166,
166
],
[
185,
186
],
[
191,
192
],
[
194,
198
],
[
200,
206
],
[
208,
210
],
[
222,
222
],
[
225,
225
],
[
231,
233
],
[
261,
261
],
[
263,
263
],
[
265,
265
],
[
268,
268
],
[
270,
270
],
[
273,
273
],
[
275,
275
],
[
278,
278
],
[
280,
280
],
[
283,
283
],
[
285,
286
]
],
[
[
12,
12
],
[
48,
51
],
[
102,
102
],
[
106,
106
]
],
[
[
22,
23
],
[
25,
25
],
[
31,
31
],
[
33,
33
],
[
98,
100
],
[
104,
104
],
[
108,
108
],
[
110,
113
],
[
115,
116
],
[
118,
150
],
[
152,
155
],
[
162,
165
],
[
167,
167
],
[
169,
184
],
[
187,
190
],
[
193,
193
],
[
199,
199
],
[
207,
207
],
[
211,
221
],
[
223,
224
],
[
226,
230
],
[
234,
260
],
[
264,
264
],
[
266,
267
],
[
269,
269
],
[
271,
272
],
[
274,
274
],
[
276,
277
],
[
279,
279
],
[
281,
282
],
[
284,
284
]
],
[
[
29,
29
],
[
35,
40
],
[
52,
73
],
[
105,
105
],
[
168,
168
]
],
[
[
79,
79
]
]
] |
e607deaf3846751b5c07e03d7bea4e8c5c38d618 | 28b0332fabba904ac0668630f185e0ecd292d2a1 | /src/Gcc/UnitTest.cpp | 2922ba4d02375706f14748bec1b0c7cceb62ad78 | [] | no_license | iplayfast/crylib | 57a507ba996d1abe020f93ea4a58f47f62b31434 | dbd435e14abc508c31d1f2f041f8254620e24dc0 | refs/heads/master | 2016-09-05T10:33:02.861605 | 2009-04-19T05:17:55 | 2009-04-19T05:17:55 | 35,353,897 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,682 | cpp | #include <stdio.h>
#include "ClassString.h"
#include "CryBackProp.h"
#include "CryFuzzy.h"
#include "HugeInt.h"
#include "CrySet.h"
using namespace Crystal;
//---------------------------------------------------------------------------
bool/* __cdecl */FormCallBack(bool Verbose,const char *Result,bool fail)
{
String s;
s.printf("%s %s",Result,fail ? "Fail" : "Pass");
printf("%s",s.AsPChar());
if (fail)
{
return false;
}
return true;
}
void StringTest()
{
try
{
String a;
a.Test(true,a,FormCallBack);
}
catch(Exception &E)
{
String s;
s ="Exception Caught: ";
s += E;
printf("%s",s.AsPChar());
}
}
//---------------------------------------------------------------------------
void BackPropTest()
{
try
{
BPNetContainer bp;
#ifdef VALIDATING
bp.Test(true,bp,FormCallBack);
#endif
}
catch(Exception &E)
{
String s;
s ="Exception Caught: ";
s += E;
printf("%s",s.AsPChar());
}
}
//---------------------------------------------------------------------------
void TemplateTest()
{
try
{
TArray<int> a;
#ifdef VALIDATING
a.Test(true,a,FormCallBack);
#endif
}
catch(Exception &E)
{
String s;
s ="Exception Caught: ";
s += E;
printf("%s",s.AsPChar());
}
}
//---------------------------------------------------------------------------
void SetTest()
{
try
{
CrySet a;
a.Test(true,a,FormCallBack);
}
catch(Exception &E)
{
String s;
s ="Exception Caught: ";
s += E;
printf("%s",s.AsPChar());
}
}
//---------------------------------------------------------------------------
int main(int argc,char *argv[])
{
SetTest();
TemplateTest();
StringTest();
}
| [
"cwbruner@f8ea3247-a519-0410-8bc2-439d413616df"
] | [
[
[
1,
101
]
]
] |
e5e05afa8bfcfc59063c044bfa0e185b3eb3fef4 | 60b362ba672a29bedf3d44abf11138dd71742c5d | /project/start/ex5-Project/Bomb.cpp | 8f4b676ebb0d5a90d551e0d072f3eff7502d4fd0 | [] | no_license | AndreyShamis/oop1 | 9e04882ab6969cc542e99422b84114157d4b20f3 | 861da0e7a70eba21e4b7ee39e355c21a864ce8b1 | refs/heads/master | 2016-09-06T14:15:47.867525 | 2011-03-16T22:20:04 | 2011-03-16T22:20:04 | 32,789,848 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,192 | cpp | #include "Bomb.h"
//=============================================================================
// Class constructor
Bomb::Bomb()
{
_sprite.push_back(BOMB_STEP_ONE);
_sprite.push_back(BOMB_STEP_TWO);
_sprite.push_back(BOMB_BEFOR);
_movable = false;
_timer = 25;
setSize();
}
//=============================================================================
Bomb::~Bomb()
{
_sprite.clear();
}
//=============================================================================
short int Bomb::getTimer()
{
return(_timer);
}
//=============================================================================
void Bomb::IncereaseTimer()
{
_timer+=BOMB_TIMER_INCREASER;
}
//=============================================================================
void Bomb::Draw()
{
if(_sprite.size() > 0)
{
vector <Sprite>::iterator it;
if(_timer > 20)
it = _sprite.begin();
else if(_timer> 10)
it = _sprite.begin()+1;
else
it = _sprite.begin()+2;
if(_timer >=0)
{
it->Draw(_cord);
}
}
}
//=============================================================================
void Bomb::decTimer()
{
_timer--;
}
| [
"[email protected]@915c7e4a-0830-d67a-7742-9bd6d4e428b7"
] | [
[
[
1,
59
]
]
] |
c46f68aedeaa994b91aaf32fc88f15945ca698f0 | 741b36f4ddf392c4459d777930bc55b966c2111a | /incubator/deeppurple/lwplugins/lwwrapper/PluginTemplates/CustomObject_Adaptor.h | 15ced7cdb146f0d7370671069cb717af0d5be78f | [] | no_license | BackupTheBerlios/lwpp-svn | d2e905641f60a7c9ca296d29169c70762f5a9281 | fd6f80cbba14209d4ca639f291b1a28a0ed5404d | refs/heads/master | 2021-01-17T17:01:31.802187 | 2005-10-16T22:12:52 | 2005-10-16T22:12:52 | 40,805,554 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,792 | h | #ifndef CUSTOMOBJECT_ADAPTOR_INCLUDED
#define CUSTOMOBJECT_ADAPTOR_INCLUDED
#include "HandlerItemRend.h"
#include "../../lwinclude/lwcustobj.h"
/**
* Template class for the creation of Custom Object Plugins.
* @author David Forstenlechner
* @date 2002-2003
*/
template <class T> class CustomObject_Adaptor :
public HandlerItemRend<T>
{
public:
CustomObject_Adaptor(const char *name, ServerTagInfo *srvinfo);
virtual ~CustomObject_Adaptor();
static void Evaluate_Callback(LWInstance inst, const LWCustomObjAccess *ca);
static unsigned int Flags_Callback( LWInstance inst );
static int CustomObject_Callback( long version, GlobalFunc *global, void *INlocal, void *serverData );
};
template <class T>
CustomObject_Adaptor<T>::CustomObject_Adaptor(const char *name, ServerTagInfo *srvinfo)
: HandlerItemRend<T>( LWCUSTOMOBJ_HCLASS, name, CustomObject_Callback, srvinfo ) {}
template <class T>
CustomObject_Adaptor<T>::~CustomObject_Adaptor() {}
template <class T>
void CustomObject_Adaptor<T>::Evaluate_Callback(LWInstance inst, const LWCustomObjAccess *ca) { ((T*)inst)->Evaluate(ca); }
template <class T>
unsigned int CustomObject_Adaptor<T>::Flags_Callback( LWInstance inst ) { return ((T*)inst)->Flags(); }
template <class T>
int CustomObject_Adaptor<T>::CustomObject_Callback( long version, GlobalFunc *global, void *INlocal, void *serverData )
{
if ( version != LWCUSTOMOBJ_VERSION )
return AFUNC_BADVERSION;
LWCustomObjHandler *local=(LWCustomObjHandler *)INlocal;
local->evaluate = Evaluate_Callback;
local->flags = Flags_Callback;
return HandlerItemRend_Callback( global, local->inst, local->item, local->rend );
}
#endif // CUSTOMOBJECT_ADAPTOR_INCLUDED
| [
"deeppurple@dac1304f-7ce9-0310-a59f-f2d444f72a61"
] | [
[
[
1,
57
]
]
] |
116d5862098ebbe98150a3759904dca4ff4170fc | 216398e30aca5f7874edfb8b72a13f95c22fbb5a | /AITerm/src/AITerm/WNDictionary.cpp | 2e1be63de2327bfbd509e4a0308502c8facb183f | [] | no_license | markisme/healthcare | 791813ac6ac811870f3f28d1d31c3d5a07fb2fa2 | 7ab5a959deba02e7637da02a3f3c681548871520 | refs/heads/master | 2021-01-10T07:18:42.195610 | 2009-09-09T13:00:10 | 2009-09-09T13:00:10 | 35,987,767 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 6,714 | cpp | #include "stdafx.h"
#include "WNDictionary.h"
WNDictionary::WNDictionary()
{
}
WNDictionary::~WNDictionary()
{
}
void WNDictionary::Init()
{
// 워드넷 초기화
wninit();
_synsetPtr=(Synset *)malloc(sizeof(Synset));
memset( _synsetPtr, 0, sizeof(_synsetPtr));
// 사전 초기화
_dic.clear();
// 사전 생성 옵션 로드
XmlDocument xmlDoc;
std::string path = "./resource/WNDicConfig.xml";
xmlDoc.LoadFile( path.c_str() );
const XmlNode * resNode = xmlDoc.GetNode( "resource" );
std::string create = resNode->GetAttribute( "create" );
if( create == "true" )
{
// 사전 생성
CreateWNDic( resNode );
// 사전 저장
XmlDocument xmlDoc;
XmlNode * resNode = xmlDoc.AddNode( "resource" );
SaveToXML( resNode );
std::string path = "./resource/WNDic.xml";
xmlDoc.SaveFile( path.c_str() );
}
else
{
// 사전 로드
XmlDocument xmlDoc;
std::string path = "./resource/WNDic.xml";
xmlDoc.LoadFile( path.c_str() );
const XmlNode * resNode = xmlDoc.GetNode( "resource" );
LoadFromXML( resNode );
}
}
void WNDictionary::Uninit()
{
// 사전 초기화
_dic.clear();
}
bool WNDictionary::CreateWNDic( const XmlNode * resNode )
{
int nodeCount = resNode->GetNodeCount( "tag" );
for( int num = 0; num < nodeCount; num++ )
{
const XmlNode * tagNode = resNode->GetNode( "tag", num );
std::string tagName = tagNode->GetAttribute( "name" );
TagDataForDic tagDataList;
tagDataList._tagName = tagName;
int nodeCount = tagNode->GetNodeCount( "keyword" );
for( int cnt = 0; cnt < nodeCount; cnt++ )
{
const XmlNode * keywordNode = tagNode->GetNode( "keyword", cnt );
std::string keyword = keywordNode->GetAttribute( "name" );
std::string sense = keywordNode->GetAttribute( "sense" );
// sense 0 인경우 워드넷 참조 안함
if( sense == "0" )
{
tagDataList._dataList.push_back( keyword );
continue;
}
// 0 이 아닌 경우엔 워드넷 참조
if( ( _synsetPtr = GetSynset( keyword ) ) == NULL )
{
perror("serach failure\n");
continue;
}
// 동의어 추가
for( int i=0; i<_synsetPtr->wcount; i++)
{
std::string word = (*(_synsetPtr->words)++);
tagDataList._dataList.push_back( word );
}
// 상위어 추가
while( ( _synsetPtr= _synsetPtr->ptrlist ) != NULL )
{
for( int i=0; i<_synsetPtr->wcount; i++)
{
std::string word = (*(_synsetPtr->words)++);
tagDataList._dataList.push_back( word );
}
}
}
_dic.push_back( tagDataList );
}
return true;
}
bool WNDictionary::LoadFromXML( const XmlNode * resNode )
{
int nodeCount = resNode->GetNodeCount( "tag" );
for( int num = 0; num < nodeCount; num++ )
{
const XmlNode * tagNode = resNode->GetNode( "tag", num );
std::string tagName = tagNode->GetAttribute( "name" );
TagDataForDic tagDataList;
tagDataList._tagName = tagName;
int keyCount = tagNode->GetNodeCount( "keyword" );
for( int cnt = 0; cnt < keyCount; cnt++ )
{
const XmlNode * keyNode = tagNode->GetNode( "keyword", cnt );
std::string keyword = keyNode->GetAttribute( "name" );
tagDataList._dataList.push_back( keyword );
}
_dic.push_back( tagDataList );
}
return true;
}
bool WNDictionary::SaveToXML( XmlNode * resNode )
{
int size = _dic.size();
for( int num = 0; num < size; num++ )
{
TagDataForDic tagDataList = _dic[num];
std::string tagName = tagDataList._tagName;
XmlNode * tagNode = resNode->AddNode( "tag" );
tagNode->SetAttribute( "name", tagName.c_str() );
int dataSize = tagDataList._dataList.size();
for( int cnt = 0; cnt < dataSize; cnt++ )
{
std::string word = tagDataList._dataList[ cnt ];
XmlNode * keywordNode = tagNode->AddNode( "keyword" );
keywordNode->SetAttribute( "name", word.c_str() );
}
}
return true;
}
int WNDictionary::GetTagName( const std::vector<std::string> & inDataList, std::string & outTagName, std::string & outWords )
{
// 날짜 / 시간
// 숫자
if( IsNumber( (std::string)inDataList[0] ) == true )
{
outTagName = "number";
outWords = inDataList[0];
return 0;
}
// 단어인 경우
int size = _dic.size();
for( int num = 0; num < size; num++ )
{
std::string tag = _dic[ num ]._tagName;
int dataSize = _dic[ num ]._dataList.size();
for( int cnt = 0; cnt < dataSize; cnt++ )
{
std::string data = _dic[ num ]._dataList[ cnt ];
std::string word = ToLowerCase( (char*)data.c_str() );
int count = IsSameWords( inDataList, word, outWords );
if( count >= 0 )
{
outTagName = tag;
return count;
}
}
}
return 0;
}
int WNDictionary::IsSameWords( const std::vector<std::string> & lWordList, std::string rWord, std::string & outWords )
{
// 연속된 단어 비교
std::string words;
int count = lWordList.size();
for( int num = 0; num < count; num++ )
{
std::string word = lWordList[ num ];
if( words.length() > 0 )
{
char prefix = words[words.length()-1];
if( word == "-" || prefix == '-')
{
words += word;
}
else
{
words += " ";
words += word;
}
}
else
{
words = word;
}
if( words == rWord )
{
outWords = words;
return num;
}
}
std::string lWord = lWordList[ 0 ];
//
int length = lWord.size();
if( length < 3 )
{
return -1;
}
// 복수 비교 (s)
if( lWord[length-1] == 's' )
{
lWord.erase(length-1);
if( lWord == rWord )
{
outWords = lWord;
return 0;
}
}
// 복수 비교 (es)
if( lWord[length-1] == 's' && lWord[length-2] == 'e' )
{
lWord.erase(length-1);
lWord.erase(length-2);
if( lWord == rWord )
{
outWords = lWord;
return 0;
}
}
return -1;
}
bool WNDictionary::IsNumber( const std::string & inData )
{
int num = atoi( inData.c_str() );
if( num > 0 || inData == "0" )
{
return true;
}
return false;
}
Synset * WNDictionary::GetSynset( std::string keyword )
{
Synset * synsetPtr = NULL;
if( (synsetPtr= findtheinfo_ds( (char*)keyword.c_str(), NOUN, HYPERPTR, ALLSENSES )) != NULL )
{
return synsetPtr;
}
if( (synsetPtr= findtheinfo_ds( (char*)keyword.c_str(), VERB, HYPERPTR, ALLSENSES )) != NULL )
{
return synsetPtr;
}
if( (synsetPtr= findtheinfo_ds( (char*)keyword.c_str(), ADJ, HYPERPTR, ALLSENSES )) != NULL )
{
return synsetPtr;
}
if( (synsetPtr= findtheinfo_ds( (char*)keyword.c_str(), ADV, HYPERPTR, ALLSENSES )) != NULL )
{
return synsetPtr;
}
return synsetPtr;
} | [
"naidzzang@cc586c1e-b153-0410-8069-cfc9d6f95ec9"
] | [
[
[
1,
309
]
]
] |
7f2546ab7e98e45eb5230ab867a6a28b7db8ed02 | a36d7a42310a8351aa0d427fe38b4c6eece305ea | /mybilliard01/MyEffectShaderFeederImp.cpp | 22919a8f33636fab9e2d5cde4b95918ccb87aad1 | [] | no_license | newpolaris/mybilliard01 | ca92888373c97606033c16c84a423de54146386a | dc3b21c63b5bfc762d6b1741b550021b347432e8 | refs/heads/master | 2020-04-21T06:08:04.412207 | 2009-09-21T15:18:27 | 2009-09-21T15:18:27 | 39,947,400 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,352 | cpp | #include "StdAfx.h"
#include "my_app.h"
MyEffectShaderFeederImp::MyEffectShaderFeederImp( bool bShared )
: RenderMonkeySemanticFeeder( bShared )
{
}
void MyEffectShaderFeederImp::updateProjection_shadowMap( size_t index, const RowMajorMatrix44f & matProj ) {
shadowMaps_.at( index ).matProj_ = matProj;
MY_FOR_EACH( ShadowMapSemantic::ActiveSemantics, iter, shadowMaps_.at( index ).activeSemantics_proj_ )
uploadShadowMapValue( index, *iter );
}
void MyEffectShaderFeederImp::updateView_shadowMap(
size_t index,
const NxVec3 & lightPos,
const NxVec3 & lightDir,
const RowMajorMatrix44f & matView,
const RowMajorMatrix44f & matProjView )
{
shadowMaps_.at( index ).lightPos_ = lightPos;
shadowMaps_.at( index ).lightDir_ = lightDir;
shadowMaps_.at( index ).matView_ = matView;
shadowMaps_.at( index ).matProjView_ = matProjView;
MY_FOR_EACH( ShadowMapSemantic::ActiveSemantics, iter, shadowMaps_.at( index ).activeSemantics_view_ )
uploadShadowMapValue( index, *iter );
}
void MyEffectShaderFeederImp::updateModelMatrix( const RowMajorMatrix44f & matWorld )
{
RenderMonkeySemanticFeeder::updateModelMatrix( matWorld );
matWorld_ = matWorld;
for( size_t index = 0; index < shadowMaps_.size(); ++index )
MY_FOR_EACH( ShadowMapSemantic::ActiveSemantics, iter, shadowMaps_.at( index ).activeSemantics_world_ )
uploadShadowMapValue( index, *iter );
}
void MyEffectShaderFeederImp::uploadShadowMapValue( size_t index, int whichSemantic )
{
ShadowMapSemantic * const shadowMap = &( shadowMaps_[ index ] );
float floatArray[ 16 ];
size_t countOfFloat = 16;
switch( whichSemantic )
{
case Position:
memcpy( (void*) floatArray, (void*) shadowMap->lightPos_.get(), sizeof( float ) * 3 );
floatArray[ 3 ] = 1.f;
countOfFloat = 4;
break;
case DIrection:
memcpy( (void*) floatArray, (void*) shadowMap->lightDir_.get(), sizeof( float ) * 3 );
floatArray[ 3 ] = 0.f;
countOfFloat = 4;
break;
case World: matWorld_.GetColumnMajor( floatArray ); break;
case View: shadowMap->matView_.GetColumnMajor( floatArray ); break;
case Projection: shadowMap->matProj_.GetColumnMajor( floatArray ); break;
case WorldView: (shadowMap->matView_ * matWorld_).GetColumnMajor( floatArray ); break;
case ViewProjection: shadowMap->matProjView_.GetColumnMajor( floatArray ); break;
case WorldViewProjection: (shadowMap->matProjView_ * matWorld_).GetColumnMajor( floatArray ); break;
}
shadowMap->shaderVariables_[ whichSemantic ]->setFloatArray( floatArray, countOfFloat );
}
void MyEffectShaderFeederImp::initShadowMapSemantics( EffectShader * effect )
{
#define INIT_SEMANTIC( INDEX, SEMANTIC, WHERETO ) \
{ wstringstream semanticName; \
semanticName << L"Light" << setw( 2 ) << setfill< wchar_t >( '0' ) << INDEX << L"_" << L#SEMANTIC; \
if( getEffectShader()->hasVariableBySemantic( semanticName.str() ) ) \
{ bFound = true; \
if( shadowMaps_.size() <= INDEX ) shadowMaps_.resize( INDEX + 1 ); \
shadowMaps_[ INDEX ].shaderVariables_[ SEMANTIC ] \
= getEffectShader()->createVariableBySemantic( semanticName.str() ); \
shadowMaps_[ INDEX ].WHERETO.insert( SEMANTIC ); }}
for( size_t i = 0; i < 100; ++i )
{
bool bFound = false;
INIT_SEMANTIC( i, Position, activeSemantics_view_ );
INIT_SEMANTIC( i, DIrection, activeSemantics_view_ );
INIT_SEMANTIC( i, World, activeSemantics_world_ );
INIT_SEMANTIC( i, View, activeSemantics_view_ );
INIT_SEMANTIC( i, Projection, activeSemantics_proj_ );
INIT_SEMANTIC( i, WorldView, activeSemantics_world_ );
INIT_SEMANTIC( i, ViewProjection, activeSemantics_view_ );
INIT_SEMANTIC( i, WorldViewProjection, activeSemantics_world_ );
if( false == bFound ) break;
}
#undef INIT_SEMANTIC
}
void MyEffectShaderFeederImp::setEffectShader( EffectShader * effect )
{
RenderMonkeySemanticFeeder::setEffectShader( effect );
initShadowMapSemantics( effect );
}
| [
"wrice127@af801a76-7f76-11de-8b9f-9be6f49bd635"
] | [
[
[
1,
114
]
]
] |
fb0c009ac65d7169bbde9be53dc74ecc67867b96 | 9d6d89a97c85abbfce7e2533d133816480ba8e11 | /src/Engine/Exception/ExceptionNoLoader.cpp | 562ef3f25f2207cb3fb37bcb8d8a87108b2667f0 | [] | no_license | polycraft/Bomberman-like-reseau | 1963b79b9cf5d99f1846a7b60507977ba544c680 | 27361a47bd1aa4ffea972c85b3407c3c97fe6b8e | refs/heads/master | 2020-05-16T22:36:22.182021 | 2011-06-09T07:37:01 | 2011-06-09T07:37:01 | 1,564,502 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 280 | cpp | #include "ExceptionNoLoader.h"
namespace Engine
{
ExceptionNoLoader::ExceptionNoLoader() throw()
{
}
ExceptionNoLoader::~ExceptionNoLoader() throw()
{
//dtor
}
const char* ExceptionNoLoader::what() const throw()
{
return "No loader for this extension";
}
}
| [
"[email protected]"
] | [
[
[
1,
20
]
]
] |
dc82890ced402c487977ff5935db6405e68ae91f | 3daaefb69e57941b3dee2a616f62121a3939455a | /mgllib/src/audio/MglDirectMusicBase.h | 7290c6f21026170daa3de9df319f4ee22bfb380a | [] | 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 | 3,222 | h | //////////////////////////////////////////////////////////
//
// MglDirectMusicBase v0.10.51 05/01/29
// - DirectMusicクラス
//
// v0.10.50 04/12/26
// ・色々改良
//
// v0.10.51 05/01/29
// ・ループ再生のロジックをちーとばかし改良
//
//////////////////////////////////////////////////////////
#ifndef __MglDirectMusicBase_H__
#define __MglDirectMusicBase_H__
// DirectShow
#include <DShow.h>/*
#ifdef _DEBUG
#pragma comment(lib, "Strmbasd.lib")
#else
#pragma comment(lib, "Strmbase.lib")
#endif//_DEBUG*/
//#include "MyuStringNameMap.h"
#include "MyuReleaseBase.h"
// クラス宣言
//class DLL_EXP CMglDirectMusicBase
class DLL_EXP CMglDirectMusicBase : public CMglReleaseBase // 2009/09/05
{
private:
IDirectMusicLoader8* m_pLoader;
IDirectMusicPerformance8* m_pPerformance;
//IDirectMusicSegment8 *segments[256];
typedef map<string,IDirectMusicSegment8*> SEG_TYPE;
typedef SEG_TYPE::iterator SEG_ITR;
SEG_TYPE m_segments;
BOOL m_flgEnable; // <-- コイツはbaseにあるべきじゃない気が…
//CMyuStringNameMap m_segments;
// 存在チェック
void InitCheck() {
if ( m_pLoader == NULL || m_pPerformance == NULL )
Init();
}
void ExistChk( const char* szSegmentName )
{
if ( IsExist(szSegmentName) == FALSE )
MyuThrow( 0, "CMglDirectMusicBase m_segments[%s]は存在しない、または正しく初期化されていません。", szSegmentName );
}
public:
CMglDirectMusicBase();
virtual ~CMglDirectMusicBase();
void InitEx( HWND hWnd, const char *szBaseDirectory, DWORD dwDefaultPathType, DWORD dwPerformanceChannelCount, DWORD dwFlags=DMUS_AUDIOF_ALL );
void Init( HWND hWnd, const char *szBaseDirectory="" ){
InitEx( hWnd, szBaseDirectory, DMUS_APATH_DYNAMIC_STEREO, 64 );}
void Init( const char *szBaseDirectory="" ){ Init( NULL, szBaseDirectory ); }
void Release();
void Load( const char* szAudioFile, const char* szAlias=NULL );
void PlaySegment( const char* szSegmentName );
void Play( const char* szSegmentName ){PlaySegment(szSegmentName);}
void LoopPlay( const char* szSegmentName, DWORD dwLoopCount=DMUS_SEG_REPEAT_INFINITE ){
LoopPlaySegment(szSegmentName,dwLoopCount); }
void LoopPlaySegment( const char* szSegmentName, DWORD dwLoopCount=DMUS_SEG_REPEAT_INFINITE );
void StopSegment( const char* szSegmentName );
void StopSegment( IDirectMusicSegment* pSegment );
void Stop( const char* szSegmentName );
void StopAll();
void SetVolume( int nVolume=0 );
void Disable(){
/*
全ての再生を停止。
ただし、再生されていないセグメントをStopSegment()するとどうなるかは不明。
*/
StopAll();
m_flgEnable = FALSE;
}
void Enable(){ m_flgEnable = TRUE; }
// 2009/09/26 外部に公開(privateから移動)
BOOL IsExist( const char* szSegmentName )
{
SEG_ITR itr = m_segments.find( szSegmentName );
if ( itr == m_segments.end() )
return FALSE;
else
return TRUE;
}
// 未実装
//void PauseSegment( const char* szSegmentName ){}-
IDirectMusicSegment8* GetSegmentPtr( const char* szSegmentName );
};
#endif//__MglDirectMusicBase_H__ | [
"myun2@6d62ff88-fa28-0410-b5a4-834eb811a934"
] | [
[
[
1,
106
]
]
] |
dd0d13cd4a24f2abd0f5d1beb724c05c26472f71 | 58ef4939342d5253f6fcb372c56513055d589eb8 | /CloverDemo/src/CloverDemoAppUi.cpp | 7dd96801134fb6dd34ab485221a3a4cf434b4122 | [] | 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 | 3,360 | cpp | /*
============================================================================
Name : CloverDemoAppUi.cpp
Author : zengcity
Copyright : Your copyright notice
Description : CCloverDemoAppUi implementation
============================================================================
*/
// INCLUDE FILES
#include <avkon.hrh>
#include <aknmessagequerydialog.h>
#include <aknnotewrappers.h>
#include <stringloader.h>
#include <f32file.h>
#include <s32file.h>
#include <CloverDemo_0xECDEBC61.rsg>
#include "CloverDemo.hrh"
#include "CloverDemo.pan"
#include "CloverDemoApplication.h"
#include "CloverDemoAppUi.h"
#include "CloverDemoAppView.h"
// ============================ MEMBER FUNCTIONS ===============================
// -----------------------------------------------------------------------------
// CCloverDemoAppUi::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CCloverDemoAppUi::ConstructL()
{
// Initialise app UI with standard value.
BaseConstructL(CAknAppUi::EAknEnableSkin);
// Create view object
iAppView = CCloverDemoAppView::NewL();
AddViewL(iAppView);
SetDefaultViewL(*iAppView);
//add your code here...
}
// -----------------------------------------------------------------------------
// CCloverDemoAppUi::CCloverDemoAppUi()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CCloverDemoAppUi::CCloverDemoAppUi()
{
// No implementation required
iAppView = NULL;
}
// -----------------------------------------------------------------------------
// CCloverDemoAppUi::~CCloverDemoAppUi()
// Destructor.
// -----------------------------------------------------------------------------
//
CCloverDemoAppUi::~CCloverDemoAppUi()
{
//add your code here...
}
// -----------------------------------------------------------------------------
// CCloverDemoAppUi::HandleCommandL()
// Takes care of command handling.
// -----------------------------------------------------------------------------
//
void CCloverDemoAppUi::HandleCommandL(TInt aCommand)
{
switch (aCommand)
{
case EEikCmdExit:
case EAknSoftkeyExit:
Exit();
break;
case EAbout:
{
CAknMessageQueryDialog* dlg = new (ELeave) CAknMessageQueryDialog();
dlg->PrepareLC(R_ABOUT_QUERY_DIALOG);
HBufC* title = iEikonEnv->AllocReadResourceLC(R_ABOUT_DIALOG_TITLE);
dlg->QueryHeading()->SetTextL(*title);
CleanupStack::PopAndDestroy(); //title
HBufC* msg = iEikonEnv->AllocReadResourceLC(R_ABOUT_DIALOG_TEXT);
dlg->SetMessageTextL(*msg);
CleanupStack::PopAndDestroy(); //msg
dlg->RunLD();
}
break;
default:
Panic(ECloverDemoUi);
break;
}
}
// -----------------------------------------------------------------------------
// Called by the framework when the application status pane
// size is changed. Passes the new client rectangle to the
// AppView
// -----------------------------------------------------------------------------
//
void CCloverDemoAppUi::HandleStatusPaneSizeChange()
{
if (iAppView != NULL)
iAppView->HandleStatusPaneSizeChange();
}
// End of File
| [
"zengcity@415e30b0-1e86-11de-9c9a-2d325a3e6494"
] | [
[
[
1,
113
]
]
] |
8d0e6a12fb7a6cbfc49b73f05f0acd46dd74ed52 | f13f46fbe8535a7573d0f399449c230a35cd2014 | /JelloMan/ObjectSelecter.h | 6da93906aa4fe7a04d2dc6348e59a45df29dd83e | [] | no_license | fangsunjian/jello-man | 354f1c86edc2af55045d8d2bcb58d9cf9b26c68a | 148170a4834a77a9e1549ad3bb746cb03470df8f | refs/heads/master | 2020-12-24T16:42:11.511756 | 2011-06-14T10:16:51 | 2011-06-14T10:16:51 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,299 | h | #pragma once
#include "D3DUtil.h"
#include "Blox2D.h"
#include "Controls.h"
#include "ILevelObject.h"
#include "RenderContext.h"
#include "PhysX.h"
#include "Actor.h"
class Level;
class ObjectSelecter
{
public:
// CONSTRUCTOR - DESTRUCTOR
ObjectSelecter(Level* pLevel, PhysX* pPhysXEngine);
virtual ~ObjectSelecter();
// GENERAL
void Tick(const RenderContext* pRenderContext);
void Draw(const RenderContext* pRenderContext);
void DeselectAll();
void AbortControls();
void CalcCenterPos();
void CopySelected();
void DeleteSelected();
// GETTERS
vector<IEditorObject*> GetSelectedObjects() { return m_SelectedObjects; }
const Vector3& GetCenterPos() const { return m_vCenterPos; }
private:
bool TrySelectLight(const RenderContext* pRenderContext);
bool TrySelectObject(const RenderContext* pRenderContext);
void CheckControls(const RenderContext* pRenderContext);
// DATAMEMBERS
bool m_bClick;
D3D10_VIEWPORT m_ViewPort;
const PhysX* m_pPhysXEngine;
Vector3 m_vCenterPos;
Level* m_pLevel;
vector<IEditorObject*> m_SelectedObjects;
// copy & assignment operator
ObjectSelecter(const ObjectSelecter& second);
ObjectSelecter& operator=(const ObjectSelecter& second);
}; | [
"bastian.damman@0fb7bab5-1bf9-c5f3-09d9-7611b49293d6",
"[email protected]"
] | [
[
[
1,
3
],
[
5,
52
],
[
57,
57
]
],
[
[
4,
4
],
[
53,
56
]
]
] |
d47d7f25f35c04c7e0436d7c567b55c4a2656fd3 | ea12fed4c32e9c7992956419eb3e2bace91f063a | /zombie/code/nebula2/src/kernel/ndbgalloc.cc | aa2f3ca06bef521bf590786df4d8186052e9d5a1 | [] | no_license | ugozapad/TheZombieEngine | 832492930df28c28cd349673f79f3609b1fe7190 | 8e8c3e6225c2ed93e07287356def9fbdeacf3d6a | refs/heads/master | 2020-04-30T11:35:36.258363 | 2011-02-24T14:18:43 | 2011-02-24T14:18:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,132 | cc | #include "precompiled/pchnkernel.h"
#if (defined __WIN32__ && !defined(__XBxX__)) || defined(DOXYGEN)
//------------------------------------------------------------------------------
// ndbgalloc.cc
// (C) 2004 RadonLabs GmbH
//------------------------------------------------------------------------------
#define CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#include "kernel/ntypes.h"
bool nMemoryLoggingEnabled = false;
//------------------------------------------------------------------------------
/**
Debug malloc function.
*/
void*
n_malloc_dbg(size_t size, const char* filename, int line)
{
void* res = _malloc_dbg(size, _NORMAL_BLOCK, filename, line);
if (nMemoryLoggingEnabled)
{
n_printf("%lx = n_malloc(size=%d, file=%s, line=%d)\n", res, size, filename, line);
}
return res;
}
//------------------------------------------------------------------------------
/**
Debug calloc function.
*/
void*
n_calloc_dbg(size_t num, size_t size, const char* filename, int line)
{
void* res = _calloc_dbg(num, size, _NORMAL_BLOCK, filename, line);
if (nMemoryLoggingEnabled)
{
n_printf("%lx = n_calloc(num=%d, size=%d, file=%s, line=%d)\n", res, num, size, filename, line);
}
return res;
}
//------------------------------------------------------------------------------
/**
Debug realloc function.
*/
void*
n_realloc_dbg(void* memblock, size_t size, const char* filename, int line)
{
void* res = _realloc_dbg(memblock, size, _NORMAL_BLOCK, filename, line);
if (nMemoryLoggingEnabled)
{
n_printf("%lx = n_realloc(ptr=%lx, size=%d, file=%s, line=%d)\n", res, memblock, size, filename, line);
}
return res;
}
//------------------------------------------------------------------------------
/**
Debug free function.
*/
void
n_free_dbg(void* memblock, const char* filename, int line)
{
_free_dbg(memblock, _NORMAL_BLOCK);
if (nMemoryLoggingEnabled)
{
n_printf("n_free(ptr=%lx, file=%s, line=%d)\n", memblock, filename, line);
}
}
//------------------------------------------------------------------------------
/**
Replacement global new operator without location reporting. This
catches calls which don't use n_new for some reason.
*/
void*
operator new(size_t size)
{
void* res = _malloc_dbg(size, _NORMAL_BLOCK, __FILE__, __LINE__);
if (nMemoryLoggingEnabled)
{
n_printf("%lx = new(size=%d)\n", res, size);
}
return res;
}
//------------------------------------------------------------------------------
/**
Replacement global new operator with location reporting (redirected
from n_new()).
*/
void*
operator new(size_t size, const char* file, int line)
{
void* res = _malloc_dbg(size, _NORMAL_BLOCK, file, line);
if (nMemoryLoggingEnabled)
{
n_printf("%lx = new(size=%d, file=%s, line=%d)\n", res, size, file, line);
}
return res;
}
//------------------------------------------------------------------------------
/**
Replacement global new[] operator without location reporting.
*/
void*
operator new[](size_t size)
{
void* res = _malloc_dbg(size, _NORMAL_BLOCK, __FILE__, __LINE__);
if (nMemoryLoggingEnabled)
{
n_printf("%lx = new[](size=%d)\n", res, size);
}
return res;
}
//------------------------------------------------------------------------------
/**
Replacement global new[] operator with location reporting.
*/
void*
operator new[](size_t size, const char* file, int line)
{
void* res = _malloc_dbg(size, _NORMAL_BLOCK, file, line);
if (nMemoryLoggingEnabled)
{
n_printf("%lx = new[](size=%d, file=%s, line=%d)\n", res, size, file, line);
}
return res;
}
//------------------------------------------------------------------------------
/**
Replacement global delete operator.
*/
void
operator delete(void* p)
{
if (nMemoryLoggingEnabled)
{
n_printf("delete(ptr=%lx)\n", p);
}
_free_dbg(p, _NORMAL_BLOCK);
}
//------------------------------------------------------------------------------
/**
Replacement global delete operator to match the new with location
reporting.
*/
void
operator delete(void* p, const char* /*file*/, int /*line*/)
{
if (nMemoryLoggingEnabled)
{
n_printf("delete(ptr=%lx)\n", p);
}
_free_dbg(p, _NORMAL_BLOCK);
}
//------------------------------------------------------------------------------
/**
Replacement global delete[] operator.
*/
void
operator delete[](void* p)
{
if (nMemoryLoggingEnabled)
{
n_printf("delete[](ptr=%lx)\n", p);
}
_free_dbg(p, _NORMAL_BLOCK);
}
//------------------------------------------------------------------------------
/**
Replacement global delete[] operator to match the new with location
reporting.
*/
void
operator delete[](void* p, const char* /*file*/, int /*line*/)
{
if (nMemoryLoggingEnabled)
{
n_printf("delete[](ptr=%lx)\n", p);
}
_free_dbg(p, _NORMAL_BLOCK);
}
//------------------------------------------------------------------------------
/**
Initialize the debug memory system.
*/
void
n_dbgmeminit()
{
// enable automatic memory leak check at end of application
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
}
//------------------------------------------------------------------------------
/**
Create debug memory statistics.
*/
nMemoryStats
n_dbgmemgetstats()
{
_CrtMemState crtState = { 0 };
_CrtMemCheckpoint(&crtState);
nMemoryStats memStats = { 0 };
memStats.highWaterSize = static_cast<int>( crtState.lHighWaterCount );
int i;
for (i = 0; i < _MAX_BLOCKS; i++)
{
memStats.totalCount += static_cast<int>( crtState.lCounts[i] );
memStats.totalSize += static_cast<int>( crtState.lSizes[i] );
}
return memStats;
}
#endif
| [
"magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91"
] | [
[
[
1,
226
]
]
] |
326a6cfb5d96d56c00fe381bfbe34dc5dddf30aa | 5a05acb4caae7d8eb6ab4731dcda528e2696b093 | /GameEngine/Gfx/Font/FreeType/FreeTypeFont.cpp | acadc8bf453895c78f8df737c4da979271f54c0a | [] | no_license | andreparker/spiralengine | aea8b22491aaae4c14f1cdb20f5407a4fb725922 | 36a4942045f49a7255004ec968b188f8088758f4 | refs/heads/master | 2021-01-22T12:12:39.066832 | 2010-05-07T00:02:31 | 2010-05-07T00:02:31 | 33,547,546 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,064 | cpp | #include "FreeTypeFont.hpp"
#include <boost/assert.hpp>
#include <freetype/ftbitmap.h>
#include <boost/tokenizer.hpp>
#include "../../Surface.hpp"
#include "../../Color.hpp"
#include "../../../Core/TypeUtils.hpp"
using namespace Spiral;
using namespace boost;
const uint32_t kPadding = 3; // raise it 3 pixels
namespace
{
inline int32_t convert_26_6_to_int32( signed long value )
{
return value >> 6;
}
}
FreeTypeFont::~FreeTypeFont()
{
}
FreeTypeFont::FreeTypeFont( const FreeTypeFont& font ):
Font( font.GetCharWidth(), convert_26_6_to_int32( font.m_face->size->metrics.height ) ),
m_library( font.m_library ), m_face( font.m_face ),m_data( font.m_data )
{}
FreeTypeFont::FreeTypeFont( FT_Library library, FT_Face font,const boost::shared_array< boost::int8_t >& data, boost::int32_t width, boost::int32_t height ):
Font( width, convert_26_6_to_int32( font->size->metrics.height ) ),m_library( library ), m_face( font, FT_Done_Face ),m_data( data )
{
}
/*!
@function FindMaxStrSize
@brief finds the max string size, newlines in the string marks a sub string
@return boost::int32_t
@param const std::string & str
*/
boost::uint32_t FindMaxStrSize( const wString& str )
{
uint32_t firstPos = 0,lastPos = 0;
uint32_t len = 0;
typedef tokenizer< char_separator<wChar>, wString::const_iterator, wString > wTokenizer;
wTokenizer tokens( str,char_separator<wChar>( L"\n" ) );
for( wTokenizer::iterator itr = tokens.begin(); itr != tokens.end(); ++itr )
{
uint32_t curlen = (*itr).length();
if( curlen > len )
len = curlen;
}
return ( len == 0 ? str.length() : len );
}
void FreeTypeFont::DoCalcSurfaceSize( const wString& str, boost::int32_t& surfWidth, boost::int32_t& surfHeight )
{
surfWidth = FindMaxStrSize( str ) * convert_26_6_to_int32( m_face->max_advance_width / 2 );
surfHeight = GetCharHeight() * ( 1 + count_element_occurences( str.begin(), str.end(), '\n' ) ) + GetCharHeight();
}
struct SurfacePosition
{
SurfacePosition( boost::int32_t x_, boost::int32_t y_ ):
x( x_ ),y( y_ ){}
SurfacePosition():x(0),y(0){}
boost::int32_t x,y;
};
inline void StorePixelRgba( unsigned char* currentLine, const Rgba& color, unsigned char* bitmap_surf )
{
currentLine[0] = color.GetByteComponent( 0 );
currentLine[1] = color.GetByteComponent( 1 );
currentLine[2] = color.GetByteComponent( 2 );
currentLine[3] = *bitmap_surf;
}
inline void StorePixelRgb( unsigned char* currentLine, const Rgba& color, unsigned char* bitmap_surf )
{
currentLine[0] = static_cast< unsigned char >( color[0] * (*bitmap_surf) );
currentLine[1] = static_cast< unsigned char >( color[1] * (*bitmap_surf) );
currentLine[2] = static_cast< unsigned char >( color[2] * (*bitmap_surf) );
}
template< void PixelStorePolicy( unsigned char*, const Rgba&, unsigned char*), int32_t elementMinSize >
void RenderBitmapToSurf( const SurfacePosition& position, const FT_Bitmap& bitmap, const Rgba& color, boost::shared_ptr< Surface >& surface )
{
int32_t rows = bitmap.rows;
int32_t surfacePitch = surface->GetBytesPerLine();
int32_t elementSize = surface->GetElementSize();
BOOST_ASSERT( elementSize >= elementMinSize );
unsigned char* surf = reinterpret_cast<unsigned char*>( surface->GetData() ) + position.y * surfacePitch + position.x * elementSize;
unsigned char* bitmap_surf = bitmap.buffer;
int32_t col = bitmap.width;
unsigned char* currentSurfLine = surf;
unsigned char* currentBitMapLine = bitmap.buffer;
while( rows-- != 0 )
{
do
{
if( *currentBitMapLine != 0 )
{
// store the pixel
PixelStorePolicy(currentSurfLine, color, currentBitMapLine);
}
currentSurfLine += elementSize;
++currentBitMapLine;
} while ( --col != 0 );
surf += surfacePitch;
bitmap_surf += bitmap.pitch;
col = bitmap.width;
currentSurfLine = surf;
currentBitMapLine = bitmap_surf;
}
}
void RenderBitmapOpaque( const SurfacePosition& pos, const FT_Bitmap& bitmap, const Rgba& color, boost::shared_ptr< Surface >& surface )
{
RenderBitmapToSurf< StorePixelRgb, 3 >( pos, bitmap, color, surface );
}
void RenderBitmapAlpha( const SurfacePosition& pos, const FT_Bitmap& bitmap, const Rgba& color, boost::shared_ptr< Surface >& surface )
{
RenderBitmapToSurf< StorePixelRgba, 4 >( pos, bitmap, color, surface );
}
struct TextData
{
TextData( FT_Face face_, const boost::shared_ptr< Surface >& surface, const SurfacePosition& pos ):
face( face_ ),renderSurface( surface ),cursorPos( pos ){}
FT_Face face;
boost::shared_ptr< Surface > renderSurface;
SurfacePosition cursorPos;
};
template< void Render( const SurfacePosition&, const FT_Bitmap&, const Rgba&, boost::shared_ptr< Surface >& ) >
void DrawText( TextData& data, const wString& str, const Rgba& color )
{
const wChar* text = str.c_str();
const int32_t text_height = convert_26_6_to_int32( data.face->size->metrics.height );
SurfacePosition pos( data.cursorPos.x, text_height - kPadding );
bool useKerning = bool( FT_HAS_KERNING( data.face ) ? true : false );
FT_UInt preIndex = 0;
while( *text != 0 )
{
wChar c = *text;
if( c == '\n' )
{
pos.y += text_height;
pos.x = 0;
++text;
continue;
}
FT_UInt index = FT_Get_Char_Index( data.face, c );
FT_Error result = FT_Load_Glyph( data.face, index, FT_LOAD_DEFAULT );
if( !result )
{
if( useKerning && index && preIndex )
{
FT_Vector delta;
FT_Get_Kerning( data.face, preIndex, index, 0, &delta );
pos.x += convert_26_6_to_int32(delta.x);
}
result = FT_Render_Glyph( data.face->glyph, FT_RENDER_MODE_NORMAL );
FT_GlyphSlot slot = data.face->glyph;
if( !result )
{
SurfacePosition tmpPos( pos.x + slot->bitmap_left, pos.y - slot->bitmap_top );
Render( tmpPos, slot->bitmap, color, data.renderSurface );
}
pos.x += convert_26_6_to_int32(data.face->glyph->advance.x); // advance is in 26.6 format, convert to int
preIndex = index;
}
++text;
}
data.cursorPos.x = pos.x;
data.cursorPos.y = pos.y - text_height;
}
void FreeTypeFont::DoRenderAlpha( boost::shared_ptr< Surface >& surface, const wString& str, const Rgba& color )
{
TextData renderInfo( m_face.get(), surface, SurfacePosition() );
SetTheFontSize();
DrawText< RenderBitmapAlpha >( renderInfo, str, color );
}
void FreeTypeFont::DoRenderOpaque( boost::shared_ptr< Surface >& surface, const wString& str, const Rgba& color )
{
TextData renderInfo( m_face.get(), surface, SurfacePosition() );
SetTheFontSize();
DrawText< RenderBitmapOpaque >( renderInfo, str, color );
}
void FreeTypeFont::DoRenderAlpha( boost::shared_ptr< Surface >& surface, boost::uint32_t& cursorX, const wString& str, const Rgba& color )
{
TextData renderInfo( m_face.get(), surface, SurfacePosition(cursorX,0) );
SetTheFontSize();
DrawText< RenderBitmapAlpha >( renderInfo, str, color );
cursorX = renderInfo.cursorPos.x;
}
void FreeTypeFont::DoRenderOpaque( boost::shared_ptr< Surface >& surface, boost::uint32_t& cursorX, const wString& str, const Rgba& color )
{
TextData renderInfo( m_face.get(), surface, SurfacePosition(cursorX,0) );
SetTheFontSize();
DrawText< RenderBitmapOpaque >( renderInfo, str, color );
cursorX = renderInfo.cursorPos.x;
}
bool FreeTypeFont::DoSetSize( boost::int32_t width, boost::int32_t height )
{
FT_Error result = 0;
if( !( convert_26_6_to_int32( m_face->size->metrics.height ) == height && width == GetCharWidth() ) )
{
result = FT_Set_Pixel_Sizes( m_face.get(), width, height );
if( !result )
{
SetSize( width, convert_26_6_to_int32( m_face->size->metrics.height ) );
}
}
return bool( !result );
}
FreeTypeFont* FreeTypeFont::DoClone() const
{
return new FreeTypeFont( *this );
}
void FreeTypeFont::SetTheFontSize()
{
SetFontSize( GetCharWidth(), GetCharHeight() );
} | [
"DreLnBrown@e933ee44-1dc6-11de-9e56-bf19dc6c588e"
] | [
[
[
1,
264
]
]
] |
7b135158c42de7f3f29cf9bbd7f4c2e9de52200b | 974a20e0f85d6ac74c6d7e16be463565c637d135 | /trunk/coreLibrary_300/source/physics/dgCollisionBox.h | 43cfb64253e507a63e3dd6f76ffc137f9dd001f2 | [] | no_license | Naddiseo/Newton-Dynamics-fork | cb0b8429943b9faca9a83126280aa4f2e6944f7f | 91ac59c9687258c3e653f592c32a57b61dc62fb6 | refs/heads/master | 2021-01-15T13:45:04.651163 | 2011-11-12T04:02:33 | 2011-11-12T04:02:33 | 2,759,246 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,303 | h | /* Copyright (c) <2003-2011> <Julio Jerez, Newton Game Dynamics>
*
* 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.
*/
#if !defined(AFX_DGCOLLISIONBOX_H__364692C2_5F23_41AE_A167_7A92E2D2DA5F__INCLUDED_)
#define AFX_DGCOLLISIONBOX_H__364692C2_5F23_41AE_A167_7A92E2D2DA5F__INCLUDED_
#include "dgCollisionConvex.h"
class dgCollisionBox;
class dgCollisionBox: public dgCollisionConvex
{
public:
dgCollisionBox(dgMemoryAllocator* const allocator, dgUnsigned32 signature, dgFloat32 size_x, dgFloat32 size_y, dgFloat32 size_z, const dgMatrix& matrix);
dgCollisionBox(dgWorld* const world, dgDeserialize deserialization, void* const userData);
virtual ~dgCollisionBox();
protected:
void Init (dgFloat32 size_x, dgFloat32 size_y, dgFloat32 size_z);
virtual void CalcAABB (const dgMatrix &matrix, dgVector& p0, dgVector& p1) const;
virtual void CalcAABBSimd (const dgMatrix &matrix, dgVector& p0, dgVector& p1) const;
virtual dgFloat32 RayCast (const dgVector& localP0, const dgVector& localP1, dgContactPoint& contactOut, OnRayPrecastAction preFilter, const dgBody* const body, void* const userData) const;
virtual dgFloat32 RayCastSimd (const dgVector& localP0, const dgVector& localP1, dgContactPoint& contactOut, OnRayPrecastAction preFilter, const dgBody* const body, void* const userData) const;
virtual dgVector SupportVertex (const dgVector& dir) const;
virtual dgVector SupportVertexSimd (const dgVector& dir) const;
virtual dgInt32 CalculatePlaneIntersection (const dgVector& normal, const dgVector& point, dgVector* const contactsOut) const;
virtual dgInt32 CalculatePlaneIntersectionSimd (const dgVector& normal, const dgVector& point, dgVector* const contactsOut) const;
virtual dgInt32 CalculateSignature () const;
virtual void SetCollisionBBox (const dgVector& p0, const dgVector& p1);
virtual dgFloat32 CalculateMassProperties (dgVector& inertia, dgVector& crossInertia, dgVector& centerOfMass) const;
virtual void GetCollisionInfo(dgCollisionInfo* info) const;
virtual void Serialize(dgSerialize callback, void* const userData) const;
virtual void SetBreakImpulse(dgFloat32 force);
virtual dgFloat32 GetBreakImpulse() const;
dgVector m_size[2];
dgVector m_vertex[8];
simd_128 m_vertex_sse[6];
dgFloat32 m_destructionImpulse;
static dgConvexSimplexEdge m_edgeArray[];
friend class dgWorld;
};
#endif // !defined(AFX_DGCOLLISIONBOX_H__364692C2_5F23_41AE_A167_7A92E2D2DA5F__INCLUDED_)
| [
"[email protected]@b7a2f1d6-d59d-a8fe-1e9e-8d4888b32692"
] | [
[
[
1,
73
]
]
] |
64e5034455d1abcbeb400d25b82c46ed0af2969f | 36bf908bb8423598bda91bd63c4bcbc02db67a9d | /Library/CHyperLink.cpp | 72f60b3369acc5d64ba3fca601744cd539a21891 | [] | no_license | code4bones/crawlpaper | edbae18a8b099814a1eed5453607a2d66142b496 | f218be1947a9791b2438b438362bc66c0a505f99 | refs/heads/master | 2021-01-10T13:11:23.176481 | 2011-04-14T11:04:17 | 2011-04-14T11:04:17 | 44,686,513 | 0 | 1 | null | null | null | null | ISO-8859-15 | C++ | false | false | 7,019 | cpp | /*
CHyperLink.cpp
Classe per il collegamento ipertestuale (MFC).
Luca Piergentili, 21/07/03
[email protected]
Codice iniziale ripreso da:
HyperLink static control.
Copyright Chris Maunder, 1997, 1998
Feel free to use and distribute. May not be sold for profit.
*/
#include "env.h"
#include "pragma.h"
#include "macro.h"
#include "window.h"
#include "CBrowser.h"
#include "CToolTipCtrlEx.h"
#include "CHyperLink.h"
#include "traceexpr.h"
//#define _TRACE_FLAG _TRFLAG_TRACEOUTPUT
//#define _TRACE_FLAG _TRFLAG_NOTRACE
#define _TRACE_FLAG _TRFLAG_NOTRACE
#define _TRACE_FLAG_INFO _TRFLAG_NOTRACE
#define _TRACE_FLAG_WARN _TRFLAG_NOTRACE
#define _TRACE_FLAG_ERR _TRFLAG_NOTRACE
#if (defined(_DEBUG) && defined(_WINDOWS)) && (defined(_AFX) || defined(_AFXDLL))
#ifdef PRAGMA_MESSAGE_VERBOSE
#pragma message("\t\t\t"__FILE__"("STR(__LINE__)"): using DEBUG_NEW macro")
#endif
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// id per il tooltip
#define ID_TOOLTIP_CONTROL 1965
BEGIN_MESSAGE_MAP(CHyperLink,CStatic)
ON_CONTROL_REFLECT(STN_CLICKED,OnClicked)
ON_WM_CTLCOLOR_REFLECT()
ON_WM_SETCURSOR()
ON_WM_MOUSEMOVE()
END_MESSAGE_MAP()
/*
CHyperLink()
*/
CHyperLink::CHyperLink()
{
m_hCursor = NULL;
m_crLinkColour = RGB(0,0,255);
m_crVisitedColour = RGB(128,0,128);
m_crHoverColour = ::GetSysColor(COLOR_HIGHLIGHT);
m_bOverControl = FALSE;
m_bVisited = FALSE;
m_bUnderline = TRUE;
m_bAdjustToFit = FALSE;
m_strUrl = "";
m_bAutoText = TRUE;
m_strText = "";
m_strToolTipText = "";
}
/*
~CHyperLink()
*/
CHyperLink::~CHyperLink()
{
m_Font.DeleteObject();
}
/*
SetUrl()
*/
void CHyperLink::SetUrl(LPCSTR lpcszUrl)
{
m_strUrl.Format("%s",lpcszUrl);
if(m_bAdjustToFit)
if(::IsWindow(GetSafeHwnd()))
PositionWindow();
}
/*
OpenUrl()
*/
BOOL CHyperLink::OpenUrl(LPCSTR lpcszUrl/*=NULL*/)
{
BOOL bRes = FALSE;
if(lpcszUrl)
m_strUrl.Format("%s",lpcszUrl);
if(!m_strUrl.IsEmpty())
{
CBrowser browser;
bRes = browser.Browse(LPCSTR(m_strUrl));
}
return(bRes);
}
/*
SetVisited()
*/
void CHyperLink::SetVisited(BOOL bVisited)
{
m_bVisited = bVisited;
if(::IsWindow(GetSafeHwnd()))
Invalidate();
}
/*
SetCursor()
*/
void CHyperLink::SetCursor(HCURSOR hCursor)
{
m_hCursor = hCursor;
if(!m_hCursor)
SetDefaultCursor();
}
/*
SetUnderline()
*/
void CHyperLink::SetUnderline(BOOL bUnderline)
{
m_bUnderline = bUnderline;
if(::IsWindow(GetSafeHwnd()))
{
LOGFONT lf;
GetFont()->GetLogFont(&lf);
lf.lfUnderline = (BYTE)m_bUnderline;
m_Font.DeleteObject();
m_Font.CreateFontIndirect(&lf);
SetFont(&m_Font);
Invalidate();
}
}
/*
SetAutoSize()
*/
void CHyperLink::SetAutoSize(BOOL bAutoSize)
{
m_bAdjustToFit = bAutoSize;
if(m_bAdjustToFit)
if(::IsWindow(GetSafeHwnd()))
PositionWindow();
}
/*
PreSubclassWindow()
*/
void CHyperLink::PreSubclassWindow(void)
{
// we want to get mouse clicks via STN_CLICKED
DWORD dwStyle = GetStyle();
::SetWindowLong(GetSafeHwnd(),GWL_STYLE,dwStyle|SS_NOTIFY);
// check that the window text isn't empty. If it is, set it as the URL.
if(m_strText.IsEmpty() && m_bAutoText)
m_strText = m_strUrl;
SetWindowText(m_strText);
// create the font
LOGFONT lf;
GetFont()->GetLogFont(&lf);
lf.lfUnderline = (BYTE)m_bUnderline;
m_Font.CreateFontIndirect(&lf);
SetFont(&m_Font);
// adjust size of window to fit URL if necessary
if(m_bAdjustToFit)
PositionWindow();
// try and load up a "hand" cursor
SetDefaultCursor();
// crea il tooltip
m_wndToolTip.Create(this,TTS_ALWAYSTIP);
m_wndToolTip.SetWidth(TOOLTIP_XXL_WIDTH);
m_wndToolTip.SetDelay(TOOLTIP_REASONABLE_DELAYTIME);
CRect rect(0,0,0,0);
m_wndToolTip.AddRectTool(this,"hyperlink",&rect,ID_TOOLTIP_CONTROL);
m_wndToolTip.UpdateTipText(m_strToolTipText,this,ID_TOOLTIP_CONTROL);
GetClientRect(rect);
m_wndToolTip.SetToolRect(this,ID_TOOLTIP_CONTROL,&rect);
m_wndToolTip.Activate(TRUE);
CStatic::PreSubclassWindow();
}
/*
PositionWindow()
Move and resize the window so that the window is the same size as the hyperlink text. This stops
the hyperlink cursor being active when it is not directly over the text. If the text is left
justified then the window is merely shrunk, but if it is centred or right justified then the window
will have to be moved as well.
Suggested by Pål K. Tønder
*/
void CHyperLink::PositionWindow(void)
{
if(!::IsWindow(GetSafeHwnd()) || !m_bAdjustToFit)
return;
// get the current window position
CRect rect;
GetWindowRect(rect);
CWnd* pParent = GetParent();
if(pParent)
pParent->ScreenToClient(rect);
// get the size of the window text
CDC* pDC = GetDC();
CFont* pOldFont = pDC->SelectObject(&m_Font);
CSize Extent = pDC->GetTextExtent(m_strText);
pDC->SelectObject(pOldFont);
ReleaseDC(pDC);
// get the text justification via the window style
DWORD dwStyle = GetStyle();
// recalc the window size and position based on the text justification
if(dwStyle & SS_CENTERIMAGE)
rect.DeflateRect(0,(rect.Height() - Extent.cy) / 2);
else
rect.bottom = rect.top + Extent.cy;
if(dwStyle & SS_CENTER)
rect.DeflateRect((rect.Width() - Extent.cx) / 2,0);
else if(dwStyle & SS_RIGHT)
rect.left = rect.right - Extent.cx;
else // SS_LEFT = 0, so we can't test for it explicitly
rect.right = rect.left + Extent.cx;
// move the window
SetWindowPos(NULL,rect.left,rect.top,rect.Width(),rect.Height(),SWP_NOZORDER);
}
/*
SetDefaultCursor()
*/
void CHyperLink::SetDefaultCursor(void)
{
if(!m_hCursor)
m_hCursor = ::LoadCursor(NULL,MAKEINTRESOURCE(32649));
}
/*
CtlColor()
*/
HBRUSH CHyperLink::CtlColor(CDC* pDC,UINT nCtlColor)
{
ASSERT(nCtlColor==CTLCOLOR_STATIC);
if(m_bOverControl)
pDC->SetTextColor(m_crHoverColour);
else
{
if(m_bVisited)
pDC->SetTextColor(m_crVisitedColour);
else
pDC->SetTextColor(m_crLinkColour);
}
// transparent text
pDC->SetBkMode(TRANSPARENT);
return((HBRUSH)GetStockObject(NULL_BRUSH));
}
/*
OnSetCursor()
*/
BOOL CHyperLink::OnSetCursor(CWnd* /*pWnd*/,UINT /*nHitTest*/,UINT /*nMsg*/)
{
if(m_hCursor)
{
::SetCursor(m_hCursor);
return(TRUE);
}
return(FALSE);
}
/*
OnMouseMove()
*/
void CHyperLink::OnMouseMove(UINT nFlags,CPoint point)
{
CStatic::OnMouseMove(nFlags,point);
if(m_bOverControl) // cursor is currently over control
{
CRect rect;
GetClientRect(rect);
if(!rect.PtInRect(point))
{
m_bOverControl = FALSE;
ReleaseCapture();
RedrawWindow();
return;
}
}
else // cursor has just moved over control
{
m_bOverControl = TRUE;
RedrawWindow();
SetCapture();
}
}
/*
OnClicked()
*/
void CHyperLink::OnClicked(void)
{
if(OpenUrl())
SetVisited(TRUE);
}
| [
"[email protected]"
] | [
[
[
1,
329
]
]
] |
0fefdeafce0549a7f1d7e81e6011114f90865992 | 1bb66b98419d712cfdb2b200bc7b8ae701f1927c | /branches/dependencies/Variable.hpp | f31b720daf521e5788fb1ca0270f46bf468251b0 | [] | no_license | BackupTheBerlios/cbmakegen-svn | f9aadde316f8270296355106841666f346f7ff7a | 6164cb69487932d5cd2101a9eca82f39a6703727 | refs/heads/master | 2021-01-10T18:26:41.642983 | 2010-06-21T11:53:04 | 2010-06-21T11:53:04 | 40,718,403 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 826 | hpp | #ifndef VARIABLE_HPP
#define VARIABLE_HPP
#include <wx/arrstr.h>
#include <wx/textfile.h>
class cbMGVariable
{
wxArrayString m_VariableName;
wxArrayString m_VariableValue;
public:
cbMGVariable();
virtual ~cbMGVariable();
void AddVariable(const wxString& pVarName,const wxString& pVarValue);
wxString GetVariable(const wxString& pVarName) const;
wxString GetVariable( unsigned long Index ) const;
wxString GetVarName( unsigned long Index ) const;
void AppendValue(const wxString& pVarName,const wxString& pVarValue,const wxChar& pDelimiter = _T(' '));
bool SaveAllVars( wxTextFile& pFile );
void Clear();
unsigned long Count() const;
protected:
long GetVariableIndex(const wxString& pVarName) const;
private:
};
#endif // VARIABLE_HPP
| [
"kisoftcb@43f0282e-a136-0410-aefe-e816e2e1d084"
] | [
[
[
1,
29
]
]
] |
04f197f73ac760c4d214ef634af2e5c24854553f | b6a6fa4324540b94fb84ee68de3021a66f5efe43 | /Duplo/Modules/ModuleCreator.h | 7a4ee5ba18838b3ce914cd7e77f6b7083a45fff8 | [] | no_license | southor/duplo-scs | dbb54061704f8a2ec0514ad7d204178bfb5a290e | 403cc209039484b469d602b6752f66b9e7c811de | refs/heads/master | 2021-01-20T10:41:22.702098 | 2010-02-25T16:44:39 | 2010-02-25T16:44:39 | 34,623,992 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 935 | h |
#ifndef _MODULE_CREATOR_
#define _MODULE_CREATOR_
class ModuleHandler;
namespace Dup
{
void createModule(ModuleHandler *mH, dup_uint32 pathNr, dup_uint32 id, MessageParser argsMsg);
};
#endif
#ifndef _MODULE_CREATOR_DEC_
#define _MODULE_CREATOR_DEC_
#include "Dup_AllModules.h"
#include "ModuleHandler.h"
#include "MessageParser.h"
namespace Dup
{
void createModule(ModuleHandler *mH, dup_uint32 pathNr, dup_uint32 id, MessageParser argsMsg)
{
/*
switch(pathNr)
{
case NotePlayer::PATHID
mH->addModule(new NotePlayer(mH, id, argsMsg));
break;
case StereoWaveBuffer::PATHID
mH->addModule(new StereoWaveBuffer(mH, id, argsMsg));
break;
case SineOscillator::PATHID
mH->addModule(new SineOscillator(mH, id, argsMsg));
break;
case TimeEnv1::PATHID
mH->addModule(new TimeEnv1(mH, id, argsMsg));
break;
}
*/
}
};
#endif | [
"t.soderberg8@2b3d9118-3c8b-11de-9b50-8bb2048eb44c"
] | [
[
[
1,
51
]
]
] |
b028b23a0a2a1a69134b25ebfc229a7a8b55f5c4 | 5927f0908f05d3f58fe0adf4d5d20c27a4756fbe | /examples/chrome/tab_strip_selection_model.h | 0a9401edfaf6e7ea905bf8ba1e563e938aef8974 | [] | no_license | seasky013/x-framework | b5585505a184a7d00d229da8ab0f556ca0b4b883 | 575e29de5840ede157e0348987fa188b7205f54d | refs/heads/master | 2016-09-16T09:41:26.994686 | 2011-09-16T06:16:22 | 2011-09-16T06:16:22 | 41,719,436 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,950 | h |
#ifndef __tab_strip_selection_model_h__
#define __tab_strip_selection_model_h__
#pragma once
#include <vector>
#include "base/basic_types.h"
// Selection model used by the tab strip. In addition to the set of selected
// indices TabStripSelectionModel maintains the following:
// active: the index of the currently visible tab in the tab strip.
// anchor: the index of the last tab the user clicked on. Extending the
// selection extends it from this index.
//
// Typically there is only one selected tab in the tabstrip, in which case the
// anchor and active index correspond to the same thing.
class TabStripSelectionModel
{
public:
typedef std::vector<int> SelectedIndices;
// Used to identify no selection.
static const int kUnselectedIndex;
TabStripSelectionModel();
~TabStripSelectionModel();
// See class description for details of the anchor.
void set_anchor(int anchor) { anchor_ = anchor; }
int anchor() const { return anchor_; }
// See class description for details of active.
void set_active(int active) { active_ = active; }
int active() const { return active_; }
// True if nothing is selected.
bool empty() const { return selected_indices_.empty(); }
// Number of selected indices.
size_t size() const { return selected_indices_.size(); }
// Increments all indices >= |index|. For example, if the selection consists
// of [0, 1, 5] and this is invoked with 1, it results in [0, 2, 6]. This also
// updates the anchor and active indices.
// This is used when a new tab is inserted into the tabstrip.
void IncrementFrom(int index);
// Shifts all indices < |index| down by 1. If |index| is selected, it is
// removed. For example, if the selection consists of [0, 1, 5] and this is
// invoked with 1, it results in [0, 4]. This is used when a tab is removed
// from the tabstrip.
void DecrementFrom(int index);
// Sets the anchor, active and selection to |index|.
void SetSelectedIndex(int index);
// Returns true if |index| is selected.
bool IsSelected(int index) const;
// Adds |index| to the selection. This does not change the active or anchor
// indices.
void AddIndexToSelection(int index);
// Removes |index| from the selection. This does not change the active or
// anchor indices.
void RemoveIndexFromSelection(int index);
// Extends the selection from the anchor to |index|. If the anchor is empty,
// this sets the anchor, selection and active indices to |index|.
void SetSelectionFromAnchorTo(int index);
// Makes sure the indices from the anchor to |index| are selected. This only
// adds to the selection.
void AddSelectionFromAnchorTo(int index);
// Invoked when an item moves. |from| is the original index, and |to| the
// target index.
// NOTE: this matches the TabStripModel API. If moving to a greater index,
// |to| should be the index *after* removing |from|. For example, consider
// three tabs 'A B C', to move A to the end of the list, this should be
// invoked with '0, 2'.
void Move(int from, int to);
// Sets the anchor and active to kUnselectedIndex, and removes all the
// selected indices.
void Clear();
// Returns the selected indices. The selection is always ordered in acending
// order.
const SelectedIndices& selected_indices() const { return selected_indices_; }
// Copies the selection from |source| to this.
void Copy(const TabStripSelectionModel& source);
// Compares this selection with |rhs|.
bool Equals(const TabStripSelectionModel& rhs) const;
private:
SelectedIndices selected_indices_;
int active_;
int anchor_;
DISALLOW_COPY_AND_ASSIGN(TabStripSelectionModel);
};
#endif //__tab_strip_selection_model_h__ | [
"[email protected]"
] | [
[
[
1,
110
]
]
] |
880a235690f3033cee6cb57ba43bece62b7761fb | ecd62ff3b58c304344000881849e70e46eca9dbb | /unit_tests/main.cpp | 2d3ccb16f01f6bf11fda4790d55db332833da211 | [
"BSD-2-Clause"
] | permissive | paullasarev/cpp-names | e0abbaa6b1297a9b151c43295b5b3db8ba72bb95 | 9feffd94f8e28008748bef1a9c875466ebe2c097 | refs/heads/master | 2021-01-10T05:27:27.990830 | 2011-12-26T18:01:20 | 2011-12-26T18:01:20 | 36,063,945 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,822 | cpp | #define YAFFUT_MAIN
#include "yaffut.h"
/*
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
#include <cppunit/TextTestProgressListener.h>
#include <cppunit/Protector.h>
#include <iostream>
#include <fstream>
#include <set>
#include <string>
namespace CppNames
{
namespace UnitTests
{
int RunUnitTests(int argc, char* argv[])
{
std::string testPath = (argc > 1) ? std::string(argv[1]) : "";
// Create the event manager and test controller
CppUnit::TestResult controller;
// Add a listener that colllects test result
CppUnit::TestResultCollector result;
controller.addListener(&result);
// Add a listener that print dots as test run.
CppUnit::TextTestProgressListener progress;
controller.addListener(&progress);
// Add the top suite to the test runner
CppUnit::TestRunner runner;
runner.addTest( CppUnit::TestFactoryRegistry::getRegistry().makeTest());
try
{
std::cout << "Running tests " << testPath << ":" << std::endl;
runner.run( controller, testPath );
std::cout << std::endl;
// Print test in a compiler compatible format.
CppUnit::CompilerOutputter outputter(&result, std::cerr);
outputter.write();
}
catch ( std::exception &e )
{
std::cerr << std::endl << "ERROR: " << e.what() << std::endl;
return 0;
}
return result.wasSuccessful() ? 0 : 1;
}
}
}
int main(int argc, char* argv[])
{
return CppNames::UnitTests::RunUnitTests(argc, argv);
}
*/ | [
"[email protected]@d4c89ac4-cce6-dfee-ab0c-273009d6406b"
] | [
[
[
1,
70
]
]
] |
a8b5b72539292ecbefb0f1983b2154f06db6d386 | 4ac19e8642b3005d702a1112a722811c8b3cc7c6 | /include/freeCGI.h | 65d433ad46572f66a3b37dfaa3e91547c39bf5fc | [
"BSD-3-Clause"
] | permissive | amreisa/freeCGI | 5ab00029e86fad79a2580262c04afa3ae442e127 | 84c047c4790eaabbc9d2284242a44c204fe674ea | refs/heads/master | 2022-04-27T19:51:11.690512 | 2011-02-28T22:33:34 | 2011-02-28T22:33:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 902 | h | //a_This is the main include
#ifndef __A_FREECGI_H__
#define __A_FREECGI_H__
//a_Predefinitions
#include "a_predef.h"
//a_Global function declarations
#include "a_global.h"
//a_Structures
#include "a_struct.h"
//a_Forward declarations
class AStreamOutput;
//a_Base classes
#include "a_base.h"
//a_Branch of the hierarchy that deals with encryption, encoding, conversion, etc...
#include "a_conv.h"
//a_AList, ADataItem and other founding container/element classes
#include "a_list.h"
//a_AElementPairList and items derrived from it
#include "a_elist.h"
//a_HTML form items and lists
#include "a_form.h"
//a_Branch of the hierarchy that deals with output as stream
#include "a_stream.h"
//a_HTML and CGI class based on stream
#include "a_html.h"
#include "a_cgi.h"
#include "a_helper.h"
//a_Shooping Cart and items
#include "a_scart.h"
#endif
| [
"[email protected]"
] | [
[
[
1,
45
]
]
] |
3598af716df59b16615c5fd1984d001ff923b54f | 9152cb31fbe4e82c22092bb3071b2ec8c6ae86ab | /tests/siptestwin/StdAfx.cpp | e3197b609ca2f650c506635b5d7d019a947122ac | [] | no_license | zzjs2001702/sfsipua-svn | ca3051b53549066494f6264e8f3bf300b8090d17 | e8768338340254aa287bf37cf620e2c68e4ff844 | refs/heads/master | 2022-01-09T20:02:20.777586 | 2006-03-29T13:24:02 | 2006-03-29T13:24:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 209 | cpp | // stdafx.cpp : source file that includes just the standard includes
// testwin.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
| [
"yippeesoft@5dda88da-d10c-0410-ac74-cc18da35fedd"
] | [
[
[
1,
8
]
]
] |
8b325679e82ea9bc278c20206a921a7a09a4e7a2 | 1cc5720e245ca0d8083b0f12806a5c8b13b5cf98 | /v4/ok/414/c.cpp | e4a9f3dea2d0f3d28d792b937b3fcd1471187ca1 | [] | no_license | Emerson21/uva-problems | 399d82d93b563e3018921eaff12ca545415fd782 | 3079bdd1cd17087cf54b08c60e2d52dbd0118556 | refs/heads/master | 2021-01-18T09:12:23.069387 | 2010-12-15T00:38:34 | 2010-12-15T00:38:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 549 | cpp | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
using namespace std;
#define FOR(a,b) for(a=0;a<b;a++)
int main() {
int val[20];
char lin[300];
int n,i,j,k;
while(true) {
gets(lin);
sscanf(lin,"%d",&n);
if(!n) break;
FOR(i,n) {
val[i]=0;
gets(lin);
FOR(j,25) if(lin[j]==' ') val[i]++;
// cout << i << " " << val[i] << endl;
}
int d = *min_element(val,&val[n]);
j = 0;
FOR(i,n) j += (val[i]-d);
cout << j << endl;
}
return 0;
}
| [
"[email protected]"
] | [
[
[
1,
33
]
]
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.