blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 5
146
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
7
| license_type
stringclasses 2
values | repo_name
stringlengths 6
79
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 4
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.07k
426M
⌀ | star_events_count
int64 0
27
| fork_events_count
int64 0
12
| gha_license_id
stringclasses 3
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 6
values | src_encoding
stringclasses 26
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 1
class | length_bytes
int64 20
6.28M
| extension
stringclasses 20
values | content
stringlengths 20
6.28M
| authors
listlengths 1
16
| author_lines
listlengths 1
16
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
94988f6997038c8260dae11555613f5482af1063 | 5d5b1d55ce0df21d3b6335ab92bd41e8c4cbbba5 | /arduino_lib/MyduinoMotor/MyduinoMotor.h | 306b2a1123677518e48afbb960671c398534ac78 | []
| no_license | afridifastian/roboduino | 84d7a0f83b7bc9e8af77075c3171af2ef0df55c7 | 0d25b4e858a0c0e4b790d4cbafc9705970e923b9 | refs/heads/master | 2021-01-22T04:41:10.273435 | 2011-05-25T17:44:18 | 2011-05-25T17:44:18 | 35,606,023 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 839 | h | /*
MyduinoMotor.h - Library for Arduino Motor.
Created by TaoWu<[email protected]>, May 5, 2010.
Released into the public domain.
*/
#ifndef MY_DUINO_MOTOR_H
#define MY_DUINO_MOTOR_H
#include <inttypes.h>
class MyduinoMotorClass{
public:
MyduinoMotorClass();
void MyduinoMotorPrePin(int8_t mE1, int8_t mM1, int8_t mE2, int8_t mM2);
void mapPin();
void start(bool m1Dir, bool m2Dir, int8_t m1Speed, int8_t m2Speed);
void stop();
bool readDirection_M1()const;
bool readDirection_M2()const;
int8_t readSpeed_M1()const;
int8_t readSpeed_M2()const;
private:
int8_t E1;
int8_t M1;
int8_t E2;
int8_t M2;
int8_t mSpeed_M1;
int8_t mSpeed_M2;
bool mDirection_M1;
bool mDirection_M2;
};
extern MyduinoMotorClass MyduinoMotor;
#endif
| [
"[email protected]@4f242f06-2bba-d0f2-32ac-deb01479875c"
]
| [
[
[
1,
48
]
]
]
|
1d331ae03349a11281729e125edd88b4bc29a192 | 28ba648bc8e18d3ad3878885ad39a05ebfb9259c | /CGWorkOpenGL/LightDialog.cpp | 47eee27194d8d3b097e612a39e99041c979b8e99 | []
| no_license | LinusTIAN/cg1-winter10 | 67da233f27dcf2fa693d830598473fde7d402ece | 0b929141c6eac3b96c038656e58620767ff52d9f | refs/heads/master | 2020-05-05T08:12:56.957326 | 2011-01-31T13:24:08 | 2011-01-31T13:24:08 | 36,010,723 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,886 | cpp | // LightDialog.cpp : implementation file
//
#include "stdafx.h"
#include "OpenGL.h"
#include "LightDialog.h"
// CLightDialog dialog
IMPLEMENT_DYNAMIC(CLightDialog, CDialog)
CLightDialog::CLightDialog(CWnd* pParent /*=NULL*/)
: CDialog(CLightDialog::IDD, pParent)
{
m_currentLightIdx = 0;
}
CLightDialog::~CLightDialog()
{
}
void CLightDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//ambient light
DDX_Text(pDX, IDC_AMBL_COLOR_R, m_ambiant.colorR);
DDX_Text(pDX, IDC_AMBL_COLOR_G, m_ambiant.colorG);
DDX_Text(pDX, IDC_AMBL_COLOR_B, m_ambiant.colorB);
//update light parameters for the currently selected light
DDX_Text(pDX, IDC_LIGHT_COLOR_R, m_lights[m_currentLightIdx].colorR);
DDX_Text(pDX, IDC_LIGHT_COLOR_G, m_lights[m_currentLightIdx].colorG);
DDX_Text(pDX, IDC_LIGHT_COLOR_B, m_lights[m_currentLightIdx].colorB);
DDX_Text(pDX, IDC_LIGHT_POS_X, m_lights[m_currentLightIdx].posX);
DDX_Text(pDX, IDC_LIGHT_POS_Y, m_lights[m_currentLightIdx].posY);
DDX_Text(pDX, IDC_LIGHT_POS_Z, m_lights[m_currentLightIdx].posZ);
DDX_Text(pDX, IDC_LIGHT_DIR_X, m_lights[m_currentLightIdx].dirX);
DDX_Text(pDX, IDC_LIGHT_DIR_Y, m_lights[m_currentLightIdx].dirY);
DDX_Text(pDX, IDC_LIGHT_DIR_Z, m_lights[m_currentLightIdx].dirZ);
//NOTE:Add more dialog controls which are associated with the structure below this line
//...
//the following class members can't be updated directly through DDX
//using a helper variable for type-casting to solve the compilation error
int helper=m_lights[m_currentLightIdx].enabled;
DDX_Check(pDX,IDC_LIGHT_ENABLED,helper);
m_lights[m_currentLightIdx].enabled = (bool)helper;
helper = m_lights[m_currentLightIdx].type;
DDX_CBIndex(pDX,IDC_LIGHT_TYPE,helper);
m_lights[m_currentLightIdx].type = (LightType)helper;
helper = m_lights[m_currentLightIdx].space;
DDX_CBIndex(pDX,IDC_LIGHT_SPACE,helper);
m_lights[m_currentLightIdx].space = (LightSpace)helper;
}
BEGIN_MESSAGE_MAP(CLightDialog, CDialog)
ON_BN_CLICKED(IDC_RADIO_LIGHT1, &CLightDialog::OnBnClickedRadioLight)
ON_BN_CLICKED(IDC_RADIO_LIGHT2, &CLightDialog::OnBnClickedRadioLight)
ON_BN_CLICKED(IDC_RADIO_LIGHT3, &CLightDialog::OnBnClickedRadioLight)
ON_BN_CLICKED(IDC_RADIO_LIGHT4, &CLightDialog::OnBnClickedRadioLight)
ON_BN_CLICKED(IDC_RADIO_LIGHT5, &CLightDialog::OnBnClickedRadioLight)
ON_BN_CLICKED(IDC_RADIO_LIGHT6, &CLightDialog::OnBnClickedRadioLight)
ON_BN_CLICKED(IDC_RADIO_LIGHT7, &CLightDialog::OnBnClickedRadioLight)
ON_BN_CLICKED(IDC_RADIO_LIGHT8, &CLightDialog::OnBnClickedRadioLight)
END_MESSAGE_MAP()
void CLightDialog::SetDialogData( LightID id,const LightParams& light )
{
if (id<=LIGHT_ID_AMBIENT)
m_ambiant = light;
else
m_lights[id]=light;
}
LightParams CLightDialog::GetDialogData( LightID id )
{
if (id==LIGHT_ID_AMBIENT)
return m_ambiant;
else
return m_lights[id];
}
// CLightDialog message handlers
//this callback function is called when each of the radio buttons on the dialog is clicked
void CLightDialog::OnBnClickedRadioLight()
{
//save the dialog state into the data variables
UpdateData(TRUE);
//get the newly selected light index from the radio buttons
m_currentLightIdx=GetCheckedRadioButton(IDC_RADIO_LIGHT1,IDC_RADIO_LIGHT8)-IDC_RADIO_LIGHT1;
//Update all dialog fields according to the new light index
UpdateData(FALSE);
Invalidate();
}
BOOL CLightDialog::OnInitDialog()
{
CDialog::OnInitDialog();
//Set the radio button of the current light to be selected
CheckRadioButton(IDC_RADIO_LIGHT1,IDC_RADIO_LIGHT8,m_currentLightIdx+IDC_RADIO_LIGHT1);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
| [
"slavak@2ff579a8-b8b1-c11a-477f-bc6c74f83876"
]
| [
[
[
1,
115
]
]
]
|
e22d8852c096f483c0f8e759f0f5d6b2937d6ffd | f46635ca45296b3060db74036b32fc6f8092f11c | /FGAPI_wrapper/FGAPI_wrapper/FGAPI_headers/Geodatabase.h | 0b029640517a74d75de6699c09ef2dee14580faf | []
| no_license | donnyv/filegdbapi-dotnet-example | b01c37ac11c5d88bf84f6d258dbda69b878107e2 | 8c6323c87cd73af1bbc3f7240aff2434285dc230 | refs/heads/master | 2021-01-02T22:45:04.651780 | 2011-02-11T19:07:38 | 2011-02-11T19:07:38 | 32,096,978 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,659 | h | //
// Geodatabase.h
//
#pragma once
////////////////////////////////////////////////////////////////////////////////
#include <map>
struct ci_less : std::binary_function<std::wstring, std::wstring, bool>
{
// case insensitive (ci) string less_than
// returns true if s1 < s2
// case-independent (ci) compare_less binary function
struct nocase_compare : public std::binary_function<wchar_t, wchar_t, bool>
{
bool operator() (const wchar_t& c1, const wchar_t& c2) const
{
return towlower(c1) < towlower(c2);
}
};
bool operator() (const std::wstring & s1, const std::wstring & s2) const
{
return std::lexicographical_compare(s1.begin(), s1.end(), // source range
s2.begin(), s2.end(), // dest range
nocase_compare()); // comparison
}
};
class Catalog;
class CatalogRef;
////////////////////////////////////////////////////////////////////////////////
namespace FileGDBAPI
{
class EnumRows;
class Row;
class Table;
/// A class representing a File Geodatabase.
class EXT_FILEGDB_API Geodatabase
{
public:
/// @name Schema browsing
//@{
/// Gets a list of the dataset types in the geodatabase.
/// @param[out] datasetTypes The dataset types in the geodatabase.
/// @return A long integer indicating whether the method finished successfully.
long GetDatasetTypes(std::vector<std::wstring>& datasetTypes);
/// Gets a list of relationship types in the geodatabase.
/// @param[out] relationshipTypes The relationship types in the geodatabase.
/// @return A long integer indicating whether the method finished successfully.
long GetDatasetRelationshipTypes(std::vector<std::wstring>& relationshipTypes);
/// Gets the child datasets for a particular dataset, if any.
/// If a non-existent path is provided, a -2147211775 (ITEM_NOT_FOUND) error will be returned.
/// @param[in] parentPath The dataset to find the children of, e.g. "\usa".
/// @param[in] datasetType The child dataset type as a wstring, e.g. "Feature Class". Passing in
/// an empty string will return all child datasets. <a href="ItemTypes.txt">DatasetType</a>
/// @param[out] childDatasets The children of the parent dataset, if any.
/// @return A long integer indicating whether the method finished successfully.
long GetChildDatasets(const std::wstring& parentPath, const std::wstring& datasetType, std::vector<std::wstring>& childDatasets);
/// Gets the related datasets for a particular dataset, if any.
/// If a non-existent path is provided, a -2147211775 (ITEM_NOT_FOUND) error will be returned.
/// @param[in] path The path of the dataset to find related datasets for, e.g. "\usa\streets_topology".
/// @param[in] relType The relationship type to filter return values with, e.g. "DatasetInFeatureDataset". Passing in
/// an empty string will return all related datasets. <a href="RelationshipTypes.txt">RelationshipType</a>
/// @param[in] datasetType The type of the dataset to find related datasets for. <a href="ItemTypes.txt">DatasetType</a>
/// @param[out] relatedDatasets The origin dataset's related datasets, if any.
/// @result A long integer indicating whether the method finished successfully.
long GetRelatedDatasets(const std::wstring& path, const std::wstring& relType, const std::wstring& datasetType, std::vector<std::wstring>& relatedDatasets);
//@}
/// @name Schema definition
//@{
/// Gets the definition of a dataset as an XML document.
/// If the dataset does not exist, this will fail with an error code of -2147220655 (TABLE_NOT_FOUND).
/// If a non-existent path is provided, a -2147211775 (ITEM_NOT_FOUND) error will be returned.
/// @param[in] path The requested dataset's path. e.g. "\usa\city_anno"
/// @param[in] datasetType The requested dataset's type as a string, e.g. "Table". <a href="ItemTypes.txt">DatasetType</a>
/// @param[out] datasetDef The dataset's definition as an XML document.
/// @return A long integer indicating whether the method finished successfully.
long GetDatasetDefinition(const std::wstring& path, const std::wstring& datasetType, std::string& datasetDef);
/// Gets the definitions of child datasets as a collection of XML documents.
/// If a non-existent path is provided, a -2147211775 (ITEM_NOT_FOUND) error will be returned.
/// @param[in] parentPath The parent dataset's path, e.g. "\usa".
/// @param[in] datasetType The parent dataset's type as a string, e.g. "Feature Dataset". Passing in
/// an empty string will return all child datasets. <a href="ItemTypes.txt">DatasetType</a>
/// @param[out] childDatasetDefs A collection of child dataset definitions, if any.
/// @return A long integer indicating whether the method finished successfully.
long GetChildDatasetDefinitions(const std::wstring& parentPath, const std::wstring& datasetType, std::vector<std::string>& childDatasetDefs);
/// Gets the definitions of related datasets as a collection of XML documents.
/// If a non-existent path is provided, a -2147211775 (ITEM_NOT_FOUND) error will be returned.
/// @param[in] path The origin dataset's path, e.g. "\usa\streets_topology"
/// @param[in] relType The relationship type to filter return values with, e.g. "DatasetInFeatureDataset". <a href="RelationshipTypes.txt">RelationshipType</a>
/// @param[in] datasetType The origin dataset's type as a string, e.g. "Relationship Class". Passing in
/// an empty string will return all related datasets. <a href="ItemTypes.txt">DatasetType</a>
/// @param[out] relatedDatasetDefs A collection of related dataset definitions, if any.
/// @return A long integer indicating whether the method finished successfully.
long GetRelatedDatasetDefinitions(const std::wstring& path, const std::wstring& relType, const std::wstring& datasetType, std::vector<std::string>& relatedDatasetDefs);
/// Gets the metadata of a dataset as XML.
/// If a non-existent path is provided, a -2147211775 (ITEM_NOT_FOUND) error will be returned.
/// @param[in] path The requested dataset's path. e.g. "\address_list"
/// @param[in] datasetType The requested dataset's type as a string, e.g. "Table". <a href="ItemTypes.txt">DatasetType</a>
/// @param[out] documentation The dataset's metadata as XML.
/// @return A long integer indicating whether the method finished successfully.
long GetDatasetDocumentation(const std::wstring& path, const std::wstring& datasetType, std::string& documentation);
//@}
/// @name Datasets
//@{
/// Creates a new feature dataset.
/// If the feature dataset already exists, a -2147220733 (DATASET_ALREADY_EXISTS) error will be returned.<br/>
/// If the feature dataset name is missing from the XML, a -2147220645 (INVALID_NAME) error will be returned.<br/>
/// If the XML is not UTF-8 encoded, create will fail with an error code of -2147024809 (INVALIDARG).<br/>
/// <a href="FeatureDataset.xml">XML</a>
/// <br><br>
/// @param[in] featureDatasetDef The XML definition of the feature dataset to be created.
/// @return A long integer indicating whether the method finished successfully.
long CreateFeatureDataset(const std::string& featureDatasetDef);
/// Creates a new table. This can either be a table or a feature class.<br/>
/// If the table already exists, a -2147220653 (TABLE_ALREADY_EXISTS) error will be returned.<br/>
/// If the table name is missing from the XML, a -2147220645 (INVALID_NAME) error will be returned.<br/>
/// If the XML is not UTF-8 encoded, create will fail with an error code of -2147024809 (INVALIDARG).<br/>
/// <br><a href="Table.xml">XML-Table</a><br><a href="FC_GCS_Line.xml">XML-Feature Class</a>
/// @param[in] tableDef The XML definition of the table to be created.
/// @param[in] parent The location where the table will be created. Pass an empty string if you want to
/// create a table or feature class at the root. If you want to create a feature class in an existing feature
/// dataset use the path "\USA".
/// @param[out] table An Table instance for the newly created table.
/// @return A long integer indicating whether the method finished successfully.
long CreateTable(const std::string& tableDef, const std::wstring& parent, Table& table);
/// Opens a table. This can also be used open attributed and M:N relationship class tables.
/// If the table does not exist, a -2147220655 (TABLE_NOT_FOUND) error will be returned.
/// @param[in] path The path of the table to open. Opening a table or feature class at
/// the root make sure to include "\". If opening a feature class in a feature dataset include
/// the feature dataset name in the path "\USA\counties".
/// @param[out] table An Table instance for the opened table.
/// @return A long integer indicating whether the method finished successfully.
long OpenTable(const std::wstring& path, Table& table);
/// Closes a table that has been previously created or opened.
/// @param[in] table The table to close.
/// @return A long integer indicating whether the method finished successfully.
long CloseTable(Table& table);
/// Renames a dataset.
/// @param[in] path The path of the dataset, e.g. "\Landbase\Parcels".
/// @param[in] newName The name to apply to the dataset, e.g. "Parcels2".
/// @return A long integer indicating whether the method finished successfully.
long Rename(const std::wstring& path, const std::wstring& newName);
/// Moves a dataset from one container to another.
/// @param[in] path The path of the dataset to move, e.g. "\Landbase\Parcels".
/// @param[in] newParentPath The path of the container the dataset will be moved to, e.g. "\LandUse".
/// @return A long integer indicating whether the method finished successfully.
long Move(const std::wstring& path, const std::wstring& newParentPath);
/// Deletes a dataset.
/// If a the dataset does not exist, this will fail with an error code of -2147219118 (ROW_NOT_FOUND).<br/>
/// If you do not have delete access to the dataset, this will fail with an error code of E_FAIL.<br/>
/// @param[in] path The path of the dataset to delete, e.g. "\Owners".
/// @param[in] datasetType The requested dataset's type as a string, e.g. "Table". <a href="ItemTypes.txt">DatasetType</a>
/// @return A long integer indicating whether the method finished successfully.
long Delete(const std::wstring& path, const std::wstring& datasetType);
//@}
/// @name Domains
//@{
/// Creates a domain.
/// If the XML is not UTF-8, create will fail with an error code of -2147024809 (INVALIDARG).<br/>
/// If the domain name already exists, a -2147215532 (DOMAIN_NAME_ALREADY_EXISTS) error will be returned.<br/>
/// <a href="CodedValueDomain.xml">XML - Coded Value Domain</a> <a href="RangeDomain.xml">XML - Range Domain</a>
/// @param[in] domainDef The XML definition of the domain to be created.
/// @return A long integer indicating whether the method finished successfully.
long CreateDomain(const std::string& domainDef);
/// Modifies the properties of an existing domain.
/// If the XML is not UTF-8, create will fail with an error code of -2147024809 (INVALIDARG).<br/>
/// @param[in] domainDef The modified XML definition of the domain.
/// @return A long integer indicating whether the method finished successfully.
long AlterDomain(const std::string& domainDef);
/// Deletes the specified domain.
///If the domain does not exist, this will fail with an error code of -2147209215 (DOMAIN_NOT_FOUND).<br/>
/// @param[in] domainName The name of the domain to delete.
/// @return A long integer indicating whether the method finished successfully.
long DeleteDomain(const std::wstring& domainName);
/// Gets the definition of the specified domain.
/// @param[in] domainName The name of the domain.
/// @param[in] domainDef The XML definition of the domain to be created.
/// @return A long integer indicating whether the method finished successfully.
long GetDomainDefinition(const std::wstring& domainName, std::string& domainDef);
//@}
/// @name SQL
//@{
/// Gets the query name (the name to use in SQL statements) of a table based on its path.
/// @param[in] path The path of the dataset that will be queried.
/// @param[out] queryName The name that should be used for the table in SQL statements.
/// @return A long integer indicating whether the method finished successfully.
long GetQueryName(const std::wstring& path, std::wstring& queryName);
/// Executes a SQL statement on the geodatabase. This may or may not return a result set.
/// If the SQL statement is invalid, an -2147220985 (INVALID_SQL) error will be returned.<br/>
/// @param[in] sqlStmt The SQL statement to be executed.
/// @param[in] recycling Indicates whether the row enumerator should recycle memory.
/// @param[out] rows An enumerator of rows or a null value.
/// @return A long integer indicating whether the method finished successfully.
long ExecuteSQL(const std::wstring& sqlStmt, bool recycling, EnumRows& rows);
//@}
/// @name Constructors and Destructors
//@{
/// The class constructor.
Geodatabase();
/// The class destructor.
~Geodatabase();
//@}
private:
/// @cond PRIVATE
long CreateGeodatabase(const std::wstring& path);
long OpenGeodatabase(const std::wstring& path);
long CloseGeodatabase();
long DeleteGeodatabase();
bool IsSetup();
Catalog* m_pCatalog;
std::map<Table*, Table*> m_tableROT;
friend EXT_FILEGDB_API long CreateGeodatabase(const std::wstring& path, Geodatabase& geodatabase);
friend EXT_FILEGDB_API long OpenGeodatabase(const std::wstring& path, Geodatabase& geodatabase);
friend EXT_FILEGDB_API long CloseGeodatabase(Geodatabase& geodatabase);
friend EXT_FILEGDB_API long DeleteGeodatabase(const std::wstring& path);
friend class Table;
static std::map<std::wstring, CatalogRef*, ci_less> m_catalogROT;
Geodatabase(const Geodatabase&) { }
Geodatabase& operator=(const Geodatabase&) { return *this; }
/// @endcond
};
}; // namespace FileGDBAPI
| [
"[email protected]@55f01ca7-fafe-a058-1a29-a2f4ad2297cc"
]
| [
[
[
1,
264
]
]
]
|
ee055486ce87cf7373166f01da4ed9921c71cd08 | 8c40bb1e4e7220809a7a92b6ea87a51e8c314360 | /ChatClient/DxSound.cpp | 550743bb86908f05be6a0e60fdc5d7e63acc65a2 | []
| no_license | littlewingsoft/gwdummy | 1c10538770ea52dd9159f8fe50090398b6d744c0 | 996dffd30bb680d52d0422f220986bf4502a201a | refs/heads/master | 2021-01-10T21:23:25.968724 | 2010-05-13T13:04:29 | 2010-05-13T13:04:29 | 32,302,169 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,396 | cpp | /*
The author : jazonsim
Create Date : 1998/08/25
Modify Date : 2001/05/24
*/
#include "DxSound.h"
#pragma comment(lib, "dsound.lib")
CDxSound DS;
#ifdef DEF_DXSOUND_VER1
BOOL CDxSound::InitDS(HWND hWnd)
{
m_hWnd = hWnd;
// Create the main DirectSound object.
HRESULT result = DirectSoundCreate(0, &m_pDirectSoundObj, 0);
if(result != DS_OK) return FALSE;
// Set the priority level.
result = m_pDirectSoundObj->SetCooperativeLevel(m_hWnd, DSSCL_NORMAL);
if(result != DS_OK)
{
m_pDirectSoundObj = 0;
return FALSE;
}
return TRUE;
}
void CDxSound::ExitDS(void)
{
if(m_pDirectSoundObj != 0)
{
m_pDirectSoundObj->Release();
m_pDirectSoundObj = 0;
}
}
#endif //DEF_DXSOUND_VER1
#ifdef DEF_DXSOUND_VER9
BOOL CDxSound::InitDS(HWND hWnd)
{
m_hWnd = hWnd;
// Create the main DirectSound object.
HRESULT result = DirectSoundCreate8(0, &m_pDirectSoundObj, 0);
if(result != DS_OK) return FALSE;
// Set the priority level.
result = m_pDirectSoundObj->SetCooperativeLevel(m_hWnd, DSSCL_NORMAL);
if(result != DS_OK)
{
m_pDirectSoundObj = 0;
return FALSE;
}
return TRUE;
}
void CDxSound::ExitDS(void)
{
if(m_pDirectSoundObj != 0)
{
m_pDirectSoundObj->Release();
m_pDirectSoundObj = 0;
}
}
#endif //DEF_DXSOUND_VER9
| [
"jungmoona@317d3104-4b19-9edd-f554-c50553ae2c9a"
]
| [
[
[
1,
75
]
]
]
|
e17a863b08805ad07430b1c5309f1a114d50ca77 | 9a5db9951432056bb5cd4cf3c32362a4e17008b7 | /FacesCapture/trunk/RemoteImaging/FaceSearchWrapper/FaceSearchWrapper.h | 3251ea09407543d9766dfa735066c89bd96204be | []
| no_license | miaozhendaoren/appcollection | 65b0ede264e74e60b68ca74cf70fb24222543278 | f8b85af93f787fa897af90e8361569a36ff65d35 | refs/heads/master | 2021-05-30T19:27:21.142158 | 2011-06-27T03:49:22 | 2011-06-27T03:49:22 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,376 | h | // FaceSearchWrapper.h
#pragma once
#include "../../OutPut/FaceSelect.h"
#include "FaceSearchConfiguration.h"
using namespace System;
using namespace System::Runtime::InteropServices;
namespace FaceSearchWrapper {
public ref class FaceSearch
{
// TODO: Add your methods for this class here.
public:
FaceSearch::FaceSearch(void);
FaceSearch::~FaceSearch(void);
//Michael Add -- 设置类变量的接口
void SetROI( int x, int y, int width, int height );
void SetFaceParas( int iMinFace, double dFaceChangeRatio);
void SetDwSmpRatio( double dRatio );
void SetOutputDir( const char* dir );
//SetExRatio : 设置输出的图片应在人脸的四个方向扩展多少比例
//如果人脸框大小保持不变,4个值都应该为0.0f
void SetExRatio( double topExRatio, double bottomExRatio, double leftExRatio, double rightExRatio );
void SetLightMode(int iMode);
void AddInFrame(ImageProcess::Frame^ frame);
array<ImageProcess::Target^>^ SearchFacesFastMode(ImageProcess::Frame^ frame);
array<ImageProcess::Target^>^ SearchFaces();
OpenCvSharp::IplImage^ NormalizeImage(OpenCvSharp::IplImage^ imgIn, OpenCvSharp::CvRect roi);
array<OpenCvSharp::IplImage^>^ NormalizeImageForTraining(OpenCvSharp::IplImage^ imgIn, OpenCvSharp::CvRect roi);
property FaceSearchConfiguration^ Configuration
{
FaceSearchConfiguration^ get()
{
return this->config;
}
void set(FaceSearchConfiguration^ cfg)
{
this->config = cfg;
this->pFaceSearch->SetFaceParas(this->config->MinFaceWidth, this->config->FaceWidthRatio);
this->pFaceSearch->SetExRatio(this->config->TopRation,
this->config->BottomRation,
this->config->LeftRation,
this->config->RightRation);
this->pFaceSearch->SetLightMode(this->config->EnvironmentMode);
this->pFaceSearch->SetROI(this->config->SearchRectangle->Left,
this->config->SearchRectangle->Top,
this->config->SearchRectangle->Width,
this->config->SearchRectangle->Height);
}
}
private:
::CvRect ManagedRectToUnmanaged(OpenCvSharp::CvRect^ managedRect);
OpenCvSharp::CvRect UnmanagedRectToManaged(const ::CvRect& unmanaged);
FaceSearchConfiguration^ config;
CFaceSelect *pFaceSearch;
};
}
| [
"shenbinsc@cbf8b9f2-3a65-11de-be05-5f7a86268029"
]
| [
[
[
1,
68
]
]
]
|
c0271b324cf58754f91585183bd1e35b5c22065d | 71ffdff29137de6bda23f02c9e22a45fe94e7910 | /KillaCoptuz3000/src/CEvent.h | 38a08b380c94faf8c23e1ed21f5f9cb1cbd2c8cf | []
| no_license | anhoppe/killakoptuz3000 | f2b6ecca308c1d6ebee9f43a1632a2051f321272 | fbf2e77d16c11abdadf45a88e1c747fa86517c59 | refs/heads/master | 2021-01-02T22:19:10.695739 | 2009-03-15T21:22:31 | 2009-03-15T21:22:31 | 35,839,301 | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 787 | h | // ***************************************************************
// CEvent version: 1.0 · date: 06/11/2007
// -------------------------------------------------------------
//
// -------------------------------------------------------------
// Copyright (C) 2007 - All Rights Reserved
// ***************************************************************
//
// ***************************************************************
#ifndef CEVENT_H
#define CEVENT_H
#include <vector>
enum EEventType {e_delete, e_collided};
class CEvent
{
public:
CEvent();
CEvent(EEventType t_type);
~CEvent();
/** List of participating object id's*/
std::vector<unsigned int> m_objectList;
/** Event type*/
EEventType m_event;
};
#endif
| [
"anhoppe@9386d06f-8230-0410-af72-8d16ca8b68df",
"fabianheinemann@9386d06f-8230-0410-af72-8d16ca8b68df"
]
| [
[
[
1,
15
],
[
17,
33
]
],
[
[
16,
16
]
]
]
|
2e576f06d9df1e608852a76c1b0fa7a0f7ba3f7e | 25f79693b806edb9041e3786fa3cf331d6fd4b97 | /tests/unit/sorting/BitonicSortTest.h | 00016fcdfd5b4d61aeb2d35e963394abbdc765f8 | []
| no_license | ouj/amd-spl | ff3c9faf89d20b5d6267b7f862c277d16aae9eee | 54b38e80088855f5e118f0992558ab88a7dea5b9 | refs/heads/master | 2016-09-06T03:13:23.993426 | 2009-08-29T08:55:02 | 2009-08-29T08:55:02 | 32,124,284 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 439 | h | #ifndef _BITONIC_SORT_TEST_H_
#define _BITONIC_SORT_TEST_H_
#include "gtest/gtest.h"
#include "SplBitonicSort.h"
using namespace std;
class BitonicSortTest : public testing::Test
{
protected:
static void SetUpTestCase();
static void TearDownTestCase();
static bool HasFatalFailure();
public:
static unsigned int Length;
private:
static bool m_Fatal;
};
#endif
| [
"jiawei.ou@1960d7c4-c739-11dd-8829-37334faa441c"
]
| [
[
[
1,
22
]
]
]
|
971931fc09cbadb19841ab2b1a0a06c8f9c3d369 | 971b000b9e6c4bf91d28f3723923a678520f5bcf | /PaginationFormat/fop_format/Fo_Reader.cpp | 1d6c65bd1e0e6045f9565955604926f512960436 | []
| 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 | 54,753 | cpp | #include "Fo_Reader.h"
#include "Config.h"
using namespace ApacheFop;
Fo_Reader::~Fo_Reader()
{
ApiSession *session = ApiSession::instance();
session->current_Page_Format = PSize();
}
Fo_Reader::Fo_Reader( const QString readfile , QObject *parent )
: Fo_Format( parent ),device( new StreamFop()),
file(0),Qdoc(new QTextDocument()),LayerCount(0),
Current_Block_Tree_Level(0),oldMiniScribusFormat(false)
{
doc_cur = 0;
QFont userfont( QApplication::font() );
userfont.setPointSize(_DEFAULT_FONT_POINT_SIZE_);
Qdoc->setDefaultFont ( userfont );
Tcursor = QTextCursor(Qdoc);
finfo = QFileInfo(readfile);
file = finfo.absoluteFilePath();
ImageCount = 0;
table_cur = 0;
LoadFopFile(file);
}
void Fo_Reader::LoadFopFile( const QString readfile )
{
if (device->LoadFile(readfile))
{
if (device->isValid())
{
finfo = QFileInfo(readfile);
const QString ext = finfo.completeSuffix().toLower();
oldMiniScribusFormat = ext == "fop" ? true : false;
file = finfo.absoluteFilePath();
read_dir = QDir(finfo.absolutePath());
Xdoc = device->Dom();
delete device;
device = new StreamFop();
read();
}
}
}
void Fo_Reader::read()
{
QDomElement root = Xdoc.documentElement();
if (root.tagName() !="fo:root")
{
return;
}
ApiSession *session = ApiSession::instance();
QDomElement layout_master = root.firstChildElement("fo:layout-master-set");
QDomElement layout = layout_master.firstChildElement("fo:simple-page-master");
qreal pwi = Unit(layout.attribute ("page-width",QString("210mm")));
qreal phi = Unit(layout.attribute ("page-height",QString("297mm")));
PageSize = session->FindPagePsize(QRect(0,0,pwi,phi));
QString yourname = layout.attribute("master-name");
const qreal largefront = qMax (pwi,phi);
while (!layout.isNull())
{
qreal xBottomMargin = Unit(layout.attribute ("margin-bottom",QString("1cm")));
qreal xTopMargin = Unit(layout.attribute ("margin-top",QString("1cm")));
qreal xRightMargin = Unit(layout.attribute ("margin-right",QString("1cm")));
qreal xLeftMargin = Unit(layout.attribute ("margin-left",QString("1cm")));
MarginPage = QRectF(xTopMargin,xRightMargin,xBottomMargin,xLeftMargin);
////////////////// QRectF(top,right,bottom,left);
if (yourname.size() < 5) {
yourname = layout.attribute("master-name");
}
////// QRectF(xTopMargin,xRightMargin,xBottomMargin,xLeftMargin);
QDomElement body = layout.firstChildElement("fo:region-body");
FindMargin(body);
QDomElement footer = layout.firstChildElement("fo:region-after");
FindMargin(footer);
layout = layout.nextSiblingElement("fo:simple-page-master");
}
PageSize.SetMargin( MarginPage );
PageSize.landscape = largefront == phi ? false : true;
PageSize.P_rect = QPrinter::Custom;
if (yourname.size() > 5) {
PageSize.name = yourname;
}
session->current_Page_Format = PageSize;
session->AppendPaper(PageSize);
Docwidth = pwi - MarginPage.y() - MarginPage.height();
session->CurrentDocWidth = Docwidth;
Qdoc->setPageSize ( QSizeF( Docwidth , phi - MarginPage.x() - MarginPage.width() ) );
Qdoc->setTextWidth ( Docwidth ); /* remove margin */
QDomElement master = root.firstChildElement("fo:page-sequence");
Tcursor.setPosition(0);
/* header & footer here ! */
QDomElement page = master.firstChildElement("fo:flow");
qDebug() << "### Docwidth " << Docwidth;
qDebug() << "### START READ DOCUMENT ################################################################";
RootFramePaint(page);
/*
QString debugtext = session->DebugAttributes();
Tcursor.setPosition(doc_cur);
Tcursor.beginEditBlock();
Tcursor.setCharFormat(DefaultCharFormats());
Tcursor.insertText(debugtext);
Tcursor.endEditBlock();
Tcursor.atBlockEnd();
*/
doc_cur = Tcursor.position();
}
bool Fo_Reader::placeNewAbsoluteLayer( const QDomElement e )
{
QStringList attri = attributeList(e);
LayerCount++;
QMap<QString,SPics> list;
const QString style = attri.join(";");
qDebug() << "### inite an absolute " << style;
QTextDocument *ldoc = new QTextDocument();
QTextCursor layercursor(ldoc);
FrameDomIterator(e.firstChild(),layercursor);
RichDoc xlayer;
xlayer.Register(ldoc,list,style);
layerList.insert(LayerCount,xlayer);
return true;
}
void Fo_Reader::RootFramePaint( const QDomElement e )
{
if (e.tagName() !="fo:flow")
{
return;
}
Tcursor = QTextCursor(Qdoc);
Qdoc->clear();
DocRootFrameDefault();
MoveEndDocNow();
////////////qDebug() << "### root move cursor " << doc_cur;
doc_cur = Tcursor.position();
QDomNode child = e.firstChild();
QDomElement LastElementParent = e;
int tagposition = -1;
while ( !child.isNull() )
{
if ( child.isElement() )
{
const QDomElement el = child.toElement();
tagposition++;
if ( tagposition == 0 )
{
}
////////////qDebug() << "### FRAME/Root loop Iterator " << el.tagName() << " pos." << tagposition;
if ( FoTag(el) == INLINE_BR )
{
///////////qDebug() << "### root line breack............................... ";
Tcursor.insertText(QString(QChar::LineSeparator));
MoveEndDocNow();
}
else if (FoTag(el) == FOLEADER)
{
FoLeaderPaint(el,Tcursor);
MoveEndDocNow();
}
else if (FoTag(el) == BLOCK_TAG)
{
FoBlockTagPaint(el,Tcursor); /* root blocks */
MoveEndDocNow();
qDebug() << "### paragraph " << tagposition << " ------------------------------------------------------------------------------";
}
else if ( FoTag(el) == FOOTNOTEBOTTOM )
{
//////FootNoteSave(el,Tcursor);
///////MoveEndDocNow();
}
else if (FoTag(el) == BLOCK_CONTAINER)
{
FoBlockContainerPaint(el,Tcursor);
MoveEndDocNow();
}
else if (FoTag(el) == TABLE_TAG)
{
FoTableTagPaint(el);
MoveEndDocNow();
}
else if (FoTag(el) == LIST_BLOCK)
{
FoListUlTagPaint(el);
MoveEndDocNow();
}
else if ( FoTag(el) == FLOATBLOCK )
{
/* root frame conflict insert para null*/
Tcursor.beginEditBlock();
Tcursor.setBlockFormat(DefaultMargin());
doc_cur = Tcursor.position();
bool Bx = FoFloatingContainerPaint(el,LastElementParent);
Tcursor.endEditBlock();
MoveEndDocNow();
}
else
{
/* not relax tag */
if (FoTag(el) == TAG_NOT_KNOW )
{
DidplayUnknowTag(el,Tcursor);
}
MoveEndDocNow();
}
LastElementParent = el;
}
child = child.nextSibling();
}
doc_cur = Tcursor.position();
MoveEndDocNow();
qDebug() << "### END READ DOCUMENT ################################################################";
}
/* only root block */
bool Fo_Reader::RunningFirstFrame( QTextCursor Cursor )
{
QTextFrame *rootframe = Qdoc->rootFrame();
int CursorFirstFrame = rootframe->firstPosition();
return CursorFirstFrame == Cursor.position() ? true : false;
}
bool Fo_Reader::FoBlockTagPaint( const QDomElement e , QTextCursor Cursor )
{
Current_Block_Tree_Level = 0;
if (FoTag(e) != BLOCK_TAG)
{
return false;
}
QTextBlockFormat dd;
QTextCharFormat cc;
///////Cursor.setBlockFormat(dd); /* try to reset !!!! */
Cursor.setCharFormat(cc); /* try to reset !!!! */
const QTextBlockFormat blf = TextBlockFormFromDom(e, DefaultMargin());
if (FoTag(e) == INLINE_BR)
{
return false;
}
if (RunningFirstFrame(Cursor))
{
qDebug() << "#### First root block " << __LINE__;
}
else
{
Cursor.insertBlock();
Cursor.setBlockFormat(blf);
}
return InlineBlockLoop(e,Cursor);
}
bool Fo_Reader::FoLeaderPaint( const QDomElement e , QTextCursor Cursor )
{
if (FoTag(e) != FOLEADER)
{
return false;
}
/* check if is a self writteln fo:leader to emulate a breack line or empity paragraph !!!! */
if ( e.attribute("leader-pattern") == "space" &&
e.attribute("leader-length") == RecoveryBreackLineParagraph() &&
AllowtoBreack(e)) {
/* breack line br check line hight ???? */
Cursor.setBlockFormat(DefaultMargin());
Cursor.insertText(QString(QChar::Nbsp),DefaultCharFormats());
Cursor.setCharFormat ( DefaultCharFormats() );
Cursor.endEditBlock();
Cursor.atBlockEnd();
return true;
}
/* draw space */
FopLeader space;
space.read(e,Docwidth);
const QString namespaceimg = space.Name();
/* dispay */
QPixmap spaceimg = space.DummyImage();
QUrl recresourcein(namespaceimg);
Qdoc->addResource( QTextDocument::ImageResource,recresourcein,spaceimg);
SPics ximg;
ximg.name = namespaceimg;
ximg.set_pics(spaceimg);
/* insert pixel 1 x1 */
QTextImageFormat format;
format.setName( ximg.name );
format.setHeight( spaceimg.height() );
format.setWidth ( spaceimg.width() );
format.setProperty(LeaderNummer,space);
Cursor.insertImage( format );
if (space.leaderpattern == 3)
{
/////leader-pattern = space | rule | dots | use-content | inherit
FrameDomIterator(e.firstChild(),Cursor);
return false;
}
return false;
}
void Fo_Reader::DidplayUnknowTag( const QDomElement e , QTextCursor Cursor )
{
const QString tagname = e.tagName().toLower();
QDomDocument wrax = DomelenentToString(e,QString("Unknow Tag %1: please send a report to author if this tag is important! try to Fop file to ispect this tag.").arg(tagname));
QString pretag = Qt::escape(wrax.toString(1));
pretag.prepend("<pre>");
pretag.append("</pre>");
QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(pretag);
Cursor.setCharFormat ( PreFormatChar() );
Cursor.insertFragment(fragment);
Cursor.setCharFormat ( PreFormatChar() );
}
bool Fo_Reader::InlineSpanning( const QDomElement e , const QDomElement parentup , QTextCursor Cinline , bool HandleSpace ) /* default false */
{
qDebug() << "### InlineSpanning................................ ";
if (FoTag(e) != INLINE_STYLE)
{
return false;
}
if (FoTag(e) == INLINE_BR)
{
return false;
}
Current_Block_Tree_Level++;
QTextBlockFormat Paraformat = TextBlockFormFromDom(parentup,DefaultMargin());
QTextCharFormat Charformat = GlobalCharFormat(parentup,DefaultCharFormats());
const QTextCharFormat InlineStyle = GlobalCharFormat(e,Charformat);
Cinline.setCharFormat(InlineStyle);
QStringList texter = e.text().split("\n");
for (int i = 0; i < texter.size(); ++i)
{
if (HandleSpace)
{
Cinline.insertText(foptrimmed(texter.at(i),e.attribute("text-transform")));
}
else
{
Cinline.insertText(texter.at(i));
}
if (i > 0)
{
Cinline.insertText(QString(QChar::Nbsp)); /////
}
}
doc_cur = Cinline.position();
QDomNode child = e.firstChild();
QDomElement LastElementParent = e;
while ( !child.isNull() )
{
if ( child.isElement() )
{
const QDomElement childElement = child.toElement();
const QTextCharFormat InlineStyle = GlobalCharFormat(childElement,Charformat);
if ( FoTag(childElement) == INLINE_BR )
{
Cinline.insertText(QString(QChar::LineSeparator));
}
else if ( FoTag(childElement) == INLINE_STYLE)
{
InlineSpanning(childElement,parentup,Cinline,HandleSpace);
Cinline.setCharFormat(Charformat);
}
else if ( FoTag(childElement) == LINK_DOC )
{
Cinline.setCharFormat(InlineStyle);
Cinline.insertText(foptrimmed(childElement.text(),childElement.attribute("text-transform")));
Cinline.setCharFormat(Charformat);
}
}
doc_cur = Cinline.position();
child = child.nextSibling();
}
doc_cur = Cinline.position();
return true;
}
void Fo_Reader::FootNoteSave( const QDomElement e , QTextCursor Cursor )
{
/* register tag to resave */
return;
}
bool Fo_Reader::InlineBlockLoop( const QDomElement e , QTextCursor Cinline , bool skipborder ) /* default false */
{
if (FoTag(e) != BLOCK_TAG)
{
return false;
}
if (FoTag(e) == INLINE_BR)
{
return false;
}
Current_Block_Tree_Level++;
const int OriginalPos = Cinline.position();
if (RunningFirstFrame(Cinline))
{
Cinline.beginEditBlock();
Cinline.setBlockFormat(DefaultMargin());
}
QTextBlock bf = Cinline.block();
Cinline.beginEditBlock();
QTextBlockFormat bbformat = Cinline.block().blockFormat();
const QTextBlockFormat blf = TextBlockFormFromDom(e,bbformat);
bbformat.setAlignment( TagAlignElement(e) ); /////TagAlignElement(e)
QTextCharFormat Charformat;
Charformat = GlobalCharFormat(e,DefaultCharFormats());
/* HandleSpace default forever true */
bool HandleSpace = e.attribute("white-space-collapse","true") == "true" ? true : false;
bool NoWrapLine = e.attribute("wrap-option","wrap") == "wrap" ? false : true;
if (!HandleSpace)
{
bbformat.setProperty(QTextFormat::BlockNonBreakableLines,1);
bbformat.setNonBreakableLines(true);
}
if (NoWrapLine)
{
bbformat.setNonBreakableLines(true);
HandleSpace = false;
}
int BlockNummer = Cinline.block().position();
qDebug() << "### InlineBlockLoop top margin " << bbformat.topMargin() << "BB nr.->" << BlockNummer << "BB tree level->" << Current_Block_Tree_Level;
Cinline.setBlockFormat(blf);
Cinline.setCharFormat(Charformat);
QDomNode child = e.firstChild();
QDomElement LastElementParent = e;
int tagposition = -1;
while ( !child.isNull() )
{
tagposition++;
if ( child.isElement() )
{
const QDomElement childElement = child.toElement();
const QTextCharFormat InlineStyle = GlobalCharFormat(childElement,Charformat);
//////////// qDebug() << "### BLock loop Iterator " << childElement.tagName() << " pos." << tagposition;
if ( !childElement.hasAttributes() && !childElement.hasChildNodes() )
{
///////////////Cinline.insertText(QString(QChar::LineSeparator)); /* null tag !!!!!!! only name */
} if ( FoTag(childElement) == INLINE_STYLE)
{
InlineSpanning(childElement,e,Tcursor,HandleSpace);
Cinline.setCharFormat(Charformat);
}
else if ( FoTag(childElement) == INLINE_BR )
{
Tcursor.insertText(QString(QChar::LineSeparator));
}
else if ( FoTag(childElement) == FOPAGENRCITATION )
{
Tcursor.insertText(".");
}
else if ( FoTag(childElement) == FOLEADER )
{
bool brline = FoLeaderPaint(childElement,Tcursor);
if (brline) {
return true;
}
}
else if ( FoTag(childElement) == FOOTNOTEBOTTOM )
{
/* register tag to resave */
FopLeader footnote;
footnote.read(childElement,Docwidth);
bbformat.setProperty(FootNoteNummer,footnote);
Cinline.setBlockFormat(bbformat);
//////qDebug() << "### FootNoteSave on block " << footnote.ELoriginal;
/////FootNoteSave(childElement,Tcursor);
}
else if ( FoTag(childElement) == LINK_DOC )
{
Tcursor.setCharFormat(InlineStyle);
Tcursor.insertText(foptrimmed(childElement.text(),childElement.attribute("text-transform")));
Tcursor.setCharFormat(Charformat);
}
else if ( childElement.tagName().toLower() == "fo:page-number" )
{
Tcursor.setCharFormat(InlineStyle);
Tcursor.insertText("#Page#");
Tcursor.setCharFormat(Charformat);
}
else if ( FoTag(childElement) == FOCHAR )
{
/* One letter format make frame float left right? fo:page-number*/
Cinline.setCharFormat(InlineStyle);
Cinline.insertText(childElement.attribute ("character"));
Cinline.setCharFormat(Charformat);
}
else if ( FoTag(childElement) == BLOCK_CONTAINER)
{
/* inline frame elements */
FoBlockContainerPaint(childElement,Cinline);
}
else if ( FoTag(childElement) == TABLE_TAG )
{
FoTableTagPaint( childElement );
}
else if ( FoTag(childElement) == IMAGE_INLINE )
{
FoDrawSvgInline( childElement );
qDebug() << "## svg image paint ";
}
else if ( FoTag(childElement) == IMAGE_SRC )
{
FoDrawImage( childElement );
}
else if ( FoTag(childElement) == FLOATBLOCK )
{
FoFloatingContainerPaint(childElement,LastElementParent);
}
else
{
/* not relax tag */
if (FoTag(childElement) == TAG_NOT_KNOW )
{
DidplayUnknowTag(childElement,Cinline);
}
}
/////FoDrawImage( const QDomElement e )
LastElementParent = childElement;
}
else if (child.isCDATASection())
{
const QDomCDATASection ChunkPRE = child.toCDATASection();
QString pretag = Qt::escape(child.nodeValue());
pretag.prepend("<pre>");
pretag.append("</pre>");
QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(pretag);
Cinline.setCharFormat ( PreFormatChar() );
Cinline.insertFragment(fragment);
Cinline.setCharFormat ( PreFormatChar() );
bbformat.setProperty(QTextFormat::BlockNonBreakableLines,1);
bbformat.setNonBreakableLines(true);
}
else if (child.isText())
{
/* plain text normal */
///////const QDomText txtNode = child.toText()()
QString paratext = child.nodeValue();
QStringList texter = paratext.split("\n");
if (texter.size() > 0)
{
for (int i = 0; i < texter.size(); ++i)
{
if (HandleSpace)
{
Cinline.insertText(foptrimmed(texter.at(i),e.attribute("text-transform")));
}
else
{
Cinline.insertText(texter.at(i));
}
///////qDebug() << "### block text " << texter.at(i).simplified();
if (i > 0)
{
Cinline.insertText(QString(QChar::Nbsp)); /////
}
}
}
else
{
Cinline.insertText("ERROR DOM......");
}
}
child = child.nextSibling();
}
Cinline.setBlockFormat(bbformat);
Cinline.endEditBlock();
Cinline.atBlockEnd();
return true;
}
bool Fo_Reader::FoBlockContainerPaint( const QDomElement e , QTextCursor Cinline )
{
if (FoTag(e) != BLOCK_CONTAINER) /* block in block make frame */
{
return false;
}
if (FoTag(e) == INLINE_BR)
{
return false;
}
FopLeader xx;
xx.read(e,Docwidth);
QColor bgcolor = QColor(Qt::white);
qDebug() << "### fo:block-containerPaint a " << e.tagName();
///////if (IsAbsoluteLayer(e))
const int rotateD = e.attribute("reference-orientation","0").toInt();
qreal LargeWi = Unit(e.attribute("width","0"));
qreal lleft = Unit(e.attribute("left","0"));
qreal ltop = Unit(e.attribute("top","0"));
QTextLength wide = BlockMesure(e);
qDebug() << "### fo:block-containerPaint c " << wide.rawValue();
/* check if absolute */
if (wide.rawValue() > 9 && !e.attribute("left").isEmpty() && !e.attribute("top").isEmpty()) {
return placeNewAbsoluteLayer(e);
}
QTextFrameFormat frame = xx.format;
frame.setWidth(wide);
QTextFrameFormat FrameFormat = PaintFrameFormat(e,frame);
if (!e.attribute("background-color").isEmpty())
{
bgcolor = ColorFromFoString( e.attribute("background-color") );
}
QDomElement firstPara = e.firstChildElement("fo:block");
if (!firstPara.isNull())
{
if (!firstPara.attribute("background-color").isEmpty())
{
bgcolor = ColorFromFoString(firstPara.attribute("background-color") );
}
}
FrameFormat.setBackground(bgcolor);
QTextFrame *Divframe = Cinline.insertFrame(FrameFormat);
doc_cur = Divframe->firstPosition();
Cinline.setPosition(doc_cur);
FrameDomIterator(e.firstChild(),Cinline);
return true;
}
void Fo_Reader::PaintMessage( QTextCursor Curs , const QString msg )
{
Curs.insertBlock();
Curs.setBlockFormat(DefaultMargin());
Curs.insertText(QString("Error Message:\n%1").arg(msg),AlertCharFormats());
Curs.endEditBlock();
Curs.atBlockEnd();
doc_cur = Curs.position();
}
bool Fo_Reader::FoListUlTagPaint( const QDomElement e )
{
qDebug() << "### FoListUlTagPaint aaaa " << e.tagName();
if (FoTag(e) != LIST_BLOCK)
{
return false;
}
bool fattoblocco = false;
int lisumm = 0;
Tcursor.setPosition(doc_cur);
QTextBlock bf = Tcursor.block();
QTextBlockFormat format = TextBlockFormFromDom(e,bf.blockFormat());
Tcursor.setBlockFormat(format);
QTextListFormat formatul = TextListFromFromDom(e);
formatul.setStyle ( QTextListFormat::ListDisc );
formatul.setIndent(1);
QDomElement litem = e.firstChildElement("fo:list-item");
QTextList *Uls = Tcursor.insertList( formatul );
while ( !litem.isNull() )
{
QDomElement libody = litem.firstChildElement("fo:list-item-body");
QDomElement sublock = libody.firstChildElement("fo:block");
if (!sublock.isNull())
{
lisumm++;
if (lisumm > 0 )
{
Tcursor.insertBlock();
}
fattoblocco = InlineBlockLoop(sublock,Tcursor);
Uls->add( Tcursor.block() );
qDebug() << "### li " << fattoblocco << " nr.->" << lisumm;
}
litem = litem.nextSiblingElement("fo:list-item");
}
Uls->removeItem(0);
//////////qDebug() << "### doc_cur at list " << doc_cur;
return true;
}
bool Fo_Reader::FoDrawImage( const QDomElement e )
{
Tcursor.setPosition(doc_cur);
bool maketag = FoDrawImage(e,Tcursor);
doc_cur = Tcursor.position();
return maketag;
}
bool Fo_Reader::FoDrawImage( const QDomElement e , QTextCursor Cursor )
{
ImageCount++;
const QString LastPathToRestore = QDir::currentPath(); /* reset current dir to last */
bool RunningFromFile = read_dir.exists();
QDateTime timer1( QDateTime::currentDateTime() );
const QString TimestampsMs = QString("%1-%2-file").arg(timer1.toTime_t()).arg(timer1.toString("zzz"));
qreal wi = qMax ( Unit( e.attribute( "width" , "0" ),IMAGE) , Unit( e.attribute( "content-width" , "0" ),IMAGE));
qreal hi = qMax ( Unit( e.attribute( "height" , "0"),IMAGE) , Unit( e.attribute( "content-height" , "0" ),IMAGE));
qreal havingnummer = qMax(wi,hi);
QSize imageSize;
imageSize = QSize(wi,hi);
if (!wi > 0 && !hi > 0)
{
imageSize = QSize(havingnummer,havingnummer);
}
if (havingnummer < 1)
{
imageSize = QSize(20,20);
}
QString scaling = e.attribute("scaling","0");
/* dont scale if not having set nothing width / height */
if (havingnummer < 1)
{
scaling = "0";
}
QString FileAbsolute = 0;
QString FileSuffix = "PNG";
QString FileBaseName = "NotFound";
ApiSession *session = ApiSession::instance();
QDir::setCurrent(read_dir.absolutePath());
QByteArray derangedata;
QPixmap resultimage;
QPixmap scaledsimage;
QString resourceName;
SPics ximg;
const QString hrefimageplace = ImagesrcUrl(e);
QUrl imageurl(hrefimageplace );
qDebug() << "## dir readdddddddddddddddddddddddddddddddddd " << read_dir.absolutePath();
qDebug() << "## image url " << imageurl;
if (hrefimageplace.startsWith("http://", Qt::CaseInsensitive) ||
hrefimageplace.startsWith("https://", Qt::CaseInsensitive) ||
hrefimageplace.startsWith("ftp://", Qt::CaseInsensitive))
{
resourceName = QString("/none/%1/%2/url/%3").arg(TimestampsMs).arg(ImageCount).arg(hrefimageplace);
/* grab */
resultimage = ximg.erno_pix();
ximg.set_pics( resultimage );
derangedata = ximg.streams();
RunningFromFile = false;
}
if (RunningFromFile)
{
QFileInfo imageFix(hrefimageplace);
if (imageFix.exists())
{
FileAbsolute = imageFix.absoluteFilePath();
qDebug() << "## open file " << FileAbsolute;
FileSuffix = imageFix.completeSuffix().toLower();
qDebug() << "## FileSuffix " << FileSuffix;
FileBaseName = imageFix.baseName();
if (FileSuffix.endsWith(".gz"))
{
derangedata = OpenGzipOneFileByte( imageFix.absoluteFilePath() );
}
else
{
/* normal image file */
QFile f(imageFix.absoluteFilePath());
if (f.open(QIODevice::ReadOnly))
{
derangedata = f.readAll();
f.close();
}
}
qDebug() << "## derangedata " << derangedata.size();
if (FileSuffix.contains("sv"))
{
resourceName = QString("/svg/%1/%2/file/%3").arg(TimestampsMs).arg(ImageCount).arg(imageFix.absoluteFilePath());
resultimage = RenderPixmapFromSvgByte( derangedata );
session->SvgList.insert(resourceName,derangedata);
}
else
{
resourceName = QString("/png/%1/%2/file/%3").arg(TimestampsMs).arg(ImageCount).arg(imageFix.absoluteFilePath());
resultimage.loadFromData( derangedata );
}
}
QDir::setCurrent(LastPathToRestore);
}
/* image is here or null */
if (resultimage.isNull())
{
///////imageSize
QPixmap notfound(":/img/image-file-48x48.png");
resultimage = notfound.scaled(imageSize,Qt::IgnoreAspectRatio);
wi = resultimage.width();
hi = resultimage.height();
scaling = "0";
}
if (wi !=0 && wi !=resultimage.width() && scaling=="0")
{
scaling = "uniform";
}
if (hi !=0 && hi !=resultimage.height() && scaling=="0")
{
scaling = "uniform";
}
/* scaling image size ?? */
if (scaling == "uniform")
{
if (wi !=0)
{
scaledsimage = resultimage.scaledToWidth(wi);
}
else if (hi !=0)
{
scaledsimage = resultimage.scaledToHeight(hi);
}
}
else if (scaling == "non-uniform" && wi!=0 && hi!=0)
{
scaledsimage = resultimage.scaled(wi,hi,Qt::IgnoreAspectRatio);
}
else
{
scaledsimage = resultimage;
}
QByteArray extensionCurrent;
extensionCurrent.append(FileSuffix.toUpper());
ximg.set_pics(scaledsimage);
ximg.name = FileBaseName;
ximg.extension = extensionCurrent;
QUrl recresourcein(resourceName);
Qdoc->addResource( QTextDocument::ImageResource,recresourcein,scaledsimage);
session->ImagePageList.insert(resourceName,ximg);
QTextImageFormat format;
format.setName( resourceName );
format.setHeight ( scaledsimage.height() );
format.setWidth ( scaledsimage.width() );
format.setToolTip(ximg.info);
format.setProperty(_IMAGE_PICS_ITEM_,ximg);
Cursor.insertImage( format );
QTextBlock bf = Cursor.block();
QTextBlockFormat bbff = bf.blockFormat();
if ( TagAlignElement(e) != Qt::AlignLeft )
{
bbff.setAlignment( TagAlignElement(e) );
Cursor.setBlockFormat(bbff);
}
QDir::setCurrent(LastPathToRestore);
qDebug() << "## dir restore dirrrrrrrrrrrrrrrrrrrr " << LastPathToRestore;
return true;
}
bool Fo_Reader::FoDrawSvgInline( const QDomElement e )
{
Tcursor.setPosition(doc_cur);
bool maketag = FoDrawSvgInline(e,Tcursor);
doc_cur = Tcursor.position();
return maketag;
}
bool Fo_Reader::FoDrawSvgInline( const QDomElement e , QTextCursor Cursor )
{
if (FoTag(e) !=IMAGE_INLINE)
{
return false;
}
ImageCount++;
ImageCount++;
ImageCount++;
QDateTime timer1( QDateTime::currentDateTime() );
const QString TimestampsMs = QString("%1-%2-stream").arg(timer1.toTime_t()).arg(timer1.toString("zzz"));
QString j_op( QString::number( qrand() % 1000 ) );
const QString resourceName = QString("/svg/%1/%2/%3").arg(TimestampsMs).arg(ImageCount).arg(j_op);
SPics ximg;
qreal wi = qMax ( Unit( e.attribute( "width" , "0" ),IMAGE) , Unit( e.attribute( "content-width" , "0" ),IMAGE));
qreal hi = qMax ( Unit( e.attribute( "height" , "0"),IMAGE) , Unit( e.attribute( "content-height" , "0" ),IMAGE));
QDomElement domObject = e.firstChildElement();
if ( domObject.tagName().toLower() == "svg:svg" || domObject.tagName().toLower() == "svg" )
{
QPixmap paintsvg = RenderSvg(e,resourceName); /* go in session image resource here on svg format */
QPixmap scaler;
if (wi > 0)
{
scaler = paintsvg.scaledToWidth(wi);
}
else if (hi > 0)
{
scaler = paintsvg.scaledToHeight(hi);
}
else
{
scaler = paintsvg;
}
ApiSession *session = ApiSession::instance(); /* back up image resource as normal not svg to write on save ... */
ximg.set_pics(scaler);
ximg.name = Imagename( resourceName );
ximg.info = "Inline svg image";
session->ImagePageList.insert(resourceName,ximg); /* need only if inline original svg stream can not repopulate on save */
Qdoc->addResource( QTextDocument::ImageResource,QUrl(resourceName),scaler);
QTextImageFormat format;
format.setName( resourceName );
format.setWidth ( scaler.width() );
format.setHeight ( scaler.height() );
format.setToolTip(ximg.info);
format.setProperty(_IMAGE_PICS_ITEM_,ximg);
Cursor.insertImage( format ); /* cursor insert image QPixmap */
QTextBlock bf = Tcursor.block();
QTextBlockFormat bbff = bf.blockFormat();
if ( TagAlignElement(e) != Qt::AlignLeft )
{
bbff.setAlignment( TagAlignElement(e) );
Cursor.setBlockFormat(bbff);
}
return true;
}
else
{
return false;
}
}
void Fo_Reader::MoveEndDocNow()
{
Tcursor.movePosition(QTextCursor::End);
doc_cur = Tcursor.position();
////qDebug() << "### MoveEndDocNow " << doc_cur;
}
void Fo_Reader::DocRootFrameDefault()
{
QTextFrame *Tframe = Qdoc->rootFrame();
QTextFrameFormat Ftf = Tframe->frameFormat();
Ftf.setLeftMargin(0);
Ftf.setBottomMargin(0);
Ftf.setTopMargin(0);
Ftf.setRightMargin(0);
Ftf.setPadding ( 0);
Tframe->setFrameFormat(Ftf);
}
bool Fo_Reader::FoChildBlockPaint( const QDomElement e , bool recursive )
{
if (FoTag(e) !=BLOCK_TAG) /* block in block make frame */
{
return false;
}
QDomElement page = e.firstChildElement("fo:block");
if (page.isNull())
{
return false;
}
if (FoTag(page) == INLINE_BR)
{
return false;
}
Tcursor.setPosition(doc_cur);
QDomNode child = e.firstChild();
if (child.isText() )
{
Tcursor.insertBlock();
bool firstBl = InlineBlockLoop(e,Tcursor,true);
qDebug() << "### first parent before frame block block " << firstBl;
}
doc_cur = Tcursor.position();
return FoFloatingContainerPaint(page,e); /* go page while down format from parent up e */
}
bool Fo_Reader::FoFloatingContainerPaint( const QDomElement e , const QDomElement parentup )
{
qDebug() << "###floatfloatfloat..a." << e.tagName().toLower();
qDebug() << "###floatfloatfloat..b." << parentup.tagName().toLower();
bool take = false;
bool isBlockBlock = (FoTag(e) == BLOCK_TAG && FoTag(parentup) == BLOCK_TAG) == true ? true : false;
if (FoTag(e) == FLOATBLOCK) /* floating block parentup must fo:block-container or fo:block !fo:float */
{
take = true;
}
if (FoTag(e) == BLOCK_TAG)
{
take = true;
}
if (!take)
{
return false;
}
QDomElement FirstPara;
QTextLength mesure = BlockMesure(e);
if (isBlockBlock)
{
mesure = BlockMesure(parentup);
}
qDebug() << "############ Draw_Width " << QVariant(mesure).toInt();
////////////////qDebug() << "############ isBlockBlock " << isBlockBlock;
/* new container */
QTextFrameFormat FrameFormat;
FrameFormat.setWidth(mesure);
QTextCharFormat Charformat;
QTextBlockFormat Paraformat = TextBlockFormFromDom(e,DefaultMargin());
if (!isBlockBlock)
{
FrameFormat = PaintFrameFormat(e,FrameFormat); /* float */
FirstPara = e.firstChildElement();
if (FirstPara.isNull())
{
return false;
}
Charformat = GlobalCharFormat(parentup,DefaultCharFormats());
Charformat = GlobalCharFormat(FirstPara,Charformat);
}
else
{
FirstPara = e;
FrameFormat = PaintFrameFormat(parentup,FrameFormat); /* block blcok */
Charformat = GlobalCharFormat(e,DefaultCharFormats());
Charformat = GlobalCharFormat(parentup,Charformat);
Paraformat = TextBlockFormFromDom(e,Paraformat);
FrameFormat = PaintFrameFormat(e,FrameFormat);
}
FrameFormat.setWidth(mesure); /* if is loast ! */
QColor bgcolor = QColor(Qt::transparent);
if (!parentup.attribute("background-color").isEmpty())
{
bgcolor = ColorFromFoString( parentup.attribute("background-color") );
}
if (!e.attribute("background-color").isEmpty())
{
bgcolor = ColorFromFoString( e.attribute("background-color") );
}
qreal borderrforce = isBorder(e);
if (borderrforce < 0.1)
{
/* editinting border leave by print */
FrameFormat.setBorderBrush ( bgcolor );
FrameFormat.setBorder ( 0.4 );
FrameFormat.setBorderStyle(QTextFrameFormat::BorderStyle_DotDotDash);
}
///////FrameFormat.setBorderStyle(QTextFrameFormat::BorderStyle_Dotted); /* debug */
QTextFrame *Divframe = Tcursor.insertFrame(FrameFormat);
doc_cur = Divframe->firstPosition();
Tcursor.setPosition(doc_cur);
Paraformat = TextBlockFormFromDom(parentup,DefaultMargin());
Tcursor.setCharFormat(Charformat);
QDomElement blocks;
doc_cur = Tcursor.position();
int helpline = -1;
if (isBlockBlock)
{
if (InlineBlockLoop(e,Tcursor,true))
{
doc_cur = Tcursor.position();
qDebug() << "### radice ";
helpline = 1;
}
blocks = e.firstChildElement("fo:block");
if (blocks.isNull())
{
qDebug() << "### secondo false ";
doc_cur = Tcursor.position();
return true;
}
else
{
qDebug() << "### secondo vero ";
}
}
else
{
blocks = e.firstChildElement("fo:block");
}
while (!blocks.isNull())
{
helpline++;
////////////qDebug() << "### loop float block block " << helpline << "|" << blocks.text();
if (helpline > 0)
{
Tcursor.insertBlock();
}
bool firstBl = InlineBlockLoop(blocks,Tcursor,true);
doc_cur = Tcursor.position();
qDebug() << "### block block float loop " << firstBl;
blocks = blocks.nextSiblingElement("fo:block");
}
doc_cur = Tcursor.position();
return true;
}
bool Fo_Reader::FoTableTagPaint( const QDomElement e )
{
if (FoTag(e) != TABLE_TAG)
{
return false;
}
QTextTableCell cell;
int RowLineNummer = -1; /* cell and row count from 0 */
int MultipleBodyTableRowLine = -1; /* cell and row count from 0 */
qreal MaxHeightCellContenent = 0;
/* check for multiple body */
QDomNode bchild = e.firstChild();
while ( !bchild.isNull() )
{
if ( bchild.isElement() )
{
const QDomElement tde = bchild.toElement();
if (FoTag(tde) == TABLE_BODY || FoTag(tde) == TABLE_FOOTER || FoTag(tde) == TABLE_HEADER )
{
QDomElement multirows = tde.firstChildElement("fo:table-row");
while (!multirows.isNull())
{
MultipleBodyTableRowLine++;
multirows = multirows.nextSiblingElement("fo:table-row");
}
}
}
bchild = bchild.nextSibling();
}
/* check for multiple body */
QTextLength table_wi = BlockMesure(e);
qreal width_double = table_wi.rawValue();
const int ORIGINALCURSOR_POSITION = doc_cur;
int LastCellCurorrisPos = -1;
qDebug() << "### TTTTTTTTTTTTTTable..................init" << width_double << " type->" << table_wi.type();
Tcursor.setPosition(doc_cur);
doc_cur = Tcursor.position();
QDomElement bodytable = e.firstChildElement("fo:table-body");
int rowCounter = 0;
int columnCounter = 0;
QVector<QTextLength> constraints;
LastTableCON.clear();
bool colum_WI_command = false;
QDomElement column = e.firstChildElement("fo:table-column");
/* column count and sett wi distance */
if (!column.isNull())
{
while (!column.isNull())
{
QTextLength cool_wi = BlockMesure(column);
const int MiTx = cool_wi.type();
if (cool_wi.rawValue() !=100 && MiTx != 2 )
{
colum_WI_command = true; /* width from table-column not table */
constraints.insert(columnCounter,cool_wi);
}
columnCounter++;
column = column.nextSiblingElement("fo:table-column");
}
}
LastTableCON = constraints;
QDomElement rows = bodytable.firstChildElement("fo:table-row");
if (rows.isNull())
{
return false;
}
if (columnCounter == 0) /* unable to count fo:table-column */
{
QDomElement CCceller = rows.firstChildElement("fo:table-cell");
while (!CCceller.isNull())
{
columnCounter++;
CCceller = CCceller.nextSiblingElement("fo:table-cell");
}
}
while (!rows.isNull())
{
rowCounter++;
rows = rows.nextSiblingElement("fo:table-row");
}
if (rowCounter !=0 && columnCounter!=0)
{
/* ok table having ...*/
}
else
{
return false;
}
QDomElement headetable = e.firstChildElement("fo:table-header");
if (!headetable.isNull())
{
/* hey found header row cool !!!!!!!!!!!!!!*/
rowCounter++; /* more one line */
}
QDomElement footertable = e.firstChildElement("fo:table-footer");
if (!footertable.isNull())
{
/* hey found header row cool !!!!!!!!!!!!!!*/
rowCounter++; /* more one line */
}
if (MultipleBodyTableRowLine == 0)
{
return false;
}
if (MultipleBodyTableRowLine != rowCounter)
{
/* bastard table insert multiple body !!!! */
rowCounter = MultipleBodyTableRowLine;
}
qDebug() << "### Row........." << rowCounter << MultipleBodyTableRowLine;
QTextTable *qtable = Tcursor.insertTable( rowCounter, columnCounter );
if (!headetable.isNull())
{
QDomElement setrowsHH = headetable.firstChildElement("fo:table-row");
if (setrowsHH.isNull())
{
return false;
}
RowLineNummer++;
int cool = -1;
QDomElement columnElement = setrowsHH.firstChildElement(); /* sub element from row */
while ( !columnElement.isNull() )
{
if ( columnElement.tagName().toLower() == "fo:table-cell" )
{
cool++;
const int is_spancol = columnElement.attribute( "number-columns-spanned","0").simplified().toInt();
if (is_spancol > 1)
{
for (int i = 0; i < is_spancol; ++i)
{
//////QTextTableCell cellstart = qtable->cellAt(RowLineNummer,columnCounter + i);
/* format cell */
}
qtable->mergeCells ( RowLineNummer ,cool,1,is_spancol); /* last zero no merge */
cell = qtable->cellAt( RowLineNummer , cool );
}
else
{
cell = qtable->cellAt( RowLineNummer , cool );
}
bool success = FoTableCellLoop(columnElement,cell);
////////////////qDebug() << "### RowLineNummer " << RowLineNummer << " cool |" << cool << " cursor " << success;
}
columnElement = columnElement.nextSiblingElement();
}
}
QDomElement setrows = bodytable.firstChildElement("fo:table-row");
if (setrows.isNull())
{
return false;
}
while (!setrows.isNull())
{
RowLineNummer++;
int cool = -1;
MaxHeightCellContenent = 0; /* restore reset by line height */
MaxHeightCellContenent = TrLineMaxHight(setrows,constraints);
QDomElement columnElement = setrows.firstChildElement(); /* sub element from row */
while ( !columnElement.isNull() )
{
if ( columnElement.tagName().toLower() == "fo:table-cell" )
{
cool++;
const int is_spancol = columnElement.attribute( "number-columns-spanned","0").simplified().toInt();
/* number-columns-spanned td */
if (is_spancol > 1)
{
for (int i = 0; i < is_spancol; ++i)
{
//////QTextTableCell cellstart = qtable->cellAt(RowLineNummer,columnCounter + i);
/* format cell */
}
qtable->mergeCells ( RowLineNummer ,cool,1,is_spancol); /* last zero no merge */
cell = qtable->cellAt( RowLineNummer , cool );
}
else
{
cell = qtable->cellAt( RowLineNummer , cool );
}
bool success = FoTableCellLoop(columnElement,cell,MaxHeightCellContenent);
///////////qDebug() << "### RowLineNummer " << RowLineNummer << " cool |" << cool << " cursor " << success;
}
columnElement = columnElement.nextSiblingElement();
}
setrows = setrows.nextSiblingElement("fo:table-row");
}
if (!footertable.isNull())
{
QDomElement setrowsFF = footertable.firstChildElement("fo:table-row");
if (setrowsFF.isNull())
{
return false;
}
RowLineNummer++;
int cool = -1;
QDomElement columnElement = setrowsFF.firstChildElement(); /* sub element from row */
//////////QRect Fo_Format::Fo_Format::BlockRect( const QDomElement e , qreal largespace )
while ( !columnElement.isNull() )
{
if ( columnElement.tagName().toLower() == "fo:table-cell" )
{
cool++;
const int is_spancol = columnElement.attribute( "number-columns-spanned","0").simplified().toInt();
if (is_spancol > 1)
{
for (int i = 0; i < is_spancol; ++i)
{
//////QTextTableCell cellstart = qtable->cellAt(RowLineNummer,columnCounter + i);
/* format cell */
}
qtable->mergeCells ( RowLineNummer ,cool,1,is_spancol); /* last zero no merge */
cell = qtable->cellAt( RowLineNummer , cool );
}
else
{
cell = qtable->cellAt( RowLineNummer , cool );
}
bool success = FoTableCellLoop(columnElement,cell);
//////////////qDebug() << "### RowLineNummer " << RowLineNummer << " cool |" << cool << " cursor " << success;
}
columnElement = columnElement.nextSiblingElement();
}
}
QTextTableFormat tableFormat = qtable->format();
tableFormat.setBorder(PaintFrameFormat(e,QTextFrameFormat()).border() > 0 ? 0.4 : 0);
tableFormat.setCellSpacing(0);
tableFormat.setCellPadding(0);
if (colum_WI_command)
{
tableFormat.setColumnWidthConstraints(constraints);
}
if (!e.attribute("background-color").isEmpty())
{
tableFormat.setBackground(ColorFromFoString(e.attribute("background-color")));
}
QTextLength table_large = BlockMesure(e);
tableFormat.setWidth ( table_large );
/* last */
qtable->setFormat( tableFormat );
MoveEndDocNow();
doc_cur = Tcursor.position();
return true;
}
bool Fo_Reader::FoTableCellLoop( const QDomElement e , QTextTableCell cell , qreal maxhight )
{
const QString fotag = e.tagName().toLower();
if ( fotag != "fo:table-cell")
{
return false;
}
if ( !cell.isValid() )
{
return false;
}
QTextLength mesure; /* need to frame if border */
bool makeframe = false;
qreal FutureFrametopPadding = 0;
QDomElement firstPara = e.firstChildElement("fo:block");
int is_spancol = e.attribute( "number-columns-spanned" ).trimmed().toInt();
QColor bgcolor( Qt::white ); /* to init if table having color ! */
QTextTableCellFormat td_format = cell.format().toTableCellFormat();
if (!e.attribute("background-color").isEmpty())
{
bgcolor = ColorFromFoString( e.attribute("background-color") );
}
QTextFrameFormat CellfindBorder = PaintFrameFormat(e,QTextFrameFormat());
QTextFrameFormat BlockfindBorder = CellfindBorder;
if (!firstPara.isNull())
{
BlockfindBorder = PaintFrameFormat(firstPara,CellfindBorder);
if (!firstPara.attribute("background-color").isEmpty())
{
bgcolor = ColorFromFoString( firstPara.attribute("background-color") );
}
}
ApiSession *session = ApiSession::instance();
if (!session->Lastsignature())
{
if (BlockfindBorder.border() > 0)
{
makeframe = true;
//////qDebug() << "### cell border " << CellfindBorder.border();
}
else if (CellfindBorder.border() > 0 && !firstPara.isNull())
{
makeframe = true;
/////qDebug() << "### block border " << BlockfindBorder.border();
}
else
{
//////qDebug() << "### border none ......... ";
}
}
qreal actualWiiii = ColumnLarge(LastTableCON,cell.column());
if (actualWiiii > 0)
{
mesure = QTextLength(QTextLength::QTextLength::FixedLength,actualWiiii);
}
else
{
mesure = QTextLength(QTextLength::PercentageLength,100);
}
BlockfindBorder.setWidth(mesure);
if (bgcolor.isValid () )
{
BlockfindBorder.setBackground(bgcolor);
}
Qt::Alignment cellalign = TagAlignElement(e); /* fake */
if ( cellalign == Qt::AlignVCenter && maxhight > 0.5 && !firstPara.isNull())
{
QRect fiBBrect = BlockRect(firstPara,actualWiiii);
qreal ccenter = maxhight / 2;
qreal fromtopPadding = ccenter - (fiBBrect.height() / 2);
BlockfindBorder.setHeight(QTextLength(QTextLength::QTextLength::FixedLength,fiBBrect.height() + BlockfindBorder.border()));
if (fromtopPadding > 0)
{
if (makeframe)
{
FutureFrametopPadding = fromtopPadding;
td_format.setPadding(0);
}
else
{
td_format.setTopPadding(fromtopPadding);
}
}
}
else
{
td_format.setPadding(0);
}
BlockfindBorder.setTopMargin ( FutureFrametopPadding );
QTextCursor Cellcursor = cell.firstCursorPosition();
int LastCellCurorrisPos = Cellcursor.position();
/* reset only if not miniscribus signature */
if (makeframe)
{
QTextFrame *Divframe = Cellcursor.insertFrame(BlockfindBorder);
int poscuuuri = Divframe->firstPosition();
Cellcursor.setPosition(poscuuuri);
td_format.setVerticalAlignment ( QTextCharFormat::AlignTop );
}
FrameDomIterator(e.firstChild(),Cellcursor);
td_format.setBackground(bgcolor);
cell.setFormat(td_format);
LastCellCurorrisPos = Cellcursor.position();
return true;
}
void Fo_Reader::FrameDomIterator( QDomNode node , QTextCursor Cinline )
{
int LastCellCurorrisPos = Cinline.position();
QDomElement LastElementParent;
int loop = -1;
while ( !node.isNull() )
{
loop++;
if ( node.isElement() )
{
const QDomElement el = node.toElement();
qDebug() << "### FrameDomIterator " << el.tagName() << " cursor->" << LastCellCurorrisPos << "-" << loop;
if ( FoTag(el) == INLINE_BR )
{
Cinline.insertText(QString(QChar::LineSeparator));
}
else if (FoTag(el) == FOLEADER)
{
FoLeaderPaint(el,Cinline);
}
else if (FoTag(el) == BLOCK_TAG)
{
if (loop !=0) {
Cinline.insertBlock();
Cinline.setBlockFormat(DefaultMargin());
}
InlineBlockLoop(el,Cinline,true);
}
else if ( FoTag(el) == BLOCK_CONTAINER)
{
/* inline frame elements */
FoBlockContainerPaint(el,Cinline);
}
else if ( FoTag(el) == IMAGE_INLINE )
{
FoDrawSvgInline(el,Cinline);
}
else if ( FoTag(el) == FOOTNOTEBOTTOM )
{
////////FootNoteSave(el,Cinline);
}
else if ( FoTag(el) == IMAGE_SRC )
{
FoDrawImage(el,Cinline);
}
else
{
if (FoTag(el) == TAG_NOT_KNOW )
{
DidplayUnknowTag(el,Cinline);
}
}
//////// FOOTNOTEBOTTOM
LastElementParent = el;
LastCellCurorrisPos = Cinline.position();
}
node = node.nextSibling();
}
LastCellCurorrisPos = Cinline.position();
}
| [
"ppkciz@9af58faf-7e3e-0410-b956-55d145112073"
]
| [
[
[
1,
1764
]
]
]
|
018af9a8c107b2d545acaf23e1d976ba5c7def57 | fb959e36e35df7e74757e04c699796a77c49f605 | /Source/VirtualMachine.cpp | 5dbddd2facb1703ab90d6ede37a08052abea7dfa | []
| no_license | olegp/tyro | 265e63e4922bbdab0f88189c71c72d40ceb4cc4f | b63f8eacf20462bfa36bb574109e8fa4ecd847c5 | refs/heads/master | 2016-09-05T20:49:52.838981 | 2010-07-14T12:08:34 | 2010-07-14T12:08:34 | 774,398 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,012 | cpp | #include "Assembly.h"
#include <windows.h>
#include <stdio.h>
#include "TyroDebug.h"
#define tofloat(x) (*((float *)x))
#define todword(x) (*((dword *)x))
#define tosigned(x) (*((long *)x)) // signed int
VirtualMachine::VirtualMachine() : stackpos(stack)
{
memset(stack, 0, sizeof(stack));
}
VirtualMachine::~VirtualMachine()
{
}
bool VirtualMachine::Execute(Assembly& assembly)
{
// check if there's a "SYS SC_EXIT" op at the end of the bytecode stream
dword *lastop = assembly.GetByteCode() + assembly.GetSize() - 2;
if(!(lastop[0] == SYS && lastop[1] == SC_EXIT))
assembly.WriteOp(SYS, SC_EXIT); // if not, add it
dword *localvars = null;
dword *bytecode = assembly.GetByteCode();
dword *cur = bytecode;
stackpos = stack;
dword a, b;
// the only way we exit this loop is when we encounter "SYS SC_EXIT"
for(;;) {
dword opcode = *(cur ++);
dword operand = *(cur ++);
switch(opcode) {
case NOOP:
break;
case LOCAL:
#ifdef _DEBUG
memset(stackpos, 0xcafebabe, sizeof(dword) * operand);
#endif
localvars = stackpos;
stackpos += operand;
break;
case CALL:
Call((Function *)assembly.GetFunctions()[operand]);
break;
case SYS:
if(operand == SC_EXIT) return true;
System((SYSCODE)operand);
break;
case PUSH:
*(++ stackpos) = operand;
break;
case POP:
stackpos --;
break;
case LOAD:
*(++ stackpos) = localvars[operand];
break;
case STORE:
localvars[operand] = *stackpos;
break;
case GOTO:
cur = bytecode + operand;
break;
case IFT:
if(*(stackpos --) == 1) cur = bytecode + operand;
break;
case IFF:
if(*(stackpos --) == 0) cur = bytecode + operand;
break;
case IAND:
b = *(stackpos --);
a = *stackpos;
*stackpos = (a && b) ? 1 : 0;
break;
case IOR:
b = *(stackpos --);
a = *stackpos;
*stackpos = (a || b) ? 1 : 0;
break;
case IEQ:
*stackpos = (*stackpos == 0) ? 1 : 0;
break;
case INE:
*stackpos = (*stackpos != 0) ? 1 : 0;
break;
case ILT:
*stackpos = (tosigned(stackpos) < 0) ? 1 : 0;
break;
case ILE:
*stackpos = (tosigned(stackpos) <= 0) ? 1 : 0;
break;
case IGT:
*stackpos = (tosigned(stackpos) > 0) ? 1 : 0;
break;
case IGE:
*stackpos = (tosigned(stackpos) >= 0) ? 1 : 0;
break;
case I2F:
*((float *)stackpos) = (float)*((long *)stackpos);
break;
case F2I:
*((long *)stackpos) = (long)*((float *)stackpos);
break;
case IADD:
b = *(stackpos --);
a = *stackpos;
*stackpos = a + b;
break;
case ISUB:
b = *(stackpos --);
a = *stackpos;
*stackpos = a - b;
break;
case IMUL:
b = *(stackpos --);
a = *stackpos;
*stackpos = a * b;
break;
case IDIV:
b = *(stackpos --);
a = *stackpos;
*stackpos = a / b;
break;
case IMOD:
b = *(stackpos --);
a = *stackpos;
*stackpos = tosigned(&a) % tosigned(&b);
break;
case FADD:
b = *(stackpos --);
a = *stackpos;
*((float *)stackpos) = tofloat(&a) + tofloat(&b);
break;
case FSUB:
b = *(stackpos --);
a = *stackpos;
*((float *)stackpos) = tofloat(&a) - tofloat(&b);
break;
case FMUL:
b = *(stackpos --);
a = *stackpos;
*((float *)stackpos) = tofloat(&a) * tofloat(&b);
break;
case FDIV:
b = *(stackpos --);
a = *stackpos;
*((float *)stackpos) = tofloat(&a) / tofloat(&b);
break;
case FCMP:
b = *(stackpos --);
a = *stackpos;
if(tofloat(&a) < tofloat(&b)) *stackpos = -1;
else if(tofloat(&a) > tofloat(&b)) *stackpos = 1;
else *stackpos = 0;
break;
default:
return false;
}
}
return true;
}
bool VirtualMachine::System(SYSCODE operand)
{
// all sys ops pop the values they use from the stack
switch(operand) {
case SC_PRINTC:
putchar((char)*(stackpos --));
return true;
case SC_PRINTI:
printf("%d\n", (int)*(stackpos --));
return true;
case SC_PRINTF:
printf("%f", *((float *)&*(stackpos --)));
return true;
case SC_SLEEP:
// note: platform dependant
Sleep(*(stackpos --));
return true;
}
return false;
}
bool VirtualMachine::Call(Function *function)
{
dword pc = function->paramcount;
dword r;
void* pointer = function->pointer;
// push the parameters on to the stack
for(dword i = 0; i < pc; i ++) {
dword a = *(stackpos --);
__asm { push a }
}
// call the function
// store the return value
__asm {
call pointer
mov r, eax
}
// do we need to pop the parameters passed (or have they been popped already)
if(function->popparams) {
// balance the stack frame
for(dword i = 0; i < pc; i ++) {
__asm { pop ebx }
}
}
if(function->returncount == 0)
r = 0; // don't push garbage on our stack, push a 0 instead
// save the return value
// note: all the functions return a value (void -> 0)
*(++ stackpos) = r;
return true;
}
void VirtualMachine::DumpStack()
{
printf("\n");
for(dword *j = stack, i = 0; j < stackpos; j ++, i ++) {
printf("%08x ", *j);
if((i + 1) % 8 == 0) printf("\n");
}
printf("\n");
}
| [
"[email protected]"
]
| [
[
[
1,
278
]
]
]
|
dda914676f4c4ac8da1f9f29a9bbc851375ddc94 | 1eb0e6d7119d33fa76bdad32363483d0c9ace9b2 | /PointCloud/trunk/PointCloud/Simply/SimplyPlugin.h | 7c5b328bbf59950161eb01e58e05876ae4716800 | []
| no_license | kbdacaa/point-clouds-mesh | 90f174a534eddb373a1ac6f5481ee7a80b05f806 | 73b6bc17aa5c597192ace1a3356bff4880ca062f | refs/heads/master | 2016-09-08T00:22:30.593144 | 2011-06-04T01:54:24 | 2011-06-04T01:54:24 | 41,203,780 | 0 | 2 | null | null | null | null | GB18030 | C++ | false | false | 5,020 | h | #ifndef SIMPLYPLUGIN
#define SIMPLYPLUGIN
#include "pointset.h"
#include "Common/Otree.h"
// 计算两个顶点之间距离的平方
inline double distance(float* pta, float*ptb){
return (pta[0]-ptb[0])*(pta[0]-ptb[0]) +
(pta[1]-ptb[1])*(pta[1]-ptb[1]) +
(pta[2]-ptb[2])*(pta[2]-ptb[2]);
}
class CSimplyPlugin{
public:
CPointSet* m_ps;
int m_M; // 八叉树单元中叶子节点的最大点容量
int m_K; // 邻域搜索时的K
private:
float* m_ratio;
float m_rateAve;
bool* m_bDelete;
public:
CSimplyPlugin(CPointSet* ps, int Me=15, int Ke=15);
public:
void doSimply();
void simplyOctreeCell(vector<int>& ptsVector);
void removePts();
};
CSimplyPlugin::CSimplyPlugin(CPointSet* ps, int Me, int Ke){
m_ps = ps;
m_M = Me;
m_K = Ke;
m_ratio = NULL;
m_bDelete = NULL;
}
inline void CSimplyPlugin::doSimply(){
size_t psSize = m_ps->getPointSize();
if (m_ratio == NULL)
m_ratio = new float[psSize];
ANNidxArray nnidx = new ANNidx[m_K+1];
ANNdistArray nndist = new ANNdist[m_K+1];
ANNkd_tree* kdTree = new ANNkd_tree(m_ps->m_point, m_ps->m_pointN, 3);
m_rateAve = 0.0f;
for (size_t i = 0; i < psSize; i++) {
ANNpoint qPt = m_ps->getPoint(i);
kdTree->annkSearch(qPt, m_K+1, nnidx, nndist);
// 计算顶点曲率
float ratio[3], c1,rate, nor[3];
computeParamRatio(ratio, m_ps->m_point, nnidx, m_K+1);
computePtNormAndRate(nor, c1, rate, ratio, qPt);
rate = abs(rate);
m_ratio[i] = rate;
m_rateAve += rate;
}
m_rateAve /= psSize;
delete kdTree;
delete[] nnidx;
delete[] nndist;
SplitNode* octreeRoot = createOctTree<int>(m_ps, m_M);
delete octreeRoot;
m_bDelete = new bool[psSize];
for (size_t t = 0; t < psSize; t++)
m_bDelete[t] = true;
// 对每一个八叉树叶子节点进行精简
//cout<<"八叉树叶子个数:"<<gLeafNodeVector.size()<<endl;
vector<LeafNode<int>*>::iterator it = gLeafNodeVector.begin();
for (; it != gLeafNodeVector.end(); it++)
if ((*it)->level > 5)
simplyOctreeCell((*it)->ptIndex);
delete[] m_ratio;
m_ratio = NULL;
removePts();
delete[] m_bDelete;
m_bDelete = NULL;
}
void CSimplyPlugin::simplyOctreeCell(vector<int>& ptsVector){
int pts = ptsVector.size();
if (pts == 1) {
int ptIdx = ptsVector[0];
m_bDelete[ptIdx] = false;
return;
}
float rateAve = 0.0f; // 网格中点的曲率平均值Et
float ptCenter[3] = {0.0f, 0.0f, 0.0f};
for (int i = 0; i < pts; i ++){
int ptIndex = ptsVector[i];
rateAve += m_ratio[ptIndex];
float* pt = m_ps->getPoint(ptIndex);
ptCenter[0] += pt[0];
ptCenter[1] += pt[1];
ptCenter[2] += pt[2];
}
rateAve /= pts;
ptCenter[0] /= pts;
ptCenter[1] /= pts;
ptCenter[2] /= pts;
double MinD2 = DBL_MAX;
int idxMin = -1; // 最接近重心的顶点
for (int j =0; j < pts; j++){
double d2 = distance(ptCenter, m_ps->getPoint( ptsVector[j] ));
if (MinD2 > d2){
MinD2 = d2;
idxMin = ptsVector[j];
}
}
m_bDelete[idxMin] = false;
if (rateAve > m_rateAve){
for (int t = 0; t < pts; t++) {
int ptIdx = ptsVector[t];
m_bDelete[ptIdx] = false;
}
return;
}
if (rateAve > m_rateAve*0.1) {
int idxMax = ptsVector[0], idxMax2 = idxMax;
float rateMax = m_ratio[idxMax];
int m = 0;
for (int k = 1; k < pts; k++){
int ptIdx = ptsVector[k];
if (rateMax < m_ratio[ptIdx]){
rateMax = m_ratio[ptIdx];
idxMax2 = idxMax;
idxMax = ptIdx;
m = k;
}
}
m_bDelete[idxMax] = false;
if (rateAve > m_rateAve*0.4) {
for (int n = m+1; n < pts; n++){
int ptI = ptsVector[n];
if (m_ratio[idxMax2] < m_ratio[ptI]){
idxMax2 = ptI;
}
}
m_bDelete[idxMax2] = false;
// if (rateAve > m_rateAve*0.7) {
// }
}
}
}
inline void CSimplyPlugin::removePts(){
if (m_bDelete == NULL)
return ;
size_t ptSimN = 0;
size_t ptSize = m_ps->getPointSize();
for (size_t j = 0; j < ptSize ; j++) {
if (!m_bDelete[j]) ptSimN ++;
}
if (ptSimN == ptSize) return ;
size_t sT = 0;
ANNpointArray dataPts = annAllocPts(ptSimN, 3);
float (*normal)[3] = NULL;
float *weight = NULL;
if (m_ps->m_normal != NULL)
normal = new float[ptSimN][3];
if (m_ps->m_weight != NULL)
weight = new float[ptSimN];
for (size_t i = 0; i < ptSize; i++){
if (!m_bDelete[i]){
dataPts[sT][0] = m_ps->m_point[i][0];
dataPts[sT][1] = m_ps->m_point[i][1];
dataPts[sT][2] = m_ps->m_point[i][2];
if (normal != NULL){
normal[sT][0] = m_ps->m_normal[i][0];
normal[sT][1] = m_ps->m_normal[i][1];
normal[sT][2] = m_ps->m_normal[i][2];
}
if (weight != NULL)
weight[sT] = m_ps->m_weight[i];
sT++;
}
}
annDeallocPts(m_ps->m_point);
m_ps->m_pointN = ptSimN;
m_ps->m_point = dataPts;
if (normal != NULL){
delete[] m_ps->m_normal;
m_ps->m_normal = normal;
}
if (weight != NULL){
delete[] m_ps->m_weight;
m_ps->m_weight = weight;
}
}
#endif // SIMPLYPLUGIN | [
"huangchunkuangke@e87e5053-baee-b2b1-302d-3646b6e6cf75"
]
| [
[
[
1,
207
]
]
]
|
c31ac175d3ea07940960cce216c70fd6063c46dd | b24759bb01b002d42d51c93cb8f02eb681ca1542 | /src/LibKopul/KPLC++/srcs/VariableIterator.cpp | 8cbd7601f6537c4db322f7ccd87ee53316ee9b10 | []
| no_license | LionelAuroux/kopul | 272745e6343bf8ca4db73eff76df08c2fab2600b | dc169ca347878e3d11b84371a734acf10230ff4f | refs/heads/master | 2020-12-24T15:58:07.863503 | 2011-12-28T10:37:44 | 2011-12-28T10:37:44 | 32,329,849 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,208 | cpp | /*
* File: VariableIterator.cpp
* Author: deveza
*
* Created on October 29, 2010, 12:29 AM
*/
#include <exception>
#include "VariableIterator.h"
#include "DynamicArray.h"
using namespace kpl;
VariableIterator::VariableIterator(const Variable &var, void *value) : Variable(var)
{
_type->FreeBuffer(_value);
_value = value;
}
VariableIterator::VariableIterator(const VariableIterator& orig) : Variable(orig)
{
_type->FreeBuffer(_value);
_value = orig._value;
_deepList = orig._deepList;
}
VariableIterator::~VariableIterator()
{
_value = 0;
}
VariableIterator &VariableIterator::operator = (const VariableIterator& old)
{
this->_isLastBytesRead = old._isLastBytesRead;
this->_variableName = old._variableName;
this->_value = old._value;
this->_deepList = old._deepList;
return (*this);
}
VariableIterator VariableIterator::operator [] (unsigned int i)
{
VariableIterator var(*this, this->_value);
const Type *type = this->_type;
const IComposedType *cType;
for (unsigned int j = 0; j < this->_deepList.size(); ++j)
type = &dynamic_cast<const IComposedType*>(type)->GetTypeN(this->_deepList[j]);
if (!((cType = dynamic_cast<const IComposedType*>(type)) && cType->GetNbType() > (int)i))
throw (std::exception());
this->_deepList.push_back(i);
var.SetDeepList(this->_deepList);
this->_deepList.pop_back();
return (var);
}
void* VariableIterator::operator *()
{
void *buffer = this->_value;
for (unsigned int i = 0; i < this->_deepList.size(); ++i)
buffer = ((void **)buffer)[this->_deepList[i]];
return (buffer);
}
llvm::Value *VariableIterator::GetLLVMValue(llvm::BasicBlock *) const
{
//TODO
}
const std::vector<int> VariableIterator::GetDeepList() const
{
return (this->_deepList);
}
void VariableIterator::SetDeepList(const std::vector<int>& deepList)
{
this->_deepList = deepList;
}
Value *VariableIterator::Duplicate() const
{
return (new VariableIterator(*this));
} | [
"sebastien.deveza@39133846-08c2-f29e-502e-0a4191c0ae44"
]
| [
[
[
1,
85
]
]
]
|
d3d9d27ab2e502859eb3b71ff6ea2074305f5d34 | bf72fce4046aa921bc34f5278fbbdc7b46585f03 | /Remod/Code/HUD/HUDVehicleInterface.cpp | e13636e641338ab2e75baf170057e9439f866359 | []
| no_license | wang1986one/remod | b80bea1666c098eae581f4aa724a45a0ef859090 | a368ea10f3d8b84d3af2277cd5f65f96e08deb6d | refs/heads/master | 2021-01-19T05:39:23.174602 | 2011-03-27T21:40:45 | 2011-03-27T21:40:45 | 33,872,157 | 0 | 0 | null | null | null | null | ISO-8859-3 | C++ | false | false | 33,543 | cpp | /*************************************************************************
Crytek Source File.
Copyright (C), Crytek Studios, 2001-2007.
-------------------------------------------------------------------------
$Id$
$DateTime$
Description: Vehicle HUD object (refactored from old HUD code)
-------------------------------------------------------------------------
History:
- 21:02:2007 16:00 : Created by Jan Müller
*************************************************************************/
#include "StdAfx.h"
#include "HUDVehicleInterface.h"
#include "GameFlashAnimation.h"
#include "GameFlashLogic.h"
#include "HUD.h"
#include "HUDRadar.h"
#include "Weapon.h"
#include "IWorldQuery.h"
#include "GameCVars.h"
CHUDVehicleInterface::CHUDVehicleInterface(CHUD *pHUD, CGameFlashAnimation *pAmmo) : m_pVehicle(NULL)
{
m_bParachute = false;
m_bAmmoForceNextUpdate = false;
m_eCurVehicleHUD = EHUD_NONE;
g_pHUD = pHUD;
g_pAmmo = pAmmo;
m_lastSetFriendly = m_friendlyFire = false;
m_seatId = InvalidVehicleSeatId;
m_iSecondaryAmmoCount = m_iPrimaryAmmoCount = m_iSecondaryClipSize = m_iPrimaryClipSize = 0;// m_iHeat = 0;
m_iLastReloadBarValue = -1;
m_animMainWindow.Init("Libs/UI/HUD_VehicleHUD.gfx", eFD_Center, eFAF_ManualRender|eFAF_Visible|eFAF_ThisHandler);
m_animStats.Init("Libs/UI/HUD_VehicleStats.gfx", eFD_Center, eFAF_ManualRender|eFAF_Visible);
memset(m_hasMainHUD, 0, (int)EHUD_LAST);
//fill "hasMainHUD" list
m_hasMainHUD[EHUD_TANKUS] = true;
m_hasMainHUD[EHUD_AAA] = true;
m_hasMainHUD[EHUD_HELI] = true;
m_hasMainHUD[EHUD_VTOL] = true;
m_hasMainHUD[EHUD_LTV] = false;
m_hasMainHUD[EHUD_APC] = true;
m_hasMainHUD[EHUD_APC2] = true;
m_hasMainHUD[EHUD_SMALLBOAT] = true;
m_hasMainHUD[EHUD_PATROLBOAT] = true;
m_hasMainHUD[EHUD_CIVCAR] = false;
m_hasMainHUD[EHUD_CIVBOAT] = false;
m_hasMainHUD[EHUD_TRUCK] = false;
m_hasMainHUD[EHUD_HOVER] = true;
m_hasMainHUD[EHUD_PARACHUTE ] = true;
m_hasMainHUD[EHUD_TANKA] = true;
m_hasMainHUD[EHUD_ASV] = false;
m_hudTankNames["US_tank"] = "M5A2 Atlas";
m_hudTankNames["Asian_tank"] = "NK T-108";
m_hudTankNames["Asian_aaa"] = "NK AAA";
m_hudTankNames["US_apc"] = "US APC";
}
//-----------------------------------------------------------------------------------------------------
CHUDVehicleInterface::~CHUDVehicleInterface()
{
if(m_pVehicle)
{
m_pVehicle->UnregisterVehicleEventListener(this);
m_pVehicle = NULL;
}
}
//-----------------------------------------------------------------------------------------------------
void CHUDVehicleInterface::Update(float fDeltaTime)
{
if(m_animMainWindow.GetVisible())
{
if(m_friendlyFire != m_lastSetFriendly)
{
m_animMainWindow.Invoke("setFriendly", m_friendlyFire);
m_lastSetFriendly = m_friendlyFire;
}
m_animMainWindow.GetFlashPlayer()->Advance(fDeltaTime);
m_animMainWindow.GetFlashPlayer()->Render();
}
if(m_animStats.GetVisible())
{
m_animStats.GetFlashPlayer()->Advance(fDeltaTime);
m_animStats.GetFlashPlayer()->Render();
}
g_pHUD->UpdateCrosshairVisibility();
}
//-----------------------------------------------------------------------------------------------------
bool CHUDVehicleInterface::ForceCrosshair()
{
if (m_pVehicle && m_seatId != InvalidVehicleSeatId)
{
if (IVehicleSeat* pSeat = m_pVehicle->GetSeatById(m_seatId))
{
return pSeat->IsGunner() && !m_animMainWindow.GetVisible();
}
}
return false;
}
//-----------------------------------------------------------------------------------------------------
CHUDVehicleInterface::EVehicleHud CHUDVehicleInterface::ChooseVehicleHUD(IVehicle* pVehicle)
{
if(m_bParachute)
return EHUD_PARACHUTE;
if(!pVehicle)
return EHUD_NONE;
IEntityClass *cls = pVehicle->GetEntity()->GetClass();
CHUDRadar *pRadar = g_pHUD->GetRadar();
if(!cls || !pRadar)
return EHUD_NONE;
if(cls == pRadar->m_pTankUS)
{
return EHUD_TANKUS;
}
else if(cls == pRadar->m_pTankA)
{
return EHUD_TANKA;
}
else if(cls == pRadar->m_pAAA)
{
return EHUD_AAA;
}
else if(cls == pRadar->m_pVTOL)
{
return EHUD_VTOL;
}
else if(cls == pRadar->m_pHeli)
{
return EHUD_HELI;
}
else if(cls == pRadar->m_pLTVA || cls == pRadar->m_pLTVUS)
{
return EHUD_LTV;
}
else if(cls == pRadar->m_pAPCUS)
{
return EHUD_APC;
}
else if(cls == pRadar->m_pAPCA)
{
return EHUD_APC2;
}
else if(cls == pRadar->m_pTruck)
{
return EHUD_TRUCK;
}
else if(cls == pRadar->m_pBoatCiv)
{
return EHUD_CIVBOAT;
}
else if(cls == pRadar->m_pCarCiv)
{
return EHUD_CIVCAR;
}
else if(cls == pRadar->m_pBoatUS)
{
return EHUD_SMALLBOAT;
}
else if(cls == pRadar->m_pBoatA)
{
return EHUD_PATROLBOAT;
}
else if(cls == pRadar->m_pHover)
{
return EHUD_HOVER;
}
else if(cls == pRadar->m_pUSASV)
{
return EHUD_ASV;
}
else
return EHUD_NONE;
}
//-----------------------------------------------------------------------------------------------------
void CHUDVehicleInterface::OnEnterVehicle(IActor *pActor,const char *szVehicleClassName,const char *szSeatName)
{
m_bParachute = (bool) (!strcmpi(szVehicleClassName,"Parachute"));
if(m_bParachute)
{
bool open = (bool)(!strcmpi(szSeatName,"Open"));
m_animStats.Reload();
CRY_ASSERT_MESSAGE(NULL == m_pVehicle,"Attempt to enter in parachute while already in a vehicle!");
m_animStats.Invoke("setActiveParachute", open);
m_animMainWindow.Invoke("setActiveParachute", open);
if(!open || !m_animMainWindow.GetVisible())
OnEnterVehicle(static_cast<CPlayer*> (pActor));
}
else
OnEnterVehicle(static_cast<CPlayer*> (pActor));
g_pHUD->HideInventoryOverview();
}
//-----------------------------------------------------------------------------------------------------
void CHUDVehicleInterface::OnEnterVehicle(CPlayer *pPlayer)
{
if (!pPlayer || !pPlayer->IsClient())
return;
if(m_pVehicle)
{
GameWarning("[HUD]: Attempt to enter a vehicle while already in one!");
return;
}
m_pVehicle = pPlayer->GetLinkedVehicle();
m_seatId = InvalidVehicleSeatId;
if(m_pVehicle)
{
m_pVehicle->RegisterVehicleEventListener(this, "HUDVehicleInterface");
if (IVehicleSeat *seat = m_pVehicle->GetSeatForPassenger(pPlayer->GetEntityId()))
{
m_seatId = seat->GetSeatId();
g_pHUD->UpdateCrosshairVisibility();
}
}
//reset ammos
m_bAmmoForceNextUpdate = true;
//choose vehicle hud
m_eCurVehicleHUD = ChooseVehicleHUD(m_pVehicle);
LoadVehicleHUDs();
//setup flash hud
InitVehicleHuds();
g_pHUD->UpdateCrosshairVisibility();
}
//-----------------------------------------------------------------------------------------------------
void CHUDVehicleInterface::LoadVehicleHUDs(bool forceEverything)
{
if(m_hasMainHUD[m_eCurVehicleHUD] || forceEverything)
m_animMainWindow.Reload();
m_animStats.Reload();
}
//-----------------------------------------------------------------------------------------------------
void CHUDVehicleInterface::OnExitVehicle(IActor *pActor)
{
if(m_pVehicle)
{
m_pVehicle->UnregisterVehicleEventListener(this);
m_pVehicle = NULL;
}
else
m_bParachute = false;
m_seatId = InvalidVehicleSeatId;
if(m_eCurVehicleHUD!=EHUD_NONE)
{
HideVehicleInterface();
m_eCurVehicleHUD = EHUD_NONE;
}
m_animMainWindow.SetVisible(false);
m_animStats.SetVisible(false);
m_animMainWindow.Unload();
m_animStats.Unload();
g_pHUD->UpdateCrosshairVisibility();
}
//-----------------------------------------------------------------------------------------------------
void CHUDVehicleInterface::InitVehicleHuds()
{
if(m_eCurVehicleHUD != EHUD_NONE)
{
const char *szVehicleClassName = NULL;
if(m_pVehicle)
{
szVehicleClassName = m_pVehicle->GetEntity()->GetClass()->GetName();
}
m_animMainWindow.Invoke("showHUD");
m_animMainWindow.Invoke("setVehicleHUDMode", (int)m_eCurVehicleHUD);
m_animMainWindow.SetVisible(true);
m_animStats.Invoke("showStats");
m_animStats.Invoke("setVehicleStatsMode", (int)m_eCurVehicleHUD);
m_animStats.SetVisible(true);
UpdateVehicleHUDDisplay();
UpdateDamages(m_eCurVehicleHUD, m_pVehicle);
if(szVehicleClassName)
{
string name = m_hudTankNames[szVehicleClassName];
if(g_pAmmo)
g_pAmmo->Invoke("setTankName", name.c_str());
}
m_statsSpeed = -999;
m_statsHeading = -999;
m_lastSetFriendly = false;
m_friendlyFire = false;
if(m_eCurVehicleHUD == EHUD_VTOL)
m_animStats.Invoke("disableEject", !(gEnv->bMultiplayer)); //no eject warning in SP
}
}
//-----------------------------------------------------------------------------------------------------
float CHUDVehicleInterface::UpdateDamages(EVehicleHud eHud, IVehicle *pVehicle, bool updateFlash) //this could be put in an xml file for better mod-ability
{
CHUDRadar *pRadar = g_pHUD->GetRadar();
if(!pVehicle || !pVehicle->GetEntity() || !pRadar)
return 1.0f;
bool engineDisabled = pVehicle->GetMovement()->IsEngineDisabled();
if(eHud == EHUD_TANKA || eHud == EHUD_TANKUS || eHud == EHUD_APC)
{
IEntityClass *cls = pVehicle->GetEntity()->GetClass();
if(cls == pRadar->m_pTankA || cls == pRadar->m_pTankUS || cls == pRadar->m_pAPCUS)
{
float fH = pVehicle->GetComponent("hull")->GetDamageRatio();
if(updateFlash)
{
SFlashVarValue args[5] = {fH, engineDisabled ? 1.0f : fH, fH, fH, fH}; // same health for all.
m_animStats.Invoke("setDamage", args, 5);
}
return fH;
}
}
else if(eHud == EHUD_APC2)
{
if(pVehicle->GetEntity()->GetClass() == pRadar->m_pAPCA)
{
float fH = pVehicle->GetComponent("hull")->GetDamageRatio();
float fW1 = pVehicle->GetComponent("wheel1")->GetDamageRatio();
float fW2 = pVehicle->GetComponent("wheel2")->GetDamageRatio();
float fW3 = pVehicle->GetComponent("wheel3")->GetDamageRatio();
float fW4 = pVehicle->GetComponent("wheel4")->GetDamageRatio();
float fW5 = pVehicle->GetComponent("wheel5")->GetDamageRatio();
float fW6 = pVehicle->GetComponent("wheel6")->GetDamageRatio();
float fW7 = pVehicle->GetComponent("wheel7")->GetDamageRatio();
float fW8 = pVehicle->GetComponent("wheel8")->GetDamageRatio();
if(updateFlash)
{
SFlashVarValue args[11] = {fH, engineDisabled ? 1.0f : fH, fH, fW1, fW5, fW2, fW6, fW3, fW7, fW4, fW8};
m_animStats.Invoke("setDamage", args, 11);
}
return fH;
}
}
else if(eHud == EHUD_AAA)
{
if(pVehicle->GetEntity()->GetClass() == pRadar->m_pAAA)
{
float hull = pVehicle->GetComponent("hull")->GetDamageRatio();
if(updateFlash)
{
SFlashVarValue args[3] = {hull, hull, hull};
m_animStats.Invoke("setDamage", args, 3);
}
return hull;
}
}
else if(eHud == EHUD_VTOL)
{
if(pVehicle->GetEntity()->GetClass() == pRadar->m_pVTOL)
{
float fH = pVehicle->GetComponent("Hull")->GetDamageRatio();
if(updateFlash)
{
SFlashVarValue args[3] = {fH, fH, fH};
m_animStats.Invoke("setDamage", args, 3);
}
return fH;
}
}
else if(eHud == EHUD_HELI)
{
if(pVehicle->GetEntity()->GetClass() == pRadar->m_pHeli)
{
float fH = pVehicle->GetComponent("Hull")->GetDamageRatio();
if(updateFlash)
{
SFlashVarValue args[4] = {fH, fH, engineDisabled ? 1.0f : fH, fH};
m_animStats.Invoke("setDamage", args, 4);
}
return fH;
}
}
else if(eHud == EHUD_LTV)
{
if(pVehicle->GetEntity()->GetClass() == pRadar->m_pLTVA || pVehicle->GetEntity()->GetClass() == pRadar->m_pLTVUS)
{
float fH = pVehicle->GetComponent("Hull")->GetDamageRatio();
float fT = pVehicle->GetComponent("FuelCan")->GetDamageRatio();
float fW1 = pVehicle->GetComponent("wheel1")->GetDamageRatio();
float fW2 = pVehicle->GetComponent("wheel2")->GetDamageRatio();
float fW3 = pVehicle->GetComponent("wheel3")->GetDamageRatio();
float fW4 = pVehicle->GetComponent("wheel4")->GetDamageRatio();
if(updateFlash)
{
SFlashVarValue args[7] = {fH, engineDisabled ? 1.0f : fH, fT, fW1, fW2, fW3, fW4};
m_animStats.Invoke("setDamage", args, 7);
}
return fH;
}
}
else if(eHud == EHUD_TRUCK)
{
if(pVehicle->GetEntity()->GetClass() == pRadar->m_pTruck)
{
float fH = pVehicle->GetComponent("Hull")->GetDamageRatio();
float fT1 = pVehicle->GetComponent("LeftFuelTank")->GetDamageRatio();
float fT2 = pVehicle->GetComponent("RightFuelTank")->GetDamageRatio();
float fW1 = pVehicle->GetComponent("wheel1")->GetDamageRatio();
float fW2 = pVehicle->GetComponent("wheel2")->GetDamageRatio();
float fW3 = pVehicle->GetComponent("wheel3")->GetDamageRatio();
float fW4 = pVehicle->GetComponent("wheel4")->GetDamageRatio();
float fW5 = pVehicle->GetComponent("wheel5")->GetDamageRatio();
float fW6 = pVehicle->GetComponent("wheel6")->GetDamageRatio();
if(updateFlash)
{
SFlashVarValue args[10] = {fH, engineDisabled ? 1.0f : fH, fT1, fT2, fW1, fW2, fW3, fW4, fW5, fW6};
m_animStats.Invoke("setDamage", args, 10);
}
return fH;
}
}
else if(eHud == EHUD_SMALLBOAT || m_eCurVehicleHUD == EHUD_CIVBOAT)
{
if(pVehicle->GetEntity()->GetClass() == pRadar->m_pBoatUS || pVehicle->GetEntity()->GetClass() == pRadar->m_pBoatCiv)
{
float fH = pVehicle->GetComponent("Hull")->GetDamageRatio();
if(updateFlash)
{
SFlashVarValue args[3] = {fH, fH, fH};
m_animStats.Invoke("setDamage", args, 3);
}
return fH;
}
}
else if(eHud == EHUD_PATROLBOAT)
{
if(pVehicle->GetEntity()->GetClass() == pRadar->m_pBoatA)
{
float fH = pVehicle->GetComponent("Hull")->GetDamageRatio();
if(updateFlash)
{
SFlashVarValue args[3] = {fH, 0, 0};
m_animStats.Invoke("setDamage", args, 3);
}
return fH;
}
}
else if(eHud == EHUD_HOVER)
{
if(pVehicle->GetEntity()->GetClass() == pRadar->m_pHover)
{
float fH = pVehicle->GetComponent("Hull")->GetDamageRatio();
if(updateFlash)
{
SFlashVarValue args[3] = {fH, 0, 0};
m_animStats.Invoke("setDamage", args, 3);
}
return fH;
}
}
else if(eHud == EHUD_CIVCAR)
{
if(pVehicle->GetEntity()->GetClass() == pRadar->m_pCarCiv)
{
float fH = pVehicle->GetComponent("Hull")->GetDamageRatio();
float fW1 = pVehicle->GetComponent("wheel1")->GetDamageRatio();
float fW2 = pVehicle->GetComponent("wheel2")->GetDamageRatio();
float fW3 = pVehicle->GetComponent("wheel3")->GetDamageRatio();
float fW4 = pVehicle->GetComponent("wheel4")->GetDamageRatio();
if(updateFlash)
{
SFlashVarValue args[6] = {fH, engineDisabled ? 1.0f : fH, fW1, fW2, fW3, fW4};
m_animStats.Invoke("setDamage", args, 6);
}
return fH;
}
}
else if(eHud == EHUD_ASV)
{
float fH = pVehicle->GetComponent("Hull")->GetDamageRatio();
float fW1 = pVehicle->GetComponent("wheel1")->GetDamageRatio();
float fW2 = pVehicle->GetComponent("wheel2")->GetDamageRatio();
float fW3 = pVehicle->GetComponent("wheel3")->GetDamageRatio();
float fW4 = pVehicle->GetComponent("wheel4")->GetDamageRatio();
if(updateFlash)
{
SFlashVarValue args[6] = {fH, engineDisabled ? 1.0f : fH, fW1, fW3, fW2, fW4};
m_animStats.Invoke("setDamage", args, 6);
}
return fH;
}
return 1.0f;
}
//-----------------------------------------------------------------------------------------------------
void CHUDVehicleInterface::UpdateSeats()
{
if(!m_pVehicle)
return;
int seatCount = m_pVehicle->GetSeatCount();
for(int i = 1; i <= seatCount; ++i)
{
IVehicleSeat *pSeat = m_pVehicle->GetSeatById(TVehicleSeatId(i));
if(pSeat)
{
EntityId passenger = pSeat->GetPassenger();
//set seats in flash
if(m_eCurVehicleHUD)
{
SFlashVarValue args[2] = {i, 0};
if(passenger)
{
IActor *pActor=gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(passenger);
if (pActor && pActor->GetHealth()>0) // don't show dead players on the hud
{
// set different colors if the passenger is the player
args[1] = (passenger == gEnv->pGame->GetIGameFramework()->GetClientActor()->GetEntityId())?2:1;
}
}
else if(pSeat->IsLocked())
{
args[1] = 3;
}
m_animStats.Invoke("setSeat", args, 2);
}
}
}
}
//-----------------------------------------------------------------------------------------------------
void CHUDVehicleInterface::OnVehicleEvent(EVehicleEvent event, const SVehicleEventParams& params)
{
if(eVE_VehicleDeleted == event)
{
m_pVehicle = NULL;
m_seatId = InvalidVehicleSeatId;
}
if (!m_pVehicle)
return;
CActor *pPlayerActor = static_cast<CActor *>(gEnv->pGame->GetIGameFramework()->GetClientActor());
if(!pPlayerActor)
return;
if(event == eVE_SetAmmo)
{
g_pHUD->UpdateBuyMenuPages();
}
if(event == eVE_PassengerEnter || event == eVE_PassengerChangeSeat || event == eVE_SeatFreed)
{
g_pHUD->m_buyMenuKeyLog.Clear();
if(params.entityId == pPlayerActor->GetEntityId())
{
m_seatId = params.iParam;
UpdateVehicleHUDDisplay();
g_pHUD->UpdateBuyMenuPages();
}
if (eVE_PassengerChangeSeat == event)
{
if (IEntity* pEntity = gEnv->pEntitySystem->GetEntity(params.entityId))
{
IEntitySoundProxy* pSoundProxy = (IEntitySoundProxy*)pEntity->GetProxy(ENTITY_PROXY_SOUND);
if (pSoundProxy)
pSoundProxy->PlaySound("sounds/physics:player_foley:switch_seat", Vec3Constants<float>::fVec3_Zero, Vec3Constants<float>::fVec3_OneY, 0, eSoundSemantic_Player_Foley);
if(pPlayerActor->GetEntity() == pEntity)
g_pHUD->SetFireMode(NULL, NULL, true);
}
}
UpdateSeats();
}
else if(eVE_Damaged == event || eVE_Collision == event || eVE_Repair)
{
UpdateDamages(m_eCurVehicleHUD, m_pVehicle);
}
}
//-----------------------------------------------------------------------------------------------------
void CHUDVehicleInterface::UpdateVehicleHUDDisplay()
{
CActor *pPlayerActor = static_cast<CActor *>(gEnv->pGame->GetIGameFramework()->GetClientActor());
if(!pPlayerActor)
return;
IVehicleSeat *seat = NULL;
if(m_pVehicle)
{
seat = m_pVehicle->GetSeatForPassenger(pPlayerActor->GetEntityId());
if(!seat)
return;
}
m_eCurVehicleHUD = ChooseVehicleHUD(m_pVehicle);
if(!g_pAmmo)
return;
if((seat && seat->IsDriver()) || m_bParachute)
{
if(m_hasMainHUD[m_eCurVehicleHUD])
{
m_animMainWindow.Invoke("showHUD");
m_animMainWindow.SetVisible(true);
}
else if(m_animMainWindow.IsLoaded())
m_animMainWindow.Unload();
if(m_pVehicle && m_pVehicle->GetWeaponCount() > 1)
g_pAmmo->Invoke("showReloadDuration2");
else
g_pAmmo->Invoke("hideReloadDuration2");
g_pAmmo->Invoke("setAmmoMode", m_eCurVehicleHUD);
}
else if(seat && seat->IsGunner())
{
m_animMainWindow.Invoke("hideHUD");
m_animMainWindow.SetVisible(false);
g_pAmmo->Invoke("setAmmoMode", 0);
}
else
{
m_animMainWindow.Invoke("hideHUD");
m_animMainWindow.SetVisible(false);
g_pAmmo->Invoke("setAmmoMode", 21);
}
g_pHUD->UpdateCrosshairVisibility();
}
//-----------------------------------------------------------------------------------------------------
bool CHUDVehicleInterface::IsAbleToBuy()
{
if(!m_pVehicle)
return false;
if(m_seatId == InvalidVehicleSeatId)
return false;
if(m_pVehicle->GetWeaponCount()<=0)
return false;
if (IVehicleSeat* pSeat = m_pVehicle->GetSeatById(m_seatId))
{
if(!pSeat->IsDriver() && !pSeat->IsGunner())
return false;
}
bool needAmmo = false;
int n=m_pVehicle->GetWeaponCount();
for (int i=0; i<n; i++)
{
if(!needAmmo)
{
if (EntityId weaponId=m_pVehicle->GetWeaponId(i))
{
if (IItem *pItem=gEnv->pGame->GetIGameFramework()->GetIItemSystem()->GetItem(weaponId))
{
CWeapon *pWeapon=static_cast<CWeapon *>(pItem->GetIWeapon());
if (!pWeapon)
continue;
int nfm=pWeapon->GetNumOfFireModes();
for (int fm=0; fm<nfm; fm++)
{
if(!needAmmo)
{
IFireMode *pFM = pWeapon->GetFireMode(fm);
if (pFM && pFM->IsEnabled() && (pFM->GetClipSize()!=-1))
{
needAmmo = true;
break;
}
}
}
}
}
}
}
return needAmmo;
}
//-----------------------------------------------------------------------------------------------------
float CHUDVehicleInterface::GetVehicleSpeed()
{
float fSpeed = 0.0;
if(m_pVehicle)
{
fSpeed = m_pVehicle->GetStatus().speed;
}
else
{
CActor *pPlayerActor = static_cast<CActor *>(gEnv->pGame->GetIGameFramework()->GetClientActor());
if(pPlayerActor)
{
fSpeed = pPlayerActor->GetActorStats()->velocity.len();
}
}
fSpeed *= 2.24f; // Meter per second TO Miles hour
return fSpeed;
}
//-----------------------------------------------------------------------------------------------------
float CHUDVehicleInterface::GetVehicleHeading()
{
float fAngle = 0.0;
if(m_pVehicle)
{
SMovementState sMovementState;
m_pVehicle->GetMovementController()->GetMovementState(sMovementState);
Vec3 vEyeDirection = sMovementState.eyeDirection;
vEyeDirection.z = 0.0f;
vEyeDirection.normalize();
fAngle = RAD2DEG(acos_tpl(vEyeDirection.x));
if(vEyeDirection.y < 0) fAngle = -fAngle;
}
return fAngle;
}
//-----------------------------------------------------------------------------------------------------
float CHUDVehicleInterface::GetRelativeHeading()
{
float fAngle = 0.0;
if(m_pVehicle)
{
CActor *pPlayerActor = static_cast<CActor *>(gEnv->pGame->GetIGameFramework()->GetClientActor());
if(pPlayerActor)
{
if (IVehicleSeat *pSeat = m_pVehicle->GetSeatForPassenger(pPlayerActor->GetEntityId()))
{
//this is kinda workaround since it requires the "turning part" of the vehicle to be called "turret" (but everything else would be way more complicated)
if (IVehiclePart* pPart = m_pVehicle->GetPart("turret"))
{
const Matrix34& matLocal = pPart->GetLocalTM(false);
Vec3 vLocalLook = matLocal.GetColumn(1);
vLocalLook.z = 0.0f;
vLocalLook.normalize();
fAngle = RAD2DEG(acos_tpl(vLocalLook.x));
if(vLocalLook.y < 0) fAngle = -fAngle;
fAngle -= 90.0f;
}
else
return 0.0f;
}
}
}
return fAngle;
}
//-----------------------------------------------------------------------------------------------------
void CHUDVehicleInterface::ShowVehicleInterface(EVehicleHud type, bool forceFlashUpdate)
{
if(!m_pVehicle && !m_bParachute)
return;
CActor *pPlayerActor = static_cast<CActor *>(gEnv->pGame->GetIGameFramework()->GetClientActor());
IVehicleSeat *pSeat = NULL;
if(m_pVehicle)
{
pSeat = m_pVehicle->GetSeatForPassenger(pPlayerActor->GetEntityId());
if(!pSeat)
return;
}
if(g_pAmmo)
{
int iPrimaryAmmoCount = 0;
int iPrimaryClipSize = 0;
int iSecondaryAmmoCount = 0;
int iSecondaryClipSize = 0;
if(m_pVehicle)
{
CWeapon *pWeapon = pPlayerActor->GetWeapon(m_pVehicle->GetCurrentWeaponId(pPlayerActor->GetEntity()->GetId()));
if(pWeapon)
{
IFireMode *pFireMode = pWeapon->GetFireMode(pWeapon->GetCurrentFireMode());
if(pFireMode)
{
IEntityClass *pAmmoType = pFireMode->GetAmmoType();
iPrimaryClipSize = pFireMode->GetClipSize();
if (iPrimaryClipSize==0)
iPrimaryAmmoCount=m_pVehicle->GetAmmoCount(pAmmoType);
else
{
if (iPrimaryClipSize!=-1)
iPrimaryClipSize=m_pVehicle->GetAmmoCount(pAmmoType);
iPrimaryAmmoCount=pWeapon->GetAmmoCount(pAmmoType);
}
/*if(pFireMode->CanOverheat())
{
int heat = int(pFireMode->GetHeat()*100);
if(m_iHeat != heat)
{
SFlashVarValue args[2] = {true, pFireMode->GetHeat()*100};
g_pAmmo->Invoke("setOverheatBar", args, 2);
m_iHeat = heat;
}
}
else
m_iHeat = 0;*/
int fmIdx = g_pHUD->GetSelectedFiremode();
if(fmIdx == 8 || fmIdx == 15 || fmIdx == 22 || fmIdx == 24) //infite ammo firemodes
iSecondaryClipSize = -1;
}
}
else
{
if(IItem *pFists = pPlayerActor->GetItemByClass(CItem::sFistsClass))
g_pHUD->SetFireMode(pFists, NULL);
}
pWeapon = pPlayerActor->GetWeapon(m_pVehicle->GetCurrentWeaponId(pPlayerActor->GetEntity()->GetId(),true));
if(pWeapon)
{
IFireMode *pFireMode = pWeapon->GetFireMode(pWeapon->GetCurrentFireMode());
if(pFireMode)
{
IEntityClass *pAmmoType = pFireMode->GetAmmoType();
iSecondaryClipSize = pFireMode->GetClipSize();
if (iSecondaryClipSize==0)
iSecondaryAmmoCount=m_pVehicle->GetAmmoCount(pAmmoType);
else
{
if (iSecondaryClipSize!=-1)
iSecondaryClipSize=m_pVehicle->GetAmmoCount(pAmmoType);
iSecondaryAmmoCount=pWeapon->GetAmmoCount(pAmmoType);
}
}
}
if( forceFlashUpdate ||
m_iSecondaryAmmoCount != iSecondaryAmmoCount ||
m_iPrimaryAmmoCount != iPrimaryAmmoCount ||
m_iSecondaryClipSize != iSecondaryClipSize ||
m_iPrimaryClipSize != iPrimaryClipSize ||
m_bAmmoForceNextUpdate)
{
SFlashVarValue args[7] = {iSecondaryAmmoCount, iPrimaryAmmoCount, iSecondaryClipSize, iPrimaryClipSize, 0, "", false};
g_pAmmo->Invoke("setAmmo", args, 7);
//if(iSecondaryClipSize == -1)
// g_pAmmo->Invoke("setFireMode", 8);
m_iSecondaryAmmoCount = iSecondaryAmmoCount;
m_iPrimaryAmmoCount = iPrimaryAmmoCount;
m_iSecondaryClipSize = iSecondaryClipSize;
m_iPrimaryClipSize = iPrimaryClipSize;
m_bAmmoForceNextUpdate = false;
}
}
}
SMovementState sMovementState;
if(m_pVehicle)
{
m_pVehicle->GetMovementController()->GetMovementState(sMovementState);
}
else
{
pPlayerActor->GetMovementController()->GetMovementState(sMovementState);
}
float fAngle = GetVehicleHeading();
float fSpeed = GetVehicleSpeed();
float fRelAngle = GetRelativeHeading();
float fPosHeading = (fAngle*8.0f/3.0f);
if(m_pVehicle && m_pVehicle->GetEntity())
{
fPosHeading = (m_pVehicle->GetEntity()->GetWorldAngles().z*180.0f/gf_PI + fRelAngle)*8.0f/3.0f;
}
wchar_t szN[256];
wchar_t szW[256];
char szSpeed[32];
char szAltitude[32];
char szDistance[32];
CrySwprintf(szN,32,L"%.0f",0.f);
CrySwprintf(szW,32,L"%.0f",0.f);
sprintf(szSpeed,"%.2f",fSpeed);
sprintf(szAltitude,"%.0f",0.f);
sprintf(szDistance,"%.0f",0.f);
float fAltitude;
if(((int)fSpeed) != m_statsSpeed)
{
SFlashVarValue args[2] = {szSpeed, (int)fSpeed};
m_animStats.CheckedInvoke("setSpeed", args, 2);
m_statsSpeed = (int)fSpeed;
}
// Note: this needs to be done even if we are not the driver, as the driver
// may change the direction of the main turret while we'are at the gunner seat
if(pSeat && (type == EHUD_TANKA || type == EHUD_TANKUS || type == EHUD_AAA || type == EHUD_APC || type == EHUD_APC2))
{
if((int)fRelAngle != m_statsHeading)
{
m_animStats.CheckedInvoke("setDirection", (int)fRelAngle); //vehicle/turret angle
m_statsHeading = (int)fRelAngle;
}
}
if(type == EHUD_VTOL || type == EHUD_HELI || type == EHUD_PARACHUTE)
{
float fHorizon;
if(m_pVehicle)
{
Vec3 vWorldPos = m_pVehicle->GetEntity()->GetWorldPos();
float waterLevel = gEnv->p3DEngine->GetWaterLevel(&vWorldPos);
float terrainZ = GetISystem()->GetI3DEngine()->GetTerrainZ((int)vWorldPos.x,(int)vWorldPos.y);
if(terrainZ < waterLevel)
terrainZ = waterLevel;
fAltitude = vWorldPos.z-terrainZ;
fHorizon = -RAD2DEG(m_pVehicle->GetEntity()->GetWorldAngles().y);
}
else
{
Vec3 vWorldPos = pPlayerActor->GetEntity()->GetWorldPos();
float waterLevel = gEnv->p3DEngine->GetWaterLevel(&vWorldPos);
float terrainZ = GetISystem()->GetI3DEngine()->GetTerrainZ((int)vWorldPos.x,(int)vWorldPos.y);
if(terrainZ < waterLevel)
terrainZ = waterLevel;
fAltitude = vWorldPos.z-terrainZ;
fHorizon = -RAD2DEG(pPlayerActor->GetAngles().y);
}
sprintf(szAltitude,"%.2f",fAltitude);
//g_pHUD->GetGPSPosition(szN,szW);
m_animMainWindow.Invoke("setHorizon", fHorizon);
}
if(type == EHUD_VTOL || type == EHUD_HELI)
{
float fVerticalHorizon = 0.0f;
if(m_pVehicle)
{
fVerticalHorizon = RAD2DEG(m_pVehicle->GetEntity()->GetWorldAngles().x);
m_animMainWindow.Invoke("setVerticalHorizon", fVerticalHorizon);
}
}
if(type == EHUD_VTOL || type == EHUD_HELI || type == EHUD_TANKA || type == EHUD_TANKUS ||
type == EHUD_AAA || type == EHUD_LTV || type == EHUD_APC || type == EHUD_TRUCK ||
type == EHUD_SMALLBOAT || type == EHUD_PATROLBOAT || type == EHUD_APC2 || type==EHUD_ASV || type==EHUD_HOVER)
{
if(g_pAmmo)
{
IWeapon *pPlayerWeapon = pPlayerActor->GetWeapon(m_pVehicle->GetCurrentWeaponId(pPlayerActor->GetEntity()->GetId()));
if(pPlayerWeapon)
{
if(IFireMode *pFireMode = pPlayerWeapon->GetFireMode(pPlayerWeapon->GetCurrentFireMode()))
{
int duration = 0;
if(pFireMode->CanOverheat())
{
duration = (int)(pFireMode->GetHeat()*100);
if(duration != m_iLastReloadBarValue)
{
g_pAmmo->Invoke("setOverheatBar", duration);
m_iLastReloadBarValue = duration;
}
}
else
{
float fFireRate = 60.0f / pFireMode->GetFireRate();
float fNextShotTime = pFireMode->GetNextShotTime();
duration = int(((fFireRate-fNextShotTime)/fFireRate)*100.0f+1.0f);
if(duration != m_iLastReloadBarValue)
{
g_pAmmo->Invoke("setReloadDuration", duration);
if(g_pGameCVars->hud_showBigVehicleReload && m_hasMainHUD[m_eCurVehicleHUD] && type != EHUD_PATROLBOAT)
m_animMainWindow.Invoke("setReloadDuration", duration);
m_iLastReloadBarValue = duration;
}
}
}
}
if(type == EHUD_AAA || type == EHUD_APC || type == EHUD_APC2 || type == EHUD_TANKA || type == EHUD_TANKUS || type == EHUD_VTOL || type == EHUD_HELI) //get reload for secondary guns
{
IItem *pItem = gEnv->pGame->GetIGameFramework()->GetIItemSystem()->GetItem(m_pVehicle->GetWeaponId(1));
if(pItem)
{
IWeapon *pWeapon = pItem->GetIWeapon();
if(IFireMode *pFireMode = pWeapon->GetFireMode(pWeapon->GetCurrentFireMode()))
{
int duration = 0;
if(pFireMode->CanOverheat())
{
duration = (int)(pFireMode->GetHeat()*100);
if(duration != m_iLastReloadBarValue2)
{
g_pAmmo->Invoke("setOverheatBar2", duration);
m_iLastReloadBarValue2 = duration;
}
}
else
{
float fFireRate = 60.0f / pFireMode->GetFireRate();
float fNextShotTime = pFireMode->GetNextShotTime();
duration = int(((fFireRate-fNextShotTime)/fFireRate)*100.0f+1.0f);
if(duration != m_iLastReloadBarValue2)
{
g_pAmmo->Invoke("setReloadDuration2", duration);
if(g_pGameCVars->hud_showBigVehicleReload && m_hasMainHUD[m_eCurVehicleHUD])
m_animMainWindow.Invoke("setReloadDuration2", duration);
m_iLastReloadBarValue2 = duration;
}
}
}
}
}
}
// FIXME: This one doesn't work because the nearest object often is ... the cannon of the tank !!!
const ray_hit *pRay = pPlayerActor->GetGameObject()->GetWorldQuery()->GetLookAtPoint(100.0f);
if(pRay)
{
sprintf(szDistance,"%.1f",pRay->dist);
}
else
{
sprintf(szDistance,"%.0f",11.0);
szDistance[0]='-';
}
}
{
SFlashVarValue args[10] = {(int)fPosHeading, szN, szW, szAltitude, fAltitude, (int)(sMovementState.eyeDirection.z*90.0), szSpeed, (int)fSpeed, (int)fAngle, szDistance};
m_animMainWindow.Invoke("setVehicleValues", args, 10);
}
}
//-----------------------------------------------------------------------------------------------------
void CHUDVehicleInterface::HideVehicleInterface()
{
m_animMainWindow.Invoke("hideHUD");
m_animMainWindow.SetVisible(false);
m_animStats.Invoke("hideStats");
m_animStats.SetVisible(false);
}
//-----------------------------------------------------------------------------------------------------
void CHUDVehicleInterface::UnloadVehicleHUD(bool remove)
{
if(remove)
{
m_animStats.Unload();
m_animMainWindow.Unload();
m_statsSpeed = -999;
m_statsHeading = -999;
}
else if(m_pVehicle && m_eCurVehicleHUD != EHUD_NONE)
{
if(m_hasMainHUD[m_eCurVehicleHUD])
{
m_animMainWindow.Reload();
m_animMainWindow.SetVariable("SkipSequence",SFlashVarValue(true));
}
m_animStats.Reload();
ShowVehicleInterface(m_eCurVehicleHUD);
InitVehicleHuds();
UpdateVehicleHUDDisplay();
UpdateSeats();
UpdateDamages(m_eCurVehicleHUD, m_pVehicle);
}
}
void CHUDVehicleInterface::Serialize(TSerialize ser)
{
ser.Value("hudParachute", m_bParachute);
EVehicleHud oldVehicleHud = m_eCurVehicleHUD;
ser.EnumValue("CurVehicleHUD", m_eCurVehicleHUD, EHUD_NONE, EHUD_LAST);
if(ser.IsReading())
{
IActor *pActor = gEnv->pGame->GetIGameFramework()->GetClientActor();
if(pActor)
{
OnExitVehicle(pActor);
}
}
}
| [
"joannesvos@3e62a6f2-0c60-11df-bbbe-ede73d0abfb9",
"i59.EDGE@3e62a6f2-0c60-11df-bbbe-ede73d0abfb9"
]
| [
[
[
1,
285
],
[
289,
1148
]
],
[
[
286,
288
]
]
]
|
1c5f097feeffd0f501d1af6b9969a3bc651fb39a | a5de878687ee2e72db865481785dafbeda373e2a | /trunck/OpenPR-0.0.2/sci_gateway/qdmatch/QuasiDense.h | 6d4e89ac2bda16491c2505c18bbdca1456ce0292 | [
"BSD-3-Clause"
]
| permissive | Augertron/OpenPR | 8f43102fd5811d26301ef75e0a1f2b6ba9cbdb73 | e2b1ce89f020c1b25df8ac5d93f6a0014ed4f714 | refs/heads/master | 2020-05-15T09:31:08.385577 | 2011-03-21T02:51:40 | 2011-03-21T02:51:40 | 182,178,910 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,904 | h | //////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2009 OpenPR
// 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 OpenPR 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 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 HOLDER AND 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.
////////////////////////////////////////////////////////////////////////////
// QuasiDense.h
#ifndef QUASIDENSE_H
#define QUASIDENSE_H
#include <algorithm>
#include <functional>
#include <list>
#include "Image.h"
#include "Match.h"
#include "Ransac.h"
#include "Correspond.h"
#include "SiftUtil.h"
#include "HeapSort.h"
#include "NyxMat.h"
/*-----------------------------Quasi-Dense Correspondence--------------------*/
int QuasiDense(NyxMat<double> &fundM, vector<Match> &matches,
const vector<Match> &corrMatches,
Image &im1, Image &im2, int times,
vector<Match>* pMatch01 = 0, char* match12File=0);
int Propagate(vector<Match> &denseMatches,
const vector<Match> &matches, NyxMat<double> &fund, double thresh,
Image &im1, Image &im2);
bool ** InitializeFlag(int xDim, int yDim);
//double ** InitializeGrad(Image &im);
double GradMeasure(int x, int y, Image &im);
int Resample(vector<Match> &sampledMatches,
const vector<Match> &matches,
Image &im1, Image &im2, int times,
vector<Match>* pMatch01 = 0, char* match12File=0);
// initialize confident measure for the two images
bool** InitializeConfidL(Image& img, int xDim, int yDim, double sThresh);
// find corresponding points using affine matrix, and then store that match into a vector
bool AddPnt2Vec(double x1, double y1, Image &im1, Image &im2,
bool isKey, NyxMat<double> &affine, vector<Match>& matches);
// judge whether two points are same
bool IsSamePoint(Point& pnt1, Point& pnt2);
bool IsSamePoint(double x1, double y1, double x2, double y2);
// judge whether pnt1 is included in vector "matches"
bool IsInMatchVec(Point& pnt1, vector<Match>& matches);
// overload
bool IsInMatchVec(int x1, int x2, vector<Match>& matches);
// assign matches into match queues of local patches
void AssignMatch2Local(vector<vector<Match> >& localMatches,
vector<vector<Match> >& localInterst,
const vector<Match>& matches, int xMargin, int yMargin,
int XDim, int yDim, int xSquare, int squareNum, int square);
//overload
void AssignMatch2Local(vector<vector<Match> >& match01Pat,
vector<Match>* pMatch01, int xMargin, int yMargin,
int XDim, int yDim, int xSquare, int squareNum, int square);
#endif
| [
"openpr@9318c073-892e-421e-b8e5-d5f98a2b248e"
]
| [
[
[
1,
95
]
]
]
|
9d6af076849dcec723bcab07de3654a0e331b7dc | 89d2197ed4531892f005d7ee3804774202b1cb8d | /GWEN/src/stdafx.cpp | 4426ee4ed9477a3863bc53fe06b014edb1e12016 | [
"MIT",
"Zlib"
]
| permissive | hpidcock/gbsfml | ef8172b6c62b1c17d71d59aec9a7ff2da0131d23 | e3aa990dff8c6b95aef92bab3e94affb978409f2 | refs/heads/master | 2020-05-30T15:01:19.182234 | 2010-09-29T06:53:53 | 2010-09-29T06:53:53 | 35,650,825 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 291 | cpp | // stdafx.cpp : source file that includes just the standard includes
// Gwen.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
| [
"haza55@5bf3a77f-ad06-ad18-b9fb-7d0f6dabd793"
]
| [
[
[
1,
8
]
]
]
|
ebe954b1d8de0037044b77670b9a9d66b0f1ef27 | 085c4bd19e5cc208cd115a2c873ee1835b83cf28 | /final_integrated_codes/openmoko-side/src/main.cpp | f3ede7d5cf3ab82b9df4a13cc4f7b39b3b953cbf | []
| no_license | saurabh1403/attendance-on-openmoko | 3d127f266e4880fd6e7f4335d2421a32abf88e1e | c2b69fd79067c27764a8a25d8202c91e92c8089c | refs/heads/master | 2020-05-19T11:57:39.954037 | 2010-05-29T09:36:12 | 2010-05-29T09:36:12 | 35,387,175 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,504 | cpp |
#include"include.h"
using namespace std;
Comm_Mode Current_mode = Via_WiFi; //default communication mode
int send_pending_files(Comm_Mode Current_Mode = Via_WiFi)
{
int status;
string ErrMsg;
//sending of all previous files should be done here. TO DO
string config_file = get_data_folder();
config_file+= CONFIG_FILE_NAME;
vector<string> list_files;
int no_file;
read_file(config_file, no_file,list_files);
for(int i =0;i<no_file;i++)
{
if(Current_Mode == Via_WiFi)
status = send_file(get_local_folder(), list_files[i], IP_CONNECT, PORT, ErrMsg);
else if(Current_Mode == Via_Wire)
status = send_file(get_local_folder(), list_files[i], IP_USB, PORT, ErrMsg);
if(status<0)
{
update_log_file(ErrMsg);
}
else
{
ErrMsg = list_files[i];
ErrMsg+= " sent to server";
update_log_file(ErrMsg);
update_config_file(list_files[i], DELETE_ENTRY);
}
}
return status;
}
void take_new_attendance(int argc, char *argv[], string class_selected, string sub_selected)
{
string file_name, ErrMsg;
int status = 1;
status = create_take_attendance(argc, argv, file_name, class_selected, sub_selected);
if(status<0)
{
update_log_file("failed to take attendance");
}
else
{
update_config_file(file_name, ADD_ENTRY);
// final_window(argc,argv);
status = send_pending_files(Current_mode);
feedback_window(argc, argv, status);
}
}
void enter_new_notes(int argc, char * argv[],string RollList, string sub_selected)
{
string file_name, ErrMsg;
Option return_code;
int status = create_take_notes(argc, argv, file_name, RollList, sub_selected,return_code);
// cout<<"notes file is "<<file_name.c_str();
if(return_code == NO)
{
update_log_file("failed to take notes");
// cout<<"failed to take notes";
}
else
{
status = take_notes_individual(argc, argv, file_name, sub_selected);
// cout<<"notes file later is "<<file_name.c_str();
if(status<0)
{
update_log_file("failed to take attendance");
}
else
{
update_config_file(file_name, ADD_ENTRY);
// final_window(argc, argv);
status = send_pending_files(Current_mode);
feedback_window(argc, argv, status);
}
}
}
void update_openmoko_data()
{
}
int main(int argc, char* argv[])
{
// this is the main window creating the combo box.
string class_selected, sub_selected, ErrMsg;
UserOptions option_selected;
int status;Option return_code = YES;
// while(return_code == YES)
{
status = backend(argc, argv);
status = begin_window(argc, argv,option_selected);
// cout<<option_selected;
switch (option_selected)
{
case TakeAttendance:
status = class_list_window(argc,argv, class_selected, sub_selected);
if(status > 0)
take_new_attendance(argc, argv, class_selected, sub_selected);
// cout<<class_selected<<" "<<sub_selected;
break;
case TakeNotes:
status = class_list_window(argc, argv, class_selected, sub_selected);
if(status > 0)
enter_new_notes(argc, argv, class_selected ,sub_selected);
// cout<<"\n\nreturn code is"<<(return_code==YES);
break;
case Pending_data:
Current_mode = pending_data( argc, argv);
// cout<<"Print fuck:\n"<<Current_mode;
send_pending_files(Current_mode);
break;
default:
break;
}
// final_window_call(argc, argv, return_code);
}
return 0;
}
| [
"majumdar.unicorn@921b6ea8-b952-11dd-a503-ed2d4bea8bb5",
"saurabhgupta1403@921b6ea8-b952-11dd-a503-ed2d4bea8bb5"
]
| [
[
[
1,
5
],
[
115,
116
],
[
121,
121
],
[
158,
158
]
],
[
[
6,
114
],
[
117,
120
],
[
122,
157
],
[
159,
160
]
]
]
|
14553b113784ea055ccf9f5d91f31610079857e8 | 9ba08620ddc3579995435d6e0e9cabc436e1c88d | /src/RenderMethod_Gouraud.h | b72f10a6305708b5444b93df8ea72c6d65bb289b | [
"MIT"
]
| permissive | foxostro/CheeseTesseract | f5d6d7a280cbdddc94a5d57f32a50caf1f15e198 | 737ebbd19cee8f5a196bf39a11ca793c561e56cb | refs/heads/master | 2021-01-01T17:31:27.189613 | 2009-08-02T13:27:20 | 2009-08-02T13:27:33 | 267,008 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 848 | h | #ifndef _RENDER_METHOD_DIFFUSE_TEXTURE_H_
#define _RENDER_METHOD_DIFFUSE_TEXTURE_H_
#include "RenderMethod.h"
/** Renders a model with diffuse gouraud shading and texturing */
class RenderMethod_Gouraud : public RenderMethod {
public:
/** Constructor */
RenderMethod_Gouraud() {
// Do Nothing
}
/** Called one time to set up the shader when the renderer starts */
virtual void setupShader(CGcontext &, CGprofile &, CGprofile &) {
// Do Nothing
}
/** Shader performs whatever work is necessary during the specified pass*/
virtual void renderPass(RENDER_PASS pass);
/** Indicates that the shadr is supported on this hardware */
virtual bool isSupported() const {
return true; // so simple it uses opengl 1.0
}
private:
/** Pass for opaque, shaded objects */
void pass_opaque();
};
#endif
| [
"arfox@arfox-desktop"
]
| [
[
[
1,
32
]
]
]
|
616dbc8a94a1f8180799eaea4f9a341f1c99c78b | c5534a6df16a89e0ae8f53bcd49a6417e8d44409 | /trunk/Dependencies/Xerces/include/xercesc/sax2/LexicalHandler.hpp | 19dc06d1e7ed08c5feab13a28c1312cb077e1913 | []
| no_license | svn2github/ngene | b2cddacf7ec035aa681d5b8989feab3383dac012 | 61850134a354816161859fe86c2907c8e73dc113 | refs/heads/master | 2023-09-03T12:34:18.944872 | 2011-07-27T19:26:04 | 2011-07-27T19:26:04 | 78,163,390 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,245 | hpp | /*
* Copyright 1999-2000,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: LexicalHandler.hpp 191054 2005-06-17 02:56:35Z jberry $
*/
#ifndef LEXICALHANDLER_HPP
#define LEXICALHANDLER_HPP
#include <xercesc/util/XercesDefs.hpp>
XERCES_CPP_NAMESPACE_BEGIN
/**
* Receive notification of lexical events.
*
* <p>This is an extension handler for that provides lexical information
* about an XML document. It does not provide information about document
* content. For those events, an application must register an instance of
* a ContentHandler.</p>
*
* <p>The order of events in this interface is very important, and
* mirrors the order of information in the document itself. For
* example, startDTD() and endDTD() events will occur before the
* first element in the document.</p>
*
* @see SAX2XMLReader#setLexicalHandler
* @see SAX2XMLReader#setContentHandler
*/
class SAX2_EXPORT LexicalHandler
{
public:
/** @name Constructors and Destructor */
//@{
/** Default constructor */
LexicalHandler()
{
}
/** Destructor */
virtual ~LexicalHandler()
{
}
//@}
/** @name The virtual document handler interface */
//@{
/**
* Receive notification of comments.
*
* <p>The Parser will call this method to report each occurence of
* a comment in the XML document.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* @param chars The characters from the XML document.
* @param length The number of characters to read from the array.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void comment
(
const XMLCh* const chars
, const unsigned int length
) = 0;
/**
* Receive notification of the end of a CDATA section.
*
* <p>The SAX parser will invoke this method at the end of
* each CDATA parsed.</p>
*
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void endCDATA () = 0;
/**
* Receive notification of the end of the DTD declarations.
*
* <p>The SAX parser will invoke this method at the end of the
* DTD</p>
*
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void endDTD () = 0;
/**
* Receive notification of the end of an entity.
*
* <p>The SAX parser will invoke this method at the end of an
* entity</p>
*
* @param name The name of the entity that is ending.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void endEntity (const XMLCh* const name) = 0;
/**
* Receive notification of the start of a CDATA section.
*
* <p>The SAX parser will invoke this method at the start of
* each CDATA parsed.</p>
*
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void startCDATA () = 0;
/**
* Receive notification of the start of the DTD declarations.
*
* <p>The SAX parser will invoke this method at the start of the
* DTD</p>
*
* @param name The document type name.
* @param publicId The declared public identifier for the external DTD subset, or null if none was declared.
* @param systemId The declared system identifier for the external DTD subset, or null if none was declared.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void startDTD
(
const XMLCh* const name
, const XMLCh* const publicId
, const XMLCh* const systemId
) = 0;
/**
* Receive notification of the start of an entity.
*
* <p>The SAX parser will invoke this method at the start of an
* entity</p>
*
* @param name The name of the entity that is starting.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void startEntity (const XMLCh* const name) = 0;
//@}
private :
/* Unimplemented Constructors and operators */
/* Copy constructor */
LexicalHandler(const LexicalHandler&);
/** Assignment operator */
LexicalHandler& operator=(const LexicalHandler&);
};
XERCES_CPP_NAMESPACE_END
#endif
| [
"Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57"
]
| [
[
[
1,
172
]
]
]
|
2bf256f3f47fc591e230aeac53d5c3713778d7d7 | ecad3fd828aed1aa8b7703a3631e0d37bf5d4cbf | /normalizer.hpp | 9689a7e0c72ccf8deec9bf145f8985173dd26d59 | []
| no_license | Fadis/TinyFM | 2b1c2b241a28f89b188a931fd8f41b4284fb6e2a | b2940ca1166ccb1e7a0cdfae7e97f6da3bfa2da4 | refs/heads/master | 2016-09-05T17:06:54.086871 | 2011-09-23T05:06:54 | 2011-09-23T05:06:54 | 2,361,667 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,843 | hpp | #ifndef TINYFM_NORMALIZER_HPP
#define TINYFM_NORMALIZER_HPP
#include "config.hpp"
class Top {
public:
Top() : top( 1 ), until( 0 ) {
}
void set( SampleType _value ) {
if( get() < _value ) {
top = _value;
until = 1;
}
else if( until > 0 )
until -= getGain();
}
SampleType get() const {
const SampleType value = top * until;
if( value < 1 )
return 1;
else
return value;
}
private:
SampleType getGain() const {
static const SampleType gain = 0.0000625f;
return gain;
}
SampleType top;
SampleType until;
};
class Normalize {
public:
Normalize() : head( 0u ) {
for( unsigned int index = 0; index != 9; ++index ) {
wave_buffer[ index ] = 0;
top_buffer[ index ] = 1;
}
}
void set( SampleType _value ) {
wave_buffer[ head ] = _value;
if( _value < 0 )
_value = -_value;
top.set( _value * getScale() );
top_buffer[ head ] = top.get();
++head;
head %= 9;
}
SampleType get() const {
SampleType sum = 0;
for( unsigned int index = 0; index != 9; ++index ) {
sum += top_buffer[ ( index + head ) % 9 ] * getWeight( index );
}
sum /= getNormal();
return wave_buffer[ ( head + 5 ) % 9 ] / sum;
}
private:
SampleType getWeight( unsigned int _index ) const {
static const SampleType savgol_weight[ 9 ] = {
-21, 14, 39, 54, 59, 54, 39, 14, -21
};
return savgol_weight[ _index ];
}
SampleType getNormal() const {
static const SampleType savgol_normal = 231;
return savgol_normal;
}
SampleType getScale() const {
static const SampleType scale = 1.5f;
return scale;
}
Top top;
unsigned int head;
SampleType wave_buffer[9];
SampleType top_buffer[9];
};
#endif
| [
"[email protected]"
]
| [
[
[
1,
80
]
]
]
|
cabbdd2602d945496c28d1ac449e22ee783fb28a | ccc3e2995bc64d09b9e88fea8c1c7e2029a60ed8 | /SO/Trabalhos/Trabalho 2/tmp_src/32142/v3_sem_pistas_fechadas_e_alineas_opcionais/GestorDePistas.cpp | b9969e664f63609e94d906e5022129629d1da4e5 | []
| no_license | masterzdran/semestre5 | e559e93017f5e40c29e9f28466ae1c5822fe336e | 148d65349073f8ae2f510b5659b94ddf47adc2c7 | refs/heads/master | 2021-01-25T10:05:42.513229 | 2011-02-20T17:46:14 | 2011-02-20T17:46:14 | 35,061,115 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,511 | cpp | #include "headers\stdafx.h"
#include "headers\IGestorDePistas.h"
#include <list>
#include "Plane.cpp"
#ifndef GESTORDEPISTAS
#define GESTORDEPISTAS
const int NUMBER_OF_SKIING = 2;
const int SKIING_1 = 0;
const int SKIING_2 = 1;
class GestorDePistas : IGestorDePistas {
private:
//Mutex associado as threads que pretendem descolar
//Semaforo* _Mutex;
HANDLE _Mutex;
//Mutex associado as threads que pretendem libertar a pista
//_closePistas[0] - pista 1, _closePistas[1] - pista 2
bool* _closePistas;
DWORD* thread_pista;
//quando a true existe alerta de furacao
bool _furacao;
std::list<Plane*> landList;
std::list<Plane*> takeoffList;
public:
GestorDePistas(){
//_Mutex = new Semaforo[NUMBER_OF_SKIING];
_Mutex = CreateMutex(NULL, false, NULL);
_closePistas = new bool[NUMBER_OF_SKIING];
_closePistas[0]=false;
_closePistas[1]=false;
_furacao = false;
thread_pista = new DWORD[NUMBER_OF_SKIING];
thread_pista[0] = -1;
thread_pista[1] = -1;
}
~GestorDePistas(){
delete _Mutex;
delete _closePistas;
delete thread_pista;
}
int esperarPistaParaAterrar(Plane* a){
DWORD id = a->GetIDThread();
//entra no while caso nao haja pista livre
while( (_closePistas[0] && _closePistas[1]) ||
(thread_pista[0]!=id && thread_pista[0]!=-1 && thread_pista[1]!=id
&& thread_pista[1]!=-1 && landList.size()>=0)){
WaitForSingleObject(_Mutex, INFINITE);//_Mutex->Wait();
landList.push_back(a);
ReleaseMutex(_Mutex);//_Mutex->Signal();
a->EsperarPista();
}
//ja tem pista reservada!
int p = 0;
WaitForSingleObject(_Mutex, INFINITE);//_Mutex->Wait();
if(thread_pista[0]==id || thread_pista[0]==-1) p=0;
else if(thread_pista[1]==id || thread_pista[1]==-1) p = 1;
//caso pista estivesse vaga, sem reserva
if(thread_pista[p]==-1)thread_pista[p]=a->GetIDThread();
ReleaseMutex(_Mutex);//_Mutex->Signal();
return p;
}
int esperarPistaParaDescolar(Plane* d){
DWORD id = d->GetIDThread();
//entra no while caso nao haja pista livre
while( _furacao || (_closePistas[0] && _closePistas[1]) ||
thread_pista[0]!=id && thread_pista[0]!=-1 && thread_pista[1]!=id
&& thread_pista[1]!=-1 && takeoffList.size()>=0){
WaitForSingleObject(_Mutex, INFINITE);//_Mutex->Wait();
takeoffList.push_back(d);
ReleaseMutex(_Mutex);//_Mutex->Signal();
d->EsperarPista();
}
//ja tem pista reservada!
int p = 0;
WaitForSingleObject(_Mutex, INFINITE);//_Mutex->Wait();
if(thread_pista[0]==id || thread_pista[0]==-1) p=0;
else if(thread_pista[1]==id || thread_pista[1]==-1) p = 1;
//caso pista estivesse vaga, sem reserva
if(thread_pista[p]==-1)thread_pista[p]=d->GetIDThread();
ReleaseMutex(_Mutex);//_Mutex->Signal();
return p;
}
void libertarPista(int idPista){
WaitForSingleObject(_Mutex, INFINITE);//_Mutex->Wait();
if(idPista==0){
if(landList.size()==0){
thread_pista[idPista]=-1;
//se esta vaga entao posso ver se existe algum aviao para descolar
if(!_furacao && takeoffList.size()>0){
ActiveTakeoffPlane(idPista);
}
}
else ActiveLandingPlane(idPista);
}
else{//idPista==1
if(_furacao || takeoffList.size()==0){
thread_pista[idPista]=-1;
//se esta vaga entao posso ver se existe algum aviao para aterrar
if(landList.size()>0)
ActiveLandingPlane(idPista);
}
else{
//reserva pista para o proximo aviao
ActiveTakeoffPlane(idPista);
}
}
ReleaseMutex(_Mutex);//_Mutex->Signal();
}
void fecharPista(int idPista){
_closePistas[idPista] = true;
}
void abrirPista(int idPista){
_closePistas[idPista] = false;
}
void alertaFuracao(bool al){
_furacao = al;
if(_furacao == false && takeoffList.size()>0){
for(int i = 0; i < NUMBER_OF_SKIING; ++i){
if(thread_pista[i]==-1){
WaitForSingleObject(_Mutex, INFINITE);
ActiveTakeoffPlane(i);
ReleaseMutex(_Mutex);
}
}
}
}
private:
bool isAirportClosed(){
return _closePistas[0] == true && _closePistas[1] == true;
}
void ActiveLandingPlane(int idPista){
Plane* next = landList.front();
landList.pop_front();
thread_pista[idPista]=next->GetIDThread();
next->TerPista();
}
void ActiveTakeoffPlane(int idPista){
Plane* next = takeoffList.front();
takeoffList.pop_front();
thread_pista[idPista]=next->GetIDThread();
next->TerPista();
}
};
#endif GESTORDEPISTAS
| [
"[email protected]@b139f23c-5e1e-54d6-eab5-85b03e268133"
]
| [
[
[
1,
162
]
]
]
|
bd6c16cf753225ee7e8bb40ee3f0eae83072d561 | 00b979f12f13ace4e98e75a9528033636dab021d | /doc/doxy_comment_sample.hh | 0d8501d4fd1f4c9b063172163c4dd68b9f5eecec | []
| no_license | BackupTheBerlios/ziahttpd-svn | 812e4278555fdd346b643534d175546bef32afd5 | 8c0b930d3f4a86f0622987776b5220564e89b7c8 | refs/heads/master | 2016-09-09T20:39:16.760554 | 2006-04-13T08:44:28 | 2006-04-13T08:44:28 | 40,819,288 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 736 | hh | class foo
{
int data_;
public:
void display() const;
void access(const char*);
};
//! \file
//! \brief This is a brief description of class.hh
//!
//! Here this is the more
//! detail description, spanning over more than one line.
//! \class foo
//! \brief description of the foo class
//!
//! This class does nothing is a more detailed
//! descritpion.
//! This detailed description spans over more
//! than one line.
//! \fn void foo::display() const
//! \brief display contents of the class
//!
//! detailed description of the display method
//! \fn void foo::access(const char*)
//! \brief access...
//!
//! \param pathname name of the path.
//!
//! This is a detailed description
| [
"texane@754ce95b-6e01-0410-81d0-8774ba66fe44"
]
| [
[
[
1,
37
]
]
]
|
309c0e5ba6c609d2bac5e2bf4391f4fdbe26ed8d | 9eaa698f624abd80019ac7e3c53304950daa66ba | /xmpp/xmppclientextension.h | 1fcbc14179ae39a3ed29a78a4820c9fab59767b4 | []
| no_license | gan7488/happ-talk-jchat | 8f2e3f1437a683ec16d3bc4d0d36e409df088a94 | 182cec6e496401b4ea8f108fb711b05a775232b4 | refs/heads/master | 2021-01-10T11:14:23.607688 | 2011-05-17T17:30:57 | 2011-05-17T17:30:57 | 52,271,940 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 925 | h | /******************************************************************************
** Author: Svirskiy Sergey Nickname: Happ
******************************************************************************/
#ifndef XMPPCLIENTEXTENSION_H
#define XMPPCLIENTEXTENSION_H
#include <QObject>
#include <gloox/client.h>
using namespace gloox;
/**
* @brief Base client extension.
*/
class XMPPClientExtension : public QObject
{
Q_OBJECT
public:
/**
* @brief Desctructor
*/
virtual ~XMPPClientExtension() {}
/**
* @brief Register handlers, and etc.
*/
virtual void attachClient(Client *client) = 0;
/**
* @brief Unregister handlers, and some other functionality.
*/
virtual void detachClient(Client *client) = 0;
protected:
/**
* @brief Constructor
*/
XMPPClientExtension() {}
};
#endif // XMPPCLIENTEXTENSION_H
| [
"[email protected]"
]
| [
[
[
1,
41
]
]
]
|
13f944b6b6836a22e9fd8267419f80805e531a27 | f2b4a9d938244916aa4377d4d15e0e2a6f65a345 | /Game/SpellListView.h | f013887811b55afee6209ea12b05f9089e7b90ae | [
"Apache-2.0"
]
| permissive | notpushkin/palm-heroes | d4523798c813b6d1f872be2c88282161cb9bee0b | 9313ea9a2948526eaed7a4d0c8ed2292a90a4966 | refs/heads/master | 2021-05-31T19:10:39.270939 | 2010-07-25T12:25:00 | 2010-07-25T12:25:00 | 62,046,865 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,894 | h | /*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
#ifndef _HMM_GAME_SPELL_LIST_VIEW_H_
#define _HMM_GAME_SPELL_LIST_VIEW_H_
class iSpellListBox;
class iSpellListView : public iView, public IViewCmdHandler
{
public:
iSpellListView(iViewMgr* pViewMgr, IViewCmdHandler* pCmdHandler, const iRect& rect, uint32 uid, iHero* pOwner, bool bShowFavorites);
void SetOwner(iHero* pOwner);
inline iHero* Owner() { return m_pOwner; }
inline MAGIC_SPELL SelSpell() const { return m_curSel; }
inline bool CanCastSelSpell() const { return m_curSel != MSP_INVALID && m_pOwner->ManaPts() >= iBaseSpell::GetSpellCost(m_curSel, m_pOwner); }
inline void SetMask(uint32 typeMask) { m_typeMask = typeMask; UpdateSpellList(); }
void SelNext();
void SelPrev();
private:
void UpdateSpellList();
void OnCompose();
void iCMDH_ControlCommand(iView* pView, CTRL_CMD_ID cmd, sint32 param);
private:
iSpellListBox* m_pSpellListBox;
iSpellBtn* m_pSpellButton;
iBarTabSwitch* m_pSchoolSwitch;
uint32 m_typeMask;
MAGIC_SPELL m_curSel;
iHero* m_pOwner;
IViewCmdHandler* m_pCmdHandler;
};
#endif //_HMM_GAME_SPELL_LIST_VIEW_H_
| [
"palmheroesteam@2c21ad19-eed7-4c86-9350-8a7669309276"
]
| [
[
[
1,
54
]
]
]
|
fd27f0c82051309dab988fd6f9f66311b95fbebe | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/boost/test/parameterized_test.hpp | 83e04dbbcfc9aa3f9a8bc937a12586d55b43d953 | [
"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 | 8,017 | hpp | // (C) Copyright Gennadiy Rozental 2001-2005.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/test for the library home page.
//
// File : $RCSfile: parameterized_test.hpp,v $
//
// Version : $Revision: 1.7.2.1 $
//
// Description : generators and helper macros for parameterized tests
// ***************************************************************************
#ifndef BOOST_TEST_PARAMETERIZED_TEST_HPP_021102GER
#define BOOST_TEST_PARAMETERIZED_TEST_HPP_021102GER
// Boost.Test
#include <boost/test/unit_test_suite.hpp>
#include <boost/test/utils/callback.hpp>
// Boost
#include <boost/type_traits/remove_reference.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/test/detail/suppress_warnings.hpp>
//____________________________________________________________________________//
#define BOOST_PARAM_TEST_CASE( function, begin, end ) \
boost::unit_test::make_test_case( function, \
BOOST_TEST_STRINGIZE( function ), \
(begin), (end) ) \
/**/
#define BOOST_PARAM_CLASS_TEST_CASE( function, tc_instance, begin, end ) \
boost::unit_test::make_test_case( function, \
BOOST_TEST_STRINGIZE( function ), \
(tc_instance), \
(begin), (end) ) \
/**/
namespace boost {
namespace unit_test {
// ************************************************************************** //
// ************** test_func_with_bound_param ************** //
// ************************************************************************** //
namespace ut_detail {
template<typename ParamType>
struct test_func_with_bound_param {
template<typename T>
test_func_with_bound_param( callback1<ParamType> test_func, T const& param )
: m_test_func( test_func )
, m_param( param )
{}
void operator()() { m_test_func( m_param ); }
private:
callback1<ParamType> m_test_func;
ParamType m_param;
};
// ************************************************************************** //
// ************** param_test_case_generator ************** //
// ************************************************************************** //
template<typename ParamType, typename ParamIter>
class param_test_case_generator : public test_unit_generator {
public:
param_test_case_generator( callback1<ParamType> const& test_func,
const_string tc_name,
ParamIter par_begin,
ParamIter par_end )
: m_test_func( test_func )
, m_tc_name( ut_detail::normalize_test_case_name( tc_name ) )
, m_par_begin( par_begin )
, m_par_end( par_end )
{}
test_unit* next() const
{
if( m_par_begin == m_par_end )
return (test_unit*)0;
test_func_with_bound_param<ParamType> bound_test_func( m_test_func, *m_par_begin );
::boost::unit_test::test_unit* res = new test_case( m_tc_name, bound_test_func );
++m_par_begin;
return res;
}
private:
// Data members
callback1<ParamType> m_test_func;
std::string m_tc_name;
mutable ParamIter m_par_begin;
ParamIter m_par_end;
};
//____________________________________________________________________________//
template<typename UserTestCase,typename ParamType>
struct user_param_tc_method_invoker {
typedef void (UserTestCase::*test_method)( ParamType );
// Constructor
user_param_tc_method_invoker( shared_ptr<UserTestCase> inst, test_method test_method )
: m_inst( inst ), m_test_method( test_method ) {}
void operator()( ParamType p ) { ((*m_inst).*m_test_method)( p ); }
// Data members
shared_ptr<UserTestCase> m_inst;
test_method m_test_method;
};
//____________________________________________________________________________//
} // namespace ut_detail
template<typename ParamType, typename ParamIter>
inline ut_detail::param_test_case_generator<ParamType,ParamIter>
make_test_case( callback1<ParamType> const& test_func,
const_string tc_name,
ParamIter par_begin,
ParamIter par_end )
{
return ut_detail::param_test_case_generator<ParamType,ParamIter>( test_func, tc_name, par_begin, par_end );
}
//____________________________________________________________________________//
template<typename ParamType, typename ParamIter>
inline ut_detail::param_test_case_generator<
BOOST_DEDUCED_TYPENAME remove_const<BOOST_DEDUCED_TYPENAME remove_reference<ParamType>::type>::type,ParamIter>
make_test_case( void (*test_func)( ParamType ),
const_string tc_name,
ParamIter par_begin,
ParamIter par_end )
{
typedef BOOST_DEDUCED_TYPENAME remove_const<BOOST_DEDUCED_TYPENAME remove_reference<ParamType>::type>::type param_value_type;
return ut_detail::param_test_case_generator<param_value_type,ParamIter>( test_func, tc_name, par_begin, par_end );
}
//____________________________________________________________________________//
template<typename UserTestCase,typename ParamType, typename ParamIter>
inline ut_detail::param_test_case_generator<
BOOST_DEDUCED_TYPENAME remove_const<BOOST_DEDUCED_TYPENAME remove_reference<ParamType>::type>::type,ParamIter>
make_test_case( void (UserTestCase::*test_method )( ParamType ),
const_string tc_name,
boost::shared_ptr<UserTestCase> const& user_test_case,
ParamIter par_begin,
ParamIter par_end )
{
typedef BOOST_DEDUCED_TYPENAME remove_const<BOOST_DEDUCED_TYPENAME remove_reference<ParamType>::type>::type param_value_type;
return ut_detail::param_test_case_generator<param_value_type,ParamIter>(
ut_detail::user_param_tc_method_invoker<UserTestCase,ParamType>( user_test_case, test_method ),
tc_name,
par_begin,
par_end );
}
//____________________________________________________________________________//
} // unit_test
} // namespace boost
//____________________________________________________________________________//
#include <boost/test/detail/enable_warnings.hpp>
// ***************************************************************************
// Revision History :
//
// $Log: parameterized_test.hpp,v $
// Revision 1.7.2.1 2006/10/19 09:23:04 johnmaddock
// Fix for VC6.
//
// Revision 1.7 2006/01/28 08:57:02 rogeeff
// VC6.0 workaround removed
//
// Revision 1.6 2006/01/28 07:10:20 rogeeff
// tm->test_method
//
// Revision 1.5 2005/12/14 05:16:49 rogeeff
// dll support introduced
//
// Revision 1.4 2005/05/02 06:00:10 rogeeff
// restore a parameterized user case method based testing
//
// Revision 1.3 2005/03/21 15:32:31 rogeeff
// check reworked
//
// Revision 1.2 2005/02/21 10:25:04 rogeeff
// remove const during ParamType deduction
//
// Revision 1.1 2005/02/20 08:27:06 rogeeff
// This a major update for Boost.Test framework. See release docs for complete list of fixes/updates
//
// ***************************************************************************
#endif // BOOST_TEST_PARAMETERIZED_TEST_HPP_021102GER
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
]
| [
[
[
1,
211
]
]
]
|
4aed2d755fa2214070c2f9fe68ab8e85dc2575b9 | 5efbd0cc4133aabbf0fa25a55e81bd8efe9040fd | /include/sys/sys_singleton.h | 445acc599ccfbfd5aa3fccaaac5fd9e9b5abf166 | []
| no_license | electri/spext | b4041dea8e1b3f7f92fa8dd01b038165836b74cb | 352809d2fba8f5528cdff7195a3ecdcc08be7ba4 | refs/heads/master | 2016-09-02T05:56:10.173821 | 2011-07-18T14:35:58 | 2011-07-18T14:35:58 | 35,587,658 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,292 | h | /** Copyright (c) 2008
* All rights reserved.
*
* 文件名称: sys_singleton.h
* 摘 要: singleton模式
*
* 当前版本: 1.0
* 作 者: 范涛涛
* 操 作: 新建
* 完成日期: 2008年5月6日
*/
#ifndef __SYS_SINGLETON_H__
#define __SYS_SINGLETON_H__
#include "sys_globa_def.h"
namespace xy
{
class copy_disable
{
private:
copy_disable(const copy_disable&);
const copy_disable& operator=(const copy_disable&);
protected:
copy_disable() { ;}
~copy_disable() { ;}
};
template <class T, class MUTEX>
class singleton : private copy_disable
{
private:
struct __destroy
{
__destroy(T** p) : m_p(p)
{
///assert(*p);
}
~__destroy()
{
try
{
if(*m_p)
delete (*m_p);
}
catch (...)
{
}
}
T** m_p;
};
public:
static T*& instance()
{
static T* p = 0;
static mutex_adapter<MUTEX> lock;
if(!p)
{
auto_lock< mutex_adapter<MUTEX> > __mon(lock);
if(!p)
{
p = new T;
static __destroy des(&p);
}
}
return p;
}
static void destroy()
{
T*& p = singleton<T, MUTEX>::instance();
if(p)
{
delete p;
p = NULL;
}
}
};
};
#endif //__SYS_SINGLETON_H__ | [
"[email protected]@01c74763-b75b-5a55-715c-6f18d641bb61"
]
| [
[
[
1,
95
]
]
]
|
62aea36fbabffe040f14a1cd45cb10903f63c6a0 | 12ea67a9bd20cbeed3ed839e036187e3d5437504 | /winxgui/WTLHelper/Options/FunctionOptDlg.cpp | 57a5e2eb31cc55fefd18ad6edaf9c3ed931dd74c | []
| no_license | cnsuhao/winxgui | e0025edec44b9c93e13a6c2884692da3773f9103 | 348bb48994f56bf55e96e040d561ec25642d0e46 | refs/heads/master | 2021-05-28T21:33:54.407837 | 2008-09-13T19:43:38 | 2008-09-13T19:43:38 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,196 | cpp | ////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2004 Sergey Solozhentsev
// Author: Sergey Solozhentsev e-mail: [email protected]
// Product: WTL Helper
// File: FunctionOptDlg.cpp
// Created: 21.12.2004 10:46
//
// Using this software in commercial applications requires an author
// permission. The permission will be granted to everyone excluding the cases
// when someone simply tries to resell the code.
// This file may be redistributed by any means PROVIDING it is not sold for
// profit without the authors written consent, and providing that this notice
// and the authors name is included.
// This file is provided "as is" with no expressed or implied warranty. The
// author accepts no liability if it causes any damage to you or your computer
// whatsoever.
//
////////////////////////////////////////////////////////////////////////////////
// This file was generated by WTL Dialog wizard
// FunctionOptDlg.cpp : Implementation of CFunctionOptDlg
#include "stdafx.h"
#include "FunctionOptDlg.h"
#include "../RegArchive.h"
#include ".\functionoptdlg.h"
extern LPCTSTR RegPath;
extern LPCTSTR FunctionName;
// CFunctionOptDlg
CFunctionOptDlg::CFunctionOptDlg() : m_bNewStyle(TRUE), m_Sort(TRUE),
m_bInline(FALSE), m_bUseAtlMisc(TRUE), m_bAllowDlgIdle(TRUE), m_bCheckMissingEndMap(TRUE)
{
}
CFunctionOptDlg::~CFunctionOptDlg()
{
}
LRESULT CFunctionOptDlg::OnInitDialog(HWND hwndFocus, LPARAM lParam)
{
CRegArchive RegArchive;
if (RegArchive.Open(HKEY_CURRENT_USER, RegPath))
{
LoadSettings(RegArchive, FunctionName);
m_ColorSetup.LoadSettings(RegArchive, FunctionName);
RegArchive.Close();
}
DoDataExchange();
return TRUE;
}
void CFunctionOptDlg::SaveOptions()
{
DoDataExchange(TRUE);
CRegArchive RegArchive;
if (RegArchive.Open(HKEY_CURRENT_USER, RegPath, true))
{
SaveSettings(RegArchive, FunctionName);
m_ColorSetup.SaveSettings(RegArchive, FunctionName);
RegArchive.Close();
}
}
LRESULT CFunctionOptDlg::OnColorsClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
m_ColorSetup.DoModal();
return 0;
} | [
"xushiweizh@86f14454-5125-0410-a45d-e989635d7e98"
]
| [
[
[
1,
71
]
]
]
|
58e203671495b05b8240ba5fa94d521b4f3cacb0 | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/multi_index/test/test_range_main.cpp | 2d3ad24bb99a4f9c2a0160c6279d398c80d02243 | [
"BSL-1.0",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | willrebuild/flyffsf | e5911fb412221e00a20a6867fd00c55afca593c7 | d38cc11790480d617b38bb5fc50729d676aef80d | refs/heads/master | 2021-01-19T20:27:35.200154 | 2011-02-10T12:34:43 | 2011-02-10T12:34:43 | 32,710,780 | 3 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 480 | cpp | /* Boost.MultiIndex test for range().
*
* Copyright 2003-2004 Joaquín M López Muñoz.
* 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/multi_index for library home page.
*/
#include <boost/test/included/test_exec_monitor.hpp>
#include "test_range.hpp"
int test_main(int,char *[])
{
test_range();
return 0;
}
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
]
| [
[
[
1,
18
]
]
]
|
d8f17f75b176428dc80d89237c266ad2be615246 | 009dd29ba75c9ee64ef6d6ba0e2d313f3f709bdd | /Android/MV/jni/h263/coder.cpp | 92e2a7e8fa36d4e9f196757da20d750125713932 | []
| no_license | AnthonyNystrom/MobiVU | c849857784c09c73b9ee11a49f554b70523e8739 | b6b8dab96ae8005e132092dde4792cb363e732a2 | refs/heads/master | 2021-01-10T19:36:50.695911 | 2010-10-25T03:39:25 | 2010-10-25T03:39:25 | 1,015,426 | 3 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 31,501 | cpp | ////////////////////////////////////////////////////////////////////////////
//
//
// Project : VideoNet version 1.1.
// Description : Peer to Peer Video Conferencing over the LAN.
// Author : Nagareshwar Y Talekar ( [email protected])
// Date : 15-6-2004.
//
// I have converted origional fast h.263 encoder library from C to C++
// so that it can be integrated into any windows application easily.
// I have removed some of unnecessary codes/files from the
// fast h263 library.Also moved definitions and declarations
// in their proper .h and .cpp files.
//
// File description :
// Name : coder.cpp
//
//
/////////////////////////////////////////////////////////////////////////////
/*************************************************
* libr263: fast H.263 encoder library
*
* Copyright (C) 1996, Roalt Aalmoes, Twente University
* SPA multimedia group
*
* Based on Telenor TMN 1.6 encoder (Copyright (C) 1995, Telenor R&D)
* created by Karl Lillevold
*
* Author encoder: Roalt Aalmoes, <[email protected]>
*
* Date: 31-07-96
**************************************************/
/* Modyfied by Roalt Aalmoes with better algorithms and performance
* objectives
*
* Warning: Although I tried to remove all advanced options code,
* there might still be some artifacts in the code. Please do not
* blame me for not removing all of it.
* Removing all advanced and alternating quantization code was done
* for performance reasons. I'm sorry these options are not
* implemented here, but see the tmn1.7 code for a slow functioning
* advanced H.263 compression algorithm.
*****************************************************************/
/* Notes for clear code: */
/* var. j is used for row indexing of MB in frame */
/* var. i is used for column indexing of MB in frame */
/* pic is declared global */
/* MV is changed: it is now a real array of MV instead of array of pointers
to MV. Its range is also equal to MVs encoded, without border MVs
Advantages: No more mallocs and frees in the code, disadvantages: ?? */
/* PictImage structure is replaced by int pointer. Drawback: not flexible for
other format. */
#include"coder.h"
#include "countbit.h"
#include "pred.h"
#include "quant.h"
#include "mot_est.h"
#include "dct.h"
/**********************************************************************
*
* Name: Clip
* Description: clips recontructed data 0-255
*
* Input: pointer to recon. data structure
* Side effects: data structure clipped
*
* Date: 960715 Author: Roalt Aalmoes
*
***********************************************************************/
//__inline__ void Clip(MB_Structure *data)
void Clip(MB_Structure *data)
{
int n;
int *mb_ptr = (int *) data;
for (n = 0; n < 256 + 64 + 64; n++) {
*mb_ptr = mmin(255,mmax(0,*mb_ptr));
mb_ptr++;
}
}
/* Encodes one frame intra using params */
void CodeIntraH263(CParam *params, Bits *bits)
{
unsigned int *new_recon;
MB_Structure *data = (MB_Structure *)malloc(sizeof(MB_Structure));
int *qcoeff;
int Mode = MODE_INTRA;
int CBP;
int i,j;
new_recon = params->recon;
ZeroBits(bits);
Global.pic->QUANT = params->Q_intra;
Global.pic->picture_coding_type = PCT_INTRA;
bits->header += CountBitsPicture(Global.pic);
for ( j = 0; j < Global.mbr; j++) {
/* insert sync in *every* slice if use_gobsync is chosen */
if (Global.pic->use_gobsync && j != 0)
bits->header += CountBitsSlice(j,params->Q_intra);
for ( i = 0; i < Global.mbc; i++) {
Global.pic->MB = i + j * Global.mbc;
bits->no_intra++;
FillLumBlock(i*MB_SIZE, j*MB_SIZE, params->data, data);
FillChromBlock(i*MB_SIZE, j*MB_SIZE, params->data, data);
qcoeff = MB_EncodeAndFindCBP(data, params->Q_intra, Mode, &CBP);
/* Do standard VLC encoding */
/* COD = 0 ,Every block is coded as Intra frame */
CountBitsMB(Mode,0,CBP,0,Global.pic,bits);
CountBitsCoeff(qcoeff, Mode, CBP,bits,64);
MB_Decode(qcoeff, data, params->Q_intra, Mode);
Clip(data);
ReconImage(i,j,data,new_recon);
free(qcoeff);
}
}
Global.pic->QP_mean = params->Q_intra;
params->recon = new_recon;
AddBitsPicture(bits);
free(data);
return;
}
/**********************************************************************
*
* Name: MB_Encode
* Description: DCT and quantization of Macroblocks
*
* Input: MB data struct, mquant (1-31, 0 = no quant),
* MB info struct
* Returns: Pointer to quantized coefficients
* Side effects:
*
* Date: 930128 Author: [email protected]
*
**********************************************************************/
/* If you compare original quant with FindCBP, you see they both act
on the same range of coefficients in the cases INTRA (1..63) or
INTER (0..63) */
int *MB_EncodeAndFindCBP(MB_Structure *mb_orig, int QP, int I, int *CBP)
{
int i, j, k, l, row, col;
int fblock[64];
int coeff[384];
int *coeff_ind;
int *qcoeff;
int *qcoeff_ind;
int CBP_Mask = 32;
*CBP = 0; /* CBP gives bit pattern of lowest 6 bits
that specify which coordinates are not
zero. Bits 6 (32) to 2 (4) repr. four
8x8 Y parts of macroblock, while bits
1 (2) and 0 (1) repr. resp. the U and
V component */
if ((qcoeff=(int *)malloc(sizeof(int)*384)) == 0) {
fprintf(stderr,"mb_encode(): Couldn't allocate qcoeff.\n");
exit(0);
}
coeff_ind = coeff;
qcoeff_ind = qcoeff;
for (k=0;k<16;k+=8) {
for (l=0;l<16;l+=8) {
for (i=k,row=0;row<64;i++,row+=8) {
#if LONGISDOUBLEINT
for (j=l,col=0;col<8;j += 2,col +=2 ) {
*(long *) (fblock+row+col) = * (long *) &(mb_orig->lum[i][j]);
}
#else
for (j=l,col=0;col<8;j++ , col++ ) {
*(int *) (fblock+row+col) = * (int *) &(mb_orig->lum[i][j]);
}
#endif
}
Dct(fblock,coeff_ind);
*CBP |= QuantAndFindCBP(coeff_ind,qcoeff_ind,QP,I,CBP_Mask);
coeff_ind += 64;
qcoeff_ind += 64;
CBP_Mask = CBP_Mask>>1;
} /* end l */
} /* End k */
for (i=0;i<8;i++) {
#ifdef LONGISDOUBLEINT
for (j=0;j<8;j += 2) {
*(long *) (fblock+i*8+j) = *(long *) &(mb_orig->Cb[i][j]);
}
#else
for (j=0;j<8;j++) {
*(int *) (fblock+i*8+j) = *(int *) &(mb_orig->Cb[i][j]);
}
#endif
}
Dct(fblock,coeff_ind);
*CBP |= QuantAndFindCBP(coeff_ind,qcoeff_ind,QP,I,CBP_Mask /* i == 4 */);
coeff_ind += 64;
qcoeff_ind += 64;
CBP_Mask = CBP_Mask>>1;
for (i=0;i<8;i++) {
#ifdef LONGISDOUBLEINT
for (j=0;j<8;j += 2) {
* (long *) (fblock+i*8+j) = *(long *) &(mb_orig->Cr[i][j]);
}
#else
for (j=0;j<8;j ++) {
* (int *) (fblock+i*8+j) = *(int *) &(mb_orig->Cr[i][j]);
}
#endif
}
Dct(fblock,coeff_ind);
*CBP |= QuantAndFindCBP(coeff_ind,qcoeff_ind,QP,I, CBP_Mask /* i == 5 */);
return qcoeff;
}
/**********************************************************************
*
* Name: MB_Decode
* Description: Reconstruction of quantized DCT-coded Macroblocks
*
* Input: Quantized coefficients, MB data
* QP (1-31, 0 = no quant), MB info block
* Returns: int (just 0)
* Side effects:
*
* Date: 930128 Author: [email protected]
*
**********************************************************************/
int MB_Decode(int *qcoeff, MB_Structure *mb_recon, int QP, int I)
{
int i, j, k, l, row, col;
int *iblock;
int *qcoeff_ind;
int *rcoeff, *rcoeff_ind;
if ((iblock = (int *)malloc(sizeof(int)*64)) == NULL) {
fprintf(stderr,"MB_Coder: Could not allocate space for iblock\n");
exit(-1);
}
if ((rcoeff = (int *)malloc(sizeof(int)*384)) == NULL) {
fprintf(stderr,"MB_Coder: Could not allocate space for rcoeff\n");
exit(-1);
}
/* For control purposes */
/* Zero data */
for (i = 0; i < 16; i++)
#ifdef LONGISDOUBLEINT
for (j = 0; j < 8; j+=2)
*(long *) &(mb_recon->lum[i][j]) = 0L;
#else
for (j = 0; j < 8; j++)
*(int *) &(mb_recon->lum[i][j]) = 0;
#endif
for (i = 0; i < 8; i++)
#ifdef LONGISDOUBLEINT
for (j = 0; j < 8; j += 2) {
*(long *) &(mb_recon->Cb[i][j]) = 0L;
*(long *) &(mb_recon->Cr[i][j]) = 0L;
}
#else
for (j = 0; j < 8; j ++) {
*(int *) &(mb_recon->Cb[i][j]) = 0;
*(int *) &(mb_recon->Cr[i][j]) = 0;
}
#endif
qcoeff_ind = qcoeff;
rcoeff_ind = rcoeff;
for (k=0;k<16;k+=8) {
for (l=0;l<16;l+=8) {
Dequant(qcoeff_ind,rcoeff_ind,QP,I);
#ifdef STANDARDIDCT
idctref(rcoeff_ind,iblock);
#else
idct(rcoeff_ind,iblock);
#endif
qcoeff_ind += 64;
rcoeff_ind += 64;
for (i=k,row=0;row<64;i++,row+=8) {
#ifdef LONGISDOUBLEINT
for (j=l,col=0;col<8;j += 2,col += 2) {
*(long *) &(mb_recon->lum[i][j]) = * (long *) (iblock+row+col);
}
#else
for (j=l,col=0;col<8; j++, col++) {
*(int *) &(mb_recon->lum[i][j]) = * (int *) (iblock+row+col);
}
#endif
}
}
}
Dequant(qcoeff_ind,rcoeff_ind,QP,I);
#ifdef STANDARDIDCT
idctref(rcoeff_ind,iblock);
#else
idct(rcoeff_ind,iblock);
#endif
qcoeff_ind += 64;
rcoeff_ind += 64;
for (i=0;i<8;i++) {
#ifdef LONGISDOUBLEINT
for (j=0;j<8;j +=2 ) {
*(long *) &(mb_recon->Cb[i][j]) = *(long *) (iblock+i*8+j);
}
#else
for (j=0;j<8;j++ ) {
*(int *) &(mb_recon->Cb[i][j]) = *(int *) (iblock+i*8+j);
}
#endif
}
Dequant(qcoeff_ind,rcoeff_ind,QP,I);
#ifdef STANDARDIDCT
idctref(rcoeff_ind,iblock);
#else
idct(rcoeff_ind,iblock);
#endif
for (i=0;i<8;i++) {
#ifdef LONGISDOUBLEINT
for (j=0;j<8;j += 2) {
*(long *) &(mb_recon->Cr[i][j]) = *(long *) (iblock+i*8+j);
}
#else
for (j=0;j<8;j++) {
*(int *) &(mb_recon->Cr[i][j]) = *(int *) (iblock+i*8+j);
}
#endif
}
free(iblock);
free(rcoeff);
return 0;
}
/**********************************************************************
*
* Name: FillLumBlock
* Description: Fills the luminance of one block of lines*pels
*
* Input: Position, pointer to qcif, array to fill
* Returns:
* Side effects: fills array
*
* Date: 930129 Author: [email protected]
*
***********************************************************************/
void FillLumBlock( int x, int y, unsigned int *image, MB_Structure *data)
{
int n, m;
/* OPTIMIZE HERE */
/* m -> int conversion is done here, so no long optimiz. possible */
for (n = 0; n < MB_SIZE; n++)
for (m = 0; m < MB_SIZE; m++)
data->lum[n][m] =
(int) (*(image + x+m + (y+n)*Global.pels));
return;
}
/**********************************************************************
*
* Name: FillChromBlock
* Description: Fills the chrominance of one block of qcif
*
* Input: Position, pointer to qcif, array to fill
* Returns:
* Side effects: fills array
* 128 subtracted from each
*
* Date: 930129 Author: [email protected]
*
***********************************************************************/
void FillChromBlock(int x_curr, int y_curr, unsigned int *image,
MB_Structure *data)
{
int n;
register int m;
int x, y;
x = x_curr>>1;
y = y_curr>>1;
for (n = 0; n < (MB_SIZE>>1); n++)
for (m = 0; m < (MB_SIZE>>1); m++) {
data->Cr[n][m] =
(int) (*(image + Global.vskip + x+m + (y+n)*Global.cpels));
data->Cb[n][m] =
(int) (*(image + Global.uskip + x+m + (y+n)*Global.cpels));
}
return;
}
/**********************************************************************
*
* Name: ZeroMBlock
* Description: Fills one MB with Zeros
*
* Input: MB_Structure to zero out
* Returns:
* Side effects:
*
* Date: 940829 Author: [email protected]
*
***********************************************************************/
void ZeroMBlock(MB_Structure *data)
{
int n;
register int m;
/* ALPHA optimization */
#ifdef LONGISDOUBLEINT
for (n = 0; n < MB_SIZE; n++)
for (m = 0; m < MB_SIZE; m +=2 )
*(long *) &(data->lum[n][m]) = 0L;
for (n = 0; n < (MB_SIZE>>1); n++)
for (m = 0; m < (MB_SIZE>>1); m +=2 ) {
*(long *) &(data->Cr[n][m]) = 0L;
*(long *) &(data->Cb[n][m]) = 0L;
}
#else
for (n = 0; n < MB_SIZE; n++)
for (m = 0; m < MB_SIZE; m++ )
*(int *) &(data->lum[n][m]) = 0;
for (n = 0; n < (MB_SIZE>>1); n++)
for (m = 0; m < (MB_SIZE>>1); m++ ) {
*(int *) &(data->Cr[n][m]) = 0;
*(int *) &(data->Cb[n][m]) = 0;
}
#endif
return;
}
/**********************************************************************
*
* Name: ReconImage
* Description: Puts together reconstructed image
*
* Input: position of curr block, reconstructed
* macroblock, pointer to recontructed image
* Returns:
* Side effects:
*
* Date: 930123 Author: [email protected]
*
***********************************************************************/
void ReconImage (int i, int j, MB_Structure *data, unsigned int *recon)
{
int n;
int x_curr, y_curr;
int *lum_ptr, *Cb_ptr, *Cr_ptr;
unsigned int *recon_ptr, *recon_Cb_ptr, *recon_Cr_ptr;
x_curr = i * MB_SIZE;
y_curr = j * MB_SIZE;
lum_ptr = &(data->lum[0][0]);
recon_ptr = recon + x_curr + y_curr*Global.pels;
/* Fill in luminance data */
for (n = 0; n < MB_SIZE; n++) {
#ifdef LONGISDOUBLEINT
* (long *) recon_ptr = * (long *) lum_ptr;
recon_ptr += 2; lum_ptr += 2;
* (long *) recon_ptr = * (long *) lum_ptr;
recon_ptr += 2; lum_ptr += 2;
* (long *) recon_ptr = * (long *) lum_ptr;
recon_ptr += 2; lum_ptr += 2;
* (long *) recon_ptr = * (long *) lum_ptr;
recon_ptr += 2; lum_ptr += 2;
* (long *) recon_ptr = * (long *) lum_ptr;
recon_ptr += 2; lum_ptr += 2;
* (long *) recon_ptr = * (long *) lum_ptr;
recon_ptr += 2; lum_ptr += 2;
* (long *) recon_ptr = * (long *) lum_ptr;
recon_ptr += 2; lum_ptr += 2;
* (long *) recon_ptr = * (long *) lum_ptr;
recon_ptr += Global.pels - 14; lum_ptr += 2;
/* Was: for every m = 0..15 :
*(recon->lum + x_curr+m + (y_curr+n)*Global.pels) = *(lum_ptr++);
*/
#else
* (int *) recon_ptr = * (int *) lum_ptr;
recon_ptr++; lum_ptr++;
* (int *) recon_ptr = * (int *) lum_ptr;
recon_ptr++; lum_ptr++;
* (int *) recon_ptr = * (int *) lum_ptr;
recon_ptr++; lum_ptr++;
* (int *) recon_ptr = * (int *) lum_ptr;
recon_ptr++; lum_ptr++;
* (int *) recon_ptr = * (int *) lum_ptr;
recon_ptr++; lum_ptr++;
* (int *) recon_ptr = * (int *) lum_ptr;
recon_ptr++; lum_ptr++;
* (int *) recon_ptr = * (int *) lum_ptr;
recon_ptr++; lum_ptr++;
* (int *) recon_ptr = * (int *) lum_ptr;
recon_ptr++; lum_ptr++;
* (int *) recon_ptr = * (int *) lum_ptr;
recon_ptr++; lum_ptr++;
* (int *) recon_ptr = * (int *) lum_ptr;
recon_ptr++; lum_ptr++;
* (int *) recon_ptr = * (int *) lum_ptr;
recon_ptr++; lum_ptr++;
* (int *) recon_ptr = * (int *) lum_ptr;
recon_ptr++; lum_ptr++;
* (int *) recon_ptr = * (int *) lum_ptr;
recon_ptr++; lum_ptr++;
* (int *) recon_ptr = * (int *) lum_ptr;
recon_ptr++; lum_ptr++;
* (int *) recon_ptr = * (int *) lum_ptr;
recon_ptr++; lum_ptr++;
* (int *) recon_ptr = * (int *) lum_ptr;
recon_ptr += Global.pels - 15; lum_ptr++;
#endif
}
recon_Cb_ptr = recon+Global.uskip+ (x_curr>>1) + (y_curr>>1)*Global.cpels;
recon_Cr_ptr = recon+Global.vskip+ (x_curr>>1) + (y_curr>>1)*Global.cpels;
Cb_ptr = &(data->Cb[0][0]);
Cr_ptr = &(data->Cr[0][0]);
/* Fill in chrominance data */
for (n = 0; n < MB_SIZE>>1; n++) {
#ifdef LONGISDOUBLEINT
* (long *) recon_Cb_ptr = * (long *) Cb_ptr;
recon_Cb_ptr += 2; Cb_ptr += 2;
* (long *) recon_Cr_ptr = * (long *) Cr_ptr;
recon_Cr_ptr += 2; Cr_ptr += 2;
* (long *) recon_Cb_ptr = * (long *) Cb_ptr;
recon_Cb_ptr += 2; Cb_ptr += 2;
* (long *) recon_Cr_ptr = * (long *) Cr_ptr;
recon_Cr_ptr += 2; Cr_ptr += 2;
* (long *) recon_Cb_ptr = * (long *) Cb_ptr;
recon_Cb_ptr += 2; Cb_ptr += 2;
* (long *) recon_Cr_ptr = * (long *) Cr_ptr;
recon_Cr_ptr += 2; Cr_ptr += 2;
* (long *) recon_Cb_ptr = * (long *) Cb_ptr;
recon_Cb_ptr += Global.cpels - 6; Cb_ptr += 2;
* (long *) recon_Cr_ptr = * (long *) Cr_ptr;
recon_Cr_ptr += Global.cpels - 6; Cr_ptr += 2;
#else
* (int *) recon_Cb_ptr = * (int *) Cb_ptr;
recon_Cb_ptr++; Cb_ptr++;
* (int *) recon_Cr_ptr = * (int *) Cr_ptr;
recon_Cr_ptr++; Cr_ptr++;
* (int *) recon_Cb_ptr = * (int *) Cb_ptr;
recon_Cb_ptr++; Cb_ptr++;
* (int *) recon_Cr_ptr = * (int *) Cr_ptr;
recon_Cr_ptr++; Cr_ptr++;
* (int *) recon_Cb_ptr = * (int *) Cb_ptr;
recon_Cb_ptr++; Cb_ptr++;
* (int *) recon_Cr_ptr = * (int *) Cr_ptr;
recon_Cr_ptr++; Cr_ptr++;
* (int *) recon_Cb_ptr = * (int *) Cb_ptr;
recon_Cb_ptr++; Cb_ptr++;
* (int *) recon_Cr_ptr = * (int *) Cr_ptr;
recon_Cr_ptr++; Cr_ptr++;
* (int *) recon_Cb_ptr = * (int *) Cb_ptr;
recon_Cb_ptr++; Cb_ptr++;
* (int *) recon_Cr_ptr = * (int *) Cr_ptr;
recon_Cr_ptr++; Cr_ptr++;
* (int *) recon_Cb_ptr = * (int *) Cb_ptr;
recon_Cb_ptr++; Cb_ptr++;
* (int *) recon_Cr_ptr = * (int *) Cr_ptr;
recon_Cr_ptr++; Cr_ptr++;
* (int *) recon_Cb_ptr = * (int *) Cb_ptr;
recon_Cb_ptr++; Cb_ptr++;
* (int *) recon_Cr_ptr = * (int *) Cr_ptr;
recon_Cr_ptr++; Cr_ptr++;
* (int *) recon_Cb_ptr = * (int *) Cb_ptr;
* (int *) recon_Cr_ptr = * (int *) Cr_ptr;
recon_Cb_ptr += Global.cpels - 7; Cb_ptr ++;
recon_Cr_ptr += Global.cpels - 7; Cr_ptr ++;
#endif
}
/* WAS:
for (m = 0; m < MB_SIZE>>1; m++) {
*(recon->Cr + (x_curr>>1)+m + ((y_curr>>1)+n)*Global.cpels) = data->Cr[n][m];
*(recon->Cb + (x_curr>>1)+m + ((y_curr>>1)+n)*Global.cpels) = data->Cb[n][m];
}
*/
return;
}
/**********************************************************************
*
* Name: ReconCopyImage
* Description: Copies previous recon_image to current recon image
*
* Input: position of curr block, reconstructed
* macroblock, pointer to recontructed image
* Returns:
* Side effects:
*
* Date: 960423 Author: Roalt Aalmoes
*
***********************************************************************/
void ReconCopyImage (int i, int j, unsigned int *recon, unsigned int *prev_recon)
{
int n;
int x_curr, y_curr;
unsigned int *lum_now, *lum_prev, *cb_now, *cr_now, *cb_prev, *cr_prev;
x_curr = i * MB_SIZE;
y_curr = j * MB_SIZE;
lum_now = recon + x_curr + y_curr*Global.pels;
lum_prev = prev_recon + x_curr + y_curr*Global.pels;
/* Fill in luminance data */
for (n = 0; n < 16; n++) {
#ifdef LONGISDOUBLEINT
*(long *)(lum_now) = *(long *)(lum_prev);
*(long *)(lum_now + 2) = *(long *)(lum_prev + 2);
*(long *)(lum_now + 4) = *(long *)(lum_prev + 4);
*(long *)(lum_now + 6) = *(long *)(lum_prev + 6);
*(long *)(lum_now + 8) = *(long *)(lum_prev + 8);
*(long *)(lum_now + 10) = *(long *)(lum_prev + 10);
*(long *)(lum_now + 12) = *(long *)(lum_prev + 12);
*(long *)(lum_now + 14) = *(long *)(lum_prev + 14);
#else
*(int *)(lum_now) = *(int *)(lum_prev);
*(int *)(lum_now + 1) = *(int *)(lum_prev + 1);
*(int *)(lum_now + 2) = *(int *)(lum_prev + 2);
*(int *)(lum_now + 3) = *(int *)(lum_prev + 3);
*(int *)(lum_now + 4) = *(int *)(lum_prev + 4);
*(int *)(lum_now + 5) = *(int *)(lum_prev + 5);
*(int *)(lum_now + 6) = *(int *)(lum_prev + 6);
*(int *)(lum_now + 7) = *(int *)(lum_prev + 7);
*(int *)(lum_now + 8) = *(int *)(lum_prev + 8);
*(int *)(lum_now + 9) = *(int *)(lum_prev + 9);
*(int *)(lum_now + 10) = *(int *)(lum_prev + 10);
*(int *)(lum_now + 11) = *(int *)(lum_prev + 11);
*(int *)(lum_now + 12) = *(int *)(lum_prev + 12);
*(int *)(lum_now + 13) = *(int *)(lum_prev + 13);
*(int *)(lum_now + 14) = *(int *)(lum_prev + 14);
*(int *)(lum_now + 15) = *(int *)(lum_prev + 15);
#endif
lum_now += Global.pels;
lum_prev += Global.pels;
}
cb_now = recon+Global.uskip + (x_curr>>1) + (y_curr>>1)*Global.cpels;
cr_now = recon+Global.vskip + (x_curr>>1) + (y_curr>>1)*Global.cpels;
cb_prev = prev_recon+Global.uskip+ (x_curr>>1) + (y_curr>>1)*Global.cpels;
cr_prev = prev_recon+Global.vskip + (x_curr>>1) + (y_curr>>1)*Global.cpels;
/* Fill in chrominance data */
for (n = 0; n < (MB_SIZE>>1); n++) {
#ifdef LONGISDOUBLEINT
*(long *)(cb_now) = *(long *)(cb_prev);
*(long *)(cb_now + 2) = *(long *)(cb_prev + 2);
*(long *)(cb_now + 4) = *(long *)(cb_prev + 4);
*(long *)(cb_now + 6) = *(long *)(cb_prev + 6);
cb_now += Global.cpels;
cb_prev += Global.cpels;
*(long *)(cr_now) = *(long *)(cr_prev);
*(long *)(cr_now + 2) = *(long *)(cr_prev + 2);
*(long *)(cr_now + 4) = *(long *)(cr_prev + 4);
*(long *)(cr_now + 6) = *(long *)(cr_prev + 6);
cr_now += Global.cpels;
cr_prev += Global.cpels;
#else
*(int *)(cb_now) = *(int *)(cb_prev);
*(int *)(cb_now + 1) = *(int *)(cb_prev + 1);
*(int *)(cb_now + 2) = *(int *)(cb_prev + 2);
*(int *)(cb_now + 3) = *(int *)(cb_prev + 3);
*(int *)(cb_now + 4) = *(int *)(cb_prev + 4);
*(int *)(cb_now + 5) = *(int *)(cb_prev + 5);
*(int *)(cb_now + 6) = *(int *)(cb_prev + 6);
*(int *)(cb_now + 7) = *(int *)(cb_prev + 7);
cb_now += Global.cpels;
cb_prev += Global.cpels;
*(int *)(cr_now) = *(int *)(cr_prev);
*(int *)(cr_now + 1) = *(int *)(cr_prev + 1);
*(int *)(cr_now + 2) = *(int *)(cr_prev + 2);
*(int *)(cr_now + 3) = *(int *)(cr_prev + 3);
*(int *)(cr_now + 4) = *(int *)(cr_prev + 4);
*(int *)(cr_now + 5) = *(int *)(cr_prev + 5);
*(int *)(cr_now + 6) = *(int *)(cr_prev + 6);
*(int *)(cr_now + 7) = *(int *)(cr_prev + 7);
cr_now += Global.cpels;
cr_prev += Global.cpels;
#endif
}
return;
}
/**********************************************************************
*
* Name: InterpolateImage
* Description: Interpolates a complete image for easier half
* pel prediction
*
* Input: pointer to image structure
* Returns: pointer to interpolated image
* Side effects: allocates memory to interpolated image
*
* Date: 950207 Author: [email protected]
* 960207 Author: Roalt aalmoes
***********************************************************************/
void InterpolateImage(unsigned int *image, unsigned int *ipol_image,
int width, int height)
{
/* If anyone has better ideas to optimize this code, be my guest!
note: assembly or some advanced bitshifts routine might do the trick...*/
register unsigned int *ii, *oo,
*ii_new,
*ii_new_line2,
*oo_prev,
*oo_prev_line2;
register int i,j;
register unsigned int pix1,pix2,pix3,pix4;
ii = ipol_image;
oo = image;
oo_prev = image;
oo_prev_line2 = image + width;
ii_new = ipol_image;
ii_new_line2 = ipol_image + (width<<1);
/* main image */
for (j = 0; j < height-1; j++) {
/* get Pix1 and Pix3, because they are
not known the first time */
pix1 = *oo_prev;
pix3 = *oo_prev_line2;
for (i = 0; i < width-1; i++) {
/* Pix1 Pix2
Pix3 Pix4 */
/* Pix2 and Pix4 are used here for first time */
pix2 = *(oo_prev + 1);
pix4 = *(oo_prev_line2 + 1);
*(ii_new) = pix1; /* X.
..*/
*(ii_new + 1) = (pix1 + pix2 + 1)>>1; /* *X
.. */
*ii_new_line2 = (pix1 + pix3 + 1)>>1; /* *.
X. */
*(ii_new_line2 + 1) = (pix1 + pix2 + pix3 + pix4 + 2)>>2;
oo_prev++; oo_prev_line2++; ii_new += 2; ii_new_line2 += 2;
pix1 = pix2;
pix3 = pix4; /* Pix1 Pix2=Pix1' Pix2' */
/* Pix3 Pix4=Pix3' Pix4' */
}
/* One but last column */
*(ii_new++) = pix1;
*(ii_new++) = pix3;
/* Last column -On the Edge - */
*(ii_new_line2++) = (pix1 + pix3 + 1 ) >>1;
*(ii_new_line2++) = (pix1 + pix3 + 1 ) >>1;
ii_new += (width<<1); /* ii_new now on old position ii_new_line2,so
one interpolated screen line must be added*/
ii_new_line2 += (width<<1); /* In fact, ii_new_line here has same value
as ii_new */
oo_prev += 1; /* Remember, loop is done one time less! */
oo_prev_line2 += 1;
}
/* last lines */
pix1 = *oo_prev;
for (i = 0; i < width-1; i++) {
pix2 = *(oo_prev + 1);
*ii_new = *ii_new_line2 = pix1;
*(ii_new + 1) = *(ii_new_line2 + 1) = (pix1 + pix2 + 1)>>1;
ii_new += 2;
ii_new_line2 += 2;
oo_prev += 1;
pix1 = pix2; /* Pix1 Pix2=Pix1' Pix2' */
}
/* bottom right corner Global.pels */
*(ii_new) = pix1;
*(ii_new + 1) = pix1;
*(ii_new_line2) = pix1;
*(ii_new_line2+1) = pix1;
return;
}
/**********************************************************************
*
* Name: FullMotionEstimatePicture
* Description: Finds integer and half pel motion estimation
*
* Input: current image, previous image, interpolated
* reconstructed previous image, seek_dist,
* motion vector array
* Returns:
* Side effects: allocates memory for MV structure
*
* Date: 960418 Author: Roatlt
*
***********************************************************************/
void FullMotionEstimatePicture(unsigned int *curr, unsigned int *prev,
unsigned int *prev_ipol, int seek_dist,
MotionVector *MV_ptr,
int advanced_method,
int *EncodeThisBlock)
{
int i,j;
MotionVector *current_MV;
for(j = 0; j < Global.mbr; j++) {
for(i = 0; i < Global.mbc; i++) {
current_MV = MV_ptr + j*Global.mbc + i;
if(advanced_method && !*(EncodeThisBlock + j*Global.mbc + i) ) {
current_MV->x = current_MV->y = current_MV->x_half =
current_MV->y_half = 0;
current_MV->Mode = MODE_SKIP;
} else { /* EncodeThisBlock */
FullMotionEstimation(curr, prev_ipol, seek_dist, current_MV,
i*MB_SIZE, j*MB_SIZE);
current_MV->Mode = ChooseMode(curr,i*MB_SIZE,j*MB_SIZE,
current_MV->min_error);
if(current_MV->Mode == MODE_INTRA)
ZeroVec(current_MV);
}
}
}
}
void CodeInterH263(CParam *params, Bits *bits)
{
MotionVector *MV;
MotionVector ZERO = {0,0,0,0,0};
MB_Structure *recon_data_P;
MB_Structure *diff;
int *qcoeff_P;
unsigned int *new_recon=NULL;
unsigned int *prev_recon;
int Mode;
int CBP, CBPB=0;
int newgob;
int i,j;
Global.search_p_frames = params->search_method;
MV =(struct motionvector*) malloc(sizeof(MotionVector)*Global.mbc*Global.mbr);
new_recon =(unsigned int*) malloc(Global.sizeof_frame);
prev_recon = params->recon;
/* buffer control vars */
ZeroBits(bits);
/* Interpolate luminance from reconstr. picture */
InterpolateImage(prev_recon,params->interpolated_lum,Global.pels,Global.lines);
FullMotionEstimatePicture( params->data,
prev_recon,
params->interpolated_lum,
params->half_pixel_searchwindow,MV,
params->advanced_method, params->EncodeThisBlock);
/* Calculate MV for each MB */
/* ENCODE TO H.263 STREAM */
for ( j = 0; j < Global.mbr; j++) {
newgob = 0;
if (j == 0) {
Global.pic->QUANT = params->Q_inter;
Global.pic->picture_coding_type = PCT_INTER;
bits->header += CountBitsPicture(Global.pic);
}
else if (Global.pic->use_gobsync && j%Global.pic->use_gobsync == 0) {
bits->header += CountBitsSlice(j,params->Q_inter); /* insert gob sync */
newgob = 1;
}
for ( i = 0; i < Global.mbc; i++) {
/* This means: For every macroblock (i,j) do ... */
/* We have 4 different situations:
1) !EncodeThisBlock: this means that the
macroblock in not encoded
2) EncodeThisBlock: This means that the MB is
encoded by using the predicted motion vector.
3) EncodeThisBlock: However, the approx of the
motion vector was so bad, that INTRA coding is more
appropiate here ...
4) EncodeThisBlock: The approx is so good that
the coefficients are all zero (after quant.) and are not
send.
*/
/* This means: For every macroblock (i,j) do ... */
Global.pic->DQUANT = 0;
Mode = MV[j*Global.mbc + i].Mode;
/* Determine position of MB */
Global.pic->MB = i + j * Global.mbc;
if(Mode == MODE_SKIP) {
/* SITUATION 1 */
Mode = MODE_INTRA; /* This might be done "better" in the future*/
MV[j*Global.mbc + i].Mode = Mode;
ZeroVec(&(MV[j*Global.mbc + i]));
CBP = CBPB = 0;
/* Now send code for "skip this MB" */
CountBitsMB(Mode,1,CBP,CBPB,Global.pic,bits);
ReconCopyImage(i,j,new_recon,prev_recon);
} else { /* Encode this block */
if (Mode == MODE_INTER) {
/* SITUATION 2 */
/* Predict P-MB */
diff = Predict_P(params->data,
prev_recon,
params->interpolated_lum,i*MB_SIZE,
j*MB_SIZE,MV);
} else {
/* SITUATION 3 */
/* Create MB_Structure diff that contains coefficients that must be
sent to the other end */
diff = (MB_Structure *)malloc(sizeof(MB_Structure));
FillLumBlock(i*MB_SIZE, j*MB_SIZE, params->data, diff);
/* Copy curr->lum to diff for macroblock (i,j) */
FillChromBlock(i*MB_SIZE, j*MB_SIZE, params->data, diff);
/* Equiv. for curr->Cb and curr->Cr */
}
/* P or INTRA Macroblock */
/* diff -> DCT -> QUANTIZED -> qcoeff_P */
qcoeff_P = MB_EncodeAndFindCBP(diff, params->Q_inter, Mode,&CBP);
/* CBP = FindCBP(qcoeff_P, Mode, 64); -> Not required anymore */
/* All encoded, now calculate decoded image
for comparison in next frame */
/* Do DECODING */
if (CBP == 0 && (Mode == MODE_INTER) ) {
/* SITUATION 4 */
ZeroMBlock(diff);
} else {
/* qcoeff_P -> Dequantized -> IDCT -> diff */
MB_Decode(qcoeff_P, diff, params->Q_inter, Mode);
}
recon_data_P = MB_Recon_P(prev_recon,
params->interpolated_lum,diff,
i*MB_SIZE,j*MB_SIZE,MV);
Clip(recon_data_P);
free(diff);
/* Do bitstream encoding */
if((CBP==0) && (EqualVec(&(MV[j*Global.mbc+i]),&ZERO)) &&
(Mode == MODE_INTER) ) {
/* Skipped MB : both CBP and CBPB are zero, 16x16 vector is zero,
PB delta vector is zero and Mode = MODE_INTER */
/* Now send code for "skip this MB" */
CountBitsMB(Mode,1,CBP,CBPB,Global.pic,bits);
} else {
/* Normal MB */
/* VLC */
CountBitsMB(Mode,0,CBP,CBPB,Global.pic,bits);
if (Mode == MODE_INTER) {
bits->no_inter++;
CountBitsVectors(MV, bits, i, j, Mode, newgob, Global.pic);
} else {
/* MODE_INTRA */
bits->no_intra++;
}
/* Only encode coefficient if they are nonzero or Mode is INTRA*/
if (CBP || Mode == MODE_INTRA)
CountBitsCoeff(qcoeff_P, Mode, CBP, bits, 64);
} /* End skip/not skip macroblock encoding */
ReconImage(i,j,recon_data_P,new_recon);
free(recon_data_P);
free(qcoeff_P);
} /* End advanced */
} /* End for i */
} /* End for j */
Global.pic->QP_mean = params->Q_inter;
free(prev_recon);
params->recon = new_recon;
AddBitsPicture(bits);
free(MV);
return;
}
| [
"[email protected]"
]
| [
[
[
1,
1110
]
]
]
|
29c48374e2fbc04ad88fb6a5ae4cff93862d0bb4 | 3e69b159d352a57a48bc483cb8ca802b49679d65 | /tags/release-2006-04-24/pcbnew/essai.h | 38285350e9997b2dc5fc62ff11fc564db8dd61d2 | []
| no_license | BackupTheBerlios/kicad-svn | 4b79bc0af39d6e5cb0f07556eb781a83e8a464b9 | 4c97bbde4b1b12ec5616a57c17298c77a9790398 | refs/heads/master | 2021-01-01T19:38:40.000652 | 2006-06-19T20:01:24 | 2006-06-19T20:01:24 | 40,799,911 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,566 | h | /////////////////////////////////////////////////////////////////////////////
// Name: essai.h
// Purpose:
// Author: jean-pierre Charras
// Modified by:
// Created: 28/02/2006 07:46:42
// RCS-ID:
// Copyright: License GNU
// Licence:
/////////////////////////////////////////////////////////////////////////////
// Generated by DialogBlocks (unregistered), 28/02/2006 07:46:42
#ifndef _ESSAI_H_
#define _ESSAI_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "essai.h"
#endif
/*!
* Includes
*/
////@begin includes
////@end includes
/*!
* Forward declarations
*/
////@begin forward declarations
class wxFlexGridSizer;
////@end forward declarations
/*!
* Control identifiers
*/
////@begin control identifiers
#define ID_DIALOG 10000
#define SYMBOL_ESSAI_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX
#define SYMBOL_ESSAI_TITLE _("essai")
#define SYMBOL_ESSAI_IDNAME ID_DIALOG
#define SYMBOL_ESSAI_SIZE wxSize(400, 300)
#define SYMBOL_ESSAI_POSITION wxDefaultPosition
#define ID_TEXTCTRL 10001
////@end control identifiers
/*!
* Compatibility
*/
#ifndef wxCLOSE_BOX
#define wxCLOSE_BOX 0x1000
#endif
/*!
* essai class declaration
*/
class essai: public wxDialog
{
DECLARE_DYNAMIC_CLASS( essai )
DECLARE_EVENT_TABLE()
public:
/// Constructors
essai( );
essai( wxWindow* parent, wxWindowID id = SYMBOL_ESSAI_IDNAME, const wxString& caption = SYMBOL_ESSAI_TITLE, const wxPoint& pos = SYMBOL_ESSAI_POSITION, const wxSize& size = SYMBOL_ESSAI_SIZE, long style = SYMBOL_ESSAI_STYLE );
/// Creation
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_ESSAI_IDNAME, const wxString& caption = SYMBOL_ESSAI_TITLE, const wxPoint& pos = SYMBOL_ESSAI_POSITION, const wxSize& size = SYMBOL_ESSAI_SIZE, long style = SYMBOL_ESSAI_STYLE );
/// Creates the controls and sizers
void CreateControls();
////@begin essai event handler declarations
////@end essai event handler declarations
////@begin essai member function declarations
/// Retrieves bitmap resources
wxBitmap GetBitmapResource( const wxString& name );
/// Retrieves icon resources
wxIcon GetIconResource( const wxString& name );
////@end essai member function declarations
/// Should we show tooltips?
static bool ShowToolTips();
////@begin essai member variables
wxFlexGridSizer* GridSizer;
////@end essai member variables
};
#endif
// _ESSAI_H_
| [
"fcoiffie@244deca0-f506-0410-ab94-f4f3571dea26"
]
| [
[
[
1,
100
]
]
]
|
da170175e971e22dcd025240f8e13f597b9ad1b0 | daa67e21cc615348ba166d31eb25ced40fba9dc7 | /GameCode/Mesh.cpp | bc1eddefb36d3cb1309436708f60f5a8da56605a | []
| no_license | gearsin/geartesttroject | 443d48b7211f706ab2c5104204bad7228458c3f2 | f86f255f5e9d1d34a00a4095f601a8235e39aa5a | refs/heads/master | 2020-05-19T14:27:35.821340 | 2008-09-02T19:51:16 | 2008-09-02T19:51:16 | 32,342,555 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,000 | cpp | //------------------------------------------------------------------------------------------------------------------
#include "StdAfx.h"
#include "Renderer.h"
#include "Mesh.h"
//------------------------------------------------------------------------------------------------------------------
cMesh::cMesh( const WCHAR * pFileName ) :
CDXUTXFileMesh( pFileName )
{
HRESULT hr;
WCHAR filePath[1024];
hr = DXUTFindDXSDKMediaFileCch( filePath, MAX_PATH, pFileName );
Assert( hr == S_OK, " File not found\n" );
hr = Create( g_Renderer->GetRendererDevice() , filePath );
Assert( hr == S_OK, "Can't load mesh file\n" );
}
//------------------------------------------------------------------------------------------------------------------
cMesh::~cMesh()
{
}
//------------------------------------------------------------------------------------------------------------------
void cMesh::Render()
{
CDXUTXFileMesh::Render( g_Renderer->GetRendererDevice() );
} | [
"sunil.ssingh@592c7993-d951-0410-8115-35849596357c"
]
| [
[
[
1,
31
]
]
]
|
ea7d98520581e25127b40abf24394f53661d6a68 | 9fb229975cc6bd01eb38c3e96849d0c36985fa1e | /src/Lib3D2/IMath.cpp | 4ea1b5e7a56840705157ad137fbb9944ce888f09 | []
| no_license | Danewalker/ahr | 3758bf3219f407ed813c2bbed5d1d86291b9237d | 2af9fd5a866c98ef1f95f4d1c3d9b192fee785a6 | refs/heads/master | 2016-09-13T08:03:43.040624 | 2010-07-21T15:44:41 | 2010-07-21T15:44:41 | 56,323,321 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 24,267 | cpp | // integer math class
// note: sinus/cosinus/atan table are not stored in const array to be available everywhere with
// symbian. (cannot be defined a global array), so must be rebuild if array size changed
#include "HG/HighGear.h"
#include "imath.h"
#include <stdlib.h>
#ifndef NGI
#include <math.h>
#endif // NGI
#include "config.h"
#include "constants.h"
#include "devutil.h"
#include "fsqrt.h"
#include "vector.h"
// sinus table, used for cosinus too with cos(x) = sin(x + pi/4)
const int Lib3D::TSIN[ANGLE2PI] =
{
0, 50, 101, 151, 201, 251, 302, 352, 402, 452, 503, 553, 603, 653, 704, 754,
804, 854, 904, 955, 1005, 1055, 1105, 1155, 1205, 1255, 1306, 1356, 1406, 1456, 1506, 1556,
1606, 1656, 1706, 1756, 1806, 1856, 1906, 1956, 2006, 2055, 2105, 2155, 2205, 2255, 2305, 2354,
2404, 2454, 2503, 2553, 2603, 2652, 2702, 2752, 2801, 2851, 2900, 2949, 2999, 3048, 3098, 3147,
3196, 3246, 3295, 3344, 3393, 3442, 3492, 3541, 3590, 3639, 3688, 3737, 3786, 3835, 3883, 3932,
3981, 4030, 4078, 4127, 4176, 4224, 4273, 4321, 4370, 4418, 4467, 4515, 4563, 4612, 4660, 4708,
4756, 4804, 4852, 4900, 4948, 4996, 5044, 5092, 5139, 5187, 5235, 5282, 5330, 5377, 5425, 5472,
5520, 5567, 5614, 5661, 5708, 5756, 5803, 5850, 5897, 5943, 5990, 6037, 6084, 6130, 6177, 6223,
6270, 6316, 6363, 6409, 6455, 6501, 6547, 6593, 6639, 6685, 6731, 6777, 6823, 6868, 6914, 6960,
7005, 7050, 7096, 7141, 7186, 7231, 7276, 7321, 7366, 7411, 7456, 7501, 7545, 7590, 7635, 7679,
7723, 7768, 7812, 7856, 7900, 7944, 7988, 8032, 8076, 8119, 8163, 8207, 8250, 8293, 8337, 8380,
8423, 8466, 8509, 8552, 8595, 8638, 8680, 8723, 8765, 8808, 8850, 8892, 8935, 8977, 9019, 9061,
9102, 9144, 9186, 9227, 9269, 9310, 9352, 9393, 9434, 9475, 9516, 9557, 9598, 9638, 9679, 9720,
9760, 9800, 9841, 9881, 9921, 9961, 10001, 10040, 10080, 10120, 10159, 10198, 10238, 10277, 10316, 10355,
10394, 10433, 10471, 10510, 10549, 10587, 10625, 10663, 10702, 10740, 10778, 10815, 10853, 10891, 10928, 10966,
11003, 11040, 11077, 11114, 11151, 11188, 11224, 11261, 11297, 11334, 11370, 11406, 11442, 11478, 11514, 11550,
11585, 11621, 11656, 11691, 11727, 11762, 11797, 11831, 11866, 11901, 11935, 11970, 12004, 12038, 12072, 12106,
12140, 12173, 12207, 12240, 12274, 12307, 12340, 12373, 12406, 12439, 12472, 12504, 12537, 12569, 12601, 12633,
12665, 12697, 12729, 12760, 12792, 12823, 12854, 12885, 12916, 12947, 12978, 13008, 13039, 13069, 13100, 13130,
13160, 13190, 13219, 13249, 13279, 13308, 13337, 13366, 13395, 13424, 13453, 13482, 13510, 13538, 13567, 13595,
13623, 13651, 13678, 13706, 13733, 13761, 13788, 13815, 13842, 13869, 13896, 13922, 13949, 13975, 14001, 14027,
14053, 14079, 14104, 14130, 14155, 14181, 14206, 14231, 14256, 14280, 14305, 14329, 14354, 14378, 14402, 14426,
14449, 14473, 14497, 14520, 14543, 14566, 14589, 14612, 14635, 14657, 14680, 14702, 14724, 14746, 14768, 14789,
14811, 14832, 14854, 14875, 14896, 14917, 14937, 14958, 14978, 14999, 15019, 15039, 15059, 15078, 15098, 15118,
15137, 15156, 15175, 15194, 15213, 15231, 15250, 15268, 15286, 15304, 15322, 15340, 15357, 15375, 15392, 15409,
15426, 15443, 15460, 15476, 15493, 15509, 15525, 15541, 15557, 15573, 15588, 15604, 15619, 15634, 15649, 15664,
15679, 15693, 15707, 15722, 15736, 15750, 15763, 15777, 15791, 15804, 15817, 15830, 15843, 15856, 15868, 15881,
15893, 15905, 15917, 15929, 15941, 15952, 15964, 15975, 15986, 15997, 16008, 16018, 16029, 16039, 16049, 16059,
16069, 16079, 16088, 16098, 16107, 16116, 16125, 16134, 16143, 16151, 16160, 16168, 16176, 16184, 16192, 16199,
16207, 16214, 16221, 16228, 16235, 16242, 16248, 16255, 16261, 16267, 16273, 16279, 16284, 16290, 16295, 16300,
16305, 16310, 16315, 16319, 16324, 16328, 16332, 16336, 16340, 16343, 16347, 16350, 16353, 16356, 16359, 16362,
16364, 16367, 16369, 16371, 16373, 16375, 16376, 16378, 16379, 16380, 16381, 16382, 16383, 16383, 16384, 16384,
16384, 16384, 16384, 16383, 16383, 16382, 16381, 16380, 16379, 16378, 16376, 16375, 16373, 16371, 16369, 16367,
16364, 16362, 16359, 16356, 16353, 16350, 16347, 16343, 16340, 16336, 16332, 16328, 16324, 16319, 16315, 16310,
16305, 16300, 16295, 16290, 16284, 16279, 16273, 16267, 16261, 16255, 16248, 16242, 16235, 16228, 16221, 16214,
16207, 16199, 16192, 16184, 16176, 16168, 16160, 16151, 16143, 16134, 16125, 16116, 16107, 16098, 16088, 16079,
16069, 16059, 16049, 16039, 16029, 16018, 16008, 15997, 15986, 15975, 15964, 15952, 15941, 15929, 15917, 15905,
15893, 15881, 15868, 15856, 15843, 15830, 15817, 15804, 15791, 15777, 15763, 15750, 15736, 15722, 15707, 15693,
15679, 15664, 15649, 15634, 15619, 15604, 15588, 15573, 15557, 15541, 15525, 15509, 15493, 15476, 15460, 15443,
15426, 15409, 15392, 15375, 15357, 15340, 15322, 15304, 15286, 15268, 15250, 15231, 15213, 15194, 15175, 15156,
15137, 15118, 15098, 15078, 15059, 15039, 15019, 14999, 14978, 14958, 14937, 14917, 14896, 14875, 14854, 14832,
14811, 14789, 14768, 14746, 14724, 14702, 14680, 14657, 14635, 14612, 14589, 14566, 14543, 14520, 14497, 14473,
14449, 14426, 14402, 14378, 14354, 14329, 14305, 14280, 14256, 14231, 14206, 14181, 14155, 14130, 14104, 14079,
14053, 14027, 14001, 13975, 13949, 13922, 13896, 13869, 13842, 13815, 13788, 13761, 13733, 13706, 13678, 13651,
13623, 13595, 13567, 13538, 13510, 13482, 13453, 13424, 13395, 13366, 13337, 13308, 13279, 13249, 13219, 13190,
13160, 13130, 13100, 13069, 13039, 13008, 12978, 12947, 12916, 12885, 12854, 12823, 12792, 12760, 12729, 12697,
12665, 12633, 12601, 12569, 12536, 12504, 12472, 12439, 12406, 12373, 12340, 12307, 12274, 12240, 12207, 12173,
12140, 12106, 12072, 12038, 12004, 11970, 11935, 11901, 11866, 11831, 11797, 11762, 11727, 11691, 11656, 11621,
11585, 11550, 11514, 11478, 11442, 11406, 11370, 11334, 11297, 11261, 11224, 11188, 11151, 11114, 11077, 11040,
11003, 10966, 10928, 10891, 10853, 10815, 10778, 10740, 10702, 10663, 10625, 10587, 10549, 10510, 10471, 10433,
10394, 10355, 10316, 10277, 10238, 10198, 10159, 10120, 10080, 10040, 10001, 9961, 9921, 9881, 9840, 9800,
9760, 9720, 9679, 9638, 9598, 9557, 9516, 9475, 9434, 9393, 9352, 9310, 9269, 9227, 9186, 9144,
9102, 9061, 9019, 8977, 8935, 8892, 8850, 8808, 8765, 8723, 8680, 8638, 8595, 8552, 8509, 8466,
8423, 8380, 8337, 8293, 8250, 8207, 8163, 8119, 8076, 8032, 7988, 7944, 7900, 7856, 7812, 7768,
7723, 7679, 7635, 7590, 7545, 7501, 7456, 7411, 7366, 7321, 7276, 7231, 7186, 7141, 7096, 7050,
7005, 6960, 6914, 6868, 6823, 6777, 6731, 6685, 6639, 6593, 6547, 6501, 6455, 6409, 6363, 6316,
6270, 6223, 6177, 6130, 6084, 6037, 5990, 5943, 5897, 5850, 5803, 5756, 5708, 5661, 5614, 5567,
5520, 5472, 5425, 5377, 5330, 5282, 5235, 5187, 5139, 5092, 5044, 4996, 4948, 4900, 4852, 4804,
4756, 4708, 4660, 4612, 4563, 4515, 4467, 4418, 4370, 4321, 4273, 4224, 4176, 4127, 4078, 4030,
3981, 3932, 3883, 3835, 3786, 3737, 3688, 3639, 3590, 3541, 3492, 3442, 3393, 3344, 3295, 3246,
3196, 3147, 3098, 3048, 2999, 2949, 2900, 2851, 2801, 2751, 2702, 2652, 2603, 2553, 2503, 2454,
2404, 2354, 2305, 2255, 2205, 2155, 2105, 2055, 2006, 1956, 1906, 1856, 1806, 1756, 1706, 1656,
1606, 1556, 1506, 1456, 1406, 1356, 1306, 1255, 1205, 1155, 1105, 1055, 1005, 955, 904, 854,
804, 754, 703, 653, 603, 553, 503, 452, 402, 352, 302, 251, 201, 151, 101, 50,
0, -49, -100, -150, -200, -250, -301, -351, -401, -451, -502, -552, -602, -652, -703, -753,
-803, -853, -903, -954, -1004, -1054, -1104, -1154, -1204, -1254, -1305, -1355, -1405, -1455, -1505, -1555,
-1605, -1655, -1705, -1755, -1805, -1855, -1905, -1955, -2005, -2054, -2104, -2154, -2204, -2254, -2304, -2353,
-2403, -2453, -2502, -2552, -2602, -2651, -2701, -2751, -2800, -2850, -2899, -2948, -2998, -3047, -3097, -3146,
-3195, -3245, -3294, -3343, -3392, -3441, -3491, -3540, -3589, -3638, -3687, -3736, -3785, -3834, -3882, -3931,
-3980, -4029, -4077, -4126, -4175, -4223, -4272, -4320, -4369, -4417, -4466, -4514, -4562, -4611, -4659, -4707,
-4755, -4803, -4851, -4899, -4947, -4995, -5043, -5091, -5138, -5186, -5234, -5281, -5329, -5376, -5424, -5471,
-5519, -5566, -5613, -5660, -5707, -5755, -5802, -5849, -5896, -5942, -5989, -6036, -6083, -6129, -6176, -6222,
-6269, -6315, -6362, -6408, -6454, -6500, -6546, -6592, -6638, -6684, -6730, -6776, -6822, -6867, -6913, -6959,
-7004, -7049, -7095, -7140, -7185, -7230, -7275, -7321, -7365, -7410, -7455, -7500, -7544, -7589, -7634, -7678,
-7722, -7767, -7811, -7855, -7899, -7943, -7987, -8031, -8075, -8118, -8162, -8206, -8249, -8292, -8336, -8379,
-8422, -8465, -8508, -8551, -8594, -8637, -8679, -8722, -8764, -8807, -8849, -8891, -8934, -8976, -9018, -9060,
-9101, -9143, -9185, -9226, -9268, -9309, -9351, -9392, -9433, -9474, -9515, -9556, -9597, -9637, -9678, -9719,
-9759, -9799, -9840, -9880, -9920, -9960, -10000, -10039, -10079, -10119, -10158, -10197, -10237, -10276, -10315, -10354,
-10393, -10432, -10470, -10509, -10548, -10586, -10624, -10662, -10701, -10739, -10777, -10814, -10852, -10890, -10927, -10965,
-11002, -11039, -11076, -11113, -11150, -11187, -11223, -11260, -11296, -11333, -11369, -11405, -11441, -11477, -11513, -11549,
-11584, -11620, -11655, -11690, -11726, -11761, -11796, -11830, -11865, -11900, -11934, -11969, -12003, -12037, -12071, -12105,
-12139, -12172, -12206, -12239, -12273, -12306, -12339, -12372, -12405, -12438, -12471, -12503, -12536, -12568, -12600, -12632,
-12664, -12696, -12728, -12759, -12791, -12822, -12853, -12884, -12915, -12946, -12977, -13007, -13038, -13068, -13099, -13129,
-13159, -13189, -13218, -13248, -13278, -13307, -13336, -13365, -13394, -13423, -13452, -13481, -13509, -13537, -13566, -13594,
-13622, -13650, -13677, -13705, -13732, -13760, -13787, -13814, -13841, -13868, -13895, -13921, -13948, -13974, -14000, -14026,
-14052, -14078, -14103, -14129, -14154, -14180, -14205, -14230, -14255, -14279, -14304, -14328, -14353, -14377, -14401, -14425,
-14448, -14472, -14496, -14519, -14542, -14565, -14588, -14611, -14634, -14656, -14679, -14701, -14723, -14745, -14767, -14788,
-14810, -14831, -14853, -14874, -14895, -14916, -14936, -14957, -14977, -14998, -15018, -15038, -15058, -15077, -15097, -15117,
-15136, -15155, -15174, -15193, -15212, -15230, -15249, -15267, -15285, -15303, -15321, -15339, -15356, -15374, -15391, -15408,
-15425, -15442, -15459, -15475, -15492, -15508, -15524, -15540, -15556, -15572, -15587, -15603, -15618, -15633, -15648, -15663,
-15678, -15692, -15706, -15721, -15735, -15749, -15762, -15776, -15790, -15803, -15816, -15829, -15842, -15855, -15867, -15880,
-15892, -15904, -15916, -15928, -15940, -15951, -15963, -15974, -15985, -15996, -16007, -16017, -16028, -16038, -16048, -16058,
-16068, -16078, -16087, -16097, -16106, -16115, -16124, -16133, -16142, -16150, -16159, -16167, -16175, -16183, -16191, -16198,
-16206, -16213, -16220, -16227, -16234, -16241, -16247, -16254, -16260, -16266, -16272, -16278, -16283, -16289, -16294, -16299,
-16304, -16309, -16314, -16318, -16323, -16327, -16331, -16335, -16339, -16342, -16346, -16349, -16352, -16355, -16358, -16361,
-16363, -16366, -16368, -16370, -16372, -16374, -16375, -16377, -16378, -16379, -16380, -16381, -16382, -16382, -16383, -16383,
-16383, -16383, -16383, -16382, -16382, -16381, -16380, -16379, -16378, -16377, -16375, -16374, -16372, -16370, -16368, -16366,
-16363, -16361, -16358, -16355, -16352, -16349, -16346, -16342, -16339, -16335, -16331, -16327, -16323, -16318, -16314, -16309,
-16304, -16299, -16294, -16289, -16283, -16278, -16272, -16266, -16260, -16254, -16247, -16241, -16234, -16227, -16220, -16213,
-16206, -16198, -16191, -16183, -16175, -16167, -16159, -16150, -16142, -16133, -16124, -16115, -16106, -16097, -16087, -16078,
-16068, -16058, -16048, -16038, -16028, -16017, -16007, -15996, -15985, -15974, -15963, -15951, -15940, -15928, -15916, -15904,
-15892, -15880, -15867, -15855, -15842, -15829, -15816, -15803, -15790, -15776, -15762, -15749, -15735, -15721, -15706, -15692,
-15678, -15663, -15648, -15633, -15618, -15603, -15587, -15572, -15556, -15540, -15524, -15508, -15492, -15475, -15459, -15442,
-15425, -15408, -15391, -15374, -15356, -15339, -15321, -15303, -15285, -15267, -15249, -15230, -15212, -15193, -15174, -15155,
-15136, -15117, -15097, -15077, -15058, -15038, -15018, -14998, -14977, -14957, -14936, -14916, -14895, -14874, -14853, -14831,
-14810, -14788, -14767, -14745, -14723, -14701, -14679, -14656, -14634, -14611, -14588, -14565, -14542, -14519, -14496, -14472,
-14448, -14425, -14401, -14377, -14353, -14328, -14304, -14279, -14255, -14230, -14205, -14180, -14154, -14129, -14103, -14078,
-14052, -14026, -14000, -13974, -13948, -13921, -13895, -13868, -13841, -13814, -13787, -13760, -13732, -13705, -13677, -13650,
-13622, -13594, -13566, -13537, -13509, -13481, -13452, -13423, -13394, -13365, -13336, -13307, -13278, -13248, -13218, -13189,
-13159, -13129, -13099, -13068, -13038, -13007, -12977, -12946, -12915, -12884, -12853, -12822, -12791, -12759, -12728, -12696,
-12664, -12632, -12600, -12568, -12535, -12503, -12471, -12438, -12405, -12372, -12339, -12306, -12273, -12239, -12206, -12172,
-12139, -12105, -12071, -12037, -12003, -11969, -11934, -11900, -11865, -11830, -11796, -11761, -11726, -11690, -11655, -11620,
-11584, -11549, -11513, -11477, -11441, -11405, -11369, -11333, -11296, -11260, -11223, -11187, -11150, -11113, -11076, -11039,
-11002, -10965, -10927, -10890, -10852, -10814, -10777, -10739, -10701, -10662, -10624, -10586, -10548, -10509, -10470, -10432,
-10393, -10354, -10315, -10276, -10237, -10197, -10158, -10119, -10079, -10039, -10000, -9960, -9920, -9880, -9839, -9799,
-9759, -9719, -9678, -9637, -9597, -9556, -9515, -9474, -9433, -9392, -9351, -9309, -9268, -9226, -9185, -9143,
-9101, -9060, -9018, -8976, -8934, -8891, -8849, -8807, -8764, -8722, -8679, -8637, -8594, -8551, -8508, -8465,
-8422, -8379, -8336, -8292, -8249, -8206, -8162, -8118, -8075, -8031, -7987, -7943, -7899, -7855, -7811, -7767,
-7722, -7678, -7634, -7589, -7544, -7500, -7455, -7410, -7365, -7320, -7275, -7230, -7185, -7140, -7095, -7049,
-7004, -6959, -6913, -6867, -6822, -6776, -6730, -6684, -6638, -6592, -6546, -6500, -6454, -6408, -6362, -6315,
-6269, -6222, -6176, -6129, -6083, -6036, -5989, -5942, -5896, -5849, -5802, -5755, -5707, -5660, -5613, -5566,
-5519, -5471, -5424, -5376, -5329, -5281, -5234, -5186, -5138, -5091, -5043, -4995, -4947, -4899, -4851, -4803,
-4755, -4707, -4659, -4611, -4562, -4514, -4466, -4417, -4369, -4320, -4272, -4223, -4175, -4126, -4077, -4029,
-3980, -3931, -3882, -3834, -3785, -3736, -3687, -3638, -3589, -3540, -3491, -3441, -3392, -3343, -3294, -3245,
-3195, -3146, -3097, -3047, -2998, -2948, -2899, -2850, -2800, -2750, -2701, -2651, -2602, -2552, -2502, -2453,
-2403, -2353, -2304, -2254, -2204, -2154, -2104, -2054, -2005, -1955, -1905, -1855, -1805, -1755, -1705, -1655,
-1605, -1555, -1505, -1455, -1405, -1355, -1305, -1254, -1204, -1154, -1104, -1054, -1004, -954, -903, -853,
-803, -753, -702, -652, -602, -552, -502, -451, -401, -351, -301, -250, -200, -150, -100, -49,
};
const unsigned char AtanTab[ATAN_SIZE + 1] =
{
0, 0, 1, 1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 8, 9,
10, 10, 11, 12, 12, 13, 13, 14, 15, 15, 16, 17, 17, 18, 19, 19,
20, 20, 21, 22, 22, 23, 24, 24, 25, 26, 26, 27, 27, 28, 29, 29,
30, 31, 31, 32, 32, 33, 34, 34, 35, 36, 36, 37, 38, 38, 39, 39,
40, 41, 41, 42, 43, 43, 44, 44, 45, 46, 46, 47, 48, 48, 49, 49,
50, 51, 51, 52, 53, 53, 54, 54, 55, 56, 56, 57, 57, 58, 59, 59,
60, 61, 61, 62, 62, 63, 64, 64, 65, 65, 66, 67, 67, 68, 68, 69,
70, 70, 71, 72, 72, 73, 73, 74, 75, 75, 76, 76, 77, 78, 78, 79,
79, 80, 81, 81, 82, 82, 83, 84, 84, 85, 85, 86, 87, 87, 88, 88,
89, 89, 90, 91, 91, 92, 92, 93, 94, 94, 95, 95, 96, 96, 97, 98,
98, 99, 99, 100, 101, 101, 102, 102, 103, 103, 104, 105, 105, 106, 106, 107,
107, 108, 109, 109, 110, 110, 111, 111, 112, 113, 113, 114, 114, 115, 115, 116,
116, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 123, 123, 124, 124, 125,
125, 126, 126, 127, 127, 128, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133,
134, 134, 135, 136, 136, 137, 137, 138, 138, 139, 139, 140, 140, 141, 141, 142,
142, 143, 143, 144, 144, 145, 145, 146, 147, 147, 148, 148, 149, 149, 150, 150,
151, 151, 152, 152, 153, 153, 154, 154, 155, 155, 156, 156, 157, 157, 158, 158,
159, 159, 160, 160, 161, 161, 162, 162, 163, 163, 164, 164, 165, 165, 166, 166,
167, 167, 167, 168, 168, 169, 169, 170, 170, 171, 171, 172, 172, 173, 173, 174,
174, 175, 175, 176, 176, 176, 177, 177, 178, 178, 179, 179, 180, 180, 181, 181,
182, 182, 182, 183, 183, 184, 184, 185, 185, 186, 186, 187, 187, 187, 188, 188,
189, 189, 190, 190, 191, 191, 191, 192, 192, 193, 193, 194, 194, 195, 195, 195,
196, 196, 197, 197, 198, 198, 198, 199, 199, 200, 200, 201, 201, 201, 202, 202,
203, 203, 203, 204, 204, 205, 205, 206, 206, 206, 207, 207, 208, 208, 208, 209,
209, 210, 210, 210, 211, 211, 212, 212, 212, 213, 213, 214, 214, 214, 215, 215,
216, 216, 216, 217, 217, 218, 218, 218, 219, 219, 220, 220, 220, 221, 221, 222,
222, 222, 223, 223, 223, 224, 224, 225, 225, 225, 226, 226, 226, 227, 227, 228,
228, 228, 229, 229, 229, 230, 230, 231, 231, 231, 232, 232, 232, 233, 233, 233,
234, 234, 235, 235, 235, 236, 236, 236, 237, 237, 237, 238, 238, 238, 239, 239,
239, 240, 240, 241, 241, 241, 242, 242, 242, 243, 243, 243, 244, 244, 244, 245,
245, 245, 246, 246, 246, 247, 247, 247, 248, 248, 248, 249, 249, 249, 250, 250,
250, 251, 251, 251, 252, 252, 252, 253, 253, 253, 254, 254, 254, 255, 255, 255,
255
};
// inverse trigo
#define ATN_ADJUST 0 // round value to adjust (0 to disable, 1 to enable)
int Atan2i(int x, int y)
{
if (x == 0)
{
if (y>=0)
return ANGLE2PI/4;
else
return (ANGLE2PI*3)/4;
}
int Index;
if (x>0)
{
if (y>=0)
{
if (x>=y)
{
Index = (y*ATAN_SIZE)/x;
return AtanTab[Index] + ATN_ADJUST;
}
else
{
Index = (x*ATAN_SIZE)/y;
return ((ANGLE2PI/4) - ATN_ADJUST) - AtanTab[Index];
}
}
else
{
y = -y;
if (x>=y)
{
Index = (y*ATAN_SIZE)/x;
return (ANGLE2PI - ATN_ADJUST) - AtanTab[Index];
}
else
{
Index = (x*ATAN_SIZE)/y;
return (((ANGLE2PI*3)/4) + ATN_ADJUST) + AtanTab[Index];
}
}
}
else
{
x = -x;
if (y>=0)
{
if (x>=y)
{
Index = (y*ATAN_SIZE)/x;
return ((ANGLE2PI/2) - ATN_ADJUST) - AtanTab[Index];
}
else
{
Index = (x*ATAN_SIZE)/y;
return ((ANGLE2PI/4) + ATN_ADJUST) + AtanTab[Index];
}
}
else
{
y = -y;
if (x>=y)
{
Index = (y*ATAN_SIZE)/x;
return ((ANGLE2PI/2) + ATN_ADJUST) + AtanTab[Index];
}
else
{
Index = (x*ATAN_SIZE)/y;
return (((ANGLE2PI*3)/4) - ATN_ADJUST) - AtanTab[Index];
}
}
}
}
#if 0
// debug code to check Atan2i function
void Lib3D::CheckAtan2i(void)
{
int ErrCtr = 0; // if delta error < +/-1
int BugCtr = 0; // if delta error > +/-1 -> bug
for (int i=0; i<ANGLE2PI; i++)
{
int x = 3*COSINUS(i);
int y = 3*SINUS(i);
int a = Atan2i(x, y);
if (a < i)
ErrCtr++;
if (a > i)
ErrCtr++;
if ((a < (i-1)) || (a > (i+1)))
BugCtr++; // place breakpoint here
if (a < 0)
ErrCtr++;
if (a >= ANGLE2PI)
ErrCtr++;
}
// round error = ErrCtr;
}
#endif
int Lib3D::GetYOrient(Vector4s const & Src, Vector4s const & Dest)
{
return Atan2i(Dest.z - Src.z, Dest.x - Src.x);
}
int Lib3D::GetXOrient(Vector4s const & Src,Vector4s const & Dest)
{
Vector4s distVector = Dest - Src;
int nXZLength= Lib3D::FSqrt(distVector.x * distVector.x + distVector.z * distVector.z);
return Atan2i(nXZLength, distVector.y);
}
int Lib3D::AngleDiff(int SrcAngle, int TargetAngle)
{
int Delta = (TargetAngle - SrcAngle) & ANGLEMASK;
if (Delta > (ANGLE2PI/2))
Delta -= ANGLE2PI;
return Delta;
}
// return B with (1 << B) == A
int Lib3D::Log2(int a)
{
int b = 0;
while ((1<<b) <= a)
b++;
return b;
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
int Lib3D::GetFovFromXAngle(int in_nXAngle)
{
in_nXAngle>>=1;
A_ASSERT(0 < in_nXAngle && in_nXAngle < PGL_PI);
// tan
int nTan = (Lib3D::Sinus(in_nXAngle)<<COS_SIN_SHIFT)/Lib3D::Cosinus(in_nXAngle);
return ((CHighGear::GetInstance()->m_dispX>>1)<<COS_SIN_SHIFT)/nTan;
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
int Lib3D::GetFovFromYAngle(int in_nYAngle)
{
in_nYAngle>>=1;
A_ASSERT(0 < in_nYAngle && in_nYAngle < PGL_PI);
// tan
int nTan = (Lib3D::Sinus(in_nYAngle)<<COS_SIN_SHIFT)/Lib3D::Cosinus(in_nYAngle);
return ((CHighGear::GetInstance()->m_dispY>>1)<<COS_SIN_SHIFT)/nTan;
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
int Lib3D::GetXAngleFromFov(int in_nFov)
{
return Atan2i(in_nFov, CHighGear::GetInstance()->m_dispX>>1)<<1;
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
int Lib3D::GetYAngleFromFov(int in_nFov)
{
return Atan2i(in_nFov, CHighGear::GetInstance()->m_dispY>>1)<<1;
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
int Lib3D::PositiveQuadraticRoot12(int i_A, int i_B, int i_C)
{
if (i_A == 0)
{
if (i_B == 0)
{
// constant case
return -1;
}
// linear case
return Quotient12(-i_C, i_B);
}
bool const negativeA = i_A < 0;
int rootShift = 0;
int const abcMax = Max(Abs(i_A), Max(Abs(i_B), Abs(i_C)));
int a12 = Quotient12(i_A, abcMax);
int b12 = Quotient12(i_B, abcMax);
int c12 = Quotient12(i_C, abcMax);
int const ac24 = a12 * c12;
int const discriminant24 = b12 * b12 - 4 * ac24;
if (discriminant24 < 0)
{
// no real root
return -1;
}
int const root = Product12(FSqrt(discriminant24), abcMax);
int const t = -i_B + (((ac24 < 0) != negativeA) ? root : -root);
if ((t < 0) != negativeA)
{
// no positive root
return -1;
}
return Quotient12(t, 2 * i_A);
}
//#if CHECK_MATH
#if defined (WIN32) && !defined(WINDOWS_MOBILE)
#include <limits.h>
volatile static bool _disable = false;
// ---------------------------------------------------------------------------
// Used bu debug macros CHK_MULT and CHK_LIMITS; see config.h
// ---------------------------------------------------------------------------
void _Check_Int_Limit(double x)
{
if(!_disable)
{
A_ASSERT(x <= double(INT_MAX) && x >= double(INT_MIN));
}
}
void _Check_Short_Limit(double x)
{
if(!_disable)
{
A_ASSERT(x <= double(SHRT_MAX) && x >= double(SHRT_MIN));
}
}
void _Check_Precision(double fResult, int nResult, double fTolerancePercentage)
{
double fError = fResult - nResult;
if (fError < 0) fError = -fError;
double fTolerance = fTolerancePercentage*fResult/100;
if (fTolerance < 0) fTolerance = -fTolerance;
A_ASSERT(int(fError) <= int(fTolerance)); // always tolerate decimal error
}
#endif //#if CHECK_MATH | [
"jakesoul@c957e3ca-5ece-11de-8832-3f4c773c73ae"
]
| [
[
[
1,
446
]
]
]
|
0f43dfb83923a3fc0ec548dae0319007c8c1e814 | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/filesystem/src/utf8_codecvt_facet.hpp | 1cf9327454517a37016516e40d549a36eef1f72d | [
"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 | WINDOWS-1252 | C++ | false | false | 902 | hpp | // Copyright © 2001 Ronald Garcia, Indiana University ([email protected])
// Andrew Lumsdaine, Indiana University ([email protected]). Permission to copy,
// use, modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided "as is"
// without express or implied warranty, and with no claim as to its suitability
// for any purpose.
#ifndef BOOST_FILESYSTEM_UTF8_CODECVT_FACET_HPP
#define BOOST_FILESYSTEM_UTF8_CODECVT_FACET_HPP
#include <boost/filesystem/config.hpp>
#define BOOST_UTF8_BEGIN_NAMESPACE \
namespace boost { namespace filesystem { namespace detail {
#define BOOST_UTF8_END_NAMESPACE }}}
#define BOOST_UTF8_DECL BOOST_FILESYSTEM_DECL
#include <boost/detail/utf8_codecvt_facet.hpp>
#undef BOOST_UTF8_BEGIN_NAMESPACE
#undef BOOST_UTF8_END_NAMESPACE
#undef BOOST_UTF8_DECL
#endif
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
]
| [
[
[
1,
25
]
]
]
|
693cddbae4cd7800ee9d59fd34642aae9e67df87 | ccc3e2995bc64d09b9e88fea8c1c7e2029a60ed8 | /SO/Trabalhos/Trabalho 2/tmp_src/31529/versao3 terminarAvioes implementado e codigo comentado/Trab2.cpp | 2f0913f2acb616264e8120297010b4209af27728 | []
| no_license | masterzdran/semestre5 | e559e93017f5e40c29e9f28466ae1c5822fe336e | 148d65349073f8ae2f510b5659b94ddf47adc2c7 | refs/heads/master | 2021-01-25T10:05:42.513229 | 2011-02-20T17:46:14 | 2011-02-20T17:46:14 | 35,061,115 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 8,670 | cpp | // Trab2.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "Trab2.h"
#define MAX_LOADSTRING 100
#define MAX_BUFFER 21
// Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
GestorDePistas * gestor;
//Objecto de sincronização utilizado para assegurar de que há somente uma thread de cada vez
//a remover itens da ListBox.
CRITICAL_SECTION csDelFromLB;
//buffer utilizado para efectuar as leituras dos objectos existentes na parte gráfica
TCHAR buffer[MAX_BUFFER];
//indica se o alerta de furacao esta ligado ou não
bool _bFuracao;
typedef INT (*CountPlanesFunc)(void);
typedef Plane * (*LandOrLiftPlanesFunc)(void);
// Forward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
// criar Dialog do 2º trabalho prático
//DialogBox(hInst, MAKEINTRESOURCE(IDD_TRAB2_DIALOG), NULL, About);
DialogBox(hInst, MAKEINTRESOURCE(IDD_RUNWAY), NULL, About);
return (int) 0;
}
INT Landing_Animate_Id[] = {
IDC_AT0, IDC_AT1, IDC_AT2, IDC_AT3, IDC_AT4, IDC_AT5, IDC_AT6, IDC_AT7, IDC_AT8,
IDC_AT9, IDC_AT10, IDC_AT11, IDC_AT12, IDC_AT13, IDC_AT14, IDC_AT15, IDC_AT16, IDC_AT17,
IDC_AT18, IDC_AT19, IDC_AT20, IDC_AT21, IDC_AT22, IDC_AT23, IDC_AT24, IDC_AT25
}
, Takeoff_Animate_Id[] = {
IDC_DS0, IDC_DS1, IDC_DS2, IDC_DS3, IDC_DS4, IDC_DS5, IDC_DS6, IDC_DS7, IDC_DS8,
IDC_DS9, IDC_DS10, IDC_DS11, IDC_DS12, IDC_DS13, IDC_DS14, IDC_DS15, IDC_DS16, IDC_DS17,
IDC_DS18, IDC_DS19, IDC_DS20, IDC_DS21, IDC_DS22, IDC_DS23, IDC_DS24, IDC_DS25
};
void loadIntoBufferPlanesCount(Plane::PlaneDirection direction)
{
int n;
if(Plane::LAND==direction)
{
n = gestor->getCountPlanesToLand();
}
else if(Plane::LIFTOFF==direction)
{
n = gestor->getCountPlanesToLift();
}
_itot(n,buffer,10);
}
Plane* executeLandOrListFunction(Plane::PlaneDirection direction)
{
if(Plane::LAND==direction)
{
return gestor->esperarPistaParaAterrar();
}
else if(Plane::LIFTOFF==direction)
{
return gestor->esperarPistaParaDescolar();
}
}
INT * getAnimationEditText(INT idLane)
{
if(idLane==1)
{
return Landing_Animate_Id;
}
else if(idLane==0)
{
return Takeoff_Animate_Id;
}
}
void doAnimation(Plane * plane, HWND hDlg, INT animationEditTexts)
{
Edit_SetText(GetDlgItem(hDlg, animationEditTexts), plane->GetName());
Sleep(200);
Edit_SetText(GetDlgItem(hDlg, animationEditTexts), TEXT(" "));
}
void perform(HWND hDlg, HWND hList, HWND hEditList,Plane::PlaneDirection direction
//,CountPlanesFunc cpf,LandOrLiftPlanesFunc lolpf,
)
{
Plane * plane = gestor->criarAviaoPara(direction);
ListBox_AddString(hList,plane->GetName());
//_itot_s(cpf(),buffer,sizeof(_TCHAR)*MAX_BUFFER,10);
loadIntoBufferPlanesCount(direction);
Edit_SetText(hEditList,buffer);
plane = executeLandOrListFunction(direction);
EnterCriticalSection(&csDelFromLB);
ListBox_DeleteString(hList,ListBox_FindStringExact(hList,0,plane->GetName()));
LeaveCriticalSection(&csDelFromLB);
//_itot_s(cpf(),buffer,sizeof(_TCHAR)*MAX_BUFFER,10);
loadIntoBufferPlanesCount(direction);
Edit_SetText(hEditList,buffer);
if(!(plane->terminateQuickly()))
{
INT * animationEditTexts = getAnimationEditText(plane->_idLane);
if(plane->GetDirection()==Plane::LAND)
{
for (int i=0; i < 26; ++i) {
doAnimation(plane,hDlg,animationEditTexts[i]);
}
}
else if(plane->GetDirection()==Plane::LIFTOFF)
{
for(int i = 25; i>=0;--i)
{
doAnimation(plane,hDlg,animationEditTexts[i]);
}
}
gestor->libertarPista(plane);
}
}
DWORD WINAPI thAviaoAterrar(LPVOID param)
{
HWND hDlg = (HWND)param;
HWND hList = GetDlgItem(hDlg,IDC_LAND_LIST);
HWND hEditList = GetDlgItem(hDlg,IDC_N_LAND_LIST);
perform(hDlg,hList,hEditList,Plane::LAND
//,&(gestor->getCountPlanesToLand),&(gestor->esperarPistaParaAterrar),
);
return 0;
}
DWORD WINAPI thAviaoDescolar(LPVOID param)
{
HWND hDlg = (HWND)param;
HWND hList = GetDlgItem(hDlg,IDC_LIFT_LIST);
HWND hEditList = GetDlgItem(hDlg,IDC_N_LIFT_LIST);
perform(hDlg,hList,hEditList,Plane::LIFTOFF);
return 0;
}
VOID WINAPI fecharOuAbrirPista(HWND hControl,INT idLane, HWND hStatic)
{
Button_GetText(hControl,buffer,MAX_BUFFER);
if(buffer[0]=='A')
{
gestor->abrirPista(idLane);
Button_SetText(hControl,_T("Fechar"));
Static_SetText(hStatic,_T("Encontra-se aberta"));
}
else if(buffer[0]=='F')
{
gestor->fecharPista(idLane);
Button_SetText(hControl,_T("Abrir"));
Static_SetText(hStatic,_T("Encontra-se fechada"));
}
}
VOID WINAPI pistaParaAterrarOuDescolar(HWND hControl, INT idLane, HWND hStatic)
{
Button_GetText(hControl,buffer,MAX_BUFFER);
if(buffer[0]=='A')
{
gestor->SetLanePriorityTo(Plane::LAND,idLane);
Button_SetText(hControl,_T("Descolar"));
Static_SetText(hStatic,_T("Dá prioridade a aterragens"));
}
else if(buffer[0]=='D')
{
gestor->SetLanePriorityTo(Plane::LIFTOFF,idLane);
Button_SetText(hControl,_T("Aterrar"));
Static_SetText(hStatic,_T("Dá prioridade a descolagens"));
}
}
// Message handler for about box.
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
int n_planes;
UNREFERENCED_PARAMETER(lParam);
switch (message)
{
case WM_INITDIALOG:
gestor = new GestorDePistas(2);
gestor->SetLanePriorityTo(Plane::LAND,1);
gestor->SetLanePriorityTo(Plane::LIFTOFF,0);
Static_SetText(GetDlgItem(hDlg,IDC_PISTA1_LL),_T("Dá prioridade a aterragens"));
Static_SetText(GetDlgItem(hDlg,IDC_PISTA0_LL),_T("Dá prioridade a descolagens"));
Static_SetText(GetDlgItem(hDlg,IDC_PISTA1_OC),_T("Encontra-se aberta"));
Static_SetText(GetDlgItem(hDlg,IDC_PISTA0_OC),_T("Encontra-se aberta"));
// é necessário para trabalhar sobre a parte grafica,
//porque quando vai obter o indice do elemento a remover,
//pode haver um contextswitch que provoca erros.
InitializeCriticalSectionAndSpinCount(&csDelFromLB,5000);
_bFuracao = false;
Edit_SetText(GetDlgItem(hDlg, IDC_N_LAND), TEXT("0"));
Edit_SetText(GetDlgItem(hDlg, IDC_N_LIFT), TEXT("0"));
Edit_SetText(GetDlgItem(hDlg, IDC_N_LAND_LIST), TEXT("0"));
Edit_SetText(GetDlgItem(hDlg, IDC_N_LIFT_LIST), TEXT("0"));
//Button_SetCheck(GetDlgItem(hDlg, IDC_CHECK1), TRUE);
//Button_SetCheck(GetDlgItem(hDlg, IDC_CHECK2), TRUE);
return (INT_PTR)TRUE;
case WM_COMMAND:
switch ( LOWORD(wParam) ) {
case IDC_CREATE_LANDING:
Edit_GetText(GetDlgItem(hDlg,IDC_N_LAND),buffer,MAX_BUFFER);
n_planes = _ttoi(buffer);
for(int i = 0;i<n_planes;++i)
{
CreateThread(NULL, 0, thAviaoAterrar, (LPVOID)hDlg, 0, NULL);
}
break;
case IDC_CREATE_TAKEOFF:
Edit_GetText(GetDlgItem(hDlg,IDC_N_LIFT),buffer,MAX_BUFFER);
n_planes = _ttoi(buffer);
for(int i = 0;i<n_planes;++i)
{
CreateThread(NULL, 0, thAviaoDescolar, (LPVOID)hDlg, 0, NULL);
}
break;
case IDC_OPEN_LANE0:
fecharOuAbrirPista(GetDlgItem(hDlg,IDC_OPEN_LANE0),0,GetDlgItem(hDlg,IDC_PISTA0_OC));
break;
case IDC_OPEN_LANE1:
fecharOuAbrirPista(GetDlgItem(hDlg,IDC_OPEN_LANE1),1,GetDlgItem(hDlg,IDC_PISTA1_OC));
break;
case IDC_LIFT_LANE0:
pistaParaAterrarOuDescolar(GetDlgItem(hDlg,IDC_LIFT_LANE0),0,GetDlgItem(hDlg,IDC_PISTA0_LL));
break;
case IDC_LAND_LANE1:
pistaParaAterrarOuDescolar(GetDlgItem(hDlg,IDC_LAND_LANE1),1,GetDlgItem(hDlg,IDC_PISTA1_LL));
break;
case IDC_FURACAO:
if(!_bFuracao)
{
Static_SetText(GetDlgItem(hDlg,IDC_LBL_FURACAO),_T("AVISO: FURACÃO!"));
}else
{
Static_SetText(GetDlgItem(hDlg,IDC_LBL_FURACAO),_T(""));
}
_bFuracao = !_bFuracao;
gestor->alertaFuracao(_bFuracao);
break;
case IDTerminarAvioes:
gestor->terminar();
break;
case IDCANCEL:
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
}
break;
}
return (INT_PTR)FALSE;
}
| [
"the.whinner@b139f23c-5e1e-54d6-eab5-85b03e268133"
]
| [
[
[
1,
284
]
]
]
|
b8e93beed3d4c5992957a6683adb63999274119f | 22d9640edca14b31280fae414f188739a82733e4 | /Code/VTK/include/vtk-5.2/vtkXMLDataElement.h | 297cf5c59ba64f5fc7933d7c8072a3b491a3e2a8 | []
| no_license | tack1/Casam | ad0a98febdb566c411adfe6983fcf63442b5eed5 | 3914de9d34c830d4a23a785768579bea80342f41 | refs/heads/master | 2020-04-06T03:45:40.734355 | 2009-06-10T14:54:07 | 2009-06-10T14:54:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,731 | h | /*=========================================================================
Program: Visualization Toolkit
Module: $RCSfile: vtkXMLDataElement.h,v $
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkXMLDataElement - Represents an XML element and those nested inside.
// .SECTION Description
// vtkXMLDataElement is used by vtkXMLDataParser to represent an XML
// element. It provides methods to access the element's attributes
// and nested elements in a convenient manner. This allows easy
// traversal of an input XML file by vtkXMLReader and its subclasses.
// .SECTION See Also
// vtkXMLDataParser
#ifndef __vtkXMLDataElement_h
#define __vtkXMLDataElement_h
#include "vtkObject.h"
class vtkXMLDataParser;
class VTK_IO_EXPORT vtkXMLDataElement : public vtkObject
{
public:
vtkTypeRevisionMacro(vtkXMLDataElement,vtkObject);
void PrintSelf(ostream& os, vtkIndent indent);
static vtkXMLDataElement* New();
// Description:
// Set/Get the name of the element. This is its XML tag.
vtkGetStringMacro(Name);
vtkSetStringMacro(Name);
// Description:
// Set/Get the value of the id attribute of the element, if any.
vtkGetStringMacro(Id);
vtkSetStringMacro(Id);
// Description:
// Get the attribute with the given name. If it doesn't exist,
// returns 0.
const char* GetAttribute(const char* name);
// Description:
// Set the attribute with the given name and value. If it doesn't exist,
// adds it.
void SetAttribute(const char* name, const char* value);
// Description:
// Set/Get the character data between XML start/end tags.
void SetCharacterData(const char* c, int length);
void AddCharacterData(const char* c, int length);
vtkGetStringMacro(CharacterData);
// Description:
// Get the attribute with the given name and converted to a scalar
// value. Returns whether value was extracted.
int GetScalarAttribute(const char* name, int& value);
int GetScalarAttribute(const char* name, float& value);
int GetScalarAttribute(const char* name, double& value);
int GetScalarAttribute(const char* name, unsigned long& value);
// Description:
// Set the attribute with the given name.
// We can not use the same GetScalarAttribute() construct since
// the compiler will not be able to resolve between
// SetAttribute(..., int) and SetAttribute(..., unsigned long).
void SetIntAttribute(const char* name, int value);
void SetFloatAttribute(const char* name, float value);
void SetDoubleAttribute(const char* name, double value);
void SetUnsignedLongAttribute(const char* name, unsigned long value);
// Description:
// Get the attribute with the given name and converted to a scalar
// value. Returns length of vector read.
int GetVectorAttribute(const char* name, int length, int* value);
int GetVectorAttribute(const char* name, int length, float* value);
int GetVectorAttribute(const char* name, int length, double* value);
int GetVectorAttribute(const char* name, int length, unsigned long* value);
// Description:
// Set the attribute with the given name.
void SetVectorAttribute(const char* name, int length, const int* value);
void SetVectorAttribute(const char* name, int length, const float* value);
void SetVectorAttribute(const char* name, int length, const double* value);
void SetVectorAttribute(const char* name, int length, const unsigned long* value);
#ifdef VTK_USE_64BIT_IDS
//BTX
int GetScalarAttribute(const char* name, vtkIdType& value);
void SetIdTypeAttribute(const char* name, vtkIdType value);
int GetVectorAttribute(const char* name, int length, vtkIdType* value);
void SetVectorAttribute(const char* name, int length, const vtkIdType* value);
//ETX
#endif
// Description:
// Get the attribute with the given name and converted to a word type
// such as VTK_FLOAT or VTK_UNSIGNED_LONG.
int GetWordTypeAttribute(const char* name, int& value);
// Description:
// Get the number of attributes.
vtkGetMacro(NumberOfAttributes, int);
// Description:
// Get the n-th attribute name.
// Returns 0 if there is no such attribute.
const char* GetAttributeName(int idx);
// Description:
// Get the n-th attribute value.
// Returns 0 if there is no such attribute.
const char* GetAttributeValue(int idx);
// Description:
// Remove one or all attributes.
virtual void RemoveAttribute(const char *name);
virtual void RemoveAllAttributes();
// Description:
// Set/Get the parent of this element.
vtkXMLDataElement* GetParent();
void SetParent(vtkXMLDataElement* parent);
// Description:
// Get root of the XML tree this element is part of.
virtual vtkXMLDataElement* GetRoot();
// Description:
// Get the number of elements nested in this one.
int GetNumberOfNestedElements();
// Description:
// Get the element nested in this one at the given index.
vtkXMLDataElement* GetNestedElement(int index);
// Description:
// Add nested element
void AddNestedElement(vtkXMLDataElement* element);
// Description:
// Remove nested element.
virtual void RemoveNestedElement(vtkXMLDataElement *);
// Description:
// Remove all nested elements.
virtual void RemoveAllNestedElements();
// Description:
// Find the first nested element with the given id, given name, or given
// name and id.
// WARNING: the search is only performed on the children, not
// the grand-children.
vtkXMLDataElement* FindNestedElement(const char* id);
vtkXMLDataElement* FindNestedElementWithName(const char* name);
vtkXMLDataElement* FindNestedElementWithNameAndId(
const char* name, const char* id);
vtkXMLDataElement* FindNestedElementWithNameAndAttribute(
const char* name, const char* att_name, const char* att_value);
// Description:
// Find the first nested element with given name.
// WARNING: the search is performed on the whole XML tree.
vtkXMLDataElement* LookupElementWithName(const char* name);
// Description:
// Lookup the element with the given id, starting at this scope.
vtkXMLDataElement* LookupElement(const char* id);
// Description:
// Set/Get the offset from the beginning of the XML document to this element.
vtkGetMacro(XMLByteIndex, unsigned long);
vtkSetMacro(XMLByteIndex, unsigned long);
// Description:
// Check if the instance has the same name, attributes, character data
// and nested elements contents than the given element (this method is
// applied recursively on the nested elements, and they must be stored in
// the same order).
// Warning: Id, Parent, XMLByteIndex are ignored.
virtual int IsEqualTo(vtkXMLDataElement *elem);
// Description:
// Copy this element from another of the same type (elem), recursively.
// Old attributes and nested elements are removed, new ones are created
// given the contents of 'elem'.
// Warning: Parent is ignored.
virtual void DeepCopy(vtkXMLDataElement *elem);
// Description:
// Get/Set the internal character encoding of the attributes.
// Default type is VTK_ENCODING_UTF_8.
// Note that a vtkXMLDataParser has its own AttributesEncoding ivar. If
// this ivar is set to something other than VTK_ENCODING_NONE, it will be
// used to set the attribute encoding of each vtkXMLDataElement
// created by this vtkXMLDataParser.
vtkSetClampMacro(AttributeEncoding,int,VTK_ENCODING_NONE,VTK_ENCODING_UNKNOWN);
vtkGetMacro(AttributeEncoding, int);
// Description:
// Prints element tree as XML.
void PrintXML(ostream& os, vtkIndent indent);
protected:
vtkXMLDataElement();
~vtkXMLDataElement();
// The name of the element from the XML file.
char* Name;
// The value of the "id" attribute, if any was given.
char* Id;
// The character data between the start and end tags of this element.
char* CharacterData;
// The offset into the XML stream where the element begins.
unsigned long XMLByteIndex;
// The offset into the XML stream where the inline data begins.
unsigned long InlineDataPosition;
// The raw property name/value pairs read from the XML attributes.
char** AttributeNames;
char** AttributeValues;
int NumberOfAttributes;
int AttributesSize;
int AttributeEncoding;
// The set of nested elements.
int NumberOfNestedElements;
int NestedElementsSize;
vtkXMLDataElement** NestedElements;
// The parent of this element.
vtkXMLDataElement* Parent;
// Method used by vtkXMLFileParser to setup the element.
void ReadXMLAttributes(const char** atts, int encoding);
void SeekInlineDataPosition(vtkXMLDataParser* parser);
// Internal utility methods.
vtkXMLDataElement* LookupElementInScope(const char* id);
vtkXMLDataElement* LookupElementUpScope(const char* id);
static int IsSpace(char c);
//BTX
friend class vtkXMLDataParser;
friend class vtkXMLMaterialParser;
//ETX
private:
vtkXMLDataElement(const vtkXMLDataElement&); // Not implemented.
void operator=(const vtkXMLDataElement&); // Not implemented.
};
#endif
| [
"nnsmit@9b22acdf-97ab-464f-81e2-08fcc4a6931f"
]
| [
[
[
1,
268
]
]
]
|
c4bab66799ba97f2b7f4f4ede8aeb6d980b4501d | c95a83e1a741b8c0eb810dd018d91060e5872dd8 | /Game/ObjectDLL/ObjectShared/DeathMatchMissionMgr.h | 8cc4582fc1f60fa7d0376fb8a5d1285e877ffaf5 | []
| no_license | rickyharis39/nolf2 | ba0b56e2abb076e60d97fc7a2a8ee7be4394266c | 0da0603dc961e73ac734ff365bfbfb8abb9b9b04 | refs/heads/master | 2021-01-01T17:21:00.678517 | 2011-07-23T12:11:19 | 2011-07-23T12:11:19 | 38,495,312 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,471 | h | // ----------------------------------------------------------------------- //
//
// MODULE : DeathMatchMissionMgr.h
//
// PURPOSE : Definition of class to handle deathmatch missions
//
// (c) 2002 Monolith Productions, Inc. All Rights Reserved
//
// ----------------------------------------------------------------------- //
#ifndef __DEATHMATCHMISSIONMGR_H__
#define __DEATHMATCHMISSIONMGR_H__
#include "ServerMissionMgr.h"
class CDeathMatchMissionMgr : public CServerMissionMgr
{
public:
CDeathMatchMissionMgr();
~CDeathMatchMissionMgr();
// Game type overrides.
public:
// Initializes the object. Overrides should call up.
virtual bool Init( );
// Terminates the object. Overrides should call up.
virtual void Term();
// Save/load state of missionmgr. Overrides should call up.
virtual bool Save( ILTMessage_Write& msg, uint32 dwSaveFlags );
virtual bool Load( ILTMessage_Read& msg, uint32 dwSaveFlags );
// Called every frame. Overrides should call up.
virtual void Update( );
// Game type overrides.
protected:
// Does loading of next level.
virtual bool FinishExitLevel( );
// Init game.
virtual bool StartGame( ILTMessage_Read& msg );
// End game.
virtual bool EndGame( );
//handle updating multiplayer options while in game
virtual bool HandleMultiplayerOptions( HCLIENT hSender, ILTMessage_Read& msg );
};
#endif // __DEATHMATCHMISSIONMGR_H__ | [
"[email protected]"
]
| [
[
[
1,
56
]
]
]
|
ada4109a4ca0386f5b42fb88870b089368e770b1 | 57574cc7192ea8564bd630dbc2a1f1c4806e4e69 | /Poker/Cliente/OpUIClienteSolicitarArchivo.cpp | f4a116602bf75faebe4584e3cf0207499463af4a | []
| no_license | natlehmann/taller-2010-2c-poker | 3c6821faacccd5afa526b36026b2b153a2e471f9 | d07384873b3705d1cd37448a65b04b4105060f19 | refs/heads/master | 2016-09-05T23:43:54.272182 | 2010-11-17T11:48:00 | 2010-11-17T11:48:00 | 32,321,142 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,629 | cpp | #include "OpUIClienteSolicitarArchivo.h"
#include "DomTree.h"
#include "DomTreeFactory.h"
#include "Elemento.h"
#include "UICliente.h"
#include "Cliente.h"
#include "XmlParser.h"
#include "PokerException.h"
#include "RecursosCliente.h"
#include "Respuesta.h"
#include "Mesa.h"
#include "Jugador.h"
#include "Imagen.h"
#include "FabricaDeElementosGraficos.h"
OpUIClienteSolicitarArchivo::OpUIClienteSolicitarArchivo(vector<string> parametros) : OperacionUICliente(){
this->parametros = parametros;
}
OpUIClienteSolicitarArchivo::~OpUIClienteSolicitarArchivo(void){
}
bool OpUIClienteSolicitarArchivo::ejecutarAccion(Ventana* ventana){
string nombreArchivo = parametros.at(0);
string pathDestino = RecursosCliente::getConfig()->get("cliente.configuracion.imagenes.path");
//arma el xml de solicitud de archivo
DomTree* tree = new DomTree("operaciones");
Elemento* pedido = tree->agregarElemento("pedido");
Elemento* operacion = pedido->agregarHijo("operacion");
operacion->agregarAtributo("id", "OpEnviarArchivo");
Elemento* parametros = operacion->agregarHijo("parametros");
Elemento* parametro = parametros->agregarHijo("parametro");
parametro->agregarAtributo("nombre", "nombreArchivo");
parametro->setTexto(nombreArchivo);
XmlParser* parser = new XmlParser();
string mensaje = parser->toString(tree);
delete(tree);
delete(parser);
//envia el pedido al servidor
Cliente* cliente = UICliente::getCliente();
string mensajeRecibido;
//recibe la longitud del archivo solicitado
if (cliente->enviarRecibir(mensaje, mensajeRecibido)) {
//valida y convierte el string con en tamanio del archivo a un entero
int size = UtilTiposDatos::stringAEntero(mensajeRecibido);
if (size != -1)
{
//envia el mensaje de recibido ok y recibe el archivo solicitado
if (cliente->enviarRecibir(string("OK"), mensajeRecibido, size)) {
//arma el path de destino
string pathCompleto = pathDestino;
pathCompleto.append(nombreArchivo);
ofstream newfile(pathCompleto.c_str(), ios::out | ios::binary);
if(newfile.is_open())
{
//graba el archivo en el disco
newfile.write(mensajeRecibido.data(), size);
newfile.close();
return true;
}
else
RecursosCliente::getLog()->escribir("Error al escribir el archivo " + pathCompleto);
}
else
RecursosCliente::getLog()->escribir("Error al recibir el archivo " + nombreArchivo);
}
else
RecursosCliente::getLog()->escribir("El servidor no encuentra el archivo solicitado: " + nombreArchivo);
}
return false;
} | [
"pablooddo@a9434d28-8610-e991-b0d0-89a272e3a296",
"[email protected]@a9434d28-8610-e991-b0d0-89a272e3a296"
]
| [
[
[
1,
8
],
[
10,
22
],
[
24,
25
],
[
27,
45
],
[
47,
48
],
[
51,
51
],
[
53,
54
],
[
57,
65
],
[
67,
71
],
[
73,
74
],
[
76,
77
],
[
79,
82
]
],
[
[
9,
9
],
[
23,
23
],
[
26,
26
],
[
46,
46
],
[
49,
50
],
[
52,
52
],
[
55,
56
],
[
66,
66
],
[
72,
72
],
[
75,
75
],
[
78,
78
]
]
]
|
eb32dbfd2f7df132cd37f85437d05a2e5c7dd436 | cb480b1c0fbf026576305311c8af98237161d49c | /branches/1.2-BRANCH/AlarmClock.cpp | d457c84766e2bb862932b1b4a53e5a21e93b8691 | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer"
]
| permissive | BackupTheBerlios/winamp-alarm-svn | 770a832880b0e65ff94fd468f5a983df9c1c78fe | fb10dd4adc643abc0509bd3d355ae31ad0ae9e43 | refs/heads/master | 2021-01-01T17:22:19.131562 | 2005-02-20T20:06:01 | 2005-02-20T20:06:01 | 40,773,150 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,200 | cpp | /*
Copyright (c) 2004 Harri Salokorpi <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
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.
*/
// AlarmClock.cpp : Defines the initialization routines for the DLL.
//
#include "stdafx.h"
#include "AlarmClock.h"
#include "ConfigAlarmDlg.h"
#include "Alarm.h"
#include "Configuration.h"
#include "SnoozeAlarmDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define iniFileName "alarmConfig.ini"
//
// Note!
//
// If this DLL is dynamically linked against the MFC
// DLLs, any functions exported from this DLL which
// call into MFC must have the AFX_MANAGE_STATE macro
// added at the very beginning of the function.
//
// For example:
//
// extern "C" bool PASCAL EXPORT ExportedFunction()
// {
// AFX_MANAGE_STATE(AfxGetStaticModuleState());
// // normal function body here
// }
//
// It is very important that this macro appear in each
// function, prior to any calls into MFC. This means that
// it must appear as the first statement within the
// function, even before any object variable declarations
// as their constructors may generate calls into the MFC
// DLL.
//
// Please see MFC Technical Notes 33 and 58 for additional
// details.
//
/////////////////////////////////////////////////////////////////////////////
// CAlarmClockApp
BEGIN_MESSAGE_MAP(CAlarmClockApp, CWinApp)
//{{AFX_MSG_MAP(CAlarmClockApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAlarmClockApp construction
#define TICK_COUNT 3
CAlarm *alarm = 0;
CConfiguration *configuration = 0;
CConfigAlarmDlg *cfg = 0;
CSnoozeAlarmDlg *snooze = 0;
time_t lastAlarm;
time_t currentTime;
time_t fadeStarted;
char plugindir[512];
char winampdir[128];
char buffer[PLAYLIST_NAME];
char shellplaycommand[512];
bool alarmExecuted = false;
bool cfgWindowOpen = false;
bool snoozeWindowOpen = false;
int tickCounter = 0;
int fadeVol = 0;
bool fadeIn = false;
bool shuffleSet;
bool repeatSet;
CAlarmClockApp::CAlarmClockApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
};
/////////////////////////////////////////////////////////////////////////////
// The one and only CAlarmClockApp object
CAlarmClockApp theApp;
/////////////////////////////////////////////////////////////////////////////
// Below are method/struct declarations required by WinAmp
WNDPROC lpWndProcOld;
extern "C" int init();
extern "C" void quit();
extern "C" void config();
winampGeneralPurposePlugin plugin =
{
GPPHDR_VER,
"Winamp alarm v1.21",
init,
config,
quit,
};
// This wndproc is hooked to winamps message loop
extern "C" LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
int state = 0;
int ret = 0;
// Here we deal with the configuration window closing
if(message == WM_CONFIGDIALOG_KILLED)
{
if(wParam == IDOK)
{
configuration->saveConfiguration();
alarm->enableAlarm();
}
if(wParam == IDCANCEL)
{
configuration->readConfiguration(plugindir);
alarm->enableAlarm();
}
cfg->DestroyWindow();
delete cfg;
cfgWindowOpen = false;
}
if(message == WM_SNOOZING)
{
if( wParam == IDSNOOZE )
{
// Stop playing
::SendMessage(plugin.hwndParent, WM_COMMAND, 40046, 0l );
time( &lastAlarm );
alarm->setState(STATE_SNOOZE);
//snooze->ShowWindow( SW_HIDE );
}
if( wParam == IDSTOP )
{
// Stop playing
::SendMessage(plugin.hwndParent, WM_COMMAND, 40047, 0l );
alarm->setState(STATE_WAITING);
if( snoozeWindowOpen == true )
{
snoozeWindowOpen = false;
snooze->DestroyWindow();
delete snooze;
}
// Set full volume
ret = SendMessage( plugin.hwndParent, WM_USER , 255 , 122 );
repeatSet == true ? SendMessage( plugin.hwndParent, WM_USER , 1 , 253 ) : SendMessage( plugin.hwndParent, WM_USER , 0 , 253 );
shuffleSet == true ? SendMessage( plugin.hwndParent, WM_USER , 1 , 252 ) : SendMessage( plugin.hwndParent, WM_USER , 0 , 252 );
}
if( wParam == IDCLOSESNOOZE )
{
if( snoozeWindowOpen == true )
{
snoozeWindowOpen = false;
snooze->DestroyWindow();
delete snooze;
}
alarm->setState(STATE_WAITING);
}
}
// Timer triggered checks... idles 10 ticks, currently
if(message == WM_TIMER)
{
if(tickCounter > 0)
{
tickCounter--;
}
else
{
// Get current alarm state
state = alarm->getState();
tickCounter = TICK_COUNT;
if (configuration->getConfig()->getFadeInStatus() == true &&
state == STATE_ALARMING )
{
if(fadeVol < configuration->getConfig()->getAlarmLevel())
{
time( ¤tTime );
int timediff = currentTime - fadeStarted;
int fadingTime = configuration->getConfig()->getFadeInTime() * 60;
if( timediff != 0 )
{
fadeVol = ( configuration->getConfig()->getAlarmLevel() * timediff ) / fadingTime;
}
}
}
}
}
if( state == STATE_SNOOZE )
{
int minuteDiff = 0;
int minutes = 0;
int seconds = 0;
time( ¤tTime );
minuteDiff = ( currentTime - lastAlarm ) / (60);
minutes = configuration->getConfig()->getSnoozeTime() - minuteDiff - 1;
seconds = 60 - ( currentTime - lastAlarm ) % 60;
if( minutes < 0 )
{
minutes = 0;
seconds = 0;
}
if( seconds == 60 )
{
minutes += 1;
seconds = 0;
}
snooze->setTimer( minutes, seconds );
if( minuteDiff >= configuration->getConfig()->getSnoozeTime() )
{
time( &lastAlarm );
alarm->setState( STATE_ALARMING );
//snooze->ShowWindow( SW_NORMAL );
snooze->enableSnooze();
ret = SendMessage(plugin.hwndParent, WM_USER , 0l , 102);
// No fade in -> we set volume HERE
if(configuration->getConfig()->getFadeInStatus() == false)
{
ret = SendMessage(plugin.hwndParent, WM_USER , configuration->getConfig()->getAlarmLevel() , 122);
}
else
{
fadeVol = 0;
ret = SendMessage(plugin.hwndParent, WM_USER , 0 , 122); // Fade in
}
}
}
// NOP
if(state == STATE_WAITING)
{
}
// Alarm is triggered -> load playlist etc.
if(state == STATE_ALARM_TRIGGER)
{
time( &fadeStarted );
fadeVol = 0;
if( configuration->getConfig()->getPlaylistStatus() == false )
{
configuration->getConfig()->getPlaylistName( buffer );
fstream* playliststream = new fstream(buffer, ios::in | ios::nocreate, filebuf::sh_read);
// Check if file was opened successfully
if(playliststream->is_open() == TRUE)
{
ret = SendMessage(plugin.hwndParent, WM_USER , 0 , 101); // Clear playlist
shellplaycommand[0] = '\0';
strcat( shellplaycommand, winampdir );
strcat( shellplaycommand, "winamp.exe /ADD " );
strcat( shellplaycommand, "\"" );
strcat( shellplaycommand, buffer );
strcat( shellplaycommand, "\"" );
// Tell winamp to load our playlist
::WinExec( shellplaycommand, false);
}
}
configuration->getConfig()->getRepeatStatus() ? SendMessage( plugin.hwndParent, WM_USER , 1 , 253 ) : SendMessage( plugin.hwndParent, WM_USER , 0 , 253 );
configuration->getConfig()->getShuffleStatus() ? SendMessage( plugin.hwndParent, WM_USER , 1 , 252 ) : SendMessage( plugin.hwndParent, WM_USER , 0 , 252 );
// Trigger acknowledged -> alarming... NOTE: MUST BE TRIGGERED BEFORE WinExec() OR KABOOM! Recursion and stack overflow 8)
alarm->setState(STATE_ALARMING);
// Set volume to 0
SendMessage(plugin.hwndParent, WM_USER , 0 , 122);
alarmExecuted = false; // Mark alarm not yet executed (needed by the STATE_ALARMING)
if( configuration->getConfig()->getSnoozeStatus() == true )
{
if( snoozeWindowOpen == false)
{
snooze = new CSnoozeAlarmDlg();
snooze->init( plugin.hwndParent );
snooze->Create( IDD_SNOOZEDIALOG );
snooze->CenterWindow( CWnd::GetDesktopWindow() );
snooze->ShowWindow( SW_SHOW );
snoozeWindowOpen = true;
}
}
}
if(state == STATE_ALARMING)
{
// Executed once after alarm trigger
if(alarmExecuted == false)
{
// Reset the fade volume
fadeVol = 0;
// Check if winamp is already playing .>
ret = SendMessage( plugin.hwndParent, WM_USER, 0, 104 );
// Play it, Sam
ret = SendMessage(plugin.hwndParent, WM_COMMAND, 0l , 100 );
// No fade in -> we set volume HERE
if(configuration->getConfig()->getFadeInStatus() == false)
{
// Set alarm volume
ret = SendMessage(plugin.hwndParent, WM_USER , configuration->getConfig()->getAlarmLevel() , 122);
}
else
{
ret = SendMessage(plugin.hwndParent, WM_USER , 0 , 122); // Fade in
}
alarmExecuted = true;
}
// Here we do fade in etc.
if(message != WM_USER)
{
if(configuration->getConfig()->getFadeInStatus() == true)
{
if( fadeVol < configuration->getConfig()->getAlarmLevel() )
{
ret = SendMessage( plugin.hwndParent, WM_USER , fadeVol , 122 );
}
}
ret = SendMessage(plugin.hwndParent,WM_USER, 0l, 104); // Check whether we are playing
// if WinAmp is stopped -> we go to wait-state
if(ret != 1)
{
if( snoozeWindowOpen == true )
{
snoozeWindowOpen = false;
snooze->DestroyWindow();
delete snooze;
}
repeatSet == true ? SendMessage( plugin.hwndParent, WM_USER , 1 , 253 ) : SendMessage( plugin.hwndParent, WM_USER , 0 , 253 );
shuffleSet == true ? SendMessage( plugin.hwndParent, WM_USER , 1 , 252 ) : SendMessage( plugin.hwndParent, WM_USER , 0 , 252 );
alarm->setState(STATE_WAITING);
}
}
}
return CallWindowProc(lpWndProcOld,hwnd,message,wParam,lParam);
}
extern "C" void config()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
// Open configuration dialog if it is not already open
if( cfgWindowOpen != true)
{
// Set correct values for configuration dialog
alarm->disableAlarm();
cfg = new CConfigAlarmDlg();
cfg->init(configuration, plugin.hwndParent);
cfg->Create( IDD_CONFIGALARMDLG );
cfg->ShowWindow( SW_SHOWNORMAL );
cfgWindowOpen = true;
}
else
{
cfg->SetFocus();
}
}
extern "C" int init()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
char* charIndex;
int index;
alarmExecuted = false;
// Get the winamp plugin directory
GetModuleFileName(plugin.hDllInstance,plugindir,sizeof(plugindir));
charIndex = plugindir+lstrlen(plugindir); // Go to the end of string
while (charIndex >= plugindir && *charIndex != '\\') charIndex--; // Go back until we hit the directory separator
index = charIndex - plugindir;
plugindir[index + 1] = '\0'; // Cut the relevant part by placing a null-mark
// Get the Winamp-directory
strcpy(winampdir, plugindir);
charIndex = (winampdir + lstrlen(winampdir) - 2); // Go to the end of string
while (charIndex >= winampdir && *charIndex != '\\') charIndex--; // Go back until we hit the directory separator
index = charIndex - winampdir;
winampdir[index + 1] = '\0'; // Cut the relevant part by placing a null-mark
strcat(plugindir, iniFileName);
configuration = new CConfiguration();
alarm = new CAlarm();
configuration->readConfiguration(plugindir);
alarm->init(configuration); // Pass CConfiguration to Alarm for settings
lpWndProcOld = (WNDPROC)GetWindowLong(plugin.hwndParent,GWL_WNDPROC);
SetWindowLong(plugin.hwndParent,GWL_WNDPROC,(long)WndProc);
return 0;
}
extern "C" void quit()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
// Add exit preparations
}
extern "C" {
_declspec(dllexport) winampGeneralPurposePlugin * winampGetGeneralPurposePlugin()
{
//AFX_MANAGE_STATE(AfxGetStaticModuleState());
return &plugin;
}
}
| [
"gillet@03ee7669-e0e8-0310-81e0-e03ded02296e"
]
| [
[
[
1,
472
]
]
]
|
29f6e79d43c471ced37ef69b1dcaf125e08062e9 | 45c0d7927220c0607531d6a0d7ce49e6399c8785 | /GlobeFactory/src/gfx/material_def/text.hh | ead5afae13b3e1b43e32bc365cb2ddf723db5468 | []
| no_license | wavs/pfe-2011-scia | 74e0fc04e30764ffd34ee7cee3866a26d1beb7e2 | a4e1843239d9a65ecaa50bafe3c0c66b9c05d86a | refs/heads/master | 2021-01-25T07:08:36.552423 | 2011-01-17T20:23:43 | 2011-01-17T20:23:43 | 39,025,134 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,602 | hh | ////////////////////////////////////////////////////////////////////////////////
// Filename : text.hh
// Authors : Creteur Clement
// Last edit : 09/03/10 - 20h06
// Comment :
////////////////////////////////////////////////////////////////////////////////
#ifndef MATERIAL_DEF_TEXT_HH
#define MATERIAL_DEF_TEXT_HH
#include "../../useful/all.hh"
#include "../material.hh"
#include "../material_type_descriptor.hh"
#include "../font_mng.hh"
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
class TextMaterial : public Material
{
public:
TextMaterial(Font* parFont, const std::string& parText, Vector2i& parSize, int parStyle);
~TextMaterial();
void PreRender();
void PostRender();
inline virtual bool HasAlpha() const {return true;}
private:
unsigned MTextureId;
Font* MFont;
};
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
class TextMaterialDescriptor : public MaterialTypeDescriptor
{
public:
TextMaterialDescriptor();
virtual ~TextMaterialDescriptor();
virtual TextMaterial* Load(XmlTree& parXmlFile) const;
virtual void PreRender() const;
virtual void PostRender() const;
};
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
#endif
| [
"creteur.c@8e971d8e-9cf3-0c36-aa0f-a7c54ab41ffc"
]
| [
[
[
1,
51
]
]
]
|
017a32399621637a7288a5e56b016fe2caaed961 | 3bf3c2da2fd334599a80aa09420dbe4c187e71a0 | /VTD_main.cpp | 7f9eae0912eefc718909d6456153d138f3902666 | []
| no_license | xiongchiamiov/virus-td | 31b88f6a5d156a7b7ee076df55ddce4e1c65ca4f | a7b24ce50d07388018f82d00469cb331275f429b | refs/heads/master | 2020-12-24T16:50:11.991795 | 2010-06-10T05:05:48 | 2010-06-10T05:05:48 | 668,821 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 16,744 | cpp | #include <stdlib.h>
//#include <iostream>
#include <vector>
#include <map>
#include <time.h>
#ifdef __unix__
#include <GL/glut.h>
#endif
#ifdef __APPLE__
#include "GLUT/glut.h"
#endif
#ifdef _WIN32
#include <gl/glut.h>
#endif
#include "MyVector.h"
#include "Camera.h"
#include "GameGrid.h"
#include "Player.h"
#include "PlayerAI.h"
#include "lighting.h"
#include "constants.h"
#include "UI.h"
#include "models.h"
#include "Scenery.h"
#include "Projectile.h"
#if VTD_SOUNDS
#include "GameSounds.h"
#endif
const int PLAYER_WIN = 0;
const int COMPUTER_WIN = 1;
int GW, GH;
//Camera variables
MyVector camera;//Camera's positon held by x, y, z,
//the lookat held by i, j, k
Camera cam;
MyVector newCam;
MyVector u;
MyVector v;
MyVector w;
float theta = 0.0;
float phi = 0.0;
Player p1;
PlayerAI opponent;
int tlx, tly;
int ulx, uly;
std::vector<Button*> buttons;
bool clicked = false;
int last_time;
int last_cycle;
bool paused = false;
bool gameOver = false;
bool exitting = false;
bool starting = true;
int winner = 0;
GLuint winTexture;
GLuint startTexture;
Scenery scene("scenery.grid", &p1);
GameSounds sound;
void drawBlueScreen(void);
void drawWinScreen(void);
void drawIntroScreen(void);
void place_lights()
{
GLfloat light_pos2[4] = {0.25, 3.0, 0.25, 1.0};
glLightfv(GL_LIGHT1, GL_POSITION, light_pos2);
GLfloat light_pos3[4] = {12.25, 3.0, 0.25, 1.0};
glLightfv(GL_LIGHT2, GL_POSITION, light_pos3);
}
void display(){
if(exitting) {
exit(0);
return;
}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClearColor(0.0f,0.0f,0.0f,0.0f); // Black Background
glPushMatrix();
gluLookAt(cam.getCamX(), cam.getCamY(), cam.getCamZ(),
cam.getLookAtX(), cam.getLookAtY(), cam.getLookAtZ(),
0.0, 1.0, 0.0);
place_lights();
if(!gameOver)
{
if(starting)
{
glPushMatrix();
//glTranslatef(.5,.5,.5);
drawIntroScreen();
glPopMatrix();
}
glPushMatrix();
scene.draw();
glPopMatrix();
glPushMatrix();
if(placingTower){
setMaterial(Exp);
glNormal3f(0.0, 1.0, 0.0);
glBegin(GL_POLYGON);{
glVertex3f(worldX - GRID_SIZE*2.0, 0.001, worldZ - GRID_SIZE*2.0);
glVertex3f(worldX - GRID_SIZE*2.0, 0.001, worldZ + GRID_SIZE*2.0);
glVertex3f(worldX + GRID_SIZE*2.0, 0.001, worldZ + GRID_SIZE*2.0);
glVertex3f(worldX + GRID_SIZE*2.0, 0.001, worldZ - GRID_SIZE*2.0);
}glEnd();
}
if(towerSelected){
setMaterial(Exp);
glNormal3f(0.0, 1.0, 0.0);
glBegin(GL_POLYGON);{
glVertex3f(towerSelect->getX() - GRID_SIZE*2.0 + P1_POSX, 0.001, towerSelect->getZ() - GRID_SIZE*2.0 + P1_POSZ);
glVertex3f(towerSelect->getX() - GRID_SIZE*2.0 + P1_POSX, 0.001, towerSelect->getZ() + GRID_SIZE*2.0 + P1_POSZ);
glVertex3f(towerSelect->getX() + GRID_SIZE*2.0 + P1_POSX, 0.001, towerSelect->getZ() + GRID_SIZE*2.0 + P1_POSZ);
glVertex3f(towerSelect->getX() + GRID_SIZE*2.0 + P1_POSX, 0.001, towerSelect->getZ() - GRID_SIZE*2.0 + P1_POSZ);
}glEnd();
}
p1.draw(placingTower); // GL_RENDER for normal, GL_SELECT for picking.
opponent.player.draw(false);
//drawProjectiles();
glPopMatrix();
vfc::extractPlanes();
glColor3f(0.8, 0.5, 0.3);
float lx = tlx*2.0*GRID_SIZE - GRID_SIZE*float(GRID_WIDTH) + GRID_SIZE + (GRID_SIZE * 2);
float lz = tly*2.0*GRID_SIZE - GRID_SIZE*float(GRID_HEIGHT) + GRID_SIZE + (GRID_SIZE * 2);
// draw root directories
glPushMatrix();
glTranslatef(0.0, 2 * GRID_SIZE, 1.0 * GRID_HEIGHT * GRID_SIZE + (GRID_SIZE * 8));
glPushMatrix();
glScalef(0.25, 0.25, 0.25);
glCallList(vtd_dl::rootDL);
glPopMatrix();
glTranslatef(GRID_WIDTH * GRID_SIZE * 3, 0.0, 0.0);
glPushMatrix();
glScalef(0.25, 0.25, 0.25);
glCallList(vtd_dl::rootDL);
glPopMatrix();
glPopMatrix();
if(!starting){
glPushMatrix();
renderUI(GW, GH,&p1,&opponent.player,((CYCLE_TIME-last_cycle)/1000.0), GL_RENDER);
glPopMatrix();
}
drawMouseBox(clicked);
}
else
{
if(winner == COMPUTER_WIN)
drawBlueScreen();
else
drawWinScreen();
}
glPopMatrix();
glutSwapBuffers();
}
void reshape(int w, int h){
GW = w;
GH = h;
resetUIPosition();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, 1.0 * w / h, 1.0, 100.0);
glMatrixMode(GL_MODELVIEW);
glViewport(0, 0, w, h);
glutPostRedisplay();
}
void init_lighting() {
//light position
GLfloat light_pos[4] = {0.0, 0.0, 0.0, 1.0};
//light color (ambiant, diffuse and specular)
GLfloat light_amb[4] = {0.3, 0.3, 0.3, 1.0};
GLfloat light_diff[4] = {0.3, 0.3, 0.3, 1.0};
GLfloat light_spec[4] = {0.0, 0.0, 0.0, 1.0};
//turn on light0
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_POSITION, light_pos);
//set up the diffuse, ambient and specular components for the light
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diff);
glLightfv(GL_LIGHT0, GL_AMBIENT, light_amb);
glLightfv(GL_LIGHT0, GL_SPECULAR, light_spec);
const GLfloat light_atten = 0.3f;
//light position
GLfloat light_pos2[4] = {0.25, 2.0, 0.25, 1.0};
//light color (ambiant, diffuse and specular)
GLfloat light_amb2[4] = {0.0, 0.0, 0.0, 1.0};
GLfloat light_diff2[4] = {0.0, 0.0, 0.4, 1.0};
GLfloat light_spec2[4] = {0.0, 0.0, 0.8, 1.0};
//turn on light0
glEnable(GL_LIGHT1);
glLightfv(GL_LIGHT1, GL_POSITION, light_pos2);
//set up the diffuse, ambient and specular components for the light
glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diff2);
glLightfv(GL_LIGHT1, GL_AMBIENT, light_amb2);
glLightfv(GL_LIGHT1, GL_SPECULAR, light_spec2);
glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, light_atten);
//light position
GLfloat light_pos3[4] = {12.25, 2.0, 0.25, 1.0};
//light color (ambiant, diffuse and specular)
GLfloat light_amb3[4] = {0.0, 0.0, 0.0, 1.0};
GLfloat light_diff3[4] = {0.4, 0.0, 0.0, 1.0};
GLfloat light_spec3[4] = {0.8, 0.0, 0.0, 1.0};
//turn on light0
glEnable(GL_LIGHT2);
glLightfv(GL_LIGHT2, GL_POSITION, light_pos3);
//set up the diffuse, ambient and specular components for the light
glLightfv(GL_LIGHT2, GL_DIFFUSE, light_diff3);
glLightfv(GL_LIGHT2, GL_AMBIENT, light_amb3);
glLightfv(GL_LIGHT2, GL_SPECULAR, light_spec3);
glLightf(GL_LIGHT2, GL_LINEAR_ATTENUATION, light_atten);
//specify our lighting model as 1 normal per face
glShadeModel(SHADING_MODE);
glLightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, 1.0f);
glEnable(GL_NORMALIZE);
}
void drawBitmapString(float x, float y, void *font,char *string) {
glPushMatrix();
char *c;
glRasterPos3f(x, y, 0.1);
for (c=string; *c != '\0'; c++) {
if(*c == '\n') {
y += 18;
glRasterPos3f(x, y, 0.1);
}
else
glutBitmapCharacter(font, *c);
}
glPopMatrix();
}
void drawBlueScreen()
{
//Switch to Ortho
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0, GW, 0, GH, -5, 5);
glScalef(1, -1, 1);
glTranslatef(0, -GH, 0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
//Draw blue screen
glDisable(GL_LIGHTING);
glColor3f(0.0f,0.0f,1.0f);
glBegin(GL_QUADS);
glVertex2f(0,0);
glVertex2f(GW,0);
glVertex2f(GW,GH);
glVertex2f(0,GH);
glEnd();
glTranslatef(0.0f,0.0f,0.1);
int center_x = GW/2.0;
int center_y = GH/2.0;
char *title = "GAME OVER";
char *info = "An exception 06 has occured at 0028:C11B3ADC in VxD DiskTSD(03) +\n00001660. This was called from 0028:C11B40CB in VxD voltrack(04) +\n00000000. System is unable to continue running.";
char *instr = "* Press any key to attempt to continue.\n* Press CTRL+ALT+RESET to restart your computer. You will\n lose any unsaved information in all applications.";
char *lose = "Your root folder has been corrupted. You have lost";
char *todo = "Press SPACE key to retry";
const int title_W = getBitmapStringWidth(GLUT_BITMAP_9_BY_15,title);;
const int title_Y = -128;
const int info_W = getBitmapStringWidth(GLUT_BITMAP_9_BY_15,info);
const int info_Y = -80;
const int instr_W = getBitmapStringWidth(GLUT_BITMAP_9_BY_15,instr);
const int instr_Y = 0;
const int lose_W = getBitmapStringWidth(GLUT_BITMAP_9_BY_15,lose);
const int lose_Y = 80;
const int todo_W = getBitmapStringWidth(GLUT_BITMAP_9_BY_15,todo);
const int todo_Y = 120;
glColor3f(1.0f,1.0f,1.0f);
glBegin(GL_QUADS);
glVertex2f(center_x - title_W/2 - 10,center_y + title_Y-15);
glVertex2f(center_x + title_W/2 + 10,center_y + title_Y-15);
glVertex2f(center_x + title_W/2 + 10,center_y + title_Y+5);
glVertex2f(center_x - title_W/2 - 10,center_y + title_Y+5);
glEnd();
glColor3f(0.0f,0.0f,1.0f);
drawBitmapString(center_x - title_W/2,center_y + title_Y,GLUT_BITMAP_9_BY_15,title);
glColor3f(1.0f,1.0f,1.0f);
drawBitmapString(center_x - info_W/2,center_y + info_Y,GLUT_BITMAP_9_BY_15,info);
drawBitmapString(center_x - instr_W/2,center_y + instr_Y,GLUT_BITMAP_9_BY_15,instr);
drawBitmapString(center_x - lose_W/2,center_y + lose_Y,GLUT_BITMAP_9_BY_15,lose);
drawBitmapString(center_x - todo_W/2,center_y + todo_Y,GLUT_BITMAP_9_BY_15,todo);
glEnable(GL_LIGHTING);
//Switch back to perspective
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
}
void drawIntroScreen()
{
//Switch to Ortho
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0, GW*2, 0, GH*2, -5, 5);
glScalef(1, -1, 1);
glTranslatef(GW/2, -GH*2 + 16, 0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, startTexture);
glDisable(GL_LIGHTING);
glColor3f(1.0f,1.0f,1.0f);
glBegin(GL_QUADS);
glTexCoord2f(0.0,1.0);
glVertex2f(0,0);
glTexCoord2f(0.0,0.0);
glVertex2f(0,GH);
glTexCoord2f(1.0,0.0);
glVertex2f(GW,GH);
glTexCoord2f(1.0,1.0);
glVertex2f(GW,0);
glEnd();
glEnable(GL_LIGHTING);
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D);
//Switch back to perspective
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
}
void drawWinScreen()
{
//Switch to Ortho
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0, GW, 0, GH, -5, 5);
glScalef(1, -1, 1);
glTranslatef(0, -GH, 0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, winTexture);
glDisable(GL_LIGHTING);
glColor3f(1.0f,1.0f,1.0f);
glBegin(GL_QUADS);
glTexCoord2f(0.0,1.0);
glVertex2f(0,0);
glTexCoord2f(0.0,0.0);
glVertex2f(0,GH);
glTexCoord2f(1.0,0.0);
glVertex2f(GW,GH);
glTexCoord2f(1.0,1.0);
glVertex2f(GW,0);
glEnd();
glEnable(GL_LIGHTING);
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D);
//Switch back to perspective
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
}
void update(int param){
if(exitting) {
exit(0);
return;
}
int this_time = glutGet(GLUT_ELAPSED_TIME);
int dt = this_time - last_time;
//fps = 1000.00/dt;
last_time = this_time;
if(!paused && !starting) {
last_cycle += dt;
}
if(controls::keyMap[controls::BACKWARD]){
cam.moveBackward();
}
if(controls::keyMap[controls::FOREWARD]){
cam.moveForward();
}
if(controls::keyMap[controls::RIGHT]){
cam.moveRight();
}
if(controls::keyMap[controls::LEFT]){
cam.moveLeft();
}
if(controls::keyMap[controls::ZOOM_IN]){
cam.zoomIn();
}
if(controls::keyMap[controls::ZOOM_OUT]){
cam.zoomOut();
}
if(!paused && !starting){
if(CYCLE_TIME < last_cycle){
p1.calcResources();
opponent.player.calcResources();
//std::cout << "INCOME! " << p1.getIncome() << std::endl;
last_cycle -= CYCLE_TIME;
}
p1.update(dt);
opponent.update(dt);
sound.checkForEnd();
if(p1.getLives() <= 0) {
paused = true;
gameOver = true;
winner = COMPUTER_WIN;
}
if(opponent.player.getLives() <= 0) {
paused = true;
gameOver = true;
winner = PLAYER_WIN;
}
}
else if (!paused) {
p1.pGrid.update(dt);
opponent.player.pGrid.update(dt);
}
glutPostRedisplay();
glutTimerFunc(10, update, 0);
}
void keyboard(unsigned char key, int x, int y){
if(gameOver) {
if(key == 32) {
p1.reset();
opponent.reset();
resetUI();
gameOver = false;
paused = false;
starting = true;
}
}
else
{
switch(key){
case 'l': case 'L':
for(int i = 0; i < GRID_WIDTH; i+=2){
p1.placeTower(i, GRID_HEIGHT/2, 12);
}
break;
case 't': case 'T':
p1.placeTower(tlx, tly, 16);
break;
case 'r': case 'R':
p1.destroyTower(tlx, tly);
break;
case 'p': case 'P':
if(!gameOver)
paused = !paused;
break;
case 'k': case 'K':
p1.reset();
opponent.reset();
resetUI();
gameOver = false;
paused = false;
starting = true;
break;
case 'm': case 'M':
sound.toggleMusic();
break;
case 27:
exitting = true;
exit(0);
break;
case 13:
starting = false;
break;
}
controls::keyMap[key] = true;
}
}
void keyboardUp(unsigned char key, int x, int y){
if(exitting) {
exit(0);
return;
}
controls::keyMap[key] = false;
}
void specKeys(int key, int x, int y){
switch(key){
case GLUT_KEY_DOWN:
// ++tly;
++uly;
break;
case GLUT_KEY_UP:
// --tly;
--uly;
break;
case GLUT_KEY_RIGHT:
// ++tlx;
++ulx;
break;
case GLUT_KEY_LEFT:
// --tlx;
--ulx;
break;
}
}
int main(int argc, char** argv){
//Initialize globals
//srand(time(NULL));
camera.setPosition(0.0, 10.0, 10.0);
camera.setVector(0.0, 0.0, 0.0);
newCam = camera;
u.setVector(-1.0, 0.0, 0.0);
v.setVector(0.0, 1.0, 0.0);
w.setVector(0.0, 0.0, -1.0);
p1.setOpponent(&(opponent.player));
p1.setPosition(P1_POSX, P1_POSY, P1_POSZ);
opponent.player.setPosition(OPP_POSX2, OPP_POSY2, OPP_POSZ2);
cam.setListenerPos();
sound.toggleMusic();
tlx = 0;
tly = 0;
ulx = 0;
uly = 0;
//Initialize window
GW = 800;
GH = 600;
/* initialize buttons */
GLfloat col[] = {1.0,1.0,1.0};
for (int i = 0; i < 18; i++) {
Button * newBtn = new Button(i, col, NULL);
buttons.push_back(newBtn);
}
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(GW, GH);
glutInitWindowPosition(100, 100);
glutCreateWindow("Crash & Burn");
glClearColor(1.0, 1.0, 1.0, 1.0);
//Register GLUT callbacks
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
glutKeyboardUpFunc(keyboardUp);
glutSpecialFunc(specKeys);
glutMouseFunc(mouseClick);
glutPassiveMotionFunc(mouseMotion);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
init_lighting();
composeDisplayLists();
glutTimerFunc(1000/60, update, 0);
initializeParticleTextures();
buttons.at(17)->setObject(new BasicTower(float(-0.5)*GRID_SIZE*2.0 + GRID_SIZE, 0.25,
float(-0.5)*GRID_SIZE*2.0 + GRID_SIZE, 0, 0));
buttons.at(16)->setObject(new FreezeTower(float(-0.5)*GRID_SIZE*2.0 + GRID_SIZE, 0.25,
float(-0.5)*GRID_SIZE*2.0 + GRID_SIZE, 0, 0));
buttons.at(15)->setObject(new FastTower(float(-0.5)*GRID_SIZE*2.0 + GRID_SIZE, 0.25,
float(-0.5)*GRID_SIZE*2.0 + GRID_SIZE, 0, 0));
buttons.at(14)->setObject(new SlowTower(float(-0.5)*GRID_SIZE*2.0 + GRID_SIZE, 0.25,
float(-0.5)*GRID_SIZE*2.0 + GRID_SIZE, 0, 0));
buttons.at(13)->setObject(new TrapTower(float(-0.5)*GRID_SIZE*2.0 + GRID_SIZE, 0.25,
float(-0.5)*GRID_SIZE*2.0 + GRID_SIZE, 0, 0));
buttons.at(12)->setObject(new WallTower(float(-0.5)*GRID_SIZE*2.0 + GRID_SIZE, 0.25,
float(-0.5)*GRID_SIZE*2.0 + GRID_SIZE, 0, 0));
initializeUI();
winTexture = LoadHQTexture("Win.bmp");
startTexture = LoadHQTexture("title.bmp");
p1.pGrid.initialize(false);
opponent.player.pGrid.initialize(true);
scene.initialize();
glutMainLoop();
}
| [
"agonza40@05766cc9-4f33-4ba7-801d-bd015708efd9",
"tcasella@05766cc9-4f33-4ba7-801d-bd015708efd9",
"pearson@05766cc9-4f33-4ba7-801d-bd015708efd9",
"kehung@05766cc9-4f33-4ba7-801d-bd015708efd9",
"jlangloi@05766cc9-4f33-4ba7-801d-bd015708efd9"
]
| [
[
[
1,
4
],
[
14,
15
],
[
17,
20
],
[
22,
25
],
[
27,
31
],
[
35,
46
],
[
48,
48
],
[
50,
53
],
[
57,
57
],
[
62,
62
],
[
67,
67
],
[
77,
89
],
[
105,
159
],
[
163,
175
],
[
177,
186
],
[
188,
188
],
[
192,
198
],
[
232,
232
],
[
235,
238
],
[
402,
402
],
[
407,
440
],
[
442,
442
],
[
444,
454
],
[
460,
465
],
[
467,
473
],
[
478,
490
],
[
493,
504
],
[
509,
513
],
[
515,
517
],
[
522,
528
],
[
530,
532
],
[
534,
536
],
[
538,
540
],
[
542,
547
],
[
549,
550
],
[
552,
563
],
[
566,
570
],
[
572,
572
],
[
574,
597
],
[
621,
621
],
[
623,
623
]
],
[
[
5,
5
],
[
26,
26
],
[
32,
34
],
[
54,
56
],
[
58,
59
],
[
61,
61
],
[
63,
65
],
[
68,
76
],
[
90,
93
],
[
101,
104
],
[
160,
162
],
[
176,
176
],
[
187,
187
],
[
189,
191
],
[
199,
231
],
[
233,
234
],
[
239,
253
],
[
256,
319
],
[
329,
329
],
[
362,
389
],
[
391,
401
],
[
403,
406
],
[
441,
441
],
[
443,
443
],
[
455,
459
],
[
466,
466
],
[
474,
477
],
[
491,
492
],
[
505,
508
],
[
514,
514
],
[
518,
521
],
[
548,
548
],
[
571,
571
],
[
573,
573
],
[
598,
615
],
[
617,
619
]
],
[
[
6,
13
],
[
16,
16
],
[
21,
21
],
[
47,
47
],
[
622,
622
]
],
[
[
49,
49
],
[
390,
390
],
[
529,
529
],
[
533,
533
],
[
537,
537
],
[
541,
541
],
[
551,
551
],
[
564,
565
],
[
620,
620
]
],
[
[
60,
60
],
[
66,
66
],
[
94,
100
],
[
254,
255
],
[
320,
328
],
[
330,
361
],
[
616,
616
]
]
]
|
439e276777be0bea8d0e9cd5da8bcca75faa9913 | b505ef7eb1a6c58ebcb73267eaa1bad60efb1cb2 | /source/sound/soundfile.h | 6ef7a29cb29c9f05af5e2d6df409a594ba6c2fe0 | []
| 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 | 2,901 | h | #ifndef maid2_sound_soundfile_h
#define maid2_sound_soundfile_h
#include"../config/define.h"
#include"../auxiliary/globalpointer.h"
#include"../auxiliary/jobcachetemplate.h"
#include"../auxiliary/string.h"
#include"../auxiliary/memorybuffer.h"
#include"soundcore.h"
#include"soundmessagebase.h"
#include"pcmreader/ipcmreader.h"
#include"pcmreader/custompcmreader.h"
#include<vector>
namespace Maid {
namespace KEEPOUT
{
class SoundFileInput : public IJobInput
{
public:
enum LOADTYPE
{
LOADTYPE_AUTO,
LOADTYPE_STATIC,
LOADTYPE_STREAM,
};
SoundFileInput( const String& name, SoundCore* p, LOADTYPE t, const SOUNDJUMPPOINTLIST& List )
:FileName(name), pCore(p),Type(t),JumpList(List){}
String FileName;
SoundCore* pCore;
LOADTYPE Type;
SOUNDJUMPPOINTLIST JumpList;
};
inline bool operator < ( const SoundFileInput& lha, const SoundFileInput& rha )
{
if( lha.FileName < rha.FileName ) { return true; }
if( lha.FileName > rha.FileName ) { return false; }
return lha.Type < rha.Type;
}
class SoundFileOutput : public IJobOutput
{
public:
SPSOUNDOBJECTINFO pInfo;
SPSOUNDMESSAGE pMessage;
};
class SoundFileFunction : public IJobFunction
{
public:
void Execute( const IJobInput& Input, IJobOutput& Output );
private:
SPSOUNDMESSAGE CreateStatic( const SPMEMORYBUFFER& pFileImage, const SPPCMREADER& pDecorder, const String& id );
SPSOUNDMESSAGE CreateStream( const SPMEMORYBUFFER& pFileImage, const SPPCMREADER& pDecorder, const CustomPCMReader::JUMPPOINTLIST& jump );
};
}
class SoundFile
: public GlobalPointer<SoundCore>
{
public:
SoundFile();
SoundFile( const SoundFile& obj );
virtual ~SoundFile();
void LoadFile( const String& filename );
void LoadFileStream( const String& filename );
void LoadFileStream( const String& filename, const SOUNDJUMPPOINTLIST& List );
void LoadFileStatic( const String& filename );
void Destroy();
bool IsLoading()const;
void Play();
void Stop();
void SetLoopState( bool IsLoop );
void SetPosition( double time );
void SetVolume( double Volume );
bool IsPlay() const;
bool IsLoopState() const;
double GetPosition() const;
double GetVolume() const;
bool IsEmpty() const;
String GetFileName() const;
SoundFile& operator=(const SoundFile &obj);
private:
void LoadCheck();
typedef JobCacheTemplate<KEEPOUT::SoundFileInput,KEEPOUT::SoundFileFunction, KEEPOUT::SoundFileOutput> CACHE;
CACHE m_Cache;
SPSOUNDOBJECTINFO m_pInfo;
bool m_IsPlay;
bool m_IsLoopPlay;
double m_Volume;
double m_Position;
};
}
#endif
| [
"[email protected]"
]
| [
[
[
1,
113
]
]
]
|
68c5049c43bbc73e0e4cc490ccce1547654bb20e | bdb1e38df8bf74ac0df4209a77ddea841045349e | /CapsuleSortor/Version 1.0 -2.0/CapsuleSortor-10-11-15/ToolCVB/CapsuleProc.cpp | 5a2f56b36e3f6c9c9dfa4b06f3a6019fc56c0a64 | []
| no_license | Strongc/my001project | e0754f23c7818df964289dc07890e29144393432 | 07d6e31b9d4708d2ef691d9bedccbb818ea6b121 | refs/heads/master | 2021-01-19T07:02:29.673281 | 2010-12-17T03:10:52 | 2010-12-17T03:10:52 | 49,062,858 | 0 | 1 | null | 2016-01-05T11:53:07 | 2016-01-05T11:53:07 | null | GB18030 | C++ | false | false | 39,859 | cpp | #include <emmintrin.h>
#include "CapsuleProc.h"
#include "HorizonExtend.h"
#include "Translation.h"
#include "TTimediff.h"
CapsuleProc::ESaveState CapsuleProc::m_eSaveState = eNoSave;
size_t CapsuleProc::m_allCount = 0; //全部胶囊数量
size_t CapsuleProc::m_badCount = 0; //次品胶囊数量
SortObserver CapsuleProc::m_sortObserver = SortObserver::TheSortObserver(); //调试观测工具
CapsuleProc::CapsuleProc()
: m_cvbImg(0),
m_cvbProfileImg(0),
m_profileBlob(0),
m_cvbBlob(NULL),
m_lightMeter(0)
{ }
CapsuleProc::~CapsuleProc()
{
ReleaseImage(m_cvbImg);
ReleaseImage(m_cvbProfileImg);
ReleaseImage(m_profileBlob);
ReleaseImage(m_cvbBlob);
LMDestroy(m_lightMeter);
}
IMG CapsuleProc::ObservedIMG( )
{
return m_sortObserver.GetImage();
}
bool CapsuleProc::ObservedIMG( SortObserver::ETarget eTarget, IMG img )
{
return m_sortObserver.ObserverIMG( eTarget, img);
}
double CapsuleProc::ObservedParam( )
{
return m_sortObserver.GetParam();
}
void CapsuleProc::ObservingTarget(unsigned int spec)
{
m_sortObserver.SpecifyTarget(spec);
}
/***************************************************************
*函数名称: ReInit
*
* 参数: TImgDim 图像尺寸信息
*
* 返回值: 成功 true, 失败 false
*
* 功能: 初始化图像处理函数
****************************************************************/
bool CapsuleProc::ReInit (const TImgDim& imgDimension)
{
if(m_dim == imgDimension) return true;
m_dim = imgDimension;
ReleaseImage(m_cvbImg);
ReleaseImage(m_cvbProfileImg);
ReleaseImage(m_profileBlob);
ReleaseImage(m_cvbBlob);
LMDestroy(m_lightMeter);
m_imgBuffer.ReInit(m_dim, 30);
m_rawImage = TAlloc<PixelMem>(m_dim.bytesPerRow * m_dim.height, e16ByteAlign);
long pitchPlane = (m_dim.bytesPerPixel == 1) ? 0 : 1;
if(0 != CreateImageFromPointer( m_rawImage.Base(),
m_rawImage.Size(),
m_dim.width,
m_dim.height,
m_dim.bytesPerPixel, 8, m_dim.bytesPerPixel,
m_dim.bytesPerRow,
pitchPlane, 0, 0, 0,
m_cvbImg))
{
return false;
}
TRect2D<int> boundary(TPoint2D<int>(0, 0), m_dim.width, m_dim.height);
m_profileImage = TImage<PelGray8> (boundary, e16ByteAlign);
if(0 != CreateImageFromPointer( m_profileImage.Base(),
m_profileImage.RowSpace() * m_profileImage.Height(),
m_profileImage.Width(),
m_profileImage.Height(),
1, 8, 1,
m_profileImage.RowSpace(),
0, 0, 0, 0,
m_cvbProfileImg))
{
return false;
}
m_cvbBlob = FBlobCreate(m_cvbImg, 0);
m_profileBlob = FBlobCreate(m_cvbProfileImg, 0);
if(0 != LMCreate(&m_lightMeter))
{
return false;
}
return true;
}
/***************************************************************
*函数名称: SetRawImage
*
* 参数: pMem 原始图像内存指针
* bytes 原始图像大小
*
* 返回值: 成功 true
* 失败 false
*
* 功能: 拷贝图像内存数据
****************************************************************/
bool CapsuleProc::SetRawImage(void* pMem, size_t bytes)
{
bool success = false;
try
{
if ((0!=pMem) && (m_rawImage.Size()==bytes))
{
memcpy(m_rawImage.Base(), pMem, m_rawImage.Size());
success = true;
}
}
catch(...)
{
FILE* pFile = NULL;
fopen_s(&pFile,"D:\\SetRawImage.txt", "wb");
fwrite("SetRawImage error", sizeof(char), strlen("SetRawImage error"), pFile);
fclose(pFile);
}
return success;
}
/***************************************************************
*函数名称: GetRawImage
*
* 参数: 无
*
* 返回值: 原始图像句柄
*
* 功能: 得到原始图像
****************************************************************/
IMG CapsuleProc::GetRawImage( )
{
return m_cvbImg;
}
/***************************************************************
*函数名称: CheckPosition
*
* 参数: posX 当前点的X坐标
* posY 当前点的Y坐标
*
* 返回值: 当前胶囊在图像中的序号
*
* 功能: 得到当前胶囊在图像中的序号,posX,posY为胶囊的中心在图像中的坐标
****************************************************************/
int CapsuleProc::CheckPosition(long posX, long posY)
{
int interval = m_dim.width / CAPSULENUM;
return posX / interval;
}
/***************************************************************
*函数名称: IsCapsuleShort
*
* 参数: stdHeight 标准高度
* realHeight 实际高度
* tolerance 高度容差
*
* 返回值: 成功 true
* 失败 false
*
*
* 功能: 判断胶囊是否短体
****************************************************************/
bool CapsuleProc::IsCapsuleShort( size_t realHeight,
size_t realWidth,
size_t stdHeight,
size_t tolerance)
{
bool isShort = (realHeight) < (stdHeight - tolerance);
bool isNarrow = realWidth < m_capsuleParam.capsuleDim.width/2;
return isShort || isNarrow;
}
/***************************************************************
*函数名称: FindOverlapCenter
*
* 参数: rawSubImg 原始子图像
* centerX 套合区横坐标
* centerY 套合区纵坐标
*
* 返回值: 成功 true
* 失败 false
*
*
* 功能: 得到胶囊套合区中点的坐标
****************************************************************/
bool CapsuleProc::FindOverlapCenter(IMG rawSubImg,
long& centerX,
long& centerY)
{
if(!IsImage(rawSubImg))
{
centerX = -1;
centerY = -1;
return false;
}
long width = ImageWidth (rawSubImg);
long height = ImageHeight(rawSubImg);
long xc = width/2;
long yc0 = height/2 - height/8;
long yc1 = height/2 + height/8;
double upMean = 0;
double downMean = 0;
long offsetX = width/4;
long offsetY = 5;
TArea upArea = CreateTArea(xc - offsetX, yc0 + offsetY, 2*offsetX, 2*offsetY);
LMSetImage (m_lightMeter, rawSubImg);
LMSetProcessFlag (m_lightMeter, 0, TRUE);
LMSetArea (m_lightMeter, 0, upArea);
LMExecute (m_lightMeter);
LMGetStatisticMean (m_lightMeter, 0, &upMean);
TArea downArea = CreateTArea(xc - offsetX, yc1 - offsetY, 2*offsetX, -2*offsetY);
LMSetImage (m_lightMeter, rawSubImg);
LMSetProcessFlag (m_lightMeter, 0, TRUE);
LMSetArea (m_lightMeter, 0, downArea);
LMExecute (m_lightMeter);
LMGetStatisticMean (m_lightMeter, 0, &downMean);
centerX = xc;
centerY = upMean <= downMean ? yc0 : yc1;
return true;
}
/***************************************************************
*函数名称: FindFirstEdgeY
*
* 参数: image 子图像
* area 边沿检测区域
* density 边沿检测密度
* threshold 阈值大小
*
* 返回值: 边沿点的坐标
*
*
* 功能: 得到胶囊的边沿的点的坐标
****************************************************************/
long CapsuleProc::FindFirstEdgeY( IMG image, TArea area, long density, double threshold)
{
long yPos = -1;
TEdgeResult edge;
if(CFindFirstEdge (image, 0, density, area, threshold, TRUE, edge))
{
yPos = long(edge.y);
}
return yPos;
}
/***************************************************************
*函数名称: FindUpDownEdge
*
* 参数: image 子图像
* density 边沿检测的密度
* threshold 阈值
* upPos 上边沿
* downPos 下边沿
*
* 返回值: 成功 true
* 失败 false
*
*
* 功能: 得到胶囊套合区的上下边沿的坐标
****************************************************************/
bool CapsuleProc::FindUpDownEdge( IMG image, long density,double threshold, long &upPos, long &downPos)
{
long overX =0, overY =0;
FindOverlapCenter(image, overX, overY);
long roiWidth = ImageWidth(image)/2;
long roiHeight = ImageHeight(image)/3;
TArea areaUp = CreateTArea(overX -roiWidth/2, overY, roiWidth, roiHeight);
long yUp = FindFirstEdgeY(image, areaUp, density,threshold);
TArea areaDown = CreateTArea(overX -roiWidth/2, overY, roiWidth, -roiHeight);
long yDown = FindFirstEdgeY(image, areaDown, density, threshold);
upPos = yUp;
downPos = yDown;
return ((upPos != -1) && (downPos != -1));
}
/***************************************************************
*函数名称: CreateTArea
*
* 参数: orgX 左上角横坐标
* orgY 左上角纵坐标
* width 图像宽度
* height 图像高度
*
* 返回值: TArea对象
*
*
* 功能: 创建图像TArea对象
****************************************************************/
TArea CapsuleProc::CreateTArea( long orgX,
long orgY,
long width,
long height)
{
TArea area;
area.X0 = orgX;
area.Y0 = orgY;
area.X1 = orgX + width;
area.Y1 = orgY;
area.X2 = orgX;
area.Y2 = orgY - height;
return area;
}
/***********************************************************
Name: ShrinkHorizontal
Input: image, shrinkNum
Output: ifsuccess
Description: 对图像水平缩进shrinkNum个像素
************************************************************/
bool CapsuleProc::ShrinkHorizontal( IMG image,
const size_t shrinkNum)
{
unsigned char *pImageBit = NULL;
PVPAT VPA = NULL;
GetImageVPA (image, 0, (void**)&pImageBit, &VPA);
const size_t imageWidth = ImageWidth (image);
const size_t imageHeight = ImageHeight(image);
const size_t halfWidth = imageWidth / 2;
const unsigned char cstVal = 127;
unsigned char* curVal = 0;
if (halfWidth < shrinkNum) { return false; }
for(size_t veCo = 0; veCo < imageHeight; ++veCo)
{
for(size_t i = 0; i <= halfWidth; ++i)
{
curVal = (VPA[veCo].YEntry + pImageBit + VPA[i].XEntry);
if ( cstVal == *curVal) { *curVal = 0; }
else if(0 == *curVal) { continue; }
else
{
for(size_t j = 0; j < shrinkNum; ++j)
{
*(VPA[veCo].YEntry + pImageBit + VPA[j + i].XEntry) = 0;
}
break;
}
}
for(size_t i = imageWidth; i >= halfWidth; --i)
{
curVal = (VPA[veCo].YEntry + pImageBit + VPA[i].XEntry);
if (cstVal == *curVal) { *curVal = 0; }
else if(0 == *curVal) { continue; }
else
{
for(size_t j = 0; j < shrinkNum; ++j)
{
*(VPA[veCo].YEntry + pImageBit + VPA[i - j].XEntry) = 0;
}
break;
}
}
}
return true;
}
/***************************************************************
*函数名称: ShrinkVertical
*
* 参数: image 检测图像
* shrinkNum 纵向缩减的数值
*返回值: 成功 true
* 失败 false
*
* 功能: 对胶囊的图像进行纵向的缩减
****************************************************************/
bool CapsuleProc::ShrinkVertical( IMG image,
const size_t shrinkNum)
{
unsigned char *pImageBit = NULL;
PVPAT VPA = NULL;
GetImageVPA (image, 0, (void**)&pImageBit, &VPA);
const size_t imageWidth = ImageWidth (image);
const size_t imageHeight = ImageHeight(image);
const size_t halfHeight = imageHeight/2;
if (halfHeight < shrinkNum) { return false; }
const unsigned char cstVal = 127;
unsigned char* curVal = 0;
for(size_t i = 0; i < imageWidth; ++i)
{
for(size_t j = 0; j <= halfHeight; ++j)
{
curVal = (VPA[i].XEntry + pImageBit + VPA[j].YEntry);
if (cstVal == *curVal) { *curVal = 0; }
else if (0 == *curVal) { continue; }
else
{
for(size_t eroCount = 0; eroCount < shrinkNum; ++eroCount)
{
*(VPA[i].XEntry + pImageBit + VPA[eroCount + j].YEntry) = 0;
}
break;
}
}
for(size_t j = imageHeight - 1; j >= halfHeight; --j)
{
curVal = (VPA[i].XEntry + pImageBit + VPA[j].YEntry);
if (cstVal == *curVal) { *curVal = 0; }
else if (0 == *curVal) { continue; }
else
{
for(size_t eroCount = 0; eroCount < shrinkNum; ++eroCount)
{
*(VPA[i].XEntry + pImageBit + VPA[ j-eroCount].YEntry) = 0;
}
break;
}
}
}
return true;
}
/*******************************************************************************
* 函数名称: RotateIMG
*
* 参数 :[IN] blobIndex 凹槽序号
* [IN] fluteBlob 凹槽斑点
* [IN] profileBlob 胶囊轮廓斑点
* [IN] rawImg 含有胶囊斑点信息的图像
* [IN] proImg 含有胶囊轮廓信息的图像
* [OUT] &rawSubIMG 含有胶囊斑点信息的子图像
* [OUT] &proSubIMG 含有胶囊轮廓信息的子图像
* [OUT] &posIndex 凹槽序号
*
*
* 功能 :对图像进行分割,取胶囊所在的小的区域,此函数并不对图像进行旋转
*
*
********************************************************************************/
bool CapsuleProc::RotateIMG( size_t blobIndex,
FBLOB profileBlob,
IMG proImg,
IMG &proSubIMG,
size_t &posIndex)
{
long profileCount = 0;
FBlobGetNumBlobs (profileBlob, profileCount);
if ( blobIndex >= static_cast<size_t>(profileCount) )
{
posIndex = -1;
return false;
}
//Get Range
long x0 = 0, y0 = 0, width = 0, height = 0;
FBlobGetBoundingBox (profileBlob, blobIndex, x0, y0, width, height);
posIndex = CheckPosition(x0+width/2, y0+height/2);
IMG proIMGMap = NULL;
CreateImageMap (proImg, x0, y0, x0+width, y0+height, width, height, proIMGMap);
double rabi = 0.0, rabi1 = 0.0, rabi2 = 0.0, momentAngle = 0.0;
FBlobGetMoments (profileBlob, blobIndex, rabi, rabi1, rabi2, momentAngle);
static const double ADIVPI = 180.0 /(4.0*atan(1.0)); //ppi = 180/PI
static const double ANGLE90 = 90; //ppiH = 180/PI*PI/2
double angle = 0.0;
if(momentAngle>=0)
{ angle = (ANGLE90 - ADIVPI * momentAngle); }
else
{ angle = -(ANGLE90 + ADIVPI * momentAngle); }
RotateImage( proIMGMap, angle, IP_Linear, proSubIMG);
TCoordinateMap cm;
InitCoordinateMap(cm);
SetImageCoordinates (proSubIMG, cm);
ShrinkVertical (proSubIMG, m_segmentParam.shrinkY);
ShrinkHorizontal(proSubIMG, m_segmentParam.shrinkX);
ReleaseImage (proIMGMap);
return true;
}
/***************************************************************
*函数名称: RectangleBlob
*
* 参数: IMG 图像
* TRect2D 感兴趣区域
* long 窗口面积
* long 动态阈值
* long 斑点的最小面积
* TBlobTouchBorderFilter 忽略边界
* long 斑点最小宽度
* long 斑点最小高度
* 返回值: 不存在斑点 true,
* 存在斑点 false
*
* 功能: 在指定的区域内采用动态阈值+
* 斑点分析的方法检测是否存在斑点
*
****************************************************************/
bool CapsuleProc::RectangleBlob ( IMG image,
const TRect2D<long>& roi,
long wndSize,
long dynThres,
long minBlobSize,
TBlobTouchBorderFilter ignorBorder,
long minBlobWidth,
long minBlobHeight,
bool alsoReverse)
{
if(!IsImage(image) || roi.IsNull())
{ return true; }
IMG imageROI = NULL;
CreateImageMap(image , roi.x0(), roi.y0(), roi.x1(), roi.y1(), roi.Width(), roi.Height(), imageROI);
bool success = RectBlackBlob(imageROI, wndSize, dynThres, minBlobSize,
ignorBorder, minBlobWidth, minBlobHeight);
if(alsoReverse && success)
{
IMG imageROI2 = NULL;
long maskVal[] = { 255 };
XorConstant(imageROI, maskVal, imageROI2);
success = RectBlackBlob(imageROI2, wndSize, dynThres, minBlobSize,
ignorBorder, minBlobWidth, minBlobHeight);
ReleaseImage(imageROI2);
}
m_sortObserver.ObserverIMG(SortObserver::MPart, imageROI);
m_sortObserver.ObserverIMG(SortObserver::CPart, imageROI);
ReleaseImage(imageROI);
return success;
}
/***************************************************************
*函数名称: RectBlackBlob
*
* 参数: IMG 图像
* TRect2D 感兴趣区域
* long 窗口面积
* long 动态阈值
* long 斑点的最小面积
* TBlobTouchBorderFilter 忽略边界
* long 斑点最小宽度
* long 斑点最小高度
* 返回值: 不存在斑点 true,
* 存在斑点 false
*
* 功能: 在指定的区域内采用动态阈值+
* 斑点分析的方法检测是否存在斑点
*
****************************************************************/
bool CapsuleProc::RectBlackBlob( IMG image,
long wndSize,
long dynThres,
long minBlobSize,
TBlobTouchBorderFilter ignorBorder,
long minBlobWidth,
long minBlobHeight)
{
if(!IsImage(image)) { return true; }
IMG DynamicImage = NULL;
CreateDynamicThresholdImage(image, wndSize, dynThres, DynamicImage);
FBlobSetImage (m_cvbBlob, DynamicImage, 0);
FBlobSetObjectFeatureRange (m_cvbBlob, 0, 128);
FBlobSetSkipBinarization (m_cvbBlob, FALSE);
FBlobSetLimitArea (m_cvbBlob, minBlobSize, -1);
FBlobSetLimitWidth (m_cvbBlob, minBlobWidth, -1);
FBlobSetLimitHeight (m_cvbBlob, minBlobHeight, -1);
FBlobSetObjectTouchBorder (m_cvbBlob, ignorBorder);
FBlobExec (m_cvbBlob);
long blobCount = 0;
FBlobGetNumBlobs(m_cvbBlob, blobCount);
if(1 == m_dim.bytesPerPixel)
{
m_sortObserver.ObserverIMG(SortObserver::MDyn, DynamicImage);
}
else
{
m_sortObserver.ObserverIMG(SortObserver::CDyn, DynamicImage);
}
ReleaseImage(DynamicImage);
return (blobCount == 0);
}
/***************************************************************
*函数名称: BlobAnalysis
*
* 参数: fblob 斑点分析对象句柄
* temp 程序模板
* image 胶囊所在的灰度图像
* topX 胶囊中轴上顶点X坐标
* topY 胶囊中轴上顶点Y坐标
* up 套和区上端点
* low 套和区下端点
* bottomY 胶囊中轴下顶点Y坐标
*返回值: 有斑点 true 无斑点false
*
*功能: 对胶囊所在的灰度图像区域进行斑点分析
****************************************************************/
bool CapsuleProc::BlobAnalysis( IMG image,
long upEdgeY,
long downEdgeY,
long wndSize,
long dynThres,
long blobSize)
{
long x0 = 0, y0 =0, dx = 0, dy = 0;
ProfileBlob(image, ImageWidth(image)/2, m_cvbBlob);
FBlobGetBoundingBox(m_cvbBlob, 0, x0, y0, dx, dy);
y0 = 0;
dy = ImageHeight(image) - 1;
//中间部分
TRect2D<long> roi(x0, upEdgeY, x0+dx, downEdgeY);
roi.Expand (-10, -6);
if(false == RectangleBlob(image, roi, wndSize, dynThres, blobSize, FBLOB_BORDER_ALL, -1, -1, true))
{ return false; }
if (upEdgeY - y0> (y0 + dy) - downEdgeY)
{
roi = TRect2D<long>(x0, y0, x0+dx, upEdgeY-15);
if(false == RectangleBlob(image, roi, wndSize, dynThres, blobSize, FBLOB_BORDER_ALL))
{ return false; }
roi = TRect2D<long>(x0, downEdgeY+15, x0+dx, y0+dy);
if(false == RectangleBlob(image, roi, wndSize, dynThres+5, blobSize, FBLOB_BORDER_ALL))
{ return false; }
}
else
{
roi= TRect2D<long>(x0, y0, x0+dx, upEdgeY-15);
if(false == RectangleBlob(image, roi, wndSize, dynThres+5, blobSize, FBLOB_BORDER_ALL))
{ return false; }
roi = TRect2D<long>(x0, downEdgeY+15, x0+dx, y0+dy);
if(false == RectangleBlob(image, roi, wndSize, dynThres, blobSize, FBLOB_BORDER_ALL))
{ return false; }
}
if (upEdgeY - y0> (y0 + dy) - downEdgeY)
{
roi = TRect2D<long>(x0, y0 + (dx/2), x0+dx, upEdgeY-15);
}
else
{
roi = TRect2D<long>(x0, downEdgeY+15, x0+dx, y0+dy - (dx/2));
}
roi.Expand (-10, -6);
if(false == RectangleBlob(image, roi, wndSize, dynThres, blobSize, FBLOB_BORDER_NONE, -1, -1, true))
{ return false; }
return true;
}
/***************************************************************
*函数名称: RectSobelBlob
*
* 参数: IMG 图像
* TRect2D 感兴趣区域
* long 窗口面积
* long 动态阈值
* long 斑点的最小面积
* TBlobTouchBorderFilter 忽略边界
* long 斑点最小宽度
* long 斑点最小高度
* 返回值: 不存在斑点 true,
* 存在斑点 false
*
* 功能: 在指定的区域内采用动态阈值+
* 斑点分析的方法检测是否存在斑点
*
****************************************************************/
bool CapsuleProc::RectSobelBlob ( IMG image,
const TRect2D<long>& roi,
long wndSize,
long dynThres,
long minBlobSize,
TBlobTouchBorderFilter ignorBorder,
long minBlobWidth,
long minBlobHeight)
{
if(!IsImage(image) || roi.IsNull() )
{ return true; }
bool success = true;
IMG imageROI= NULL;
CreateImageMap(image , roi.x0(), roi.y0(), roi.x1(), roi.y1(), roi.Width(), roi.Height(), imageROI);
if(IsImage(imageROI))
{
IMG imageSobel = 0;
FilterSobelVertical(imageROI, FM_5x5, imageSobel);
success = RectBlackBlob( imageSobel,
wndSize,
dynThres,
minBlobSize,
ignorBorder,
minBlobWidth,
minBlobHeight);
if(success)
{
IMG imageSobel2 = NULL;
long maskVal[] = { 255 };
XorConstant ( imageSobel,
maskVal,
imageSobel2);
success = RectBlackBlob ( imageSobel2,
wndSize,
dynThres,
minBlobSize,
ignorBorder,
minBlobWidth,
minBlobHeight);
ReleaseImage(imageSobel2);
}
//m_sortObserver.ObserverIMG(SortObserver::MSobel, image);
//m_sortObserver.ObserverIMG(SortObserver::CSobel, imageSobel);
ReleaseImage(imageSobel);
}
ReleaseImage(imageROI);
return success;
}
/***************************************************************
*函数名称: SobelAnalysis
*
* 参数: IMG 图像
*
*
* 返回值: 不存在斑点 true,
* 存在斑点 false
*
* 功能: 在指定的区域内采用sobel滤波+
* 斑点分析的方法检测是否存在斑点
*
****************************************************************/
bool CapsuleProc::SobelAnalysis(IMG image)
{
IMG copyImage = 0;
CreateDuplicateImage (image, copyImage);
HorizonExtend::Extend(copyImage);
long width = ImageWidth(copyImage);
long height= ImageHeight(copyImage);
TRect2D<long> roi = TRect2D<long>(TPoint2D<long>(0,0), width, height);
roi.Expand(-2, -2);
bool success = RectSobelBlob( copyImage,
roi,
m_segmentParam.dynWndSize,
m_segmentParam.dynThres,
m_segmentParam.blobSize,
FBLOB_BORDER_ALL);
ReleaseImage(copyImage);
return success;
}
/***************************************************************
*函数名称: TransSobelAnalysis
*
* 参数: IMG 图像
*
*
* 返回值: 不存在斑点 true,
* 存在斑点 false
*
* 功能: 在指定的区域内采用sobel滤波+
* 斑点分析的方法检测是否存在斑点
*
****************************************************************/
bool CapsuleProc::TransSobelAnalysis(IMG image)
{
IMG copyImage = 0;
CreateDuplicateImage (image, copyImage);
HorizonExtend::Extend(copyImage);
long width = ImageWidth(copyImage);
long height= ImageHeight(copyImage);
TRect2D<long> roi = TRect2D<long>(TPoint2D<long>(0,0), width, height);
roi.Expand(-2, -2);
bool success = false;
IMG imageROI= NULL;
CreateImageMap( copyImage, roi.x0(), roi.y0(), roi.x1(), roi.y1(), roi.Width(), roi.Height(), imageROI);
if(IsImage(imageROI))
{
IMG imageSobel = 0;
FilterSobelVertical(imageROI, FM_5x5, imageSobel);
success = RectBlackBlob ( imageSobel,
m_segmentParam.dynWndSize,
m_segmentParam.dynThres - 2,
m_segmentParam.blobSize,
FBLOB_BORDER_ALL, -1, 4);
m_sortObserver.ObserverIMG(SortObserver::MSobel, copyImage);
m_sortObserver.ObserverIMG(SortObserver::CSobel, imageSobel);
ReleaseImage(imageSobel);
}
ReleaseImage(imageROI);
ReleaseImage(copyImage);
return success;
}
/*******************************************************************************
* 函数名称: ProfileBlob
*
* 参数 : blob 斑点检测对象句柄
* temp 胶囊参数模板
*
* 返回值 : 无
*
* 功能 : 对胶囊目标进行斑点检测
*
*
********************************************************************************/
bool CapsuleProc::ProfileBlob(IMG image, long minWidth, FBLOB &blob)
{
if(!IsImage(image)) return false;
FBlobSetImage (blob, image, 0);
FBlobSetObjectFeatureRange (blob, 1, 255);
FBlobSetLimitWidth (blob, minWidth, -1);
FBlobSetSortParameter (blob, 2, 0, 0, 1);
FBlobSetSkipBinarization (blob, FALSE);
FBlobExec (blob);
return true;
}
TImgBuffer CapsuleProc::GetRecordedImage( )
{
return m_imgBuffer;
}
/**********************************************
Name: ClearRecordedImage
Input: void
Output: void
Description: 清空图像缓冲区
***********************************************/
void CapsuleProc::ClearRecordedImage()
{
m_imgBuffer.SetZero();
}
/**********************************************
Name: RecordingImage
Input: void
Output: void
Description: 存储原始图像
***********************************************/
bool CapsuleProc::RecordingImage()
{
static PixelMem errFlag[8] = { 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00 };
unsigned int errPos = m_sortResult.GetErrorPosition();
unsigned int errCode = m_sortResult.GetErrorCode();
if(eNoSave == m_eSaveState) { return true; }
if(eErrSave == m_eSaveState && 0 == errPos) { return true; }
PixelMem* pBase = m_rawImage.Base();
memcpy(pBase, errFlag, 8);
pBase += m_dim.bytesPerRow;
memcpy(pBase, &errPos, sizeof(unsigned int));
pBase += m_dim.bytesPerRow;
memcpy(pBase, &errCode, sizeof(unsigned int));
m_imgBuffer.PushData(m_rawImage.Base(), m_dim);
return true;
}
/***************************************************************
*函数名称: SegmentParam
*
* 参数: SortorParam 处理参数
*
*
* 返回值: 无
*
*
* 功能: 为CapsuleProc对象的SortorParam进行赋值操作
*
*
****************************************************************/
void CapsuleProc::SegmentParam(const SortorParam& param)
{
m_segmentParam = param;
}
/***************************************************************
*函数名称: RemainInfo
*
* 参数: RemainParam 处理参数
*
*
* 返回值: 无
*
*
* 功能: 为CapsuleProc对象的RemainParam进行赋值操作
*
*
****************************************************************/
void CapsuleProc::RemainInfo(const RemainParam& param)
{
m_remainParam = param;
}
const RemainParam& CapsuleProc::RemainInfo ( ) const
{
return m_remainParam;
}
/***************************************************************
*函数名称: SegmentParam
*
* 参数: 无
*
*
* 返回值: SortorParam 处理参数
*
*
* 功能: 得到Capsule对象的SortorParam成员数据
*
*
****************************************************************/
const SortorParam& CapsuleProc::SegmentParam( ) const
{
return m_segmentParam;
}
/***************************************************************
*函数名称: Dimension
*
* 参数: 无
*
*
* 返回值: TImgDim 图像格式数据
*
*
* 功能: 得到TImgDim成员数据
*
*
****************************************************************/
const TImgDim& CapsuleProc::Dimension( ) const
{
return m_dim;
}
/***************************************************************
*函数名称: CapsuleInfo
*
* 参数: CapsuleParam 胶囊参数
*
*
* 返回值: 无
*
*
* 功能: 得到胶囊参数
*
*
****************************************************************/
void CapsuleProc::CapsuleInfo(const CapsuleParam& param)
{
m_capsuleParam = param;
}
/***************************************************************
*函数名称: CapsuleInfo
*
* 参数: 无
*
*
* 返回值: CapsuleParam 胶囊参数
*
*
* 功能: 得到胶囊参数
*
*
****************************************************************/
const CapsuleParam& CapsuleProc::CapsuleInfo( )
{
return m_capsuleParam;
}
/***************************************************************
*函数名称: GetSaveState
*
* 参数: 无
*
*
* 返回值: ESaveState 保存方式
*
*
* 功能: 得到图像的保存方式
*
*
****************************************************************/
CapsuleProc::ESaveState CapsuleProc::GetSaveState()
{
return m_eSaveState;
}
/***************************************************************
*函数名称: SetSaveState
*
* 参数: ESaveState 保存方式
*
*
* 返回值: ESaveState 保存方式
*
*
* 功能: 设置保存方式
*
*
****************************************************************/
CapsuleProc::ESaveState CapsuleProc::SetSaveState(ESaveState NextState)
{
m_eSaveState = NextState;
return m_eSaveState;
}
/***************************************************************
*函数名称: TransProcess
*
* 参数: 无
*
*
* 返回值: unsigned int 处理结果
*
*
* 功能: 透明胶囊处理
*
*
****************************************************************/
unsigned int CapsuleProc::TransProcess( WORKMODE mode )
{
TTimeDiff td;
td.Reset();
m_curData.Clear();
m_sortResult.NewPeriod();
m_sortObserver.NewPeriod(SortObserver::Mono);
TImgDim dim = Dimension();
if (!m_transRemain.RemainCapsule(m_rawImage, dim, m_profileImage, m_remainParam, TTransRemain::TRANSMODE))
{
OutputDebugString("RemainCapsule Failed!");
return 0;
}
m_sortObserver.ObserverIMG (SortObserver::MAll, m_cvbProfileImg);
long profileBlobCount = 0;
long minWidth = 1 + m_capsuleParam.capsuleDim.width/8;
ProfileBlob (m_cvbProfileImg, minWidth, m_profileBlob);
FBlobGetNumBlobs(m_profileBlob, profileBlobCount);
int counter = 0;
for(int i = 0; i < profileBlobCount; i++)
{
IMG proSubRot = NULL;
size_t posIndex = 0;
if(TransRotateIMG(i, m_profileBlob, m_cvbProfileImg, proSubRot, posIndex))
{
if(posIndex ==0 || posIndex == 2)
{
counter++;
}
m_sortObserver.ObserverIMG(SortObserver::MSub, proSubRot);
const long width = ImageWidth (proSubRot);
const long height= ImageHeight(proSubRot);
m_curData.WidthAndHeight(width, height);
//all short
if( IsCapsuleShort( height, width,
m_capsuleParam.capsuleDim.height,
m_capsuleParam.capsuleDim.tolerance))
{
if (REALTIME == mode)
{
m_sortResult.SetResult(SortResult::ShortErr, posIndex);
OutputDebugString("Capsule Short!");
ReleaseImage(proSubRot);
continue;
}
}
if (false == TransDoubleJudge(proSubRot, width/2))
{
if (REALTIME == mode)
{
m_sortResult.SetResult(SortResult::DoubleEdge, posIndex);
OutputDebugString("Double Edge!");
ReleaseImage(proSubRot);
continue;
}
}
//Is body/cap short
long upEdge = 0, downEdge = 0;
bool findEdge = FindUpDownEdge( proSubRot,
m_segmentParam.edgeDensity,
m_segmentParam.edgeThres,
upEdge,
downEdge);
if (findEdge)
{
if (false == TransIsPartShort(height, upEdge, downEdge))
{
if (REALTIME == mode)
{
m_sortResult.SetResult(SortResult::PartShort, posIndex);
OutputDebugString("Part Short!");
ReleaseImage(proSubRot);
continue;
}
}
}
//Soble Analysis
if( false == TransSobelAnalysis(proSubRot))
{
if (REALTIME == mode)
{
m_sortResult.SetResult(SortResult::SobelErr, posIndex);
OutputDebugString("Sobel Edge!");
ReleaseImage(proSubRot);
continue;
}
}
//blobAnalysis
if(false == TransBlobAnalysis( proSubRot, upEdge, downEdge,
m_segmentParam.dynWndSize,
m_segmentParam.dynThres,
m_segmentParam.blobSize))
{
if (REALTIME == mode)
{
m_sortResult.SetResult(SortResult::BlobErr, posIndex);
ReleaseImage(proSubRot);
OutputDebugString("BlobErr!");
continue;
}
}
ReleaseImage(proSubRot);
}
}
unsigned int badResult = m_sortResult.GetErrorPosition();
m_sortObserver.ObserverParam(SortObserver::MResult, badResult & 0x0F);
m_sortObserver.ObserverParam(SortObserver::MTime, td.msec() );
if (mode == REALTIME)
{
if( eSecond == m_processIndex )
{
CapsuleProc::AddToAllCount( counter );
}
}
if(profileBlobCount > 0)
{
RecordingImage();
}
return badResult;
}
/***************************************************************
*函数名称: TransRotateIMG
*
* 参数: size_t
* FBLOB
* IMG
* IMG
* size_t
*
* 返回值:
*
*
* 功能: 透明胶囊的旋转处理
*
*
****************************************************************/
bool CapsuleProc::TransRotateIMG( size_t blobIndex,
FBLOB profileBlob,
IMG proImg,
IMG &proSubIMG,
size_t &posIndex)
{
long profileCount = 0;
FBlobGetNumBlobs (profileBlob, profileCount);
if ( blobIndex >= static_cast<size_t>(profileCount) )
{
posIndex = -1;
return false;
}
//Get Range
long x0 = 0, y0 = 0, width = 0, height = 0;
FBlobGetBoundingBox (profileBlob, blobIndex, x0, y0, width, height);
posIndex = CheckPosition(x0+width/2, y0+height/2);
IMG proIMGMap = NULL;
CreateImageMap (proImg, x0, y0, x0+width, y0+height, width, height, proIMGMap);
double rabi = 0.0, rabi1 = 0.0, rabi2 = 0.0, momentAngle = 0.0;
FBlobGetMoments (profileBlob, blobIndex, rabi, rabi1, rabi2, momentAngle);
static const double ADIVPI = 180.0 /(4.0*atan(1.0)); //ppi = 180/PI
static const double ANGLE90 = 90; //ppiH = 180/PI*PI/2
double angle = 0.0;
if(momentAngle>=0)
{ angle = (ANGLE90 - ADIVPI * momentAngle); }
else
{ angle = -(ANGLE90 + ADIVPI * momentAngle); }
RotateImage( proIMGMap, angle, IP_Linear, proSubIMG);
TCoordinateMap cm;
InitCoordinateMap(cm);
SetImageCoordinates (proSubIMG, cm);
ShrinkVertical ( proSubIMG, m_segmentParam.shrinkY);
ShrinkHorizontal( proSubIMG, m_segmentParam.shrinkX*3/2);
ReleaseImage (proIMGMap);
return true;
}
/***************************************************************
* 函数名称: TransDoubleJudge
*
* 参数: IMG 子图像
* size_t 半径
*
* 返回值: 存在 true
* 不存在 false
*
*
* 功能: 判断是否存在两个边界
*
*
****************************************************************/
bool CapsuleProc::TransDoubleJudge ( IMG &subImage,
const size_t radius)
{
const long areaWidth = 20;
long centreX = ImageWidth(subImage)/2;
long centreY = ImageHeight(subImage)/2;
TArea area;
area.X0 = centreX -areaWidth;
area.X2 = centreX -areaWidth;
area.X1 = centreX +areaWidth;
area.Y0 = centreY;
area.Y2 = centreY-radius;
area.Y1 = centreY;
TEdgeResult tr;
CFindFirstEdge ( subImage, 0, m_segmentParam.edgeDensity,
area, m_segmentParam.edgeThres, FALSE, tr);
area.X0 = centreX -areaWidth;
area.X2 = centreX -areaWidth;
area.X1 = centreX +areaWidth;
area.Y0 = centreY;
area.Y2 = centreY+radius;
area.Y1 = centreY;
TEdgeResult downEdge;
CFindFirstEdge ( subImage, 0, m_segmentParam.edgeDensity,
area, m_segmentParam.edgeThres, FALSE, downEdge);
if ((tr.y == 0.f)||(downEdge.y == 0.f))
{
return true;
}
else
{
return false;
}
}
/***************************************************************
*函数名称: TransIsPartShort
*
* 参数: size_t 部分高度
* size_t 上边界
* size_t 下边界
*
* 返回值: 短体|短帽 true
*
*
* 功能: 是否存在短体|短帽
*
*
****************************************************************/
bool CapsuleProc::TransIsPartShort ( const size_t height,
const size_t upEdge,
const size_t downEdge )
{
const size_t part1Length = downEdge + m_segmentParam.shrinkY;
const size_t part2Length = height - upEdge + m_segmentParam.shrinkY;
m_curData.PartLength(part1Length, part2Length);
if (TransIsShort( part1Length, m_capsuleParam.capLength, m_capsuleParam.bodyLength, m_capsuleParam.partTolerance)&&
TransIsShort( part2Length, m_capsuleParam.bodyLength, m_capsuleParam.capLength, m_capsuleParam.partTolerance))
{
return true;
}
return false;
}
/***************************************************************
*函数名称: TransIsShort
*
* 参数: size_t 真实高度
* size_t 上半部分的高度
* size_t 下半部分的高度
* size_t 容差
*
* 返回值: 短体|短帽 true
*
*
* 功能: 是否存在短体|短帽
*
*
****************************************************************/
bool CapsuleProc::TransIsShort( const size_t realSize,
const size_t stdSize1,
const size_t stdSize2,
const size_t tolerance)
{
bool bStd1 = static_cast<size_t>(abs(static_cast<int>(realSize - stdSize1)))<tolerance;
bool bStd2 = static_cast<size_t>(abs(static_cast<int>(realSize - stdSize2)))<tolerance;
if (bStd1||bStd2)
{
return true;
}
return false;
}
/***************************************************************
*函数名称: TransBlobAnalysis
*
*
* 返回值: 是否存在斑点
*
*
* 功能:为透明胶囊设计的Blob斑点检测
*
*
****************************************************************/
bool CapsuleProc::TransBlobAnalysis( IMG image,
long upEdgeY,
long downEdgeY,
long wndSize,
long dynThres,
long blobSize)
{
long x0 = 0, y0 =0, dx = 0, dy = 0;
ProfileBlob(image, ImageWidth(image)/2, m_cvbBlob);
FBlobGetBoundingBox(m_cvbBlob, 0, x0, y0, dx, dy);
y0 = 0;
dy = ImageHeight(image) - 1;
//中间部分
TRect2D<long> roi(x0, upEdgeY, x0+dx, downEdgeY);
roi.Expand (-10, -6);
if(false == RectangleBlob(image, roi, wndSize, dynThres, blobSize, FBLOB_BORDER_ALL, -1, -1, true))
{ return false; }
if (upEdgeY - y0> (y0 + dy) - downEdgeY)
{
roi = TRect2D<long>(x0, y0, x0+dx, upEdgeY-10);
if(false == RectangleBlob(image, roi, wndSize, dynThres, blobSize, FBLOB_BORDER_ALL))
{ return false; }
roi = TRect2D<long>(x0, downEdgeY+10, x0+dx, y0+dy);
if(false == RectangleBlob(image, roi, wndSize, dynThres+5, blobSize, FBLOB_BORDER_ALL))
{ return false; }
}
else
{
roi= TRect2D<long>(x0, y0, x0+dx, upEdgeY-15);
if(false == RectangleBlob(image, roi, wndSize, dynThres+5, blobSize, FBLOB_BORDER_ALL))
{ return false; }
roi = TRect2D<long>(x0, downEdgeY+15, x0+dx, y0+dy);
if(false == RectangleBlob(image, roi, wndSize, dynThres, blobSize, FBLOB_BORDER_ALL))
{ return false; }
}
if (upEdgeY - y0> (y0 + dy) - downEdgeY)
{
roi = TRect2D<long>(x0, y0 + (dx/2), x0+dx, upEdgeY-15);
}
else
{
roi = TRect2D<long>(x0, downEdgeY+15, x0+dx, y0+dy - (dx/2));
}
roi.Expand (-10, -6);
if(false == RectangleBlob(image, roi, wndSize, dynThres, blobSize, FBLOB_BORDER_NONE, -1, -1, true))
{ return false; }
return true;
} | [
"vincen.cn@66f52ff4-a261-11de-b161-9f508301ba8e"
]
| [
[
[
1,
1474
]
]
]
|
499b01893ebd0527aa263cc5e4e77a8eef969f2c | 96e96a73920734376fd5c90eb8979509a2da25c0 | /C3DE/Input.h | a7bc0f86a1bc17957d0f720ac1c8a0c2e094d186 | []
| 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 | 939 | h | #ifndef INPUT_H
#define INPUT_H
#include "MouseListener.h"
#include "KeyboardListener.h"
#include <vector>
using namespace std;
class Input
{
public:
Input();
virtual ~Input();
virtual void Update() = 0;
virtual void Init(){};
virtual bool IsKeyDown(int key) = 0;
//useful for replay
virtual void SetKeyDown(int key, bool a_isDown) = 0;
virtual bool IsMouseButtonDown(int button) = 0;
float GetMouseDX() { return m_mouseDX;}
float GetMouseDY() { return m_mouseDY;}
float GetMouseDZ() { return m_mouseDZ;}
void AddMouseListener(MouseListener *listener);
void RemoveMouseListener(MouseListener *listener);
void AddKeyboardListener(KeyboardListener *listener);
void RemoveKeyboardListener(KeyboardListener *listener);
protected:
float m_mouseDX;
float m_mouseDY;
float m_mouseDZ;
vector<KeyboardListener *> *m_keyboardListeners;
vector<MouseListener *> *m_mouseListeners;
};
#endif | [
"caiocsabino@7e2be596-0d54-0410-9f9d-cf4183935158"
]
| [
[
[
1,
37
]
]
]
|
9d9e26223625887196ca123ccc88748a911020f3 | ad80c85f09a98b1bfc47191c0e99f3d4559b10d4 | /code/src/gfx/nchannelserver_cmds.cc | dd12aa7e77df4237f410194ed595d70ca270b049 | []
| no_license | DSPNerd/m-nebula | 76a4578f5504f6902e054ddd365b42672024de6d | 52a32902773c10cf1c6bc3dabefd2fd1587d83b3 | refs/heads/master | 2021-12-07T18:23:07.272880 | 2009-07-07T09:47:09 | 2009-07-07T09:47:09 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,069 | cc | #define N_IMPLEMENTS nChannelServer
//------------------------------------------------------------------------------
// nchannelserver_cmds.cc
// (C) 2001 RadonLabs GmbH
//------------------------------------------------------------------------------
#include "gfx/nchannelserver.h"
static void n_setchannel1f(void*, nCmd*);
static void n_setchannel2f(void*, nCmd*);
static void n_setchannel3f(void*, nCmd*);
static void n_setchannel4f(void*, nCmd*);
static void n_setchannelstring(void*, nCmd*);
static void n_getchannel1f(void*, nCmd*);
static void n_getchannel2f(void*, nCmd*);
static void n_getchannel3f(void*, nCmd*);
static void n_getchannel4f(void*, nCmd*);
static void n_getchannelstring(void*, nCmd*);
//------------------------------------------------------------------------------
/**
@scriptclass
nchannelserver
@superclass
nroot
@classinfo
Manages the animation channels.
*/
void
n_initcmds(nClass* cl)
{
cl->BeginCmds();
cl->AddCmd("v_setchannel1f_sf", 'SCH1', n_setchannel1f);
cl->AddCmd("v_setchannel2f_sff", 'SCH2', n_setchannel2f);
cl->AddCmd("v_setchannel3f_sfff", 'SCH3', n_setchannel3f);
cl->AddCmd("v_setchannel4f_sffff", 'SCH4', n_setchannel4f);
cl->AddCmd("v_setchannelstring_ss",'SCHS', n_setchannelstring);
cl->AddCmd("f_getchannel1f_s", 'GCH1', n_getchannel1f);
cl->AddCmd("ff_getchannel2f_s", 'GCH2', n_getchannel2f);
cl->AddCmd("fff_getchannel3f_s", 'GCH3', n_getchannel3f);
cl->AddCmd("ffff_getchannel4f_s", 'GCH4', n_getchannel4f);
cl->AddCmd("s_getchannelstring_s", 'GCHS', n_getchannelstring);
cl->EndCmds();
}
//------------------------------------------------------------------------------
/**
@cmd
setchannel1f
@input
s (ChannelName), f (Value)
@output
v
@info
Set channel to a float value.
*/
static void
n_setchannel1f(void* slf, nCmd* cmd)
{
nChannelServer* self = (nChannelServer*) slf;
int chnIndex = self->GenChannel(cmd->In()->GetS());
float f0 = cmd->In()->GetF();
self->SetChannel1f(chnIndex, f0);
}
//------------------------------------------------------------------------------
/**
@cmd
setchannel2f
@input
s(ChannelName), f(Val0), f(Val1)
@output
v
@info
Set channel to a 2d float value.
*/
static void
n_setchannel2f(void* slf, nCmd* cmd)
{
nChannelServer* self = (nChannelServer*) slf;
int chnIndex = self->GenChannel(cmd->In()->GetS());
float f0 = cmd->In()->GetF();
float f1 = cmd->In()->GetF();
self->SetChannel2f(chnIndex, f0, f1);
}
//------------------------------------------------------------------------------
/**
@cmd
setchannel3f
@input
s(ChannelName), f(Val0), f(Val1), f(Val2)
@output
v
@info
Set channel to a 3d float value.
*/
static void
n_setchannel3f(void* slf, nCmd* cmd)
{
nChannelServer* self = (nChannelServer*) slf;
int chnIndex = self->GenChannel(cmd->In()->GetS());
float f0 = cmd->In()->GetF();
float f1 = cmd->In()->GetF();
float f2 = cmd->In()->GetF();
self->SetChannel3f(chnIndex, f0, f1, f2);
}
//------------------------------------------------------------------------------
/**
@cmd
setchannel4f
@input
s(ChannelName), f(Val0), f(Val1), f(Val2), f(Val3)
@output
v
@info
Set channel to a 4d float value.
*/
static void
n_setchannel4f(void* slf, nCmd* cmd)
{
nChannelServer* self = (nChannelServer*) slf;
int chnIndex = self->GenChannel(cmd->In()->GetS());
float f0 = cmd->In()->GetF();
float f1 = cmd->In()->GetF();
float f2 = cmd->In()->GetF();
float f4 = cmd->In()->GetF();
self->SetChannel4f(chnIndex, f0, f1, f2, f4);
}
//------------------------------------------------------------------------------
/**
@cmd
setchannelstring
@input
s(ChannelName), s(ChannelContents)
@output
v
@info
Set channel to a string.
*/
static void
n_setchannelstring(void* slf, nCmd* cmd)
{
nChannelServer* self = (nChannelServer*) slf;
int chnIndex = self->GenChannel(cmd->In()->GetS());
self->SetChannelStringCopy(chnIndex, cmd->In()->GetS());
}
//------------------------------------------------------------------------------
/**
@cmd
getchannel1f
@input
s(ChannelName)
@output
f(Value)
@info
Get channel as float value.
*/
static void
n_getchannel1f(void* slf, nCmd* cmd)
{
nChannelServer* self = (nChannelServer*) slf;
int chnIndex = self->GenChannel(cmd->In()->GetS());
float f0;
f0 = self->GetChannel1f(chnIndex);
cmd->Out()->SetF(f0);
}
//------------------------------------------------------------------------------
/**
@cmd
getchannel2f
@input
s(ChannelName)
@output
f(Val0), f(Val1)
@info
Get channel as 2d float value.
*/
static void
n_getchannel2f(void* slf, nCmd* cmd)
{
nChannelServer* self = (nChannelServer*) slf;
int chnIndex = self->GenChannel(cmd->In()->GetS());
float f0, f1;
self->GetChannel2f(chnIndex, f0, f1);
cmd->Out()->SetF(f0);
cmd->Out()->SetF(f1);
}
//------------------------------------------------------------------------------
/**
@cmd
getchannel3f
@input
s(ChannelName)
@output
f(Val0), f(Val1), f(Val2)
@info
Get channel as 3d float value.
*/
static void
n_getchannel3f(void* slf, nCmd* cmd)
{
nChannelServer* self = (nChannelServer*) slf;
int chnIndex = self->GenChannel(cmd->In()->GetS());
float f0, f1, f2;
self->GetChannel3f(chnIndex, f0, f1, f2);
cmd->Out()->SetF(f0);
cmd->Out()->SetF(f1);
cmd->Out()->SetF(f2);
}
//------------------------------------------------------------------------------
/**
@cmd
getchannel4f
@input
s(ChannelName)
@output
f(Val0), f(Val1), f(Val2), f(Val3)
@info
Get channel as 4d float value.
*/
static void
n_getchannel4f(void* slf, nCmd* cmd)
{
nChannelServer* self = (nChannelServer*) slf;
int chnIndex = self->GenChannel(cmd->In()->GetS());
float f0, f1, f2, f3;
self->GetChannel4f(chnIndex, f0, f1, f2, f3);
cmd->Out()->SetF(f0);
cmd->Out()->SetF(f1);
cmd->Out()->SetF(f2);
cmd->Out()->SetF(f3);
}
//------------------------------------------------------------------------------
/**
@cmd
getchannelstring
@input
s(ChannelName)
@output
s(ChannelContent)
@info
Get channel content as string.
*/
static void
n_getchannelstring(void* slf, nCmd* cmd)
{
nChannelServer* self = (nChannelServer*) slf;
int chnIndex = self->GenChannel(cmd->In()->GetS());
cmd->Out()->SetS(self->GetChannelString(chnIndex));
}
//------------------------------------------------------------------------------
| [
"plushe@411252de-2431-11de-b186-ef1da62b6547"
]
| [
[
[
1,
285
]
]
]
|
fee50f8b504c8f7544c518da3e960204ccedf879 | b47e38256ce41d17fa8cbc7cbb46f8c4394b1e79 | /stdafx.cpp | 8bc7bde38eded7b9b6482a013e23611125c1bf3f | []
| no_license | timothyha/ppc-bq | b54162c6e117d6df9849054e75bc7da06d630c1a | 144c3a00bd130fc34831f530e2c7207edaa8ee7e | refs/heads/master | 2020-05-16T14:25:31.426285 | 2010-09-04T06:03:47 | 2010-09-04T06:03:47 | 32,114,289 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 292 | cpp | // stdafx.cpp : source file that includes just the standard includes
// ppcbq.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
| [
"nuh.ubf@e3e9064e-3af0-11de-9146-fdf1833cc731"
]
| [
[
[
1,
8
]
]
]
|
ee49f43dce278123e2e53a4b317c34419847fdd6 | de1e5905af557c6155ee50f509758a549e458ef3 | /src/treesynth/Eliot/Eliot.h | 966727d70fe88a08163a05e757ce6b39b26c8cfa | []
| no_license | alltom/taps | f15f0a5b234db92447a581f3777dbe143d78da6c | a3c399d932314436f055f147106d41a90ba2fd02 | refs/heads/master | 2021-01-13T01:46:24.766584 | 2011-09-03T23:20:12 | 2011-09-03T23:20:12 | 2,486,969 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,358 | h | // Treesynth object
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <assert.h>
#include <iostream>
#include "../lib/sndfile.h"
#include "daub.h"
#include "Stk.h"
#include "RtAudio.h"
#define TS_FLOAT float
#define TS_UINT unsigned int
#define CUTOFF (1 << 18)
#define MAX_TREE_SIZE (CUTOFF << 1)
#define TS_BIG_BUFFER_SIZE CUTOFF
#define TS_BIG_BUFFER_COUNT 16
#define TS_BUFFER_SIZE 2048;
struct Node
{
TS_FLOAT * value; // Can point to value in m_values_ instead of reproducing, right?
TS_UINT * cs;
TS_UINT cslength;
Node * parent;
Node * left;
Node * right;
};
class Tree
{
public:
Tree();
~Tree();
bool initialize( TS_UINT levels ); // init by levels => size is power of 2 by default
void shutdown();
public:
inline TS_FLOAT getValue( TS_UINT level, TS_UINT offset );
inline Node * getNode( TS_UINT level, TS_UINT offset );
TS_FLOAT * values();
void setValues( TS_FLOAT * values, TS_UINT size ); // just for convenience
TS_UINT getSize();
TS_UINT getLevels();
protected:
Node * m_nodes_;
TS_FLOAT * m_values_;
TS_UINT m_size_;
TS_UINT m_levels_;
};
class Treesynth
{
public:
Treesynth();
~Treesynth();
bool initialize();
void shutdown();
double FindEpsilon( Tree * the_tree, int size, double P );
short Ancestors( int lev, int nod, int csl );
short Predecessors( int lev, int nod, int csl );
void CandidateSet(int lev, int nod );
bool setup( void );
void synth( void );
Tree * outputTree();
TS_FLOAT * outputSignal();
// the trees
Tree * tree;
Tree * lefttree;
// treesynth knobs
// If we make these private and implement a bunch of methods to set/get them,
// they can always check the values before setting and be safe.
float kfactor; // the thing that actually determines npredecessors
bool randflip; // whether first 2 coefficients are copied in order or randomly
double percentage; // percentage of nodes to be considered when learning new tree
bool ancfirst; // whether learning is first done on ancestors or predecessors
int startlevel;
int stoplevel; // changed later in the program
protected:
Tree * tnew_data;
Tree * tnew;
TS_FLOAT * synsig; // synthesized signal
bool leftinit;
int npredecessors; // number of predecessors checked
double epsilon; // closeness threshold; calculated from percentage
int * cands;
bool * in;
short * S;
short * L;
};
enum TheReadModes
{
// actions
RM_STOP = 0x0,
RM_WRAP = 0x1,
RM_BOUNCE = 0x2,
RM_STATIONARY = 0x4,
// directions
RM_FORWARD = 0x8,
RM_BACKWARD = 0x10,
RM_RANDOM = 0x20,
// don't or this in
RM_ACTION_MASK = 0x7,
RM_DIRECTION_MASK = ~RM_ACTION_MASK
};
class TreesynthIO
{
public:
// FUNKY THINGS:
TreesynthIO();
~TreesynthIO();
// actual stuff
int m_audio_cb( char * buffer, int buffer_size, void * user_data );
bool audio_initialize( int (*audio_cb) (char *, int, void *), TS_UINT srate = 44100 );
void set_next_pos( const char * filename );
int ReadSoundFile( char filename[], TS_FLOAT * data, int datasize );
int WriteSoundFile( char filename[], TS_FLOAT * data, int datasize );
// imaginary stuff?
TS_UINT get_srate();
// DATA:
// INPUT AND OUTPUT sound file names and info
char ifilename[1024];
char ofilename[1024];
char leftfile[1024];
// INPUT reading mode
int rm_mode;
// OUTPUT synthesized signal size (# of samples)
int nsamples;
protected:
// MORE DATA:
Treesynth * m_treesynth_; // just a harmless pointer...
bool leftinit; // delete if not used
// INPUT AND OUTPUT sound files and info
SF_INFO info;
SNDFILE * sfread;
SNDFILE * sfwrite;
// INPUT reading position and length
int rm_next_pos;
int rm_next_length;
// OUTPUT real-time stuff
int g_write_index;
int g_read_index;
TS_FLOAT g_big_buffer[TS_BIG_BUFFER_COUNT][TS_BIG_BUFFER_SIZE];
TS_FLOAT * g_audio_begin;
TS_FLOAT * g_audio_end;
int g_buffer_size;
TS_UINT g_data_count;
TS_UINT g_max_data_count;
int g_ready;
RtAudio * g_audio;
TS_UINT g_srate;
};
// floating functions (aka internal hacks)
double pow( int x, int n );
int our_min(int a, int b);
short maximum(short *array, int size);
int lg( int n );
int compare( const void *arg1, const void *arg2 );
| [
"[email protected]"
]
| [
[
[
1,
197
]
]
]
|
d1c49be44e6b212750ec020936159e51ec77099e | f96efcf47a7b6a617b5b08f83924c7384dcf98eb | /trunk/tlen/tlen_czaty/ChatEvent.cpp | 246c168f22f02da6a92ea9b0dcd871e45c82a338 | []
| no_license | BackupTheBerlios/mtlen-svn | 0b4e7c53842914416ed3f6b1fa02c3f1623cac44 | f0ea6f0cec85e9ed537b89f7d28f75b1dc108554 | refs/heads/master | 2020-12-03T19:37:37.828462 | 2011-12-07T20:02:16 | 2011-12-07T20:02:16 | 40,800,938 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,214 | cpp | /*
MUCC Group Chat GUI Plugin for Miranda IM
Copyright (C) 2004 Piotr Piastucki
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.
*/
#include "ChatEvent.h"
#include "Options.h"
#include "Utils.h"
#include <string.h>
ChatEvent::ChatEvent() {
next = prev = NULL;
event.cbSize = sizeof(MUCCEVENT);
event.iType = 0;
event.pszID = NULL;
event.pszModule = NULL;
event.pszName = NULL;
event.pszNick = NULL;
event.pszText = NULL;
event.pszUID = NULL;
}
ChatEvent::ChatEvent(const MUCCEVENT *e) {
event.cbSize = sizeof(MUCCEVENT);
event.iType = e->iType;
event.bIsMe = e->bIsMe;
event.color = e->color;
event.dwData = e->dwData;
event.dwFlags = e->dwFlags;
event.iFont = e->iFont;
event.iFontSize = e->iFontSize;
event.time = e->time;
event.pszID = NULL;
event.pszModule = NULL;
event.pszName = NULL;
event.pszNick = NULL;
event.pszText = NULL;
event.pszUID = NULL;
// Utils::copyString((char **)&(event.pszID), e->pszID);
// Utils::copyString((char **)&(event.pszModule), e->pszModule);
// Utils::copyString((char **)&(event.pszName), e->pszName);
if (e->iType == MUCC_EVENT_STATUS || e->iType == MUCC_EVENT_MESSAGE) {
Utils::copyString((char **)&(event.pszNick), e->pszNick);
}
if (e->iType == MUCC_EVENT_ERROR || e->iType == MUCC_EVENT_MESSAGE || e->iType == MUCC_EVENT_TOPIC) {
Utils::copyString((char **)&(event.pszText), e->pszText);
}
// Utils::copyString((char **)&(event.pszUID), e->pszUID);
next = prev = NULL;
}
ChatEvent::~ChatEvent() {
if (event.pszID != NULL) {
delete (char *)event.pszID;
}
if (event.pszModule != NULL) {
delete (char *)event.pszModule;
}
if (event.pszName != NULL) {
delete (char *)event.pszName;
}
if (event.pszNick != NULL) {
delete (char *)event.pszNick;
}
if (event.pszText != NULL) {
delete (char *)event.pszText;
}
if (event.pszUID != NULL) {
delete (char *)event.pszUID;
}
if (next != NULL) {
next->setPrev(prev);
}
if (prev != NULL) {
prev->setNext(next);
}
}
ChatEvent * ChatEvent::getNext() {
return next;
}
ChatEvent * ChatEvent::getPrev() {
return prev;
}
void ChatEvent::setNext(ChatEvent *next) {
this->next = next;
}
void ChatEvent::setPrev(ChatEvent * prev) {
this->prev = prev;
}
const MUCCEVENT * ChatEvent::getEvent() {
return &event;
}
ChatEventList::ChatEventList() {
eventListEnd = &eventListRoot;
setMaxSize(DEFAULT_MAX_SIZE);
currentSize = 0;
}
ChatEventList::~ChatEventList() {
while (eventListRoot.getNext()!=NULL) {
delete eventListRoot.getNext();
}
}
int ChatEventList::addEvent(const MUCCEVENT *muccevent) {
int trimmed = 0;
ChatEvent *event = new ChatEvent(muccevent);
event->setPrev(eventListEnd);
eventListEnd->setNext(event);
eventListEnd=event;
currentSize++;
if (currentSize>hiMaxSize) {
while (currentSize>loMaxSize && eventListRoot.getNext()!=NULL) {
delete eventListRoot.getNext();
currentSize--;
trimmed = 1;
}
}
return trimmed;
}
ChatEvent * ChatEventList::getEvents() {
return eventListRoot.getNext();
}
void ChatEventList::setMaxSize(int s) {
loMaxSize = s;
if (s>200) {
hiMaxSize = s + s/10;
} else {
hiMaxSize = s + 20;
}
}
void ChatEventList::clear() {
ChatEvent *event = eventListRoot.getNext();
eventListRoot.setNext(NULL);
eventListEnd = &eventListRoot;
currentSize = 0;
if (event!=NULL) {
event->setPrev(NULL);
while (event->getNext()!=NULL) {
delete event->getNext();
}
delete event;
}
}
| [
"the_leech@3f195757-89ef-0310-a553-cc0e5972f89c"
]
| [
[
[
1,
174
]
]
]
|
6dc3a6403ead68d62d2bb02f6a48eb2d84020c9d | d673a65d70b98f70a4ded27a087cac8c53da4d8e | /lib/cryptopp/bench.cpp | 57596361e9d644d925daef656543779bbfb1c653 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-cryptopp",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | vrajanap/carbon-state-machine | cc7e840b4628fec79e6a6e8df4036a8c9818c665 | f74f89d766af331addc829b41e6604dc943ba5bc | refs/heads/master | 2016-09-05T23:10:15.158249 | 2008-10-27T05:22:32 | 2008-10-27T05:22:32 | 32,377,600 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,134 | cpp | // bench.cpp - written and placed in the public domain by Wei Dai
#define _CRT_SECURE_NO_DEPRECATE
#include "bench.h"
#include "crc.h"
#include "adler32.h"
#include "idea.h"
#include "des.h"
#include "rc5.h"
#include "blowfish.h"
#include "wake.h"
#include "cast.h"
#include "seal.h"
#include "rc6.h"
#include "mars.h"
#include "twofish.h"
#include "serpent.h"
#include "skipjack.h"
#include "cbcmac.h"
#include "dmac.h"
#include "aes.h"
#include "blumshub.h"
#include "rng.h"
#include "files.h"
#include "hex.h"
#include "modes.h"
#include "factory.h"
#include <time.h>
#include <math.h>
#include <iostream>
#include <iomanip>
USING_NAMESPACE(CryptoPP)
USING_NAMESPACE(std)
#ifdef CLOCKS_PER_SEC
const double CLOCK_TICKS_PER_SECOND = (double)CLOCKS_PER_SEC;
#elif defined(CLK_TCK)
const double CLOCK_TICKS_PER_SECOND = (double)CLK_TCK;
#else
const double CLOCK_TICKS_PER_SECOND = 1000000.0;
#endif
double logtotal = 0, g_allocatedTime, g_hertz;
unsigned int logcount = 0;
static const byte *const key=(byte *)"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
void OutputResultBytes(const char *name, double length, double timeTaken)
{
double mbs = length / timeTaken / (1024*1024);
cout << "\n<TR><TH>" << name;
// cout << "<TD>" << setprecision(3) << length / (1024*1024);
cout << setiosflags(ios::fixed);
// cout << "<TD>" << setprecision(3) << timeTaken;
cout << "<TD>" << setprecision(0) << setiosflags(ios::fixed) << mbs;
if (g_hertz)
cout << "<TD>" << setprecision(1) << setiosflags(ios::fixed) << timeTaken * g_hertz / length;
cout << resetiosflags(ios::fixed);
logtotal += log(mbs);
logcount++;
}
void OutputResultKeying(double iterations, double timeTaken)
{
cout << "<TD>" << setprecision(3) << setiosflags(ios::fixed) << (1000*1000*timeTaken/iterations);
if (g_hertz)
cout << "<TD>" << setprecision(0) << setiosflags(ios::fixed) << timeTaken * g_hertz / iterations;
}
void OutputResultOperations(const char *name, const char *operation, bool pc, unsigned long iterations, double timeTaken)
{
cout << "\n<TR><TH>" << name << " " << operation << (pc ? " with precomputation" : "");
// cout << "<TD>" << iterations;
// cout << setiosflags(ios::fixed);
// cout << "<TD>" << setprecision(3) << timeTaken;
cout << "<TD>" << setprecision(2) << setiosflags(ios::fixed) << (1000*timeTaken/iterations);
if (g_hertz)
cout << "<TD>" << setprecision(2) << setiosflags(ios::fixed) << timeTaken * g_hertz / iterations / 1000000;
cout << resetiosflags(ios::fixed);
logtotal += log(iterations/timeTaken);
logcount++;
}
void BenchMark(const char *name, BlockTransformation &cipher, double timeTotal)
{
const int BUF_SIZE = RoundUpToMultipleOf(2048U, cipher.OptimalNumberOfParallelBlocks() * cipher.BlockSize());
AlignedSecByteBlock buf(BUF_SIZE);
const int nBlocks = BUF_SIZE / cipher.BlockSize();
clock_t start = clock();
unsigned long i=0, blocks=1;
double timeTaken;
do
{
blocks *= 2;
for (; i<blocks; i++)
cipher.ProcessAndXorMultipleBlocks(buf, NULL, buf, nBlocks);
timeTaken = double(clock() - start) / CLOCK_TICKS_PER_SECOND;
}
while (timeTaken < 2.0/3*timeTotal);
OutputResultBytes(name, double(blocks) * BUF_SIZE, timeTaken);
}
void BenchMark(const char *name, StreamTransformation &cipher, double timeTotal)
{
const int BUF_SIZE=RoundUpToMultipleOf(2048U, cipher.OptimalBlockSize());
AlignedSecByteBlock buf(BUF_SIZE);
clock_t start = clock();
unsigned long i=0, blocks=1;
double timeTaken;
do
{
blocks *= 2;
for (; i<blocks; i++)
cipher.ProcessString(buf, BUF_SIZE);
timeTaken = double(clock() - start) / CLOCK_TICKS_PER_SECOND;
}
while (timeTaken < 2.0/3*timeTotal);
OutputResultBytes(name, double(blocks) * BUF_SIZE, timeTaken);
}
void BenchMark(const char *name, HashTransformation &ht, double timeTotal)
{
const int BUF_SIZE=2048U;
AlignedSecByteBlock buf(BUF_SIZE);
LC_RNG rng((word32)time(NULL));
rng.GenerateBlock(buf, BUF_SIZE);
clock_t start = clock();
unsigned long i=0, blocks=1;
double timeTaken;
do
{
blocks *= 2;
for (; i<blocks; i++)
ht.Update(buf, BUF_SIZE);
timeTaken = double(clock() - start) / CLOCK_TICKS_PER_SECOND;
}
while (timeTaken < 2.0/3*timeTotal);
OutputResultBytes(name, double(blocks) * BUF_SIZE, timeTaken);
}
void BenchMark(const char *name, BufferedTransformation &bt, double timeTotal)
{
const int BUF_SIZE=2048U;
AlignedSecByteBlock buf(BUF_SIZE);
LC_RNG rng((word32)time(NULL));
rng.GenerateBlock(buf, BUF_SIZE);
clock_t start = clock();
unsigned long i=0, blocks=1;
double timeTaken;
do
{
blocks *= 2;
for (; i<blocks; i++)
bt.Put(buf, BUF_SIZE);
timeTaken = double(clock() - start) / CLOCK_TICKS_PER_SECOND;
}
while (timeTaken < 2.0/3*timeTotal);
OutputResultBytes(name, double(blocks) * BUF_SIZE, timeTaken);
}
void BenchMarkKeying(SimpleKeyingInterface &c, size_t keyLength, const NameValuePairs ¶ms)
{
unsigned long iterations = 0;
clock_t start = clock();
double timeTaken;
do
{
for (unsigned int i=0; i<1024; i++)
c.SetKey(key, keyLength, params);
timeTaken = double(clock() - start) / CLOCK_TICKS_PER_SECOND;
iterations += 1024;
}
while (timeTaken < g_allocatedTime);
OutputResultKeying(iterations, timeTaken);
}
//VC60 workaround: compiler bug triggered without the extra dummy parameters
template <class T>
void BenchMarkKeyed(const char *name, double timeTotal, const NameValuePairs ¶ms = g_nullNameValuePairs, T *x=NULL)
{
T c;
c.SetKey(key, c.DefaultKeyLength(), CombinedNameValuePairs(params, MakeParameters(Name::IV(), key, false)));
BenchMark(name, c, timeTotal);
BenchMarkKeying(c, c.DefaultKeyLength(), CombinedNameValuePairs(params, MakeParameters(Name::IV(), key, false)));
}
//VC60 workaround: compiler bug triggered without the extra dummy parameters
template <class T>
void BenchMarkKeyedVariable(const char *name, double timeTotal, unsigned int keyLength, const NameValuePairs ¶ms = g_nullNameValuePairs, T *x=NULL)
{
T c;
c.SetKey(key, keyLength, CombinedNameValuePairs(params, MakeParameters(Name::IV(), key, false)));
BenchMark(name, c, timeTotal);
BenchMarkKeying(c, keyLength, CombinedNameValuePairs(params, MakeParameters(Name::IV(), key, false)));
}
//VC60 workaround: compiler bug triggered without the extra dummy parameters
template <class T>
void BenchMarkKeyless(const char *name, double timeTotal, T *x=NULL)
{
T c;
BenchMark(name, c, timeTotal);
}
//VC60 workaround: compiler bug triggered without the extra dummy parameters
template <class T>
void BenchMarkByName(const char *factoryName, size_t keyLength = 0, const char *displayName=NULL, const NameValuePairs ¶ms = g_nullNameValuePairs, T *x=NULL)
{
std::string name = factoryName;
if (displayName)
name = displayName;
else if (keyLength)
name += " (" + IntToString(keyLength * 8) + "-bit key)";
std::auto_ptr<T> obj(ObjectFactoryRegistry<T>::Registry().CreateObject(factoryName));
if (!keyLength)
keyLength = obj->DefaultKeyLength();
obj->SetKey(key, keyLength, CombinedNameValuePairs(params, MakeParameters(Name::IV(), key, false)));
BenchMark(name.c_str(), *obj, g_allocatedTime);
BenchMarkKeying(*obj, keyLength, CombinedNameValuePairs(params, MakeParameters(Name::IV(), key, false)));
}
template <class T>
void BenchMarkByNameKeyLess(const char *factoryName, const char *displayName=NULL, const NameValuePairs ¶ms = g_nullNameValuePairs, T *x=NULL)
{
std::string name = factoryName;
if (displayName)
name = displayName;
std::auto_ptr<T> obj(ObjectFactoryRegistry<T>::Registry().CreateObject(factoryName));
BenchMark(name.c_str(), *obj, g_allocatedTime);
}
void BenchmarkAll(double t, double hertz)
{
#if 1
logtotal = 0;
logcount = 0;
g_allocatedTime = t;
g_hertz = hertz;
const char *cpb, *cpk;
if (g_hertz)
{
cpb = "<TH>Cycles Per Byte";
cpk = "<TH>Cycles to<br>Setup Key and IV";
cout << "CPU frequency of the test platform is " << g_hertz << " Hz.\n";
}
else
{
cpb = cpk = "";
cout << "CPU frequency of the test platform was not provided.\n";
}
cout << "<TABLE border=1><COLGROUP><COL align=left><COL align=right><COL align=right><COL align=right><COL align=right>" << endl;
cout << "<THEAD><TR><TH>Algorithm<TH>MiB/Second" << cpb << "<TH>Microseconds to<br>Setup Key and IV" << cpk << endl;
cout << "\n<TBODY style=\"background: white\">";
BenchMarkByName<MessageAuthenticationCode>("VMAC(AES)-64");
BenchMarkByName<MessageAuthenticationCode>("VMAC(AES)-128");
BenchMarkByName<MessageAuthenticationCode>("HMAC(SHA-1)");
BenchMarkByName<MessageAuthenticationCode>("Two-Track-MAC");
BenchMarkKeyed<CBC_MAC<AES> >("CBC-MAC/AES", t);
BenchMarkKeyed<DMAC<AES> >("DMAC/AES", t);
cout << "\n<TBODY style=\"background: yellow\">";
BenchMarkKeyless<CRC32>("CRC-32", t);
BenchMarkKeyless<Adler32>("Adler-32", t);
BenchMarkByNameKeyLess<HashTransformation>("MD5");
BenchMarkByNameKeyLess<HashTransformation>("SHA-1");
BenchMarkByNameKeyLess<HashTransformation>("SHA-256");
#ifdef WORD64_AVAILABLE
BenchMarkByNameKeyLess<HashTransformation>("SHA-512");
BenchMarkByNameKeyLess<HashTransformation>("Tiger");
BenchMarkByNameKeyLess<HashTransformation>("Whirlpool");
#endif
BenchMarkByNameKeyLess<HashTransformation>("RIPEMD-160");
BenchMarkByNameKeyLess<HashTransformation>("RIPEMD-320");
BenchMarkByNameKeyLess<HashTransformation>("RIPEMD-128");
BenchMarkByNameKeyLess<HashTransformation>("RIPEMD-256");
cout << "\n<TBODY style=\"background: white\">";
BenchMarkByName<SymmetricCipher>("Salsa20");
BenchMarkByName<SymmetricCipher>("Salsa20", 0, "Salsa20/12", MakeParameters(Name::Rounds(), 12));
BenchMarkByName<SymmetricCipher>("Salsa20", 0, "Salsa20/8", MakeParameters(Name::Rounds(), 8));
BenchMarkByName<SymmetricCipher>("Sosemanuk");
BenchMarkByName<SymmetricCipher>("MARC4");
BenchMarkKeyed<SEAL<BigEndian>::Encryption>("SEAL-3.0-BE", t);
BenchMarkKeyed<SEAL<LittleEndian>::Encryption>("SEAL-3.0-LE", t);
BenchMarkKeyed<WAKE_OFB<BigEndian>::Encryption>("WAKE-OFB-BE", t);
BenchMarkKeyed<WAKE_OFB<LittleEndian>::Encryption>("WAKE-OFB-LE", t);
cout << "\n<TBODY style=\"background: yellow\">";
BenchMarkByName<SymmetricCipher>("AES/ECB", 16);
BenchMarkByName<SymmetricCipher>("AES/ECB", 24);
BenchMarkByName<SymmetricCipher>("AES/ECB", 32);
BenchMarkByName<SymmetricCipher>("AES/CTR", 16);
BenchMarkByName<SymmetricCipher>("AES/OFB", 16);
BenchMarkByName<SymmetricCipher>("AES/CFB", 16);
BenchMarkByName<SymmetricCipher>("AES/CBC", 16);
BenchMarkByName<SymmetricCipher>("Camellia/ECB", 16);
BenchMarkByName<SymmetricCipher>("Camellia/ECB", 32);
BenchMarkKeyed<Twofish::Encryption>("Twofish", t);
BenchMarkKeyed<Serpent::Encryption>("Serpent", t);
BenchMarkKeyed<CAST256::Encryption>("CAST-256", t);
BenchMarkKeyed<RC6::Encryption>("RC6", t);
BenchMarkKeyed<MARS::Encryption>("MARS", t);
BenchMarkByName<SymmetricCipher>("SHACAL-2/ECB", 16);
BenchMarkByName<SymmetricCipher>("SHACAL-2/ECB", 64);
BenchMarkKeyed<DES::Encryption>("DES", t);
BenchMarkKeyed<DES_XEX3::Encryption>("DES-XEX3", t);
BenchMarkKeyed<DES_EDE3::Encryption>("DES-EDE3", t);
BenchMarkKeyed<IDEA::Encryption>("IDEA", t);
BenchMarkKeyed<RC5::Encryption>("RC5 (r=16)", t);
BenchMarkKeyed<Blowfish::Encryption>("Blowfish", t);
BenchMarkByName<SymmetricCipher>("TEA/ECB");
BenchMarkByName<SymmetricCipher>("XTEA/ECB");
BenchMarkKeyed<CAST128::Encryption>("CAST-128", t);
BenchMarkKeyed<SKIPJACK::Encryption>("SKIPJACK", t);
cout << "</TABLE>" << endl;
BenchmarkAll2(t, hertz);
cout << "Throughput Geometric Average: " << setiosflags(ios::fixed) << exp(logtotal/logcount) << endl;
time_t endTime = time(NULL);
cout << "\nTest ended at " << asctime(localtime(&endTime));
#endif
}
| [
"mailtosrinath@6cd178ee-90f9-11dd-b633-d39c22b7b77f"
]
| [
[
[
1,
342
]
]
]
|
bccc3adb5f1cfdf6cc5f14febaedfd2b255ae176 | d2996420f8c3a6bbeef63a311dd6adc4acc40436 | /src/client/hud/ClientHUDResources.h | 0e7ccab03edd413bca6b480112c140974dac383e | []
| no_license | aruwen/graviator | 4d2e06e475492102fbf5d65754be33af641c0d6c | 9a881db9bb0f0de2e38591478429626ab8030e1d | refs/heads/master | 2021-01-19T00:13:10.843905 | 2011-03-13T13:15:25 | 2011-03-13T13:15:25 | 32,136,578 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 881 | h | //*********************************************************
// Graviator - QPT2a - FH Salzburg
// Stefan Ebner - Malte Langkabel - Christian Winkler
//
// ClientHUDResources
// Manages the silverback for the ingame HUDs, so that ih has to be loaded just once. Singleton.
//
//*********************************************************
#ifndef CLIENT_HUD_RESOURCES
#define CLIENT_HUD_RESOURCES
#include "..\..\Gorilla.h"
#define HUD ClientHUDResources::getInstance()
class ClientHUDResources
{
public:
static ClientHUDResources& getInstance();
static void destroy();
Gorilla::Silverback *getSilverback() {return mSilverback;}
private:
static ClientHUDResources* instance;
ClientHUDResources();
ClientHUDResources(const ClientHUDResources&) {}
~ClientHUDResources(void);
//HUD related
Gorilla::Silverback *mSilverback;
};
#endif | [
"[email protected]@c8d5bfcc-1391-a108-90e5-e810ef6ef867"
]
| [
[
[
1,
37
]
]
]
|
cf5e2f799dbb9e79efc12b3cd009c477f6dad18e | c3531ade6396e9ea9c7c9a85f7da538149df2d09 | /Param/src/Common/Macro.h | a59578d35150d783b83f859f0f410aa7494d0062 | []
| no_license | feengg/MultiChart-Parameterization | ddbd680f3e1c2100e04c042f8f842256f82c5088 | 764824b7ebab9a3a5e8fa67e767785d2aec6ad0a | refs/heads/master | 2020-03-28T16:43:51.242114 | 2011-04-19T17:18:44 | 2011-04-19T17:18:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,543 | h | /* ================== Library Information ================== */
// [Name]
// MeshLib Library
//
// [Developer]
// Xu Dong
// State Key Lab of CAD&CG, Zhejiang University
//
// [Date]
// 2005-08-05
//
// [Goal]
// A general, flexible, versatile and easy-to-use mesh library for research purpose.
// Supporting arbitrary polygonal meshes as input, but with a
// primary focus on triangle meshes.
/* ================== File Information ================== */
// [Name]
// Macro.h
//
// [Developer]
// Xu Dong
// State Key Lab of CAD&CG, Zhejiang University
//
// [Date]
// 2005-08-05
//
// [Goal]
// Defining the global macros and enumerations.
#pragma once
#define PLATFORM_WINDOWS 1
#ifdef PLATFORM_WINDOWS
#define MESHLIB_ASSERT(a) ASSERT(a)
#endif
#include <cmath>
/* ================== Enumerations ================== */
typedef enum {SOLID_SMOOTH, SOLID_FLAT, WIREFRAME, SOLID_AND_WIREFRAME, VERTICES, HIGHLIGHT_ONLY, TEXTURE_MAPPING,
SELECT_NULL, SELECT_VERTEX, SELECT_EDGE, SELECT_FACE, } RENDER_MODE;
typedef enum {TRANSLATE, SCALE, ROTATE, NONE} TRANSFORM_MODE;
typedef enum {FACE, EDGE, VERTEX} PICKING_MODE;
typedef enum {AXIS_X, AXIS_Y, AXIS_Z} AXIS;
typedef enum {R=0, G, B} COLOR;
/* ================== Constants ================== */
const double PI = 3.1415926535897932384626433832795;
const double PI_12 = 1.5707963267948966192313216916395;
const double LARGE_ZERO_EPSILON = 1.0E-8;
const double SMALL_ZERO_EPSILON = 1.0E-16;
/* ================== Math Macros ================== */
// Min & Max & ABS
template <typename T> inline T Max3(const T& a, const T& b, const T& c)
{
return (a > b) ? ( a > c ? a : c) : ( b > c ? b : c);
}
template <typename T> inline T Min3(const T& a, const T& b, const T& c)
{
return (a < b) ? ( a < c ? a : c) : ( b < c ? b : c);
}
// Equal within epsilon tolerance
inline bool ALMOST_EQUAL_LARGE(double x, double y)
{
return (fabs(x - y) < LARGE_ZERO_EPSILON);
}
inline bool ALMOST_EQUAL_SMALL(double x, double y)
{
return (fabs(x - y) < SMALL_ZERO_EPSILON);
}
inline bool GreaterEqual(double a, double b, double epsilon=LARGE_ZERO_EPSILON)
{
return (a > b) || ( fabs(a - b) < epsilon);
}
inline bool LessEqual(double a, double b, double epsilon = LARGE_ZERO_EPSILON)
{
return (a < b) || ( fabs(a - b) < epsilon);
}
// Degree & Radius
#define DEG2RAD(d) ((d)*0.017453292519943295769236907684886)
#define RAD2DEG(r) ((r)*57.29577951308232087679815481410500)
| [
"[email protected]"
]
| [
[
[
1,
103
]
]
]
|
ee19d8d6bde9978ef80619ec4b45585bb788a9aa | 2ca3ad74c1b5416b2748353d23710eed63539bb0 | /Src/Lokapala/Operator/DharaniFacade.h | 04986db57274474eba1bbd8aff5c58a59ea2465f | []
| no_license | sjp38/lokapala | 5ced19e534bd7067aeace0b38ee80b87dfc7faed | dfa51d28845815cfccd39941c802faaec9233a6e | refs/heads/master | 2021-01-15T16:10:23.884841 | 2009-06-03T14:56:50 | 2009-06-03T14:56:50 | 32,124,140 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 989 | h | /**@file DharaniFacade.h
* @brief Dharani component의 facade
* @author siva
*/
#ifndef DHARANI_FACADE_H
#define DHARANI_FACADE_H
#include "DharaniInterface.h"
#include "DharaniDTO.h"
/**@ingroup GroupDharani
* @class CDharaniFacade
* @brief Dharani Component의 Facade. Interface를 상속받아 실질적인 행동을 한다.
*/
class CDharaniFacade : public CDharaniInterface
{
public :
static CDharaniFacade *Instance()
{
if(!m_instance)
{
m_instance = new CDharaniFacade();
}
return m_instance;
}
virtual void DharaniSendTextMessageTo(CDharaniDTO *a_sendData);
virtual void DharaniBroadcastTextMessage(CDharaniDTO *a_sendData);
virtual void DharaniSendTextToServer(CDharaniDTO *a_sendData);
virtual void DharaniServerInitiallize(void);
virtual int DharaniClientInitiallize(DWORD a_ServerAddress);
CDharaniFacade(){}
~CDharaniFacade(){}
protected :
private :
static CDharaniFacade *m_instance;
};
#endif
| [
"nilakantha38@b9e76448-5c52-0410-ae0e-a5aea8c5d16c"
]
| [
[
[
1,
42
]
]
]
|
0ba73bd65da878983332d627b99f5b98eb4ad66a | 5dfa2f8acf81eb653df4a35a76d6be973b10a62c | /branches/test/CCV_Select_Camera/addons/ofxNCore/src/MultiCams/SetDevices.cpp | 27ff0103515ccc167a40656b53159925ab82712e | []
| no_license | guozanhua/ccv-multicam | d69534ff8592f7984a5eadc83ed8b20b9d3df949 | 31206f0de7f73b3d43f2a910fdcdffb7ed1bf2c2 | refs/heads/master | 2021-01-22T14:24:52.321877 | 2011-08-31T14:18:44 | 2011-08-31T14:18:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,224 | cpp | //! SetDevices.cpp
/*!
*
*
* Created by Yishi Guo on 05/31/2011.
* Copyright 2011 NUI Group. All rights reserved.
*
*/
//--------------------------------------------------------------
#include "SetDevices.h"
//--------------------------------------------------------------
SetDevices::SetDevices() {
bShowInterface = false;
utils = NULL;
currentCamera = NULL;
//! display info at beginning
bShowInfo = true;
//! init the camera index offset to zero
mCamIndex = 0;
//! init the devices index offset to zero
mDevIndexOffset = 0;
}
//--------------------------------------------------------------
void SetDevices::setup() {
testInt = 0;
testFont.loadFont( "verdana.ttf", 200, true, true, false );
controls = ofxGui::Instance( this );
setupControls();
}
//--------------------------------------------------------------
void SetDevices::update() {
camGrid->update();
devGrid->update();
}
//--------------------------------------------------------------
void SetDevices::passInCamsUtils( CamsUtils* utils ) {
this->utils = utils;
}
//--------------------------------------------------------------
void SetDevices::setShowCamRawId( int id ) {
if ( utils == NULL ) {
return;
}
if ( id < utils->getCount() ) {
this->mDevIndexOffset = id;
this->mCamIndex = id;
}
}
//--------------------------------------------------------------
void SetDevices::handleGui( int parameterId, int task, void* data, int length ) {
switch ( parameterId ) {
//////////////////////////////////
// Devices List Panel
case devicesListPanel_grid:
if ( length == sizeof( int ) && task == kofxGui_Set_Int ) {
this->mCamIndex = *(int*)data;
this->camGrid->setOffset( mCamIndex );
if ( this->camGrid->getFirstImage() != NULL ) {
this->currentCamera = this->camGrid->getFirstImage()->getCamera();
} else {
this->currentCamera = NULL;
}
removePanel( informationPanel );
if ( this->currentCamera != NULL && bShowInfo ) {
addPanel( informationPanel );
}
}
break;
case devicesListPanel_arrow_up:
if ( length == sizeof(bool) ) {
if ( *(bool*)data) {
devGrid->previous();
mDevIndexOffset = devGrid->getIndexOffset();
}
}
break;
case devicesListPanel_arrow_down:
if ( length == sizeof(bool) ) {
if ( *(bool*)data ) {
devGrid->next();
mDevIndexOffset = devGrid->getIndexOffset();
}
}
break;
//////////////////////////////////
// Camera Display Panel
case cameraDisplayPanel_info:
if ( length == sizeof(bool) ) {
if ( *(bool*)data && !bShowInfo ) { // info panel should not display
//! Get the current camera information
if ( this->camGrid->getFirstImage() != NULL ) {
this->currentCamera = this->camGrid->getFirstImage()->getCamera();
} else {
this->currentCamera = NULL;
}
if ( this->currentCamera != NULL ) {
this->currentCamera->PrintInfo();
addPanel( informationPanel );
this->bShowInfo = true;
} else {
//! turn off the [show info] button
controls->update( cameraDisplayPanel_info, kofxGui_Set_Bool, &bShowInfo, sizeof( bool ) );
}
} else {
removePanel( informationPanel );
this->bShowInfo = false;
}
}
break;
//////////////////////////////////
// Information Panel
case informationPanel_hflip:
if ( length == sizeof(bool) ) {
if ( this->currentCamera != NULL ) {
this->currentCamera->SetHFlip( *(bool*)data );
}
}
break;
case informationPanel_vflip:
if ( length == sizeof( bool ) ) {
if ( this->currentCamera != NULL ) {
this->currentCamera->SetVFlip( *(bool*)data );
}
}
break;
case informationPanel_auto_gain:
if ( length == sizeof( bool ) ) {
if ( this->currentCamera != NULL ) {
this->currentCamera->SetAutoGain( *(bool*)data );
if ( !*(bool*)data ) { // use the manual value
this->currentCamera->SetGainValue( currentCamera->GetGainValue() );
}
}
}
break;
case informationPanel_gain:
if ( length == sizeof( float ) ) {
if ( this->currentCamera != NULL ) {
this->currentCamera->SetGainValue( (int)*(float*)data );
}
}
break;
case informationPanel_auto_exposure:
if ( length == sizeof( bool ) ) {
if ( this->currentCamera != NULL ) {
this->currentCamera->SetAutoExposure( *(bool*)data );
if ( !*(bool*)data ) { // use the manual value
this->currentCamera->SetExposure( currentCamera->GetExposure() );
}
}
}
break;
case informationPanel_exposure:
if ( length == sizeof( float ) ) {
if ( this->currentCamera != NULL ) {
this->currentCamera->SetExposure( (int)*(float*)data );
}
}
break;
case informationPanel_auto_whitebalance:
if ( length == sizeof( bool ) ) {
if ( this->currentCamera != NULL ) {
this->currentCamera->SetAutoWhiteBalance( *(bool*)data );
if ( !*(bool*)data ) {
this->currentCamera->SetWhiteBalanceRed( currentCamera->GetWhiteBalanceRed() );
this->currentCamera->SetWhiteBalanceGreen( currentCamera->GetWhiteBalanceGreen() );
this->currentCamera->SetWhiteBalanceBlue( currentCamera->GetWhiteBalanceBlue() );
}
}
}
break;
case informationPanel_whitebalance_red:
if ( length == sizeof( float ) ) {
if ( this->currentCamera != NULL ) {
this->currentCamera->SetWhiteBalanceRed( (int)*(float*)data );
}
}
break;
case informationPanel_whitebalance_green:
if ( length == sizeof( float ) ) {
if ( this->currentCamera != NULL ) {
this->currentCamera->SetWhiteBalanceGreen( (int)*(float*)data );
}
}
break;
case informationPanel_whitebalance_blue:
if ( length == sizeof( float ) ) {
if ( this->currentCamera != NULL ) {
this->currentCamera->SetWhiteBalanceBlue( (int)*(float*)data );
}
}
break;
//////////////////////////////////
// Settings Panel
case settingsPanel_reset:
if ( length == sizeof(bool) ) {
if ( *(bool*)data ) {
if ( utils != NULL ) {
utils->resetCams();
//! Refresh the panel info
if ( bShowInfo ) {
removePanel( informationPanel );
addPanel( informationPanel );
}
}
}
}
break;
case settingsPanel_save:
if ( length == sizeof(bool) ) {
if ( *(bool*)data ) {
showInterface( false );
}
}
break;
case settingsPanel_cancel:
if ( length == sizeof(bool) ) {
if ( *(bool*)data ) {
showInterface( false );
}
}
break;
default:
break;
}
}
//--------------------------------------------------------------
void SetDevices::setupControls() {
// TODO
}
//--------------------------------------------------------------
void SetDevices::draw() {
ofSetColor( 0x33aa33 );
ofFill();
ofRect( 0, 0, ofGetWidth(), ofGetHeight() );
//ofSetColor( 0xFFFFFF );
//testInt++;
//string testStr = ofToString( testInt );
//testFont.drawString( testStr,
// ofGetWidth()/2 - testFont.stringWidth(testStr)/2,
// ofGetHeight()/2 + testFont.stringHeight(testStr)/2 );
controls->draw();
}
//--------------------------------------------------------------
void SetDevices::addPanels() {
// TODO
this->addPanel( devicesListPanel );
//! Set the devices index offset
this->devGrid->setOffset( this->mDevIndexOffset );
this->addPanel( cameraDisplayPanel );
//! Set the camera index offset
this->camGrid->setOffset( this->mCamIndex );
if ( this->camGrid->getFirstImage() != NULL ) {
this->currentCamera = this->camGrid->getFirstImage()->getCamera();
}
if ( bShowInfo && currentCamera != NULL ) {
this->addPanel( informationPanel );
}
this->addPanel( settingsPanel );
controls->forceUpdate( true );
controls->activate( true );
}
//--------------------------------------------------------------
void SetDevices::addPanel( int id ) {
ofxGuiPanel* pPanel;
switch ( id ) {
//////////////////////////////////
case cameraDisplayPanel:
pPanel = controls->addPanel( cameraDisplayPanel,
"Camera Display", 30, 30,
OFXGUI_PANEL_BORDER, OFXGUI_PANEL_SPACING );
camGrid = (ofxGuiGrid*)pPanel->addGrid( cameraDisplayPanel_grid, "",
640, 480, 1, 1, 0, 0, kofxGui_Grid_List );
camGrid->setCamsUtils( utils );
camGrid->setActive( false ); //! Disable the mouse event for this control
camGrid->setDrawInfo( true );
pPanel->addButton( cameraDisplayPanel_info,
"Show Info", OFXGUI_BUTTON_HEIGHT, OFXGUI_BUTTON_HEIGHT,
bShowInfo, kofxGui_Button_Switch );
//pPanel->mObjects[1]->mObjX = 380; // [1]: "Show Info" button
//pPanel->mObjects[1]->mObjY = 510;
pPanel->mObjWidth = 660;
pPanel->mObjHeight = 540;
pPanel->adjustToNewContent( 640, 0 );
break;
//////////////////////////////////
case devicesListPanel:
pPanel = controls->addPanel( devicesListPanel,
"Devices List", 720, 30,
OFXGUI_PANEL_BORDER, OFXGUI_PANEL_SPACING );
pPanel->addArrow( devicesListPanel_arrow_up, "",
180, 35, kofxGui_Arrow_Up, 5 );
devGrid = (ofxGuiGrid*)pPanel->addGrid( devicesListPanel_grid, "",
180, 270, 1, DEVGRID_Y_GRID, 10, 10, kofxGui_Grid_List );
devGrid->setCamsUtils( utils );
pPanel->addArrow( devicesListPanel_arrow_down, "",
180, 35, kofxGui_Arrow_Down, 5 );
pPanel->mObjWidth = 200;
pPanel->mObjHeight = 400;
break;
//////////////////////////////////
case informationPanel:
pPanel = controls->addPanel( informationPanel,
"Information", 350, 200,
OFXGUI_PANEL_BORDER, OFXGUI_PANEL_SPACING );
pPanel->addLabel( informationPanel_uuid, "UUID", 260, 10,
"UUID: " + (this->currentCamera == NULL ? "NONE!" : PS3::GUID2String( this->currentCamera->GetGUID(), '_', true ) ),
&(controls->mGlobals->mParamFont), controls->mGlobals->mTextColor );
//! For this moment, the type is hard-code with "PS3"
pPanel->addLabel( informationPanel_type, "Type", 260, 10,
"Type: PS3", &(controls->mGlobals->mParamFont), controls->mGlobals->mTextColor );
pPanel->addButton( informationPanel_hflip, "Horizontal Flip",
OFXGUI_BUTTON_HEIGHT, OFXGUI_BUTTON_HEIGHT,
this->currentCamera->GetHFlip(), kofxGui_Button_Switch );
pPanel->addButton( informationPanel_vflip, "Vertical Flip",
OFXGUI_BUTTON_HEIGHT, OFXGUI_BUTTON_HEIGHT,
this->currentCamera->GetVFlip(), kofxGui_Button_Switch );
//! Gain
pPanel->addButton( informationPanel_auto_gain, "Auto Gain",
OFXGUI_BUTTON_HEIGHT, OFXGUI_BUTTON_HEIGHT,
this->currentCamera->GetAutoGain(), kofxGui_Button_Switch );
pPanel->addSlider( informationPanel_gain, "Gain",
150, 10, 0.0f, 79.0f,
this->currentCamera->GetGainValue(), kofxGui_Display_Int, 0 );
//! Exposure
pPanel->addButton( informationPanel_auto_exposure, "Auto Exposure",
OFXGUI_BUTTON_HEIGHT, OFXGUI_BUTTON_HEIGHT,
this->currentCamera->GetAutoExposure(), kofxGui_Button_Switch );
pPanel->addSlider( informationPanel_exposure, "Exposure",
150, 10, 0.0f, 511.0f,
this->currentCamera->GetExposure(), kofxGui_Display_Int, 0 );
//! White balance
pPanel->addButton( informationPanel_auto_whitebalance, "Auto Whitebalance",
OFXGUI_BUTTON_HEIGHT, OFXGUI_BUTTON_HEIGHT,
this->currentCamera->GetAutoWhiteBalance(), kofxGui_Button_Switch );
pPanel->addSlider( informationPanel_whitebalance_red, "Whitebalance Red",
150, 10, 0.0f, 255.0f,
this->currentCamera->GetWhiteBalanceRed(), kofxGui_Display_Int, 0 );
pPanel->addSlider( informationPanel_whitebalance_green, "Whitebalance Green",
150, 10, 0.0f, 255.0f,
this->currentCamera->GetWhiteBalanceGreen(), kofxGui_Display_Int, 0 );
pPanel->addSlider( informationPanel_whitebalance_blue, "Whitebalance Blue",
150, 10, 0.0f, 255.0f,
this->currentCamera->GetWhiteBalanceBlue(), kofxGui_Display_Int, 0 );
pPanel->mObjWidth = 270;
pPanel->mObjHeight = 360;
break;
//////////////////////////////////
case settingsPanel:
pPanel = controls->addPanel( settingsPanel,
"Settings", 720, 460,
OFXGUI_PANEL_BORDER, OFXGUI_PANEL_SPACING );
pPanel->addButton( settingsPanel_reset,
"Reset All", OFXGUI_BUTTON_HEIGHT, OFXGUI_BUTTON_HEIGHT,
kofxGui_Button_Off, kofxGui_Button_Trigger );
pPanel->addButton( settingsPanel_save,
"Back", OFXGUI_BUTTON_HEIGHT, OFXGUI_BUTTON_HEIGHT,
kofxGui_Button_Off, kofxGui_Button_Trigger );
//pPanel->addButton( settingsPanel_cancel,
// "Cancel", OFXGUI_BUTTON_HEIGHT, OFXGUI_BUTTON_HEIGHT,
// kofxGui_Button_Off, kofxGui_Button_Trigger );
pPanel->mObjWidth = 200;
pPanel->mObjHeight = 110;
break;
default:
break;
}
}
//--------------------------------------------------------------
void SetDevices::removePanels() {
removePanel( cameraDisplayPanel );
removePanel( devicesListPanel );
removePanel( informationPanel );
removePanel( settingsPanel );
}
//--------------------------------------------------------------
void SetDevices::removePanel( int id ) {
controls->removePanel( id );
}
//--------------------------------------------------------------
void SetDevices::showInterface( bool bShow ) {
if ( bShow ) {
bShowInterface = true;
addPanels();
} else {
bShowInterface = false;
removePanels();
}
}
//-------------------------------------------------------------- | [
"baicaibang@da66ed7f-4d6a-8cb4-a557-1474cfe16edc"
]
| [
[
[
1,
437
]
]
]
|
a0d1f3a07ecd7abe592f672d6a54e46855dc8fdd | 5095bbe94f3af8dc3b14a331519cfee887f4c07e | /Shared/ComponentInterface/Variable.h | 8932b8d20647c331b37b132f405cf39a5b7d3646 | []
| no_license | sativa/apsim_development | efc2b584459b43c89e841abf93830db8d523b07a | a90ffef3b4ed8a7d0cce1c169c65364be6e93797 | refs/heads/master | 2020-12-24T06:53:59.364336 | 2008-09-17T05:31:07 | 2008-09-17T05:31:07 | 64,154,433 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,154 | h | //---------------------------------------------------------------------------
#ifndef VariableH
#define VariableH
#include <string>
#include <vector>
#include <general/platform.h>
#include <ComponentInterface/Interfaces.h>
namespace protocol {
class EXPORT Variable : public IData
// --------------------------------------------------------------
// This class wraps a variable from an APSIM module.
// --------------------------------------------------------------
{
public:
Variable() : data(NULL) { }
Variable(bool value);
Variable(int value);
Variable(float value);
Variable(double value);
Variable(const std::string& value);
Variable(const std::vector<bool>& value);
~Variable() {delete data;}
Variable(const Variable& rhs);
Variable& operator=(const Variable& rhs);
virtual Variable* Clone() const;
virtual void Pack(protocol::MessageData& message);
virtual void Unpack(protocol::MessageData & message);
virtual std::string DDML();
virtual unsigned Size();
private:
IData* data;
};
}
#endif
| [
"hol353@8bb03f63-af10-0410-889a-a89e84ef1bc8",
"devoilp@8bb03f63-af10-0410-889a-a89e84ef1bc8"
]
| [
[
[
1,
6
],
[
8,
12
],
[
14,
43
]
],
[
[
7,
7
],
[
13,
13
]
]
]
|
b23cdd1e0a8167460dc6261a7173b2e8a71c4520 | 5927f0908f05d3f58fe0adf4d5d20c27a4756fbe | /examples/igantt/gantt_view_delegate.cpp | a19a24a330c268adb55e3ee156ed362cdeab9d6f | []
| 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 | 1,539 | cpp |
#include "gantt_view_delegate.h"
#include "base/logging.h"
#include "ui_gfx/icon_util.h"
#include "ui_gfx/image/image.h"
#include "ui_base/clipboard/clipboard.h"
#include "ui_base/resource/resource_bundle.h"
#include "../wanui_res/resource.h"
GanttViewDelegate::GanttViewDelegate() : default_parent_view_(NULL)
{
DCHECK(!view::ViewDelegate::view_delegate);
view::ViewDelegate::view_delegate = this;
}
GanttViewDelegate::~GanttViewDelegate()
{
view::ViewDelegate::view_delegate = NULL;
}
ui::Clipboard* GanttViewDelegate::GetClipboard() const
{
if(!clipboard_.get())
{
// Note that we need a MessageLoop for the next call to work.
clipboard_.reset(new ui::Clipboard());
}
return clipboard_.get();
}
view::View* GanttViewDelegate::GetDefaultParentView()
{
return default_parent_view_;
}
void GanttViewDelegate::SaveWindowPlacement(
const view::Widget* widget,
const std::wstring& window_name,
const gfx::Rect& bounds,
ui::WindowShowState show_state) {}
bool GanttViewDelegate::GetSavedWindowPlacement(
const std::wstring& window_name,
gfx::Rect* bounds,
ui::WindowShowState* show_state) const
{
return false;
}
HICON GanttViewDelegate::GetDefaultWindowIcon() const
{
return IconUtil::CreateHICONFromSkBitmap(
ui::ResourceBundle::GetSharedInstance().GetImageNamed(
IDR_PRODUCT_LOGO_16));
}
int GanttViewDelegate::GetDispositionForEvent(int event_flags)
{
return 0;
} | [
"[email protected]"
]
| [
[
[
1,
62
]
]
]
|
ffc9d4c2806c0ef55594af40b3d7f198ba425db1 | 29c5bc6757634a26ac5103f87ed068292e418d74 | /src/tlclasses/CLevel.h | 046a7c09b39fb6f205de10879bccd7afc64c9770 | []
| no_license | drivehappy/tlapi | d10bb75f47773e381e3ba59206ff50889de7e66a | 56607a0243bd9d2f0d6fb853cddc4fce3e7e0eb9 | refs/heads/master | 2021-03-19T07:10:57.343889 | 2011-04-18T22:58:29 | 2011-04-18T22:58:29 | 32,191,364 | 5 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,257 | h | #pragma once
#include "_CList.h"
#include "_CLinkedListNode.h"
#include "CQuadTree.h"
#include "CCollisionList.h"
#include "CCharacter.h"
#include "CResourceManager.h"
#include "CAstarPathFinder.h"
#include "CEquipment.h"
#include "CLevelTemplateData.h"
#include "CAutomap.h"
#include "CChunk.h"
#include "CLevelLayout.h"
#include "CGameClient.h"
#include "CParticle.h"
namespace TLAPI
{
#pragma pack(1)
// Forward decl
struct CLayout;
struct CResourceManager;
struct CLevel;
TLFUNC(LevelDropItem, PVOID, __thiscall, (CLevel*, CItem*, Vector3 &, bool));
TLFUNC(LevelCharacterInitialize, CCharacter*, __thiscall, (CLevel*, CCharacter*, Vector3*, u32));
TLFUNC(Level_CharacterKilledCharacter, void, __thiscall, (CLevel*, CCharacter*, CCharacter*, Vector3*, u32));
TLFUNC(Level_RemoveEquipment, void, __thiscall, (CLevel*, CEquipment*));
TLFUNC(Level_CheckCharacterProximity, void, __thiscall, (CLevel*, Vector3*, u32, float, float, float, u32, CCharacter*, u32));
TLFUNC(Level_RemoveCharacter, void, __thiscall, (CLevel*, CCharacter*));
//
struct CLevel : CRunicCore
{
u32 unk0;
CList<CLayout*> CLayoutsList;
CList<float> unkFloatList; // @18h
u32 unk5[5];
CQuadtree *pCQuadTree; // @3Ch
CCollisionList *pCCollisionList; // @40h
u32 unk11[6]; // @44h
LinkedListNode **charactersProximity; // @5Ch
LinkedListNode **itemsProximity; // @60h
LinkedListNode **charactersAll; // @64h
LinkedListNode **itemsAll; // @68h
CList<CParticle*> particleList; // @6Ch
PVOID unk18[3];
vector<u32> vecUnk1;
u32 unk19[8]; // 3 dup( 0), 0Ah,3 dup( 0), 0Ah
vector<u32> vecUnk2;
float unk20[22];
u32 unk21[6];
Ogre::SceneManager *pOctreeSM;
Ogre::StaticGeometry *pOgreStaticGeom[4];
CLevelTemplateData* pCLevelTemplateData;
CAutomap* pCAutomap;
u32 unk22[3];
CChunk **ppCChunk;
u32 unk23[6];
CLevelLayout* pCLevelLayout;
CGameClient* pCGameClient;
u32 unk24[2];
float unk25[4];
u32 unk26[12];
CList<CLayout*> layoutList;
float unk27; // 40.0
wstring levelName;
//
// Function hooks
// Player Initialization
EVENT_DECL(CLevel, void, LevelCharacterInitialize,
(CCharacter*, CLevel*, CCharacter*, Vector3*, u32, bool&),
((CCharacter*)e->retval, (CLevel*)e->_this, (CCharacter*)Pz[0], (Vector3*)Pz[1], Pz[2], e->calloriginal));
// Create AstarPathFinder - This appears to be a static member function
EVENT_DECL(CLevel, void, LevelCreateAstarPathfinding,
(CAstarPathfinder*, float, float, u32, u32, PVOID, PVOID, float),
((CAstarPathfinder*)e->retval, *(float*)&Pz[0], *(float*)&Pz[1], Pz[2], Pz[3], (PVOID)Pz[4], (PVOID)Pz[5], *(float*)&Pz[6]));
// Drop Equipment
EVENT_DECL(CLevel, void, LevelDropItem,
(CLevel*, CItem*, Vector3 &, bool, bool&),
((CLevel*)e->_this, (CItem*)Pz[0], *(Vector3*)Pz[1], (bool)Pz[2], e->calloriginal));
// Character Killed
EVENT_DECL(CLevel, void, Level_CharacterKilledCharacter,
(CLevel*, CCharacter*, CCharacter*, Vector3*, u32, bool&),
((CLevel*)e->_this, (CCharacter*)Pz[0], (CCharacter*)Pz[1], (Vector3*)Pz[2], Pz[3], e->calloriginal));
// Level Dtor
EVENT_DECL(CLevel, void, Level_Dtor,
(CLevel*, u32, bool&),
((CLevel*)e->_this, Pz[0], e->calloriginal));
// Level Ctor
EVENT_DECL(CLevel, void, Level_Ctor,
(wstring name, CSettings*, CGameClient*, CResourceManager*, PVOID OctreeSM, CSoundManager*, u32, u32, bool&),
(*(wstring*)&Pz[0], (CSettings*)Pz[7], (CGameClient*)Pz[8], (CResourceManager*)Pz[9], (PVOID)Pz[10], (CSoundManager*)Pz[11], Pz[12], Pz[13], e->calloriginal));
// Level Update
EVENT_DECL(CLevel, void, Level_Update,
(CLevel*, Vector3*, u32, float, bool&),
((CLevel*)e->_this, (Vector3*)Pz[0], Pz[1], *(float*)&Pz[2], e->calloriginal));
// Level Cleanup
EVENT_DECL(CLevel, void, Level_Cleanup,
(CLevel*, u32, u32, bool&),
((CLevel*)e->_this, Pz[0], Pz[1], e->calloriginal));
// Level Remove Equipment
EVENT_DECL(CLevel, void, Level_RemoveEquipment,
(CLevel*, CEquipment*, bool&),
((CLevel*)e->_this, (CEquipment*)Pz[0], e->calloriginal));
// Level Proximity Check
EVENT_DECL(CLevel, void, Level_CheckCharacterProximity,
(CCharacter*, CLevel*, Vector3*, u32, float, float, float, u32, CCharacter*, u32, bool&),
((CCharacter*)e->retval, (CLevel*)e->_this, (Vector3*)Pz[0], Pz[1], *(float*)&Pz[2], *(float*)&Pz[3], *(float*)&Pz[4], Pz[5], (CCharacter*)Pz[6], Pz[7], e->calloriginal));
// Level Remove Character
EVENT_DECL(CLevel, void, Level_RemoveCharacter,
(CLevel*, CCharacter*, bool&),
((CLevel*)e->_this, (CCharacter*)Pz[0], e->calloriginal));
// Level
EVENT_DECL(CLevel, void, Level_RemoveItem,
(CLevel*, CItem*, bool&),
((CLevel*)e->_this, (CItem*)Pz[0], e->calloriginal));
// Character Killed
void CharacterKill(CCharacter* attacker, CCharacter* killed, Vector3* position, u32 unk0) {
Level_CharacterKilledCharacter(this, attacker, killed, position, unk0);
}
// Item drop
void ItemDrop(CItem* item, Vector3 & position, bool unk) {
LevelDropItem(this, item, position, unk0);
}
// Equipment drop ^^ Same call, just diff name
void EquipmentDrop(CItem* item, Vector3 & position, bool unk) {
LevelDropItem(this, item, position, unk0);
}
void CharacterInitialize(CCharacter* character, Vector3* position, u32 unk0) {
LevelCharacterInitialize(this, character, position, unk0);
}
void RemoveCharacter(CCharacter* character) {
Level_RemoveCharacter(this, character);
}
void DumpCharacters1() {
/*
LinkedListNode* itr = *ppCCharacters1;
while (itr != NULL) {
CCharacter* character = (CCharacter*)itr->pCBaseUnit;
logColor(B_GREEN, L" Level Character1: (itr = %p) %p %s", itr, character, character->characterName.c_str());
//multiplayerLogger.WriteLine(Info, L" Level Item: (itr = %p) %p %s", itr, character, character->characterName.c_str());
itr = itr->pNext;
}
*/
}
void DumpTriggerUnits() {
LinkedListNode* itr = *itemsProximity;
while (itr != NULL) {
CTriggerUnit* triggerUnit = (CTriggerUnit*)itr->pCBaseUnit;
log(L" Level TriggerUnit: (itr = %p) %p %s (%f, %f, %f) Type: %x", itr, triggerUnit, triggerUnit->nameReal.c_str(),
triggerUnit->GetPosition().x, triggerUnit->GetPosition().y, triggerUnit->GetPosition().z, triggerUnit->type__);
itr = itr->pNext;
}
}
void DumpCharacters2() {
LinkedListNode* itr = *charactersAll;
while (itr != NULL) {
CCharacter* character = (CCharacter*)itr->pCBaseUnit;
logColor(B_GREEN, L" Level Character2: (itr = %p) %p %s", itr, character, character->characterName.c_str());
itr = itr->pNext;
}
}
vector<CCharacter*>& GetCharacters() {
vector<CCharacter*>* retval = new vector<CCharacter*>();
LinkedListNode* itr = *charactersAll;
while (itr != NULL) {
CCharacter* character = (CCharacter*)itr->pCBaseUnit;
retval->push_back(character);
itr = itr->pNext;
}
return *retval;
}
int GetCharacterCount() {
int count = 0;
LinkedListNode* itr = *charactersAll;
while (itr != NULL) {
count++;
itr = itr->pNext;
}
return count;
}
void DumpItems() {
LinkedListNode* itr = *itemsAll;
while (itr != NULL) {
//log(L" Level Item: itr = %p", itr);
CItem* item = (CItem*)itr->pCBaseUnit;
log(L" itrNext: %p, Item: %p, Name: %s (%f %f %f)",
itr->pNext, item, item->nameReal.c_str(),
item->GetPosition().x, item->GetPosition().y, item->GetPosition().z);
//log(L" vtable: %p dtor: %p", *(u32*)(itr->pCBaseUnit), **(u32**)(itr->pCBaseUnit));
//multiplayerLogger.WriteLine(Info, L" Level Item: (itr = %p) %p %s", itr, item, item->nameReal.c_str());
itr = itr->pNext;
}
log(L"Done Dumping.");
}
bool containsItem(CItem* itemSearch) {
LinkedListNode* itr = *itemsAll;
while (itr != NULL) {
CItem* item = (CItem*)itr->pCBaseUnit;
if (item == itemSearch)
return true;
itr = itr->pNext;
}
return false;
}
};
#pragma pack()
};
| [
"drivehappy@53ea644a-42e2-1498-a4e7-6aa81ae25522"
]
| [
[
[
1,
278
]
]
]
|
41004d73524c43f574828cfaea8110b6561e01d5 | 6114db1d18909e8d38365a81ab5f0b1221c6d479 | /Sources/ExpressionParser/AssemblyInfo.cpp | 04c87df3179d13ff1c8447a4faec7fc57bb8bcaa | []
| no_license | bitmizone/asprofiled | c6bf81e89037b68d0a7c8a981be3cd9c8a4db7c7 | b54cb47b1d3ee1ce6ad7077960394ddd5578c0ff | refs/heads/master | 2021-01-10T14:14:42.048633 | 2011-06-21T11:38:26 | 2011-06-21T11:38:26 | 48,724,442 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,348 | 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("ExpressionParser")];
[assembly:AssemblyDescriptionAttribute("")];
[assembly:AssemblyConfigurationAttribute("")];
[assembly:AssemblyCompanyAttribute("")];
[assembly:AssemblyProductAttribute("ExpressionParser")];
[assembly:AssemblyCopyrightAttribute("Copyright (c) 2009")];
[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)];
| [
"adamsonic@cf2cc628-70ab-11de-90d8-1fdda9445408"
]
| [
[
[
1,
40
]
]
]
|
01679fa8d313e914bdee60b44e50809b9e26ec94 | cfa6cdfaba310a2fd5f89326690b5c48c6872a2a | /Sources/Tutorials/Simple Chat/Client/Client/Client.cpp | b0a7bba2a8149140275e7ff1159a22b52213c5bd | []
| no_license | asdlei00/project-jb | 1cc70130020a5904e0e6a46ace8944a431a358f6 | 0bfaa84ddab946c90245f539c1e7c2e75f65a5c0 | refs/heads/master | 2020-05-07T21:41:16.420207 | 2009-09-12T03:40:17 | 2009-09-12T03:40:17 | 40,292,178 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 2,497 | cpp |
// Client.cpp : 응용 프로그램에 대한 클래스 동작을 정의합니다.
//
#include "stdafx.h"
#include "Client.h"
#include "ClientDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CClientApp
BEGIN_MESSAGE_MAP(CClientApp, CWinAppEx)
ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()
// CClientApp 생성
CClientApp::CClientApp()
{
// TODO: 여기에 생성 코드를 추가합니다.
// InitInstance에 모든 중요한 초기화 작업을 배치합니다.
}
// 유일한 CClientApp 개체입니다.
CClientApp theApp;
// CClientApp 초기화
BOOL CClientApp::InitInstance()
{
// 응용 프로그램 매니페스트가 ComCtl32.dll 버전 6 이상을 사용하여 비주얼 스타일을
// 사용하도록 지정하는 경우, Windows XP 상에서 반드시 InitCommonControlsEx()가 필요합니다.
// InitCommonControlsEx()를 사용하지 않으면 창을 만들 수 없습니다.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// 응용 프로그램에서 사용할 모든 공용 컨트롤 클래스를 포함하도록
// 이 항목을 설정하십시오.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinAppEx::InitInstance();
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
// 표준 초기화
// 이들 기능을 사용하지 않고 최종 실행 파일의 크기를 줄이려면
// 아래에서 필요 없는 특정 초기화
// 루틴을 제거해야 합니다.
// 해당 설정이 저장된 레지스트리 키를 변경하십시오.
// TODO: 이 문자열을 회사 또는 조직의 이름과 같은
// 적절한 내용으로 수정해야 합니다.
SetRegistryKey(_T("로컬 응용 프로그램 마법사에서 생성된 응용 프로그램"));
CClientDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: 여기에 [확인]을 클릭하여 대화 상자가 없어질 때 처리할
// 코드를 배치합니다.
}
else if (nResponse == IDCANCEL)
{
// TODO: 여기에 [취소]를 클릭하여 대화 상자가 없어질 때 처리할
// 코드를 배치합니다.
}
// 대화 상자가 닫혔으므로 응용 프로그램의 메시지 펌프를 시작하지 않고 응용 프로그램을 끝낼 수 있도록 FALSE를
// 반환합니다.
return FALSE;
}
| [
"[email protected]"
]
| [
[
[
1,
85
]
]
]
|
d3c7864d2bd225c2cb955f5333a7ef88a6a175e3 | 841e58a0ee1393ddd5053245793319c0069655ef | /Karma/Headers/GuiMouseOver.h | 577018c1ce2f5d07e04f06457e1439980a01f40c | []
| no_license | dremerbuik/projectkarma | 425169d06dc00f867187839618c2d45865da8aaa | faf42e22b855fc76ed15347501dd817c57ec3630 | refs/heads/master | 2016-08-11T10:02:06.537467 | 2010-06-09T07:06:59 | 2010-06-09T07:06:59 | 35,989,873 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,785 | h | /*---------------------------------------------------------------------------------*/
/* File: GuiMouseOver.h */
/* Author: Per Karlsson, [email protected] */
/* */
/* Description: GuiMouseOver is a class that takes cares of GUI elements that */
/* has mouseOver effects and functions. For clarification in this class, */
/* MOE = MouseOverElement */
/*---------------------------------------------------------------------------------*/
#ifndef GUIMOUSEOVER_H
#define GUIMOUSEOVER_H
#include <vector>
#include <Ogre.h>
#include <OISMouse.h>
#include "AppState.h"
template <class T> class GuiMouseOver
{
public:
/* Information about every MouseOverElement(MOE).
3 different overlay elements
Normal = Normal state.
MouseOver = MouseOver state.
Locked = Locked/Hidden/Not available.
onGuiMouseOverPressFunction = Pointer to a function inside this class.
onStatePressFunction = Function outside the class bound with the element. Will be fired when the element is pressed
lockReleationships = vector of IDs of elements that should be locked when the element is pressed.
unlockRelationships = vector of IDs of elements taht should be unlocked when the element is pressed.
*/
struct mouseOverElement
{
Ogre::OverlayElement *overlay,*overlayMOE,*overlayLocked;
Ogre::Real left,right,top,bottom;
void (GuiMouseOver::*onGuiMouseOverPressFunction)();
void (T::*onStatePressFunction)();
bool locked;
std::vector<int> *lockRelationships, *unlockRelationships;
};
/* state = use this-pointer from the state you're calling GuiMouseOver from.
s = name of the GUI overlay.*/
GuiMouseOver(T* state, Ogre::String& s);
~GuiMouseOver();
/* Adds a vector containing the lockRelationship for a MOE. See struct mouseOverElement */
void addLockedRelation(int currentMOE, std::vector<int> relationshipMOEs);
/* Adds a Mouse Over element.
s = Name of the normal GUI component.
onStatePressFunction = Function that will be fired when the element is pressed.
lockedAvailable = Can the MOE be locked/hidden?
locked = Is it by default locked?*/
int addMouseOver(Ogre::String &s,void (T::*onStatePressFunction)(), bool lockedAvailable = false, bool locked = false);
/* Adds a vector containing the unlockRelationship for a MOE. See struct mouseOverElement */
void addUnlockedRelation(int currentMOE, std::vector<int> relationshipMOEs);
/* Checks if the mouse has intersected with any MOE. x and y = screen coordinates. */
bool checkMouseOver(const int x, const int y);
/* Fires the functions that is bound with the active MOE. Also changes locked/unlocked relationships.
Returns false if the element doesn't lock any MOEs. If the functions returns true, then we have to
manually reset the mvpCurrentMouseOver in the AppState. This is needed since we might quit the whole
application as a T::function, and then mvpCurrentMouseOver won't exist.*/
bool mousePressed();
/* Resets the current MOE. */
void resetMouseOver(){mvpCurrentMouseOver = NULL;};
private:
T* mvpClass;
int mvWindowWidth,mvWindowHeight;
mouseOverElement* mvpCurrentMouseOver;
bool mvMouseOver;
std::vector<mouseOverElement> mvMouseOverElements;
/* Returns true if the MOE is mouseOvered at the coordinates x and y */
bool isMouseOver(mouseOverElement &,const int x, const int y);
/* Lock the elements in the lockedRelationship vector of the MOE. */
void lockElements(mouseOverElement* mOE);
/* Either shows or hides the MOE. Default = Show. */
void showMouseOver(mouseOverElement* mOE, bool showMouseOver = true);
/* Unlock the elements in the unlockedRelationship vector of the MOE. */
void unlockElements(mouseOverElement* mOE);
};
#endif
/*---------------------------------------------------------------------------------*/
/* PUBLIC */
/*---------------------------------------------------------------------------------*/
template <class T> GuiMouseOver<T>::GuiMouseOver(T* state, Ogre::String& s)
{
//Associative pointer to the class that initiated the GuiMouseOver klass.
mvpClass = state;
//Start values for member variables.
mvpCurrentMouseOver=NULL;
mvMouseOver= 0;
//These are being used when initiating new MOEs.
mvWindowWidth = GameFramework::getSingletonPtr()->mpRenderWnd->getWidth();
mvWindowHeight = GameFramework::getSingletonPtr()->mpRenderWnd->getHeight();
//Load the overlay that hold our MOEs
Ogre::Overlay* GuiMouseOverOverlay = Ogre::OverlayManager::getSingleton().getByName(s);
GuiMouseOverOverlay->show();
//Loops through all elements in the Overlay and hides them (default = show);
Ogre::Overlay::Overlay2DElementsIterator Iter = GuiMouseOverOverlay->get2DElementsIterator();
while (Iter.hasMoreElements())
{
Ogre::OverlayContainer* pContainer = Iter.getNext();
Ogre::OverlayContainer::ChildIterator IterCont = pContainer->getChildIterator();
while (IterCont.hasMoreElements())
{
Ogre::OverlayElement* pElement = IterCont.getNext();
pElement->hide();
}
}
}
/*---------------------------------------------------------------------------------*/
template <class T> GuiMouseOver<T>::~GuiMouseOver()
{
GameFramework::getSingletonPtr()->mpLog->logMessage("Deleting GuiMouseOver stuff...");
//Deallocate earlier allocated vectors.
for (unsigned int i= 0; i < mvMouseOverElements.size();i++)
{
delete mvMouseOverElements[i].lockRelationships;
delete mvMouseOverElements[i].unlockRelationships;
}
}
/*---------------------------------------------------------------------------------*/
template <class T> void GuiMouseOver<T>::addLockedRelation(int currentMOE, std::vector<int> relationshipMOEs)
{
//Adds a vector that has information about what elements that's going to be locked when currentMOE is pressed.
mvMouseOverElements[currentMOE].lockRelationships = new std::vector<int>(relationshipMOEs);
}
/*---------------------------------------------------------------------------------*/
template <class T> void GuiMouseOver<T>::addUnlockedRelation(int currentMOE, std::vector<int> relationshipMOEs)
{
//Adds a vector that has information about what elements that's going to be unlocked when currentMOE is pressed.
mvMouseOverElements[currentMOE].unlockRelationships = new std::vector<int>(relationshipMOEs);
}
/*---------------------------------------------------------------------------------*/
template <class T> int GuiMouseOver<T>::addMouseOver(Ogre::String &s,void (T::*onStatePressFunction)(),bool lockedAvailable, bool locked)
{
mouseOverElement mOE;
mOE.locked = locked;
//NULL since we might not add any relationships. Easy to check to later on
mOE.lockRelationships = NULL;
mOE.unlockRelationships = NULL;
//Show normal overlay, hide the mouseOver.
mOE.overlay =Ogre::OverlayManager::getSingleton().getOverlayElement(s);
mOE.overlay->show();
mOE.overlayMOE =Ogre::OverlayManager::getSingleton().getOverlayElement(s + "MouseOver");
mOE.overlayMOE->hide();
//Loads the locked overlay element(if available)
if (lockedAvailable)
{
mOE.overlayLocked = Ogre::OverlayManager::getSingleton().getOverlayElement(s + "Locked");
//If locked = true then start as locked
if (locked)
{
mOE.overlayLocked->show();
mOE.overlay->hide();
}
else
{
mOE.overlayLocked->hide();
}
}
//Information about the size.
mOE.top = mOE.overlay->_getDerivedTop() * mvWindowHeight;
mOE.bottom = (mOE.overlay->_getDerivedTop() + mOE.overlay->_getHeight()) * mvWindowHeight;
mOE.left = mOE.overlay->_getDerivedLeft()* mvWindowWidth;
mOE.right = (mOE.overlay->_getDerivedLeft() + mOE.overlay->_getWidth() ) * mvWindowWidth;
//Pointer to the function that will be executed when element is pressed;
mOE.onStatePressFunction = onStatePressFunction;
//Add the mouseOverElement to the vector. Returns the index of the added vector element
mvMouseOverElements.push_back(mOE);
return mvMouseOverElements.size() - 1;
}
/*---------------------------------------------------------------------------------*/
template <class T> bool GuiMouseOver<T>::checkMouseOver(const int x, const int y)
{
/*mvpCurrentMouseOver is a pointer to the current mouseOverElement.
So if the cursor is over an element, we will start next frame by checking if it still is.
If that's the case, return, no need to continue looking.
If not, unload the pointer.
*/
//If mvpCurrentMouseOver== NULL then nothing was mouseOvered previous frame
if (mvpCurrentMouseOver)
{
//If element is not locked and isMouseOver return false, then change back to normal overlay
if( !mvpCurrentMouseOver->locked && !isMouseOver(*mvpCurrentMouseOver,x,y))
{
mvMouseOver = false;
showMouseOver(mvpCurrentMouseOver,false);
mvpCurrentMouseOver = NULL;
}
//Cursor is still at the same MOE. Do nothing.
else
return true;
}
//Loops through all elements to check possible mouseovers.
for (unsigned int i = 0; i < mvMouseOverElements.size(); i++)
{
if ( !mvMouseOverElements[i].locked && isMouseOver(mvMouseOverElements[i],x,y))
{
mvpCurrentMouseOver = &mvMouseOverElements[i];
//Change to mouseOver element
showMouseOver(mvpCurrentMouseOver);
mvMouseOver = true;
break;
}
}
//If any object is mouseOvered, this will return true.
return mvMouseOver;
}
/*---------------------------------------------------------------------------------*/
template <class T> bool GuiMouseOver<T>::mousePressed()
{
//By default, a press will not lock the button
bool locked = false;
//This will be false if no element is mouseOvered and we will return the locked ==false
if (mvpCurrentMouseOver)
{
//If we have added lock relationships
if(mvpCurrentMouseOver->lockRelationships != NULL)
{
lockElements(mvpCurrentMouseOver);
locked = true;
}
//If we have added unlock relationships
if(mvpCurrentMouseOver->unlockRelationships != NULL)
{
unlockElements(mvpCurrentMouseOver);
}
//Fire the function has been linked with the MOE.
void (T::*onStatePressFunction)() = mvpCurrentMouseOver->onStatePressFunction;
(mvpClass->*onStatePressFunction)();
}
//If locked == true, then we have to manually reset the mvpCurrentMouseOver in the AppState
//This is needed since we might quit the whole application as a T::function, and then mvpCurrentMouseOver won't exist.
return locked;
}
/*---------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
/* PRIVATE */
/*---------------------------------------------------------------------------------*/
template <class T> bool GuiMouseOver<T>::isMouseOver(mouseOverElement &mOE,const int x, const int y)
{
//If the cursor in inside the MOE border, return true
if (x > mOE.left && x < mOE.right && y > mOE.top && y < mOE.bottom)
{
return true;
}
return false;
}
/*---------------------------------------------------------------------------------*/
template <class T> void GuiMouseOver<T>::lockElements(mouseOverElement* mOE)
{
//Lock the elements that is binded with the current MOE
for(unsigned int i = 0; i < mOE->lockRelationships->size(); i++)
{
mvMouseOverElements[mOE->lockRelationships->at(i)].locked = true;
mvMouseOverElements[mOE->lockRelationships->at(i)].overlay->hide();
mvMouseOverElements[mOE->lockRelationships->at(i)].overlayMOE->hide();
mvMouseOverElements[mOE->lockRelationships->at(i)].overlayLocked->show();
}
}
/*---------------------------------------------------------------------------------*/
template <class T> void GuiMouseOver<T>::showMouseOver(mouseOverElement* mOE, bool showMouseOver)
{
//Default - showMouseOver == true
if (showMouseOver)
{
mOE->overlay->hide();
mOE->overlayMOE->show();
}
else
{
mOE->overlay->show();
mOE->overlayMOE->hide();
}
}
/*---------------------------------------------------------------------------------*/
template <class T> void GuiMouseOver<T>::unlockElements(mouseOverElement* mOE)
{
//Unlock the elements that is binded with the current MOE
for(unsigned int i = 0; i < mOE->unlockRelationships->size(); i++)
{
mvMouseOverElements[mOE->unlockRelationships->at(i)].locked = false;
mvMouseOverElements[mOE->unlockRelationships->at(i)].overlay->show();
mvMouseOverElements[mOE->unlockRelationships->at(i)].overlayMOE->hide();
mvMouseOverElements[mOE->unlockRelationships->at(i)].overlayLocked->hide();
}
} | [
"perkarlsson89@0a7da93c-2c89-6d21-fed9-0a9a637d9411"
]
| [
[
[
1,
315
]
]
]
|
848b7131714681fdfe761db7de657984dbcf851a | 2dbbca065b62a24f47aeb7ec5cd7a4fd82083dd4 | /OUAN/OUAN/Src/Loader/XMLParser.h | 600faee0e7781ecc71e5bffda0b922f5dac7f897 | []
| no_license | juanjmostazo/once-upon-a-night | 9651dc4dcebef80f0475e2e61865193ad61edaaa | f8d5d3a62952c45093a94c8b073cbb70f8146a53 | refs/heads/master | 2020-05-28T05:45:17.386664 | 2010-10-06T12:49:50 | 2010-10-06T12:49:50 | 38,101,059 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,867 | h | #ifndef XMLParserH_H
#define XMLParserH_H
#include "../OUAN.h"
namespace OUAN
{
class XMLParser
{
protected:
TiXmlDocument *XMLDoc;
TiXmlElement *XMLRootNode;
void parseLevelRoot(TiXmlElement *XMLNode);
void parseElements(TiXmlElement *XMLNode);
void parseElement(TiXmlElement *XMLNode);
void addXMLGameObjectNode(const std::string& worldName,const std::string& gameObjectType,TiXmlElement *XMLNode);
void addXMLNodeCustomProperties();
void setNames();
//Trajectory Parsing
void parseTrajectory(TiXmlElement *XMLTrajectoryStartNode);
TiXmlElement * findNode(const std::string& nodeName);
//WalkabilityMapParsing
void parseWalkabilityMap(TiXmlElement *XMLWalkabilityMap);
//Game Object names processors
bool isDreams(const std::string& worldName,const std::string& gameObjectType);
bool isNightmares(const std::string& worldName,const std::string& gameObjectType);
std::string getBaseName(const std::string& worldName,const std::string& gameObjectType);
std::string getNightmaresName(const std::string& baseName,const std::string& gameObjectType);
std::string getDreamsName(const std::string& baseName,const std::string& gameObjectType);
//Vector containing all GameObject types
std::vector<std::string> gameObjectTypes;
//Map containing all the GameObject custom properties documents
std::map<std::string,TiXmlDocument *> XMLCustomProperties;
//Parse all GameObject's types and its custom properties file .ctp
void parseGameObjectTypes();
//Parses custom properties file (.ctp) the specifies game object type and adds it to XMLCustomProperties map
void parseCustomProperties(const std::string& gameObjectType);
//Returns a node containing the custom properties for the specified game object type
TiXmlElement * getXMLCustomProperties(const std::string& gameObjectType);
//Attribute parser
OUAN::String getAttrib(TiXmlElement *XMLNode, const OUAN::String ¶meter, const OUAN::String &defaultValue = "");
//Property string parser
OUAN::String getPropertyString(TiXmlElement *XMLNode, const OUAN::String &attrib_name, bool logErrors=true);
public:
XMLParser();
virtual ~XMLParser();
void init();
void clearLevelInfo();
void parseLevel(const String& SceneName);
//Map containing all the parsed game objects
XMLGameObjectContainer mXMLGameObjectContainer;
//Map containing all the parsed trajectories
XMLTrajectoryContainer mXMLTrajectoryContainer;
std::vector<std::string> mCameraTrajectoryNames;
//Map containing all the parsed walkability maps
XMLWalkabilityMapContainer mXMLWalkabilityMapContainer;
//Map containing all the parsed scene nodes
XMLSceneNodeContainer mXMLSceneNodeContainer;
};
}
#endif
| [
"wyern1@1610d384-d83c-11de-a027-019ae363d039",
"ithiliel@1610d384-d83c-11de-a027-019ae363d039"
]
| [
[
[
1,
15
],
[
17,
21
],
[
23,
28
],
[
34,
43
],
[
45,
46
],
[
48,
61
],
[
63,
79
]
],
[
[
16,
16
],
[
22,
22
],
[
29,
33
],
[
44,
44
],
[
47,
47
],
[
62,
62
]
]
]
|
9dc9214247983f1b014a22acf151a8bc551c8f3c | 9ad9345e116ead00be7b3bd147a0f43144a2e402 | /Integration_WAH_&_Extraction/SMDataExtraction/SEEDMinerGUIApplication/SeedMinerGui.h | 2de1df85d2c25f675dfe3d8e2ad0a3adcea46501 | []
| no_license | asankaf/scalable-data-mining-framework | e46999670a2317ee8d7814a4bd21f62d8f9f5c8f | 811fddd97f52a203fdacd14c5753c3923d3a6498 | refs/heads/master | 2020-04-02T08:14:39.589079 | 2010-07-18T16:44:56 | 2010-07-18T16:44:56 | 33,870,353 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,445 | h | // IntelliCheckersUI.h : main header file for the IntelliCheckersUI application
//
#if !defined(AFX_IntelliCheckersUI_H__47F8577B_C6E8_484F_88BC_BA4252C3B545__INCLUDED_)
#define AFX_IntelliCheckersUI_H__47F8577B_C6E8_484F_88BC_BA4252C3B545__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
/////////////////////////////////////////////////////////////////////////////
// CIntelliCheckersUIApp:
// See IntelliCheckersUI.cpp for the implementation of this class
//
class CIntelliCheckersUIApp : public CWinApp
{
public:
CIntelliCheckersUIApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CIntelliCheckersUIApp)
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CIntelliCheckersUIApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_IntelliCheckersUI_H__47F8577B_C6E8_484F_88BC_BA4252C3B545__INCLUDED_)
| [
"jaadds@c7f6ba40-6498-11de-987a-95e5a5a5d5f1"
]
| [
[
[
1,
49
]
]
]
|
79754ab7def946a01acce771a25a3bdaed787796 | e3f578e81aa4402c2fa4bc3434be80c2e203dbf9 | /libs/gpm/crypto/blowfish.hpp | a48c2e16d19dbab08c0f5a8c0d87aae090da3424 | []
| no_license | bytemaster/GeneralPublicMarket | b4d53a651bfe3cacb7c363517dc24224ae51e9d9 | 70f73235f33be1feac6f209b719d2bb79d6da0b3 | refs/heads/master | 2016-09-10T18:58:42.152557 | 2011-05-23T04:08:52 | 2011-05-23T04:08:52 | 1,485,893 | 5 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 8,229 | hpp | ////////////////////////////////////////////////////////////////////////////
///
// Blowfish.h Header File
//
// BLOWFISH ENCRYPTION ALGORITHM
//
// encryption and decryption of Byte Strings using the Blowfish encryption Algorithm.
// Blowfish is a block cipher that encrypts data in 8-byte blocks. The algorithm consists
// of two parts: a key-expansion part and a data-ancryption part. Key expansion converts a
// variable key of at least 1 and at most 56 bytes into several subkey arrays totaling
// 4168 bytes. Blowfish has 16 rounds. Each round consists of a key-dependent permutation,
// and a key and data-dependent substitution. All operations are XORs and additions on 32-bit words.
// The only additional operations are four indexed array data lookups per round.
// Blowfish uses a large number of subkeys. These keys must be precomputed before any data
// encryption or decryption. The P-array consists of 18 32-bit subkeys: P0, P1,...,P17.
// There are also four 32-bit S-boxes with 256 entries each: S0,0, S0,1,...,S0,255;
// S1,0, S1,1,...,S1,255; S2,0, S2,1,...,S2,255; S3,0, S3,1,...,S3,255;
//
// The Electronic Code Book (ECB), Cipher Block Chaining (CBC) and Cipher Feedback modes
// are used:
//
// In ECB mode if the same block is encrypted twice with the same key, the resulting
// ciphertext blocks are the same.
//
// In CBC Mode a ciphertext block is obtained by first xoring the
// plaintext block with the previous ciphertext block, and encrypting the resulting value.
//
// In CFB mode a ciphertext block is obtained by encrypting the previous ciphertext block
// and xoring the resulting value with the plaintext
//
// The previous ciphertext block is usually stored in an Initialization Vector (IV).
// An Initialization Vector of zero is commonly used for the first block, though other
// arrangements are also in use.
/*
http://www.counterpane.com/vectors.txt
Test vectors by Eric Young. These tests all assume Blowfish with 16
rounds.
All data is shown as a hex string with 012345 loading as
data[0]=0x01;
data[1]=0x23;
data[2]=0x45;
ecb test data (taken from the DES validation tests)
key bytes clear bytes cipher bytes
0000000000000000 0000000000000000 4EF997456198DD78
FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF 51866FD5B85ECB8A
3000000000000000 1000000000000001 7D856F9A613063F2 ???
1111111111111111 1111111111111111 2466DD878B963C9D
0123456789ABCDEF 1111111111111111 61F9C3802281B096
1111111111111111 0123456789ABCDEF 7D0CC630AFDA1EC7
0000000000000000 0000000000000000 4EF997456198DD78
FEDCBA9876543210 0123456789ABCDEF 0ACEAB0FC6A0A28D
7CA110454A1A6E57 01A1D6D039776742 59C68245EB05282B
0131D9619DC1376E 5CD54CA83DEF57DA B1B8CC0B250F09A0
07A1133E4A0B2686 0248D43806F67172 1730E5778BEA1DA4
3849674C2602319E 51454B582DDF440A A25E7856CF2651EB
04B915BA43FEB5B6 42FD443059577FA2 353882B109CE8F1A
0113B970FD34F2CE 059B5E0851CF143A 48F4D0884C379918
0170F175468FB5E6 0756D8E0774761D2 432193B78951FC98
43297FAD38E373FE 762514B829BF486A 13F04154D69D1AE5
07A7137045DA2A16 3BDD119049372802 2EEDDA93FFD39C79
04689104C2FD3B2F 26955F6835AF609A D887E0393C2DA6E3
37D06BB516CB7546 164D5E404F275232 5F99D04F5B163969
1F08260D1AC2465E 6B056E18759F5CCA 4A057A3B24D3977B
584023641ABA6176 004BD6EF09176062 452031C1E4FADA8E
025816164629B007 480D39006EE762F2 7555AE39F59B87BD
49793EBC79B3258F 437540C8698F3CFA 53C55F9CB49FC019
4FB05E1515AB73A7 072D43A077075292 7A8E7BFA937E89A3
49E95D6D4CA229BF 02FE55778117F12A CF9C5D7A4986ADB5
018310DC409B26D6 1D9D5C5018F728C2 D1ABB290658BC778
1C587F1C13924FEF 305532286D6F295A 55CB3774D13EF201
0101010101010101 0123456789ABCDEF FA34EC4847B268B2
1F1F1F1F0E0E0E0E 0123456789ABCDEF A790795108EA3CAE
E0FEE0FEF1FEF1FE 0123456789ABCDEF C39E072D9FAC631D
0000000000000000 FFFFFFFFFFFFFFFF 014933E0CDAFF6E4
FFFFFFFFFFFFFFFF 0000000000000000 F21E9A77B71C49BC
0123456789ABCDEF 0000000000000000 245946885754369A
FEDCBA9876543210 FFFFFFFFFFFFFFFF 6B5C5A9C5D9E0A5A
set_key test data
data[8]= FEDCBA9876543210
c=F9AD597C49DB005E k[ 1]=F0
c=E91D21C1D961A6D6 k[ 2]=F0E1
c=E9C2B70A1BC65CF3 k[ 3]=F0E1D2
c=BE1E639408640F05 k[ 4]=F0E1D2C3
c=B39E44481BDB1E6E k[ 5]=F0E1D2C3B4
c=9457AA83B1928C0D k[ 6]=F0E1D2C3B4A5
c=8BB77032F960629D k[ 7]=F0E1D2C3B4A596
c=E87A244E2CC85E82 k[ 8]=F0E1D2C3B4A59687
c=15750E7A4F4EC577 k[ 9]=F0E1D2C3B4A5968778
c=122BA70B3AB64AE0 k[10]=F0E1D2C3B4A596877869
c=3A833C9AFFC537F6 k[11]=F0E1D2C3B4A5968778695A
c=9409DA87A90F6BF2 k[12]=F0E1D2C3B4A5968778695A4B
c=884F80625060B8B4 k[13]=F0E1D2C3B4A5968778695A4B3C
c=1F85031C19E11968 k[14]=F0E1D2C3B4A5968778695A4B3C2D
c=79D9373A714CA34F k[15]=F0E1D2C3B4A5968778695A4B3C2D1E ???
c=93142887EE3BE15C k[16]=F0E1D2C3B4A5968778695A4B3C2D1E0F
c=03429E838CE2D14B k[17]=F0E1D2C3B4A5968778695A4B3C2D1E0F00
c=A4299E27469FF67B k[18]=F0E1D2C3B4A5968778695A4B3C2D1E0F0011
c=AFD5AED1C1BC96A8 k[19]=F0E1D2C3B4A5968778695A4B3C2D1E0F001122
c=10851C0E3858DA9F k[20]=F0E1D2C3B4A5968778695A4B3C2D1E0F00112233
c=E6F51ED79B9DB21F k[21]=F0E1D2C3B4A5968778695A4B3C2D1E0F0011223344
c=64A6E14AFD36B46F k[22]=F0E1D2C3B4A5968778695A4B3C2D1E0F001122334455
c=80C7D7D45A5479AD k[23]=F0E1D2C3B4A5968778695A4B3C2D1E0F00112233445566
c=05044B62FA52D080 k[24]=F0E1D2C3B4A5968778695A4B3C2D1E0F0011223344556677
chaining mode test data
key[16] = 0123456789ABCDEFF0E1D2C3B4A59687
iv[8] = FEDCBA9876543210
data[29] = "7654321 Now is the time for " (includes trailing '\0')
data[29] = 37363534333231204E6F77206973207468652074696D6520666F722000
cbc cipher text
cipher[32]= 6B77B4D63006DEE605B156E27403979358DEB9E7154616D959F1652BD5FF92CC
cfb64 cipher text cipher[29]=
E73214A2822139CAF26ECF6D2EB9E76E3DA3DE04D1517200519D57A6C3
ofb64 cipher text cipher[29]=
E73214A2822139CA62B343CC5B65587310DD908D0C241B2263C2CF80DA
*/
#ifndef __DLSL_BLOWFISH_H__
#define __DLSL_BLOWFISH_H__
namespace gpm {
//Block Structure
struct sblock
{
//Constructors
sblock(unsigned int l=0, unsigned int r=0) : m_uil(l), m_uir(r) {}
//Copy Constructor
sblock(const sblock& roBlock) : m_uil(roBlock.m_uil), m_uir(roBlock.m_uir) {}
sblock& operator^=(sblock& b) { m_uil ^= b.m_uil; m_uir ^= b.m_uir; return *this; }
unsigned int m_uil, m_uir;
};
class blowfish
{
public:
enum { ECB=0, CBC=1, CFB=2 };
//Constructor - Initialize the P and S boxes for a given Key
blowfish();
void start(unsigned char* ucKey, size_t n, const sblock& roChain = sblock(0UL,0UL));
//Resetting the chaining block
void reset_chain() { m_oChain = m_oChain0; }
// encrypt/decrypt Buffer in Place
void encrypt(unsigned char* buf, size_t n, int iMode=ECB);
void decrypt(unsigned char* buf, size_t n, int iMode=ECB);
// encrypt/decrypt from Input Buffer to Output Buffer
void encrypt(const unsigned char* in, unsigned char* out, size_t n, int iMode=ECB);
void decrypt(const unsigned char* in, unsigned char* out, size_t n, int iMode=ECB);
//Private Functions
private:
unsigned int F(unsigned int ui);
void encrypt(sblock&);
void decrypt(sblock&);
private:
//The Initialization Vector, by default {0, 0}
sblock m_oChain0;
sblock m_oChain;
unsigned int m_auiP[18];
unsigned int m_auiS[4][256];
static const unsigned int scm_auiInitP[18];
static const unsigned int scm_auiInitS[4][256];
};
//Extract low order byte
inline unsigned char Byte(unsigned int ui)
{
return (unsigned char)(ui & 0xff);
}
//Function F
inline unsigned int blowfish::F(unsigned int ui)
{
return ((m_auiS[0][Byte(ui>>24)] + m_auiS[1][Byte(ui>>16)]) ^ m_auiS[2][Byte(ui>>8)]) + m_auiS[3][Byte(ui)];
}
} // namespace gpm
#endif // __BLOWFISH_H__
| [
"[email protected]"
]
| [
[
[
1,
190
]
]
]
|
7b05cd7c6de700a2eb6469878d2001c2bcd1855e | 9ad9345e116ead00be7b3bd147a0f43144a2e402 | /Integration_WAH_&_Extraction/SMDataExtraction/SMDataExtraction/ConfigurationReader.h | f017d8566a686f70c2129033287dd319c01eb5a8 | []
| no_license | asankaf/scalable-data-mining-framework | e46999670a2317ee8d7814a4bd21f62d8f9f5c8f | 811fddd97f52a203fdacd14c5753c3923d3a6498 | refs/heads/master | 2020-04-02T08:14:39.589079 | 2010-07-18T16:44:56 | 2010-07-18T16:44:56 | 33,870,353 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,173 | h | #pragma once
#include <hash_map>
#include <iostream>
//#include <string>
using namespace std;
using namespace stdext;
/************************************************************************/
/* Class :ConfigurationReader.h
/* Started:11.03.2010 13:51:02
/* Updated:28.05.2010 21:18:51
/* Author :SEEDMiner
/* Subj :Common utility class to read configuration values
/* Version:
/************************************************************************/
class ConfigurationReader
{
public:
/** enum to hold the available configuration keys available*/
static enum configutation{ COMPRESSION,
METAFILE_NAME,
DATAFILE_NAME,
FILE_NAME ,
FOLDER_NAME ,
LOAD_TYPE ,
LOAD_TYPE_MULTI,
LOAD_TYPE_SINGLE,
LOAD_TYPE_CSV,
SAVE_DATA_FOLDER,
DOUBLE_PRECISION,
CSV_NULL };
#pragma region Constructors & Destructor
_declspec(dllexport) ConfigurationReader(void);
_declspec(dllexport) ConfigurationReader(string & _path);
_declspec(dllexport) ~ConfigurationReader(void);
#pragma endregion Constructors & Destructor
/** Gives the Configuration indicated by _property*/
_declspec(dllexport)static string ReadConfiguration(string & _property);
/** Gives the Configuration indicated by _property*/
_declspec(dllexport)static string ReadConfiguration(const string & _property);
/** Gives the Configuration indicated by _property*/
_declspec(dllexport)static string ReadConfiguration(configutation _property);
/** Creating the Exception file, given by the location _path*/
_declspec(dllexport) static void BuildFile(string & _path);
private :
static hash_map<string,string> m_map;
static string getMapping(configutation & _configuration);
static string COMPRESSION_VAL;
static string METAFILE_NAME_VAL;
static string DATAFILE_NAME_VAL;
static string FILE_NAME_VAL;
static string FOLDER_NAME_VAL ;
static string LOAD_TYPE_VAL ;
static string LOAD_TYPE_MULTI_VAL;
static string LOAD_TYPE_SINGLE_VAL;
static string LOAD_TYPE_CSV_VAL;
static string SAVE_XML_FILE_FOLDER;
static string DOUBLE_PRECISION_VAL;
static string CSV_NULL_VAL;
};
| [
"jaadds@c7f6ba40-6498-11de-987a-95e5a5a5d5f1",
"samfernandopulle@c7f6ba40-6498-11de-987a-95e5a5a5d5f1"
]
| [
[
[
1,
7
],
[
18,
20
],
[
23,
30
],
[
37,
43
],
[
46,
69
],
[
73,
73
]
],
[
[
8,
17
],
[
21,
22
],
[
31,
36
],
[
44,
45
],
[
70,
72
]
]
]
|
96799873e72401b3c00e194ef1f3914603b35b84 | 279b68f31b11224c18bfe7a0c8b8086f84c6afba | /playground/barfan/0.0.1-DEV-02/connection.hpp | ad0f36cacfb1e65d513d57df7ac8bae9ae9c6991 | []
| no_license | bogus/findik | 83b7b44b36b42db68c2b536361541ee6175bb791 | 2258b3b3cc58711375fe05221588d5a068da5ea8 | refs/heads/master | 2020-12-24T13:36:19.550337 | 2009-08-16T21:46:57 | 2009-08-16T21:46:57 | 32,120,100 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,035 | hpp | #ifndef FINDIK_IO_CONNECTION_HPP
#define FINDIK_IO_CONNECTION_HPP
#include <boost/asio.hpp>
#include <boost/array.hpp>
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include "findik_config.hpp"
#include "reply.hpp"
#include "request.hpp"
#include "response.hpp"
#include "request_parser.hpp"
#include "response_parser.hpp"
#include "request_filter.hpp"
#include "response_filter.hpp"
namespace findik {
namespace io {
/// Represents a single connection from a client.
class connection
: public boost::enable_shared_from_this<connection>,
private boost::noncopyable
{
public:
/// Construct a connection with the given io_service.
explicit connection(boost::asio::io_service& io_service,
findik::persistency::dbmanager::pointer & manager);
/// Get the socket associated with the local connection.
boost::asio::ip::tcp::socket& l_socket();
/// Get the socket associated with the remote connection.
boost::asio::ip::tcp::socket& r_socket();
/// Start the first asynchronous operation for the connection.
void start();
private:
/// Handle completion of a read operation.
void handle_read_request(const boost::system::error_code& e,
std::size_t bytes_transferred);
/// Handle completion of a write operation.
void handle_write_response(const boost::system::error_code& e);
void handle_resolve_remote(const boost::system::error_code& err,
boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
void handle_connect_remote(const boost::system::error_code& err,
boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
void handle_write_request(const boost::system::error_code& err);
void handle_read_response(const boost::system::error_code& e,
std::size_t bytes_transferred);
/// Strand to ensure the connection's handlers are not called concurrently.
boost::asio::io_service::strand strand_;
boost::asio::ip::tcp::resolver resolver_;
/// Socket for the local connection.
boost::asio::ip::tcp::socket l_socket_;
/// Socket for the remote connection.
boost::asio::ip::tcp::socket r_socket_;
/// Buffer for incoming data.
boost::array<char, __FC_SOCKET_BUFFER_SIZE> buffer_;
/// The incoming request.
request request_;
boost::asio::streambuf request_sbuf_;
/// The incoming response.
response response_;
boost::asio::streambuf response_sbuf_;
/// The parser for the incoming request.
request_parser request_parser_;
/// The parser for the incoming response.
response_parser response_parser_;
/// The reply to be sent back to the client.
reply reply_;
/// Database manager object
findik::persistency::dbmanager::pointer & manager_;
/// Debug logger
static log4cxx::LoggerPtr debug_logger;
};
typedef boost::shared_ptr<connection> connection_ptr;
} // namespace server3
} // namespace http
#endif // FINDIK_IO_CONNECTION_HPP
| [
"barfan@d40773b4-ada0-11de-b0a2-13e92fe56a31"
]
| [
[
[
1,
107
]
]
]
|
f947fc395e9dbd061c5a206d7b7aa0c18ca85c62 | 3761dcce2ce81abcbe6d421d8729af568d158209 | /include/cybergarage/xml/NodeData.h | e4eabb18a87214b4fbd66bb16bb6ade554f2c0c6 | [
"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 | 740 | h | /******************************************************************
*
* CyberXML for C++
*
* Copyright (C) Satoshi Konno 2002-2003
*
* File: Data.h
*
* Revision;
*
* 07/22/03
* - first revision
*
******************************************************************/
#ifndef _CXML_XMLNODEDATA_H_
#define _CXML_XMLNODEDATA_H_
namespace CyberXML {
class Node;
class NodeData
{
Node *node;
public:
NodeData()
{
}
virtual ~NodeData()
{
}
////////////////////////////////////////////////
// node
////////////////////////////////////////////////
void setNode(CyberXML::Node *node)
{
this->node = node;
}
CyberXML::Node *getNode()
{
return node;
}
};
}
#endif
| [
"skonno@b944b01c-6696-4570-ab44-a0e08c11cb0e"
]
| [
[
[
1,
55
]
]
]
|
07343a71c1404e6be0308553556bf177711eec79 | 01fa2d8a6dead72c3f05e22b9e63942b4422214f | /src/test/pull.cpp | 4886cb888a3ae7418916b2d68e668266cc24dcbc | []
| no_license | AlekseiCherkes/ttscpp | 693f7aac56ae59cf2555b0852eb26a6f96a4dbe3 | e3976e6f5e4f5a7923effa95b25c8ba2031ae9f1 | refs/heads/master | 2021-01-10T20:36:58.267873 | 2011-12-17T10:00:24 | 2011-12-17T10:00:24 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,344 | cpp | // Important note for Visual C++ users
// If you put your tests into a library and your main() function is in a different library or in
// your .exe file, those tests will not run. The reason is a bug in Visual C++. When you define your
// tests, Google Test creates certain static objects to register them. These objects are not
// referenced from elsewhere but their constructors are still supposed to run. When Visual C++
// linker sees that nothing in the library is referenced from other places it throws the
// library out. You have to reference your library with tests from your main program to keep
// the linker from discarding it. Here is how to do it. Somewhere in your library code
// declare a function:
//
// __declspec(dllexport) int PullInMyLibrary() { return 0; }
//
// If you put your tests in a static library (not DLL) then __declspec(dllexport) is not
// required. Now, in your main program, write a code that invokes that function:
//
// int PullInMyLibrary();
// static int dummy = PullInMyLibrary();
//
// This will keep your tests referenced and will make them register themselves at startup.
//
// In addition, if you define your tests in a static library, add /OPT:NOREF to your
// main program linker options. If you use MSVC++ IDE, go to your .exe project
// properties/Configuration Properties/Linker/Optimization and set References
// setting to Keep Unreferenced Data (/OPT:NOREF). This will keep
// Visual C++ linker from discarding individual symbols generated by your
// tests from the final executable.
//
// There is one more pitfall, though. If you use Google Test as a static library
// (that's how it is defined in gtest.vcproj) your tests must also reside in a
// static library. If you have to have them in a DLL, you must change Google Test
// to build into a DLL as well. Otherwise your tests will not run correctly or will
// not run at all. The general conclusion here is: make your life easier - do not
// write your tests in libraries!
//--------------------------------------------------------------------------------------------------
#ifdef _MSC_VER
__declspec(dllexport) int PullInMyLibrary()
{
return 0;
}
#endif
//--------------------------------------------------------------------------------------------------
| [
"[email protected]"
]
| [
[
[
1,
45
]
]
]
|
46998dbe34a88cc6564fe1d4eafd34eba125ce66 | 602ebbd79009761dddc04cebb737f09bbe9bf16f | /Geometry/Point.cpp | 06b86fa10007de1c6bbed82443fde366c45f3282 | []
| no_license | RafaelMarinheiro/Objective-ART | f62d8ba8e0fc58fcf4291c8aed5288f2e01bc936 | 3a131981513360802398d0898772170b45d0d59f | refs/heads/master | 2021-01-19T09:44:21.829879 | 2011-10-21T19:58:25 | 2011-10-21T19:58:25 | 2,608,881 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,475 | cpp | #include "GeometryAFX.h"
#include "Point.h"
#include <math.h>
using namespace oart;
Point::Point()
{
this->x = 0.0;
this->y = 0.0;
}
Point::Point(double x, double y)
{
this->x = x;
this->y = y;
}
Point::Point(const Point & v)
{
this->x = v.x;
this->y = v.y;
}
Point & Point::operator=(const Point & v)
{
if(this == &v){
return (*this);
} else{
this->x = v.x;
this->y = v.y;
return (*this);
}
}
Point::~Point()
{
//Using default destructor
}
Point & Point::operator+(const Point & v) const
{
Point * p = new Point();
p->x = this->x + v.x;
p->y = this->y + v.y;
return (*p);
}
Point & Point::operator+=(const Point & v)
{
this->x += v.x;
this->y += v.y;
return (*this);
}
Point & Point::operator-(const Point & v) const
{
Point * p = new Point();
p->x = this->x - v.x;
p->y = this->y - v.y;
return (*p);
}
Point & Point::operator-=(const Point & v)
{
this->x -= v.x;
this->y -= v.y;
return (*this);
}
const double Point::operator*(const Point & v) const
{
const double ret = this->x * v.x + this->y * v.y;
return ret;
}
const bool Point::operator==(const Point & v) const
{
if(this->x == v.x && this->y == v.y){
return true;
} else{
return false;
}
}
const bool Point::operator!=(const Point & v) const
{
return !((*this) == v);
}
const double Point::norm() const
{
return (sqrt((this->x)*(this->x) + (this->y)*(this->y)));
} | [
"[email protected]"
]
| [
[
[
1,
95
]
]
]
|
d9bda09677e6286fc40a924dcec6fc8aa10c5d07 | ee065463a247fda9a1927e978143186204fefa23 | /Src/Depends/Entity/precomp.h | a6cc690de9ed65195e12d5d4bdffe9e74a2edc54 | [
"Zlib"
]
| permissive | ptrefall/hinsimviz | 32e9a679170eda9e552d69db6578369a3065f863 | 9caaacd39bf04bbe13ee1288d8578ece7949518f | refs/heads/master | 2021-01-22T09:03:52.503587 | 2010-09-26T17:29:20 | 2010-09-26T17:29:20 | 32,448,374 | 1 | 0 | null | null | null | null | ISO-8859-15 | C++ | false | false | 1,275 | h | /*Component-based Entity Engine
Copyright (c) 2009 Pål Trefall and Kenneth Gangstø
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.
Note: Some of the libraries Component-based Entity Engine may link to may have additional
requirements or restrictions.
*/
#pragma once
#include <vector>
#include <map>
#include <ClanLib/core.h>
typedef CL_String T_String;
typedef CL_StringHelp T_StringHelp;
//typedef CL_TempString T_TempString;
typedef CL_Exception T_Exception;
| [
"[email protected]@28a56cb3-1e7c-bc60-7718-65c159e1d2df"
]
| [
[
[
1,
34
]
]
]
|
1cf100d0b0d2381984c811ea0e4fda9df93f93d4 | 4d838ba98a21fc4593652e66eb7df0fac6282ef6 | /CaveProj/Editor.cpp | a61ee9f8447f7dec55f8a8f9995c5482a9e41814 | []
| no_license | davidhart/ProceduralCaveEditor | 39ed0cf4ab4acb420fa2ad4af10f9546c138a83a | 31264591f2dcd250299049c826aeca18fc52880e | refs/heads/master | 2021-01-17T15:10:09.100572 | 2011-05-03T19:24:06 | 2011-05-03T19:24:06 | 69,302,913 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,334 | cpp | #include "Editor.h"
#include "RenderWindow.h"
#include "Util.h"
#include <iostream>
Editor::Editor(RenderWindow& renderWindow) :
_lightIcon(NULL),
_selectedLight(-1),
_selectedShape(-1),
_selectedObject(-1),
_positionWidget(Vector3f(0, 0, 0)),
_editorUI(renderWindow),
_preview(false),
_ball(_environment),
_player(_environment),
_particleSystem(5000, _environment)
{
_editorUI.SetEnvironment(&_environment);
_editorUI.SetEditor(this);
}
void Editor::Load(RenderWindow& renderWindow)
{
_player.Load(renderWindow);
_environment.Load(renderWindow.GetDevice(), _player.GetCamera());
_billboardDrawer.Load(renderWindow);
D3DX10_IMAGE_LOAD_INFO loadInfo;
ZeroMemory( &loadInfo, sizeof(D3DX10_IMAGE_LOAD_INFO) );
loadInfo.BindFlags = D3D10_BIND_SHADER_RESOURCE;
loadInfo.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
HRESULT hr;
if (FAILED(D3DX10CreateShaderResourceViewFromFile(renderWindow.GetDevice(), "Assets/lightIcon.png", &loadInfo, NULL, &_lightIcon, &hr)))
{
// TODO: log error
}
_positionWidget.Load(renderWindow);
_editorUI.Load(renderWindow);
_ball.Load(renderWindow);
_particleSystem.Load(renderWindow);
}
void Editor::Unload()
{
_environment.Unload();
_billboardDrawer.Unload();
_positionWidget.Unload();
_lightIcon->Release();
_lightIcon = NULL;
_editorUI.Unload();
_ball.Unload();
_particleSystem.Unload();
}
void Editor::Draw(RenderWindow& renderWindow)
{
_environment.Draw(renderWindow.GetDevice(), _player.GetCamera());
// in preview mode draw the ball, in editor mode draw light billboard sprites and selection widgets
if (_preview)
{
_ball.Draw(renderWindow, _player.GetCamera());
//_particleSystem.Draw(renderWindow, _player.GetCamera());
}
else
{
if (_environment.NumLights() > 0)
{
_billboardDrawer.Begin(_player.GetCamera());
for (int i = 0; i < _environment.NumLights(); ++i)
{
_billboardDrawer.Draw(_environment.GetLightPosition(i),
0.05f,
_environment.GetLightColor(i),
_lightIcon);
}
_billboardDrawer.End();
if (_selectedLight >= 0)
{
_positionWidget.SetPosition(_environment.GetLightPosition(_selectedLight));
_positionWidget.Draw(_player.GetCamera(), renderWindow);
}
}
if (_selectedObject >= 0)
{
_positionWidget.SetPosition(_environment.GetChestPosition(_selectedObject));
_positionWidget.Draw(_player.GetCamera(), renderWindow);
}
_editorUI.Draw();
}
}
void Editor::Update(float dt, const Input& input)
{
if (_preview)
{
_environment.Update(dt);
}
Vector2f movement(0, 0);
if (input.IsKeyDown(Input::KEY_W)) movement.y = 1;
if (input.IsKeyDown(Input::KEY_S)) movement.y = -1;
if (input.IsKeyDown(Input::KEY_A)) movement.x = -1;
if (input.IsKeyDown(Input::KEY_D)) movement.x = 1;
if (movement.Length() != 0)
{
movement.Normalise();
movement *= 0.3f;
}
Vector2f rotation;
if (input.IsButtonDown(Input::BUTTON_MID))
{
rotation.x = input.GetMouseDistance().y*0.006f;
rotation.y = input.GetMouseDistance().x*0.006f;
}
bool jump = input.IsButtonJustPressed(Input::BUTTON_RIGHT);
_player.Update(movement, rotation, dt, !_preview, jump);
if (_preview)
{
if (input.IsButtonJustPressed(Input::BUTTON_LEFT))
{
_ball.SetPosition(_player.Position());
_ball.SetVelocity(_player.GetCamera().UnprojectCoord(input.GetCursorPosition())._direction*3.0f);
}
_ball.Update(dt);
//_particleSystem.Update(dt);
if (input.IsKeyJustPressed(Input::KEY_ESC))
{
Preview(false);
}
}
else
{
// Update object to selection position in drag mode
if (_positionWidget.IsInDrag())
{
_positionWidget.HandleDrag(_player.GetCamera(), input.GetCursorPosition());
if (_selectedLight >= 0)
{
_environment.SetLightPosition(_selectedLight, _positionWidget.GetPosition());
_editorUI.UpdateLightProperties(_selectedLight);
}
if (_selectedObject >= 0)
{
_environment.SetChestPosition(_selectedObject, _positionWidget.GetPosition());
_editorUI.UpdateObjectProperties(_selectedObject);
}
}
_positionWidget.SetHover(PositionWidget::GRAB_NONE);
// Work out what is under the cursor
Ray r = _player.GetCamera().UnprojectCoord(input.GetCursorPosition());
float nearestPoint = -1;
int nearestLight = -1;
int nearestObject = -1;
for (int i = 0; i < _environment.NumLights(); ++i)
{
if (i == _selectedLight)
continue;
float t = r.Intersects(_environment.GetLightPosition(i), 0.03f);
if (t >= 0.0f)
{
if (nearestPoint < 0 || t < nearestPoint)
{
nearestPoint = t;
nearestLight = i;
}
}
}
for (int i = 0; i < _environment.NumChests(); ++i)
{
if (i == _selectedObject)
continue;
float t = r.Intersects(AABB(_environment.GetChestPosition(i) - Vector3f(0.03f, 0, 0.025f),
_environment.GetChestPosition(i) + Vector3f(0.03f, 0.06f, 0.025f)));
if (t >= 0.0f)
{
if (nearestPoint < 0 || t < nearestPoint)
{
nearestPoint = t;
nearestObject = i;
nearestLight = -1;
}
}
}
PositionWidget::eGrabState grab = PositionWidget::GRAB_NONE;
float positionintersect;
// If something is selected
if (_selectedLight >= 0 || _selectedObject >= 0)
{
grab = _positionWidget.TestIntersection(r, positionintersect);
}
// If dragger was clicked
if (grab != PositionWidget::GRAB_NONE)
{
_positionWidget.SetHover(grab);
if (input.IsButtonJustPressed(Input::BUTTON_LEFT))
{
_positionWidget.StartDrag(r, positionintersect, grab);
}
}
else
{
// If new object selected
if (input.IsButtonJustPressed(Input::BUTTON_LEFT))
{
if (nearestLight >= 0)
{
_editorUI.SelectLight(nearestLight);
}
if (nearestObject >= 0)
{
_editorUI.SelectObject(nearestObject);
}
}
}
if (input.IsButtonJustReleased(Input::BUTTON_LEFT) && _positionWidget.IsInDrag())
{
_positionWidget.EndDrag();
}
}
if (input.IsKeyJustPressed(Input::KEY_SPACE))
{
_environment.Rebuild();
}
}
void Editor::HandleMessage(MSG msg)
{
if (!_preview)
{
_editorUI.HandleMessage(msg);
}
}
void Editor::SelectObject(int object)
{
_selectedObject = object;
_selectedLight = -1;
_editorUI.SelectLight(-1);
_positionWidget.EndDrag();
_positionWidget.SetPosition(_environment.GetChestPosition(object));
}
void Editor::DeselectObject()
{
_positionWidget.EndDrag();
_selectedObject = -1;
}
void Editor::SelectLight(int light)
{
_selectedLight = light;
_selectedObject = -1;
_editorUI.SelectObject(-1);
_positionWidget.EndDrag();
_positionWidget.SetPosition(_environment.GetLightPosition(light));
}
void Editor::DeselectLight()
{
_positionWidget.EndDrag();
_selectedLight = -1;
}
void Editor::SelectShape(int shape)
{
_selectedShape = shape;
}
void Editor::DeselectShape()
{
_selectedShape = -1;
}
void Editor::ResetCamera()
{
_player.Reset();
}
void Editor::Preview(bool enable)
{
if (enable && !_preview)
{
_particleSystem.Reset();
_ball.Reset();
}
else if (!enable && _preview)
{
_environment.Reset();
}
_preview = enable;
} | [
"[email protected]"
]
| [
[
[
1,
319
]
]
]
|
4e02c65a6c19dc354316f6ef8f58aade6a284545 | b2601dbc552b4ffa9b439dc17e5f18bb75b09379 | /src/arm9/source/lg/rand.cpp | cb90206f5492416ab1e8458dbaaec9ac5afa9d42 | []
| no_license | sgraham/twinisles | 70e9989e47933c87aa66f43efdd9b03c2b4e9d64 | e0086154fcc4f3be130d4c88b9af3a0aab490715 | refs/heads/master | 2021-01-18T13:53:55.740730 | 2010-10-13T06:59:12 | 2010-10-13T06:59:12 | 34,834,093 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,787 | cpp | #include "lg/rand.h"
namespace luvafair
{
// this code is taken from the SGADE gameboy library, thanks to Jaap
unsigned int Rand::ReloadMersenneTwister()
{
// Variables;
register unsigned int *p0=mRandState, *p2=mRandState+2, *pM=mRandState+LG_RAND_PERIOD, s0, s1;
register int j;
// Code;
if( mRandLeft < -1 ) Seed( 4357U );
mRandLeft = LG_RAND_STATE_VECTOR_LENGTH - 1;
mRandNext = mRandState + 1;
for( s0 = mRandState[0], s1 = mRandState[1], j = LG_RAND_STATE_VECTOR_LENGTH - LG_RAND_PERIOD + 1; --j; s0 = s1, s1 = *p2++ )
{
*p0++ = *pM++ ^ (LG_RAND_MIX_BITS(s0, s1) >> 1) ^ (LG_RAND_LO_BIT(s1) ? LG_RAND_MAGIC : 0U);
}
for( pM = mRandState, j = LG_RAND_PERIOD; --j; s0 = s1, s1 = *p2++ )
{
*p0++ = *pM++ ^ (LG_RAND_MIX_BITS(s0, s1) >> 1) ^ (LG_RAND_LO_BIT(s1) ? LG_RAND_MAGIC : 0U);
}
s1=mRandState[0], *p0 = *pM ^ (LG_RAND_MIX_BITS(s0, s1) >> 1) ^ (LG_RAND_LO_BIT(s1) ? LG_RAND_MAGIC : 0U);
s1 ^= (s1 >> 11);
s1 ^= (s1 << 7) & 0x9D2C5680U;
s1 ^= (s1 << 15) & 0xEFC60000U;
return(s1 ^ (s1 >> 18));
}
unsigned int Rand::Get()
{
unsigned int y;
if( --mRandLeft < 0 ) return ReloadMersenneTwister();
y = *mRandNext++;
y ^= (y >> 11);
y ^= (y << 7) & 0x9D2C5680U;
y ^= (y << 15) & 0xEFC60000U;
return(y ^ (y >> 18));
}
luvafair::F32 Rand::Getf()
{
#define LG_MAX_RANDF 8192
F32 ret((int)(Get() % LG_MAX_RANDF));
ret /= LG_MAX_RANDF;
return ret;
}
void Rand::Seed(unsigned int a_Seed)
{
register unsigned int x = (a_Seed | 1U) & 0xFFFFFFFFU, *s = mRandState;
register int j;
for( mRandLeft = 0, *s++ = x, j = LG_RAND_STATE_VECTOR_LENGTH;
--j;
*s++ = (x*=69069U) & 0xFFFFFFFFU );
}
}
| [
"[email protected]"
]
| [
[
[
1,
71
]
]
]
|
ff494e7faebcc8ebc1d866ee2eb7f5f2ae80ceb2 | 1c9f99b2b2e3835038aba7ec0abc3a228e24a558 | /Projects/elastix/elastix_sources_v4/src/Common/ParameterFileParser/itkParameterFileParser.cxx | f1e61ffcc6b8da3db05a0c7a90034b0c89d5cd91 | []
| no_license | mijc/Diploma | 95fa1b04801ba9afb6493b24b53383d0fbd00b33 | bae131ed74f1b344b219c0ffe0fffcd90306aeb8 | refs/heads/master | 2021-01-18T13:57:42.223466 | 2011-02-15T14:19:49 | 2011-02-15T14:19:49 | 1,369,569 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,412 | cxx | /*======================================================================
This file is part of the elastix software.
Copyright (c) University Medical Center Utrecht. All rights reserved.
See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
======================================================================*/
#ifndef __itkParameterFileParser_cxx
#define __itkParameterFileParser_cxx
#include "itkParameterFileParser.h"
#include <itksys/SystemTools.hxx>
#include <itksys/RegularExpression.hxx>
namespace itk
{
/**
* **************** Constructor ***************
*/
ParameterFileParser
::ParameterFileParser()
{
this->m_ParameterFileName = "";
this->m_ParameterMap.clear();
} // end Constructor()
/**
* **************** Destructor ***************
*/
ParameterFileParser
::~ParameterFileParser()
{
if ( this->m_ParameterFile.is_open() )
{
this->m_ParameterFile.close();
}
} // end Destructor()
/**
* **************** GetParameterMap ***************
*/
const ParameterFileParser::ParameterMapType &
ParameterFileParser
::GetParameterMap( void ) const
{
return this->m_ParameterMap;
} // end GetParameterMap()
/**
* **************** ReadParameterFile ***************
*/
void
ParameterFileParser
::ReadParameterFile( void )
{
/** Perform some basic checks. */
this->BasicFileChecking();
/** Open the parameter file for reading. */
if ( this->m_ParameterFile.is_open() )
{
this->m_ParameterFile.clear();
this->m_ParameterFile.close();
}
this->m_ParameterFile.open( this->m_ParameterFileName.c_str(), std::fstream::in );
/** Check if it opened. */
if ( !this->m_ParameterFile.is_open() )
{
itkExceptionMacro( << "ERROR: could not open "
<< this->m_ParameterFileName
<< " for reading." );
}
/** Clear the map. */
this->m_ParameterMap.clear();
/** Loop over the parameter file, line by line. */
std::string lineIn = "";
std::string lineOut = "";
while ( this->m_ParameterFile.good() )
{
/** Extract a line. */
itksys::SystemTools::GetLineFromStream( this->m_ParameterFile, lineIn );
/** Check this line. */
bool validLine = this->CheckLine( lineIn, lineOut );
if ( validLine )
{
/** Get the parameter name from this line and store it. */
this->GetParameterFromLine( lineIn, lineOut );
}
// Otherwise, we simply ignore this line
}
/** Close the parameter file. */
this->m_ParameterFile.clear();
this->m_ParameterFile.close();
} // end ReadParameterFile()
/**
* **************** BasicFileChecking ***************
*/
void
ParameterFileParser
::BasicFileChecking( void ) const
{
/** Check if the file name is given. */
if ( this->m_ParameterFileName == "" )
{
itkExceptionMacro( << "ERROR: FileName has not been set." );
}
/** Basic error checking: existence. */
bool exists = itksys::SystemTools::FileExists(
this->m_ParameterFileName.c_str() );
if ( !exists )
{
itkExceptionMacro( << "ERROR: the file "
<< this->m_ParameterFileName
<< " does not exist." );
}
/** Basic error checking: file or directory. */
bool isDir = itksys::SystemTools::FileIsDirectory(
this->m_ParameterFileName.c_str() );
if ( isDir )
{
itkExceptionMacro( << "ERROR: the file "
<< this->m_ParameterFileName
<< " is a directory." );
}
/** Check the extension. */
std::string ext = itksys::SystemTools::GetFilenameLastExtension(
this->m_ParameterFileName );
if ( ext != ".txt" )
{
itkExceptionMacro( << "ERROR: the file "
<< this->m_ParameterFileName
<< " should be a text file (*.txt)." );
}
} // end BasicFileChecking()
/**
* **************** CheckLine ***************
*/
bool
ParameterFileParser
::CheckLine( const std::string & lineIn, std::string & lineOut ) const
{
/** Preprocessing of lineIn:
* 1) Replace tabs with spaces
* 2) Remove everything after comment sign //
* 3) Remove leading spaces
* 4) Remove trailing spaces
*/
lineOut = lineIn;
itksys::SystemTools::ReplaceString( lineOut, "\t", " " );
itksys::RegularExpression commentPart( "//" );
if ( commentPart.find( lineOut ) )
{
lineOut = lineOut.substr( 0, commentPart.start() );
}
itksys::RegularExpression leadingSpaces( "^[ ]*(.*)" );
leadingSpaces.find( lineOut );
lineOut = leadingSpaces.match( 1 );
itksys::RegularExpression trailingSpaces( "[ \t]+$" );
if ( trailingSpaces.find( lineOut ) )
{
lineOut = lineOut.substr( 0, trailingSpaces.start() );
}
/**
* Checks:
* 1. Empty line -> false
* 2. Comment (line starts with "//") -> false
* 3. Line is not between brackets (...) -> exception
* 4. Line contains less than two words -> exception
*
* Otherwise return true.
*/
/** 1. Check for non-empty lines. */
itksys::RegularExpression reNonEmptyLine( "[^ ]+" );
bool match1 = reNonEmptyLine.find( lineOut );
if ( !match1 )
{
return false;
}
/** 2. Check for comments. */
itksys::RegularExpression reComment( "^//" );
bool match2 = reComment.find( lineOut );
if ( match2 )
{
return false;
}
/** 3. Check if line is between brackets. */
if ( !itksys::SystemTools::StringStartsWith( lineOut.c_str(), "(" )
|| !itksys::SystemTools::StringEndsWith( lineOut.c_str(), ")" ) )
{
std::string hint = "Line is not between brackets: \"(...)\".";
this->ThrowException( lineIn, hint );
}
/** Remove brackets. */
lineOut = lineOut.substr( 1, lineOut.size() - 2 );
/** 4. Check: the line should contain at least two words. */
itksys::RegularExpression reTwoWords( "([ ]+)([^ ]+)" );
bool match4 = reTwoWords.find( lineOut );
if ( !match4 )
{
std::string hint = "Line does not contain a parameter name and value.";
this->ThrowException( lineIn, hint );
}
/** At this point we know its at least a line containing a parameter.
* However, this line can still be invalid, for example:
* (string &^%^*)
* This will be checked later.
*/
return true;
} // end CheckLine()
/**
* **************** GetParameterFromLine ***************
*/
void
ParameterFileParser
::GetParameterFromLine( const std::string & fullLine,
const std::string & line )
{
/** A line has a parameter name followed by one or more parameters.
* They are all separated by one or more spaces (all tabs have been
* removed previously) or by quotes in case of strings. So,
* 1) we split the line at the spaces or quotes
* 2) the first one is the parameter name
* 3) the other strings that are not a series of spaces, are parameter values
*/
/** 1) Split the line. */
std::vector<std::string> splittedLine;
this->SplitLine( fullLine, line, splittedLine );
/** 2) Get the parameter name. */
std::string parameterName = splittedLine[ 0 ];
itksys::SystemTools::ReplaceString( parameterName, " ", "" );
splittedLine.erase( splittedLine.begin() );
/** 3) Get the parameter values. */
std::vector< std::string > parameterValues;
for ( unsigned int i = 0; i < splittedLine.size(); ++i )
{
if ( splittedLine[ i ] != "" )
{
parameterValues.push_back( splittedLine[ i ] );
}
}
/** 4) Perform some checks on the parameter name. */
itksys::RegularExpression reInvalidCharacters1( "[.,:;!@#$%^&-+|<>?]" );
bool match = reInvalidCharacters1.find( parameterName );
if ( match )
{
std::string hint = "The parameter \""
+ parameterName
+ "\" contains invalid characters (.,:;!@#$%^&-+|<>?).";
this->ThrowException( fullLine, hint );
}
/** 5) Perform checks on the parameter values. */
itksys::RegularExpression reInvalidCharacters2( "[,;!@#$%^&|<>?]" );
for ( unsigned int i = 0; i < parameterValues.size(); ++i )
{
/** For all entries some characters are not allowed. */
if ( reInvalidCharacters2.find( parameterValues[ i ] ) )
{
std::string hint = "The parameter value \""
+ parameterValues[ i ]
+ "\" contains invalid characters (,;!@#$%^&|<>?).";
this->ThrowException( fullLine, hint );
}
}
/** 6) Insert this combination in the parameter map. */
if ( this->m_ParameterMap.count( parameterName ) )
{
std::string hint = "The parameter \""
+ parameterName
+ "\" is specified more than once.";
this->ThrowException( fullLine, hint );
}
else
{
this->m_ParameterMap.insert( make_pair( parameterName, parameterValues ) );
}
} // end GetParameterFromLine()
/**
* **************** SplitLine ***************
*/
void
ParameterFileParser
::SplitLine( const std::string & fullLine, const std::string & line,
std::vector<std::string> & splittedLine ) const
{
splittedLine.clear();
splittedLine.resize( 1 );
std::vector<itksys::String> splittedLine1;
/** Count the number of quotes in the line. If it is an odd value, the
* line contains an error; strings should start and end with a quote, so
* the total number of quotes is even.
*/
std::size_t numQuotes = itksys::SystemTools::CountChar( line.c_str(), '"' );
if ( numQuotes % 2 == 1 )
{
/** An invalid parameter line. */
std::string hint = "This line has an odd number of quotes (\").";
this->ThrowException( fullLine, hint );
}
/** Loop over the line. */
std::string::const_iterator it;
unsigned int index = 0;
numQuotes = 0;
for ( it = line.begin(); it < line.end(); it++ )
{
if ( *it == '"' )
{
/** Start a new element. */
splittedLine.push_back( "" );
index++;
numQuotes++;
}
else if ( *it == ' ' )
{
/** Only start a new element if it is not a quote, otherwise just add
* the space to the string.
*/
if ( numQuotes % 2 == 0 )
{
splittedLine.push_back( "" );
index++;
}
else
{
splittedLine[ index ].push_back( *it );
}
}
else
{
/** Add this character to the element. */
splittedLine[ index ].push_back( *it );
}
}
} // end SplitLine()
/**
* **************** ThrowException ***************
*/
void
ParameterFileParser
::ThrowException( const std::string & line, const std::string & hint ) const
{
/** Construct an error message. */
std::string errorMessage
= "ERROR: the following line in your parameter file is invalid: \n\""
+ line
+ "\"\n"
+ hint
+ "\nPlease correct you parameter file!";
/** Throw exception. */
itkExceptionMacro( << errorMessage.c_str() );
} // end ThrowException()
/**
* **************** ReturnParameterFileAsString ***************
*/
std::string
ParameterFileParser
::ReturnParameterFileAsString( void )
{
/** Perform some basic checks. */
this->BasicFileChecking();
/** Open the parameter file for reading. */
if ( this->m_ParameterFile.is_open() )
{
this->m_ParameterFile.clear();
this->m_ParameterFile.close();
}
this->m_ParameterFile.open( this->m_ParameterFileName.c_str(), std::fstream::in );
/** Check if it opened. */
if ( !this->m_ParameterFile.is_open() )
{
itkExceptionMacro( << "ERROR: could not open "
<< this->m_ParameterFileName
<< " for reading." );
}
/** Loop over the parameter file, line by line. */
std::string line = "";
std::string output;
while ( this->m_ParameterFile.good() )
{
/** Extract a line. */
itksys::SystemTools::GetLineFromStream( this->m_ParameterFile, line ); // \todo: returns bool
output += line + "\n";
}
/** Close the parameter file. */
this->m_ParameterFile.clear();
this->m_ParameterFile.close();
/** Return the string. */
return output;
} // end ReturnParameterFileAsString()
} // end namespace itk
#endif // end __itkParameterFileParser_cxx
| [
"[email protected]"
]
| [
[
[
1,
474
]
]
]
|
87610ab5d2d36b6327548f98b88346fdc88223db | 5ff30d64df43c7438bbbcfda528b09bb8fec9e6b | /kgraphics/math/FileReader.h | 2c336f2bfb002970ecdf82cfdb3d5f764ae8510b | []
| no_license | lvtx/gamekernel | c80cdb4655f6d4930a7d035a5448b469ac9ae924 | a84d9c268590a294a298a4c825d2dfe35e6eca21 | refs/heads/master | 2016-09-06T18:11:42.702216 | 2011-09-27T07:22:08 | 2011-09-27T07:22:08 | 38,255,025 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 820 | h | #pragma once
#include <fstream>
namespace gfx {
class FileReader : public std::ifstream
{
public:
// constructor/destructor
inline FileReader() : std::ifstream() {}
inline FileReader( const char* filename ) : std::ifstream( filename ) {}
inline ~FileReader() {}
// stream management
// open the stream
void Open( const char* filename ) { std::ifstream::open( filename ); }
// close the stream
void Close() { std::ifstream::close(); }
protected:
// hide base open routine (we control the mode )
void open( const char * filename, openmode mode );
private:
// copy operations
FileReader(const FileReader& other);
FileReader& operator=(const FileReader& other);
};
} // namespace gfx
| [
"keedongpark@keedongpark"
]
| [
[
[
1,
31
]
]
]
|
e9880baf9b9cabf42d506ec190d9ecc512533d1e | 15af06eb4abeb931d51d642057b5f60ed61d3cbf | /group/ccsjt/Usermanage/Group/Public.inc | e9363b996435ef6d2981bc48a1f6040146fe5075 | []
| no_license | zhaowe/bc | cf9954e205703e301dd1095c92901d100b159cb7 | d83f2b9219356e3abce3efca0f62efb92266d03d | refs/heads/master | 2021-01-19T18:07:19.497291 | 2011-04-15T12:01:35 | 2011-04-15T12:01:35 | 1,598,344 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 73 | inc | <%
Locale=application("locale")
UseObject=application("UseObject")
%> | [
"[email protected]"
]
| [
[
[
1,
4
]
]
]
|
b17c19eda8a98ec3419050f469e9a69b79233b3e | b2d46af9c6152323ce240374afc998c1574db71f | /cursovideojuegos/theflostiproject/Code/Tools/Tests/AVITestProcess.cpp | e26391155fb91c4f0e7fdcee1e1561c2f96e6ed0 | []
| no_license | bugbit/cipsaoscar | 601b4da0f0a647e71717ed35ee5c2f2d63c8a0f4 | 52aa8b4b67d48f59e46cb43527480f8b3552e96d | refs/heads/master | 2021-01-10T21:31:18.653163 | 2011-09-28T16:39:12 | 2011-09-28T16:39:12 | 33,032,640 | 0 | 0 | null | null | null | null | MacCentralEurope | C++ | false | false | 12,490 | cpp | #include "__PCH_Tests.h"
#include "AVITestProcess.h"
//---Engine Includes--------
#include "Core/Core.h"
#include "Language/LanguageManager.h"
#include "Input/InputManager.h"
#include "Input/ActionToInput.h"
#include "Graphics/RenderManager.h"
#include "Graphics/FontManager.h"
#include "Logger/Logger.h"
#include "Graphics/Object3D.h"
#include "Graphics/ThPSCamera.h"
#include "Graphics/Textures/TextureManager.h"
#include "Graphics/Textures/Texture.h"
#include "Graphics/AviPlayer.h"
#include "Graphics/AviPlayerManager.h"
#include "Script/ScriptManager.h"
#include "Sound/SoundManager.h"
#include "luabind/luabind.hpp"
//--------------------------
//----------------------------------------------------------------------------
// Finalize data
//----------------------------------------------------------------------------
bool CAVITestProcess::Init ()
{
CProcess::m_bIsOk = false;
m_pObject3D = new CObject3D(Vect3f(0.f,0.f,0.f), 0.f, 0.f);
uint32 w,h;
CORE->GetRenderManager()->GetWidthAndHeight(w,h);
float aspect_ratio = (float)w/h;
m_pCamera = new CThPSCamera(1.f,500.f,mathUtils::Deg2Rad(60.f),aspect_ratio,m_pObject3D,50.f);
if (m_pObject3D && m_pCamera)
{
CProcess::m_bIsOk = true;
}
if (m_bIsOk)
{
CRenderManager* rm = CORE->GetRenderManager();
CAviPlayerManager* aviM = CORE->GetAviPlayerManager();
m_pAviTexture1 = new CTexture();
aviM->SetAviTexture("lost",m_pAviTexture1);
aviM->PlayAvi("lost");
m_pAviTexture2 = new CTexture();
aviM->SetAviTexture("intro",m_pAviTexture2);
aviM->PlayAvi("intro");
CTextureManager* textureM = CORE->GetTextureManager();
m_pQuadTextureFragile1 = textureM->GetTexture("./Data/Textures/fragile2.jpg");
m_uSoundSource = CORE->GetSoundManager()->CreateSource();
//CORE->GetSoundManager()->PlaySource2D(m_uSoundSource,"help",true);
}
if (!CProcess::m_bIsOk)
{
Release();
}
return CProcess::m_bIsOk;
}
void CAVITestProcess::Release ()
{
CHECKED_DELETE(m_pObject3D);
CHECKED_DELETE(m_pCamera);
CHECKED_DELETE(m_pAviTexture1);
CHECKED_DELETE(m_pAviTexture2);
CORE->GetAviPlayerManager()->UnLoadAvis();
}
void CAVITestProcess::RenderScene (CRenderManager* renderManager, CFontManager* fm)
{
renderManager->DrawAxis(40.f);
//renderManager->DrawGrid(50.f,colWHITE,20,20);
renderManager->DrawGrid(50.f,colWHITE,20,20, PAINT_WIREFRAME);
renderManager->DrawCamera(m_pCamera);
//renderManager->DrawSphere(5.f);
//renderManager->DrawCylinder(5.f, 5.f, 10.f, 10, colBLUE, PAINT_BOTH, true);
//renderManager->DrawCylinder(3.f, 3.f, 6.f, 10, colRED, PAINT_WIREFRAME, true);
//renderManager->DrawSphere(3.f,colRED,10,PAINT_BOTH);
//renderManager->DrawSphere(3.f,colRED,10,PAINT_BOTH);
//renderManager->DrawSphere(3.f,colRED,10,PAINT_BOTH);
//renderManager->DrawSphere(3.f,colRED,10,PAINT_BOTH);
//renderManager->DrawSphere(3.f,colRED,10,PAINT_BOTH);
//renderManager->DrawSphere(3.f,colRED,10,PAINT_BOTH);
//renderManager->DrawCapsule(3.f,5.f, 10, colRED, PAINT_SOLID);
//renderManager->DrawCube(6.f);
//renderManager->DrawPlane(20.f,Vect3f(1.0f,0.,0.f), 1.f, colBLUE,20,20, PAINT_BOTH);
//-----Dibujamos un cubo a base de quads---
//Vamos a dibujar un cubo 6 quads, con una textura de madera (de 4x4x4):
//La normal del quad va en el sentido del reloj respecto el vector right que se ha pasado como argumento->
//Quad top->
/*
renderManager->DrawQuad3D(v3fY*2, -v3fX, v3fZ, 4.f, 4.f, m_pQuadTextureFragile1);
//Quad bottom->
renderManager->DrawQuad3D(v3fY*-2, v3fX, v3fZ, 4.f, 4.f, m_pQuadTextureFragile1);
//Quad front->(miramos por el eje X)
renderManager->DrawQuad3D(v3fX*2, v3fY, v3fZ, 4.f, 4.f, m_pQuadTextureFragile1);
//Quad back->(miramos por el eje X)
renderManager->DrawQuad3D(v3fX*-2, -v3fY, v3fZ, 4.f, 4.f, m_pQuadTextureFragile1);
//Quad left->(miramos por el eje X)
renderManager->DrawQuad3D(v3fZ*2, -v3fY, v3fX, 4.f, 4.f, m_pQuadTextureFragile1);
//Quad right->(miramos por el eje X)
renderManager->DrawQuad3D(v3fZ*-2, v3fY, v3fX, 4.f, 4.f, m_pQuadTextureFragile1);
*/
//renderManager->DrawCube(5.f,colRED, PAINT_SOLID);
//renderManager->DrawBox(5.f,6.f,7.f,colRED, PAINT_SOLID);
//Render avi3D
//renderManager->DrawQuad3D(v3fX*2.05f, v3fY, v3fZ, 3.f, 3.f, m_pAviTexture1);
//renderManager->DrawQuad3D(v3fZ*-2.05f, v3fY, v3fX, 3.f, 3.f, m_pAviTexture2);
//renderManager->DrawQuad2D(Vect2i(750,500),250,200,UPPER_LEFT, m_pAviTexture1);
//renderManager->EnableAlphaBlend();
//renderManager->EnableZBuffering();
////CTexture* texture = CORE->GetTextureManager()->GetTexture("Data/Textures/columna.png");
//CTexture* texture = CORE->GetTextureManager()->GetTexture("Data/Textures/f_helpa.png");
//renderManager->DrawQuad2D(Vect2i(0,0), 500, 500, UPPER_LEFT, texture, FLIP_X );
//renderManager->DisbaleZBuffering();
//renderManager->DisbaleAlphaBlend();
float value;
m_LerpAnimator1D.Update(0.f,value);
/*
renderManager->DrawText((uint32)value,200,colBLACK,renderManager->GetTTF_Id("xfiles"),"El murci corrrre!");
renderManager->DrawText(100,400,colRED,renderManager->GetTTF_Id("futurama"),"El murcielago corre!");
renderManager->DrawText(100,600,colWHITE,renderManager->GetTTF_Id("Annabel"),"El murcielago corre!");
*/
SLiteral l_literal;
fm->DrawLiteral(100, 100, "HiWorld");
fm->DrawLiteral(100, 200, "Exit");
fm->DrawDefaultText(100,300,colRED,"H“LAń—");
}
uint32 CAVITestProcess::RenderDebugInfo(CRenderManager* renderManager, CFontManager* fm, float fps)
{
uint32 posY = 0;
posY = CProcess::RenderDebugInfo(renderManager, fm, fps);
if (m_bRenderDebugInfo)
{
uint32 posX = m_PosRenderDebugInfo.x;
posY+=fm->DrawDefaultText(posX,posY,colWHITE,"____________________________________________________" );
posY+=fm->DrawDefaultText(posX,posY,colWHITE,"" );
posY+=fm->DrawDefaultText(posX,posY,colWHITE,"AviTestProcess: per probar la classe CAvi" );
CInputManager * inputManager = CORE->GetInputManager();
float deltaTirggerRight,deltaTirggerLeft;
inputManager->GetGamePadDeltaTriggers(&deltaTirggerLeft, &deltaTirggerRight);
posY+=fm->DrawDefaultText(posX,posY,colWHITE,"Delta Trigger Left,Right= (%f, %f" , deltaTirggerLeft, deltaTirggerRight);
float l_fX, l_fY;
inputManager->GetGamePadLeftThumbDeflection(&l_fX, &l_fY);
posY+=fm->DrawDefaultText(posX,posY,colWHITE,"Left Thumb Deflection (x,y)=(%f, %f)" , l_fX, l_fY);
inputManager->GetGamePadRightThumbDeflection(&l_fX, &l_fY);
posY+=fm->DrawDefaultText(posX,posY,colWHITE,"Right Thumb Deflection (x,y)=(%f, %f)" , l_fX, l_fY);
std::string padbuttons = "Pad Buttons isdown: ";
if( inputManager->IsDown(IDV_GAMEPAD1, PAD_DPAD_UP))
padbuttons += " DPAD_UP ";
if( inputManager->IsDown(IDV_GAMEPAD1, PAD_DPAD_DOWN))
padbuttons += " DPAD_DOWN ";
if( inputManager->IsDown(IDV_GAMEPAD1, PAD_DPAD_LEFT))
padbuttons += " DPAD_LEFT ";
if( inputManager->IsDown(IDV_GAMEPAD1, PAD_DPAD_RIGHT))
padbuttons += " DPAD_RIGHT ";
if( inputManager->IsDown(IDV_GAMEPAD1, PAD_DPAD_START))
padbuttons += " DPAD_START ";
if( inputManager->IsDown(IDV_GAMEPAD1, PAD_DPAD_BACK))
padbuttons += " DPAD_BACK ";
if( inputManager->IsDown(IDV_GAMEPAD1, PAD_BUTTON_LEFT_THUMB))
padbuttons += " LEFT_THUMB ";
if( inputManager->IsDown(IDV_GAMEPAD1, PAD_BUTTON_RIGHT_THUMB))
padbuttons += " RIGHT_THUMB ";
if( inputManager->IsDown(IDV_GAMEPAD1, PAD_BUTTON_LEFT_SHOULDER))
padbuttons += " LEFT_SHOULDER ";
if( inputManager->IsDown(IDV_GAMEPAD1, PAD_BUTTON_RIGHT_SHOULDER))
padbuttons += " RIGHT_SHOULDER ";
if( inputManager->IsDown(IDV_GAMEPAD1, PAD_BUTTON_A))
padbuttons += " A ";
if( inputManager->IsDown(IDV_GAMEPAD1, PAD_BUTTON_B))
padbuttons += " B ";
if( inputManager->IsDown(IDV_GAMEPAD1, PAD_BUTTON_X))
padbuttons += " X ";
if( inputManager->IsDown(IDV_GAMEPAD1, PAD_BUTTON_Y))
padbuttons += " Y ";
posY+=fm->DrawDefaultText(posX,posY,colWHITE,"%s" , padbuttons.c_str());
posY+=fm->DrawDefaultText(posX,posY,colWHITE,"____________________________________________________" );
}
return posY;
}
void CAVITestProcess::Update (float elapsedTime)
{
CProcess::Update(elapsedTime);
CCore * core = CCore::GetSingletonPtr();
CInputManager * inputManager = core->GetInputManager();
UpdateInputActions(inputManager);
float value;
if (m_LerpAnimator1D.Update(elapsedTime,value))
{
if (value == 0.f)
{
m_LerpAnimator1D.SetValues(0.f,700.f, 2.f,FUNC_INCREMENT);
}
else
{
m_LerpAnimator1D.SetValues(700.f,0.f, 2.f,FUNC_INCREMENT);
}
}
float deltaTirggerRight,deltaTirggerLeft;
inputManager->GetGamePadDeltaTriggers(&deltaTirggerLeft, &deltaTirggerRight);
uint32 left = uint32((deltaTirggerLeft/255)*65535);
uint32 right = uint32((deltaTirggerRight/255)*65535);
inputManager->SetGamePadLeftMotorSpeed(left);
inputManager->SetGamePadRightMotorSpeed(right);
}
void CAVITestProcess::UpdateInputActions (CInputManager* inputManager)
{
//----------------------------------------------------------
//-----ACTUALIZAMOS LA CAMARA ESFERICA AL ESTILO DEL MAX----
Vect3i deltaMouse;
deltaMouse = inputManager->GetMouseDelta();
CActionToInput* input2Action = CORE->GetActionToInput();
float delta;
if (input2Action->DoAction("YawViewerCam", delta))
{
delta = delta * 0.01f;
float yaw = m_pObject3D->GetYaw();
m_pObject3D->SetYaw(yaw+delta);
}
if (input2Action->DoAction("PitchViewerCam", delta))
{
delta = delta * 0.01f;
float pitch = m_pObject3D->GetPitch();
m_pObject3D->SetPitch(pitch+delta);
}
if (input2Action->DoAction("SlowZoomViewerCam", delta))
{
delta = delta * 0.1f;
float increment = 0.1f;
static_cast<CThPSCamera*>(m_pCamera)->AddZoom(-delta*increment);
}
else if (input2Action->DoAction("ZoomViewerCam", delta))
{
delta = delta * 0.1f;
float increment = 1.0f;
static_cast<CThPSCamera*>(m_pCamera)->AddZoom(-delta*increment);
}
if (input2Action->DoAction("MoveXViewerCam", delta))
{
//Perpendicularmente a su yaw. Realizamos un strafe
delta = -delta * 0.1f;
float yaw = m_pObject3D->GetYaw()+ePI2f;
Vect3f directionXZ( cos(yaw), 0, sin(yaw) );
//nos desplazamos a una velocidad de 1unidad x segundo
m_pObject3D->SetPosition(m_pObject3D->GetPosition()+directionXZ*delta);
}
if (input2Action->DoAction("MoveZViewerCam", delta))
{
//Segun su yaw directamente
float delat = -delta * 0.1f;
float yaw = m_pObject3D->GetYaw();
Vect3f directionXZ( cos(yaw), 0, sin(yaw) );
m_pObject3D->SetPosition(m_pObject3D->GetPosition()+directionXZ*delat);
}
//----------------------------------------------------------
//----------------------------------------------------------
if( inputManager->IsDownUp(IDV_KEYBOARD,KEY_0) )
{
CORE->GetLanguageManager()->SetCurrentLanguage("spanish");
}
if( inputManager->IsDownUp(IDV_KEYBOARD,KEY_9) )
{
CORE->GetLanguageManager()->SetCurrentLanguage("english");
}
if( inputManager->IsDownUp(IDV_KEYBOARD,KEY_8) )
{
CORE->GetLanguageManager()->SetCurrentLanguage("catalan");
}
if( inputManager->IsDownUp(IDV_KEYBOARD,KEY_7) )
{
CORE->GetSoundManager()->FadeOutSource(m_uSoundSource,4.f);
}
if( inputManager->IsDownUp(IDV_KEYBOARD,KEY_6) )
{
CORE->GetSoundManager()->FadeInSource(m_uSoundSource,4.f);
}
if( inputManager->IsDownUp(IDV_KEYBOARD,KEY_H ))
{
CORE->GetActionToInput()->SaveXML("./kaka.xml");
}
}
//-----------------ScriptManager------------------------------
void CAVITestProcess::RegisterFunctions (CScriptManager* scriptManager)
{
lua_State* l_pLUAState = scriptManager->GetLuaState();
using namespace luabind;
// ahora registramos lo que querramos
module(l_pLUAState)
[
def("getAVITest", GetAVITest),
// registramos la clase CAVITestProcess
class_<CAVITestProcess>(CScriptRegister::SetClassName("CAVITestProcess"))
// registramos su constructor
.def(constructor<const std::string&>())
// registramos sus funciones
// registramos sus funciones
.def( CScriptRegister::PushFunctionName(AUTO_COMPLETE), &CScriptRegister::AutoComplete)
.def( CScriptRegister::PushFunctionName(HELP,"void","void",
"Muestra todas las funciones de esta clase"),
&CScriptRegister::Help)
];
} | [
"ohernandezba@71d53fa2-cca5-e1f2-4b5e-677cbd06613a"
]
| [
[
[
1,
359
]
]
]
|
b60a14fc5fae13d5e8261c9882a4d68086c1c1ed | a9afa168fac234c3b838dd29af4a5966a6acb328 | /CppUTest/src/Platforms/StarterKit/StarterMemoryLeakWarning.cpp | 48af69a002dbbe3191817203ecd331ae54c491d3 | []
| no_license | unclebob/tddrefcpp | 38a4170c38f612c180a8b9e5bdb2ec9f8971832e | 9124a6fad27349911658606392ba5730ff0d1e15 | refs/heads/master | 2021-01-25T07:34:57.626817 | 2010-05-10T20:01:39 | 2010-05-10T20:01:39 | 659,579 | 8 | 5 | null | null | null | null | UTF-8 | C++ | false | false | 6,691 | cpp | /*
* Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "CppUTest/MemoryLeakWarning.h"
#include <stdlib.h>
#include <stdio.h>
/* Static since we REALLY can have only one of these! */
static int allocatedBlocks = 0;
static int allocatedArrays = 0;
static int firstInitialBlocks = 0;
static int firstInitialArrays = 0;
static bool reporterRegistered = false;
class MemoryLeakWarningData
{
public:
MemoryLeakWarningData();
int initialBlocksUsed;
int initialArraysUsed;
int blockUsageCheckPoint;
int arrayUsageCheckPoint;
int expectCount;
char message[100];
};
void MemoryLeakWarning::CreateData()
{
_impl = (MemoryLeakWarningData*) malloc(sizeof(MemoryLeakWarningData));
_impl->initialBlocksUsed = 0;
_impl->initialArraysUsed = 0;
_impl->blockUsageCheckPoint = 0;
_impl->arrayUsageCheckPoint = 0;
_impl->expectCount = 0;
_impl->message[0] = '\0';
}
void MemoryLeakWarning::DestroyData()
{
free(_impl);
}
extern "C" {
void reportMemoryBallance();
}
void reportMemoryBallance()
{
int blockBalance = allocatedBlocks - firstInitialBlocks;
int arrayBalance = allocatedArrays - firstInitialArrays;
if (blockBalance == 0 && arrayBalance == 0)
;
else if (blockBalance + arrayBalance == 0)
printf("No leaks but some arrays were deleted without []\n");
else
{
if (blockBalance > 0)
printf("Memory leak! %d blocks not deleted\n", blockBalance);
if (arrayBalance > 0)
printf("Memory leak! %d arrays not deleted\n", arrayBalance);
if (blockBalance < 0)
printf("More blocks deleted than newed! %d extra deletes\n", blockBalance);
if (arrayBalance < 0)
printf("More arrays deleted than newed! %d extra deletes\n", arrayBalance);
printf("NOTE - some memory leaks appear to be allocated statics that are not released\n"
" - by the standard library\n"
" - Use the -r switch on your unit tests to repeat the test sequence\n"
" - If no leaks are reported on the second pass, it is likely a static\n"
" - that is not released\n");
}
}
MemoryLeakWarning* MemoryLeakWarning::_latest = NULL;
MemoryLeakWarning::MemoryLeakWarning()
{
_latest = this;
CreateData();
}
MemoryLeakWarning::~MemoryLeakWarning()
{
DestroyData();
}
MemoryLeakWarning* MemoryLeakWarning::GetLatest()
{
return _latest;
}
void MemoryLeakWarning::SetLatest(MemoryLeakWarning* latest)
{
_latest = latest;
}
void MemoryLeakWarning::Enable()
{
_impl->initialBlocksUsed = allocatedBlocks;
_impl->initialArraysUsed = allocatedArrays;
if (!reporterRegistered) {
firstInitialBlocks = allocatedBlocks;
firstInitialArrays = allocatedArrays;
reporterRegistered = true;
}
}
const char* MemoryLeakWarning::FinalReport(int toBeDeletedLeaks)
{
if (_impl->initialBlocksUsed != (allocatedBlocks-toBeDeletedLeaks)
|| _impl->initialArraysUsed != allocatedArrays )
{
printf("initial blocks=%d, allocated blocks=%d\ninitial arrays=%d, allocated arrays=%d\n",
_impl->initialBlocksUsed, allocatedBlocks, _impl->initialArraysUsed, allocatedArrays);
return "Memory new/delete imbalance after running tests\n";
}
else
return "";
}
void MemoryLeakWarning::CheckPointUsage()
{
_impl->blockUsageCheckPoint = allocatedBlocks;
_impl->arrayUsageCheckPoint = allocatedArrays;
}
bool MemoryLeakWarning::UsageIsNotBalanced()
{
int arrayBalance = allocatedArrays - _impl->arrayUsageCheckPoint;
int blockBalance = allocatedBlocks - _impl->blockUsageCheckPoint;
if (_impl->expectCount != 0 && blockBalance + arrayBalance == _impl->expectCount)
return false;
if (blockBalance == 0 && arrayBalance == 0)
return false;
else if (blockBalance + arrayBalance == 0)
sprintf(_impl->message, "No leaks but some arrays were deleted without []\n");
else
{
int nchars = 0;
if (_impl->blockUsageCheckPoint != allocatedBlocks)
nchars = sprintf(_impl->message, "this test leaks %d blocks",
allocatedBlocks - _impl->blockUsageCheckPoint);
if (_impl->arrayUsageCheckPoint != allocatedArrays)
sprintf(_impl->message + nchars, "this test leaks %d arrays",
allocatedArrays - _impl->arrayUsageCheckPoint);
}
return true;
}
const char* MemoryLeakWarning::Message()
{
return _impl->message;
}
void MemoryLeakWarning::ExpectLeaks(int n)
{
_impl->expectCount = n;
}
/* Global overloaded operators */
void* operator new(size_t size)
{
allocatedBlocks++;
return malloc(size);
}
void operator delete(void* mem)
{
allocatedBlocks--;
free(mem);
}
void* operator new[](size_t size)
{
allocatedArrays++;
return malloc(size);
}
void operator delete[](void* mem)
{
allocatedArrays--;
free(mem);
}
void* operator new(size_t size, const char* file, int line)
{
allocatedBlocks++;
return malloc(size);
}
| [
"[email protected]"
]
| [
[
[
1,
225
]
]
]
|
1e8acf1d7cc2a155d6ae4274cad8c2aef4557a62 | c74b0c37ac8e2d3d1a3c0ffaa2b608bc4deff1c6 | /Toolkit/FreyaReflect/Lib/Source/ASTParser.cpp | 350e02eb1c31377db335cb5dfe5a468c7a9e5363 | []
| no_license | crsib/freya-3d | c33beeb787e572f2faf9528c6f3a1fa3875749c5 | ff1f54b09f7bc0e253053a474f3fe5635dbedde6 | refs/heads/master | 2022-05-21T19:42:30.694778 | 2011-03-11T13:49:00 | 2011-03-11T13:49:00 | 259,894,429 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,385 | cpp | #include "FreyaReflect.h"
#include "NamespaceNode.h"
#include "ClassNodes.h"
#include "EnumNodes.h"
#include <exception>
#include <string>
#include <iostream>
#include "cc.ast.gen.h"
#include "srcloc.h"
#include <stack>
#include <hash_set>
class ASTException : public std::exception
{
public:
ASTException(const std::string& msg) : m_What(std::string("[ASTParser]: ") + msg) {}
virtual ~ASTException(){}
virtual const char * what() const
{
return m_What.c_str();
}
private:
std::string m_What;
};
#define checkLoc(obj) (parsed_paths.find(std::string(source_loc_man->getFile(obj->getLoc()))) != parsed_paths.end())
#define checkLoc2(obj) (parsed_paths.find(std::string(source_loc_man->getFile(obj->loc))) != parsed_paths.end())
class FASTVisitior : public ASTVisitor
{
public:
FASTVisitior()
{
free_function_count = 0;
class_count = 0;
namespace_count = 0;
enum_count = 0;
}
virtual bool visitFunction(Function *obj)
{
//std::cout << source_loc_man->getFile(obj->getLoc()) << std::endl;
if(checkLoc(obj))
{
//obj->nameAndParams->
// std::cout << obj->nameAndParams->getDeclaratorId()->getName() << "\n";
//Get the top node
CppNode* top = node_stack.top();
if(top->getNodeType() == CppNode::NODE_TYPE_NAMESPACE)
{
if(obj->nameAndParams && (obj->nameAndParams->var->flags & DF_MEMBER) ) //Still a member
return false;
std::cout << obj->nameAndParams->getDeclaratorId()->toString() << "\n";
free_function_count++;
}// Belongs to namespace - a free function
else //if(top->getNodeType() != CppNode::NODE_TYPE_NAMESPACE)
{
//Is a class member
//if(obj->dflags & DF_IMPLICIT)
// return false;
//Ok, lets create a member class. We believe, that it was never created
ClassMethod* n = new ClassMethod(obj->nameAndParams->getDeclaratorId()->getName(),
(static_cast<D_func*>(obj->nameAndParams->decl))->cv & CV_CONST, obj->dflags & DF_VIRTUAL, obj->dflags & DF_STATIC,node_stack.top());
node_stack.top()->addNode(n);
}//if(top->getNodeType() != CppNode::NODE_TYPE_NAMESPACE)
}
return false;
}
virtual bool visitDeclaration(Declaration *decl)
{
if(!checkLoc2(decl->spec))
return false;
switch(decl->spec->kind())
{
case TypeSpecifier::TS_CLASSSPEC:
{
//We are parsing a class declaration now
TS_classSpec* class_spec = static_cast<TS_classSpec*>(decl->spec);
if(class_spec->keyword == TI_CLASS || class_spec->keyword == TI_STRUCT)
{
if(class_spec->name == NULL)//It must be an unnamed struct
{
class_count++;
AnonymousStructNode* n = new AnonymousStructNode(node_stack.top());
node_stack.top()->addNode(n);
node_stack.push(n);
return true;
}
if(node_stack.top()->getNodeNamed(class_spec->name->getName()))
return false;
else
{
class_count++;
//Create a new class node
ClassNode* n = new ClassNode(class_spec->name->getName(),node_stack.top());
node_stack.top()->addNode(n);
node_stack.push(n);
return true; //Recursively pass the class structure down
}
} //Truly a class or a struct if(class_spec->keyword == TI_CLASS || class_spec->keyword == TI_STRUCT)
}//TS_CLASSSPEC
break;
case TypeSpecifier::TS_ENUMSPEC:
{
TS_enumSpec* enum_spec = static_cast<TS_enumSpec*>(decl->spec);
std::string ename = enum_spec->name ? enum_spec->name : "";
if(node_stack.top()->getNodeNamed(ename))
return false;
EnumNode* n = new EnumNode(ename, node_stack.top());
node_stack.top()->addNode(n);
FAKELIST_FOREACH(Enumerator,enum_spec->elts,enumerator)
{
n->addNode(new EnumValueNode(enumerator->name,enumerator->enumValue,n));
}
return false;
}
}//switch(decl->spec->kind())
return true;
}
virtual void postvisitDeclaration(Declaration *decl)
{
if(checkLoc2(decl->spec))
{
switch(decl->spec->kind())
{
case TypeSpecifier::TS_CLASSSPEC:
{
CppNode* top = node_stack.top();
if(
(top->getNodeType() == ClassNode::NODE_TYPE_CLASS)
&&
static_cast<TS_classSpec*>(decl->spec)->name
&&
(top->getShortName() == static_cast<TS_classSpec*>(decl->spec)->name->getName())
)
node_stack.pop();//Pop the node out
else if(
top->getNodeType() == ClassNode::NODE_TYPE_ANONYMOUS_STRUCT
)
node_stack.pop();
} //TS_CLASSSPEC
break;
}//switch
}
}
//======================= Template declaration parsing =================================================
virtual bool visitTemplateDeclaration(TemplateDeclaration *obj)
{
//Ok, the location will be checked using first template parameter
if(obj->kind() == TemplateDeclaration::TD_DECL)
{
return true;
}
else if(obj->kind() == TemplateDeclaration::TD_FUNC)
{
return true;
}
return false;
}
virtual void postvisitTemplateDeclaration(TemplateDeclaration *obj)
{
if(obj->kind() == TemplateDeclaration::TD_DECL)
{
}
}
//TopForm is basically anything on the top of namespace
virtual bool visitTopForm(TopForm *obj)
{
if(checkLoc2(obj))
{
switch(obj->kind())
{
case TopForm::TF_NAMESPACEDEFN:
{
TF_namespaceDefn* defn = static_cast<TF_namespaceDefn*>(obj);
if(defn->name == std::string("__internal"))
return false;
CppNode* nd = node_stack.top();
CppNode* n = NULL;
if(n = nd->getNodeNamed(defn->name))
{
node_stack.push(n);
}
else
{
n = new NamespaceNode(defn->name,node_stack.top());
node_stack.push(n);
nd->addNode(n);
}
return true;
} //TF_NAMESPACEDEFN
break;
case TopForm::TF_DECL:
case TopForm::TF_EXPLICITINST:
case TopForm::TF_TEMPLATE:
case TopForm::TF_ONE_LINKAGE:
return true;
}//switch
} // correct location
return true;
}
virtual void postvisitTopForm(TopForm *obj)
{
if(checkLoc2(obj))
{
switch(obj->kind())
{
case TopForm::TF_NAMESPACEDEFN:
{
TF_namespaceDefn* defn = static_cast<TF_namespaceDefn*>(obj);
if(defn->name == std::string("__internal"))
return;
node_stack.pop();
} //TF_NAMESPACEDEFN
break;
}// switch
}
}
public:
size_t free_function_count;
size_t namespace_count;
size_t class_count;
size_t enum_count;
std::stack<CppNode*> node_stack;
std::hash_set<std::string> parsed_paths;
SourceLocManager* source_loc_man;
};
void regenerateAST(CppNode* top, TranslationUnit* tree, const FreyaReflect::IncludePaths& paths,SourceLocManager* mgr)
{
FASTVisitior visitor;
visitor.node_stack.push(static_cast<NamespaceNode*>(top));
for(size_t i = 0; i < paths.size(); i++)
{
std::string path = paths[i];
#ifdef _MSC_VER
//We need to replace \\ to "\"
size_t pos = path.find("\\") ;
while(pos != std::string::npos)
{
path.replace(pos,1, "\\\\");
pos = path.find("\\",pos+3);
}
//std::cout << path << std::endl;
#endif
visitor.parsed_paths.insert(path);
}
visitor.source_loc_man = mgr;
tree->traverse(visitor);
std::clog << "Found functions: " << visitor.free_function_count << std::endl;
} | [
"crsib@localhost"
]
| [
[
[
1,
276
]
]
]
|
ae917c3e166fa300b22cd3676c961c2f8a9a459e | d9a78f212155bb978f5ac27d30eb0489bca87c3f | /PB/src/PbServer/main.cpp | c687e12d9436af15f0240bc015e12db0316be557 | []
| no_license | marchon/pokerbridge | 1ed4a6a521f8644dcd0b6ec66a1ac46879b8473c | 97d42ef318bf08f3bc0c0cb1d95bd31eb2a3a8a9 | refs/heads/master | 2021-01-10T07:15:26.496252 | 2010-05-17T20:01:29 | 2010-05-17T20:01:29 | 36,398,892 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 350 | cpp | #include "stdafx.h"
#include "pbserver.h"
int main(int argc, char*argv[])
{
QPBLog::install();
QPBLog::logToFile("pbserver.log");
//PBLib_init();
qLog(Debug)<<"pblaunch";
QCoreApplication app(argc, argv);
PBServer *s = new PBServer(&app);
int res = app.exec();
QPBLog::uninstall();
qLog(Debug) << "exiting";
}
| [
"mikhail.mitkevich@a5377438-2eb2-11df-b28a-19025b8c0740"
]
| [
[
[
1,
22
]
]
]
|
bcdfd14a6f5f301ce277771fabf0ec8f6091d66e | e6b2dff99c07c1ef66cc16d15594f8ae1de902d5 | /src/menu.cpp | 7ffd766bb43b578754adece1caa19e3a483ef980 | [
"BSD-3-Clause",
"LicenseRef-scancode-public-domain"
]
| permissive | bkz/w32context | 315e52c6985eb6717b0b613e0d186a70ce494135 | 86d6756d98a7f506b8cc395c9fb9ec0a35fe81b7 | refs/heads/master | 2016-09-06T00:26:14.364251 | 2009-10-14T18:23:43 | 2009-10-14T18:23:43 | 336,593 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,399 | cpp | ///////////////////////////////////////////////////////////////////////////////////////////////////
//
// Manually launch Explorer context menu for a file/folder.
//
// Inspired from code in Jeff Prosise column "Wicked Code" (WSJ April 1997).
//
// Babar k. Zafar ([email protected])
//
///////////////////////////////////////////////////////////////////////////////////////////////////
#include <windows.h>
#include <shlobj.h>
///////////////////////////////////////////////////////////////////////////////////////////////////
// Global data.
///////////////////////////////////////////////////////////////////////////////////////////////////
static WNDPROC g_pOldWndProc;
static LPCONTEXTMENU2 g_pIContext2or3;
///////////////////////////////////////////////////////////////////////////////////////////////////
// Utilities.
///////////////////////////////////////////////////////////////////////////////////////////////////
LPITEMIDLIST GetNextItem(LPITEMIDLIST pidl)
{
USHORT nLen;
if ((nLen = pidl->mkid.cb) == 0)
{
return NULL;
}
return (LPITEMIDLIST)(((LPBYTE) pidl) + nLen);
}
UINT GetItemCount(LPITEMIDLIST pidl)
{
USHORT nLen;
UINT nCount;
nCount = 0;
while ((nLen = pidl->mkid.cb) != 0)
{
pidl = GetNextItem(pidl);
nCount++;
}
return nCount;
}
LPITEMIDLIST DuplicateItem(LPMALLOC pMalloc, LPITEMIDLIST pidl)
{
USHORT nLen;
LPITEMIDLIST pidlNew;
nLen = pidl->mkid.cb;
if (nLen == 0)
{
return NULL;
}
pidlNew = (LPITEMIDLIST) pMalloc->Alloc(nLen + sizeof(USHORT));
if (pidlNew == NULL)
{
return NULL;
}
::CopyMemory(pidlNew, pidl, nLen);
*((USHORT*)(((LPBYTE) pidlNew) + nLen)) = 0;
return pidlNew;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// Render context menu.
///////////////////////////////////////////////////////////////////////////////////////////////////
LRESULT CALLBACK HookWndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
{
switch (msg)
{
case WM_DRAWITEM:
case WM_MEASUREITEM:
case WM_INITMENUPOPUP:
g_pIContext2or3->HandleMenuMsg(msg, wp, lp);
return msg == (WM_INITMENUPOPUP ? 0 : TRUE);
default:
break;
}
return CallWindowProc(g_pOldWndProc, hWnd, msg, wp, lp);
}
BOOL PopupExplorerMenu(HWND hWnd, LPWSTR pwszPath, POINT point)
{
BOOL bResult = FALSE;
LPMALLOC pMalloc = NULL;
LPSHELLFOLDER psfFolder = NULL;
LPSHELLFOLDER psfNextFolder = NULL;
if (!SUCCEEDED(SHGetMalloc(&pMalloc)))
return bResult;
if (!SUCCEEDED(SHGetDesktopFolder(&psfFolder)))
{
pMalloc->Release();
return bResult;
}
//
// Convert the path name into a pointer to an item ID list (pidl).
//
LPITEMIDLIST pidlMain;
ULONG ulCount;
ULONG ulAttr;
UINT nCount;
if (SUCCEEDED(psfFolder->ParseDisplayName(hWnd, NULL, pwszPath, &ulCount, &pidlMain, &ulAttr)) && (pidlMain != NULL))
{
if (nCount = GetItemCount(pidlMain))
{
//
// Initialize psfFolder with a pointer to the IShellFolder
// interface of the folder that contains the item whose context
// menu we're after, and initialize pidlItem with a pointer to
// the item's item ID. If nCount > 1, this requires us to walk
// the list of item IDs stored in pidlMain and bind to each
// subfolder referenced in the list.
//
LPITEMIDLIST pidlItem = pidlMain;
while (--nCount)
{
//
// Create a 1-item item ID list for the next item in pidlMain.
//
LPITEMIDLIST pidlNextItem = DuplicateItem(pMalloc, pidlItem);
if (pidlNextItem == NULL)
{
pMalloc->Free(pidlMain);
psfFolder->Release();
pMalloc->Release();
return bResult;
}
//
// Bind to the folder specified in the new item ID list.
//
if (!SUCCEEDED(psfFolder->BindToObject(pidlNextItem, NULL, IID_IShellFolder, (void**)&psfNextFolder)))
{
pMalloc->Free(pidlNextItem);
pMalloc->Free(pidlMain);
psfFolder->Release();
pMalloc->Release();
return bResult;
}
//
// Release the IShellFolder pointer to the parent folder
// and set psfFolder equal to the IShellFolder pointer for
// the current folder.
//
psfFolder->Release();
psfFolder = psfNextFolder;
//
// Release the storage for the 1-item item ID list we created
// just a moment ago and initialize pidlItem so that it points
// to the next item in pidlMain.
//
pMalloc->Free(pidlNextItem);
pidlItem = GetNextItem(pidlItem);
}
LPITEMIDLIST* ppidl = &pidlItem;
//
// Get a pointer to the item's IContextMenu interface and call
// IContextMenu::QueryContextMenu to initialize a context menu.
//
LPCONTEXTMENU pContextMenu = NULL;
if (SUCCEEDED(psfFolder->GetUIObjectOf(hWnd, 1, (LPCITEMIDLIST*)(ppidl), IID_IContextMenu, NULL, (void**)&pContextMenu)))
{
//
// Try to see if we can upgrade to an IContextMenu2/3 interface. If so we need
// to hook into the message handler to invoke IContextMenu2::HandleMenuMsg().
//
bool hook = false;
void *pInterface = NULL;
if (pContextMenu->QueryInterface(IID_IContextMenu3, &pInterface) == NOERROR)
{
pContextMenu->Release();
pContextMenu = (LPCONTEXTMENU)pInterface;
hook = true;
}
else if (pContextMenu->QueryInterface(IID_IContextMenu2, &pInterface) == NOERROR)
{
pContextMenu->Release();
pContextMenu = (LPCONTEXTMENU)pInterface;
hook = true;
}
const int MIN_ID = 1;
const int MAX_ID = 0x7FFF;
HMENU hMenu = ::CreatePopupMenu();
if (SUCCEEDED(pContextMenu->QueryContextMenu(hMenu, 0, MIN_ID, MAX_ID, CMF_EXPLORE)))
{
::ClientToScreen(hWnd, &point);
if (hook)
{
g_pOldWndProc = (WNDPROC)::SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)HookWndProc);
g_pIContext2or3 = (LPCONTEXTMENU2)pContextMenu;
}
else
{
g_pOldWndProc = 0;
g_pIContext2or3 = NULL;
}
//
// Display the context menu.
//
UINT nCmd = ::TrackPopupMenu(
hMenu,
TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RETURNCMD,
point.x,
point.y,
0,
hWnd,
NULL);
//
// Restore our hook into the message handler.
//
if (g_pOldWndProc)
{
::SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)g_pOldWndProc);
}
//
// If a command was selected from the menu, execute it.
//
if (nCmd)
{
CMINVOKECOMMANDINFO ici;
ici.cbSize = sizeof(CMINVOKECOMMANDINFO);
ici.fMask = 0;
ici.hwnd = hWnd;
ici.lpVerb = MAKEINTRESOURCEA(nCmd - MIN_ID);
ici.lpParameters = NULL;
ici.lpDirectory = NULL;
ici.nShow = SW_SHOWNORMAL;
ici.dwHotKey = 0;
ici.hIcon = NULL;
if (SUCCEEDED(pContextMenu->InvokeCommand(&ici)))
{
bResult = TRUE;
}
}
}
::DestroyMenu(hMenu);
pContextMenu->Release();
}
}
pMalloc->Free(pidlMain);
}
psfFolder->Release();
pMalloc->Release();
return bResult;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// Enum process child windows (property dialogs).
///////////////////////////////////////////////////////////////////////////////////////////////////
BOOL IsPropertyDialog(HWND hWnd)
{
wchar_t wszClassName[256] = {0};
::GetClassName(hWnd, wszClassName, _countof(wszClassName));
// Property dialogs use the special "#32770 (Dialog)" class.
return !wcscmp(wszClassName, L"#32770");
}
BOOL CALLBACK EnumWindowCallback(HWND hWnd, LPARAM lParam)
{
DWORD dwPID;
::GetWindowThreadProcessId(hWnd, &dwPID);
if (dwPID == ::GetCurrentProcessId())
{
BOOL* pbFoundChild = (BOOL*)(lParam);
if (IsPropertyDialog(hWnd))
{
*pbFoundChild = TRUE;
return FALSE;
}
}
return TRUE;
}
BOOL HaveChildDialogs()
{
BOOL bFoundChild = FALSE;
::EnumWindows(EnumWindowCallback, (LPARAM)(&bFoundChild));
return bFoundChild;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// Application entrypoint.
///////////////////////////////////////////////////////////////////////////////////////////////////
const int QUIT_TIMER_EVENT = 1;
const int QUIT_TIMER_SLEEP = 200;
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (uMsg == WM_TIMER && wParam == QUIT_TIMER_EVENT)
{
if (HaveChildDialogs())
{
::SetTimer(hWnd, QUIT_TIMER_EVENT, QUIT_TIMER_SLEEP, NULL);
}
else
{
::PostQuitMessage(EXIT_SUCCESS);
}
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
{
int argc = 0;
LPWSTR *argv = ::CommandLineToArgvW(::GetCommandLine(), &argc);
//
// Don't bother if we weren't passed a valid file or folder argument.
//
if (argc < 2)
{
return EXIT_FAILURE;
}
//
// We can't use a hidden window since that would break our popup menus.
//
static wchar_t szWndClassName[] = L"9534921E-82FD-4d3a-B073-FDE61CDEFE25";
static wchar_t szWndTitleName[] = L"AF150A73-1756-49f0-961A-1D13C4DD13D0";
WNDCLASS wc;
wc.style = 0;
wc.lpfnWndProc = MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = ::LoadIcon(NULL, IDI_WINLOGO);
wc.hCursor = ::LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)::GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = szWndClassName;
::RegisterClass(&wc);
HWND hWnd = ::CreateWindow(
szWndClassName,
szWndTitleName,
WS_POPUP,
0, 0,
1, 1,
HWND_DESKTOP,
NULL,
hInstance,
NULL);
::ShowWindow(hWnd, SW_SHOW);
::UpdateWindow(hWnd);
POINT pt;
::GetCursorPos(&pt);
PopupExplorerMenu(hWnd, argv[1], pt);
//
// Property dialogs are owned by this process so we have to wait until
// all child windows are destroyed before we can safely exit. We'll use
// timer to keep the message pump while we wait for the user to finish
// interacting with the property dialogs.
//
::SetTimer(hWnd, QUIT_TIMER_EVENT, QUIT_TIMER_SLEEP, NULL);
MSG msg;
while (::GetMessage(&msg, NULL, 0, 0))
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
return EXIT_SUCCESS;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// The End.
///////////////////////////////////////////////////////////////////////////////////////////////////
| [
"[email protected]"
]
| [
[
[
1,
446
]
]
]
|
78c4c19da27e0a4fbf08a078adea7e94d77afdd4 | bf0684ce69d618b1bbad5e2b4d8c8d4c79c1048b | /boot/log/include/logging.h | 6b362c2d6fdf1a4d30d8a0e0a222b839338bf615 | [
"BSD-3-Clause"
]
| permissive | cider-load-test/devon | 485829d3ad8c980eeeb352a594571e4ff69711aa | 5b11265e5eae3db7bfaeb49543a2a6293bd15557 | refs/heads/master | 2021-12-02T07:24:11.497854 | 2010-08-07T09:16:40 | 2010-08-07T09:16:40 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,280 | h | #ifndef DEVON_LOGGING_H
#define DEVON_LOGGING_H
// Devon
#include <Devon/Log.h>
#include <Devon/LogCategory.h>
#include <Devon/LogCommand.h>
#include <Devon/LogEvent.h>
#include <Devon/LogPop.h>
#include <Devon/LogLock.h>
#include <Devon/StringLog.h>
namespace Devon {
// *************************************************************************************************
#define DEFAULT_LOG ::Devon::Log::GetRootLog()
#define STRING_LOG ::Devon::Log::GetStringLog()
/**
* Re-define CURRENT_LOG to change the target log for a section of your code
*/
#define CURRENT_LOG DEFAULT_LOG
#define MESSAGE_CATEGORY ::Devon::LogCategoryDefault
#define ERROR_CATEGORY ::Devon::LogCategoryDefault
#define EXCEPTION_CATEGORY ::Devon::LogCategoryException
#define LIFETIME_CATEGORY ::Devon::LogCategoryLifetime
// *************************************************************************************************
// Logging Commmands
#define LOG_COMMAND(_NAME, _ATTRS) \
::Devon::LogCommand(_NAME) << _ATTRS << ::Devon::LogEndCommand
#define ATTR(_NAME, _VALUE) \
" " << #_NAME << "=\"" << \
::Devon::Log::EscapeXML << _VALUE << ::Devon::Log::EscapeNone << "\""
// *************************************************************************************************
// Logging Fundamentals
#define LOGEX(_MESSAGE) \
DEFAULT_LOG << ::Devon::LockLog << _MESSAGE << ::Devon::LogEnd
#define LOG_STRING(_MESSAGE) \
::Devon::ReleaseStringLog(static_cast< ::Devon::StringLog&>(::Devon::NewStringLog() \
<< _MESSAGE))
#define LOG(_MESSAGE) \
LOGEX(_MESSAGE << "\n")
#define LOG_MESSAGE(_STYLE, _MESSAGE) \
LOGEX(MESSAGE_CATEGORY << \
LOG_COMMAND("beginBlock", ATTR(name, _STYLE)) \
<< _MESSAGE \
<< LOG_COMMAND("endBlock", ""))
#define LOG_ERROR(_MESSAGE) \
LOGEX(ERROR_CATEGORY << _MESSAGE)
// *************************************************************************************************
// Logging Information
#define LOG_NOTE(_STYLE, _MESSAGE) \
LOG_MESSAGE("note " _STYLE, _MESSAGE)
#define NOTE(_MESSAGE) \
LOG_NOTE("", _MESSAGE)
#define NOTE_CREATE(_MESSAGE) \
LOG_NOTE("create", _MESSAGE);
#define NOTE_DESTROY(_MESSAGE) \
LOG_NOTE("destroy", _MESSAGE);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#define WARN(_MESSAGE) \
LOG_MESSAGE("warn", _MESSAGE << LOG_CODE_FILE())
#define WARN_IF(_CONDITION, _MESSAGE) \
if (_CONDITION) \
WARN(_MESSAGE)
#define WARN_PY(_MESSAGE) \
if (PyErr_Occurred()) \
{ \
LOG_MESSAGE("warn", "Python exception: " << _MESSAGE); \
PyErr_Print(); \
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// Logging Exceptions
#define LOG_EXCEPTION_FILE(_TITLE, _MESSAGE, _FILE, _LINE, _COLUMN) \
LOG_ERROR(EXCEPTION_CATEGORY << LOG_COMMAND("exceptionThrown", \
ATTR(title, _TITLE) \
<< ATTR(message, _MESSAGE) \
<< ATTR(fileName, _FILE) \
<< ATTR(line, _LINE) \
<< ATTR(column, _COLUMN)))
#define LOG_EXCEPTION_OBJECT(_EXC) \
LOG_EXCEPTION_FILE(_EXC.GetName(), _EXC.GetMessage(), _EXC.GetFileName(), _EXC.GetLine(), \
_EXC.GetColumn())
#define LOG_EXCEPTION(_TITLE, _MESSAGE) \
LOG_EXCEPTION_FILE(#_TITLE, _MESSAGE, __FILE__, __LINE__, 0)
// *************************************************************************************************
// Logging Debugging
#define LOG_REACH() \
LOGEX(LOG_COMMAND("reach", ATTR(fileName, __FILE__) << ATTR(line, __LINE__)))
#define LOG_VARIABLE(_VAR) LOGEX( \
LOG_COMMAND("beginVariable", ATTR(name, #_VAR) << ATTR(value, (_VAR))) \
<< LOG_COMMAND("endVariable", ""))
#define LOG_VARIABLE_FORMAT(_VAR, _FORMAT) LOGEX( \
LOG_COMMAND("beginVariable", ATTR(name, #_VAR) << ATTR(value, (_VAR))) \
<< _FORMAT(_VAR) \
<< LOG_COMMAND("endVariable", ""))
#define LOG_RAW(_TEXT) \
LOG(LOG_COMMAND("beginRawText", "") << _TEXT << LOG_COMMAND("endRawText", ""));
// *************************************************************************************************
// Logging Text Formats
#define LOG_URL(_TEXT) \
LOG_COMMAND("link", ATTR(href, _TEXT))
#define LOG_FILE(_PATH, _LINE) \
LOG_COMMAND("fileLink", ATTR(fileName, _PATH) << ATTR(line, _LINE))
#define LOG_CODE_FILE() \
LOG_COMMAND("fileLink", ATTR(fileName, __FILE__) << ATTR(line, __LINE__))
// *************************************************************************************************
// Logging Lifetimes
#define LOG_CONSTRUCTOR() \
LOGEX(LIFETIME_CATEGORY << \
LOG_COMMAND("constructObject", ATTR(id, (int)this) << ATTR(typeName, this)))
#define LOG_DESTRUCTOR() \
LOGEX(LIFETIME_CATEGORY << \
LOG_COMMAND("destroyObject", ATTR(id, (int)this) << ATTR(typeName, this)))
#define LOG_EXIT() \
LOGEX(LOG_COMMAND("programExit", ""));
// *************************************************************************************************
// Logging Events
void IncrementSemaphore(const wchar_t* name);
void WaitOnSemaphore(const wchar_t* name, unsigned long long timeoutMs);
#define LOG_SUBSCRIBE(_NAME) \
DEFAULT_LOG.Subscribe(_NAME);
#define LOG_UNSUBSCRIBE(_NAME) \
DEFAULT_LOG.Unsubscribe(_NAME);
#define LOG_EVENT(_NAME, _MESSAGE) \
::Devon::IncrementSemaphore(_NAME); \
LOG(::Devon::LogEvent(_NAME) << _MESSAGE)
#define LOG_WAIT(_NAME, _TIMEOUTMS) \
::Devon::WaitOnSemaphore(_NAME, _TIMEOUTMS);
// *************************************************************************************************
// Logging Groups
#define START(_MESSAGE) \
LOGEX(LOG_MESSAGE("group", _MESSAGE << LOG_CODE_FILE()) \
<< LOG_COMMAND("beginBlock", ATTR(name, "indent")));
#define AUTOSTART(_MESSAGE) \
START(_MESSAGE); \
::Devon::AutoStart __autostart__;
#define FINISH() \
LOGEX(LOG_COMMAND("endBlock", ""))
class AutoStart
{
public:
AutoStart() {}
~AutoStart() { FINISH(); }
};
// *************************************************************************************************
// Logging Tables
#define LOG_BEGIN_TABLE(_NAME) \
LOGEX(LOG_COMMAND("beginTable", ATTR(name, _NAME)))
#define LOG_END_TABLE() \
LOGEX(LOG_COMMAND("endTable", ""))
#define LOG_BEGIN_ROW(_ROWTYPE) \
LOGEX(LOG_COMMAND("beginRow", ATTR(rowType, _ROWTYPE)))
#define LOG_END_ROW() \
LOGEX(LOG_COMMAND("endRow", ""))
#define LOG_CELL(_VALUE) \
LOGEX(LOG_COMMAND("cell", ATTR(value, _VALUE)))
// *************************************************************************************************
// Shorthand for macros used often while under duress
#define dd(_TEXT) LOGEX(_TEXT);
#define ddv(_TEXT) LOG_VARIABLE(_TEXT);
#define ddf(_TEXT, _FORMAT) LOG_VARIABLE_FORMAT(_TEXT, _FORMAT);
#define bbb LOG_REACH();
// *************************************************************************************************
} // namespace Devon
#endif // DEVON_LOGGING_H
| [
"[email protected]"
]
| [
[
[
1,
225
]
]
]
|
9c458145e9733e9404f17d4c7ff5dc62afd80284 | 54cacc105d6bacdcfc37b10d57016bdd67067383 | /trunk/source/level/objects/components/ICmpActivatable.h | 564450f47d12b5b6bd6723f0b219826f3de68c77 | []
| no_license | galek/hesperus | 4eb10e05945c6134901cc677c991b74ce6c8ac1e | dabe7ce1bb65ac5aaad144933d0b395556c1adc4 | refs/heads/master | 2020-12-31T05:40:04.121180 | 2009-12-06T17:38:49 | 2009-12-06T17:38:49 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 961 | h | /***
* hesperus: ICmpActivatable.h
* Copyright Stuart Golodetz, 2009. All rights reserved.
***/
#ifndef H_HESP_ICMPACTIVATABLE
#define H_HESP_ICMPACTIVATABLE
#include <source/level/objects/base/ObjectComponent.h>
namespace hesp {
/**
Objects with an ICmpActivatable component can be activated by other objects.
*/
class ICmpActivatable : public ObjectComponent
{
//#################### PUBLIC ABSTRACT METHODS ####################
public:
virtual void activated_by(const ObjectID& activator) = 0;
//#################### PUBLIC METHODS ####################
public:
void check_dependencies() const;
std::string group_type() const { return "Activatable"; }
static std::string static_group_type() { return "Activatable"; }
};
//#################### TYPEDEFS ####################
typedef shared_ptr<ICmpActivatable> ICmpActivatable_Ptr;
typedef shared_ptr<const ICmpActivatable> ICmpActivatable_CPtr;
}
#endif
| [
"[email protected]"
]
| [
[
[
1,
36
]
]
]
|
9e6f92ebf39f5c6169b593707fab436c2611dfd9 | d906f5ffd6d2c563b52c27ce491e056268be2ce3 | /Parallax Occlusion Mapping Tech Demo/Headers/D3DObject.h | 1091474e36f5064c0ee07a9962f7c62922098770 | []
| no_license | vksoon/directxhlslproject | 5df86d15c62711023f56f63d6098aceaaa9c2528 | 09e33f699cec98880dec71e8c67b8ce327a16f0c | refs/heads/master | 2021-01-10T01:30:41.783049 | 2011-05-16T17:42:39 | 2011-05-16T17:42:39 | 36,427,148 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 913 | h | /*
Direct3D Object Wrapper
Singleton
D3DObj::Instance
Shaun Mitchell
*/
#ifndef D3DOBJECT_H
#define D3DOBJECT_H
#include <windows.h>
#include <windowsx.h>
#include <d3d9.h>
#include <d3dx9.h>
#include <d3dx9tex.h>
#include "Singleton.h"
// include the Direct3D Library file
//#pragma comment (lib, "d3d9.lib")
//#pragma comment (lib, "d3dx9.lib")
#include <AntTweakBar.h>
class D3DObject
{
public:
~D3DObject();
void Init(HWND hWnd);
void Clean();
LPDIRECT3D9 GetDevice() const;
LPDIRECT3DDEVICE9 GetDeviceClass() const;
D3DPRESENT_PARAMETERS GetParameters() const;
HWND GetWindowHandle() const;
private:
LPDIRECT3D9 d3d; // pointer to device
LPDIRECT3DDEVICE9 d3ddev; // pointer to device class
D3DPRESENT_PARAMETERS d3dpp;
D3DObject() {}
friend class Singleton<D3DObject>;
};
typedef Singleton<D3DObject> D3DObj;
#endif | [
"[email protected]"
]
| [
[
[
1,
49
]
]
]
|
e7dce972eaf699d4c80e944ae53e5b2b3890f8ae | c1c3866586c56ec921cd8c9a690e88ac471adfc8 | /Practise_2005/dshow.cmovie/main.cpp | 2eb76617b406f9b4299c6787b4b6dfd113338d30 | []
| no_license | rtmpnewbie/lai3d | 0802dbb5ebe67be2b28d9e8a4d1cc83b4f36b14f | b44c9edfb81fde2b40e180a651793fec7d0e617d | refs/heads/master | 2021-01-10T04:29:07.463289 | 2011-03-22T17:51:24 | 2011-03-22T17:51:24 | 36,842,700 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,569 | cpp |
#include "Movie.h"
//-----------------------------------------------------------------------------
// Global variables
//-----------------------------------------------------------------------------
LPDIRECT3D9 g_pD3D = NULL; // Used to create the D3DDevice
LPDIRECT3DDEVICE9 g_pd3dDevice = NULL; // Our rendering device
CMovie* g_pMovie = NULL;
HWND g_hwnd = NULL;
//-----------------------------------------------------------------------------
// Name: InitD3D()
// Desc: Initializes Direct3D
//-----------------------------------------------------------------------------
HRESULT InitD3D( HWND hWnd )
{
// Create the D3D object, which is needed to create the D3DDevice.
if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
return E_FAIL;
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp, &g_pd3dDevice ) ) )
{
return E_FAIL;
}
// Device state would normally be set here
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: Cleanup()
// Desc: Releases all previously initialized objects
//-----------------------------------------------------------------------------
VOID Cleanup()
{
if( g_pd3dDevice != NULL)
g_pd3dDevice->Release();
if( g_pD3D != NULL)
g_pD3D->Release();
if (g_pMovie != NULL)
{
g_pMovie->CloseMovie();
delete g_pMovie;
g_pMovie = NULL;
}
}
//-----------------------------------------------------------------------------
// Name: Render()
// Desc: Draws the scene
//-----------------------------------------------------------------------------
VOID Render()
{
if(g_pMovie->IsPlaying())
{
RECT rc;
::GetClientRect(g_hwnd, &rc);
g_pMovie->PutMoviePosition(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top);
g_pMovie->RepaintVideo(g_hwnd, ::GetDC(g_hwnd));
}
else
{
if( NULL == g_pd3dDevice )
return;
// Clear the backbuffer to a blue color
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );
// Begin the scene
if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
{
// Rendering of scene objects can happen here
// End the scene
g_pd3dDevice->EndScene();
}
// Present the backbuffer contents to the display
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
}
//-----------------------------------------------------------------------------
// Name: MsgProc()
// Desc: The window's message handler
//-----------------------------------------------------------------------------
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch( msg )
{
case WM_DESTROY:
Cleanup();
PostQuitMessage( 0 );
return 0;
}
return DefWindowProc( hWnd, msg, wParam, lParam );
}
//-----------------------------------------------------------------------------
// Name: WinMain()
// Desc: The application's entry point
//-----------------------------------------------------------------------------
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
{
// Register the window class
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
L"D3D Tutorial", NULL };
RegisterClassEx( &wc );
// Create the application's window
g_hwnd = CreateWindow( L"D3D Tutorial", L"DShow CMovie Test",
WS_OVERLAPPEDWINDOW, 100, 100, 300, 300,
NULL, NULL, wc.hInstance, NULL );
g_pMovie = new CMovie(g_hwnd);
g_pMovie->OpenMovie(L"C:\\Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Samples\\Multimedia\\DirectShow\\Media\\Video\\ruby.avi");
g_pMovie->PlayMovie();
// Initialize Direct3D
if( SUCCEEDED( InitD3D( g_hwnd ) ) )
{
// Show the window
ShowWindow( g_hwnd, SW_SHOWDEFAULT );
UpdateWindow( g_hwnd );
// Enter the message loop
MSG msg;
ZeroMemory(&msg, sizeof(msg));
while(msg.message != WM_QUIT)
{
if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
else
{
Render();
}
}
}
UnregisterClass( L"D3D Tutorial", wc.hInstance );
return 0;
}
| [
"laiyanlin@27d9c402-1b7e-11de-9433-ad2e3fad96c5"
]
| [
[
[
1,
176
]
]
]
|
a5c8c926a0ba6e174af05e36b3c9c23ee5b4be57 | 188058ec6dbe8b1a74bf584ecfa7843be560d2e5 | /GodDK/util/AbstractList.h | 0cbc653a18da8cc57e204b93c44e32375be3b950 | []
| no_license | mason105/red5cpp | 636e82c660942e2b39c4bfebc63175c8539f7df0 | fcf1152cb0a31560af397f24a46b8402e854536e | refs/heads/master | 2021-01-10T07:21:31.412996 | 2007-08-23T06:29:17 | 2007-08-23T06:29:17 | 36,223,621 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,961 | h |
#ifndef _ABSTRACT_CLASS_GOD_UTIL_ABSTRACTLIST_H
#define _ABSTRACT_CLASS_GOD_UTIL_ABSTRACTLIST_H
#ifdef __cplusplus
#include "util/AbstractCollection.h"
#include "util/List.h"
#include "lang/IllegalStateException.h"
#include "util/ConcurrentModificationException.h"
using namespace goddk::util;
namespace goddk {
namespace util {
/*!\ingroup CXX_UTIL_m
* \warning class E must be a subclass of Object
*/
template<class E> class AbstractList : public virtual AbstractCollection<E>, public virtual List<E>
{
private:
class Iter : public virtual Iterator<E>
{
private:
AbstractList* _list;
const AbstractList* _const_list;
jint _pos;
jint _last;
jint _expect;
public:
Iter(AbstractList* list) : _list(list), _const_list(list)
{
_pos = 0;
_last = -1;
_expect = _const_list->modCount;
}
Iter(const AbstractList* list) : _list(0), _const_list(list)
{
_pos = 0;
_last = -1;
_expect = _const_list->modCount;
}
virtual ~Iter() {}
virtual bool hasNext() throw ()
{
return _pos < _const_list->size();
}
virtual E* next() throw (NoSuchElementExceptionPtr)
{
if (_expect != _const_list->modCount)
THROWEXCEPTIONPTR(ConcurrentModificationException)
try
{
E* e = _const_list->get(_pos);
_last = _pos++;
return e;
}
catch (IndexOutOfBoundsException&)
{
if (_expect != _const_list->modCount)
THROWEXCEPTIONPTR(ConcurrentModificationException)
THROWEXCEPTIONPTR(NoSuchElementException)
}
}
virtual void remove()
{
if (!_list)
THROWEXCEPTIONPTR1(UnsupportedOperationException,"Cannot remove items in a const iterator");
if (_last == -1)
THROWEXCEPTIONPTR(IllegalStateException)
if (_expect != _list->modCount)
THROWEXCEPTIONPTR(ConcurrentModificationException)
try
{
E* e = _list->remove(_last);
if (e)
collection_rcheck(e);
if (_last < _pos)
_pos--;
_last = -1;
_expect = _list->modCount;
}
catch (IndexOutOfBoundsException&)
{
THROWEXCEPTIONPTR(ConcurrentModificationException)
}
}
};
class ListIter : public virtual ListIterator<E>
{
private:
AbstractList* _list;
const AbstractList* _const_list;
jint _pos;
jint _last;
jint _expect;
public:
ListIter(AbstractList* list, jint index) throw (IndexOutOfBoundsExceptionPtr) : _list(list), _const_list(list)
{
if (index < 0 || index > list->size())
throw IndexOutOfBoundsException();
_pos = index;
_last = -1;
_expect = _const_list->modCount;
}
ListIter(const AbstractList* list, jint index) throw (IndexOutOfBoundsExceptionPtr) : _list(0), _const_list(list)
{
if (index < 0 || index > list->size())
throw IndexOutOfBoundsException();
_pos = index;
_last = -1;
_expect = _const_list->modCount;
}
virtual ~ListIter() {}
virtual void add(E* e)
{
if (!_list)
THROWEXCEPTIONPTR1(UnsupportedOperationException,"Cannot add items in a const iterator");
if (_expect != _list->modCount)
THROWEXCEPTIONPTR(ConcurrentModificationException)
try
{
_list->add(_pos++, e);
_last = -1;
_expect = _list->modCount;
}
catch (IndexOutOfBoundsException&)
{
THROWEXCEPTIONPTR(ConcurrentModificationException)
}
}
virtual bool hasNext() throw ()
{
return _pos < _const_list->size();
}
virtual bool hasPrevious() throw ()
{
return _pos > 0;
}
virtual E* next() throw (NoSuchElementExceptionPtr)
{
if (_expect != _const_list->modCount)
THROWEXCEPTIONPTR(ConcurrentModificationException)
try
{
E* e = _const_list->get(_pos);
_last = _pos++;
return e;
}
catch (IndexOutOfBoundsException&)
{
if (_expect != _const_list->modCount)
THROWEXCEPTIONPTR(ConcurrentModificationException)
THROWEXCEPTIONPTR(NoSuchElementException)
}
}
virtual jint nextIndex() throw ()
{
return _pos;
}
virtual E* previous() throw (NoSuchElementExceptionPtr)
{
if (_expect != _const_list->modCount)
THROWEXCEPTIONPTR(ConcurrentModificationException)
try
{
E* e = _const_list->get(_pos-1);
_last = _pos--;
return e;
}
catch (IndexOutOfBoundsException&)
{
if (_expect != _const_list->modCount)
THROWEXCEPTIONPTR(ConcurrentModificationException)
THROWEXCEPTIONPTR(NoSuchElementException)
}
}
virtual jint previousIndex() throw ()
{
return _pos-1;
}
virtual void remove()
{
if (!_list)
THROWEXCEPTIONPTR1(UnsupportedOperationException,"Cannot remove items in a const iterator");
if (_last == -1)
THROWEXCEPTIONPTR(IllegalStateException)
if (_expect != _list->modCount)
THROWEXCEPTIONPTR(ConcurrentModificationException)
try
{
E* e = _list->remove(_last);
if (e)
collection_rcheck(e);
if (_last < _pos)
_pos--;
_last = -1;
_expect = _list->modCount;
}
catch (IndexOutOfBoundsException&)
{
THROWEXCEPTIONPTR(ConcurrentModificationException)
}
}
virtual void set(E* e)
{
if (!_list)
THROWEXCEPTIONPTR1(UnsupportedOperationException,"Cannot set items in a const iterator");
if (_last == -1)
THROWEXCEPTIONPTR(IllegalStateException)
if (_expect != _list->modCount)
THROWEXCEPTIONPTR(ConcurrentModificationException)
try
{
_list->set(_last, e);
_expect = _list->modCount;
}
catch (IndexOutOfBoundsException&)
{
THROWEXCEPTIONPTR(ConcurrentModificationException)
}
}
};
protected:
jint modCount;
protected:
AbstractList()
{
modCount = 0;
}
public:
virtual ~AbstractList() {}
bool instanceof(const char* class_name)const throw()
{
if(strcmp("AbstractList", class_name)== 0)
return true;
else if(strcmp("List", class_name)== 0)
return true;
else
return __super::instanceof(class_name);
}
virtual bool add(E* e)
{
add(size(), e);
return true;
}
virtual void add(jint index, E* e)
{
THROWEXCEPTIONPTR(UnsupportedOperationException)
}
virtual bool addAll(jint index, const Collection<E>& c)
{
bool result = false;
jint pos = c.size();
Iterator<E>* cit = c.iterator();
assert(cit != 0);
while (--pos >= 0)
{
add(index++, cit->next());
result = true;
}
delete cit;
return result;
}
virtual void clear()
{
while (size())
{
E* e = remove(0);
if (e)
collection_rcheck(e);
}
}
virtual bool equals(const ObjectImpl* obj) const throw ()
{
if (this == obj)
return true;
if (obj)
{
const AbstractList<E>* abs = dynamic_cast<const AbstractList<E>*>(obj);
if (abs)
{
bool result = true;
jint pos1 = size(), pos2 = abs->size();
ListIterator<E>* lit1 = listIterator();
assert(lit1 != 0);
ListIterator<E>* lit2 = abs->listIterator();
assert(lit2 != 0);
while (--pos1 >= 0 && --pos2 >= 0)
{
if (!AbstractCollection<E>::equals(lit1->next(), lit2->next()))
{
result = false;
break;
}
}
if (result)
{
// if either of the iterators has any elements left, the lists differ
result = (pos1 < 0) && (pos2 < 0);
}
delete lit1;
delete lit2;
return result;
}
}
return false;
}
virtual E* get(jint index) const throw (IndexOutOfBoundsExceptionPtr) = 0;
virtual jint hashCode() const throw ()
{
register jint pos = size(), result = 1;
Iterator<E>* it = iterator();
assert(it != 0);
while (--pos >= 0)
{
E* e = it->next();
result *= 31;
if (e)
result += e->hashCode();
}
delete it;
return result;
}
virtual jint indexOf(const E* e) const
{
jint pos = size(), result = -1;
ListIterator<E>* lit = listIterator();
assert(lit != 0);
while (--pos >= 0)
{
if (AbstractCollection<E>::equals(e, lit->next()))
{
result = lit->previousIndex();
break;
}
}
delete lit;
return result;
}
virtual Iterator<E>* iterator()
{
return new Iter(this);
}
virtual Iterator<E>* iterator() const
{
return new Iter(this);
}
virtual jint lastIndexOf(const E* e) const
{
jint result = -1;
ListIterator<E>* lit = listIterator(size());
assert(lit != 0);
while (lit->hasPrevious())
{
if (AbstractCollection<E>::equals(e, lit->previous()))
{
result = lit->nextIndex();
break;
}
}
delete lit;
return result;
}
virtual ListIterator<E>* listIterator(jint index = 0) throw (IndexOutOfBoundsExceptionPtr)
{
return new ListIter(this, index);
}
virtual ListIterator<E>* listIterator(jint index = 0) const throw (IndexOutOfBoundsExceptionPtr)
{
return new ListIter(this, index);
}
virtual E* remove(jint index)
{
THROWEXCEPTIONPTR(UnsupportedOperationException)
}
virtual E* set(jint index, E* e)
{
THROWEXCEPTIONPTR(UnsupportedOperationException)
}
virtual jint size() const throw () = 0;
};
}
}
#endif
#endif
| [
"soaris@46205fef-a337-0410-8429-7db05d171fc8"
]
| [
[
[
1,
422
]
]
]
|
e9a93da1b245eee043361bc3edfe3b534878864a | b22c254d7670522ec2caa61c998f8741b1da9388 | /common/HurtArea.cpp | c44ed7fc4562f0b9fa6e11de56b3079b92b8d175 | []
| 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 | 5,285 | cpp | /*
------------------------[ Lbanet Source ]-------------------------
Copyright (C) 2009
Author: Vivien Delage [Rincevent_123]
Email : [email protected]
-------------------------------[ GNU License ]-------------------------------
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 3 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, see <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------------
*/
#include "HurtArea.h"
#ifndef _LBANET_SERVER_SIDE_
#include "ThreadSafeWorkpile.h"
#include "GameEvents.h"
#include <windows.h> // Header File For Windows
#include <GL/gl.h> // Header File For The OpenGL32 Library
#include "MainPlayerHandler.h"
#endif
/***********************************************************
Constructor
***********************************************************/
HurtArea::HurtArea(float zoneSizeX, float zoneSizeY, float zoneSizeZ, int LifeTaken)
: _zoneSizeX(zoneSizeX), _zoneSizeY(zoneSizeY), _zoneSizeZ(zoneSizeZ),
_LifeTaken(LifeTaken), _activated(false), _timer(false)
{
}
/***********************************************************
Destructor
***********************************************************/
HurtArea::~HurtArea()
{
}
/***********************************************************
check zone activation
***********************************************************/
int HurtArea::ActivateZone(float PlayerPosX, float PlayerPosY, float PlayerPosZ, float PlayerRotation,
MainPlayerHandler * _mph, bool DirectActivation)
{
#ifndef _LBANET_SERVER_SIDE_
if(_mph->IsJumping())
return 0;
float posX = _posX;
float posY = _posY;
float posZ = _posZ;
if( (PlayerPosX >= (posX-_zoneSizeX-_mph->GetSizeX()) && PlayerPosX < (posX+_zoneSizeX+_mph->GetSizeX())) &&
(PlayerPosY >= (posY) && (PlayerPosY-0.001f) <= (posY+_zoneSizeY)) &&
(PlayerPosZ >= (posZ-_zoneSizeZ-_mph->GetSizeZ()) && PlayerPosZ < (posZ+_zoneSizeZ+_mph->GetSizeZ())))
{
if(!_activated)
{
ThreadSafeWorkpile::getInstance()->AddPlayerHurt(_ID);
ThreadSafeWorkpile::getInstance()->AddEvent(new PlayerHurtEvent(_ID));
_activated = true;
return 1;
}
}
else
{
_activated = false;
}
#endif
return 0;
}
/***********************************************************
render editor part
***********************************************************/
void HurtArea::RenderEditor()
{
#ifndef _LBANET_SERVER_SIDE_
glEnable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
glLineWidth(2.0f);
glPushMatrix();
glTranslated(_posX, _posY/2. + 0.5, _posZ);
glColor4f(0.9f,0.2f,1.0f, 1.f);
glBegin(GL_LINES);
glVertex3f(-_zoneSizeX,0,-_zoneSizeZ);
glVertex3f(_zoneSizeX,0,-_zoneSizeZ);
glVertex3f(_zoneSizeX,0,-_zoneSizeZ);
glVertex3f(_zoneSizeX,0,_zoneSizeZ);
glVertex3f(_zoneSizeX,0,_zoneSizeZ);
glVertex3f(-_zoneSizeX,0,_zoneSizeZ);
glVertex3f(-_zoneSizeX,0,_zoneSizeZ);
glVertex3f(-_zoneSizeX,0,-_zoneSizeZ);
glVertex3f(-_zoneSizeX,(_zoneSizeY)/2,-_zoneSizeZ);
glVertex3f(_zoneSizeX,(_zoneSizeY)/2,-_zoneSizeZ);
glVertex3f(_zoneSizeX,(_zoneSizeY)/2,-_zoneSizeZ);
glVertex3f(_zoneSizeX,(_zoneSizeY)/2,_zoneSizeZ);
glVertex3f(_zoneSizeX,(_zoneSizeY)/2,_zoneSizeZ);
glVertex3f(-_zoneSizeX,(_zoneSizeY)/2,_zoneSizeZ);
glVertex3f(-_zoneSizeX,(_zoneSizeY)/2,_zoneSizeZ);
glVertex3f(-_zoneSizeX,(_zoneSizeY)/2,-_zoneSizeZ);
glVertex3f(-_zoneSizeX,0,-_zoneSizeZ);
glVertex3f(-_zoneSizeX,(_zoneSizeY)/2,-_zoneSizeZ);
glVertex3f(_zoneSizeX,0,-_zoneSizeZ);
glVertex3f(_zoneSizeX,(_zoneSizeY)/2,-_zoneSizeZ);
glVertex3f(_zoneSizeX,0,_zoneSizeZ);
glVertex3f(_zoneSizeX,(_zoneSizeY)/2,_zoneSizeZ);
glVertex3f(-_zoneSizeX,0,_zoneSizeZ);
glVertex3f(-_zoneSizeX,(_zoneSizeY)/2,_zoneSizeZ);
glEnd();
glPopMatrix();
glEnable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
Actor::RenderEditor();
#endif
}
/***********************************************************
called on signal
***********************************************************/
bool HurtArea::OnSignal(long SignalNumber)
{
if(SignalNumber == 3)
{
_timer = true;
_cumutime = 0;
return true;
}
return false;
}
/***********************************************************
do all check to be done when idle
***********************************************************/
int HurtArea::Process(double tnow, float tdiff)
{
#ifndef _LBANET_SERVER_SIDE_
if(_timer)
{
_cumutime += tdiff;
if(_cumutime > 400)
{
_timer = false;
_activated = false;
ThreadSafeWorkpile::getInstance()->AddEvent(new DoFullCheckEvent());
}
}
#endif
return Actor::Process(tnow, tdiff);
}
| [
"vdelage@3806491c-8dad-11de-9a8c-6d5b7d1e4d13"
]
| [
[
[
1,
187
]
]
]
|
3880009f38735ea62d90015ffaf15c1c6882c8a3 | c95a83e1a741b8c0eb810dd018d91060e5872dd8 | /Game/Shared/DamageTypes.h | 8d772c0ed0825414ab775f765304e4d18d003591 | []
| no_license | rickyharis39/nolf2 | ba0b56e2abb076e60d97fc7a2a8ee7be4394266c | 0da0603dc961e73ac734ff365bfbfb8abb9b9b04 | refs/heads/master | 2021-01-01T17:21:00.678517 | 2011-07-23T12:11:19 | 2011-07-23T12:11:19 | 38,495,312 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,164 | h | // ----------------------------------------------------------------------- //
//
// MODULE : DamageTypes.h
//
// PURPOSE : Definition of damage types
//
// CREATED : 11/26/97
//
// (c) 1997-2000 Monolith Productions, Inc. All Rights Reserved
//
// ----------------------------------------------------------------------- //
#ifndef __DAMAGE_TYPES_H__
#define __DAMAGE_TYPES_H__
#include "ltbasedefs.h"
#include "GameButeMgr.h"
#include <bitset>
#define DTMGR_DEFAULT_FILE "Attributes\\DamageTypes.txt"
typedef uint64 DamageFlags;
struct DTINFO;
extern DTINFO DTInfoArray[];
// IMPORTANT NOTE: If you add a new DamageType, make sure you update
// the DTInfoArray in DamageTypes.cpp!!!
enum DamageType
{
DT_INVALID = -1,
#define INCLUDE_AS_ENUM
#include "DamageTypesEnum.h"
#undef INCLUDE_AS_ENUM
kNumDamageTypes
};
static const char* pDTNames[kNumDamageTypes] =
{
#define INCLUDE_AS_STRING
#include "DamageTypesEnum.h"
#undef INCLUDE_AS_STRING
};
struct DTINFO
{
DTINFO(DamageType type, const char* name, const char* pszAltName)
{
eType = type;
nDamageFlag = 0;
pName = name;
pAltName = pszAltName;
bJarCamera = LTFALSE;
bGadget = LTFALSE;
bAccuracy = LTFALSE;
fSlowMove = 0.0f;
bScoreTag = LTFALSE;
bGrief = LTFALSE;
bHurtAnim = false;
}
DamageType eType;
DamageFlags nDamageFlag;
const char* pName;
// Used for backwards compatibility with unprocessed levels.
const char* pAltName;
LTBOOL bJarCamera;
LTBOOL bGadget;
LTBOOL bAccuracy;
LTFLOAT fSlowMove;
LTBOOL bScoreTag;
LTBOOL bGrief;
bool bHurtAnim;
StringArray saPlayerDamageSounds;
};
class CDTButeMgr : public CGameButeMgr
{
public :
CDTButeMgr();
~CDTButeMgr();
LTBOOL Init(const char* szAttributeFile=DTMGR_DEFAULT_FILE);
void Term();
};
// ----------------------------------------------------------------------- //
//
// ROUTINE: SpecificObjectFilterFn()
//
// PURPOSE: Filter a specific object out of CastRay and/or
// IntersectSegment calls.
//
// ----------------------------------------------------------------------- //
inline bool SpecificObjectFilterFn(HOBJECT hObj, void *pUserData)
{
if (!hObj) return false;
return (hObj != (HOBJECT)pUserData);
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: IsJarCameraType()
//
// PURPOSE: Does this damage type cause the camera to be "jarred"
//
// ----------------------------------------------------------------------- //
LTBOOL IsJarCameraType(DamageType eType);
// ----------------------------------------------------------------------- //
//
// ROUTINE: IsScoreTagType()
//
// PURPOSE: Does this damage type score a tag in deathmatch
//
// ----------------------------------------------------------------------- //
LTBOOL IsScoreTagType(DamageType eType);
// ----------------------------------------------------------------------- //
//
// ROUTINE: IsGriefType()
//
// PURPOSE: Should the player be protected against multiple instances of
// this type in multiplayer.
//
// ----------------------------------------------------------------------- //
LTBOOL IsGriefType(DamageType eType);
// ----------------------------------------------------------------------- //
//
// ROUTINE: IsGadgetType()
//
// PURPOSE: Does this damage type a gadget damage type?
//
// ----------------------------------------------------------------------- //
LTBOOL IsGadgetType(DamageType eType);
// ----------------------------------------------------------------------- //
//
// ROUTINE: IsAccuracyType()
//
// PURPOSE: Does this damage type count towards player accuracy
//
// ----------------------------------------------------------------------- //
LTBOOL IsAccuracyType(DamageType eType);
// ----------------------------------------------------------------------- //
//
// ROUTINE: SlowMovementDuration()
//
// PURPOSE: For how long does this damage type slow movement
//
// ----------------------------------------------------------------------- //
LTFLOAT SlowMovementDuration(DamageType eType);
// ----------------------------------------------------------------------- //
//
// ROUTINE: DamageFlagToType()
//
// PURPOSE: Convert the damage flag to its type equivillent
//
// ----------------------------------------------------------------------- //
DamageType DamageFlagToType(DamageFlags nDamageFlag);
// ----------------------------------------------------------------------- //
//
// ROUTINE: DamageTypeToFlag()
//
// PURPOSE: Convert the damage type to its flag equivillent
//
// ----------------------------------------------------------------------- //
DamageFlags DamageTypeToFlag(DamageType eType);
// ----------------------------------------------------------------------- //
//
// ROUTINE: DamageTypeToString()
//
// PURPOSE: Convert the damage type to its string equivillent
//
// ----------------------------------------------------------------------- //
const char* DamageTypeToString(DamageType eType);
// ----------------------------------------------------------------------- //
//
// ROUTINE: StringToDamageType()
//
// PURPOSE: Convert the string to its damage type equivillent
//
// ----------------------------------------------------------------------- //
DamageType StringToDamageType(const char* pDTName);
// ----------------------------------------------------------------------- //
//
// ROUTINE: GetDTINFO()
//
// PURPOSE: Gets the damagetype structure.
//
// ----------------------------------------------------------------------- //
DTINFO const* GetDTINFO( DamageType eType );
// ----------------------------------------------------------------------- //
//
// ROUTINE: GetDamageFlagsWithHurtAnim
//
// PURPOSE: Get the list of damageflags that have the hurt flag set.
//
// ----------------------------------------------------------------------- //
DamageFlags GetDamageFlagsWithHurtAnim( );
#endif // __DAMAGE_TYPES_H__ | [
"[email protected]"
]
| [
[
[
1,
234
]
]
]
|
2002961765a39fb756d9c8cfe741faf9d371cf22 | 96e96a73920734376fd5c90eb8979509a2da25c0 | /C3DE/PerVertexLightingWallNoFog.h | aafa78fc938ef77a908c33601699b7fe4c529dda | []
| 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 | 811 | h | #ifndef PER_VERTEX_LIGHTING_WALL_NO_FOG_H
#define PER_VERTEX_LIGHTING_WALL_NO_FOG_H
#include "FX.h"
class PerVertexLightingWallNoFog : public FX
{
public:
PerVertexLightingWallNoFog(ID3DXEffect * effect);
~PerVertexLightingWallNoFog();
void SetObjectMaterials(D3DXCOLOR ambientMaterial, D3DXCOLOR diffuseMaterial,
D3DXCOLOR specularMaterial, float specularPower);
void SetObjectTexture(IDirect3DTexture9 *texture);
void SetAlpha(float alpha);
void ResetHandlers();
protected:
D3DXHANDLE m_shaderObjectAmbientMaterial;//gAmbientMtrl
D3DXHANDLE m_shaderObjectDiffuseMaterial;//gDiffuseMtrl
D3DXHANDLE m_shaderObjectSpecularMaterial;//gSpecMtrl
D3DXHANDLE m_shaderSpecularLightPower;//gSpecPower
D3DXHANDLE m_shaderAlpha;//gSpecPower
D3DXHANDLE m_hTex;
};
#endif | [
"caiocsabino@7e2be596-0d54-0410-9f9d-cf4183935158"
]
| [
[
[
1,
27
]
]
]
|
18d2968f58b3607faaf215e14d770d321eaf2a64 | 097c5ec89727bca9c69964fdb0125174bd535387 | /src/objLoader.cpp | 6f133bbdde36a02e3ae7344821f3d94c15bb37fc | []
| 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 | 6,090 | cpp | #include "objLoader.hpp"
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include "toolbox.hpp"
#include <assert.h>
//#define DEBUG
ObjLoader objectLoader;
ObjLoader::ObjLoader()
{
}
ObjLoader::~ObjLoader()
{
}
// Open a .obj, load its contents into 3 arrays:
// 1. Vertices
// 2. Normals
// 3. Indices
// Returns a vector of vectors containing this data
std::vector<std::vector<double> > ObjLoader::readObjectFile(std::string path)
{
int const bufferSize(1024);
char lineBuffer[bufferSize];
std::string line = "";
int lineNumber = 0;
int i = 0;
std::fstream dataReader(path.c_str());
std::string decimalNumberString = "";
std::string integerNumberString = "";
int coordinatesAdded = 0;
double x, y, z = 0.0;
int a, b, c = 0;
std::vector<double> vertexData; // Read vertexes here
std::vector<double> normalData; // Read normals here
std::vector<double> indiceData; // Read indices here
std::vector<std::vector<double> > out; // Return in this container
if (!dataReader)
std::cout << "Error opening model file: " << path.c_str() << std::endl;
while (!dataReader.eof())
{
#ifdef DEBUG
std::cout << "Linebreak" << std::endl;
#endif
dataReader.getline(lineBuffer, bufferSize);
line = lineBuffer;
if (line[0] == 'v' && line[1] == ' ') // Vertex
{
coordinatesAdded = 0;
decimalNumberString = "";
// Start reading from the first number. Skip the leading v and whitespace
for (int i = 2; coordinatesAdded <= 3; i++)
{
if (line[i] == NULL)
break;
// If we are at a new coordinate
if (line[i] == ' ' ||
i == line.size() - 1)
{
// Convert the string into a double
if (coordinatesAdded == 0)
x = atof(decimalNumberString.c_str());
else if (coordinatesAdded == 1)
y = atof(decimalNumberString.c_str());
else if (coordinatesAdded == 2)
z = atof(decimalNumberString.c_str());
coordinatesAdded++;
decimalNumberString = "";
}
// Add the number or decimal dot to the string to be converted
decimalNumberString.append(tbox.charToString(line[i]));
if (coordinatesAdded > 3 && i > 40)
{
std::cout << "Something broke reading a 3D object. Consult your 3D model exporter" << std::endl;
break;
}
}
vertexData.push_back(x);
vertexData.push_back(y);
vertexData.push_back(z);
} else if (line[0] == 'v' && line[1] == 'n') // Vertex normal
{
coordinatesAdded = 0;
decimalNumberString = "";
// Start reading from the first number. Skip the leading v and whitespace
for (int i = 3; coordinatesAdded < 3; i++)
{
if (line[i] == NULL)
break;
// If we are at a new coordinate
if (line[i] == ' ')
{
// Convert the string into a double
if (coordinatesAdded == 0)
x = atof(decimalNumberString.c_str());
else if (coordinatesAdded == 1)
y = atof(decimalNumberString.c_str());
else if (coordinatesAdded == 2)
z = atof(decimalNumberString.c_str());
coordinatesAdded++;
decimalNumberString = "";
}
// Add the number or decimal dot to the string to be converted
decimalNumberString.append(tbox.charToString(line[i]));
if (coordinatesAdded > 3 && i > 40)
{
std::cout << "Something broke reading a 3D object. Consult your 3D model exporter" << std::endl;
break;
}
}
normalData.push_back(x);
normalData.push_back(y);
normalData.push_back(z);
} else if (line[0] == 'f' && line[1] == ' ') // Index
{
/*
The syntax for indices is as follows:
f 14//14474 4483//14474 7448//14474
Where the first value is the vertex index and the following is probably a texture index.
There is one value missing, and thus there are two "/" in sequence
*/
coordinatesAdded = 0;
integerNumberString = "";
bool valueAdded = false;
a = 0;
b = 0;
c = 0;
// Start reading from the first number. Skip the leading v and whitespace
for (int i = 2; coordinatesAdded < 3; i++)
{
if (line[i] == NULL)
break;
// If we are at a new coordinate
if (line[i] == ' ' || (coordinatesAdded == 2 && valueAdded == true) )
{
// Convert the string into an int
if (coordinatesAdded == 0)
{
a = atoi(integerNumberString.c_str());
#ifdef DEBUG
std::cout << "a: " << a << std::endl;
#endif
}
else if (coordinatesAdded == 1)
{
b = atoi(integerNumberString.c_str());
#ifdef DEBUG
std::cout << "b: " << b << std::endl;
#endif
}
else if (coordinatesAdded == 2)
{
c = atoi(integerNumberString.c_str());
#ifdef DEBUG
std::cout << "c: " << c << std::endl;
#endif
}
coordinatesAdded++;
integerNumberString = "";
valueAdded = false;
}
if (line[i] == '/')
{
valueAdded = true;
#ifdef DEBUG
std::cout << "Hit /" << std::endl;
#endif
}
// Add the number or decimal dot to the string to be converted
if (valueAdded == false)
{
#ifdef DEBUG
std::cout << "reading an integer into a string: " << line[i] << std::endl;
#endif
integerNumberString.append(tbox.charToString(line[i]));
}
if (coordinatesAdded > 3 && i > 40)
{
std::cout << "Something broke reading a 3D object. Consult your 3D model exporter" << std::endl;
break;
}
}
assert(a);
assert(b);
assert(c);
#ifdef DEBUG
std::cout << "Pushing indices to vector: " << a << ", " << b << ", " << c << std::endl;
#endif
indiceData.push_back(a);
indiceData.push_back(b);
indiceData.push_back(c);
} else {
// Non-interesting data
}
}
out.push_back(vertexData);
out.push_back(normalData);
out.push_back(indiceData);
dataReader.close();
return out;
}
| [
"[email protected]"
]
| [
[
[
1,
229
]
]
]
|
edee9229305b4d57b9ce96bf4a30bdf7c23c1e9b | 2d212a074917aad8c57ed585e6ce8e2073aa06c6 | /cgworkshop/src/AvgColSegmentator.cpp | 8d04857ba03dfbda77e6a2decc99d95254c670d5 | []
| no_license | morsela/cgworkshop | b31c9ec39419edcedfaed81468c923436528e538 | cdf9ef2a9b2d9c389279fe0e38fb9c8bc1d86d89 | refs/heads/master | 2021-07-29T01:37:24.739450 | 2007-09-09T13:44:54 | 2007-09-09T13:44:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,495 | cpp | #include "AvgColSegmentator.h"
void AvgColSegmentator::AssignColor(int i, int j, CvScalar *color)
{
int segCount = cvmGet(m_SegmentCount, i,j);
if (0 && segCount == 1)
{
for (int n=0; n<m_nScribbles; n++)
{
if (cvmGet(m_Segmentations[n],i,j))
{
RGB2YUV(m_scribbles[n].GetColor(), color);
return;
}
}
}
// Assigned to multiple segmentations
// Average out colors of all assigned scribbles
CvScalar scrYUV;
double val[3];
{
double probCount = 0;
val[0] = 0;
val[1] = 0;
val[2] = 0;
double maxProb = 0;
double minProb = 1000;
double sumProb = 0;
for (int n=0; n<m_nScribbles; n++)
{
double prob = (cvmGet(m_Probabilities[n],i,j));
if (prob < minProb)
minProb = prob;
if (prob > maxProb)
maxProb = prob;
sumProb += prob;
}
for (int n=0; n<m_nScribbles; n++)
{
double prob = maxProb-(cvmGet(m_Probabilities[n],i,j))+minProb;
//double prob = sumProb-(cvmGet(m_Probabilities[n],i,j));
// Give more weight to selected scribbles
if (cvmGet(m_Segmentations[n],i,j))
prob *= 10;
//printf("Prob[%d]=%lf\n", n,prob);
RGB2YUV(m_scribbles[n].GetColor(), &scrYUV);
val[0] += scrYUV.val[0] * prob;
val[1] += scrYUV.val[1] * prob;
val[2] += scrYUV.val[2] * prob;
probCount += prob;
}
val[0] /= probCount;
val[1] /= probCount;
val[2] /= probCount;
color->val[0] = val[0];
color->val[1] = val[1];
color->val[2] = val[2];
}
}
| [
"erancho@60b542fb-872c-0410-bfbb-43802cb78f6e"
]
| [
[
[
1,
75
]
]
]
|
516ed0230bacd466166223b177cf4f361a27307f | 989aa92c9dab9a90373c8f28aa996c7714a758eb | /HydraIRC/GUIHelpers.cpp | 8c7b3be6db645ad42788fa3dd1e90ee76bffe2c6 | []
| no_license | john-peterson/hydrairc | 5139ce002e2537d4bd8fbdcebfec6853168f23bc | f04b7f4abf0de0d2536aef93bd32bea5c4764445 | refs/heads/master | 2021-01-16T20:14:03.793977 | 2010-04-03T02:10:39 | 2010-04-03T02:10:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,743 | cpp | /*
HydraIRC
Copyright (C) 2002-2006 Dominic Clifton aka Hydra
HydraIRC limited-use source license
1) You can:
1.1) Use the source to create improvements and bug-fixes to send to the
author to be incorporated in the main program.
1.2) Use it for review/educational purposes.
2) You can NOT:
2.1) Use the source to create derivative works. (That is, you can't release
your own version of HydraIRC with your changes in it)
2.2) Compile your own version and sell it.
2.3) Distribute unmodified, modified source or compiled versions of HydraIRC
without first obtaining permission from the author. (I want one place
for people to come to get HydraIRC from)
2.4) Use any of the code or other part of HydraIRC in anything other than
HydraIRC.
3) All code submitted to the project:
3.1) Must not be covered by any license that conflicts with this license
(e.g. GPL code)
3.2) Will become the property of HydraIRC's author.
*/
// GUIHelpers.cpp : misc functions for using/populating/managing GUI controls
//
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "HydraIRC.h"
// populate an identity control with the list of identities, select the identity
// passed if set, otherwise select the default identity (if set)
void PopulateIdentityComboCtrl(CComboBox &IdentityCtrl, UserIdentity *pSelectIdentity /* = NULL */)
{
int itemnum;
char *selectname = NULL;
UserIdentity *pIdentity;
UserIdentity *pDefaultIdentity = g_pPrefs->FindIdentityByDescripton(STRINGPREF(PREF_sDefaultIdentity));
if (pDefaultIdentity)
{
itemnum = IdentityCtrl.AddString(pDefaultIdentity->m_Description);
IdentityCtrl.SetItemDataPtr(itemnum,pDefaultIdentity);
selectname = pDefaultIdentity->m_Description; // select this one, unless we're supposed to select something else...
}
for (int i = 0 ; i < g_pPrefs->m_UserIdentitiesList.GetSize() ; i++ )
{
pIdentity = g_pPrefs->m_UserIdentitiesList[i];
// check we've not already added this one.
if (pIdentity != pDefaultIdentity)
{
itemnum = IdentityCtrl.AddString(pIdentity->m_Description);
IdentityCtrl.SetItemDataPtr(itemnum,pIdentity);
// select this one?
if (pSelectIdentity && pSelectIdentity->m_Description && stricmp(pIdentity->m_Description,pSelectIdentity->m_Description) == 0)
selectname = pIdentity->m_Description;
}
}
if (selectname) // this should always be set, as we can't get to the connect dialog without an identity...
IdentityCtrl.SelectString(0,selectname);
else
IdentityCtrl.SetCurSel(0);
}
| [
"hydra@b2473a34-e2c4-0310-847b-bd686bddb4b0"
]
| [
[
[
1,
74
]
]
]
|
638f609ee349383c4ce061df6f9329b97dc1cde4 | fac8de123987842827a68da1b580f1361926ab67 | /src/base/object.cpp | fadea573e815c5bc6508398578cce51e4fda8c1c | []
| no_license | blockspacer/transporter-game | 23496e1651b3c19f6727712a5652f8e49c45c076 | 083ae2ee48fcab2c7d8a68670a71be4d09954428 | refs/heads/master | 2021-05-31T04:06:07.101459 | 2009-02-19T20:59:59 | 2009-02-19T20:59:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 455 | cpp | #include "base/object.h"
#include "base/ObjectFactory.h"
u32 Object::getClassId()
{
return _classId;
}
u32 Object::getId()
{
return _objectId;
}
Object::Object( u32 classId,u32 objectId )
{
_classId = classId;
_objectId = objectId;
}
Object::~Object()
{
}
void Object::destroy()
{
BaseObjectFactory* factory = ObjectFactoryMgr::getFactory(this->_classId);
if(factory)
{
factory->destroy(this->_objectId);
}
} | [
"uraymeiviar@bb790a93-564d-0410-8b31-212e73dc95e4"
]
| [
[
[
1,
32
]
]
]
|
8e5a34a598d62a3edc0950e3876f9cd249451891 | c6f4fe2766815616b37beccf07db82c0da27e6c1 | /SpaceshipShield.h | 435bb74e55fd217b48599202e689ae6641022b51 | []
| no_license | fragoulis/gpm-sem1-spacegame | c600f300046c054f7ab3cbf7193ccaad1503ca09 | 85bdfb5b62e2964588f41d03a295b2431ff9689f | refs/heads/master | 2023-06-09T03:43:53.175249 | 2007-12-13T03:03:30 | 2007-12-13T03:03:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 908 | h | #pragma once
#include "TileObject.h"
using tlib::Vector3f;
class Timer;
class Spaceship;
class SpaceshipShield : public TileObject
{
private:
// Pointer to the spaceship
Spaceship *m_oShip;
// A vector to hold the collision point between the shield a laser
Vector3f m_vCollPoint;
// Animation timers
Timer *m_NoiseTimer, *m_GlowTimer;
public:
/**
* Initializes the shield object
*/
void init( Spaceship *oShip );
/**
* Collision's point setter
*/
void setCollPoint( const Vector3f& vCollPoint );
/**
* Updates the shield's position
*/
void update();
/**
* Renders the shield.
*/
void render() const;
/**
* Spaceship accessor
*/
const Object* getShip() const { return (Object*)m_oShip; }
Object* getShip() { return (Object*)m_oShip; }
}; | [
"john.fragkoulis@201bd241-053d-0410-948a-418211174e54"
]
| [
[
[
1,
46
]
]
]
|
a1493f04c2b7b4345518554e012f01a600e6d969 | 33f59b1ba6b12c2dd3080b24830331c37bba9fe2 | /Graphic/Main/PAFAnimation.cpp | ffde1af2332ff820871016569e45dc943d3012c2 | []
| no_license | daleaddink/flagship3d | 4835c223fe1b6429c12e325770c14679c42ae3c6 | 6cce5b1ff7e7a2d5d0df7aa0594a70d795c7979a | refs/heads/master | 2021-01-15T16:29:12.196094 | 2009-11-01T10:18:11 | 2009-11-01T10:18:11 | 37,734,654 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,278 | cpp | #include "PAFAnimation.h"
#include <Common/LogManager.h>
namespace Flagship
{
PAFAnimation::PAFAnimation()
: PAF_MAGIC( MAKEFOURCC('P', 'A', 'F', '\0') ), PAF_VERSION( 100 )
{
m_iClassType = Base::Resource_Animation;
}
PAFAnimation::~PAFAnimation()
{
}
bool PAFAnimation::Create()
{
// char szFile[256];
// wcstombs( szFile, m_szPathName.c_str(), 256 );
// FILE * pFile = fopen( szFile, "rb" );
char * pData = (char *) m_kFileBuffer.GetPointer();
int magic;
int version;
magic = * ( (int *) pData );
pData += sizeof(int);
version = * ( (int *) pData );
pData += sizeof(int);
// fread( &magic, sizeof(int), 1, pFile );
// fread( &version, sizeof(int), 1, pFile );
if (magic != PAF_MAGIC)
{
return false;
}
bool compress;
if (version == PAF_VERSION)
{
compress = false;
}else if (version == PAF_VERSION+1)
{
compress = true;
}else
{
return false;
}
// Read animation sample rate
m_iSampleFps = * ( (int *) pData );
pData += sizeof(int);
// fread( &m_iSampleFps, sizeof(int), 1, pFile );
// Read animation duration
m_fDuration = * ( (float *) pData );
pData += sizeof(float);
// fread( &m_fDuration, sizeof(float), 1, pFile );
// Read number of animation track
unsigned int numAnimTrack = 0;
numAnimTrack = * ( (unsigned int *) pData );
pData += sizeof(unsigned int);
// fread( &numAnimTrack, sizeof(unsigned int), 1, pFile );
vector< Vector3f > transKey;
m_pAnimTrack.resize(numAnimTrack);
for (size_t i = 0; i < numAnimTrack; ++i)
{
AnimationTrack * pAnimTrack = &( m_pAnimTrack[i] );
// Read bone id
pAnimTrack->m_iBoneID = * ( (int *) pData );
pData += sizeof(int);
// fread( &(pAnimTrack->m_iBoneID), sizeof(int), 1, pFile );
// Read all rotation key frames
int numKeys = 0;
numKeys = * ( (int *) pData );
pData += sizeof(int);
// fread( &numKeys, sizeof(int), 1, pFile );
pAnimTrack->m_iNumRotKey = (numKeys);
pAnimTrack->m_pRotKey = new ROTATION_KEY[ numKeys ];
if (compress)
{
memcpy( pAnimTrack->m_pRotKey, pData, numKeys * sizeof(ROTATION_KEY) );
pData += numKeys * sizeof(ROTATION_KEY);
// fread( pAnimTrack->m_pRotKey, sizeof(ROTATION_KEY), numKeys, pFile );
}else
{
int k;
for (k = 0; k < numKeys; ++k)
{
float fQuad[4];
memcpy( fQuad, pData, 4 * sizeof(float) );
pData += 4 * sizeof(float);
// fread( fQuad, sizeof(float), 4, pFile );
Quaternionf rotKey;
rotKey = Quaternionf( fQuad[3], fQuad[0], fQuad[1], fQuad[2] );
pAnimTrack->m_pRotKey[k].FromQuat( rotKey );
}
}
// Read all position key frames
DWORD dwLength;
dwLength = * ( (DWORD *) pData );
pData += sizeof(DWORD);
// fread( &dwLength, sizeof(DWORD), 1, pFile );
transKey.reserve( dwLength );
transKey.resize( dwLength );
for( DWORD t = 0; t < dwLength; t++ )
{
float fVector[3];
memcpy( fVector, pData, 3 * sizeof(float) );
pData += 3 * sizeof(float);
// fread( fVector, sizeof(float), 3, pFile );
transKey[t] = Vector3f( fVector );
}
if (!compress)
{
size_t k;
for (k = 1; k < transKey.size(); ++k)
{
Vector3f diff = transKey[k] - transKey[k-1];
if ( fabs(diff.X()) > 0.0001f ||
fabs(diff.Y()) > 0.0001f ||
fabs(diff.Z()) > 0.0001f )
{
break;
}
}
if (k == transKey.size())
{
numKeys = 1;
}else
{
numKeys = (int)transKey.size();
}
}else
{
numKeys = (int)transKey.size();
}
if (numKeys == 1)
{
pAnimTrack->m_iNumPosKey = 1;
pAnimTrack->m_pTransKey = NULL;
pAnimTrack->m_vOnePosKey = transKey[0];
}else
{
pAnimTrack->m_iNumPosKey = numKeys;
pAnimTrack->m_pTransKey = new Vector3f[numKeys];
memcpy( pAnimTrack->m_pTransKey, &transKey[0], sizeof(Vector3f) * numKeys);
}
}
// Calculate number frames of this animation
if ( m_pAnimTrack.size() > 0 )
{
m_iNumFrame = m_pAnimTrack[0].m_iNumRotKey;
}else
{
m_iNumFrame = (int)(m_fDuration * m_iSampleFps) + 1;
}
// fclose( pFile );
return true;
}
} | [
"yf.flagship@e79fdf7c-a9d8-11de-b950-3d5b5f4ea0aa"
]
| [
[
[
1,
170
]
]
]
|
76efe10af9ad018723d90314eb0586767f373b87 | 4ac19e8642b3005d702a1112a722811c8b3cc7c6 | /samples/test/eplist.cpp | 5901ede7fa620ce93a79f01d8bf3ca96e010e74a | [
"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 | 959 | cpp | //a_Simple example of manipulating AElementPairList
#define _DEBUG_DUMP_
#include "freeCGI.h"
int main()
{
const char *pccValue = "~ ALPHA-_";
AHTML htmlOut;
AElementPairList eplTag;
//a_Add item to the list (URL encoding is mandatory for HTML)
htmlOut << "plAddItem: URLEncodeTest=\"" << pccValue << "\"" << endl;
eplTag.plAddItem("URLEncodeTest", pccValue);
//a_Encoded item doesn't get affected by URL encoding, it's already alphanumeric
htmlOut << "elAddEncoded: ASCII_Encoded=\"" << pccValue << "\"" << endl;
eplTag.elAddEncoded("ASCII_Encoded", (const BYTE *)pccValue, strlen(pccValue) + 1, AConverto::eat6Bit);
//a_Do the output
htmlOut << eplTag << endl;
//a_Retrieve our encoded data (which can be binary)
int iLength;
htmlOut << "elDecodeAndGetUserData=\"" << (const char *)eplTag.elDecodeAndGetUserData("ASCII_Encoded", iLength, AConverto::eat6Bit) << "\"" << endl;
return 0x1;
| [
"[email protected]"
]
| [
[
[
1,
28
]
]
]
|
c9c8b9b2ef7aa379dca9f58addeb08a7beb8af6e | 7b4c786d4258ce4421b1e7bcca9011d4eeb50083 | /_代码统计专用文件夹/200901/20090126_苦尽甘来皆为甜,两行清泪涌如泉.cpp | 14e33ef2366aa33b17a47044bab4f545b35eb1db | []
| no_license | lzq123218/guoyishi-works | dbfa42a3e2d3bd4a984a5681e4335814657551ef | 4e78c8f2e902589c3f06387374024225f52e5a92 | refs/heads/master | 2021-12-04T11:11:32.639076 | 2011-05-30T14:12:43 | 2011-05-30T14:12:43 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 515 | cpp | //For my friend Kim
#include <iostream>
using namespace std;
int main()
{
char new_year_2009;
int flag=0;
cout << "Do you happy in 2009?(y/n)" << endl;
cin >> new_year_2009;
if(new_year_2009=='y')
flag=1;
switch(flag){
case 1:
cout << "Yes! Happy New Year!" << endl;
break;
case 0:
cout << "Why? man?";
cout << "Do you know:"
<< "苦尽甘来皆为甜,两行清泪涌如泉"
<< endl;
break;
default:
break;
}
cout << "For Kim!" <<endl;
return 0;
} | [
"baicaibang@70501136-4834-11de-8855-c187e5f49513"
]
| [
[
[
1,
31
]
]
]
|
e33549a4273c7594d88f2ff7600e0d12328040b1 | 5ac13fa1746046451f1989b5b8734f40d6445322 | /minimangalore/Nebula2/code/mangalore/loader/characterprofile.cc | 1a1c98c46be7518b277a1b30fee8064e35f48972 | []
| no_license | moltenguy1/minimangalore | 9f2edf7901e7392490cc22486a7cf13c1790008d | 4d849672a6f25d8e441245d374b6bde4b59cbd48 | refs/heads/master | 2020-04-23T08:57:16.492734 | 2009-08-01T09:13:33 | 2009-08-01T09:13:33 | 35,933,330 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,679 | cc | //------------------------------------------------------------------------------
// loader/characterprofile.cc
// (C) 2006 Radon Labs GmbH
//------------------------------------------------------------------------------
#include "loader/characterprofile.h"
#include "loader/server.h"
namespace Loader
{
ImplementRtti(Loader::CharacterProfile, Loader::UserProfile);
ImplementFactory(Loader::CharacterProfile);
//------------------------------------------------------------------------------
/**
*/
CharacterProfile::CharacterProfile()
{
// empty
}
//------------------------------------------------------------------------------
/**
*/
CharacterProfile::~CharacterProfile()
{
if (this->IsOpen())
{
this->Close();
}
}
//------------------------------------------------------------------------------
/**
Open the profile for reading and writing. This will open the embedded
stream object.
*/
bool
CharacterProfile::Open(const nString& characterProfileName)
{
// build filename of character profile file
nString filename = Server::Instance()->GetUserProfile()->GetProfileDirectory();
filename += "/character/";
filename += characterProfileName;
filename += ".xml";
this->stream.SetFilename(filename);
if (this->stream.Open(nStream::ReadWrite))
{
// if new file, write a root node
if (this->stream.FileCreated())
{
this->stream.BeginNode("Profile");
this->stream.EndNode();
}
this->stream.SetToNode("/Profile");
return true;
}
return false;
}
} // namespace Loader
| [
"BawooiT@d1c0eb94-fc07-11dd-a7be-4b3ef3b0700c"
]
| [
[
[
1,
64
]
]
]
|
2e918f107d594638a10f7a8e1a83c459ea2f4f9d | 8fcf3f01e46f8933b356f763c61938ab11061a38 | /Expression/NamedFunction.h | cce3b7ec867e70943095526f39ee2a1a97506723 | []
| no_license | jonesbusy/parser-effex | 9facab7e0ff865d226460a729f6cb1584e8798da | c8c00e7f9cf360c0f70d86d1929ad5b44c5521be | refs/heads/master | 2021-01-01T16:50:16.254785 | 2011-02-26T22:27:05 | 2011-02-26T22:27:05 | 33,957,768 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,430 | h | #ifndef NAMEDFUNCTIONS_H_INCLUDED
#define NAMEDFUNCTIONS_H_INCLUDED
/**
* \file NamedFunction.h
* \author Valentin Delaye
* \version 1.0
* \date 03.03.2010
*
* Permet de representer une function nommee telle que
* sin, cos, abs, etc.
*/
#include <string>
#include <cmath>
#include <iostream>
#include "ExpressionExport.h"
#include "AbstractFunction.h"
/*! \class NamedFunction
*
* Permet de representer une fonction nommee
*/
class DLL_EXPORT NamedFunction : public AbstractFunction
{
private :
/*! Nom de la fonction */
std::string name;
/*! Fonction mathematique associee */
double (*function)(double);
public :
/*!
* Constructeur, creer un fonction nommee
*
* \param name Nom de la fonction
* \param function Fonction mathematique associee
*/
NamedFunction(std::string name, double(*function)(double));
/*!
* Permet d'evaluer la fonction nommee.
*
* \param value Valeur d'evaluation
* \param cases Le case pour les discontinuites
* \return La valeur d'evaluation (y = ...)
*/
double eval(double value, Cases* cases = NULL) const;
/*!
* Operateur (). Permet d'evaluer la fonction nommee.
*
* \param value Valeur d'evaluation
*/
double operator()(double value) const;
};
#endif // NAMEDFUNCTIONS_H_INCLUDED
| [
"jonesbusy@fa255007-c97c-c9ae-ff28-e9f0558300b6"
]
| [
[
[
1,
65
]
]
]
|
60340995ded778ac3bfdf73ee3b59884d3f8a81c | 6da3740464cfcc95b095d769974876eb8faf716d | /raytrace/Lambertian.cpp | 25c814123001153ae8dbc592a4b45c2ca70bf422 | []
| no_license | thorlund/rendering | 8e46b9f11e6c88eb105dfaf9b35ce3c8ca9588f7 | 648633722d7685f4a2c939595e96d79d34cba344 | refs/heads/master | 2021-01-24T06:12:27.825294 | 2011-09-28T09:01:13 | 2011-09-28T09:01:13 | 2,473,863 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,280 | cpp | // 02562 Rendering Framework
// Written by Jeppe Revall Frisvad, 2011
// Copyright (c) DTU Informatics 2011
#include <optix_world.h>
#include "HitInfo.h"
#include "Lambertian.h"
using namespace optix;
// The following macro defines 1/PI
#ifndef M_1_PIf
#define M_1_PIf 0.31830988618379067154
#endif
float3 Lambertian::shade(const Ray& r, HitInfo& hit, bool emit) const
{
float3 rho_d = get_diffuse(hit);
float3 result = make_float3(0.0f);
// Implement Lambertian reflection here.
//
// Input: r (the ray that hit the material)
// hit (info about the ray-surface intersection)
// emit (passed on to Emission::shade)
//
// Return: radiance reflected to where the ray was coming from
//
// Relevant data fields that are available (see Lambertian.h, HitInfo.h, and above):
// lights (vector of pointers to the lights in the scene)
// hit.position (position where the ray hit the material)
// hit.shading_normal (surface normal where the ray hit the material)
// rho_d (difuse reflectance of the material)
//
// Hint: Call the sample function associated with each light in the scene.
return result + Emission::shade(r, hit, emit);
}
| [
"[email protected]"
]
| [
[
[
1,
38
]
]
]
|
da6113b7708f95d1298b02f72c516437f0e649e5 | d2af4bec60dd35fc40f4784f378efcf5acd13522 | /Hooking Engine/PrototypeI_Final/PrototypeI/logger.h | 3aab4f0d927a23165c56d083c00364d68af3ba12 | []
| no_license | sankio/H2Sandboxbackup | 6a07f335ae5e1897ef07bcf564d68850c843d1f6 | bd45cfb47a0c0522c568162641fe7886675a0f39 | refs/heads/master | 2021-01-10T22:06:17.940401 | 2011-06-24T11:57:22 | 2011-06-24T11:57:22 | 1,947,055 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 165 | h | #include<fstream>
using namespace std;
class Log {
public:
Log(char* filename);
~Log();
void Write(char* logline);
private:
ofstream m_stream;
}; | [
"[email protected]"
]
| [
[
[
1,
13
]
]
]
|
3792de1455851241346e3be06b57e3095d1e5b0a | 937c59bea84dfe14cac07ed2e3a706ac765d965e | /Source Files/YESNODlg.cpp | 53bc915260aad34e55616159a5034af941aa9409 | []
| no_license | IDA-RE-things/dvsatucsd | 1b73b21644ffa869a0b5dbd36ac1c0cbfa37bce0 | dff552ac9c29bca8f5b20b46342fbb6887857915 | refs/heads/master | 2016-09-05T16:17:08.013350 | 2010-04-03T22:17:49 | 2010-04-03T22:17:49 | 40,741,625 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,349 | cpp | // YESNODlg.cpp : implementation file
//
#include "stdafx.h"
#include "DVT.h"
#include "YESNODlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// YESNODlg dialog
YESNODlg::YESNODlg(CWnd* pParent /*=NULL*/, CString tmessage, bool *tresult)
: CDialog(YESNODlg::IDD, pParent)
{
message = tmessage;
result = tresult;
*result = FALSE;
//{{AFX_DATA_INIT(YESNODlg)
//}}AFX_DATA_INIT
}
void YESNODlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(YESNODlg)
DDX_Control(pDX, IDC_Message, m_Message);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(YESNODlg, CDialog)
//{{AFX_MSG_MAP(YESNODlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// YESNODlg message handlers
void YESNODlg::OnOK()
{
*result = TRUE;
CDialog::OnOK();
}
void YESNODlg::OnCancel()
{
*result = FALSE;
CDialog::OnCancel();
}
BOOL YESNODlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_Message.SetWindowText(message);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
| [
"rishmish@bd9eb85a-b20e-11dd-9381-bf584fb1fa83"
]
| [
[
[
1,
68
]
]
]
|
e8c8ca8b2c3d839a8f01ad7b82f14b2a5a101034 | 336ec5b80085d8bdd65d5ad2384507e6db6536bd | /plugins/consoles/vt100cons/inc/vtc_controller.h | 8b35cfe46134eff4821892ce7e7447a12138f384 | []
| no_license | springxu0800/oss.FCL.sf.os.fshell | 1c2051076cfd284553a0845cc86e617c1badc188 | 30d5fcf516eed5ae7a5379a6a469c75f93a1345b | refs/heads/master | 2021-06-04T18:53:26.010490 | 2010-12-07T17:29:09 | 2010-12-07T17:29:09 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,433 | h | // vtc_controller.h
//
// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the "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:
// Accenture - Initial contribution
//
#ifndef __VTC_CONTROLLER_H__
#define __VTC_CONTROLLER_H__
#include <e32keys.h>
#include <fshell/settings.h>
#include <fshell/consoleextensions.h>
#include <fshell/abstract_console_writer.h>
#include <fshell/common.mmh>
#include <fshell/descriptorutils.h>
class TCursorTracker;
class TEscapeMapping;
class MConsoleOutput
{
public:
virtual TInt Output(const TDesC8& aDes) = 0;
};
NONSHARABLE_CLASS(CVtConsoleOutputController) : public CBase, public MAbstractConsoleWriter
{
public:
IMPORT_C static CVtConsoleOutputController* NewL(MConsoleOutput& aOutput, LtkUtils::CIniFile& aIniFile, const TSize& aScreenSize);
IMPORT_C static CVtConsoleOutputController* New(MConsoleOutput& aOutput, LtkUtils::CIniFile& aIniFile, const TSize& aScreenSize);
IMPORT_C ~CVtConsoleOutputController();
IMPORT_C TInt ResetAttributes();
IMPORT_C TInt SetAttributes(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor = ConsoleAttributes::EUnchanged, ConsoleAttributes::TColor aBackgroundColor = ConsoleAttributes::EUnchanged);
void SetMode(ConsoleMode::TMode aMode);
public: // From MAbstractConsoleWriter.
virtual TInt GetCursorPos(TPoint& aPos) const;
virtual TInt SetCursorPosAbs(const TPoint& aPos);
virtual TInt SetCursorPosRel(const TPoint& aPos);
virtual TInt SetCursorHeight(TInt aPercentage);
virtual TInt SetTitle(const TDesC& aTitle);
virtual TInt ClearScreen();
virtual TInt ClearToEndOfLine();
virtual TInt GetScreenSize(TSize& aSize) const;
virtual TInt Write(const TDesC& aDes);
virtual TInt Write(const TDesC8& aDes);
private:
CVtConsoleOutputController(MConsoleOutput& aOutput, LtkUtils::CIniFile& aIniFile);
TInt Construct(const TSize& aScreenSize);
private:
MConsoleOutput& iOutput;
LtkUtils::CIniFile& iIniFile;
TCursorTracker* iCursorTracker;
LtkUtils::RLtkBuf8 iOutputBuf;
ConsoleMode::TMode iMode;
};
class TKeyPress
{
public:
IMPORT_C TKeyPress();
IMPORT_C TKeyPress(TKeyCode aCode, TUint aModifiers);
public:
TKeyCode iCode;
TUint iModifiers;
};
class MConsoleInput
{
public:
virtual void Input(TDes8& aDes, TRequestStatus& aStatus) = 0;
virtual void CancelInput(TRequestStatus& aStatus) = 0;
};
NONSHARABLE_CLASS(CVtConsoleInputController) : public CActive
{
public:
IMPORT_C static CVtConsoleInputController* New(MConsoleInput& aConsoleInput, LtkUtils::CIniFile& aIniFile);
IMPORT_C static CVtConsoleInputController* NewL(MConsoleInput& aConsoleInput, LtkUtils::CIniFile& aIniFile);
IMPORT_C static CVtConsoleInputController* NewLC(MConsoleInput& aConsoleInput, LtkUtils::CIniFile& aIniFile);
IMPORT_C void GetKeyPress(TKeyPress& aKeyPress, TRequestStatus& aStatus);
IMPORT_C void CancelGetKeyPress();
IMPORT_C void SetMode(ConsoleMode::TMode aMode);
public:
virtual ~CVtConsoleInputController();
private:
void ConstructL();
CVtConsoleInputController(MConsoleInput& aConsoleInput, LtkUtils::CIniFile& aIniFile);
void DoEscapeKeyL(TUint8 aChar, const TEscapeMapping* iMappings, TInt aMappingCount);
void DoExtendedEscapeKey();
static TInt EscapeTimeoutS(TAny* aSelf);
TInt EscapeTimeout();
void ProcessInputBuffer();
void CompleteReadRequest(TInt aError);
void CompleteReadRequest(TKeyCode aKeyCode);
void CompleteReadRequest(TKeyCode aKeyCode1, TKeyCode aKeyCode2);
void Reset();
void RequestInput();
private: // From CActive.
virtual void RunL();
virtual void DoCancel();
private:
enum TState
{
ENormal,
EWaitingForEscapeChar2,
EWaitingForEscapeChar3,
EWaitingForEscapeChar3Func,
EWaitingForExtendedFunc, // Chars 4 and later
};
private:
MConsoleInput& iConsoleInput;
LtkUtils::CIniFile& iIniFile;
TState iState;
CPeriodic* iEscapeTimer;
ConsoleMode::TMode iMode;
TBuf8<1024> iBuf;
TInt iBufPos;
TKeyPress* iClientKeyPress;
TRequestStatus* iClientRequestStatus;
TBool iKeyCodePending;
TKeyCode iPendingKeyCode;
TInt iInputError;
TBuf8<4> iExtendedEscapeBuf;
};
#endif //__VTC_CONTROLLER_H__
| [
"[email protected]"
]
| [
[
[
1,
133
]
]
]
|
07d4c2378c6f2009a3bbf9a0bb366000bf8a8a61 | bd89d3607e32d7ebb8898f5e2d3445d524010850 | /connectivitylayer/usbphonetlink/usbpnclient_dll/inc/rusbpnclient.h | 95e858d629296e3fd6a599e11163afa2a87d911a | []
| no_license | wannaphong/symbian-incubation-projects.fcl-modemadaptation | 9b9c61ba714ca8a786db01afda8f5a066420c0db | 0e6894da14b3b096cffe0182cedecc9b6dac7b8d | refs/heads/master | 2021-05-30T05:09:10.980036 | 2010-10-19T10:16:20 | 2010-10-19T10:16:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,555 | h | /*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/
#ifndef RUSBPNCLIENT_H
#define RUSBPNCLIENT_H
// INCLUDES
#include <e32std.h>
// CONSTANTS
// MACROS
// DATA TYPES
// FUNCTION PROTOTYPES
// FORWARD DECLARATIONS
// CLASS DECLARATION
/**
* Client API for USB Phonet Link server.
*
* @lib usbpnclient.lib
* @since
*/
class RUsbPnClient : public RSessionBase
{
public: // Constructors and destructor
/**
* C++ default constructor.
*/
IMPORT_C RUsbPnClient();
public: // New functions
/**
* Connect to USB Phonet Link server.
* Server starts if first.
* @since
* @param
* @return
*/
IMPORT_C void ConnectL();
/**
* Sends message to server so it can release interface before class controller Stop() can continue.
* Closes also the handle so rest of the server is destroyed if last reference.
* @since
* @param
* @return
*/
IMPORT_C void Detach();
};
#endif // RUSBPNCLIENT_H
// End of File
| [
"dalarub@localhost"
]
| [
[
[
1,
72
]
]
]
|
6c053ba365592a16a32b54a3893dd4e0f0c8a109 | dadf8e6f3c1adef539a5ad409ce09726886182a7 | /airplay/src/toeEventArgs.cpp | 8b15f07725f1c745b6dc745018431ea58a773799 | []
| 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 | 164 | cpp | #include "toeEventArgs.h"
using namespace TinyOpenEngine;
CtoeEventArgs::CtoeEventArgs()
{
isHandled = false;
}
CtoeEventArgs::~CtoeEventArgs()
{
}
| [
"[email protected]"
]
| [
[
[
1,
12
]
]
]
|
09d0654d4f0a36c7d52f7bb59a3fee9c331363f2 | bd89d3607e32d7ebb8898f5e2d3445d524010850 | /adaptationlayer/tsy/nokiatsy_dll/inc/cmmphonetreceiver.h | c5171fcd11790d021ef1dd46c5617fa1529182d1 | []
| no_license | wannaphong/symbian-incubation-projects.fcl-modemadaptation | 9b9c61ba714ca8a786db01afda8f5a066420c0db | 0e6894da14b3b096cffe0182cedecc9b6dac7b8d | refs/heads/master | 2021-05-30T05:09:10.980036 | 2010-10-19T10:16:20 | 2010-10-19T10:16:20 | null | 0 | 0 | null | null | null | null | MacCentralEurope | C++ | false | false | 4,953 | h | /*
* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/
#ifndef CMMPHONETRECEIVER_H
#define CMMPHONETRECEIVER_H
// INCLUDES
#include <e32base.h>
#include <iscapi.h>
// CONSTANTS
// Default size for receive buffer
const TUint KDefaultReceiveBufferSize = 16384; // 16k
// MACROS
// None
// DATA TYPES
// None
// FUNCTION PROTOTYPES
// None
// FORWARD DECLARATIONS
class RIscApi;
class TIsiReceiveC;
// CLASS DECLARATION
/**
* Message receiver interface
*/
class MMmMessageReceiver
{
public:
/**
* Virtual ReceiveMessageL method. Implemented in message handlers.
* @param const TIsiReceiveC &aIsiMessage: The received ISI message
*/
virtual void ReceiveMessageL( const TIsiReceiveC& /*aIsiMessage*/ )
{
// no code
}
/**
* Virtual HandleError method. Implemented in message handlers.
* @param const TIsiReceiveC &aIsiMessage: The received ISI message
* @param TInt aError: Error code
*/
virtual void HandleError( const TIsiReceiveC& /*aIsiMessage*/,
TInt /*aError*/ )
{
// no code
}
};
/**
* CMmPhoNetReceiver is used for receiving ISI messages from PhoNet.
*/
class CMmPhoNetReceiver : public CActive
{
public: // Constructors and destructor
/**
* Two-phased constructor.
* @param RIsaApi* aPn: pointer to the Phonet
* @return CMmPhoNetReceiver*: created object
*/
static CMmPhoNetReceiver* NewL( RIscApi* aPn );
/**
* Destructor.
*/
~CMmPhoNetReceiver();
public: // New functions
struct TMessageReceiverInfo
{
TInt iResource;
TInt iMessageId;
MMmMessageReceiver* iReceiver;
};
/**
* Registers message handler to CMmPhoNetReceiver
*/
void RegisterL( MMmMessageReceiver* aReceiver,
TInt aResource,
TInt aMessageId = -1 );
/**
* When RunL leaves, RunError is called.
* @param TInt aError: Error from RunL
* @return TInt: KErrNone
*/
TInt RunError( TInt aError );
/**
* Handles an active objectís request completion event.
*/
void RunL();
/**
* Receive message from PDA phonet
*/
void ReceiveL( TInt aBufferSize = KDefaultReceiveBufferSize );
/**
* Implements cancellation of an outstanding request.
*/
void DoCancel();
/**
* Sets SAT MessageHandler.
* @param MMmMessageReceiver*: pointer to SAT message handler
* @return TInt: success/failure indication
*/
virtual TInt SetSatMessHandler( MMmMessageReceiver* aSatMessHandler );
/**
* Gets SAT MessageHandler.
* @return MMmMessageReceiver*: pointer to SAT message handler
*/
virtual MMmMessageReceiver* SatMessHandler();
/**
* Sat ready indication
* @param TUint8: Message to be retrieved.
* @return TInt: success/failure if msg was found
*/
virtual TInt SatReady( TUint8 aMsg );
private:
/**
* By default EPOC constructor is private.
*/
CMmPhoNetReceiver();
/**
* Class attributes are created in ConstructL
*/
void ConstructL();
/**
* Routes received ISI message to the correct message handler
*/
void DispatchL( const TIsiReceiveC& aIsiMessage );
// Data
public:
// None
private:
// A pointer to the iscapi object
RIscApi* iPhoNet;
RArray<TMessageReceiverInfo> iMsgReceivers;
// A pointer to the called MessageReceiver object
MMmMessageReceiver* iMessageReceiver;
// a pointer to isimessage buffer
HBufC8* iMessageBuffer;
// Modifiable descriptor to isimessage buffer
TPtr8 iMessageBufferPtr;
// Needed buffer size for overly large phonet message
TUint16 iNeededBufferLength;
// A pointer to the sat message handler
MMmMessageReceiver* iSatMessHandler;
// A pointer to the stored isimessage for sat
HBufC8* iSatMessageBuffer;
};
#endif // CMMPHONETRECEIVER_H
// End of file
| [
"dalarub@localhost",
"mikaruus@localhost"
]
| [
[
[
1,
1
],
[
3,
137
],
[
145,
145
],
[
148,
200
]
],
[
[
2,
2
],
[
138,
144
],
[
146,
147
]
]
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.