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
faa99f1c00f68d5bc67e033f7d8706dea2f49340
7b4c786d4258ce4421b1e7bcca9011d4eeb50083
/_统计专用/C++Primer中文版(第4版)/第一次-代码集合-20090414/第十五章 面向对象编程/20090222_习题15.3_定义自己的Item_base类版本.cpp
b87700ab9827d2aad6a99ccfca9ee31634a68fdb
[]
no_license
lzq123218/guoyishi-works
dbfa42a3e2d3bd4a984a5681e4335814657551ef
4e78c8f2e902589c3f06387374024225f52e5a92
refs/heads/master
2021-12-04T11:11:32.639076
2011-05-30T14:12:43
2011-05-30T14:12:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
350
cpp
class Item_base { public: Item_base(const std::string &book = "", double sales_price = 0.0): isbn(book), price(sales_price) {} std::string book() const { return isbn; } virtual double net_price(size_t n) const { return n * price; } virtual ~Item_base() {} private: std::string isbn; protected: double price; };
[ "baicaibang@70501136-4834-11de-8855-c187e5f49513" ]
[ [ [ 1, 20 ] ] ]
96793ec3769f7c60c645e74b715895a28e197889
91ac219c4cde8c08a6b23ac3d207c1b21124b627
/sound/Sound.h
e524aee541eb886e28bf6a4b59eb84d55c31b369
[]
no_license
DazDSP/hamdrm-dll
e41b78d5f5efb34f44eb3f0c366d7c1368acdbac
287da5949fd927e1d3993706204fe4392c35b351
refs/heads/master
2023-04-03T16:21:12.206998
2008-01-05T19:48:59
2008-01-05T19:48:59
354,168,520
0
0
null
null
null
null
UTF-8
C++
false
false
4,009
h
/******************************************************************************\ * Technische Universitaet Darmstadt, Institut fuer Nachrichtentechnik * Copyright (c) 2001 * * Author(s): * Volker Fischer * * Description: * See Sound.cpp * ****************************************************************************** * * 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 * \******************************************************************************/ #if !defined(AFX_SOUNDIN_H__9518A621_7F78_11D3_8C0D_EEBF182CF549__INCLUDED_) #define AFX_SOUNDIN_H__9518A621_7F78_11D3_8C0D_EEBF182CF549__INCLUDED_ #include <windows.h> #include <mmsystem.h> #include "../common/GlobalDefinitions.h" #include "../common/Vector.h" /* Definitions ****************************************************************/ #define NUM_IN_OUT_CHANNELS 1 /* Stereo recording (but we only use one channel for recording) */ #define BITS_PER_SAMPLE 16 /* Use all bits of the D/A-converter */ #define BYTES_PER_SAMPLE 2 /* Number of bytes per sample */ /* Set this number as high as we have to prebuffer symbols for one MSC block. In case of robustness mode D we have 24 symbols */ #define NUM_SOUND_BUFFERS_IN 20 /* Number of sound card buffers */ #define NUM_SOUND_BUFFERS_OUT 4 /* Number of sound card buffers */ /* Maximum number of recognized sound cards installed in the system */ #define MAX_NUMBER_SOUND_CARDS 10 /* Classes ********************************************************************/ class CSound { public: CSound(); virtual ~CSound(); void InitRecording(int iNewBufferSize, _BOOLEAN bNewBlocking = TRUE); void InitPlayback(int iNewBufferSize, _BOOLEAN bNewBlocking = FALSE); _BOOLEAN Read(CVector<short>& psData); _BOOLEAN Write(CVector<short>& psData); _BOOLEAN IsEmpty(void); int GetNumDevIn() {return iNumDevsIn;}; string GetDeviceNameIn(int iDiD) {return pstrDevicesIn[iDiD];}; int GetNumDevOut() {return iNumDevsOut;}; string GetDeviceNameOut(int iDiD) {return pstrDevicesOut[iDiD];}; void SetInDev(int iNewDev); void SetOutDev(int iNewDev); void Close(); protected: void OpenInDevice(); void OpenOutDevice(); void PrepareInBuffer(int iBufNum); void PrepareOutBuffer(int iBufNum); void AddInBuffer(); void AddOutBuffer(int iBufNum); void GetDoneBuffer(int& iCntPrepBuf, int& iIndexDoneBuf); WAVEFORMATEX sWaveFormatEx; UINT iNumDevsIn; UINT iNumDevsOut; string pstrDevicesIn[MAX_NUMBER_SOUND_CARDS]; string pstrDevicesOut[MAX_NUMBER_SOUND_CARDS]; UINT iCurInDev; UINT iCurOutDev; BOOLEAN bChangDevIn; BOOLEAN bChangDevOut; /* Wave in */ WAVEINCAPS m_WaveInDevCaps; HWAVEIN m_WaveIn; HANDLE m_WaveInEvent; WAVEHDR m_WaveInHeader[NUM_SOUND_BUFFERS_IN]; int iBufferSizeIn; int iWhichBufferIn; short* psSoundcardBuffer[NUM_SOUND_BUFFERS_IN]; _BOOLEAN bBlockingRec; /* Wave out */ WAVEOUTCAPS m_WaveOutDevCaps; int iBufferSizeOut; HWAVEOUT m_WaveOut; short* psPlaybackBuffer[NUM_SOUND_BUFFERS_OUT]; WAVEHDR m_WaveOutHeader[NUM_SOUND_BUFFERS_OUT]; HANDLE m_WaveOutEvent; _BOOLEAN bBlockingPlay; }; #endif // !defined(AFX_SOUNDIN_H__9518A621_7F78_11D3_8C0D_EEBF182CF549__INCLUDED_)
[ [ [ 1, 117 ] ] ]
20c33f4c7a2190160282782c42688828770fdb44
5399d919f33bca564bd309c448f1151e7fb6aa27
/server/utils/Atomic.hpp
7048d26db90c916e6b2e6ba4e72265f3b60a1d03
[]
no_license
hotgloupi/zhttpd
bcbc37283ebf0fb401417fa1799f7f7bb286f0d5
0437ac2e34dde89abab26665df9cbee1777f1d44
refs/heads/master
2021-01-25T05:57:49.958146
2011-01-03T14:22:05
2011-01-03T14:22:05
963,056
4
0
null
null
null
null
UTF-8
C++
false
false
257
hpp
#ifndef __ATOMIC_HPP__ # define __ATOMIC_HPP__ #ifdef _WIN32 # include "AtomicWindows.hpp" #else # include "AtomicUnix.hpp" #endif // !_WIN32 namespace zhttpd { typedef implementation::Atomic Atomic; } #endif // !__ATOMIC_HPP__
[ [ [ 1, 16 ] ] ]
6cfc4c1e68d26f88fe2d4a0611d8daffa1fdd2ac
d9a78f212155bb978f5ac27d30eb0489bca87c3f
/PB/src/PbLib/pblobby.h
ba4585d7b0f00a2ba47221f089384219ae655f33
[]
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
412
h
#pragma once #include "pbtables.h" #include "pbtourney.h" class PBTables; class RpcChannel; class PBLobby : public QObject { Q_OBJECT; public: PBLobby(QObject *parent=0); PBTables *tables(){ return _tables; } PBTourneys *tourneys(){ return _tourneys; } signals: void pong(); public slots: void ping(); protected: QPointer<PBTables> _tables; QPointer<PBTourneys> _tourneys; };
[ "[email protected]", "mikhail.mitkevich@a5377438-2eb2-11df-b28a-19025b8c0740" ]
[ [ [ 1, 2 ], [ 5, 5 ], [ 8, 9 ], [ 11, 11 ], [ 17, 17 ], [ 20, 21 ] ], [ [ 3, 4 ], [ 6, 7 ], [ 10, 10 ], [ 12, 16 ], [ 18, 19 ], [ 22, 24 ] ] ]
0ebd8c121427d6197ea12543de98eed83d9753fd
01fa6f43ad536f4c9656be0f2c7da69c6fc9dc1c
/srcsel.h
4e2ee2c0fdf0f180d72fd908544a9ce660657726
[]
no_license
akavel/wed-editor
76a22b7ff1bb4b109cfe5f3cc630e18ebb91cd51
6a10c167e46bfcb65adb514a1278634dfcb384c1
refs/heads/master
2021-01-19T19:33:18.124144
2010-04-16T20:32:17
2010-04-16T20:32:17
10,511,499
1
0
null
null
null
null
UTF-8
C++
false
false
2,204
h
#if !defined(AFX_SrcSel_H__67B2EFC3_E9B8_11D2_B398_525400D994D7__INCLUDED_) #define AFX_SrcSel_H__67B2EFC3_E9B8_11D2_B398_525400D994D7__INCLUDED_ #if _MSC_VER >= 1000 #pragma once #endif // _MSC_VER >= 1000 // SrcSel.h : header file // #include "SelList.h" ///////////////////////////////////////////////////////////////////////////// // SrcSel dialog class SrcSel : public CDialog { protected: CToolBar m_wndToolBar; CToolBarCtrl m_ToolBarCtrl; // Construction public: SelList slb; int m_busy; int m_rep; int m_shown; int m_err; void GotoSel(); int connect; CWordArray linea; CWordArray lineb; CWordArray cola; void DoChange(int line, int undog); // standard constructor SrcSel(CWnd* pParent = AfxGetMainWnd()); // standard destructor virtual ~SrcSel(); // Dialog Data //{{AFX_DATA(SrcSel) enum { IDD = IDD_DIALOG4 }; CString m_list; CString m_src; //}}AFX_DATA // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(SrcSel) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); //}}AFX_VIRTUAL // Implementation protected: // Generated message map functions //{{AFX_MSG(SrcSel) afx_msg void OnDblclkList1(); afx_msg void OnSelchangeList1(); afx_msg void OnSize(UINT nType, int cx, int cy); virtual BOOL OnInitDialog(); afx_msg void OnButton1(); afx_msg void OnButton2(); afx_msg void OnButton3(); afx_msg void OnButton4(); virtual void OnOK(); afx_msg void OnButton10(); afx_msg void OnButton9(); afx_msg void OnShowWindow(BOOL bShow, UINT nStatus); afx_msg void OnClose(); afx_msg int OnCharToItem(UINT nChar, CListBox* pListBox, UINT nIndex); afx_msg void OnButton5(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. #endif // !defined(AFX_SrcSel_H__67B2EFC3_E9B8_11D2_B398_525400D994D7__INCLUDED_)
[ "none@none" ]
[ [ [ 1, 86 ] ] ]
5f345aeccd8bdadcf48566badceda6e8e6b14f9d
e618b452106f251f3ac7cf929da9c79256c3aace
/src/lib/cpp/API/Win32/Handle.h
772b6141b6bd26f5c5ed86fcf6d5403e20381cef
[]
no_license
dlinsin/yfrog
714957669da86deff3a093a7714e7d800c9260d8
513e0d64a0ff749e902e797524ad4a521ead37f8
refs/heads/master
2020-12-25T15:40:54.751312
2010-04-13T16:31:15
2010-04-13T16:31:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,295
h
// Handle.h: Handle class. ////////////////////////////////////////////////////////////////////// #pragma once namespace API { namespace Win32 { ////////////////////////////////////////////////////////////////////// // THandle ////////////////////////////////////////////////////////////////////// template<class THANDLE = HANDLE> class THandle { protected: THANDLE handle; public: THandle() : handle(NULL) {} virtual ~THandle() { } public: virtual void Close() = 0; public: void Attach(THANDLE h) { if (handle == h) return; if (IsValid()) Close(); handle = h; } THANDLE Detach() { THANDLE h = handle; handle = NULL; return h; } THANDLE GetSafeHandle( ) const { return this == NULL ? NULL : handle; } virtual BOOL IsValid() const { return IsValid(handle); } THANDLE* operator & () { return &handle; } // operators operator THANDLE () const { return handle; } BOOL operator ! () const { return !IsValid(); } public: static BOOL IsValid(THANDLE handle) { return handle && handle != INVALID_HANDLE_VALUE; } // TODO: Implement DuplicateHandle protected: THandle(const THandle &); THandle &operator = (const THandle &); }; ////////////////////////////////////////////////////////////////////// // Handle ////////////////////////////////////////////////////////////////////// class Handle : public THandle<HANDLE> { public: Handle() { } virtual ~Handle() { Close(); } virtual void Close() { if (IsValid()) ::CloseHandle(handle), handle = NULL; } public: // static members static void Close(HANDLE handle) { if (IsValid(handle)) ::CloseHandle(handle); } }; ////////////////////////////////////////////////////////////////////// // WaitableHandle ////////////////////////////////////////////////////////////////////// class WaitableHandle : public Handle { public: WaitableHandle() {} // Implements Waitable DWORD Wait(DWORD dwMilliseconds = INFINITE) const { ATLASSERT(IsValid()); return ::WaitForSingleObject( handle, dwMilliseconds ); } }; ////////////////////////////////////////////////////////////////////// }; //namespace Win32 }; //namespace API
[ [ [ 1, 131 ] ] ]
d1b088361cdd01672f14bb8263c05034de303475
0f8559dad8e89d112362f9770a4551149d4e738f
/Wall_Destruction/Havok/Source/ContentTools/Common/Filters/Common/Filter/hctFilterDescriptor.h
29a37f68baa8420472a4f69af725f0e1c462ed35
[]
no_license
TheProjecter/olafurabertaymsc
9360ad4c988d921e55b8cef9b8dcf1959e92d814
456d4d87699342c5459534a7992f04669e75d2e1
refs/heads/master
2021-01-10T15:15:49.289873
2010-09-20T12:58:48
2010-09-20T12:58:48
45,933,002
0
0
null
null
null
null
UTF-8
C++
false
false
5,399
h
/* * * Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's * prior written consent. This software contains code, techniques and know-how which is confidential and proprietary to Havok. * Level 2 and Level 3 source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2009 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement. * */ #ifndef HAVOK_FILTER_DESCRIPTOR_H #define HAVOK_FILTER_DESCRIPTOR_H #define HCT_FILTER_VERSION(major, minor ,point) ( ((major) << 16) | ((minor) << 8) | (point) ) /// Filter Descriptors act as virtual class members and factories for all filters. They provide /// information about the filter name, type and description, as well as the ability to create instances of the actual filter. /// In that way we can find out properties of the filter before actually (optionally) creating it. class hctFilterDescriptor { public: /// This enum is used to place the filters in tabs in the filter manager. /// User-defined filters should use HK_USER. enum FilterCategory { /// Core Category HK_CATEGORY_CORE = 0, /// Deprecated category, use HK_PHYSICS instead. HK_CATEGORY_COLLISION_DEPRECATED, /// Physics Category. HK_CATEGORY_PHYSICS, /// Cloth Category. HK_CATEGORY_CLOTH, /// Destruction Category. HK_CATEGORY_DESTRUCTION, /// FX Category, no longer used HK_CATEGORY_FX_PHYSICS_DEPRECATED, /// Animation Category. HK_CATEGORY_ANIMATION, /// Graphics Category. HK_CATEGORY_GRAPHICS, /// User Category. HK_CATEGORY_USER }; /// Describes how the filter operates with the data (does it change it or no). enum FilterBehaviour { /// Filter does not alter data, can be ignored in pure data runs, such as the previewer filters. HK_DATA_PASSTHRU = 0, /// The filter changes or adds data in the stream - most filters are like this. HK_DATA_MUTATES_INPLACE = 1, /// The filter changes or adds data to a external file, not the stream (such as the platform writer). HK_DATA_MUTATES_EXTERNAL = 2 }; typedef int HavokComponentMask; enum HavokComponent { HK_COMPONENT_COMMON = 0, HK_COMPONENT_ANIMATION = 1, HK_COMPONENT_PHYSICS = 2, HK_COMPONENT_CLOTH = 4, HK_COMPONENT_DESTRUCTION = 8, HK_COMPONENT_AI = 16, // = 32, etc // Product combinations HK_COMPONENTS_COMPLETE = HK_COMPONENT_COMMON | HK_COMPONENT_ANIMATION | HK_COMPONENT_PHYSICS, // All HK_COMPONENTS_ALL = HK_COMPONENTS_COMPLETE | HK_COMPONENT_CLOTH | HK_COMPONENT_DESTRUCTION | HK_COMPONENT_AI }; /// Get unique ID of the filter (32 bits). Manager will warn when two alike are found. virtual unsigned int getID() const = 0; /// Get the rough category of the filter. virtual FilterCategory getCategory() const = 0; /// Find out at a the filter does with the contents (so we know whether we should run it. /// in trial or option runs etc). virtual FilterBehaviour getFilterBehaviour() const = 0; /// Get the short display name for the filter. Should be unique (used by the options lookup) within its category. If this proves too hard then we will have to revert to a filter id (32 bit int say). virtual const char* getShortName() const = 0; /// Get the long name for the filter. virtual const char* getLongName() const = 0; /// Return the version of the filter (used by options etc). virtual unsigned int getFilterVersion() const = 0; /// Must return a mask of HavokComponent values matching the SDK components (libraries) required to use/load /// the output of this filter. virtual HavokComponentMask getRequiredHavokComponents () const = 0; /// Create the filter. The pointer returned my be memory managed in any way, as /// deletion will be handled through destruct. Do not call delete on the filter. virtual class hctFilterInterface* createFilter(const class hctFilterManagerInterface* ownerInstance) const = 0; /// Should tell all modeless filters to close and return immediately. /// Default implementation (for modal filters) does nothing. virtual void askModelessFiltersToClose () const; /// Returns how many modeless filters are present. It must split the count between "active" and "closing" down. /// Default implementation (for modal filters) should return 0 and set both parameters to 0. virtual int countModelessFilters (int& numActiveOut, int& numClosingout) const; }; #endif // HAVOK_FILTER_DESCRIPTOR_H /* * Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20091222) * * Confidential Information of Havok. (C) Copyright 1999-2009 * Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok * Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership * rights, and intellectual property rights in the Havok software remain in * Havok and/or its suppliers. * * Use of this software for evaluation purposes is subject to and indicates * acceptance of the End User licence Agreement for this product. A copy of * the license is included with this software and is also available at www.havok.com/tryhavok. * */
[ [ [ 1, 132 ] ] ]
47edbcfbae1f381af2c0f2e6cced807de94437f4
e7c45d18fa1e4285e5227e5984e07c47f8867d1d
/Common/Models/Power1/Switch.cpp
45e1e2c20c2c069e4cdf19ed66a57cd9c05095ca
[]
no_license
abcweizhuo/Test3
0f3379e528a543c0d43aad09489b2444a2e0f86d
128a4edcf9a93d36a45e5585b70dee75e4502db4
refs/heads/master
2021-01-17T01:59:39.357645
2008-08-20T00:00:29
2008-08-20T00:00:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,819
cpp
//================== SysCAD - Copyright Kenwalt (Pty) Ltd =================== // $Nokeywords: $ //=========================================================================== #include "stdafx.h" #define __SWITCH_CPP #include "sc_defs.h" #include "pgm_e.h" #include "switch.h" #include "scd_wm.h" XID xidTSCfg = PwrXID(1000); XID xidHtLoad = PwrXID(1001); //========================================================================== // // // //========================================================================== static IOAreaRec IsolatorIOAreaList[] = {{"Input", "In" , ElecIOId(0), LIO_In0 , nc_ELnk, 0,50, 0, 0.0, {0,0,0,0}, NULL, NULL, -1, "PwrIn"}, {"Output", "Out", ElecIOId(1), LIO_Out0, nc_ELnk, 0,50, 0, 0.0, {0,0,0,0}, NULL, NULL, -1, "PwrOut"}, {NULL}}; //========================================================================== // // // //========================================================================== static double Drw_Isolator[] = { DD_Arc, 0,2,1, DD_Arc, 0,-2,1, DD_Poly, 0,-2, 2, 2, DD_End }; IMPLEMENT_MODELUNIT(CIsolator, "E_Isolator", "", Drw_Isolator, "Electrical", "Is", TOC_ALL|TOC_GRP_POWERDIST|TOC_POWERDIST, "Electrical:Isolator", "Isolator.") CIsolator::CIsolator(pTagObjClass pClass_, pchar TagIn, pTaggedObject pAttach, TagObjAttachment eAttach) : FlwNode(pClass_, TagIn, pAttach, eAttach), m_tsPwrIn(this, "PwrIn", eCT_3Ph4W), m_tsPwrOut(this, "PwrOut", eCT_3Ph4W) { AttachClassInfo(nc_Elec, IsolatorIOAreaList); SetActiveOptions(true, true); m_bOn = 0; } //-------------------------------------------------------------------------- CIsolator::~CIsolator() { } //-------------------------------------------------------------------------- void CIsolator::ResetData(flag Complete) { } //-------------------------------------------------------------------------- void CIsolator::BuildDataDefn(DataDefnBlk & DDB) { DDB.BeginStruct(this, "CIsolator", NULL, DDB_NoPage); DDB.Text(""); DDB.Long ("TermCfg", "", DC_, "", xidTSCfg, this, isParm, DDBCTTypes); DDB.CheckBoxBtn("On", "", DC_, "", &m_bOn, this, isParm); DDB.Double ("HeatLoad", "", DC_Pwr, "W", xidHtLoad, this, isResult); DDB.Text(""); m_tsPwrIn.BuildDataDefn(DDB, 1, true); m_tsPwrOut.BuildDataDefn(DDB, 2, true); DDB.EndStruct(); } //-------------------------------------------------------------------------- flag CIsolator::DataXchg(DataChangeBlk & DCB) { if (FlwNode::DataXchg(DCB)) return 1; if (m_tsPwrIn.DataXchg(DCB, 1)) return 1; if (m_tsPwrOut.DataXchg(DCB, 2)) return 1; switch (DCB.lHandle) { case xidTSCfg: if (DCB.rL) { m_tsPwrIn.SetConfiguration((eTSConfigurations)*DCB.rL); m_tsPwrOut.SetConfiguration((eTSConfigurations)*DCB.rL); } DCB.L=m_tsPwrIn.Configuration(); return 1; case xidHtLoad: { DCB.D=0; for (int w=0; w<m_Electrics.ComponentCount(); w++) DCB.D+=m_Electrics.CompData(w)->HeatLoad(); return 1; } } return False; } //-------------------------------------------------------------------------- flag CIsolator::ValidateData(ValidateDataBlk & VDB) { //ELEC for (int e=EIO1(); e<EION(); e++) //ELEC EIO_Conduit(e).m_TStrip.SetConfiguration(m_nType, m_dVolts); return FlwNode::ValidateData(VDB); } //-------------------------------------------------------------------------- void CIsolator::CollectElectrics(CNodeElectricsArray & TSCA) { FlwNode::CollectElectrics(TSCA); m_Electrics.AddTermStrip(&m_tsPwrIn); m_Electrics.AddTermStrip(&m_tsPwrOut); } //-------------------------------------------------------------------------- void CIsolator::ConnectElectrics() { FlwNode::ConnectElectrics(); if (m_bOn) { ASSERT(m_tsPwrIn.TerminalCount()==m_tsPwrOut.TerminalCount()); for (int w=0; w<m_tsPwrIn.TerminalCount(); w++) m_Electrics.SetImpedance(0, m_tsPwrIn[w], m_tsPwrOut[w], 0.001, 0); } }; //-------------------------------------------------------------------------- flag CIsolator::GetModelAction(CMdlActionArray & Acts) { Acts.SetSize(0); Acts.SetAtGrow(0, CMdlAction(0, MAT_State, !m_bOn, "On", 1)); Acts.SetAtGrow(1, CMdlAction(1, MAT_State, m_bOn, "Off", 0)); Acts.SetAtGrow(2, CMdlAction(2, MAT_Switch)); return true; }; //-------------------------------------------------------------------------- flag CIsolator::SetModelAction(CMdlAction & Act) { switch (Act.iIndex) { case 0: case 1: m_bOn=Act.iValue!=0; break; case 2: m_bOn=!m_bOn; break; } return true; }; //-------------------------------------------------------------------------- dword CIsolator::ModelStatus() { dword Status=FlwNode::ModelStatus(); Status|=/*FNS_IsElec|*/(m_bOn ? FNS_On : FNS_Off); return Status; } //-------------------------------------------------------------------------- flag CIsolator::CIStrng(int No, pchar & pS) { // NB check CBCount is large enough. switch (No-CBContext()) { case 1: pS="E\tBad external tag references"; return 1; case 2: pS="E\tErrors in evaluating functions"; return 1; case 3: pS="E\tEngineering units invalid"; return 1; default: return FlwNode::CIStrng(No, pS); } } //========================================================================== // // // //========================================================================== static IOAreaRec CctBreakerIOAreaList[] = {{"Input", "In" , ElecIOId(0), LIO_In0 , nc_ELnk, 0,50, 0, 0.0, {0,0,0,0}, NULL, NULL, -1, "PwrIn"}, {"Output", "Out", ElecIOId(1), LIO_Out0, nc_ELnk, 0,50, 0, 0.0, {0,0,0,0}, NULL, NULL, -1, "PwrOut"}, {NULL}}; static double Drw_CctBreaker[] = { DD_Arc, 0,2,1, DD_Arc, 0,-2,1, DD_Poly, 0,-2, 2, 2, DD_End }; IMPLEMENT_MODELUNIT(CCctBreaker, "E_CctBrk", "", Drw_CctBreaker, "Electrical", "Ccb", TOC_ALL|TOC_GRP_POWERDIST|TOC_POWERDIST, "Electrical:CctBreaker", "Circuit Breaker.") CCctBreaker::CCctBreaker(pTagObjClass pClass_, pchar TagIn, pTaggedObject pAttach, TagObjAttachment eAttach) : FlwNode(pClass_, TagIn, pAttach, eAttach), m_tsPwrIn(this, "PwrIn", eCT_3Ph4W), m_tsPwrOut(this, "PwrOut", eCT_3Ph4W) { AttachClassInfo(nc_Elec, CctBreakerIOAreaList); SetActiveOptions(true, true); m_bOn = 0; } //-------------------------------------------------------------------------- CCctBreaker::~CCctBreaker() { } //-------------------------------------------------------------------------- void CCctBreaker::ResetData(flag Complete) { } //-------------------------------------------------------------------------- void CCctBreaker::BuildDataDefn(DataDefnBlk & DDB) { DDB.BeginStruct(this, "CCctBreaker", NULL, DDB_NoPage); DDB.Text(""); DDB.Long ("TermCfg", "", DC_, "", xidTSCfg, this, isParm, DDBCTTypes); DDB.CheckBoxBtn("On", "", DC_, "", &m_bOn, this, isParm); DDB.Double ("HeatLoad", "", DC_Pwr, "W", xidHtLoad, this, isResult); DDB.Text(""); m_tsPwrIn.BuildDataDefn(DDB, 1, true); m_tsPwrOut.BuildDataDefn(DDB, 2, true); DDB.EndStruct(); } //-------------------------------------------------------------------------- flag CCctBreaker::DataXchg(DataChangeBlk & DCB) { if (FlwNode::DataXchg(DCB)) return 1; if (m_tsPwrIn.DataXchg(DCB, 1)) return 1; if (m_tsPwrOut.DataXchg(DCB, 2)) return 1; switch (DCB.lHandle) { case xidTSCfg: if (DCB.rL) { m_tsPwrIn.SetConfiguration((eTSConfigurations)*DCB.rL); m_tsPwrOut.SetConfiguration((eTSConfigurations)*DCB.rL); } DCB.L=m_tsPwrIn.Configuration(); return 1; case xidHtLoad: { DCB.D=0; for (int w=0; w<m_Electrics.ComponentCount(); w++) DCB.D+=m_Electrics.CompData(w)->HeatLoad(); return 1; } } return False; } //-------------------------------------------------------------------------- flag CCctBreaker::ValidateData(ValidateDataBlk & VDB) { return FlwNode::ValidateData(VDB); } //-------------------------------------------------------------------------- void CCctBreaker::CollectElectrics(CNodeElectricsArray & TSCA) { FlwNode::CollectElectrics(TSCA); m_Electrics.AddTermStrip(&m_tsPwrIn); m_Electrics.AddTermStrip(&m_tsPwrOut); } //-------------------------------------------------------------------------- void CCctBreaker::ConnectElectrics() { FlwNode::ConnectElectrics(); if (m_bOn) { ASSERT(m_tsPwrIn.TerminalCount()==m_tsPwrOut.TerminalCount()); for (int w=0; w<m_tsPwrIn.TerminalCount(); w++) m_Electrics.SetImpedance(0, m_tsPwrIn[w], m_tsPwrOut[w], 0.001, 0); } }; //-------------------------------------------------------------------------- flag CCctBreaker::GetModelAction(CMdlActionArray & Acts) { Acts.SetSize(0); Acts.SetAtGrow(0, CMdlAction(0, MAT_State, !m_bOn, "On", 1)); Acts.SetAtGrow(1, CMdlAction(1, MAT_State, m_bOn, "Off", 0)); Acts.SetAtGrow(2, CMdlAction(2, MAT_Switch)); return true; }; //-------------------------------------------------------------------------- flag CCctBreaker::SetModelAction(CMdlAction & Act) { switch (Act.iIndex) { case 0: case 1: m_bOn=Act.iValue!=0; break; case 2: m_bOn=!m_bOn; break; } return true; }; //-------------------------------------------------------------------------- dword CCctBreaker::ModelStatus() { dword Status=FlwNode::ModelStatus(); Status|=/*FNS_IsElec|*/(m_bOn? FNS_On : FNS_Off); return Status; } //-------------------------------------------------------------------------- flag CCctBreaker::CIStrng(int No, pchar & pS) { // NB check CBCount is large enough. switch (No-CBContext()) { case 1: pS="E\tBad external tag references"; return 1; case 2: pS="E\tErrors in evaluating functions"; return 1; case 3: pS="E\tEngineering units invalid"; return 1; default: return FlwNode::CIStrng(No, pS); } } //========================================================================== //==========================================================================
[ [ [ 1, 6 ], [ 8, 23 ], [ 26, 51 ], [ 53, 149 ], [ 151, 152 ], [ 156, 160 ], [ 162, 206 ], [ 209, 228 ], [ 230, 324 ], [ 326, 327 ], [ 331, 335 ], [ 337, 376 ] ], [ [ 7, 7 ], [ 24, 25 ], [ 52, 52 ], [ 150, 150 ], [ 153, 155 ], [ 161, 161 ], [ 207, 208 ], [ 229, 229 ], [ 325, 325 ], [ 328, 330 ], [ 336, 336 ] ] ]
90e81313e225b5910fd8c3740d7075fbb3d18b27
0da7fec56f63012180d848b1e72bada9f6984ef3
/PocketDjVu_root/PocketDjvu/AboutDlg.cpp
cf99c2a976d3fe0662e333591da02aa7a32a8390
[]
no_license
UIKit0/pocketdjvu
a34fb2b8ac724d25fab7a0298942db1755098b25
4c0c761e6a3d3628440fb4fb0a9c54e5594807d9
refs/heads/master
2021-01-20T12:01:16.947853
2010-05-03T12:29:44
2010-05-03T12:29:44
32,293,688
0
0
null
null
null
null
UTF-8
C++
false
false
1,699
cpp
// aboutdlg.cpp : implementation of the CAboutDlg class // ///////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "resource.h" #include "aboutdlg.h" #include "./misc.h" LRESULT CAboutDlg::OnInitDialog( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled ) { ::CreateDlgMenuBar( IDR_MENU_OKCANCEL, m_hWnd ); Base::OnInitDialog( uMsg, wParam, lParam, bHandled ); bHandled = true; CWindow verWnd = GetDlgItem(IDC_STATIC_VER); if ( verWnd.IsWindow() ) { WTL::CString s; unsigned const maxL = 128; verWnd.GetWindowText( s.GetBuffer(maxL), maxL ); s.ReleaseBuffer(); WTL::CString verStr = GetModuleVersionStr( 0 ); s += verStr; verWnd.SetWindowText( s ); } // MEMORYSTATUS ms = {0}; ms.dwLength = sizeof ms; GlobalMemoryStatus( &ms ); CWindow siWnd = GetDlgItem(IDC_INFO); if ( siWnd.IsWindow() ) { WTL::CString s; s.Format( L"TotalPhys : %d\r\nAvailPhys : %d\r\nTotalVirtual : %d\r\nAvailVirtual : %d\r\n", int(ms.dwTotalPhys), int(ms.dwAvailPhys), int(ms.dwTotalVirtual), int(ms.dwAvailVirtual) ); siWnd.SetWindowText( s ); } m_homePageLink.SubclassWindow( GetDlgItem(IDC_HOMEPAGE) ); ATL::CString link; m_homePageLink.GetWindowText( link ); m_homePageLink.SetHyperLink( link ); m_homePageLink.SetHyperLinkExtendedStyle( HLINK_UNDERLINEHOVER, HLINK_UNDERLINEHOVER ); return TRUE; } LRESULT CAboutDlg::OnWininiChange( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled ) { bHandled = true; DoSipInfo(); return 0; }
[ "Igor.Solovyov@84cd470b-3125-0410-acc3-039690e87181" ]
[ [ [ 1, 62 ] ] ]
787c5bc99d760dbc322f8b46ec3dc9a3d3244626
382b459563be90227848e5125f0d37f83c1e2a4f
/Schedule/include/markevaluator.h
91fd9bf027fe7a9f215382998079bb96213096f0
[]
no_license
Maciej-Poleski/SchoolTools
516c9758dfa153440a816a96e3f05c7f290daf6c
e55099f77eb0f65b75a871d577cc4054221b9802
refs/heads/master
2023-07-02T09:07:31.185410
2010-07-11T20:56:59
2010-07-11T20:56:59
392,391,718
0
0
null
null
null
null
UTF-8
C++
false
false
1,255
h
#ifndef MARKEVALUATOR_H #define MARKEVALUATOR_H #include "complist.h" /** Klasa reprezentuje system przeliczania punktów i ocen pośrednich w oceny cząstkowe nie uwzględniając wag. * * Możliwości: * - Dummy (do nothing) * - modern -> classic * - classic -> partial-mark (ocena cząstkowa) * - modern -> partial-mark * * W przyszłości również operacje wstecz. * * Tablica do wyszukiwania binarnego, sposób wypełniania: * Od najniższych indeksów wypełniamy progiem na daną ocenę aż do osiągnięcia dokładnie tego indeksu, który odpowiada danej ocenie. * Sposób wyszukiwania: * qUpperBound - trzeci argument to ocena w formacie modern. Od wyniku odejmujemy jeden. * Teraz posiadamy oczekiwaną odległość od początku tablicy gotową do dalszych tranformacji. * O(lg(maksymalna potencjalna liczba różnych ocen klasycznych)) */ class MarkEvaluator { public: private: bool dummy; ///< Jeżeli ustawione - należy potraktować modern-mark bezpośrednio CompList<double> modernToClassic; ///< Tablica do wyszukiwania binarnego podczas transformacji modern-mark -> classic public: private: }; #endif // MARKEVALUATOR_H
[ [ [ 1, 35 ] ] ]
240f13c1dc7bef64c1c72795ec1fa669968f0672
5e72c94a4ea92b1037217e31a66e9bfee67f71dd
/older/tptest5/src/MainFrame.h
de8a48b585f33a9aa2cd2f8c72bef71d8f496fc4
[]
no_license
stein1/bbk
1070d2c145e43af02a6df14b6d06d9e8ed85fc8a
2380fc7a2f5bcc9cb2b54f61e38411468e1a1aa8
refs/heads/master
2021-01-17T23:57:37.689787
2011-05-04T14:50:01
2011-05-04T14:50:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,376
h
#pragma once #include "main.h" #include "ServerListDialog.h" #include "DialogAbout.h" class AdvancedModePanel; // forward declarations class SimpleModePanel; // forward declarations class AvailabilityModePanel; // forward declarations class RTTPacketlossModePanel; // forward declarations class ThroughputModePanel; // forward declarations class ReportDialog; class MainFrame : public wxFrame { public: MainFrame(TheApp *theapp); ~MainFrame(void); void OnQuit(wxCommandEvent& WXUNUSED(event)); void OnAbout(wxCommandEvent& WXUNUSED(event)); void OnToggleMode(wxCommandEvent& event); void OnEditServerList(wxCommandEvent& WXUNUSED(event)); void OnReport(wxCommandEvent& WXUNUSED(event)); void OnRepeat(wxCommandEvent& WXUNUSED(event)); void OnHistorySetting(wxCommandEvent& WXUNUSED(event)); void OnExportAvailability(wxCommandEvent& WXUNUSED(event)); void OnExportStandard(wxCommandEvent& WXUNUSED(event)); void OnExportRTTPacketloss(wxCommandEvent& WXUNUSED(event)); void OnExportThroughput(wxCommandEvent& WXUNUSED(event)); void OnManual( wxCommandEvent& WXUNUSED(event) ); void OnRepeatTimer( wxTimerEvent& event ); void OnTimer( wxTimerEvent& event ); bool IsRepeatActive(void); bool IsPagesLocked(void); void AbortRepeatTimer(void); void PreStartTest(void* pobj, void (*resultfunc)(void*, bool), bool (*executefunc)(void*)); void StartTest(void); void PostTest(); void EnableMenu( bool enable ); void RefreshPanels(void); static MainFrame* GetInstance(void); private: static MainFrame *s_Instance; wxString m_StartCwd; // Current work directory on startup wxMenu *m_menuFile; wxMenu *m_menuHelp; wxMenu *m_menuFile_Export; wxMenu *m_menuConf; wxMenuBar *m_menuBar; int m_Mode; wxPanel *m_PanelMain; wxSizer *m_SizerMain; wxTimer *m_timer; wxTimer *m_timerRepeat; TheApp *m_app; long m_RepeatStarted; bool m_RepeatActive; // Callback for on-test-completed, object and static method void (*m_resultfunc)(void*,bool); bool (*m_executefunc)(void*); void *m_ResultPageInstance; ServerListDialog *m_dlgServerList; DialogAbout *m_dlgAbout; wxProgressDialog *m_dlgProgress; ReportDialog *m_dlgReport; AdvancedModePanel *m_AdvancedPanel; SimpleModePanel *m_SimplePanel; DECLARE_EVENT_TABLE() };
[ [ [ 1, 90 ] ] ]
fc0043c0aeaf55c64da79215ff8535475be3682c
b822313f0e48cf146b4ebc6e4548b9ad9da9a78e
/KylinSdk/Engine/Source/uiCursorEx.h
3f529935670c011682f0edd7ff62cbf39b3a0929
[]
no_license
dzw/kylin001v
5cca7318301931bbb9ede9a06a24a6adfe5a8d48
6cec2ed2e44cea42957301ec5013d264be03ea3e
refs/heads/master
2021-01-10T12:27:26.074650
2011-05-30T07:11:36
2011-05-30T07:11:36
46,501,473
0
0
null
null
null
null
GB18030
C++
false
false
981
h
#pragma once #include "GuiManager.h" namespace Kylin { class CursorEx : public GuiBase { public: CursorEx(); enum CursorType { CT_WINBASE = 0, CT_NORMAL, //普通 CT_ATTACK, //攻击 CT_AUTORUN, //自动行走中 CT_PICKUP, //拾取物品 CT_UNREACHABLE, //无法到达的区域 CT_MINE, //采矿 CT_HERBS, //采药 CT_FISH, //钓鱼 CT_SPEAK, //谈话 CT_INTERACT, //齿轮 CT_REPAIR, //修理 CT_HOVER, //鼠标激活(挂接物品...) CT_IDENTIFY, //鼠标鉴定 CT_ADDFRIEND, //添加好友 CT_EXCHANGE, //添加好友 CT_CATCH_PET, //捕捉 CT_NUMBER, }; virtual KBOOL Initialize(); virtual KVOID Render(KFLOAT fElapsed){} virtual KVOID Destroy(){} virtual KVOID SetVisible(KBOOL bVisible); virtual KVOID SetPointer(CursorType eType); virtual CursorType GetPointerType(); protected: CursorType m_eType; }; }
[ "[email protected]", "apayaccount@5fe9e158-c84b-58b7-3744-914c3a81fc4f" ]
[ [ [ 1, 9 ], [ 37, 43 ], [ 49, 50 ] ], [ [ 10, 36 ], [ 44, 48 ] ] ]
b009f82e093ef1147fd86c11d5ce458005ba8628
e7c45d18fa1e4285e5227e5984e07c47f8867d1d
/Application/SysCAD/SvcConn.cpp
2341b848996b25c6aa1b7d87a5ff99373b791dfc
[]
no_license
abcweizhuo/Test3
0f3379e528a543c0d43aad09489b2444a2e0f86d
128a4edcf9a93d36a45e5585b70dee75e4502db4
refs/heads/master
2021-01-17T01:59:39.357645
2008-08-20T00:00:29
2008-08-20T00:00:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
52,705
cpp
#include "stdafx.h" #include "grfdoc.h" #include "msgwnd.h" #include "flwnode.h" #include "SvcConn.h" #include "SvcConnCLR.h" //#include "optoff.h" #define NETSERVERNAME "SvcConnect" //======================================================================== #if SYSCAD10 #define dbgSvcConn 1 // temporary #if dbgSvcConn static bool dbgConnect() { return 1; } #endif //======================================================================== // // // //======================================================================== #define WITHDBGLINES 01 #if WITHDBGLINES #define DO_ENTRY_GT(Method, Guid, Tag) \ if (dbgConnect()) \ { \ dbgpln("%-30s >>> %7s %7s %s %s", Method, "", "", Guid, Tag); \ dbgindent(2); \ } #define DO_ENTRY_GTP(Method, Guid, Tag, Path) \ if (dbgConnect()) \ { \ dbgpln("%-30s >>> %7s %7s %s %-20s %s", Method, "", "", Guid, Tag, Path); \ dbgindent(2); \ } #define DO_ENTRY_TP(Method, Tag, Path) \ if (dbgConnect()) \ { \ dbgpln("%-30s >>> %7s %7s %-20s %s", Method, "", "", Tag, Path); \ dbgindent(2); \ } #define DO_ENTRY_GTPSM(Method, Guid, Tag, Path, Shape, Model) \ if (dbgConnect()) \ { \ dbgpln("%-30s >>> %7s %7s %s %-20s %s %s %s", Method, "", "", Guid, Tag, Path, Shape, Model); \ dbgindent(2); \ } #define DO_ENTRY_GGTPSM(Method, MdlGuid, GrfGuid, Tag, Path, Shape, Model) \ if (dbgConnect()) \ { \ dbgpln("%-30s >>> %7s %7s %s %s %-20s %s %s %s", Method, "", "", MdlGuid, GrfGuid, Tag, Path, Shape, Model); \ dbgindent(2); \ } #define DO_EXIT(Method) \ if (dbgConnect()) \ { \ dbgindent(-2); \ dbgpln("%-30s <<< %7s %7I64i", Method, "", m_lRequestIdRet); \ }; #define DO_EXIT_T(Method, Tag) \ if (dbgConnect()) \ { \ dbgindent(-2); \ dbgpln("%-30s <<< %7s %7I64i %s", Method, "", m_lRequestIdRet, Tag); \ }; #define DO_EXIT_G(Method, Guid) \ if (dbgConnect()) \ { \ dbgindent(-2); \ dbgpln("%-30s <<< %7s %7I64i %s", Method, "", m_lRequestIdRet, Guid); \ }; #define DO_EXIT_GT(Method, Guid, Tag) \ if (dbgConnect()) \ { \ dbgindent(-2); \ dbgpln("%-30s <<< %7s %7I64i %s %s", Method, "", m_lRequestIdRet, Guid, Tag); \ }; #define DO_EXIT_GG(Method, Guid1, Guid2) \ if (dbgConnect()) \ { \ dbgindent(-2); \ dbgpln("%-30s <<< %7s %7I64i %s %s", Method, "", m_lRequestIdRet, Guid1, Guid2); \ }; #else #define DO_ENTRY_GT(Method, Guid, Tag) /* Do Nothing */ #define DO_ENTRY_TP(Method, Tag, Path) /* Do Nothing */ #define DO_ENTRY_GTPSM(Method, Guid, Tag, Path, Shape, Model) /* Do Nothing */ #define DO_ENTRY_GGTPSM(Method, MdlGuid, GrfGuid, Tag, Path, Shape, Model) /* Do Nothing */ #define DO_ENTRY_GTP(Method, Guid, Tag, Path) /* Do Nothing */ #define DO_EXIT(Method) /* Do Nothing */ #define DO_EXIT_T(Method, Guid) /* Do Nothing */ #define DO_EXIT_G(Method, Guid) /* Do Nothing */ #define DO_EXIT_GT(Method, Guid, Tag) /* Do Nothing */ #define DO_EXIT_GG(Method, Guid1, Guid2) /* Do Nothing */ #endif //======================================================================== #if WITHDBGLINES #define ON_ENTRY_GT(Method, Guid, Tag) \ if (dbgConnect()) \ { \ dbgpln("%-30s >>> %7I64i %7I64i %s %s", Method, eventId, requestId, Guid, Tag); \ dbgindent(4); \ } #define ON_ENTRY_GTP(Method, Guid, Tag, Path) \ if (dbgConnect()) \ { \ dbgpln("%-30s >>> %7I64i %7I64i %s %-20s %s", Method, eventId, requestId, Guid, Tag, Path); \ dbgindent(4); \ } #define ON_ENTRY_GTM(Method, Guid, Tag, Model) \ if (dbgConnect()) \ { \ dbgpln("%-30s >>> %7I64i %7I64i %s %-20s %s", Method, eventId, requestId, Guid, Tag, Model); \ dbgindent(4); \ } #define ON_ENTRY_GTPSM(Method, Guid, Tag, Path, Shape, Model) \ if (dbgConnect()) \ { \ dbgpln("%-30s >>> %7I64i %7I64i %s %-20s %s %s %s", Method, eventId, requestId, Guid, Tag, Path, Shape, Model); \ dbgindent(4); \ } #define ON_EXIT(Method) \ if (dbgConnect()) \ { \ dbgindent(-4); \ dbgpln("%-30s <<< %7I64i %7I64i", Method, eventId, m_lRequestIdRet); \ }; #define ON_EXIT_G(Method, Guid) \ if (dbgConnect()) \ { \ dbgindent(-4); \ dbgpln("%-30s <<< %7I64i %7I64i %s", Method, eventId, m_lRequestIdRet, Guid); \ }; #else #define ON_ENTRY_GT(Method, Guid, Tag) /* Do Nothing */ #define ON_ENTRY_GTP(Method, Guid, Tag, Path) /* Do Nothing */ #define ON_ENTRY_GTM(Method, Guid, Tag, Model) /* Do Nothing */ #define ON_ENTRY_GTPSM(Method, Guid, Tag, Path, Shape, Model) /* Do Nothing */ #define ON_EXIT(Method) /* Do Nothing */ #define ON_EXIT_G(Method, Guid) /* Do Nothing */ #endif //======================================================================== // // Common // //======================================================================== static int CheckTagExists(LPCSTR Tag) { if (gs_pSfeSrvr) { if (!(gs_pSfeSrvr->FE_TestModelTagUnique((char*)Tag))) return 0; else return -1; } return -2; } static CDocument* GetGrfDoc(int index, LPCSTR name) { bool Done=false; CDocument* pDoc=NULL; int GrfDocCnt=-1; CDocTemplate &Templ = ScdApp()->GraphTemplate(); POSITION PosD = Templ.GetFirstDocPosition(); if (name==NULL) { return Templ.GetNextDoc(PosD); } else { while (!Done && PosD) { pDoc = Templ.GetNextDoc(PosD); POSITION pos = pDoc->GetFirstViewPosition(); if (pos) { CView* pFirstView = pDoc->GetNextView(pos); CWnd* w = pFirstView->GetParent(); // if (pDoc->IsKindOf(RUNTIME_CLASS(CGrfDoc))) if (dynamic_cast<CGrfDoc*>(pDoc)) { //ASSERT(dynamic_cast<CGrfFrameWnd*>(w)); GrfDocCnt++; if (index<0 && pDoc->GetTitle().CompareNoCase(name)==0) Done = true; else if (GrfDocCnt==index) Done = true; } } } if (!Done) return NULL; } return pDoc; } //======================================================================== // // Messaging // //======================================================================== CSvcConnect::CSvcConnect() { m_lEventId = 0; } CSvcConnect::~CSvcConnect() { } void CSvcConnect::Startup() { m_GrfGrpsNames.InitHashTable(101); m_GrfGrpsGuids.InitHashTable(101); m_pCLR = new CSvcConnectCLR; m_pCLR->Startup(this); }; bool CSvcConnect::ConfigSetup() { return m_pCLR->ConfigSetup(this); } void CSvcConnect::Shutdown() { if (m_pCLR) { m_pCLR->Shutdown(); delete m_pCLR; m_pCLR=NULL; } POSITION Pos=m_GrfGrpsNames.GetStartPosition(); while (Pos) { LPCSTR Key; CsGrfGroup *pG; m_GrfGrpsNames.GetNextAssoc(Pos, Key, pG); delete pG; } m_GrfGrpsNames.RemoveAll(); m_GrfGrpsGuids.RemoveAll(); }; void CSvcConnect::Upgrade2Scd10(LPCSTR projectPath, LPCSTR configPath) { m_Ctrl.m_bExportBusy = true; //m_pCLR->Export(projectPath, configPath); if (m_pCLR->PrepareForUpgrade(projectPath, configPath)) { m_pCLR->ProcessChangeListsHold(true); CExistingItems GI; GI.Get(); int PrevPage=-1; CString Path; POSITION Pos=GI.m_Groups.GetHeadPosition(); while (Pos) { CExistingItems::CGroup & Grp=*GI.m_Groups.GetNext(Pos); CString GrpGuid = TaggedObject::CreateGuidStr(); // where should this come from DO_ENTRY_GTP("DoCreateGroupE", GrpGuid, Grp.m_sTitle, MakePath(projectPath)); m_pCLR->AddCreateGroup(m_lRequestIdRet, GrpGuid, Grp.m_sTitle, MakePath(projectPath), CRectangleF(Grp.m_PageRct.Left()+Grp.m_XOff,Grp.m_PageRct.Bottom()+Grp.m_YOff, Grp.m_PageRct.Width(), Grp.m_PageRct.Height())); DO_EXIT_GT("DoCreateGroupE", GrpGuid, Grp.m_sTitle); } // static __int64 RqID=0; Pos=GI.m_Items.GetHeadPosition(); while (Pos) { CExistingItems::CItem & I = *GI.m_Items.GetNext(Pos); //???????? //if (I.m_sTag.CompareNoCase("PlantArea")==0) // continue; CNodeListItem & N = *I.m_pNLItem; CExistingItems::CGroupIndex Inx; if (!GI.m_TagMap.Lookup(I.m_sTag, Inx)) { LogError("Upgrade2Scd10", 0, "Tag Not in Graphics %s", I.m_sTag); continue; }; CExistingItems::CGroup & Grp = *Inx.m_pGrp; CGrfTagInfo & GTI =Grp.m_GTIA[Inx.m_iGTIA]; GTI.m_bDone=true; #if dbgSvcConn if (dbgConnect()) { dbgpln("Export %s %-20s %-20s %-20s", N.m_bIsLnk?"Link":"Node", N.m_sTag, GTI.m_sSymbol(), N.m_sClass); dbgindent(4); } #endif if (!N.m_bIsLnk) { CString Symbol = GTI.m_sSymbol(); CString GraphicGuid = GTI.m_sGuid(); CString Shape = ExtractShape(Symbol); CString Model = N.m_sClass; FlwNode * pNode = gs_pSfeSrvr->FE_FindNode(I.m_sTag, NULL); CString ModelGuid = pNode->Guid(); DO_ENTRY_GGTPSM("DoCreateNodeE", ModelGuid, GraphicGuid, I.m_sTag, MakePath(projectPath, Grp.m_sTitle), Shape, Model); float boxW = float(int(GTI.m_HiBnd.m_X-GTI.m_LoBnd.m_X)); float boxH = float(int(GTI.m_HiBnd.m_Y-GTI.m_LoBnd.m_Y)); float boxX = float(int(GTI.m_LoBnd.m_X + Grp.m_XOff + Grp.m_XShift) + 0.5); // needs to be x.5mm to meet grid in 10. float boxY = float(int(Grp.m_PageRct.Height() - GTI.m_HiBnd.m_Y + Grp.m_YOff - Grp.m_YShift) + 0.5); // needs to be x.5mm to meet grid in 10. float textBoxW = float(int(GTI.m_Tag.m_XScale * 3.0 * GTI.m_sTag.GetLength())); float textBoxH = float(int(GTI.m_Tag.m_YScale * 5.0)); float textBoxX = float(int(GTI.m_Tag.m_X + Grp.m_XOff + Grp.m_XShift - textBoxW / 2.0) + 0.5); // needs to be x.5mm to meet grid in 10. float textBoxY = float(int(Grp.m_PageRct.Height() - GTI.m_Tag.m_Y + Grp.m_YOff - Grp.m_YShift - textBoxH) + 0.5); // needs to be x.5mm to meet grid in 10. m_pCLR->AddCreateNode(m_lRequestIdRet, ModelGuid, GraphicGuid, I.m_sTag, MakePath(projectPath, Grp.m_sTitle), Model, Shape, CRectangleF(boxX, boxY, boxW, boxH), CPointF(1.0,1.0), GTI.m_Node.m_Rotation, CSvcTagBlk(CRectangleF(textBoxX, textBoxY, textBoxW, textBoxH), (float)GTI.m_Tag.m_Rotation, (float)GTI.m_Tag.m_Visible!=0), COLORREF(0), false, false); DO_EXIT_GG("DoCreateNodeE", ModelGuid, GraphicGuid); } else { CString Symbol = GTI.m_sSymbol(); CString GraphicGuid = GTI.m_sGuid(); CString Shape = ExtractShape(Symbol); CString Model = N.m_sClass; CLinePointsArray LPA; LPA.SetSize(0); Grp.m_pDoc->GCB.pDrw->CollectLinkInfo(GTI, LPA); FlwNode * pNode = gs_pSfeSrvr->FE_FindNode(I.m_sTag, NULL); CString ModelGuid = pNode->Guid(); CString SrcMdlGuid = pNode->Nd_Rmt(0)->Guid(); CString SrcGrfGuid = "Grf GUID Fetch Failed"; CString SrcPort = pNode->IODesc_Rmt(0)->IOName(); CString DstMdlGuid = pNode->Nd_Rmt(1)->Guid(); CString DstGrfGuid = "Grf GUID Fetch Failed"; CString DstPort = pNode->IODesc_Rmt(1)->IOName(); DO_ENTRY_GGTPSM("DoCreateLinkE", ModelGuid, GraphicGuid, I.m_sTag, MakePath(projectPath, Grp.m_sTitle),"",""); CExistingItems::CGroupIndex SInx; if (GI.m_TagMap.Lookup(pNode->Nd_Rmt(0)->Tag(), SInx)) SrcGrfGuid = Grp.m_GTIA[SInx.m_iGTIA].m_sGuid(); else LogError("Upgrade2Scd10", 0, "Tag Not in Graphics %s", pNode->Nd_Rmt(0)->Tag()); CExistingItems::CGroupIndex DInx; if (GI.m_TagMap.Lookup(pNode->Nd_Rmt(1)->Tag(), DInx)) DstGrfGuid = Grp.m_GTIA[DInx.m_iGTIA].m_sGuid(); else LogError("Upgrade2Scd10", 0, "Tag Not in Graphics %s", pNode->Nd_Rmt(1)->Tag()); if (dbgConnect()) { dbgpln("%-30s Src Mdl:%s Grf:%s %s", "", SrcMdlGuid, SrcGrfGuid, SrcPort); dbgpln("%-30s Dst Mdl:%s Grf:%s %s", "", DstMdlGuid, DstGrfGuid, DstPort); } CPointFList CtrlPts; for (int i=0; i<LPA.GetCount(); i++) { float PtX = float(int(LPA[i].x+Grp.m_XOff + Grp.m_XShift) + 0.5); // needs to be x.5mm to meet grid in 10. float PtY = float(int(Grp.m_PageRct.Height()-LPA[i].y+Grp.m_YOff - Grp.m_YShift) + 0.5); // needs to be x.5mm to meet grid in 10. CtrlPts.AddTail(CPointF(PtX, PtY)); } float textBoxW = float(int(GTI.m_Tag.m_XScale * 3.0 * GTI.m_sTag.GetLength())); float textBoxH = float(int(GTI.m_Tag.m_YScale * 3.0)); float textBoxX = float(int(GTI.m_Tag.m_X + Grp.m_XOff + Grp.m_XShift - textBoxW / 2.0) + 0.5); // needs to be x.5mm to meet grid in 10. float textBoxY = float(int(Grp.m_PageRct.Height() - GTI.m_Tag.m_Y + Grp.m_YOff - Grp.m_YShift - textBoxH) + 0.5); // needs to be x.5mm to meet grid in 10. m_pCLR->AddCreateLink(m_lRequestIdRet, ModelGuid, GraphicGuid, I.m_sTag, MakePath(projectPath, Grp.m_sSymbol), Model, SrcMdlGuid, DstMdlGuid, SrcGrfGuid, DstGrfGuid, SrcPort, DstPort, CtrlPts, CSvcTagBlk(CRectangleF(textBoxX, textBoxY, textBoxW, textBoxH), (float)-GTI.m_Tag.m_Rotation, GTI.m_Tag.m_Visible!=0)); DO_EXIT_GG("DoCreateLinkE", ModelGuid, GraphicGuid); } // Remove Original Symbol if (GTI.m_Entity) { Grp.m_pDoc->GCB.pDsp->Draw(GTI.m_Entity, GrfHelper.GR_BACKGROUND); Grp.m_pDoc->GCB.pDrw->Delete(GTI.m_Entity); } #if dbgSvcConn if (dbgConnect()) { dbgindent(-4); dbgpln(""); } #endif } // Other Symbols; Pos=GI.m_Groups.GetHeadPosition(); while (Pos) { CExistingItems::CGroup & Grp = *GI.m_Groups.GetNext(Pos); for (int i=0; i<Grp.m_GTIA.GetCount(); i++) { CGrfTagInfo &GTI=Grp.m_GTIA[i]; if (!GTI.m_bDone) { CString Symbol = GTI.m_sSymbol(); CString GraphicGuid = GTI.m_sGuid(); CString Shape = ExtractShape(Symbol); CString Model = "";//N.m_sClass; //FlwNode * pNode = gs_pSfeSrvr->FE_FindNode(GTI.m_sTag, NULL); CString ModelGuid = "";//TaggedObject::CreateGuidStr();//pNode->Guid(); // Cannot be blank DO_ENTRY_GGTPSM("DoDumbSymbolE", ModelGuid, GraphicGuid, GTI.m_sTag(), MakePath(projectPath, Grp.m_sTitle), Shape, Model); float boxW = float(int(GTI.m_HiBnd.m_X-GTI.m_LoBnd.m_X)); float boxH = float(int(GTI.m_HiBnd.m_Y-GTI.m_LoBnd.m_Y)); float boxX = float(int(GTI.m_LoBnd.m_X + Grp.m_XOff + Grp.m_XShift) + 0.5); // needs to be x.5mm to meet grid in 10. float boxY = float(int(Grp.m_PageRct.Height() - GTI.m_HiBnd.m_Y + Grp.m_YOff - Grp.m_YShift) + 0.5); // needs to be x.5mm to meet grid in 10. float textBoxW = float(int(GTI.m_Tag.m_XScale * 3.0 * GTI.m_sTag.GetLength())); float textBoxH = float(int(GTI.m_Tag.m_YScale * 3.0)); float textBoxX = float(int(GTI.m_Tag.m_X + Grp.m_XOff + Grp.m_XShift - textBoxW / 2.0) + 0.5); // needs to be x.5mm to meet grid in 10. float textBoxY = float(int(Grp.m_PageRct.Height() - GTI.m_Tag.m_Y + Grp.m_YOff - Grp.m_YShift - textBoxH) + 0.5); // needs to be x.5mm to meet grid in 10. m_pCLR->AddCreateNode(m_lRequestIdRet, ModelGuid, GraphicGuid, GTI.m_sTag(), MakePath(projectPath, Grp.m_sTitle), Model, Shape, CRectangleF(boxX, boxY, boxW, boxH), CPointF(1.0,1.0), GTI.m_Node.m_Rotation, CSvcTagBlk(CRectangleF(textBoxX, textBoxY, textBoxW, textBoxH), (float)-GTI.m_Tag.m_Rotation, (float)GTI.m_Tag.m_Visible!=0), COLORREF(0), false, false); DO_EXIT_GG("DoDumbSymbolE", ModelGuid, GraphicGuid); // Remove Original Symbol if (GTI.m_Entity) { Grp.m_pDoc->GCB.pDsp->Draw(GTI.m_Entity, GrfHelper.GR_BACKGROUND); Grp.m_pDoc->GCB.pDrw->Delete(GTI.m_Entity); } } } } m_pCLR->ProcessChangeListsHold(false); if (!m_pCLR->ProcessChangeLists(m_lRequestIdRet)) { _asm int 3; // Some Error occurred } } m_Ctrl.m_bExportBusy = false; }; void CSvcConnect::Attach2Scd10() { m_pCLR->Attach2Scd10(); }; //======================================================================== void CSvcConnect::Load() { m_pCLR->Load(); }; void CSvcConnect::Save() { m_pCLR->Save(); }; void CSvcConnect::SaveAs(LPCSTR name, LPCSTR path) { m_pCLR->SaveAs(name, path); }; //======================================================================== void CSvcConnect::LogMessage(DWORD Type, LPCSTR Msg) { m_pCLR->LogMessage(Type, Msg); }; void CSvcConnect::dbgPrintLn(LPCSTR Fmt, LPCSTR S0, LPCSTR S1, LPCSTR S2, LPCSTR S3, LPCSTR S4) { dbgpln((LPSTR)Fmt, S0, S1, S2, S3, S4); }; void CSvcConnect::DoOpenProject(LPCSTR tag, LPCSTR path) { CString Fn(path); Fn+="\\Project.spj"; gs_pPrj->DoOpen((LPSTR)(LPCSTR)Fn, "", PLT_Normal); int xxx=0; }; void CSvcConnect::Remove9Graphics() { gs_pPrj->Remove9Graphics(); } //======================================================================== void CSvcConnect::OnCreateGroup(__int64 eventId, __int64 requestId, LPCSTR guid, LPCSTR tag, LPCSTR path, const CRectangleF & boundingRect) { CsGrfGroup * pG = new CsGrfGroup; pG->m_Guid=guid; pG->m_Name=tag; pG->m_Path=path; pG->m_Bounds=boundingRect; m_GrfGrpsNames.SetAt(pG->m_Name, pG); m_GrfGrpsGuids.SetAt(pG->m_Guid, pG); }; //======================================================================== // // // //======================================================================== CString CSvcConnect::MakePath(LPCSTR Part1, LPCSTR Part2, LPCSTR Part3) { CString S("/"); if (Part1) { S+=Part1; S+="/"; } if (Part2) { S+=Part2; S+="/"; } if (Part3) { S+=Part3; S+="/"; } return S; }; CString CSvcConnect::ExtractPageName(LPCSTR Path) { CString Pg(Path); // find endof Path int n=0; for (int i=0; i<Pg.GetLength(); i++) if (Pg[i]=='/') n++; if (n>=2) { // Assume Page is last delimited string for (i=0; i<n-1; i++) Pg.Delete(0, Pg.Find('/')+1); Pg.Delete(Pg.Find('/'), 1000); } // Error Checking ????????? return Pg; } CGrfDoc * CSvcConnect::FindGrfDoc(LPCSTR PageName) { CGrfDoc * pDoc=dynamic_cast<CGrfDoc*>(GetGrfDoc(-1, PageName && strlen(PageName)>0?PageName:NULL)); // Error Checking ????????? return pDoc; } CGrfWnd * CSvcConnect::FindGrfWnd(LPCSTR PageName) { CGrfDoc * pDoc=dynamic_cast<CGrfDoc*>(GetGrfDoc(-1, PageName && strlen(PageName)>0?PageName:NULL)); if (pDoc) { POSITION pos = pDoc->GetFirstViewPosition(); CView* pFirstView = pDoc->GetNextView( pos ); return (CGrfWnd*)pFirstView; } return NULL; } CRectangleF CSvcConnect::GetPageRect(LPCSTR PageName) { CRectangleF PageRct(0.0, 420, 0, 297); CsGrfGroup *pG; if (PageName&& m_GrfGrpsNames.Lookup(PageName, pG)) { PageRct = pG->m_Bounds; } return PageRct; } CRectangleF CSvcConnect::GetContainingPageRect(const CRectangleF & rct) { POSITION Pos=m_GrfGrpsNames.GetStartPosition(); while (Pos) { LPCSTR Key; CsGrfGroup *pG; m_GrfGrpsNames.GetNextAssoc(Pos, Key, pG); if (pG->m_Bounds.Contains(rct, true)) return pG->m_Bounds; } return CRectangleF(0.0, 0, 0, 0); } CsGrfGroup * CSvcConnect::GetContainingGroup(const CRectangleF & rct) { POSITION Pos=m_GrfGrpsNames.GetStartPosition(); while (Pos) { LPCSTR Key; CsGrfGroup *pG; m_GrfGrpsNames.GetNextAssoc(Pos, Key, pG); if (pG->m_Bounds.Contains(rct, true)) return pG; } return NULL; }; CString CSvcConnect::ExtractShape(LPCSTR Symbol) { CString Shape(Symbol); int iSep=Shape.FindOneOf("$:"); if (iSep>=0) { // Old Fmt //Shape.Delete(0, iSep+1); // New Shape.SetAt(iSep, '/'); } return Shape; } //======================================================================== // // // //======================================================================== void CSvcConnect::GCBCreateGroup(LPCSTR Guid, LPCSTR Prj, LPCSTR Page, const CRectangleF & boundingRect) { DO_ENTRY_GTP("GCBCreateGroup", Guid, "--", MakePath(Prj, Page)); CDocTemplate & GrfTemplate = ScdApp()->GraphTemplate(); //ASSERT(pTemplate_ != NULL); gs_pPrj->bDoingLoad=true; CGrfDoc * pDoc = (CGrfDoc *)GrfTemplate.OpenDocumentFile(NULL); gs_pPrj->bDoingLoad=false; if (pDoc) { pDoc->SetTitle(Page); OnCreateGroup(-1/*eventId*/, -1/*requestId*/, Guid, Page, Prj, boundingRect); //pDoc->m } DO_EXIT("GCBCreateGroup"); } //======================================================================== // // // //======================================================================== void CSvcConnect::GCBCreateNode(CGrfDoc *pDoc, LPCSTR Prj, LPCSTR Page, LPCSTR Tag, LPCSTR Symbol, LPCSTR ClassId, Pt_3f Pt, Pt_3f Scl, float Angle) { double Width=0; //FIX double Height=0; Angle = - Angle; // Reverse Angle; CRectangleF PageRct = GetPageRect(Page); CRectangleF boundingRect(PageRct.Left()+Pt.x()-0.5*Width*Scl.X,PageRct.Top()-Pt.y()-0.5*Height*Scl.Y,Width*Scl.X, Height*Scl.Y); // TO Fix //CString Shape = ExtractShape(ClassId);//Symbol); CString Shape = ExtractShape(Symbol); CString ModelGuid = TaggedObject::CreateGuidStr(); CString GraphicGuid = TaggedObject::CreateGuidStr(); DO_ENTRY_GGTPSM("GCBCreateNode", GraphicGuid, ModelGuid, Tag, MakePath(Prj, Page), Shape, ClassId); CRectangleF textBox(boundingRect.MidX(), boundingRect.Top(), 2.0f*strlen(Tag), 3.0f); m_pCLR->AddCreateNode(m_lRequestIdRet, ModelGuid, GraphicGuid, Tag, MakePath(Prj, Page), ClassId, Shape, boundingRect, CPointF(Scl.X, Scl.Y), Angle, CSvcTagBlk(textBox, 0.0, true), 0, false, false); // !!! tagArea not used. if (!m_pCLR->ProcessChangeLists(m_lRequestIdRet)) { LogError(NETSERVERNAME, 0, "GCBCreateNode:CreateChangelist not processed!"); } DO_EXIT_GG("GCBCreateNode", ModelGuid, GraphicGuid); }; //------------------------------------------------------------------------ void CSvcConnect::OnCreateNodeG(__int64 eventId, __int64 requestId, CSvcHeaderBlk & Header, CSvcNdGBlk & NdGBlk, CSvcTagBlk & TagBlk) { ON_ENTRY_GTPSM("OnCreateNodeG", Header.m_Guid, Header.m_Tag, Header.m_Path, NdGBlk.m_Shape, Header.m_ClassId); try { CString PageName=CSvcConnect::ExtractPageName(Header.m_Path); m_Ctrl.SetXObjArray(FindGrfWnd(PageName)); int RetCode = gs_Exec.SCInsertNodeG(m_Ctrl, Header, NdGBlk, TagBlk); if (RetCode!=EOSC_DONE) { LogError(NETSERVERNAME, 0, "CreateNodeGraphic '%s' failed!", Header.m_Tag); } } catch(...) { LogError(NETSERVERNAME, 0, "Exception in CreateNodeGraphic '%s'", Header.m_Tag); } ON_EXIT_G("OnCreateNodeG", Header.m_Guid); } //------------------------------------------------------------------------ void CSvcConnect::OnCreateNodeM(__int64 eventId, __int64 requestId, CSvcHeaderBlk & Header) { ON_ENTRY_GTM("OnCreateNodeM", Header.m_Guid, Header.m_Tag, Header.m_ClassId); try { m_Ctrl.SetXObjArray(gs_pTheSFELib); int RetCode = gs_Exec.SCInsertNodeM(m_Ctrl, Header); if (RetCode!=EOSC_DONE) { LogError(NETSERVERNAME, 0, "CreateNodeModel '%s' failed!", Header.m_Tag); } } catch(...) { LogError(NETSERVERNAME, 0, "Exception in CreateNodeModel '%s'", Header.m_Tag); } ON_EXIT_G("OnCreateNodeM", Header.m_Guid); } void CSvcConnect::OnDeleteNodeM(__int64 eventId, __int64 requestId, CSvcHeaderBlk & Header) { Strng Tag; flag IsLink; if (gs_pPrj->FindNodeInfoFromGuid((LPSTR)Header.m_Guid, Tag, IsLink)) { if (!IsLink) { ON_ENTRY_GT("OnDeleteNodeM", Header.m_Guid, Tag()); try { m_Ctrl.SetXObjArray(gs_pTheSFELib); Header.m_Tag=Tag(); int RetCode = gs_Exec.SCDeleteNodeM(m_Ctrl, Header); if (RetCode!=EOSC_DONE) { LogError(NETSERVERNAME, 0, "DeleteNodeModel '%s' failed!", Tag()); } } catch(...) { LogError(NETSERVERNAME, 0, "Exception in DeleteNodeModel '%s'", Tag()); } ON_EXIT_G("OnDeleteNodeM", Header.m_Guid); } } } //------------------------------------------------------------------------ // //------------------------------------------------------------------------ void CSvcConnect::GCBDeleteNode(DXF_ENTITY eEntity, LPCSTR GraphicGuid) { DO_ENTRY_GT("GCBDeleteNode", GraphicGuid, ""); m_pCLR->AddDeleteNode(m_lRequestIdRet, GraphicGuid); DO_EXIT("GCBDeleteNode"); } //------------------------------------------------------------------------ void CSvcConnect::OnDeleteNodeG(__int64 eventId, __int64 requestId, CSvcHeaderBlk & Header) { Strng Tag; flag IsLink; Strng_List Pages; if (gs_pPrj->FindNodeInfoFromGuid((LPSTR)Header.m_Guid, Tag, IsLink)) { if (!IsLink) { ON_ENTRY_GT("OnDeleteNodeG", Header.m_Guid, ""); m_Ctrl.ClrXObjArray(); Header.m_Tag=Tag(); int RetCode = gs_Exec.SCDeleteNodeG(m_Ctrl, Header); if (RetCode!=EOSC_DONE) { LogError(Tag(), 0, "Model not deleted"); //DeletesFailedCnt++; } ON_EXIT("OnDeleteNodeG"); } else { // Links should be deleted by OnDeleteLink } } //else // { // // ... Error // } }; //------------------------------------------------------------------------ // //------------------------------------------------------------------------ void CSvcConnect::GCBModifyNodeG(CGrfDoc *pDoc, LPCSTR Prj, LPCSTR Page, DXF_ENTITY eEntity, LPCSTR GraphicGuid, Pt_3f DeltaPos, Pt_3f DeltaScl, double DeltaRot) { DO_ENTRY_GT("GCBModifyNodeG", GraphicGuid, "");//Tag); DeltaPos.Y=-DeltaPos.Y; // Y is inverted m_pCLR->AddModifyNodeG(m_lRequestIdRet, GraphicGuid, DeltaPos, DeltaScl, DeltaRot); DO_EXIT("GCBModifyNodeG"); }; //------------------------------------------------------------------------ void CSvcConnect::GCBModifyNodeSymbol(CGrfDoc *pDoc, LPCSTR Prj, LPCSTR Page, DXF_ENTITY eEntity, LPCSTR GraphicGuid, LPCSTR Symbol) { DO_ENTRY_GT("GCBModifyNodeSymbol", GraphicGuid, Symbol);//Tag); //Delta.Y=-Delta.Y; // Y is inverted CString Shape = ExtractShape(Symbol); m_pCLR->AddModifyNodeSymbol(m_lRequestIdRet, GraphicGuid, Shape); DO_EXIT("GCBModifyNodeSymbol"); }; //------------------------------------------------------------------------ void CSvcConnect::GCBModifyTagG(CGrfDoc *pDoc, LPCSTR Prj, LPCSTR Page, DXF_ENTITY eEntity, LPCSTR GraphicGuid, Pt_3f Delta, CSvcTagBlk & TagBlk) { DO_ENTRY_GT("GCBModifyTagG", GraphicGuid, "");//Tag); Delta.Y=-Delta.Y; // Y is inverted m_pCLR->AddModifyTagG(m_lRequestIdRet, GraphicGuid, Delta, TagBlk); DO_EXIT("GCBModifyTagG"); }; //------------------------------------------------------------------------ void CSvcConnect::OnModifyNodeG(__int64 eventId, __int64 requestId, CSvcHeaderBlk & Header, CSvcNdGBlk & NdGBlk, CSvcTagBlk & TagBlk) { ON_ENTRY_GT("OnModifyNodeG", Header.m_Guid, Header.m_Tag); CString PageName=CSvcConnect::ExtractPageName(Header.m_Path); m_Ctrl.SetXObjArray(FindGrfWnd(PageName)); int RetCode = gs_Exec.SCModifyNodeG(m_Ctrl, Header, NdGBlk, TagBlk); if (RetCode!=EOSC_DONE) { LogError(Header.m_Tag, 0, "Model not modified"); //DeletesFailedCnt++; } else { } ON_EXIT("OnModifyNodeG"); }; //------------------------------------------------------------------------ void CSvcConnect::OnModifyNodeM(__int64 eventId, __int64 requestId, CSvcHeaderBlk & Header) { ON_ENTRY_GT("OnModifyNodeM", Header.m_Guid, Header.m_Tag); int RetCode = gs_Exec.SCModifyNodeM(m_Ctrl, Header); if (RetCode!=EOSC_DONE) { LogError(Header.m_Tag, 0, "Model not modified"); //DeletesFailedCnt++; } else { } ON_EXIT("OnModifyNodeM"); }; //======================================================================== // // // //======================================================================== void CSvcConnect::GCBCreateLink(CGrfDoc *pDoc, LPCSTR Prj, LPCSTR Page, LPCSTR Tag, LPCSTR ClassId, LPCSTR SrcGrfGuid, LPCSTR DstGrfGuid, LPCSTR SrcMdlGuid, LPCSTR DstMdlGuid, LPCSTR SrcPort, LPCSTR DstPort, CPointFList & ControlPoints)//, const CRectangleF & tagArea) { double Width=20; double Height=20; CRectangleF PageRct = GetPageRect(Page); //CRectangleF boundingRect(Pt.x()-0.5*Width,PageRct.Top()-Pt.y()-0.5*Height,Width, Height); // TO Fix //CString Shape = ExtractShape(ClassId);//Symbol); CString ModelGuid = TaggedObject::CreateGuidStr(); CString GraphicGuid = TaggedObject::CreateGuidStr(); //CString ModelGuid = pNode->Guid(); //CString SrcMdlGuid = pNode->Nd_Rmt(0)->Guid(); //CString SrcGrfGuid = "Grf GUID Fetch Failed"; //CString SrcPort = pNode->IODesc_Rmt(0)->IOName(); //CString DstMdlGuid = pNode->Nd_Rmt(1)->Guid(); //CString DstGrfGuid = "Grf GUID Fetch Failed"; //CString DstPort = pNode->IODesc_Rmt(1)->IOName(); //DO_ENTRY_GGTPSM("DoCreateLinkE", GraphicGuid, ModelGuid, I.m_sTag, MakePath(projectPath, Grp.m_sTitle),"",""); //CExistingItems::CGroupIndex SInx; //if (GI.m_TagMap.Lookup(pNode->Nd_Rmt(0)->Tag(), SInx)) // SrcGrfGuid = Grp.m_GTIA[SInx.m_iGTIA].m_sGuid(); //else // LogError("Upgrade2Scd10", 0, "Tag Not in Graphics %s", pNode->Nd_Rmt(0)->Tag()); //CExistingItems::CGroupIndex DInx; //if (GI.m_TagMap.Lookup(pNode->Nd_Rmt(1)->Tag(), DInx)) // DstGrfGuid = Grp.m_GTIA[DInx.m_iGTIA].m_sGuid(); //else // LogError("Upgrade2Scd10", 0, "Tag Not in Graphics %s", pNode->Nd_Rmt(1)->Tag()); //FlwNode * pSrc = gs_pSfeSrvr->FE_FindNode(SrcTag, NULL); //FlwNode * pDst = gs_pSfeSrvr->FE_FindNode(DstTag, NULL); DO_ENTRY_GTP("GCBCreateLink", "NULL-Guid", Tag, MakePath(Prj, Page)); CString GuidRet; CPointF tagPos; CPointF prevPt; double LongSegLen=0; int SegCount=0; POSITION Pos=ControlPoints.GetHeadPosition(); while (Pos) { CPointF & Pt=ControlPoints.GetNext(Pos); Pt.Set(PageRct.Left()+Pt.X(),PageRct.Top()-Pt.Y()); if (++SegCount>=2) { double SegLen = Sqr(Pt.X()-prevPt.X())+Sqr(Pt.Y()-prevPt.Y()); if (SegLen>LongSegLen) { LongSegLen=SegLen; tagPos.Set(0.5*(Pt.X()+prevPt.X()), 0.5*(Pt.Y()+prevPt.Y())); } } prevPt=Pt; } //CRectangleF textBox;//boundingRect.MidX(), boundingRect.Top(), 2.0*strlen(Tag), 3.0f); CRectangleF textBox(tagPos.X(), tagPos.Y(), 2.0f*strlen(Tag), 3.0f); m_pCLR->AddCreateLink(m_lRequestIdRet, ModelGuid, GraphicGuid, Tag, MakePath(Prj, Page), ClassId, SrcMdlGuid, DstMdlGuid, SrcGrfGuid, DstGrfGuid, SrcPort, DstPort, ControlPoints, CSvcTagBlk(textBox, 0.0, false)); if (!m_pCLR->ProcessChangeLists(m_lRequestIdRet)) { LogError(NETSERVERNAME, 0, "GCBCreateLink:CreateChangelist not processed!"); } DO_EXIT_G("GCBCreateLink", GuidRet); }; //------------------------------------------------------------------------ void CSvcConnect::OnCreateLinkG(__int64 eventId, __int64 requestId, CSvcHeaderBlk & Header, CSvcGuidPair & Guids, CPointFList & ControlPoints, CSvcTagBlk & TagBlk) { // !!! tagArea not handled as yet. ON_ENTRY_GT("OnCreateLinkG", Header.m_Guid, Header.m_Tag); #if WITHDBGLINES if (dbgConnect()) { dbgpln(" Src:%s", Guids.m_OriginGuid); dbgpln(" Dst:%s", Guids.m_DestinationGuid); } #endif try { FlwNode * pSrc = gs_pSfeSrvr->FE_FindNode(NULL, Guids.m_OriginGuid); FlwNode * pDst = gs_pSfeSrvr->FE_FindNode(NULL, Guids.m_DestinationGuid); CRectangleF boundingRect; POSITION Pos=ControlPoints.GetHeadPosition(); if (Pos) { boundingRect.Set(ControlPoints.GetNext(Pos)); while (Pos) boundingRect.Include(ControlPoints.GetNext(Pos), false); } CsGrfGroup * pGrp=CSvcConnect::GetContainingGroup(boundingRect); m_Ctrl.ClrXObjArray(); if (pGrp) { CString GroupName=pGrp->m_Name; m_Ctrl.SetXObjArray(FindGrfWnd(GroupName)); } int RetCode = gs_Exec.SCInsertLinkG(m_Ctrl, Header, CSvcLnkGBlk(Guids.m_OriginGuid, Guids.m_DestinationGuid, pSrc?pSrc->Tag():"", pDst?pDst->Tag():""), ControlPoints, TagBlk); if (RetCode!=EOSC_DONE) { LogError(NETSERVERNAME, 0, "CreateLink '%s' failed!", Header.m_Tag); //return Scd.Return(eScdGraphicCode_GrfNotCreated, "AddUnit '%s' failed!", Tag); } } catch(...) { LogError(NETSERVERNAME, 0, "Exception in CreateUnit '%s'", Header.m_Tag); } ON_EXIT_G("OnCreateLinkG", Header.m_Guid); }; //------------------------------------------------------------------------ void CSvcConnect::OnCreateLinkM(__int64 eventId, __int64 requestId, CSvcHeaderBlk & Header, CSvcGuidPair & Guids, LPCSTR OriginPort, LPCSTR DestinationPort) { // !!! tagArea not handled as yet. ON_ENTRY_GT("OnCreateLinkM", Header.m_Guid, Header.m_Tag); try { FlwNode * pSrc = gs_pSfeSrvr->FE_FindNode(NULL, Guids.m_OriginGuid); FlwNode * pDst = gs_pSfeSrvr->FE_FindNode(NULL, Guids.m_DestinationGuid); #if WITHDBGLINES dbgpln("Guids:%-40s %-40s", Guids.m_OriginGuid, Guids.m_DestinationGuid); dbgpln("Tags :%-40s %-40s", pSrc?pSrc->Tag():"", pDst?pDst->Tag():""); dbgpln("Ports:%-40s %-40s", OriginPort, DestinationPort); #endif m_Ctrl.SetXObjArray(gs_pTheSFELib); int RetCode = gs_Exec.SCInsertLinkM(m_Ctrl, Header, CSvcLnkMBlk(Guids.m_OriginGuid, Guids.m_DestinationGuid, pSrc?pSrc->Tag():"", pDst?pDst->Tag():"", OriginPort, DestinationPort)); if (RetCode!=EOSC_DONE) { LogError(NETSERVERNAME, 0, "CreateLink '%s' failed!", Header.m_Tag); //return Scd.Return(eScdGraphicCode_GrfNotCreated, "AddUnit '%s' failed!", Tag); } } catch(...) { LogError(NETSERVERNAME, 0, "Exception in CreateUnit '%s'", Header.m_Tag); } ON_EXIT_G("OnCreateLinkM", Header.m_Guid); }; //------------------------------------------------------------------------ // //------------------------------------------------------------------------ void CSvcConnect::GCBDeleteLink(DXF_ENTITY eEntity, LPCSTR GraphicGuid) { DO_ENTRY_GT("GCBDeleteLink", GraphicGuid, ""); m_pCLR->AddDeleteLink(m_lRequestIdRet, GraphicGuid); DO_EXIT("GCBDeleteLink"); } //------------------------------------------------------------------------ void CSvcConnect::OnDeleteLinkM(__int64 eventId, __int64 requestId, CSvcHeaderBlk & Header) { Strng Tag; flag IsLink; Strng_List Pages; if (gs_pPrj->FindNodeInfoFromGuid((LPSTR)Header.m_Guid, Tag, IsLink)) { if (IsLink) { ON_ENTRY_GT("OnDeleteLinkM", Header.m_Guid, ""); m_Ctrl.ClrXObjArray(); Header.m_Tag=Tag(); int RetCode = gs_Exec.SCDeleteLinkM(m_Ctrl, Header); if (RetCode!=EOSC_DONE) { LogError(Tag(), 0, "Link not deleted"); //DeletesFailedCnt++; } ON_EXIT("OnDeleteLinkM"); } else { // Links should be deleted by OnDeleteLink } } }; //------------------------------------------------------------------------ void CSvcConnect::OnDeleteLinkG(__int64 eventId, __int64 requestId, CSvcHeaderBlk & Header) { Strng Tag; //flag IsLink; Strng_List Pages; if (1)//gs_pPrj->FindNodeInfoFromGuid((LPSTR)Guid, Tag, IsLink)) { if (1)//IsLink) { ON_ENTRY_GT("OnDeleteLinkG", Header.m_Guid, ""); m_Ctrl.ClrXObjArray(); int RetCode = gs_Exec.SCDeleteLinkG(m_Ctrl, Header); if (RetCode!=EOSC_DONE) { LogError(Tag(), 0, "Link not deleted"); //DeletesFailedCnt++; } ON_EXIT("OnDeleteLinkG"); } else { // Links should be deleted by OnDeleteLink } } }; //------------------------------------------------------------------------ // //------------------------------------------------------------------------ void CSvcConnect::GCBModifyLinkPts(CGrfDoc *pDoc, LPCSTR Prj, LPCSTR Page, DXF_ENTITY eEntity, LPCSTR GraphicGuid, CPointFList & ControlPoints) { //Strng Guid; //if (gs_pPrj->GetNodeGuid((LPSTR)Tag, Guid)) // { DO_ENTRY_GT("GCBModifyLinkPts", GraphicGuid, ""); CRectangleF PageRct = GetPageRect(Page); //FlwNode * pLink = gs_pSfeSrvr->FE_FindNode(Tag, NULL); //LPSTR pClass = pLink->ClassId(); //FlwNode * pSrcNd = pLink->Nd_Rmt(0); //LPSTR pSrcIO = pLink->IOArea_Rmt(0).IOName(); //FlwNode * pDstNd = pLink->Nd_Rmt(1); //LPSTR pDstIO = pLink->IOArea_Rmt(1).IOName(); POSITION Pos=ControlPoints.GetHeadPosition(); while (Pos) { CPointF &Pt=ControlPoints.GetNext(Pos); Pt.Set(PageRct.Left()+Pt.X(),PageRct.Top()-Pt.Y()); } //m_pCLR->AddModifyLink(m_lRequestIdRet, Guid(), Tag, "?Path?", pClass, pSrcNd->Guid(), pDstNd->Guid(), pSrcIO, pDstIO, ControlPoints, tagArea, tagAngle); m_pCLR->AddModifyLinkPts(m_lRequestIdRet, GraphicGuid, ControlPoints); DO_EXIT("GCBModifyLinkPts"); // } //else // { // } } //------------------------------------------------------------------------ void CSvcConnect::OnModifyLinkG(__int64 eventId, __int64 requestId, \ CSvcHeaderBlk & Header, CSvcGuidPair & Guids, CPointFList & ControlPoints, CSvcTagBlk & TagBlk) { ON_ENTRY_GT("OnModifyLinkG", Header.m_Guid, Header.m_Tag); CRectangleF boundingRect; POSITION Pos=ControlPoints.GetHeadPosition(); if (Pos) { boundingRect.Set(ControlPoints.GetNext(Pos)); while (Pos) boundingRect.Include(ControlPoints.GetNext(Pos), false); } CsGrfGroup * pGrp=CSvcConnect::GetContainingGroup(boundingRect); m_Ctrl.ClrXObjArray(); //m_Ctrl.SetXObjArray(gs_pTheSFELib); if (pGrp) { CString GroupName=pGrp->m_Name; m_Ctrl.SetXObjArray(FindGrfWnd(GroupName)); } int RetCode = gs_Exec.SCModifyLinkG(m_Ctrl, Header, Guids, ControlPoints, TagBlk); if (RetCode!=EOSC_DONE) { LogError(Header.m_Tag, 0, "Link not modified"); //DeletesFailedCnt++; } else { } ON_EXIT("OnModifyLinkG"); }; //------------------------------------------------------------------------ void CSvcConnect::OnModifyLinkM(__int64 eventId, __int64 requestId, \ CSvcHeaderBlk & Header, CSvcLnkMBlk & LnkMBlk) { ON_ENTRY_GT("OnModifyLinkM", Header.m_Guid, Header.m_Tag); FlwNode * pSrc = gs_pSfeSrvr->FE_FindNode(NULL, LnkMBlk.m_OriginGuid); FlwNode * pDst = gs_pSfeSrvr->FE_FindNode(NULL, LnkMBlk.m_DestinationGuid); m_Ctrl.SetXObjArray(gs_pTheSFELib); int RetCode = gs_Exec.SCModifyLinkM(m_Ctrl, Header, CSvcLnkMBlk(LnkMBlk.m_OriginGuid, LnkMBlk.m_DestinationGuid, pSrc->Tag(), pDst->Tag(), LnkMBlk.m_OriginPort, LnkMBlk.m_DestinationPort)); if (RetCode!=EOSC_DONE) { LogError(Header.m_Tag, 0, "Link not modified"); //DeletesFailedCnt++; } else { } ON_EXIT("OnModifyLinkM"); }; //======================================================================== // // Export Stuff // //======================================================================== static struct CPageSizeInfo {LPCSTR Nm; float Scl;} s_PgInfo[]= { {"A5", 0.5f}, {"A4", 0.7071f}, {"A3", 1.0f}, {"A2", 1.4142f}, {"A1", 2.0f}, {0} }; CExistingItems::CExistingItems() { m_nPages=0; m_PageMap.InitHashTable(201); m_TagMap.InitHashTable(20001); }; bool CExistingItems::Get() { m_nPages=0; CDocTemplate & GrfTemplate(ScdApp()->GraphTemplate()); m_PageMap.InitHashTable(201); m_TagMap.InitHashTable(20001); POSITION Pos = GrfTemplate.GetFirstDocPosition(); float MaxPageW=0; float MaxPageH=0; while (Pos) { CGrfDoc * pDoc=dynamic_cast<CGrfDoc*>(GrfTemplate.GetNextDoc(Pos)); m_Groups.AddTail(new CGroup(pDoc->GetTitle(), m_nPages++, pDoc)); CGroup &Grp=*m_Groups.GetTail(); double PageX = 0; double PageY = 0; double PageW = Grp.m_pDoc->GCB.pDrw->PageWidth();//420; double PageH = Grp.m_pDoc->GCB.pDrw->PageHeight();//297; double PageXShift = 0; double PageYShift = 0; if (Grp.m_pDoc->GCB.pDrw->GetBounds()) { double DrwX = C3_MIN_X(&Grp.m_pDoc->GCB.pDrw->m_Bounds); double DrwY = C3_MIN_Y(&Grp.m_pDoc->GCB.pDrw->m_Bounds); double DrwW = C3_MAX_X(&Grp.m_pDoc->GCB.pDrw->m_Bounds) - DrwX; double DrwH = C3_MAX_Y(&Grp.m_pDoc->GCB.pDrw->m_Bounds) - DrwY; if (DrwW>PageW*1.02 || DrwH>PageH*1.02) { // Page too small !!! bool FoundPageSz=false; for (int i=0; s_PgInfo[i].Nm; i++) { double Scl=s_PgInfo[i].Scl; double PgW=s_PgInfo[i].Scl*420; double PgH=s_PgInfo[i].Scl*297; if (DrwW<=PgW*1.02 && DrwH<=PgH*1.02) { PageW=PgW; PageH=PgH; FoundPageSz=true; break; } } } if (DrwX<0.0 || DrwX+DrwW>PageW) PageXShift = -(DrwX+0.5*DrwW-0.5*PageW); if (DrwY<0.0 || DrwY+DrwH>PageH) PageYShift = -(DrwY+0.5*DrwH-0.5*PageH); Grp.m_XShift=(float)PageXShift; Grp.m_YShift=(float)PageYShift; int xxx=0; //if (!FoundPageSz) // { // PageX += (PageW-DrwW)*0.5; // PageY += (PageH-DrwH)*0.5; // } } else { } Grp.m_PageRct.Set(PageX, PageY, PageW, PageH); MaxPageW=float(Max(MaxPageW, PageW)); MaxPageH=float(Max(MaxPageH, PageH)); } Pos=m_Groups.GetHeadPosition(); while (Pos) { CGroup & Grp=*m_Groups.GetNext(Pos); int NAcross=Max(1,int(Sqrt((double)m_nPages)+0.5)); Grp.m_XOff=(Grp.m_No%NAcross)*MaxPageW*1.05f; Grp.m_YOff=(Grp.m_No/NAcross)*MaxPageH*1.05f; m_PageMap.SetAt(Grp.m_sTitle, &Grp); bool DoAllInserts=true; long nInArray = Grp.m_pDoc->GetTagListInfo(DoAllInserts, Grp.m_GTIA); for (long i=0; i<nInArray; i++) { CGroupIndex Inx; CGrfTagInfo & I=Grp.m_GTIA[i]; if (!m_TagMap.Lookup(I.m_sTag(), Inx)) { Inx.m_pGrp=&Grp; Inx.m_iGTIA=i; m_TagMap.SetAt(I.m_sTag(), Inx); dbgpln("TagMap %-20s %-20s %-20s %-20s %-20s", I.m_sTag(), I.m_sClass(), I.m_sSymbol(), I.m_sTag(), I.m_sDrwGroup()); } } } long iRet=gs_pPrj->m_pFlwLib->FE_GetNodeList(m_Nodes); Pos=m_Nodes.GetHeadPosition(); while (Pos) { CNodeListItem &I=m_Nodes.GetNext(Pos); m_Items.AddTail(new CItem(I.m_sTag, &I)); dbgpln("Item %s", I.m_sTag); } return true; } //------------------------------------------------------------------------ CExistingItems::~CExistingItems() { while (m_Groups.GetCount()) delete m_Groups.RemoveTail(); while (m_Items.GetCount()) delete m_Items.RemoveTail(); } //======================================================================== // // // //======================================================================== #endif //========================================================================
[ [ [ 1, 14 ], [ 16, 47 ], [ 49, 54 ], [ 56, 81 ], [ 83, 95 ], [ 97, 102 ], [ 104, 106 ], [ 108, 111 ], [ 113, 114 ], [ 116, 142 ], [ 144, 182 ], [ 184, 190 ], [ 192, 205 ], [ 207, 225 ], [ 227, 229 ], [ 231, 231 ], [ 234, 247 ], [ 249, 253 ], [ 255, 256 ], [ 262, 262 ], [ 264, 298 ], [ 304, 306 ], [ 308, 308 ], [ 310, 310 ], [ 313, 313 ], [ 316, 316 ], [ 318, 319 ], [ 322, 328 ], [ 331, 331 ], [ 333, 334 ], [ 336, 336 ], [ 338, 343 ], [ 345, 346 ], [ 348, 350 ], [ 352, 353 ], [ 357, 357 ], [ 359, 359 ], [ 362, 362 ], [ 366, 367 ], [ 371, 372 ], [ 376, 380 ], [ 382, 382 ], [ 384, 385 ], [ 389, 390 ], [ 392, 392 ], [ 395, 395 ], [ 397, 397 ], [ 406, 408 ], [ 412, 412 ], [ 414, 414 ], [ 418, 418 ], [ 421, 421 ], [ 424, 426 ], [ 429, 431 ], [ 433, 434 ], [ 436, 438 ], [ 447, 452 ], [ 454, 460 ], [ 462, 462 ], [ 465, 519 ], [ 521, 521 ], [ 523, 523 ], [ 527, 528 ], [ 533, 533 ], [ 535, 548 ], [ 554, 645 ], [ 647, 656 ], [ 658, 670 ], [ 672, 735 ], [ 737, 748 ], [ 751, 762 ], [ 764, 771 ], [ 773, 775 ], [ 778, 778 ], [ 782, 784 ], [ 787, 789 ], [ 791, 792 ], [ 796, 798 ], [ 801, 809 ], [ 811, 817 ], [ 819, 820 ], [ 823, 831 ], [ 833, 834 ], [ 836, 844 ], [ 846, 849 ], [ 851, 872 ], [ 874, 877 ], [ 879, 885 ], [ 887, 962 ], [ 964, 964 ], [ 968, 970 ], [ 972, 972 ], [ 974, 975 ], [ 977, 977 ], [ 979, 980 ], [ 983, 994 ], [ 996, 1067 ], [ 1069, 1080 ], [ 1082, 1109 ], [ 1111, 1113 ], [ 1115, 1125 ], [ 1127, 1134 ], [ 1138, 1139 ], [ 1142, 1142 ], [ 1144, 1144 ], [ 1146, 1146 ], [ 1148, 1149 ], [ 1151, 1155 ], [ 1159, 1160 ], [ 1163, 1164 ], [ 1166, 1166 ], [ 1168, 1168 ], [ 1170, 1172 ], [ 1174, 1198 ], [ 1200, 1203 ], [ 1205, 1206 ], [ 1208, 1208 ], [ 1211, 1211 ], [ 1213, 1214 ], [ 1216, 1216 ], [ 1218, 1218 ], [ 1221, 1221 ], [ 1225, 1226 ], [ 1228, 1228 ], [ 1230, 1230 ], [ 1232, 1234 ], [ 1237, 1280 ], [ 1282, 1329 ], [ 1332, 1332 ], [ 1335, 1340 ], [ 1343, 1344 ], [ 1349, 1359 ], [ 1361, 1458 ], [ 1461, 1497 ], [ 1499, 1523 ] ], [ [ 15, 15 ], [ 48, 48 ], [ 55, 55 ], [ 82, 82 ], [ 96, 96 ], [ 103, 103 ], [ 107, 107 ], [ 112, 112 ], [ 115, 115 ], [ 143, 143 ], [ 183, 183 ], [ 191, 191 ], [ 206, 206 ], [ 226, 226 ], [ 230, 230 ], [ 232, 233 ], [ 248, 248 ], [ 254, 254 ], [ 257, 261 ], [ 263, 263 ], [ 299, 303 ], [ 307, 307 ], [ 309, 309 ], [ 311, 312 ], [ 314, 315 ], [ 317, 317 ], [ 320, 321 ], [ 329, 330 ], [ 332, 332 ], [ 335, 335 ], [ 337, 337 ], [ 344, 344 ], [ 347, 347 ], [ 351, 351 ], [ 354, 356 ], [ 358, 358 ], [ 360, 361 ], [ 363, 365 ], [ 368, 370 ], [ 373, 375 ], [ 381, 381 ], [ 383, 383 ], [ 386, 388 ], [ 391, 391 ], [ 393, 394 ], [ 396, 396 ], [ 398, 405 ], [ 409, 411 ], [ 413, 413 ], [ 415, 417 ], [ 419, 420 ], [ 422, 423 ], [ 427, 428 ], [ 432, 432 ], [ 435, 435 ], [ 439, 446 ], [ 453, 453 ], [ 461, 461 ], [ 463, 464 ], [ 520, 520 ], [ 522, 522 ], [ 524, 526 ], [ 529, 532 ], [ 534, 534 ], [ 549, 553 ], [ 646, 646 ], [ 657, 657 ], [ 671, 671 ], [ 736, 736 ], [ 749, 750 ], [ 763, 763 ], [ 772, 772 ], [ 776, 777 ], [ 779, 781 ], [ 785, 786 ], [ 790, 790 ], [ 793, 795 ], [ 799, 800 ], [ 810, 810 ], [ 818, 818 ], [ 821, 822 ], [ 832, 832 ], [ 835, 835 ], [ 845, 845 ], [ 850, 850 ], [ 873, 873 ], [ 878, 878 ], [ 886, 886 ], [ 963, 963 ], [ 965, 967 ], [ 971, 971 ], [ 973, 973 ], [ 976, 976 ], [ 978, 978 ], [ 981, 982 ], [ 995, 995 ], [ 1068, 1068 ], [ 1081, 1081 ], [ 1110, 1110 ], [ 1114, 1114 ], [ 1126, 1126 ], [ 1135, 1137 ], [ 1140, 1141 ], [ 1143, 1143 ], [ 1145, 1145 ], [ 1147, 1147 ], [ 1150, 1150 ], [ 1156, 1158 ], [ 1161, 1162 ], [ 1165, 1165 ], [ 1167, 1167 ], [ 1169, 1169 ], [ 1173, 1173 ], [ 1199, 1199 ], [ 1204, 1204 ], [ 1207, 1207 ], [ 1209, 1210 ], [ 1212, 1212 ], [ 1215, 1215 ], [ 1217, 1217 ], [ 1219, 1220 ], [ 1222, 1224 ], [ 1227, 1227 ], [ 1229, 1229 ], [ 1231, 1231 ], [ 1235, 1236 ], [ 1281, 1281 ], [ 1330, 1331 ], [ 1333, 1334 ], [ 1341, 1342 ], [ 1345, 1348 ], [ 1360, 1360 ], [ 1459, 1460 ], [ 1498, 1498 ] ] ]
275e65e477c7e68c978901fde6bb025ce6709382
6e4f9952ef7a3a47330a707aa993247afde65597
/PROJECTS_ROOT/WireChanger/SettingsTempl.cpp
0fbf35523b7005250c7be1f4f8049e6624b4d922
[]
no_license
meiercn/wiredplane-wintools
b35422570e2c4b486c3aa6e73200ea7035e9b232
134db644e4271079d631776cffcedc51b5456442
refs/heads/master
2021-01-19T07:50:42.622687
2009-07-07T03:34:11
2009-07-07T03:34:11
34,017,037
2
1
null
null
null
null
WINDOWS-1251
C++
false
false
39,841
cpp
#include "stdafx.h" #include <process.h> #include "_common.h" #include "_externs.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif CRect rtTargetRect(0,0,0,0); HANDLE hCloseAlertEvent=0; BOOL CALLBACK SetPosFinished(void* Param, int iButtonNum, HWND hThisWindow) { if(hThisWindow){ ::GetWindowRect(hThisWindow,&rtTargetRect); AdjustToSceenCoords(rtTargetRect,FALSE); } SetEvent(hCloseAlertEvent); return TRUE; } BOOL ShowSetPosDialog(CString sTitle,CWnd* pParent,long& lX, long& lY, long& lW, long& lH) { InfoWndStruct* info=new InfoWndStruct(); info->sText=_l("This window is placed in the exact location of the wallpaper element"); if(sTitle!=""){ info->sText+=" '"; info->sText+=sTitle; info->sText+="'"; } info->sText+="\n"; info->sText+=_l("You can move and resize this window to place element in the desired location"); info->sText+="\n"; info->sText+=_l("Click 'Save and Close' to close this window when you finish"); info->sTitle=""; if(sTitle!=""){ info->sTitle+=" '"; info->sTitle+=sTitle; info->sTitle+="': "; } info->sTitle+=_l("Select size and position"); info->sOkButtonText=_l("Save and close"); info->bCenterUnderMouse=FALSE; info->dwStaticPars=DT_CENTER|DT_WORDBREAK; info->rtStart.left=lX; info->rtStart.top=lY; if(lW==0){ lW=lH; } if(lH==0){ lH=lW; } info->rtStart.right=lX+lW; info->rtStart.bottom=lY+lH; AdjustToSceenCoords(info->rtStart); info->bPlaceOnTaskbarAnyway=TRUE; info->bHideInfoTitler=TRUE; info->pParent=pParent; rtTargetRect.SetRect(0,0,0,0); hCloseAlertEvent=CreateEvent(0,0,0,0); if(pParent){ pParent->EnableWindow(FALSE); } InfoWnd* pTargWnd=Alert(info); if(!pTargWnd){ return FALSE; } pTargWnd->SetCallback(SetPosFinished,0); WaitForSingleObject(hCloseAlertEvent,INFINITE); CloseHandle(hCloseAlertEvent); if(pParent){ pParent->EnableWindow(TRUE); //pParent->ShowWindow(SW_SHOW); //pParent->SetForegroundWindow(); SwitchToWindow(pParent->GetSafeHwnd(),TRUE); /* ::SetForegroundWindow(hActivate); ::SendMessage(::GetDesktopWindow(), WM_SYSCOMMAND, (WPARAM) SC_HOTKEY, (LPARAM)hActivate); */ } if(!rtTargetRect.IsRectEmpty() && pTargWnd->bCloseReason!=IDCANCEL){ lX=rtTargetRect.left; lY=rtTargetRect.top; lW=rtTargetRect.Width(); lH=rtTargetRect.Height(); } return TRUE; } class CWPTOptionList { public: static long lEmptyLong; CMapStringToString aStringsHolder; CMap<CString,const char*,long,long&> aLongHolder; CMap<CString,const char*,long,long&> aColorHolder; CMap<CString,const char*,COleDateTime,COleDateTime&> aDateHolder; CMap<CString,const char*,CFont*,CFont*> aFontHolder; CFont*& AddOptionHolder_Font(const char* szName, const char* sStartVal) { CString sLine=sStartVal; sLine.Replace("[","<"); sLine.Replace("]",">"); aFontHolder.SetAt(szName,CreateFontFromStr(sLine, NULL, NULL, NULL, NULL)); return aFontHolder[szName]; } COleDateTime* AddOptionHolder_Date(const char* szName, const char* lStartVal, const char* szOptionalString=0) { aDateHolder.SetAt(szName,CDataXMLSaver::Str2OleDate(lStartVal)); return &aDateHolder[szName]; } long* AddOptionHolder_Long(const char* szName, long lStartVal, const char* szOptionalString=0) { aLongHolder.SetAt(szName,lStartVal); if(szOptionalString!=0){ aStringsHolder.SetAt(CString("LIST_")+szName,szOptionalString); } return &aLongHolder[szName]; } long* AddOptionHolder_Color(const char* szName, long lStartVal) { aColorHolder.SetAt(szName,lStartVal); return &aColorHolder[szName]; } CString* AddOptionHolder_String(const char* szName, const char* szStartVal) { aStringsHolder.SetAt(szName,szStartVal); return &aStringsHolder[szName]; } CString GetOptionHolder_String(const char* szName) { CString sVal; if(aStringsHolder.Lookup(szName,sVal)){ return sVal; } return ""; } long& GetOptionHolder_Long(const char* szName) { long lVal; if(aLongHolder.Lookup(szName,lVal)){ return aLongHolder[szName]; } lEmptyLong=0; return lEmptyLong; } long& GetOptionHolder_Color(const char* szName) { long lVal; if(aColorHolder.Lookup(szName,lVal)){ return aLongHolder[szName]; } lEmptyLong=0; return lEmptyLong; } void FreeMemory() { aStringsHolder.RemoveAll(); aLongHolder.RemoveAll(); aColorHolder.RemoveAll(); // Шрифты... CString sName; CFont* pFont=0; POSITION pos=aFontHolder.GetStartPosition(); while(pos){ aFontHolder.GetNextAssoc(pos,sName,pFont); delete pFont; } aFontHolder.RemoveAll(); } ~CWPTOptionList() { FreeMemory(); }; } aWPTOptions; CString sWPTemplateTitle=""; CString sWPTemplateSource=""; CStringArray aActionsStrings; long CWPTOptionList::lEmptyLong=0; BOOL CALLBACK TemplateActions(HIROW hData, CDLG_Options* pDialog) { int iAction=int(hData); if(iAction<0 || iAction>=aActionsStrings.GetSize()){ return FALSE; } CString sString=aActionsStrings[iAction]; CallFileForOpenOrEdit(sString); return TRUE; } //CDLG_Options* g_pDialogTmp=0; HANDLE TemplateActions_SetPosEvent=0; struct CTemplateActions_SetPos_InThread { int m_iAction; CDLG_Options* m_pDialog; CWPT* pWpt; }; DWORD WINAPI TemplateActions_SetPos_InThread(LPVOID hData) { CTemplateActions_SetPos_InThread* p=(CTemplateActions_SetPos_InThread*)hData; if(!p){ return 0; } int iAction=p->m_iAction; CDLG_Options* pDialogTmp=p->m_pDialog; CWPT* wpt=p->pWpt; delete p; if(iAction<0 || iAction>=aActionsStrings.GetSize()){ return FALSE; } if(pDialogTmp){ //pDialogTmp->Lock } if(TemplateActions_SetPosEvent!=0){ ResetEvent(TemplateActions_SetPosEvent); } CString sString=aActionsStrings[iAction]; DWORD dwOC=atol(CDataXMLSaver::GetInstringPart("OC:(",")",sString)); if(dwOC && pDialogTmp){ pDialogTmp->CommitData(dwOC); } CString sXName=CDataXMLSaver::GetInstringPart("X:(",")",sString); CString sYName=CDataXMLSaver::GetInstringPart("Y:(",")",sString); CString sWName=CDataXMLSaver::GetInstringPart("W:(",")",sString); CString sHName=CDataXMLSaver::GetInstringPart("H:(",")",sString); CWnd* wndp=pDialogTmp; if(wndp==0){ if(pMainDialogWindow && pMainDialogWindow->dlgWChanger){ wndp=pMainDialogWindow->dlgWChanger; } } ShowSetPosDialog(wpt?(wpt->GetFTitle()):"",wndp,aWPTOptions.GetOptionHolder_Long(sXName),aWPTOptions.GetOptionHolder_Long(sYName),aWPTOptions.GetOptionHolder_Long(sWName),aWPTOptions.GetOptionHolder_Long(sHName)); if(dwOC && pDialogTmp){ pDialogTmp->PushSomeDataOnScreen(dwOC); } if(TemplateActions_SetPosEvent!=0){ SetEvent(TemplateActions_SetPosEvent); } if(pDialogTmp){ //pDialogTmp->UnLock } return TRUE; } BOOL CALLBACK TemplateActions_SetPos(HIROW hData, CDLG_Options* pDialog) { // g_pDialogTmp=pDialog; TemplateActions_SetPosEvent=CreateEvent(0,0,0,0); CTemplateActions_SetPos_InThread* p=new CTemplateActions_SetPos_InThread; p->m_iAction=(int)hData; p->m_pDialog=pDialog; p->pWpt=0; FORK(TemplateActions_SetPos_InThread,p); if(pDialog==0 && TemplateActions_SetPosEvent){ WaitForSingleObject(TemplateActions_SetPosEvent,INFINITE); } if(TemplateActions_SetPosEvent!=0){ CloseHandle(TemplateActions_SetPosEvent); TemplateActions_SetPosEvent=0; } // g_pDialogTmp=0; return TRUE; } CString sOptionWndTitle; CString g_CurrentEditingFile; BOOL g_CurrentEditingClocks=0; int g_CurrentEditingIndex=0; BOOL CALLBACK ApplyWOptionsFromDialog(BOOL bSaveAndClose,DWORD dwRes,CDLG_Options* dlgOpt) { BOOL bRes=FALSE; if(dwRes==IDOK){ objSettings.bTemplatesInWorkChanged=1; // Сохраняем в файл конфигурации CString sConfigFile=GetHTMLConfigFile(g_CurrentEditingFile,objSettings.sActivePreset); CString sConfig=Format("$=<Configuration file for '%s'>\r\n",g_CurrentEditingFile); {// Заменяем списочные/числовые значения новыми... POSITION pos=aWPTOptions.aLongHolder.GetStartPosition(); CString sKey,sTempVal; long lVal; while(pos){ aWPTOptions.aLongHolder.GetNextAssoc(pos,sKey,lVal); sConfig+=Format("$=<PARVAL:%s=%i>\r\n",sKey,lVal); if(aWPTOptions.aStringsHolder.Lookup(CString("LIST_")+sKey,sTempVal)){ // Это номер из списка!!! CStringArray sItemsData; ConvertComboDataToArray(sTempVal,sItemsData,'\t'); if(lVal>=0 && lVal<sItemsData.GetSize()){ CString sVal=sItemsData[lVal]; sConfig+=Format("$=<PARVAL:%s-PATH=%s>\r\n",sKey,sVal); } } } } {// Заменяем строковые значения новыми... POSITION pos=aWPTOptions.aStringsHolder.GetStartPosition(); CString sKey,sVal; while(pos){ aWPTOptions.aStringsHolder.GetNextAssoc(pos,sKey,sVal); sConfig+=Format("$=<PARVAL:%s=%s>\r\n",sKey,sVal); } } {// Заменяем датовые значения новыми... POSITION pos=aWPTOptions.aDateHolder.GetStartPosition(); CString sKey; COleDateTime sVal; while(pos){ aWPTOptions.aDateHolder.GetNextAssoc(pos,sKey,sVal); sConfig+=Format("$=<PARVAL:%s=%s>\r\n",sKey,CDataXMLSaver::OleDate2Str(sVal)); } } {// Заменяем цветовые значения новыми... POSITION pos=aWPTOptions.aColorHolder.GetStartPosition(); CString sKey; long lVal; while(pos){ aWPTOptions.aColorHolder.GetNextAssoc(pos,sKey,lVal); DWORD dwColor=(DWORD)lVal; sConfig+=Format("$=<PARVAL:%s=#%02X%02X%02X>\r\n",sKey,GetRValue(dwColor),GetGValue(dwColor),GetBValue(dwColor)); } } {// Заменяем шрифты значения новыми... POSITION pos=aWPTOptions.aFontHolder.GetStartPosition(); CString sKey; CFont* pFont; while(pos){ aWPTOptions.aFontHolder.GetNextAssoc(pos,sKey,pFont); CString sLine=CreateStrFromFont(pFont,"",0,0,0,0,TRUE); sLine.Replace("<","["); sLine.Replace(">","]"); sConfig+=Format("$=<PARVAL:%s=%s>\r\n",sKey,sLine); } } SaveFile(sConfigFile,sConfig); // Обновляем обоину if(pMainDialogWindow && (g_CurrentEditingIndex<0 || g_CurrentEditingIndex>objSettings.aLoadedWPTs.GetSize()-1 || IsWPTActive(objSettings.aLoadedWPTs[g_CurrentEditingIndex]))){ if(!objSettings.lMainWindowOpened){ pMainDialogWindow->OrderModifierForNextWallpaper=-2; pMainDialogWindow->PostMessage(WM_COMMAND,ID_SYSTRAY_CHANGEWALLPAPER,0); }else{ pMainDialogWindow->dlgWChanger->bNeddRefreshAfterClose=1; } } } return bRes; } BOOL CALLBACK EnDisTemplSep(HIROW hData, CDLG_Options* pDialog) { CString sCurrentWidget=objSettings.aLoadedWPTs[int(hData)]; SwitchSingleTemplate(sCurrentWidget,TRUE); //pDialog->PostMessage(WM_COMMAND,IDCANCEL,0); if(IsWPTActive(sCurrentWidget)){ Alert(CString("'")+GetWPTTitle(sCurrentWidget)+"': "+_l("Enabled")); }else{ Alert(CString("'")+GetWPTTitle(sCurrentWidget)+"': "+_l("Disabled")); } return TRUE; } BOOL CALLBACK DeleteTemplSep(HIROW hData, CDLG_Options* pDialog) { if(AfxMessageBox(_l("Do you really want to delete this template?\nTemplate file will be removed from your disk too"),MB_YESNO|MB_ICONQUESTION)!=IDYES){ return FALSE; } RemoveTemplate(int(hData)); pDialog->PostMessage(WM_COMMAND,IDCANCEL,0); return TRUE; } BOOL CALLBACK CloneTempl(HIROW hData, CDLG_Options* pDialog); BOOL CALLBACK AddWTemplateOptions(CDLG_Options* pData) { CDLG_Options* pDialog=pData; if(!pDialog){ return FALSE; } // aActionsStrings.RemoveAll(); pDialog->bShowColorForColorOptions=FALSE; /* pDialog->m_OptionsList.m_crIItemText=GetSysColor(COLOR_WINDOWTEXT); pDialog->m_OptionsList.m_crIRowBackground=GetSysColor(COLOR_WINDOW); pDialog->m_OptionsList.SetBkColor(GetSysColor(COLOR_WINDOW)); pDialog->m_OptionsList.m_crSelectedIRowBackground=GetSysColor(COLOR_HIGHLIGHT); pDialog->m_OptionsList.m_crSelectedIItemBackground=GetSysColor(COLOR_HIGHLIGHT); pDialog->m_OptionsList.m_crSelectedIItemText=GetSysColor(COLOR_HIGHLIGHTTEXT); */ pDialog->m_OptionsList.m_crIItemText=GetSysColor(COLOR_WINDOWTEXT); pDialog->m_OptionsList.m_crIRowBackground=GetSysColor(COLOR_BTNFACE); pDialog->m_OptionsList.SetBkColor(GetSysColor(COLOR_BTNFACE)); pDialog->m_OptionsList.m_crSelectedIRowBackground=GetSysColor(COLOR_HIGHLIGHT); pDialog->m_OptionsList.m_crSelectedIItemBackground=GetSysColor(COLOR_HIGHLIGHT); pDialog->m_OptionsList.m_crSelectedIItemText=GetSysColor(COLOR_HIGHLIGHTTEXT); CString sW98Warn=CDataXMLSaver::GetInstringPart("WIN98WARN=(",")",sWPTemplateSource); //////////////////////// // Задаем список опций //////////////////////// HIROW hRoot=FL_ROOT; CMapStringToPtr aRowMap; int iFrom=0,iFromPar=0,iCount=0; if(sWPTemplateSource.Find("{wp:define")!=-1){ CString sTagValue,sWPPar; while((iFrom=extTag("wp:define",sWPTemplateSource,&sTagValue))!=-1){ sWPPar=CDataXMLSaver::GetInstringPart("[","]",sTagValue); CString sWPParDefVal=_atr(Format("[%s]",sWPPar),sTagValue); CString sWPParDsc=_atr("title",sTagValue); if(sWPParDsc.IsEmpty()){ sWPParDsc=sWPPar; } CString sWPParDetails=_atr("description",sTagValue); if(sWPParDetails.IsEmpty()){ sWPParDetails=_atr("desc",sTagValue); } if(!sWPParDetails.IsEmpty()){ sWPParDetails=CString("\t")+_l(sWPParDetails); } // Это пока по старому... int iFromPar=0; CString sWPParValue=CDataXMLSaver::GetInstringPart(Format("$=<PARVAL:%s=",sWPPar),">",sWPTemplateSource,iFromPar); if(iFromPar==-1){ sWPParValue=sWPParDefVal; } CString sWPParType=_atr("type",sTagValue); sWPParType.MakeLower(); CString sWPParList=_atr("items",sTagValue); CString sWPParMin=_atr("min",sTagValue); CString sWPParMax=_atr("max",sTagValue); if(sWPParMax.IsEmpty()){ sWPParMax="9999"; } CString sWPParErr=_atr("onerror",sTagValue); CString sWPParAction=_atr("action",sTagValue); CString sWPParOC=_atr("oc",sTagValue); CString sWPParPar=_atr("parent",sTagValue); void* pMapValue=NULL; HIROW hInsertPoint=NULL, hInserted=NULL; if(sWPParPar!=""){ aRowMap.Lookup(sWPParPar, pMapValue); hInsertPoint=(HIROW)pMapValue; } if(hInsertPoint==NULL){ hInsertPoint=hRoot; } if(sWPParType=="list"){ sWPParList=_l(sWPParList); sWPParList.Replace(",","\t"); hInserted=pDialog->Option_AddCombo(hInsertPoint,_l(sWPParDsc)+sWPParDetails,aWPTOptions.AddOptionHolder_Long(sWPPar,atol(sWPParValue)),atol(sWPParDefVal),sWPParList); iCount++; }else if(sWPParType=="hidden"){ // Nothing to do }else if(sWPParType=="dirlist"){ CString sList,sFileList; if(sWPParList.Find("HKLM:")!=-1 || sWPParList.Find("HKCU:")!=-1){ CRegKey key; CString sPath=sWPParList.Mid(strlen("????:")); BOOL bRes=0; if(sWPParList.Find("HKLM:")!=-1 && key.Open(HKEY_LOCAL_MACHINE, sPath)==ERROR_SUCCESS && key.m_hKey!=NULL){ bRes=1; } if(sWPParList.Find("HKCU:")!=-1 && key.Open(HKEY_CURRENT_USER, sPath)==ERROR_SUCCESS && key.m_hKey!=NULL){ bRes=1; } int iAdded=0; if(bRes){ // Список! iCount=0; char szKeysNameBuf[256]={0}; CString sChangedKey=""; DWORD dwBufSize=sizeof(szKeysNameBuf); FILETIME pFileTime; memset(&pFileTime,0,sizeof(pFileTime)); while(RegEnumKeyEx(key.m_hKey,iCount++,szKeysNameBuf,&dwBufSize,0,0,0,&pFileTime)==ERROR_SUCCESS){ CString sPathK=szKeysNameBuf; sFileList+=sPath+"\\"+sPathK+"\t"; int iLP=sPathK.ReverseFind('\\'); if(iLP!=-1){ sList+=sPathK.Mid(iLP+1)+"\t"; }else{ sList+=sPathK+"\t"; } szKeysNameBuf[0]=0; dwBufSize=sizeof(szKeysNameBuf); } } }else{ CString sMask="*.def"; int iLastSlPos=sWPParList.ReverseFind('\\'); if(iLastSlPos==-1){ iLastSlPos=sWPParList.ReverseFind('/'); } if(iLastSlPos!=-1){ sMask=sWPParList.Mid(iLastSlPos+1); sWPParList=sWPParList.Left(iLastSlPos+1); } CFileInfoArray dir; dir.AddDir(sWPParList,sMask,TRUE,CFileInfoArray::AP_SORTBYNAME | CFileInfoArray::AP_SORTASCENDING,FALSE); for (int i=0;i<dir.GetSize();i++){ CString sFile=dir[i].GetFilePath(); if(sFile!="" && sFile.Find(".def")!=-1){ CString sName; ReadFile(sFile,sName); sName=CDataXMLSaver::GetInstringPart("ITEM-NAME:(",")",sName); if(sName!=""){ sFileList+=sFile+"\t"; sList+=_l(sName)+"\t"; } }else{ sFileList+=sFile+"\t"; sList+=_l(GetPathPart(sFile,0,0,1,0))+"\t"; } } } sList.TrimRight(); sFileList.TrimRight(); if(sList!=""){ hInserted=pDialog->Option_AddCombo(hInsertPoint,_l(sWPParDsc)+sWPParDetails,aWPTOptions.AddOptionHolder_Long(sWPPar,atol(sWPParValue),sFileList),atol(sWPParDefVal),sList); iCount++; }else if(sWPParErr!=""){ hInserted=pDialog->Option_AddTitle(hInsertPoint,_l(sWPParErr),63); } }else if(sWPParType=="action"){ int iActionIndex=aActionsStrings.Add(sWPParAction); hInserted=pDialog->Option_AddAction(hInsertPoint,_l(sWPParDsc)+sWPParDetails,TemplateActions,HIROW(iActionIndex)); pDialog->Option_AddMenuAction(_l(sWPParDsc), TemplateActions, HIROW(iActionIndex), hInsertPoint); iCount++; }else if(sWPParType=="set_position"){ int iActionIndex=aActionsStrings.Add(sWPParAction); hInserted=pDialog->Option_AddAction(hInsertPoint,_l(sWPParDsc)+sWPParDetails,TemplateActions_SetPos,HIROW(iActionIndex)); pDialog->Option_AddMenuAction(_l(sWPParDsc)+sWPParDetails, TemplateActions_SetPos, HIROW(iActionIndex), hInsertPoint,TRUE); iCount++; }else if(sWPParType=="number"){ hInserted=pDialog->Option_AddNString(hInsertPoint,_l(sWPParDsc)+sWPParDetails,aWPTOptions.AddOptionHolder_Long(sWPPar,atol(sWPParValue)),atol(sWPParDefVal),atol(sWPParMin),atol(sWPParMax),atol(sWPParOC)); iCount++; }else if(sWPParType=="slider"){ hInserted=pDialog->Option_AddNSlider(hInsertPoint,_l(sWPParDsc)+sWPParDetails,aWPTOptions.AddOptionHolder_Long(sWPPar,atol(sWPParValue)),atol(sWPParDefVal),atol(sWPParMin),atol(sWPParMax),atol(sWPParOC)); iCount++; }else if(sWPParType=="font"){ hInserted=pDialog->Option_AddFont(hInsertPoint,_l(sWPParDsc)+sWPParDetails,&aWPTOptions.AddOptionHolder_Font(sWPPar,sWPParValue),0,69); iCount++; }else if(sWPParType=="color"){ hInserted=pDialog->Option_AddColor(hInsertPoint,_l(sWPParDsc)+sWPParDetails,aWPTOptions.AddOptionHolder_Color(sWPPar,(long)GetRGBFromHTMLString(sWPParValue)),(long)GetRGBFromHTMLString(sWPParDefVal)); iCount++; }else if(sWPParType=="bool"){ hInserted=pDialog->Option_AddBOOL(hInsertPoint,_l(sWPParDsc)+sWPParDetails,aWPTOptions.AddOptionHolder_Long(sWPPar,atol(sWPParValue)),atol(sWPParDefVal)); iCount++; }else if(sWPParType=="date"){ hInserted=pDialog->Option_AddDate(hInsertPoint,_l(sWPParDsc)+sWPParDetails,aWPTOptions.AddOptionHolder_Date(sWPPar,sWPParValue),CDataXMLSaver::Str2OleDate(sWPParDefVal)); iCount++; }else if(sWPParType=="tip"){ hInserted=pDialog->Option_AddTitle(hInsertPoint,_l(sWPParDsc)+sWPParDetails,63); }else if(sWPParType=="folder" || sWPParType=="root"){ if(sWPParType=="folder"){ hInserted=pDialog->Option_AddTitle(hInsertPoint,_l(sWPParDsc)+sWPParDetails); hInsertPoint=hInserted; }else{ CWPT* wpt=0; if(pMainDialogWindow && g_CurrentEditingIndex>=0 && g_CurrentEditingIndex<objSettings.aLoadedWPTs.GetSize()){ wpt=GetWPT(g_CurrentEditingIndex); if(wpt && sWPParDetails=="" && wpt->sDsc!=""){ CString sDesk=_l(wpt->sDsc); sDesk.Replace("\r",""); sDesk.Replace("\n"," "); sDesk.Replace("\t"," "); sDesk.Replace(" "," "); sWPParDetails="\t"+_l("Widget description")+": "+sDesk; } } hInserted=pDialog->Option_AddHeader(FL_ROOT,_l(sWPParDsc)+sWPParDetails); if(sW98Warn!="" && isWin9x()){ pDialog->Option_AddTitle(hInserted,_l(sW98Warn),63); } pDialog->m_OptionsList.Expand(hInserted); hRoot=hInserted; } iCount++; }else{ hInserted=pDialog->Option_AddString(hInsertPoint,_l(sWPParDsc)+sWPParDetails,aWPTOptions.AddOptionHolder_String(sWPPar,sWPParValue),sWPParDefVal); if(sWPParType=="file"){ pDialog->Option_AddActionToEdit(hInserted,ChooseAnyFile,hInserted,0,70); } if(sWPParType=="directory"){ pDialog->Option_AddActionToEdit(hInserted,ChooseDir,hInserted,0,70); } iCount++; } pMapValue=(void*)hInserted; aRowMap.SetAt(sWPPar,pMapValue); sTagValue=""; } }else{ while(iFrom>=0){ CString sWPPar=CDataXMLSaver::GetInstringPart("$=<PARDEF:",">",sWPTemplateSource,iFrom); if(sWPPar.IsEmpty()){ break; } int iDefPos=sWPPar.Find("="); CString sWPParDefVal; if(iDefPos!=-1){ sWPParDefVal=sWPPar.Mid(iDefPos+1); if(sWPParDefVal=="\"\""){ sWPParDefVal=""; } sWPPar=sWPPar.Left(iDefPos); } iFromPar=iFrom; CString sWPParDsc=CDataXMLSaver::GetInstringPart(Format("$=<PARDSC:%s=",sWPPar),">",sWPTemplateSource,iFromPar); if(sWPParDsc.IsEmpty()){ sWPParDsc=sWPPar; } CString sWPParDetails=CDataXMLSaver::GetInstringPart(Format("$=<PARDET:%s=",sWPPar),">",sWPTemplateSource,iFromPar); if(!sWPParDetails.IsEmpty()){ sWPParDetails=CString("\t")+_l(sWPParDetails); } iFromPar=0; CString sWPParValue=CDataXMLSaver::GetInstringPart(Format("$=<PARVAL:%s=",sWPPar),">",sWPTemplateSource,iFromPar); if(iFromPar==-1){ sWPParValue=sWPParDefVal; } iFromPar=iFrom; CString sWPParType=CDataXMLSaver::GetInstringPart(Format("$=<PARTYP:%s=",sWPPar),">",sWPTemplateSource,iFromPar); sWPParType.MakeLower(); iFromPar=iFrom; CString sWPParList=CDataXMLSaver::GetInstringPart(Format("$=<PARLST:%s=",sWPPar),">",sWPTemplateSource,iFromPar); iFromPar=iFrom; CString sWPParMin=CDataXMLSaver::GetInstringPart(Format("$=<PARMIN:%s=",sWPPar),">",sWPTemplateSource,iFromPar); iFromPar=iFrom; CString sWPParMax=CDataXMLSaver::GetInstringPart(Format("$=<PARMAX:%s=",sWPPar),">",sWPTemplateSource,iFromPar); if(sWPParMax.IsEmpty()){ sWPParMax="9999"; } iFromPar=iFrom; CString sWPParErr=CDataXMLSaver::GetInstringPart(Format("$=<PARERR:%s=",sWPPar),">",sWPTemplateSource,iFromPar); iFromPar=iFrom; CString sWPParAction=CDataXMLSaver::GetInstringPart(Format("$=<PARACTION:%s=",sWPPar),"/>",sWPTemplateSource,iFromPar); iFromPar=iFrom; CString sWPParOC=CDataXMLSaver::GetInstringPart(Format("$=<PAROC:%s=",sWPPar),">",sWPTemplateSource,iFromPar); iFromPar=iFrom; CString sWPParPar=CDataXMLSaver::GetInstringPart(Format("$=<PARPAR:%s=",sWPPar),">",sWPTemplateSource,iFromPar); void* pMapValue=NULL; HIROW hInsertPoint=NULL, hInserted=NULL; if(sWPParPar!=""){ aRowMap.Lookup(sWPParPar, pMapValue); hInsertPoint=(HIROW)pMapValue; } if(hInsertPoint==NULL){ hInsertPoint=hRoot; } if(sWPParType=="list"){ sWPParList=_l(sWPParList); sWPParList.Replace(",","\t"); hInserted=pDialog->Option_AddCombo(hInsertPoint,_l(sWPParDsc)+sWPParDetails,aWPTOptions.AddOptionHolder_Long(sWPPar,atol(sWPParValue)),atol(sWPParDefVal),sWPParList); iCount++; }else if(sWPParType=="hidden"){ // Nothing to do }else if(sWPParType=="dirlist"){ CString sList,sFileList; if(sWPParList.Find("HKLM:")!=-1 || sWPParList.Find("HKCU:")!=-1){ CRegKey key; CString sPath=sWPParList.Mid(strlen("????:")); BOOL bRes=0; if(sWPParList.Find("HKLM:")!=-1 && key.Open(HKEY_LOCAL_MACHINE, sPath)==ERROR_SUCCESS && key.m_hKey!=NULL){ bRes=1; } if(sWPParList.Find("HKCU:")!=-1 && key.Open(HKEY_CURRENT_USER, sPath)==ERROR_SUCCESS && key.m_hKey!=NULL){ bRes=1; } int iAdded=0; if(bRes){ // Список! iCount=0; char szKeysNameBuf[256]={0}; CString sChangedKey=""; DWORD dwBufSize=sizeof(szKeysNameBuf); FILETIME pFileTime; memset(&pFileTime,0,sizeof(pFileTime)); while(RegEnumKeyEx(key.m_hKey,iCount++,szKeysNameBuf,&dwBufSize,0,0,0,&pFileTime)==ERROR_SUCCESS){ CString sPathK=szKeysNameBuf; sFileList+=sPath+"\\"+sPathK+"\t"; int iLP=sPathK.ReverseFind('\\'); if(iLP!=-1){ sList+=sPathK.Mid(iLP+1)+"\t"; }else{ sList+=sPathK+"\t"; } szKeysNameBuf[0]=0; dwBufSize=sizeof(szKeysNameBuf); } } }else{ CString sMask="*.def"; sWPParList.Replace("/","\\"); int iLastSlPos=sWPParList.ReverseFind('\\'); if(iLastSlPos==-1){ iLastSlPos=sWPParList.ReverseFind('/'); } if(iLastSlPos!=-1){ sMask=sWPParList.Mid(iLastSlPos+1); sWPParList=sWPParList.Left(iLastSlPos+1); } CFileInfoArray dir; dir.AddDir(sWPParList,sMask,TRUE,CFileInfoArray::AP_SORTBYNAME | CFileInfoArray::AP_SORTASCENDING,FALSE); for (int i=0;i<dir.GetSize();i++){ CString sFile=dir[i].GetFilePath(); if(sFile!="" && sFile.Find(".def")!=-1){ CString sName; ReadFile(sFile,sName); sName=CDataXMLSaver::GetInstringPart("ITEM-NAME:(",")",sName); if(sName!=""){ sFileList+=sFile+"\t"; sList+=_l(sName)+"\t"; } }else{ sFileList+=sFile+"\t"; sList+=_l(GetPathPart(sFile,0,0,1,0))+"\t"; } } } sList.TrimRight(); sFileList.TrimRight(); if(sList!=""){ hInserted=pDialog->Option_AddCombo(hInsertPoint,_l(sWPParDsc)+sWPParDetails,aWPTOptions.AddOptionHolder_Long(sWPPar,atol(sWPParValue),sFileList),atol(sWPParDefVal),sList); iCount++; }else if(sWPParErr!=""){ hInserted=pDialog->Option_AddTitle(hInsertPoint,_l(sWPParErr),63); } }else if(sWPParType=="action"){ int iActionIndex=aActionsStrings.Add(sWPParAction); hInserted=pDialog->Option_AddAction(hInsertPoint,_l(sWPParDsc)+sWPParDetails,TemplateActions,HIROW(iActionIndex)); pDialog->Option_AddMenuAction(_l(sWPParDsc), TemplateActions, HIROW(iActionIndex), hInsertPoint); iCount++; }else if(sWPParType=="set_position"){ int iActionIndex=aActionsStrings.Add(sWPParAction); hInserted=pDialog->Option_AddAction(hInsertPoint,_l(sWPParDsc)+sWPParDetails,TemplateActions_SetPos,HIROW(iActionIndex)); pDialog->Option_AddMenuAction(_l(sWPParDsc)+sWPParDetails, TemplateActions_SetPos, HIROW(iActionIndex), hInsertPoint,TRUE); iCount++; }else if(sWPParType=="number"){ hInserted=pDialog->Option_AddNString(hInsertPoint,_l(sWPParDsc)+sWPParDetails,aWPTOptions.AddOptionHolder_Long(sWPPar,atol(sWPParValue)),atol(sWPParDefVal),atol(sWPParMin),atol(sWPParMax),atol(sWPParOC)); iCount++; }else if(sWPParType=="slider"){ hInserted=pDialog->Option_AddNSlider(hInsertPoint,_l(sWPParDsc)+sWPParDetails,aWPTOptions.AddOptionHolder_Long(sWPPar,atol(sWPParValue)),atol(sWPParDefVal),atol(sWPParMin),atol(sWPParMax),atol(sWPParOC)); iCount++; }else if(sWPParType=="font"){ hInserted=pDialog->Option_AddFont(hInsertPoint,_l(sWPParDsc)+sWPParDetails,&aWPTOptions.AddOptionHolder_Font(sWPPar,sWPParValue),0,69); iCount++; }else if(sWPParType=="color"){ hInserted=pDialog->Option_AddColor(hInsertPoint,_l(sWPParDsc)+sWPParDetails,aWPTOptions.AddOptionHolder_Color(sWPPar,(long)GetRGBFromHTMLString(sWPParValue)),(long)GetRGBFromHTMLString(sWPParDefVal)); iCount++; }else if(sWPParType=="bool"){ hInserted=pDialog->Option_AddBOOL(hInsertPoint,_l(sWPParDsc)+sWPParDetails,aWPTOptions.AddOptionHolder_Long(sWPPar,atol(sWPParValue)),atol(sWPParDefVal)); iCount++; }else if(sWPParType=="date"){ hInserted=pDialog->Option_AddDate(hInsertPoint,_l(sWPParDsc)+sWPParDetails,aWPTOptions.AddOptionHolder_Date(sWPPar,sWPParValue),CDataXMLSaver::Str2OleDate(sWPParDefVal)); iCount++; }else if(sWPParType=="tip"){ hInserted=pDialog->Option_AddTitle(hInsertPoint,_l(sWPParDsc)+sWPParDetails,63); }else if(sWPParType=="folder" || sWPParType=="root"){ if(sWPParType=="folder"){ hInserted=pDialog->Option_AddTitle(hInsertPoint,_l(sWPParDsc)+sWPParDetails); hInsertPoint=hInserted; }else{ CWPT* wpt=0; if(pMainDialogWindow && g_CurrentEditingIndex>=0 && g_CurrentEditingIndex<objSettings.aLoadedWPTs.GetSize()){ wpt=GetWPT(g_CurrentEditingIndex); if(wpt && sWPParDetails=="" && wpt->sDsc!=""){ CString sDesk=_l(wpt->sDsc); sDesk.Replace("\r",""); sDesk.Replace("\n"," "); sDesk.Replace("\t"," "); sDesk.Replace(" "," "); sWPParDetails="\t"+_l("Widget description")+": "+sDesk; } } hInserted=pDialog->Option_AddHeader(FL_ROOT,_l(sWPParDsc)+sWPParDetails); if(sW98Warn!="" && isWin9x()){ pDialog->Option_AddTitle(hInserted,_l(sW98Warn),63); } pDialog->m_OptionsList.Expand(hInserted); hRoot=hInserted; } iCount++; }else{ hInserted=pDialog->Option_AddString(hInsertPoint,_l(sWPParDsc)+sWPParDetails,aWPTOptions.AddOptionHolder_String(sWPPar,sWPParValue),sWPParDefVal); if(sWPParType=="file"){ pDialog->Option_AddActionToEdit(hInserted,ChooseAnyFile,hInserted,0,70); } if(sWPParType=="directory"){ pDialog->Option_AddActionToEdit(hInserted,ChooseDir,hInserted,0,70); } iCount++; } pMapValue=(void*)hInserted; aRowMap.SetAt(sWPPar,pMapValue); } } if(iCount==0){ Alert(_l("No parameters found")+"!"); return FALSE; } #ifndef ART_VERSION if(!g_CurrentEditingClocks){ pDialog->Option_AddAction(hRoot,_l("Enable/Disable widget"), EnDisTemplSep, HIROW(g_CurrentEditingIndex), 0); CString sTitle=GetWPTTitle(g_CurrentEditingIndex); BOOL bWPTClonable=GetWPTClonable(g_CurrentEditingIndex); if(bWPTClonable){ pDialog->Option_AddAction(hRoot,_l("Make a copy of")+" '"+sTitle+"'", CloneTempl, HIROW(g_CurrentEditingIndex), 0); } //pDialog->Option_AddAction(hRoot,_l("Remove this widget"), DeleteTemplSep, HIROW(g_CurrentEditingIndex), 0); } #endif return TRUE; } BOOL AppMainDlg::GetHTMLForClock(const char* szFile,CString& sPreContent,CString sTemplFile, BOOL bSmallize) { sPreContent.Replace("TITLE","title"); sPreContent.Replace("SWF","swf"); sPreContent.Replace("OBJECT","object"); sPreContent.Replace("MOVIE","movie"); sPreContent.Replace("VALUE","value"); sPreContent.Replace("WIDTH","width"); sPreContent.Replace("HEIGHT","height"); BOOL bDefs=0; CString sTitle=CDataXMLSaver::GetInstringPart("<title>","</title>",sPreContent); if(sTitle=="" || sTitle.CompareNoCase("%title%")==0){ sTitle=GetPathPart(szFile,0,0,1,0); sTitle.Replace("_"," "); if(sTitle[0]>='a' && sTitle[0]<='z'){ sTitle.SetAt(0,'A'+sTitle[0]-'a'); } bDefs=1; } sPreContent=CDataXMLSaver::GetInstringPart("<object","/object>",sPreContent); int iSwfFrom=sPreContent.Find("movie"); CString sSwf=CDataXMLSaver::GetInstringPart("value=\"",".swf\"",sPreContent,iSwfFrom); if(sSwf=="" || sSwf.CompareNoCase("%swf%")==0){ sSwf=szFile; }else{ sSwf+=".swf"; } CString sX=CDataXMLSaver::GetInstringPart("width=\"","\"",sPreContent); CString sY=CDataXMLSaver::GetInstringPart("height=\"","\"",sPreContent); if(bDefs){ sX="0"; sY="0"; } CRect rt; ::GetWindowRect(::GetDesktopWindow(),&rt); if(sX.Find("%")!=-1 || sY.Find("%")!=-1){ if(sX.Find("%")!=-1){ sX=Format("%i",int(rt.Width()*atol(sX)/100)); } if(sY.Find("%")!=-1){ sY=Format("%i",int(rt.Height()*atol(sY)/100)); } } if(atol(sX)<=0 || atol(sY)<=0){ int iW=0,iH=0; CString sFPath=sSwf; if(sSwf.Find(":/")==-1 && sSwf.Find(":\\")==-1){ char szD[MAX_PATH]={0},szP[MAX_PATH]={0}; _splitpath(szFile,szD,szP,0,0); sFPath=CString(szD)+szP+sSwf; } GetImageSizeFromFile(sFPath,iW,iH); if(iW<=0 || iH<=0){ iW=150; iH=0; } if(bSmallize && iW>150){ double d=150.0f/double(iW); iW=(int)(double(iW)*d); iH=(int)(double(iH)*d); } sX=Format("%i",iW); sY=Format("%i",iH); } // Добавить проверку на ява-скрипт? CString sClockTempl; ReadFile(CString(GetApplicationDir())+WP_TEMPLATE+"\\"+sTemplFile,sClockTempl); sClockTempl.Replace("%TITLE%",sTitle); sClockTempl.Replace("%SWF%",sSwf); sClockTempl.Replace("%LEFT%",Format("%i",(rt.Width()-atol(sX))/2)); sClockTempl.Replace("%TOP%",Format("%i",(rt.Height()-atol(sY))/2)); sClockTempl.Replace("%X%",sX); sClockTempl.Replace("%Y%",sY); sPreContent=sClockTempl; return TRUE; } long lOnTemplParamsFileLock=0; BOOL AppMainDlg::OnTemplParamsFile(CWnd* pParent, CString sStartTopic, const char* sWPTemplateTitle, const char* szFile, int isWPTIndex) { if(lOnTemplParamsFileLock>0){ AfxMessageBox(_l("Another dialog is opened already. Close it first!")); return FALSE; } objSettings.bTemplatesInWorkChanged=1; BOOL bClocks=(isWPTIndex==-1); SimpleTracker Track(lOnTemplParamsFileLock); g_CurrentEditingFile=szFile; g_CurrentEditingClocks=bClocks; g_CurrentEditingIndex=isWPTIndex; if(bClocks){ // Проверяем что это от часов и нету в нем наших тэгов CString sPreContent; ReadFile(g_CurrentEditingFile,sPreContent); if(sPreContent.Find("{"CUTLINE_TAG"}")==-1){ // Оно, в сыром виде GetHTMLForClock(g_CurrentEditingFile,sPreContent); SaveFile(g_CurrentEditingFile,sPreContent); } } ReadFileWithConfig(g_CurrentEditingFile,sWPTemplateSource,objSettings.sActivePreset,TRUE); // Создаем диалог... CDLG_Options_Startup pStartupInfo; pStartupInfo.bTreeOnRight=TRUE; pStartupInfo.fpInitOptionList=AddWTemplateOptions; pStartupInfo.fpApplyOptionList=ApplyWOptionsFromDialog; pStartupInfo.iStickPix=objSettings.iStickPix; pStartupInfo.szRegSaveKey=PROG_REGKEY"\\Wnd_WPPreferences"; pStartupInfo.pImageList=&theApp.MainImageList; pStartupInfo.szDefaultTopicTitle=sStartTopic; pStartupInfo.sz1stTopic=_l(bClocks?"Clock options":"Template options"); sOptionWndTitle=Format("%s: '%s'",_l("Parameters"),sWPTemplateTitle); if(sWPTemplateTitle==""){ sOptionWndTitle=_l("Wallpaper template parameters"); } pStartupInfo.szWindowTitle=sOptionWndTitle; pStartupInfo.iWindowIcon=MAIN_ICON; CDLG_Options dlgOpt(pStartupInfo,pParent); dlgOpt.bRPaneOnly=1; dlgOpt.bShowFind=0; CString sHelpFile=CDataXMLSaver::GetInstringPart("$=<HELP-PAGE:",">",sWPTemplateSource); dlgOpt.sHelpPage=sHelpFile; if(dlgOpt.sHelpPage==""){ dlgOpt.sHelpPage=bClocks?"dsc_clocks":"dsc_templates"; } pOpenedTemplate=&dlgOpt; DWORD dwRes=dlgOpt.DoModal(); aWPTOptions.FreeMemory(); pOpenedTemplate=0; return TRUE; } BOOL AppMainDlg::OnTemplParams(CWnd* pParent, CString sWPT, CString sStartTopic) { if(pParent==0){ if(this->dlgWChanger){ pParent=this->dlgWChanger; }else{ pParent=this; } } return OnTemplParamsFile(pParent, sStartTopic, GetWPTTitle(sWPT), GetWPTemplateFilePath(sWPT)+".wpt",GetTemplateMainIndex(sWPT)); } BOOL WriteSingleTemplateVar(CString wptName,CString sVar,CString sVal,const char* szPreset) { CString sP=szPreset; if(szPreset==0){ sP=objSettings.sActivePreset; } CString sConfigFile=GetHTMLConfigFile(wptName,sP); CString sWPTemplateSource; ReadFile(sConfigFile,sWPTemplateSource); CString sWPParValue=CDataXMLSaver::GetInstringPart(Format("$=<PARVAL:%s=",sVar),">",sWPTemplateSource,0); sWPTemplateSource.Replace(Format("$=<PARVAL:%s=%s>",sVar,sWPParValue),""); sWPTemplateSource+=Format("$=<PARVAL:%s=%s>",sVar,sVal); SaveFile(sConfigFile,sWPTemplateSource); return TRUE; } BOOL ReadSingleTemplateVar(CString wptName,CString sVar,CString& sVal,const char* szPreset,const char* szOverloadedDef) { CString sP=szPreset; if(szPreset==0){ sP=objSettings.sActivePreset; } CString sConfigFile=GetHTMLConfigFile(wptName,sP); CString sWPTemplateSource; ReadFile(sConfigFile,sWPTemplateSource); int iFrom=0; sVal=CDataXMLSaver::GetInstringPart(Format("$=<PARVAL:%s=",sVar),">",sWPTemplateSource,iFrom); if(iFrom==-1){ if(szOverloadedDef){ sVal=szOverloadedDef; }else{ // Дефолт? ReadFileWithConfig(GetWPTemplateFilePath(wptName),sWPTemplateSource,objSettings.sActivePreset,TRUE); if(sWPTemplateSource.Find("wp:define")==-1){ iFrom=0; sVal=CDataXMLSaver::GetInstringPart(Format("$=<PARDEF:%s=",sVar),">",sWPTemplateSource,iFrom); }else{ sVal=_atr(Format("[%s]",sVar),sWPTemplateSource); } } } return TRUE; } DWORD WINAPI CallTemplatePositionDialog_InThread(LPVOID p) { CWPT* wpt=(CWPT*)p; CallTemplatePositionDialog(wpt); return 1; } DWORD WINAPI CallTemplatePositionDialog_InThread2(LPVOID p) { CWPT* wpt=(CWPT*)p; CallTemplatePositionDialog(wpt); if(pMainDialogWindow){ pMainDialogWindow->OrderModifierForNextWallpaper=-2; pMainDialogWindow->PostMessage(WM_COMMAND,ID_SYSTRAY_CHANGEWALLPAPER,0); } return 1; } BOOL CallTemplatePositionDialog(CWPT* wpt,CRect* pCurRect, BOOL bSilent) { if(wpt==0){ return FALSE; } if(lOnTemplParamsFileLock>0){ if(!bSilent){ AfxMessageBox(_l("Another dialog is opened already. Close it first!")); } return FALSE; } SimpleTracker Track(lOnTemplParamsFileLock); int iActionIndex=-1; if(!pCurRect){ iActionIndex=aActionsStrings.Add(wpt->sActionPosition); } aWPTOptions.FreeMemory(); CString sWPParValue; CString sXName=CDataXMLSaver::GetInstringPart("X:(",")",wpt->sActionPosition); ReadSingleTemplateVar(wpt->sWPFileName,sXName,sWPParValue); if(pCurRect){ pCurRect->left=atol(sWPParValue); } aWPTOptions.AddOptionHolder_Long(sXName,atol(sWPParValue)); CString sYName=CDataXMLSaver::GetInstringPart("Y:(",")",wpt->sActionPosition); ReadSingleTemplateVar(wpt->sWPFileName,sYName,sWPParValue); if(pCurRect){ pCurRect->top=atol(sWPParValue); } aWPTOptions.AddOptionHolder_Long(sYName,atol(sWPParValue)); CString sWName=CDataXMLSaver::GetInstringPart("W:(",")",wpt->sActionPosition); ReadSingleTemplateVar(wpt->sWPFileName,sWName,sWPParValue); if(pCurRect){ pCurRect->right=pCurRect->left+atol(sWPParValue); } aWPTOptions.AddOptionHolder_Long(sWName,atol(sWPParValue)); CString sHName=CDataXMLSaver::GetInstringPart("H:(",")",wpt->sActionPosition); ReadSingleTemplateVar(wpt->sWPFileName,sHName,sWPParValue); if(pCurRect){ pCurRect->bottom=pCurRect->top+atol(sWPParValue); } aWPTOptions.AddOptionHolder_Long(sHName,atol(sWPParValue)); if(iActionIndex!=-1){ CTemplateActions_SetPos_InThread* p=new CTemplateActions_SetPos_InThread; p->m_iAction=iActionIndex; p->m_pDialog=0; p->pWpt=wpt; TemplateActions_SetPos_InThread(LPVOID(p)); POSITION pos=aWPTOptions.aLongHolder.GetStartPosition(); CString sKey,sTempVal; long lVal; while(pos){ aWPTOptions.aLongHolder.GetNextAssoc(pos,sKey,lVal); WriteSingleTemplateVar(wpt->sWPFileName,sKey,Format("%i",lVal)); } } aWPTOptions.FreeMemory(); //int iActiveWpt=GetTemplateMainIndex(sCurrentWidget); //pMainDialogWindow->PostMessage(WM_COMMAND,WM_USER+CHANGE_TEMPL_PAR+iActiveWpt,255); return TRUE; }
[ "wplabs@3fb49600-69e0-11de-a8c1-9da277d31688" ]
[ [ [ 1, 1090 ] ] ]
2aa000c28ebd8dfd6e9c20ff6e1b3fcafda5aba6
57855d23617d6a65298c2ae3485ba611c51809eb
/Zen/plugins/ZOpenAL/src/Resource.cpp
2fef5c2ee8373959b50a1416e896188ff57b5715
[]
no_license
Azaezel/quillus-daemos
7ff4261320c29e0125843b7da39b7b53db685cd5
8ee6eac886d831eec3acfc02f03c3ecf78cc841f
refs/heads/master
2021-01-01T20:35:04.863253
2011-04-08T13:46:40
2011-04-08T13:46:40
32,132,616
2
0
null
null
null
null
UTF-8
C++
false
false
4,755
cpp
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ // IndieZen Game Engine Framework // // Copyright (C) 2001 - 2007 Tony Richards // // 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. // // Tony Richards [email protected] //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ #include "Resource.hpp" #include <iostream> //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ namespace Zen { namespace ZOpenAL { //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ SoundResource::SoundResource(ALuint _bufferID) { m_bufferID = _bufferID; } //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ SoundResource::~SoundResource() { if ((m_data)&&(m_internalMalloc)) free(m_data); else alutUnloadWAV(m_format, m_data, m_size, m_freq); alDeleteBuffers(1,&m_bufferID); } //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ Scripting::I_ObjectReference* SoundResource::getScriptObject() { // TODO Make thread safe? if (m_pScriptObject == NULL) { m_pScriptObject = new ScriptObjectReference_type (m_pScriptModule, m_pScriptModule->getScriptType(getScriptTypeName()), getSelfReference().lock()); } return m_pScriptObject; } //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ int SoundResource::getFormat() { return m_format; } //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ void SoundResource::setFormat(int _format) { m_format = _format; //TODO: determine from the format if we're mono, or multi-channel sound } //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ int SoundResource::getSize() { return m_size; } //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ void SoundResource::setSize(int _size) { m_size = _size; } //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ int SoundResource::getFreq() { return m_freq; } //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ void SoundResource::setFreq(int _freq) { m_freq = _freq; } //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ void* SoundResource::getData() { return m_data; } //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ void SoundResource::setData(void* _data) { m_data = _data; } //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ void SoundResource::setIs3d(bool _is3d) { //TODO: check file format and default it to 2d sound if it's non-monural! m_is3d = _is3d; } //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ bool SoundResource::getIs3d() { return m_is3d; } //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ unsigned int SoundResource::getBufferID() { return m_bufferID; } //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ void SoundResource::setBufferID(unsigned int _bufferID) { m_bufferID = _bufferID; } //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ bool SoundResource::isInternallyMalloced() { return m_internalMalloc; } //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ void SoundResource::setIsInternallyMalloced(bool _malloced) { m_internalMalloc = _malloced; } //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ } // namespace ZOpenAL } // namespace Zen //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
[ "sgtflame@Sullivan", "[email protected]" ]
[ [ [ 1, 38 ], [ 41, 155 ] ], [ [ 39, 40 ] ] ]
f8c4a81e62acc9b8eaa2ba8b6875c422bcf73654
62c9cb0899bbb36d3e742559831f84054b57d790
/DeviceAdapters/ABS/ABSCamera.h
0d58eacba4d6de7b148147f5037870ab192e847a
[]
no_license
astraw/micromanager1.3
b1a245f676f32bbaf1cda7cecbaaf0a5c661ad6c
6032a1916442dfd1847bef0ed1d5bd1895334c1d
refs/heads/master
2020-06-05T02:37:31.526258
2009-04-28T16:58:58
2009-04-28T16:58:58
187,348
2
0
null
null
null
null
ISO-8859-13
C++
false
false
3,446
h
///////////////////////////////////////////////////////////////////////////// // Name: ABSCamera.h // Purpose: Definition der Kameraklasse als Adapter für µManager // Author: Michael Himmelreich // Created: 31. Juli 2007 // Copyright: (c) Michael Himmelreich // Project: ConfoVis ///////////////////////////////////////////////////////////////////////////// #ifndef _ABSCAMERA_H_ #define _ABSCAMERA_H_ #include "MMDevice.h" #include "DeviceBase.h" #include "ImgBuffer.h" #include "camusb_api.h" #include <string> #include <map> ////////////////////////////////////////////////////////////////////////////// // Error codes // #define ERR_UNKNOWN_MODE 102 #define ERR_UNKNOWN_POSITION 103 class ABSCamera : public CCameraBase<ABSCamera> { public: ABSCamera(int iDeviceNumber, const char* szDeviceName); ~ABSCamera(); // MMDevice API // ------------ int Initialize(); int Shutdown(); void GetName(char* name) const; bool Busy(); // MMCamera API // ------------ int SnapImage(); const unsigned char* GetImageBuffer(); unsigned int GetNumberOfChannels() const; const unsigned int* GetImageBufferAsRGB32(); unsigned GetImageWidth() const; unsigned GetImageHeight() const; unsigned GetImageBytesPerPixel() const; unsigned GetBitDepth() const; long GetImageBufferSize() const; double GetExposure() const; void SetExposure(double exp); int SetROI( unsigned x, unsigned y, unsigned xSize, unsigned ySize ); int GetROI( unsigned& x, unsigned& y, unsigned& xSize, unsigned& ySize ); int ClearROI(); int GetBinning() const; int SetBinning(int binSize); //int StartSequenceAcquisition(long /*numImages*/, double /*interval_ms*/, bool /*stopOnOverflow*/); // action interface // ---------------- int OnExposure(MM::PropertyBase* pProp, MM::ActionType eAct); int OnBinning(MM::PropertyBase* pProp, MM::ActionType eAct); int OnPixelType(MM::PropertyBase* pProp, MM::ActionType eAct); int OnGain(MM::PropertyBase* pProp, MM::ActionType eAct); int OnReadoutTime(MM::PropertyBase* /* pProp */, MM::ActionType /* eAct */) { return DEVICE_OK; }; private: std::string m_szDeviceName; int UpdateExposureLimits(void); int createExposure(); int createBinning(); int createPixelType(); int createGain(); ImgBuffer imageBuffer; bool initialized; bool busy; unsigned int numberOfChannels; unsigned char deviceNumber; unsigned __int64 cameraFunctionMask; S_CAMERA_VERSION camVersion; S_RESOLUTION_CAPS* resolutionCap; S_PIXELTYPE_CAPS* pixelTypeCap; S_GAIN_CAPS* gainCap; S_EXPOSURE_CAPS* exposureCap; S_AUTOEXPOSURE_CAPS* autoExposureCap; unsigned char *imageBufRead; void GenerateSyntheticImage(ImgBuffer& img, double exp); int ResizeImageBuffer(); void ShowError( unsigned int errorNumber ) const; void ShowError() const; void* GetCameraCap( unsigned __int64 CamFuncID ) const; int GetCameraFunction( unsigned __int64 CamFuncID, void* functionPara, unsigned long size, void* functionParamOut = NULL, unsigned long sizeOut = 0 ) const; int SetCameraFunction( unsigned __int64 CamFuncID, void* functionPara, unsigned long size ) const; }; #endif //_ABSCAMERA_H_
[ "OD@d0ab736e-dc22-4aeb-8dc9-08def0aa14fd", "nico@d0ab736e-dc22-4aeb-8dc9-08def0aa14fd" ]
[ [ [ 1, 63 ], [ 65, 110 ] ], [ [ 64, 64 ] ] ]
912e914312dd2e24ef9186903d5b7e075e3f183a
b38ab5dcfb913569fc1e41e8deedc2487b2db491
/libraries/DX8FX/module/Device.cpp
1c4ab24de636ad7e046161dfc5df76d62f108c21
[]
no_license
santosh90n/Fury2
dacec86ab3972952e4cf6442b38e66b7a67edade
740a095c2daa32d33fdc24cc47145a1c13431889
refs/heads/master
2020-03-21T00:44:27.908074
2008-10-16T07:09:17
2008-10-16T07:09:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,310
cpp
#include "../header/DX8FX.hpp" Device::Device(int Width, int Height) { _device = 0; init(Width, Height); Global->Devices.push_back(this); } Device::~Device() { DeviceVector::iterator iter = std::find(Global->Devices.begin(), Global->Devices.end(), this); if (iter != Global->Devices.end()) { Global->Devices.erase(iter); } uninit(); } bool Device::init(int Width, int Height) { D3DPRESENT_PARAMETERS ppPresent; LPDIRECT3DDEVICE8 devDevice = 0; ZeroMemory(&ppPresent, sizeof(ppPresent)); ppPresent.Windowed = Global->Windowed; ppPresent.SwapEffect = D3DSWAPEFFECT_DISCARD; ppPresent.BackBufferFormat = D3DFMT_A8R8G8B8; ppPresent.BackBufferWidth = Width; ppPresent.BackBufferHeight = Height; ppPresent.BackBufferCount = 1; Global->D3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, Global->Window, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &ppPresent, &devDevice); if (devDevice) { _width = Width; _height = Height; _windowed = Global->Windowed; _device = devDevice; return true; } return false; } void Device::uninit() { if (!_textures.empty()) { // destroy textures } if (_device) { COMDestroy(_device); } } void Device::setTexture(Texture *newTexture, int stage) { return; } Texture* Device::getTexture(int stage) { return Null; }; void Device::setRenderTarget(Texture *newTarget) { return; } Texture* Device::getDefaultRenderTarget() { return Null; } Texture* Device::getRenderTarget() { return Null; }; bool Device::ready() { return (_device != Null); } template <class Type> void Device::setVertexFormat(Type& Vertex) { if (ready()) { _device->SetVertexShader(getVertexShader<Type>()); } return; } template <class Type> void Device::drawTrangles(Type* Vertexes, int Count) { if (ready()) { if (Count >= 1) { _device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, Count, (void*)Vertexes, sizeof(Type)); } } return; } template <class Type> void Device::drawLines(Type* Vertexes, int Count) { if (ready()) { if (Count >= 1) { _device->DrawPrimitiveUP(D3DPT_LINELIST, Count, (void*)Vertexes, sizeof(Type)); } } return; } void Device::flip() { if (ready()) { _device->Present(Null, Null, Null, Null); } return; }
[ "kevin@1af785eb-1c5d-444a-bf89-8f912f329d98" ]
[ [ [ 1, 105 ] ] ]
be3d424b60687108caa20558f746e892cb32174b
867f5533667cce30d0743d5bea6b0c083c073386
/EchoServer/EchoServer_Cxx/EchoServer_Cxx.cpp
e860dddfe83568b47d91a5bcb38199adac8796fe
[]
no_license
mei-rune/jingxian-project
32804e0fa82f3f9a38f79e9a99c4645b9256e889
47bc7a2cb51fa0d85279f46207f6d7bea57f9e19
refs/heads/master
2022-08-12T18:43:37.139637
2009-12-11T09:30:04
2009-12-11T09:30:04
null
0
0
null
null
null
null
GB18030
C++
false
false
611
cpp
// cxxTester.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> #include "acceptor.h" int _tmain(int argc, _TCHAR* argv[]) { WSADATA wsaData; if ( 0 != WSAStartup( MAKEWORD( 2, 2 ), &wsaData ) ) return false; try { server svr; svr.start( new acceptor( svr, "0.0.0.0", 30003 ) ); svr.runForever(); } catch( std::exception& e) { std::cout << e.what() << std::endl; } //{ //Iterator it( 0,10, 1 ); //while( it.next() ) //{ // std::cout << it.current() << std::endl; //} //} WSACleanup( ); return 0; }
[ "runner.mei@0dd8077a-353d-11de-b438-597f59cd7555" ]
[ [ [ 1, 39 ] ] ]
1a0f4b47c02bcfa9c648fa080f8132eb46f463b3
aa028d1c3bd1870bf3d52f801de824bd1c9d6408
/IrrHelloWorld/jni/ArchiveHelper.cpp
9cc5a721bc33d484aecb77098ad08041aae97af7
[]
no_license
androids7/irrlicht-examples
d9b3da312a2b0c665105b83d037af43633dd2c94
f2ed239ddc542785fef72498bd3f09a90b334cd6
refs/heads/master
2021-12-02T03:05:11.651328
2010-10-15T06:20:53
2010-10-15T06:20:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,942
cpp
/* * ArchiveHelper.cpp * * Created on: Oct 14, 2010 * Author: dschaefer */ #include "ArchiveHelper.h" #include <android/log.h> ArchiveHelper::ArchiveHelper(JNIEnv * env, jobject archiveHelper) { mEnv = env; mArchiveHelper = env->NewGlobalRef(archiveHelper); } ArchiveHelper::~ArchiveHelper() { mEnv->DeleteGlobalRef(mArchiveHelper); } u32 ArchiveHelper::getSize(const path & filename) { jclass cls = mEnv->GetObjectClass(mArchiveHelper); jmethodID getSize = mEnv->GetMethodID(cls, "getSize", "(Ljava/lang/String;)I"); mEnv->DeleteLocalRef(cls); jstring str = mEnv->NewStringUTF(filename.c_str()); u32 size = mEnv->CallIntMethod(mArchiveHelper, getSize, str); mEnv->DeleteLocalRef(str); return size; } jobject ArchiveHelper::openFile(const path & filename) { jclass cls = mEnv->GetObjectClass(mArchiveHelper); jmethodID openFile = mEnv->GetMethodID(cls, "openFile", "(Ljava/lang/String;)Ljava/io/InputStream;"); mEnv->DeleteLocalRef(cls); jstring str = mEnv->NewStringUTF(filename.c_str()); jobject inputStream = mEnv->CallObjectMethod(mArchiveHelper, openFile, str); mEnv->DeleteLocalRef(str); return mEnv->NewGlobalRef(inputStream); } void ArchiveHelper::releaseFile(jobject inputStream) { mEnv->DeleteGlobalRef(inputStream); } s32 ArchiveHelper::read(jobject inputStream, void * buffer, u32 sizeToRead) { jclass cls = mEnv->GetObjectClass(mArchiveHelper); jmethodID read = mEnv->GetStaticMethodID(cls, "read", "(Ljava/io/InputStream;[B)I"); jbyteArray byteArray = mEnv->NewByteArray(sizeToRead); s32 n = mEnv->CallStaticIntMethod(cls, read, inputStream, byteArray); mEnv->DeleteLocalRef(cls); jboolean isCopy; jbyte * b = mEnv->GetByteArrayElements(byteArray, &isCopy); for (int i = 0; i < n; ++i) ((char *)buffer)[i] = b[i]; mEnv->ReleaseByteArrayElements(byteArray, b, 0); mEnv->DeleteLocalRef(byteArray); return n; }
[ [ [ 1, 64 ] ] ]
cd3a22edf8d1e2bd88911c5be2b6c25603b6f707
9bd0004220edc6cde7927d06f4d06d05a57d6d7d
/xq/bitmap.h
da9ac55b12513b185e35d05c45b9073e79dfea87
[]
no_license
lwm3751/folium
32b8c1450d8a1dc1c899ac959493fd4ae5166264
e32237b6bb5dabbce64ea08e2cf8f4fe60b514d5
refs/heads/master
2021-01-22T03:12:58.594929
2011-01-09T15:36:02
2011-01-09T15:36:02
26,789,096
0
0
null
null
null
null
UTF-8
C++
false
false
5,110
h
#ifndef _BITMAP_H_ #define _BITMAP_H_ #include "int.h" #include "xq_data.h" namespace folium { class Bitmap { public: Bitmap(); void do_move(uint, uint); void undo_move(uint, uint, uint); uint nonempty_up_1(uint)const; uint nonempty_down_1(uint)const; uint nonempty_left_1(uint)const; uint nonempty_right_1(uint)const; uint nonempty_up_2(uint)const; uint nonempty_down_2(uint)const; uint nonempty_left_2(uint)const; uint nonempty_right_2(uint)const; uint mask(uint, uint)const; uint distance(uint, uint)const; bool distance_is_0(uint, uint)const; bool distance_is_1(uint, uint)const; void reset (); void setbit(uint); private: uint xinfo(uint, uint)const; uint yinfo(uint, uint)const; void changebit(uint); static uint prev_1(uint info); static uint prev_2(uint info); static uint next_1(uint info); static uint next_2(uint info); private: uint16 m_lines[20]; static const uint16 s_line_infos[10][1024]; static const uint8 s_bit_counts[1024]; static const uint16 s_distance_infos[91][128]; }; //Bitmap inline uint Bitmap::xinfo(uint x, uint y)const { assert(x < 9UL && y < 10UL); return s_line_infos[x][m_lines[y]]; } inline uint Bitmap::yinfo(uint x, uint y)const { assert(x < 9UL && y < 10UL); return s_line_infos[y][m_lines[x+10]]; } inline void Bitmap::setbit(uint sq) { uint x = coordinate_x(sq); uint y = coordinate_y(sq); m_lines[y] |= 1UL << x; m_lines[x+10UL] |= 1UL << y; } inline void Bitmap::changebit(uint sq) { uint x = coordinate_x(sq); uint y = coordinate_y(sq); m_lines[y] ^= 1UL << x; m_lines[x+10UL] ^= 1UL << y; } inline uint Bitmap::prev_1(uint info) { return info & 0xf; } inline uint Bitmap::prev_2(uint info) { return (info >> 4) & 0xf; } inline uint32 Bitmap::next_1(uint info) { return (info >> 8) & 0xf; } inline uint Bitmap::next_2(uint info) { return (info >> 12) & 0xf; } inline void Bitmap::do_move(uint src, uint dst) { changebit(src); setbit(dst); } inline void Bitmap::undo_move(uint src, uint dst, uint dst_piece) { if (dst_piece == EmptyIndex) changebit(dst); changebit(src); } inline uint Bitmap::nonempty_up_1(uint sq)const { uint x = coordinate_x(sq); uint y = coordinate_y(sq); return xy_coordinate(x, Bitmap::next_1(yinfo(x, y))); } inline uint Bitmap::nonempty_down_1(uint sq)const { uint x = coordinate_x(sq); uint y = coordinate_y(sq); return xy_coordinate(x, Bitmap::prev_1(yinfo(x, y))); } inline uint Bitmap::nonempty_left_1(uint sq)const { uint x = coordinate_x(sq); uint y = coordinate_y(sq); return xy_coordinate(Bitmap::prev_1(xinfo(x, y)), y); } inline uint Bitmap::nonempty_right_1(uint sq)const { uint x = coordinate_x(sq); uint y = coordinate_y(sq); return xy_coordinate(Bitmap::next_1(xinfo(x, y)), y); } inline uint Bitmap::nonempty_up_2(uint sq)const { uint x = coordinate_x(sq); uint y = coordinate_y(sq); return xy_coordinate(x, Bitmap::next_2(yinfo(x, y))); } inline uint Bitmap::nonempty_down_2(uint sq)const { uint x = coordinate_x(sq); uint y = coordinate_y(sq); return xy_coordinate(x, Bitmap::prev_2(yinfo(x, y))); } inline uint Bitmap::nonempty_left_2(uint sq)const { uint x = coordinate_x(sq); uint y = coordinate_y(sq); return xy_coordinate(Bitmap::prev_2(xinfo(x, y)), y); } inline uint Bitmap::nonempty_right_2(uint sq)const { uint x = coordinate_x(sq); uint y = coordinate_y(sq); return xy_coordinate(Bitmap::next_2(xinfo(x, y)), y); } inline uint Bitmap::mask(uint src, uint dst)const { uint info = s_distance_infos[src][dst]; assert((info >> 10) < 20); return info & m_lines[info >> 10]; } inline uint Bitmap::distance(uint src, uint dst)const { return s_bit_counts[mask(src, dst)]; } inline bool Bitmap::distance_is_0(uint src, uint dst)const { return mask(src, dst) == 0; } inline bool Bitmap::distance_is_1(uint src, uint dst)const { register uint m = mask(src, dst); return (m&(m-1)) == 0; } inline Bitmap::Bitmap() { reset(); } inline void Bitmap::reset() { memset(m_lines, 0, 38); m_lines[19] = 1023; } }//namespace folium #endif //_BITMAP_H_
[ "lwm3751@cb49bd84-cb2d-0410-93fd-e1760d46b244" ]
[ [ [ 1, 187 ] ] ]
27832b8913b7fcab2b3170bec8e1e6d36b44b085
335783c9e5837a1b626073d1288b492f9f6b057f
/source/fbxcmd/daolib/Model/Common/color4.h
af686905ab3c34524200b3e044a21aa296c95250
[ "BSD-3-Clause", "LicenseRef-scancode-warranty-disclaimer", "BSD-2-Clause" ]
permissive
code-google-com/fbx4eclipse
110766ee9760029d5017536847e9f3dc09e6ebd2
cc494db4261d7d636f8c4d0313db3953b781e295
refs/heads/master
2016-09-08T01:55:57.195874
2009-12-03T20:35:48
2009-12-03T20:35:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,885
h
#pragma once #include "vector3f.h" #include "vector4f.h" class Color4 { public: float r,g,b,a; // Constructors Color4() { r = g = b = a = 1.0f; } Color4(float R, float G, float B, float A=1.0f) { r = R; g = G; b = B; a=A; } Color4(double R, double G, double B, double A=1.0) { r = (float)R; g = (float)G; b = (float)B; a = (float)A; } Color4(int R, int G, int B, int A) { r = (float)R; g = (float)G; b = (float)B; a = (float)A; } Color4(const Color4& v) { r = v.r; g = v.g; b = v.b; a = v.a; } explicit Color4(DWORD rgb); // from Windows RGB value Color4(Vector3f p) { r = p.x; g = p.y; b = p.z; } Color4(Vector4f p) { r = p.x; g = p.y; b = p.z; a = p.w; } Color4(float af[], int len = 3) { r = af[0]; g = af[1]; b = af[2]; a = len > 3 ? af[3] : 1.0f; } // Access operators float& operator[](int i) { return (&r)[i]; } const float& operator[](int i) const { return (&r)[i]; } // Convert to Vector3f operator Vector3f() { return Vector3f(r,g,b); } operator Vector4f() { return Vector4f(r,g,b,a); } void Set(float R, float G, float B, float A=1.0f) { r = R; g = G; b = B; a=A; } void Set(const Color4& v) { r = v.r; g = v.g; b = v.b; a = v.a; } void Set(DWORD rgb); // from Windows RGB value void Set(const Vector3f& p) { r = p.x; g = p.y; b = p.z; } void Set(const Vector4f& p) { r = p.x; g = p.y; b = p.z; a = p.w; } void Set(float af[], int len = 3) { r = af[0]; g = af[1]; b = af[2]; a = len > 3 ? af[3] : 1.0f; } }; inline BYTE GetR(COLORREF argb) { return ((BYTE)(argb)); } inline BYTE GetG(COLORREF argb) { return (LOBYTE(((WORD)(argb)) >> 8)); } inline BYTE GetB(COLORREF argb) { return (LOBYTE((argb)>>16)); } inline BYTE GetA(COLORREF argb) { return ((BYTE)((argb)>>24)); } inline COLORREF ToARGB(BYTE a, BYTE r, BYTE g, BYTE b) { return ((COLORREF)((((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16))|(((DWORD)(BYTE)(a))<<24))); } #pragma region ColorRef typedef struct ColorRef { BYTE a,b,g,r; // Constructors ColorRef(){ a=0xFF, b=0, g=0, r=0; } ColorRef(COLORREF argb) { a=GetA(argb), r=GetR(argb), g=GetG(argb), b=GetB(argb); } ColorRef(BYTE R, BYTE G, BYTE B, BYTE A=0xFF) { a=A, r=R, g=G, b=B; } ColorRef(float R, float G, float B, float A=1.0f) { a=ToByte(A), r=ToByte(R), g=ToByte(G), b=ToByte(B); } ColorRef(const ColorRef& c) { a = c.a; r = c.r; g = c.g; b = c.b; } ColorRef(float af[3]) { a = 0xFF, r=ToByte(af[0]), g=ToByte(af[1]), b=ToByte(af[2]); } ColorRef(const Vector3f& pt) { a = 0xFF, r=ToByte(pt.x), g=ToByte(pt.y), b=ToByte(pt.z); } //ColorRef(const Color4& c) { a = 0xFF, r=ToByte(c.r), g=ToByte(c.g), b=ToByte(c.b); } static inline BYTE ToByte(float val) { return BYTE(val * 255.0f); } static inline float ToFloat(BYTE val) { return float(val) / 255.0f; } static inline BYTE GetR(COLORREF argb) { return ((BYTE)(argb)); } static inline BYTE GetG(COLORREF argb) { return (LOBYTE(((WORD)(argb)) >> 8)); } static inline BYTE GetB(COLORREF argb) { return (LOBYTE((argb)>>16)); } static inline BYTE GetA(COLORREF argb) { return ((BYTE)((argb)>>24)); } static inline COLORREF ToARGB(BYTE a, BYTE r, BYTE g, BYTE b) { return ((COLORREF)((((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16))|(((DWORD)(BYTE)(a))<<24))); } // Unary operators ColorRef operator-() const { return(ColorRef(a,-r,-g,-b)); } ColorRef operator+() const { return *this; } // Relational operators int operator==(const ColorRef& c) const { return ((a == c.a) && (r == c.r) && (g == c.g) && (b == c.b)); } int operator!=(const ColorRef& c) const { return ((a != c.a) || (r != c.r) || (g != c.g) || (b != c.b)); } operator Vector3f() { return Vector3f(ToFloat(r), ToFloat(g), ToFloat(b)); } //operator Color4() { return Color4(ToFloat(r), ToFloat(g), ToFloat(b)); } } ColorRef; #pragma endregion
[ "tazpn314@ccf8930c-dfc1-11de-9043-17b7bd24f792" ]
[ [ [ 1, 86 ] ] ]
52996beecf6b076d8993e25bc3a32e6b47cf0a00
df070aa6eb5225412ebf0c3916b41449edfa16ac
/AVS_Transcoder_SDK/kernel/audio/AudioTransCoder_Lame/av3enc/src/sam_cbc_huffman.cpp
8aad7abdd2051dbca5289acf02218180a01e0af0
[]
no_license
numericalBoy/avs-transcoder
659b584cc5bbc4598a3ec9beb6e28801d3d33f8d
56a3238b34ec4e0bf3a810cedc31284ac65361c5
refs/heads/master
2020-04-28T21:08:55.048442
2010-03-10T13:28:18
2010-03-10T13:28:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
54,562
cpp
/* *********************************************************************** * COPYRIGHT AND WARRANTY INFORMATION * * Copyright 2004, Audio Video Coding Standard, Part III * * This software module was originally developed by * * JungHoe Kim ([email protected]), Samsung AIT * * edited by * * Lei Miao ([email protected]), Samsung AIT * Lei Miao, CBC Multi-channel extension, 2005-09-19 * Lei Miao, CBC codebook reduction, 2005-12-22 * * DISCLAIMER OF WARRANTY * * These software programs are available to the users without any * license fee or royalty on an "as is" basis. The AVS disclaims * any and all warranties, whether express, implied, or statutory, * including any implied warranties of merchantability or of fitness * for a particular purpose. In no event shall the contributors or * the AVS be liable for any incidental, punitive, or consequential * damages of any kind whatsoever arising from the use of this program. * * This disclaimer of warranty extends to the user of this program * and user's customers, employees, agents, transferees, successors, * and assigns. * * The AVS does not represent or warrant that the program furnished * hereunder are free of infringement of any third-party patents. * Commercial implementations of AVS, including shareware, may be * subject to royalty fees to patent holders. Information regarding * the AVS patent policy is available from the AVS Web site at * http://www.avs.org.cn * * THIS IS NOT A GRANT OF PATENT RIGHTS - SEE THE AVS PATENT POLICY. ************************************************************************ */ #include "stdlib.h" #include "stdio.h" #include <memory.h> #include <math.h> /* codebook reduction */ unsigned int codeBook[36][7][16] = { {{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}}, {{1, 0, 6, 22, 7, 20, 21, 36, 1, 47, 19, 187, 8, 92, 37, 186}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}}, {{5, 15, 9, 8, 13, 3, 7, 29, 0, 5, 4, 28, 6, 25, 2, 24}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}}, {{1, 2, 6, 5, 7, 28, 15, 19, 0, 16, 29, 75, 6, 36, 17, 74}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}}, {{1, 6, 2, 9, 3, 23, 31, 17, 0, 29, 28, 16, 10, 61, 22, 60}, {1, 24, 0, 28, 13, 59, 15, 19, 8, 116, 11, 36, 25, 117, 10, 37}, {4, 3, 59, 6, 2, 6, 4, 28, 11, 10, 14, 58, 15, 0, 15, 5}, {6, 14, 1, 10, 0, 8, 4, 19, 15, 7, 5, 22, 6, 47, 18, 46}, {4, 11, 2, 14, 61, 14, 4, 60, 3, 10, 6, 0, 6, 15, 31, 5}, {1, 4, 15, 26, 14, 27, 10, 22, 1, 24, 1, 1, 25, 47, 0, 46}, {1, 8, 13, 25, 0, 10, 15, 11, 24, 117, 59, 116, 28, 36, 19, 37}}, {{1, 7, 5, 5, 6, 17, 4, 39, 0, 16, 18, 31, 6, 38, 14, 30}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}}, {{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {12, 36, 15, 17, 14, 16, 5, 23, 13, 37, 4, 22, 3, 19, 0, 10}, {10, 0, 244, 121, 14, 6, 120, 125, 11, 1, 245, 123, 4, 1, 124, 63}, {2, 1, 0, 12, 14, 8, 6, 55, 15, 11, 9, 15, 10, 26, 14, 54}, {10, 11, 14, 4, 244, 245, 121, 123, 2, 3, 6, 0, 120, 126, 127, 62}, {6, 5, 1, 29, 2, 31, 30, 18, 3, 0, 8, 39, 28, 2, 3, 38}, {12, 13, 14, 3, 15, 4, 5, 0, 36, 37, 16, 19, 17, 22, 23, 10}}, {{1, 0, 7, 26, 1, 110, 24, 222, 2, 446, 108, 894, 25, 1790, 109, 1791}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}}, {{1, 0, 5, 14, 6, 61, 31, 39, 1, 36, 60, 76, 8, 154, 37, 155}, {0, 14, 2, 12, 27, 124, 30, 52, 126, 854, 127, 426, 107, 855, 125, 212}, {2, 7, 1, 26, 3, 2, 7, 24, 0, 55, 12, 109, 2, 25, 13, 108}, {2, 14, 3, 30, 0, 26, 4, 62, 1, 63, 27, 103, 5, 50, 24, 102}, {1, 0, 5, 9, 1, 110, 25, 111, 7, 16, 1, 17, 26, 109, 24, 108}, {1, 15, 4, 25, 1, 0, 10, 47, 14, 2, 24, 6, 13, 46, 22, 7}, {0, 47, 9, 35, 7, 46, 10, 45, 13, 138, 44, 136, 12, 139, 16, 137}}, {{0, 12, 9, 26, 10, 16, 22, 61, 14, 63, 17, 60, 27, 47, 62, 46}, {5, 4, 6, 3, 14, 30, 0, 2, 7, 62, 8, 63, 5, 13, 9, 12}, {0, 2, 17, 16, 1, 3, 20, 24, 13, 11, 18, 19, 14, 15, 25, 21}, {2, 13, 14, 7, 12, 9, 3, 23, 15, 8, 6, 1, 10, 2, 0, 22}, {1, 12, 2, 14, 17, 18, 16, 21, 3, 13, 0, 15, 20, 23, 22, 19}, {5, 15, 13, 7, 14, 4, 8, 2, 0, 3, 6, 19, 5, 25, 24, 18}, {6, 7, 14, 4, 5, 8, 15, 9, 1, 1, 2, 13, 5, 0, 3, 12}}, {{1, 7, 5, 2, 6, 17, 1, 37, 1, 16, 19, 3, 3, 36, 0, 2}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}}, {{2, 14, 5, 3, 6, 27, 2, 24, 0, 31, 30, 14, 4, 15, 26, 25}, {6, 44, 4, 45, 0, 42, 2, 46, 14, 40, 1, 43, 15, 41, 3, 47}, {2, 3, 78, 35, 0, 5, 34, 38, 14, 15, 79, 36, 1, 6, 37, 16}, {3, 14, 0, 11, 15, 5, 4, 18, 1, 12, 8, 19, 10, 26, 55, 54}, {2, 14, 0, 1, 79, 78, 34, 37, 3, 15, 5, 6, 35, 36, 38, 16}, {6, 4, 15, 28, 1, 29, 1, 21, 3, 5, 4, 47, 0, 20, 22, 46}, {6, 11, 0, 14, 4, 1, 2, 3, 60, 40, 42, 41, 61, 43, 63, 62}}, {{22, 1, 0, 6, 23, 5, 4, 15, 2, 7, 3, 13, 10, 12, 14, 4}, {31, 0, 11, 3, 8, 1, 3, 29, 9, 2, 2, 28, 1, 30, 6, 10}, {27, 10, 0, 3, 11, 3, 2, 26, 9, 1, 1, 24, 2, 7, 25, 8}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {27, 8, 10, 2, 0, 2, 1, 26, 11, 1, 3, 7, 3, 25, 24, 9}, {2, 15, 13, 6, 12, 9, 7, 1, 14, 10, 8, 23, 3, 0, 2, 22}, {31, 10, 8, 0, 11, 2, 3, 6, 4, 5, 6, 30, 7, 28, 29, 9}}, {{1, 2, 7, 25, 0, 97, 26, 193, 1, 385, 99, 1537, 27, 1536, 98, 769}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}}, {{1, 3, 2, 7, 1, 15, 0, 6, 2, 28, 5, 58, 6, 118, 4, 119}, {1, 2, 0, 6, 29, 112, 15, 115, 226, 1817, 228, 909, 459, 1816, 458, 455}, {3, 0, 11, 5, 4, 6, 4, 40, 14, 122, 31, 246, 21, 60, 41, 247}, {2, 15, 2, 0, 3, 3, 12, 5, 1, 19, 27, 17, 14, 16, 26, 18}, {2, 12, 6, 13, 2, 123, 15, 60, 0, 491, 14, 244, 31, 980, 14, 981}, {0, 17, 5, 16, 7, 14, 6, 15, 9, 37, 8, 36, 5, 39, 6, 38}, {1, 251, 30, 249, 0, 500, 14, 248, 2, 2005, 127, 2007, 6, 2004, 126, 2006}}, {{1, 0, 4, 11, 6, 62, 29, 57, 1, 123, 63, 122, 10, 113, 60, 112}, {1, 5, 7, 0, 13, 2, 9, 3, 17, 33, 51, 49, 32, 97, 50, 96}, {7, 4, 0, 7, 1, 11, 4, 24, 10, 11, 27, 52, 6, 53, 25, 10}, {6, 14, 1, 5, 0, 8, 10, 22, 15, 23, 7, 9, 6, 18, 19, 8}, {7, 10, 13, 3, 12, 23, 4, 14, 4, 2, 0, 22, 6, 11, 15, 10}, {2, 3, 15, 21, 14, 2, 11, 24, 0, 8, 3, 25, 9, 26, 27, 20}, {1, 17, 9, 6, 7, 52, 12, 7, 5, 33, 2, 106, 0, 107, 27, 32}}, {{1, 5, 2, 8, 3, 1, 3, 26, 7, 27, 0, 5, 12, 18, 19, 4}, {0, 11, 4, 5, 12, 4, 14, 7, 27, 52, 30, 53, 31, 21, 6, 20}, {1, 3, 16, 20, 2, 14, 30, 21, 12, 9, 17, 26, 0, 11, 31, 27}, {3, 13, 12, 10, 11, 8, 3, 0, 15, 5, 4, 2, 9, 29, 1, 28}, {2, 10, 1, 0, 17, 16, 28, 24, 3, 11, 13, 15, 19, 18, 25, 29}, {4, 12, 13, 6, 15, 11, 4, 3, 14, 2, 5, 21, 7, 0, 1, 20}, {0, 30, 9, 6, 5, 8, 13, 4, 12, 56, 31, 10, 7, 57, 29, 11}}, {{1, 0, 6, 22, 7, 18, 21, 95, 1, 46, 19, 83, 8, 94, 40, 82}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}}, {{0, 13, 9, 24, 10, 63, 22, 61, 14, 17, 16, 47, 25, 60, 62, 46}, {1, 2, 6, 28, 15, 58, 0, 59, 11, 13, 9, 15, 8, 12, 10, 14}, {7, 4, 6, 5, 3, 2, 4, 7, 12, 11, 40, 41, 13, 0, 42, 43}, {6, 15, 0, 9, 1, 4, 5, 47, 14, 6, 7, 22, 8, 21, 20, 46}, {7, 12, 2, 13, 5, 40, 4, 41, 4, 11, 3, 0, 6, 42, 7, 43}, {6, 3, 2, 29, 15, 8, 0, 22, 1, 28, 1, 21, 9, 20, 47, 46}, {1, 11, 15, 3, 6, 10, 0, 9, 2, 33, 58, 32, 28, 34, 59, 35}}, {{1, 11, 10, 3, 9, 28, 0, 30, 12, 1, 29, 26, 8, 27, 31, 2}, {14, 17, 1, 23, 10, 18, 2, 0, 12, 16, 15, 19, 13, 22, 3, 1}, {10, 14, 12, 14, 13, 2, 15, 30, 12, 0, 13, 23, 1, 4, 22, 31}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {10, 11, 13, 0, 12, 13, 14, 24, 14, 1, 2, 4, 15, 25, 30, 31}, {2, 0, 12, 8, 15, 7, 9, 29, 13, 3, 10, 23, 6, 28, 2, 22}, {2, 9, 12, 13, 1, 14, 0, 3, 20, 16, 17, 21, 23, 22, 30, 31}}, {{28, 4, 29, 10, 0, 6, 7, 13, 1, 9, 5, 11, 8, 12, 15, 1}, {2, 22, 10, 23, 8, 26, 0, 3, 9, 27, 15, 4, 14, 5, 3, 12}, {2, 10, 24, 27, 8, 0, 26, 4, 9, 15, 25, 3, 14, 3, 5, 11}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {2, 8, 9, 14, 24, 27, 25, 4, 10, 15, 0, 3, 26, 5, 3, 11}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {2, 9, 8, 14, 10, 13, 0, 3, 24, 30, 31, 4, 25, 3, 5, 11}}, {{6, 11, 6, 5, 9, 30, 0, 7, 14, 31, 1, 3, 2, 4, 8, 10}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}}, {{2, 7, 5, 3, 6, 26, 1, 31, 12, 30, 28, 29, 4, 27, 0, 2}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}}, {{0, 11, 31, 27, 8, 19, 26, 61, 12, 20, 21, 60, 28, 59, 18, 58}, {3, 5, 1, 4, 13, 0, 14, 1, 9, 24, 10, 30, 8, 25, 11, 31}, {3, 2, 0, 1, 15, 13, 29, 2, 8, 9, 22, 23, 10, 12, 28, 3}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {3, 8, 13, 10, 31, 22, 1, 30, 2, 9, 14, 12, 0, 23, 3, 2}, {0, 11, 13, 7, 12, 9, 10, 4, 14, 5, 6, 2, 8, 31, 3, 30}, {3, 10, 13, 8, 1, 9, 14, 11, 5, 24, 0, 25, 4, 30, 1, 31}}, {{1, 6, 3, 9, 2, 23, 3, 17, 7, 0, 1, 16, 10, 5, 22, 4}, {0, 9, 5, 6, 14, 25, 13, 24, 8, 11, 7, 61, 31, 60, 4, 10}, {6, 2, 1, 0, 1, 15, 29, 28, 11, 9, 15, 13, 10, 8, 14, 12}, {4, 13, 14, 5, 15, 4, 10, 1, 12, 3, 7, 0, 6, 23, 2, 22}, {6, 11, 1, 10, 31, 11, 28, 9, 3, 8, 0, 9, 30, 8, 29, 10}, {2, 11, 13, 6, 15, 7, 10, 2, 12, 3, 8, 29, 9, 1, 0, 28}, {1, 10, 14, 30, 4, 3, 13, 0, 11, 2, 24, 63, 2, 3, 25, 62}}, {{1, 7, 5, 6, 6, 17, 4, 39, 0, 16, 18, 38, 7, 23, 10, 22}, {2, 0, 6, 3, 7, 13, 5, 12, 4, 63, 2, 62, 30, 58, 28, 59}, {0, 4, 6, 28, 2, 13, 23, 22, 12, 7, 63, 61, 10, 29, 62, 60}, {5, 12, 14, 6, 15, 4, 8, 2, 0, 3, 5, 19, 7, 26, 27, 18}, {0, 9, 2, 8, 7, 13, 25, 12, 5, 31, 13, 30, 29, 57, 24, 56}, {4, 12, 14, 4, 15, 5, 10, 1, 11, 3, 7, 27, 6, 0, 2, 26}, {2, 3, 7, 0, 6, 2, 5, 29, 15, 3, 13, 57, 4, 2, 12, 56}}, {{1, 0, 5, 30, 6, 18, 29, 39, 1, 62, 63, 38, 8, 115, 56, 114}, {3, 0, 4, 3, 10, 14, 6, 8, 5, 47, 2, 46, 22, 31, 9, 30}, {1, 5, 8, 30, 1, 14, 25, 24, 9, 31, 3, 55, 0, 26, 2, 54}, {6, 11, 1, 7, 0, 4, 6, 20, 14, 31, 5, 21, 8, 19, 30, 18}, {1, 9, 1, 1, 8, 63, 25, 62, 5, 0, 14, 26, 30, 55, 24, 54}, {4, 12, 14, 5, 15, 10, 7, 0, 13, 3, 6, 1, 4, 23, 2, 22}, {3, 4, 8, 18, 5, 2, 3, 11, 0, 39, 14, 30, 6, 31, 10, 38}}, {{1, 0, 6, 23, 7, 45, 21, 40, 1, 44, 17, 67, 9, 32, 41, 66}, {3, 1, 5, 6, 9, 11, 8, 8, 1, 1, 15, 0, 14, 19, 10, 18}, {2, 3, 12, 26, 2, 15, 29, 5, 3, 28, 3, 55, 0, 4, 2, 54}, {6, 0, 15, 8, 1, 7, 4, 21, 11, 29, 5, 19, 6, 20, 28, 18}, {1, 12, 1, 1, 8, 1, 18, 53, 5, 29, 15, 27, 28, 52, 19, 0}, {5, 12, 1, 5, 0, 7, 6, 30, 13, 31, 4, 28, 8, 19, 29, 18}, {3, 1, 9, 15, 5, 0, 8, 5, 2, 27, 14, 8, 3, 9, 12, 26}}, {{1, 0, 6, 15, 7, 27, 14, 17, 2, 25, 9, 49, 5, 16, 26, 48}, {0, 4, 5, 27, 31, 24, 26, 50, 28, 122, 59, 123, 60, 102, 58, 103}, {2, 3, 3, 31, 2, 14, 24, 61, 13, 1, 60, 11, 0, 25, 4, 10}, {7, 13, 11, 7, 0, 6, 8, 19, 2, 2, 3, 18, 10, 51, 24, 50}, {2, 7, 1, 1, 4, 59, 12, 22, 6, 0, 15, 10, 28, 23, 13, 58}, {5, 12, 4, 1, 1, 7, 13, 12, 15, 5, 1, 13, 4, 28, 29, 0}, {0, 21, 30, 47, 6, 59, 28, 46, 4, 41, 58, 88, 31, 40, 45, 89}}, {{1, 2, 6, 6, 7, 11, 7, 9, 1, 10, 0, 17, 1, 2, 3, 16}, {0, 2, 15, 24, 26, 109, 58, 119, 28, 205, 118, 204, 55, 108, 50, 103}, {3, 3, 2, 36, 2, 5, 3, 0, 8, 19, 297, 296, 3, 2, 149, 75}, {1, 8, 15, 26, 5, 29, 12, 28, 1, 55, 0, 54, 9, 2, 7, 6}, {2, 27, 1, 13, 0, 16, 12, 35, 7, 53, 12, 9, 7, 34, 5, 52}, {2, 0, 15, 3, 6, 14, 1, 2, 1, 29, 28, 31, 2, 13, 12, 30}, {0, 58, 28, 236, 6, 22, 10, 119, 4, 377, 95, 376, 15, 237, 46, 189}}, {{1, 0, 6, 60, 1, 123, 29, 245, 2, 114, 115, 977, 31, 489, 56, 976}, {1, 10, 1, 23, 6, 22, 1, 0, 3, 2, 29, 28, 31, 30, 9, 8}, {0, 4, 58, 119, 6, 15, 118, 45, 44, 47, 46, 41, 28, 40, 43, 42}, {2, 29, 1, 28, 31, 30, 25, 24, 27, 26, 5, 4, 7, 6, 1, 0}, {0, 48, 15, 51, 28, 99, 98, 105, 2, 104, 27, 107, 29, 106, 101, 100}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {1, 9, 3, 8, 3, 11, 1, 10, 0, 21, 20, 23, 9, 22, 17, 16}}, {{1, 0, 3, 20, 3, 17, 16, 42, 2, 87, 86, 37, 11, 36, 39, 38}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {2, 12, 27, 26, 5, 4, 7, 6, 1, 0, 3, 2, 29, 28, 31, 30}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {6, 14, 31, 30, 9, 8, 11, 10, 5, 4, 7, 6, 1, 0, 3, 2}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {6, 14, 31, 30, 9, 8, 11, 10, 5, 4, 7, 6, 1, 0, 3, 2}}, {{1, 1, 3, 0, 2, 3, 2, 21, 3, 20, 23, 22, 17, 16, 19, 18}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}}, {{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}}, {{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}}, {{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}} }; unsigned int codeBookLen[36][7][16] = { {{4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}}, {{1, 3, 4, 6, 4, 6, 6, 7, 3, 7, 6, 9, 5, 8, 7, 9}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}}, {{3, 4, 4, 4, 4, 4, 4, 5, 3, 4, 4, 5, 4, 5, 4, 5}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}}, {{1, 3, 4, 5, 4, 7, 6, 7, 3, 7, 7, 9, 5, 8, 7, 9}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}}, {{1, 4, 4, 5, 4, 6, 6, 6, 3, 6, 6, 6, 5, 7, 6, 7}, {2, 5, 2, 5, 4, 6, 4, 5, 4, 7, 4, 6, 5, 7, 4, 6}, {3, 3, 6, 5, 3, 3, 5, 5, 4, 4, 6, 6, 4, 3, 6, 5}, {3, 4, 3, 4, 3, 4, 4, 5, 4, 4, 4, 5, 4, 6, 5, 6}, {3, 4, 3, 4, 6, 6, 5, 6, 3, 4, 3, 3, 5, 6, 5, 5}, {2, 3, 4, 5, 4, 5, 4, 5, 3, 5, 4, 5, 5, 6, 5, 6}, {2, 4, 4, 5, 2, 4, 4, 4, 5, 7, 6, 7, 5, 6, 5, 6}}, {{1, 4, 4, 5, 4, 6, 5, 7, 3, 6, 6, 7, 5, 7, 6, 7}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}}, {{4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 7, 4, 6, 4, 6, 3, 6, 4, 7, 3, 6, 3, 6, 2, 5}, {4, 3, 8, 7, 4, 3, 7, 7, 4, 3, 8, 7, 3, 2, 7, 6}, {3, 3, 3, 4, 4, 4, 4, 6, 4, 4, 4, 5, 4, 5, 5, 6}, {4, 4, 4, 3, 8, 8, 7, 7, 3, 3, 3, 2, 7, 7, 7, 6}, {3, 3, 3, 5, 3, 5, 5, 5, 3, 4, 4, 6, 5, 5, 5, 6}, {4, 4, 4, 3, 4, 3, 3, 2, 7, 7, 6, 6, 6, 6, 6, 5}}, {{1, 3, 4, 6, 3, 8, 6, 9, 3, 10, 8, 11, 6, 12, 8, 12}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}}, {{1, 3, 4, 5, 4, 7, 6, 7, 3, 7, 7, 8, 5, 9, 7, 9}, {1, 4, 2, 4, 5, 7, 5, 6, 7, 10, 7, 9, 7, 10, 7, 8}, {2, 3, 4, 5, 3, 3, 5, 5, 4, 6, 6, 7, 4, 5, 6, 7}, {2, 4, 3, 5, 3, 5, 4, 6, 3, 6, 5, 7, 4, 6, 5, 7}, {2, 4, 3, 4, 4, 7, 5, 7, 3, 5, 3, 5, 5, 7, 5, 7}, {2, 4, 3, 5, 3, 4, 4, 6, 4, 5, 5, 6, 4, 6, 5, 6}, {1, 6, 4, 6, 3, 6, 4, 6, 4, 8, 6, 8, 4, 8, 5, 8}}, {{1, 4, 4, 5, 4, 5, 5, 6, 4, 6, 5, 6, 5, 6, 6, 6}, {3, 4, 3, 4, 4, 5, 3, 4, 4, 6, 4, 6, 4, 5, 4, 5}, {3, 3, 5, 5, 3, 3, 5, 5, 4, 4, 5, 5, 4, 4, 5, 5}, {3, 4, 4, 4, 4, 4, 4, 5, 4, 4, 4, 4, 4, 4, 4, 5}, {3, 4, 3, 4, 5, 5, 5, 5, 3, 4, 3, 4, 5, 5, 5, 5}, {3, 4, 4, 4, 4, 4, 4, 4, 3, 4, 4, 5, 4, 5, 5, 5}, {3, 4, 4, 4, 3, 4, 4, 4, 4, 5, 4, 5, 4, 5, 4, 5}}, {{1, 4, 4, 5, 4, 6, 5, 7, 3, 6, 6, 7, 5, 7, 6, 7}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}}, {{2, 4, 4, 4, 4, 5, 4, 5, 3, 5, 5, 5, 4, 5, 5, 5}, {3, 6, 3, 6, 3, 6, 3, 6, 4, 6, 3, 6, 4, 6, 3, 6}, {3, 3, 7, 6, 3, 3, 6, 6, 4, 4, 7, 6, 3, 3, 6, 5}, {3, 4, 3, 4, 4, 4, 4, 5, 3, 4, 4, 5, 4, 5, 6, 6}, {3, 4, 3, 3, 7, 7, 6, 6, 3, 4, 3, 3, 6, 6, 6, 5}, {3, 3, 4, 5, 3, 5, 4, 5, 3, 4, 4, 6, 4, 5, 5, 6}, {3, 4, 3, 4, 3, 3, 3, 3, 6, 6, 6, 6, 6, 6, 6, 6}}, {{5, 4, 4, 4, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3}, {5, 5, 4, 5, 4, 5, 3, 5, 4, 5, 3, 5, 3, 5, 3, 4}, {5, 4, 5, 5, 4, 3, 5, 5, 4, 3, 5, 5, 3, 3, 5, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {5, 4, 4, 3, 5, 5, 5, 5, 4, 3, 3, 3, 5, 5, 5, 4}, {3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 4, 4, 4, 5}, {5, 4, 4, 3, 4, 3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 4}}, {{1, 3, 4, 6, 3, 8, 6, 9, 3, 10, 8, 12, 6, 12, 8, 11}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}}, {{1, 3, 4, 5, 4, 8, 5, 7, 3, 9, 7, 10, 5, 11, 7, 11}, {1, 3, 2, 4, 6, 8, 5, 8, 9, 12, 9, 11, 10, 12, 10, 10}, {2, 2, 4, 4, 3, 4, 4, 6, 5, 8, 6, 9, 5, 7, 6, 9}, {2, 4, 3, 4, 3, 5, 4, 6, 3, 8, 5, 8, 4, 8, 5, 8}, {2, 5, 3, 5, 3, 7, 5, 6, 2, 9, 4, 8, 5, 10, 5, 10}, {2, 6, 3, 6, 3, 5, 3, 5, 4, 7, 4, 7, 4, 7, 4, 7}, {1, 9, 6, 9, 2, 10, 5, 9, 3, 12, 8, 12, 4, 12, 8, 12}}, {{1, 3, 4, 5, 4, 7, 6, 7, 3, 8, 7, 8, 5, 8, 7, 8}, {2, 3, 3, 3, 4, 4, 4, 4, 5, 6, 6, 6, 6, 7, 6, 7}, {3, 3, 3, 4, 3, 4, 4, 5, 4, 5, 5, 6, 4, 6, 5, 5}, {3, 4, 3, 4, 3, 4, 4, 5, 4, 5, 4, 5, 4, 5, 5, 5}, {3, 4, 4, 4, 4, 5, 4, 5, 3, 4, 3, 5, 4, 5, 5, 5}, {3, 3, 4, 5, 4, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 5}, {2, 5, 4, 5, 3, 6, 4, 5, 3, 6, 4, 7, 3, 7, 5, 6}}, {{1, 4, 4, 5, 4, 5, 5, 6, 4, 6, 5, 6, 5, 6, 6, 6}, {2, 4, 3, 4, 4, 4, 4, 4, 5, 6, 5, 6, 5, 5, 4, 5}, {3, 3, 5, 5, 3, 4, 5, 5, 4, 4, 5, 5, 3, 4, 5, 5}, {3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 4, 5}, {3, 4, 3, 3, 5, 5, 5, 5, 3, 4, 4, 4, 5, 5, 5, 5}, {3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 4, 4, 4, 5}, {2, 5, 4, 4, 3, 4, 4, 4, 4, 6, 5, 5, 4, 6, 5, 5}}, {{1, 3, 4, 6, 4, 6, 6, 8, 3, 7, 6, 8, 5, 8, 7, 8}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}}, {{1, 4, 4, 5, 4, 6, 5, 6, 4, 5, 5, 6, 5, 6, 6, 6}, {2, 4, 3, 5, 4, 6, 3, 6, 4, 6, 4, 6, 4, 6, 4, 6}, {3, 3, 5, 5, 3, 3, 5, 5, 4, 4, 6, 6, 4, 3, 6, 6}, {3, 4, 3, 4, 3, 4, 4, 6, 4, 4, 4, 5, 4, 5, 5, 6}, {3, 4, 3, 4, 5, 6, 5, 6, 3, 4, 3, 3, 5, 6, 5, 6}, {3, 3, 3, 5, 4, 4, 4, 5, 3, 5, 4, 5, 4, 5, 6, 6}, {2, 4, 4, 4, 3, 4, 3, 4, 4, 6, 6, 6, 5, 6, 6, 6}}, {{2, 4, 4, 4, 4, 5, 4, 5, 4, 4, 5, 5, 4, 5, 5, 4}, {4, 5, 3, 5, 4, 5, 3, 4, 4, 5, 4, 5, 4, 5, 3, 4}, {4, 4, 5, 5, 4, 3, 5, 5, 4, 3, 5, 5, 3, 3, 5, 5}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 3, 5, 5, 5, 5, 4, 3, 3, 3, 5, 5, 5, 5}, {3, 3, 4, 4, 4, 4, 4, 5, 4, 4, 4, 5, 4, 5, 4, 5}, {3, 4, 4, 4, 3, 4, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5}}, {{5, 4, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3}, {4, 5, 4, 5, 4, 5, 3, 4, 4, 5, 4, 4, 4, 4, 3, 4}, {4, 4, 5, 5, 4, 3, 5, 4, 4, 4, 5, 4, 4, 3, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 5, 5, 5, 4, 4, 4, 3, 3, 5, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 3, 3, 5, 5, 5, 4, 5, 4, 4, 4}}, {{3, 4, 4, 4, 4, 5, 4, 4, 4, 5, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}}, {{2, 4, 4, 4, 4, 5, 4, 5, 4, 5, 5, 5, 4, 5, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}}, {{1, 4, 5, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 5, 6}, {3, 4, 3, 4, 4, 4, 4, 4, 4, 5, 4, 5, 4, 5, 4, 5}, {3, 3, 4, 4, 4, 4, 5, 4, 4, 4, 5, 5, 4, 4, 5, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {3, 4, 4, 4, 5, 5, 4, 5, 3, 4, 4, 4, 4, 5, 4, 4}, {3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 4, 5}, {3, 4, 4, 4, 3, 4, 4, 4, 4, 5, 4, 5, 4, 5, 4, 5}}, {{1, 4, 4, 5, 4, 6, 5, 6, 4, 5, 5, 6, 5, 6, 6, 6}, {2, 4, 3, 4, 4, 5, 4, 5, 4, 5, 4, 6, 5, 6, 4, 5}, {3, 3, 4, 4, 3, 4, 5, 5, 4, 4, 5, 5, 4, 4, 5, 5}, {3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 4, 5}, {3, 4, 3, 4, 5, 5, 5, 5, 3, 4, 3, 4, 5, 5, 5, 5}, {3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 4, 4, 4, 5}, {2, 4, 4, 5, 3, 4, 4, 4, 4, 5, 5, 6, 4, 5, 5, 6}}, {{1, 4, 4, 5, 4, 6, 5, 7, 3, 6, 6, 7, 5, 7, 6, 7}, {2, 3, 3, 4, 4, 5, 4, 5, 4, 6, 4, 6, 5, 6, 5, 6}, {2, 3, 4, 5, 3, 4, 5, 5, 4, 4, 6, 6, 4, 5, 6, 6}, {3, 4, 4, 4, 4, 4, 4, 4, 3, 4, 4, 5, 4, 5, 5, 5}, {2, 4, 3, 4, 4, 5, 5, 5, 3, 5, 4, 5, 5, 6, 5, 6}, {3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 4, 4, 4, 5}, {2, 4, 4, 4, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6}}, {{1, 3, 4, 6, 4, 6, 6, 7, 3, 7, 7, 7, 5, 8, 7, 8}, {2, 3, 3, 4, 4, 5, 4, 5, 4, 6, 4, 6, 5, 6, 5, 6}, {2, 3, 4, 5, 3, 4, 5, 5, 4, 5, 5, 6, 4, 5, 5, 6}, {3, 4, 3, 4, 3, 4, 4, 5, 4, 5, 4, 5, 4, 5, 5, 5}, {2, 4, 3, 4, 4, 6, 5, 6, 3, 4, 4, 5, 5, 6, 5, 6}, {3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 4, 5}, {2, 4, 4, 5, 3, 4, 4, 5, 3, 6, 5, 6, 4, 6, 5, 6}}, {{1, 3, 4, 6, 4, 7, 6, 7, 3, 7, 6, 8, 5, 7, 7, 8}, {2, 3, 3, 4, 4, 5, 4, 5, 4, 5, 5, 5, 5, 6, 5, 6}, {2, 3, 4, 5, 3, 4, 5, 5, 4, 5, 5, 6, 4, 5, 5, 6}, {3, 3, 4, 4, 3, 4, 4, 5, 4, 5, 4, 5, 4, 5, 5, 5}, {2, 4, 3, 4, 4, 5, 5, 6, 3, 5, 4, 5, 5, 6, 5, 5}, {3, 4, 3, 4, 3, 4, 4, 5, 4, 5, 4, 5, 4, 5, 5, 5}, {2, 4, 4, 5, 3, 4, 4, 5, 3, 6, 5, 6, 4, 6, 5, 6}}, {{1, 3, 4, 6, 4, 7, 6, 7, 3, 7, 6, 8, 5, 7, 7, 8}, {1, 3, 3, 5, 5, 5, 5, 6, 5, 7, 6, 7, 6, 7, 6, 7}, {2, 3, 4, 5, 3, 4, 5, 6, 4, 4, 6, 6, 4, 5, 5, 6}, {3, 4, 4, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 6, 5, 6}, {2, 4, 3, 4, 4, 6, 5, 6, 3, 4, 4, 5, 5, 6, 5, 6}, {3, 4, 3, 4, 3, 4, 4, 5, 4, 4, 5, 5, 4, 5, 5, 5}, {1, 5, 5, 6, 3, 6, 5, 6, 3, 6, 6, 7, 5, 6, 6, 7}}, {{1, 3, 4, 6, 4, 7, 6, 7, 3, 7, 6, 8, 5, 7, 7, 8}, {1, 2, 4, 5, 5, 7, 6, 7, 5, 8, 7, 8, 6, 7, 6, 7}, {2, 3, 4, 6, 3, 3, 5, 4, 4, 5, 9, 9, 4, 5, 8, 7}, {2, 4, 4, 5, 3, 5, 4, 5, 3, 6, 4, 6, 4, 5, 6, 6}, {2, 5, 3, 5, 3, 6, 5, 7, 3, 6, 4, 5, 4, 7, 4, 6}, {2, 5, 4, 6, 3, 4, 4, 6, 3, 6, 6, 6, 3, 5, 5, 6}, {1, 6, 5, 8, 3, 5, 4, 7, 3, 9, 7, 9, 4, 8, 6, 8}}, {{1, 3, 4, 7, 3, 8, 6, 9, 3, 8, 8, 11, 6, 10, 7, 11}, {1, 5, 3, 6, 4, 6, 5, 5, 5, 5, 6, 6, 6, 6, 5, 5}, {1, 3, 6, 7, 3, 4, 7, 6, 6, 6, 6, 6, 5, 6, 6, 6}, {2, 5, 3, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4}, {1, 6, 4, 6, 5, 7, 7, 7, 2, 7, 5, 7, 5, 7, 7, 7}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {1, 6, 4, 6, 3, 6, 4, 6, 4, 6, 6, 6, 5, 6, 6, 6}}, {{1, 3, 4, 7, 3, 7, 7, 8, 3, 9, 9, 8, 6, 8, 8, 8}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {2, 4, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {3, 4, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {3, 4, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}}, {{1, 5, 3, 5, 4, 5, 5, 6, 4, 6, 6, 6, 6, 6, 6, 6}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}}, {{4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}}, {{4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}}, {{4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}} }; #define SI_NUM (30+1) unsigned int codeBookSi[SI_NUM] = { 103653, 51827, 12957, 808, 504, 246, 121, 120, 203, 122, 247, 51, 127, 14, 13, 0, 4, 5, 24, 62, 100, 253, 405, 1011, 1010, 1618, 3238, 6479, 25912, 207305, 207304}; unsigned int codeBookLenSi[SI_NUM] = { 17, 16, 14, 10, 9, 8, 7, 7, 8, 7, 8, 6, 7, 4, 4, 1, 3, 3, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 15, 18, 18}; #define SF_NUM 128 unsigned int codeBookSf[SF_NUM] = { 61533, 61532, 61535, 61534, 61529, 61528, 61531, 61530, 153365, 153364, 153367, 153366, 153361, 153360, 153363, 153362, 153373, 153372, 153375, 153374, 153369, 153368, 153371, 153370, 15381, 15380, 19173, 19172, 4935, 9590, 4934, 2466, 2310, 960, 4794, 1217, 1219, 1232, 2311, 481, 1185, 617, 1199, 241, 312, 309, 598, 89, 153, 289, 33, 45, 79, 20, 31, 75, 14, 39, 8, 25, 8, 13, 3, 7, 1, 5, 0, 5, 24, 6, 38, 18, 9, 73, 23, 17, 145, 61, 43, 32, 297, 157, 155, 121, 88, 85, 597, 576, 313, 305, 169, 1192, 1186, 1193, 1187, 1184, 168, 2309, 2308, 1218, 1216, 1923, 9591, 3844, 19175, 153349, 76697, 153348, 153351, 153350, 153345, 153344, 153347, 153346, 153357, 153356, 153359, 153358, 153353, 153352, 153355, 153354, 153397, 153396, 153399, 153398, 153393, 153392}; unsigned int codeBookLenSf[SF_NUM] = { 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 17, 17, 16, 16, 15, 15, 15, 14, 13, 13, 14, 13, 13, 13, 13, 12, 12, 12, 12, 11, 11, 11, 11, 10, 10, 10, 9, 9, 9, 8, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 1, 4, 4, 5, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 11, 13, 13, 13, 13, 14, 15, 15, 16, 19, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19 }; //bs int BitstreamOpen(FILE *fname); void BitstreamClose(void); void output_byte(long byte,int len); void start_outputing_bits(); void done_outputing_bits(); void FlushBuffer(void); void FlushBufferWithLength(void); int GetBitstreamSize(void); int ByteAlign(void); //~bs void BSHCInit(FILE *name); void BSHCClose(void); int EncodeBSHCQuant(int model,int upper,int cur); int EncodeBSHCSi(int siVal); int EncodeBSHCSf(int sfVal); int EncodeBSHCBin(int ms); void EncodeBSHCStart(void); void EncodeBSHCEnd(void); void EncodeBSHCPutBits(int val,int len); int EncodeBSHCGetSize(); void EncodeBSHCHeader(int ch,int freq); int EncodeBSHCByteAlign(void); int BSHCModelSelect(int bshcModel,int bpl); void EncodeBSHCFlush(void); int WriteAASFHeader(int ch,int freq,int bitrate,int aasf_flag); //for AASF extern void FlushAASFHeaderBuffer(); extern void get_end_band ( int signal_type, int num_window_groups, int window_group_length[], int maxSfb, short *swb_offset[], int top_layer, int base_maxSfb[], int end_sfb[], int end_freq[], int end_cband[] ); void BSHCInit(FILE *name) { BitstreamOpen(name); } void BSHCClose(void) { BitstreamClose(); } void EncodeBSHCStart(void) { start_outputing_bits(); } void EncodeBSHCEnd(void) { done_outputing_bits(); } void EncodeBSHCFlush(void) { FlushBufferWithLength(); } void EncodeBSHCHeader(int ch,int freq) { output_byte('A',8); output_byte('V',8); output_byte('S',8); output_byte('3',8); output_byte(ch,4); output_byte(freq,4); FlushBuffer(); } /************************************************************************/ /* AASF header */ /************************************************************************/ /* quick search element */ typedef struct{ int no_search_points; int search_point_dcption_present; unsigned int search_point_offset[128]; int search_dcption_size[128]; unsigned char search_point_dcption[128][64]; }Quick_search_element; /* general info element */ typedef struct{ unsigned char Title[32]; unsigned char Artist[32]; unsigned char Album[32]; unsigned char Year[4]; unsigned char Genre; unsigned char Comment[32]; unsigned char Composer[32]; unsigned char Encoded_by[32]; }General_info_element; /* 197 bytes, fixed length */ /* lyrics element */ typedef struct{ int synchronised_id; unsigned char text_coding; unsigned char language[3]; int lyrics_size; char* lyrics_text; int timestamp_format; /* 0 -- MPEG frames, 1 -- ms */ int lyrics_timestamp; }Lyrics_element; /* user defined text element */ typedef struct{ unsigned char text_coding; unsigned char language[3]; int user_text_size; char* user_define_text; }User_text_element; int WriteAASFHeader(int ch,int freq,int bitrate,int aasf_flag) { int num_stream_element; int quick_searching_flag; // int drm_flag; // wlei [20060320] int general_info_flag; int text_info_flag; int lyrics_present; int user_define_present; int bitstream_type = 1; int bitused = 0; int byteused; int i, j; Quick_search_element m_quick_search; General_info_element m_general_info; Lyrics_element m_lyrics; User_text_element m_user_text; lyrics_present = 1; user_define_present = 1; //defaut only one stream num_stream_element = 1; /* write AVS AASF ID */ output_byte('A',8); output_byte('A',8); output_byte('S',8); output_byte('F',8); bitused += 32; /* write AASF header size */ output_byte(0, 24); bitused += 24; /* NUM_STREAM_ELEMENT */ output_byte(num_stream_element,8); bitused += 8; for(i = 0; i < num_stream_element; i++) { //aasf_flag = 0x40; //0100 0000 //aasf_flag = 0x80; /* with quick search flag, 1000 0000 */ //aasf_flag = 0xA0; /* with general info flag, 1010 0000 */ aasf_flag = 0x0; /* write AASF flag */ output_byte(aasf_flag, 8); bitused += 8; /* get flag status */ quick_searching_flag = (aasf_flag>>7)&0x1; // drm_flag = (aasf_flag>>6)&0x1; // wlei [20060320] general_info_flag = (aasf_flag>>5)&0x1; text_info_flag = (aasf_flag>>4)&0x1; // wlei [20060223] /* raw stream length */ output_byte(0, 32); bitused += 32; /* version */ output_byte(0,2); /* coding profile */ output_byte(0,2); /* sampling freq. index */ //output_byte(freq+3,4); output_byte(freq, 4); /* bitrate */ output_byte(bitrate, 23); /* bitstream type */ output_byte(bitstream_type, 1); bitused += 32; /* buffer fullness */ if(bitstream_type == 0) { /* dull */ output_byte(0, 20); bitused += 20; } /* channel config */ if(ch <= 2) output_byte(ch-1, 2); else if(ch == 6) /* 5.1 ch */ output_byte(2, 2); else output_byte(3, 2); // bitused += 4; // wlei [20060223] bitused += 2; /* decoding information alignment */ EncodeBSHCByteAlign(); bitused = ((bitused+7)>>3)<<3; if(quick_searching_flag) { /* initialization */ m_quick_search.no_search_points = 2; m_quick_search.search_point_dcption_present = 1; for(i = 0; i < m_quick_search.no_search_points; i++) { /* dummy value */ m_quick_search.search_point_offset[i] = (i+1)*1024; m_quick_search.search_dcption_size[i] = 5; sprintf((char*)(m_quick_search.search_point_dcption[i]), "test"); } /* write quick search info. */ output_byte(m_quick_search.no_search_points, 7); output_byte(m_quick_search.search_point_dcption_present, 1); bitused += 8; for(i = 0; i < m_quick_search.no_search_points; i++) { output_byte(m_quick_search.search_point_offset[i], 32); bitused += 32; if(m_quick_search.search_point_dcption_present) { output_byte(m_quick_search.search_dcption_size[i], 8); for(j = 0; j < m_quick_search.search_dcption_size[i]; j ++) { output_byte(m_quick_search.search_point_dcption[i][j], 8); bitused += 8; } } } /* donot need byte alignment */ } // wlei [20060320] // if(drm_flag) // { // } if(general_info_flag) { /* initialization */ memcpy(m_general_info.Title, "NoName song", 12); memcpy(m_general_info.Artist, "NoName guy", 11); memcpy(m_general_info.Album, "NoName album", 13); memcpy(m_general_info.Year, "2005", 5); m_general_info.Genre = 0; memcpy(m_general_info.Comment, "comment", 8); memcpy(m_general_info.Composer, "NoName guy2", 12); memcpy(m_general_info.Encoded_by, "NoName encoder", 15); /* Title, 32 bytes */ for(i = 0; i < 32; i ++) output_byte(m_general_info.Title[i], 8); /* Artist, 32 bytes */ for(i = 0; i < 32; i ++) output_byte(m_general_info.Artist[i], 8); /* Album, 32 bytes */ for(i = 0; i < 32; i ++) output_byte(m_general_info.Album[i], 8); /* Year, 4 bytes */ for(i = 0; i < 4; i ++) output_byte(m_general_info.Year[i], 8); /* Genre, 1 bytes */ output_byte(m_general_info.Genre, 8); /* Comment, 32 bytes */ for(i = 0; i < 32; i ++) output_byte(m_general_info.Comment[i], 8); /* Composer, 32 bytes */ for(i = 0; i < 32; i ++) output_byte(m_general_info.Composer[i], 8); /* Encoded_by, 32 bytes */ for(i = 0; i < 32; i ++) output_byte(m_general_info.Encoded_by[i], 8); bitused += 1576; //197 bytes } if(text_info_flag) { output_byte(lyrics_present, 1); bitused += 1; if(lyrics_present) { /* initialization */ // m_lyrics.synchronised_id = 0; /* non-sync */ m_lyrics.synchronised_id = 1; /* sync */ m_lyrics.lyrics_size = 12; m_lyrics.lyrics_text = (char *)malloc(m_lyrics.lyrics_size); memcpy(m_lyrics.lyrics_text, "lyrics text", 12); /* synchronised_id */ output_byte(m_lyrics.synchronised_id, 1); /* text coding */ output_byte(m_lyrics.text_coding, 8); /* language */ for(i = 0; i < 3; i ++) output_byte(m_lyrics.language[i], 8); /* synchronised or not */ if(m_lyrics.synchronised_id == 0) { /* lyrics size */ output_byte(m_lyrics.lyrics_size, 22); /* lyrics text */ for(i = 0; i < m_lyrics.lyrics_size; i ++) output_byte(m_lyrics.lyrics_text[i], 8); } else { /* timestamp format */ output_byte(m_lyrics.timestamp_format, 2); bitused += 2; memcpy(m_lyrics.lyrics_text, "lyrics", 7); m_lyrics.lyrics_timestamp = 1; m_lyrics.lyrics_size = 7; /* lyrics size */ output_byte(m_lyrics.lyrics_size+4, 22); /* lyrics text */ for(i = 0; i < m_lyrics.lyrics_size; i ++) output_byte(m_lyrics.lyrics_text[i], 8); /* timestamp */ output_byte(m_lyrics.lyrics_timestamp, 32); bitused += 32; } free(m_lyrics.lyrics_text); bitused += (m_lyrics.lyrics_size*8+1+8+24+22); } output_byte(user_define_present, 1); bitused += 1; if(user_define_present) { /* initialization */ m_user_text.user_text_size = 17; m_user_text.user_define_text = (char *)malloc(m_user_text.user_text_size); memcpy(m_user_text.user_define_text, "user define text", 17); /* text coding */ output_byte(m_user_text.text_coding, 8); /* language */ for(i = 0; i < 3; i ++) output_byte(m_user_text.language[i], 8); /* user text size */ output_byte(m_user_text.user_text_size, 22); /* user text info */ for(i = 0; i < m_user_text.user_text_size; i ++) output_byte(m_user_text.user_define_text[i], 8); free(m_user_text.user_define_text); bitused += (m_user_text.user_text_size+8+24+22); } /* reserved_bit */ output_byte(0, 1); bitused += 1; /* text information alignment */ EncodeBSHCByteAlign(); bitused = ((bitused+7)>>3)<<3; } } byteused = (bitused+7)>>3; FlushAASFHeaderBuffer(); return byteused; } int EncodeBSHCQuant(int model,int upper,int cur) { output_byte((long)codeBook[model][upper][cur],codeBookLen[model][upper][cur]); return codeBookLen[model][upper][cur]; } int EncodeBSHCSi(int siVal) { output_byte((long)codeBookSi[siVal],codeBookLenSi[siVal]); return codeBookLenSi[siVal]; } int EncodeBSHCSf(int sfVal) { output_byte((long)codeBookSf[sfVal],codeBookLenSf[sfVal]); return codeBookLenSf[sfVal]; } int EncodeBSHCBin(int ms) { if(ms==1) output_byte(1,1); else output_byte(0,1); return 1; } void EncodeBSHCPutBits(int val,int len) { output_byte((long)val,len); } int EncodeBSHCGetSize(void) { //in bits return GetBitstreamSize(); } int EncodeBSHCByteAlign(void) { return ByteAlign(); } int BSHCModelSelect(int bshcModel,int bpl) { int modelNum; int msb; /*model decision*/ if(bshcModel >= 9) msb = bshcModel -4; else { msb = (bshcModel+1)/2; } if(msb==1) { modelNum = bshcModel; } if(msb==2) { if(bpl==2 && bshcModel==3) modelNum = 3; if(bpl==1 && bshcModel==3) modelNum = 4; if(bpl==2 && bshcModel==4) modelNum = 5; if(bpl==1 && bshcModel==4) modelNum = 6; } if(msb==3) { if(bpl==3 && bshcModel==5) modelNum = 7; if(bpl==2 && bshcModel==5) modelNum = 8; if(bpl==1 && bshcModel==5) modelNum = 9; if(bpl==3 && bshcModel==6) modelNum = 10; if(bpl==2 && bshcModel==6) modelNum = 11; if(bpl==1 && bshcModel==6) modelNum = 12; } if(msb==4) { if(bpl==4 && bshcModel==7) modelNum = 13; if(bpl==3 && bshcModel==7) modelNum = 14; if(bpl==2 && bshcModel==7) modelNum = 15; if(bpl==1 && bshcModel==7) modelNum = 16; if(bpl==4 && bshcModel==8) modelNum = 17; if(bpl==3 && bshcModel==8) modelNum = 18; if(bpl==2 && bshcModel==8) modelNum = 19; if(bpl==1 && bshcModel==8) modelNum = 20; } if(msb>4) { modelNum = 20+bpl; } return modelNum; } int BSHCFindModelBase(int msb) { int modelNum; /*model decision*/ if(msb<=4) { modelNum = msb*msb-msb+1; } else { modelNum = 20; } return modelNum; } static int my_log2(int value) { int i, step; if(value < 0) { fprintf(stderr, "my_log2:error : %d\n", value); return 0; } if(value == 0) return 0; step = 2; for(i = 1; i < 24; i++) { if(value < step) return i; step *= 2; } return ( 1 + (int)(log10((double)value)/log10(2.0))); } int get_msb_of_samples ( int sample[], int num_sample ) { int i; int bal; int max = 0; for (i = 0; i < num_sample; i++) { if (abs(sample[i])>max) max = abs(sample[i]); } if(max > 0) bal = my_log2(max); else bal = 0; return bal; } void get_cband_msb ( int num_window_groups, int *sample[], int max_cband[], int *band_qbit[] ) { int g, cband, offset; for(g=0; g<num_window_groups; g++) for (cband = 0; cband < max_cband[g]; cband++) { offset = 32 * cband; band_qbit[g][cband] = get_msb_of_samples(&(sample[g][offset]), 32); } } int siCodeMode = 0; extern int cb_tab[16]; void BSHCFindModel( int nch, int signal_type, int num_window_groups, int window_group_length[], int *sample[][8], int *scalefactors[][8], int maxSfb, short *swb_offset[], int top_layer, int *bshc_model[2][8] ) { int ch, g; int cband; int end_cband[8]; /* Array Size : 64 -> 8 shpark 2000.04.20 */ int end_sfb[8]; int end_freq[8]; int scf_model; int used_bits=0; int u_bits; int base_maxSfb[8]; /* maxsfb in each group */ int band_snf[2][128]; int *cband_qbit[2][8]; int model; int curMask; int upperMask,bplMask; int bpl; int t1,t2,t3,t4; int cbBitCount1,cbBitCount2; int idx,i; int prevSi[2]; int prevSf[2]; if(maxSfb == 0) { used_bits = (int)((used_bits + 7) / 8) * 8; return; } /* Calculate base_maxSfb & maximum cband, qband, frequency */ get_end_band (signal_type, num_window_groups, window_group_length, maxSfb, swb_offset, top_layer, base_maxSfb, end_sfb, end_freq, end_cband); /* Determine the arithmetic model for the Slice-Bits */ for(ch = 0; ch < nch; ch++) { cband_qbit[ch][0] = &(band_snf[ch][0]); for (g = 1; g < num_window_groups; g++) { cband_qbit[ch][g] = cband_qbit[ch][g-1] + end_cband[g-1]; } get_cband_msb ( num_window_groups, sample[ch], end_cband, cband_qbit[ch]); /*bshc model selection*/ for (g = 0; g < num_window_groups; g++) for(cband=0;cband<end_cband[g];cband++) { if(cband_qbit[ch][g][cband]==0) bshc_model[ch][g][cband] = 0; else if(cband_qbit[ch][g][cband]>=5) { bshc_model[ch][g][cband] = (cband_qbit[ch][g][cband]+4); } else { /*BSHCFindModelBase(cband_qbit[ch][g][cband])*/ /*count cband bits*/ bshc_model[ch][g][cband] = cband_qbit[ch][g][cband]*2-1; for(cbBitCount1=0,i=0;i<8;i++) { idx = cband*32+i*4; for(upperMask=0,bpl=cband_qbit[ch][g][cband];bpl>0;bpl--) { bplMask = 1<<(bpl-1); if(abs(sample[ch][g][idx]) & bplMask) t1 = 1; else t1 = 0; if(abs(sample[ch][g][idx+1]) & bplMask) t2 = 1; else t2 = 0; if(abs(sample[ch][g][idx+2]) & bplMask) t3 = 1; else t3 = 0; if(abs(sample[ch][g][idx+3]) & bplMask) t4 = 1; else t4 = 0; curMask = (t1<<3) + (t2<<2) + (t3<<1) +t4; model = BSHCFindModelBase(cband_qbit[ch][g][cband])+(cband_qbit[ch][g][cband]-bpl); /* codebook reduction */ upperMask = cb_tab[upperMask]; cbBitCount1 += codeBookLen[model][upperMask][curMask]; upperMask = curMask; } } bshc_model[ch][g][cband] = cband_qbit[ch][g][cband]*2; for(cbBitCount2=0,i=0;i<8;i++) { idx = cband*32+i*4; for(upperMask=0,bpl= cband_qbit[ch][g][cband];bpl>0;bpl--) { bplMask = 1<<(bpl-1); if(abs(sample[ch][g][idx]) & bplMask) t1 = 1; else t1 = 0; if(abs(sample[ch][g][idx+1]) & bplMask) t2 = 1; else t2 = 0; if(abs(sample[ch][g][idx+2]) & bplMask) t3 = 1; else t3 = 0; if(abs(sample[ch][g][idx+3]) & bplMask) t4 = 1; else t4 = 0; curMask = (t1<<3) + (t2<<2) + (t3<<1) +t4; model = BSHCFindModelBase(cband_qbit[ch][g][cband])+(2*cband_qbit[ch][g][cband]-bpl); /* codebook reduction */ upperMask = cb_tab[upperMask]; cbBitCount2 += codeBookLen[model][upperMask][curMask]; upperMask = curMask; } } if(cbBitCount2>cbBitCount1) { bshc_model[ch][g][cband] = cband_qbit[ch][g][cband]*2-1; cbBitCount2 = cbBitCount1; } used_bits += cbBitCount2; } } } } /*+----------------------------------------------------+ | | | AATF header write | | | +----------------------------------------------------+*/ #define SYNCWORD 0x00000001 #define ID 0x00000000 #define CODING_PROFILE 0x00000000 #define DECODING_STATUS_PRESENT 0x00000001 #define DRM_PRESENT 0x00000000 #define GENERAL_INFO_PRESENT 0x00000000 #define TEXT_INFO_PRESENT 0x00000000 #define BITSTREAM_TYPE 0x00000001 #define CHANNEL_CONFIG 0x00000000 #define LYRICS_PRESENT 0x00000001 /* vacant function */ int aatf_error_check() { return 0; } /* vacant function */ int aatf_raw_data_block_error_check() { return 0; } /* vacant function */ int aatf_header_error_check() { return 0; } /* vacant function */ // wlei [20060320] //int DRM_element() //{ // return 0; int general_info_element() { int i; General_info_element m_general_info; memcpy(m_general_info.Title, "NoName song", 12); memcpy(m_general_info.Artist, "NoName guy", 11); memcpy(m_general_info.Album, "NoName album", 13); memcpy(m_general_info.Year, "2005", 5); m_general_info.Genre = 0; memcpy(m_general_info.Comment, "comment", 8); memcpy(m_general_info.Composer, "NoName guy2", 12); memcpy(m_general_info.Encoded_by, "NoName encoder", 15); /* Title, 32 bytes */ for(i = 0; i < 32; i ++) output_byte(m_general_info.Title[i], 8); /* Artist, 32 bytes */ for(i = 0; i < 32; i ++) output_byte(m_general_info.Artist[i], 8); /* Album, 32 bytes */ for(i = 0; i < 32; i ++) output_byte(m_general_info.Album[i], 8); /* Year, 4 bytes */ for(i = 0; i < 4; i ++) output_byte(m_general_info.Year[i], 8); /* Genre, 1 bytes */ output_byte(m_general_info.Genre, 8); /* Comment, 32 bytes */ for(i = 0; i < 32; i ++) output_byte(m_general_info.Comment[i], 8); /* Composer, 32 bytes */ for(i = 0; i < 32; i ++) output_byte(m_general_info.Composer[i], 8); /* Encoded_by, 32 bytes */ for(i = 0; i < 32; i ++) output_byte(m_general_info.Encoded_by[i], 8); return 1576; // 197 * 8 bits } int text_info_element() { int i; int bitused; int lyrics_present; Lyrics_element m_lyrics; bitused = 0; lyrics_present = LYRICS_PRESENT; output_byte(lyrics_present, 1); bitused += 1; if(lyrics_present) { /* initialization */ // m_lyrics.synchronised_id = 0; /* non-sync */ m_lyrics.synchronised_id = 1; /* sync */ m_lyrics.lyrics_size = 12; m_lyrics.lyrics_text = (char *)malloc(m_lyrics.lyrics_size); memcpy(m_lyrics.lyrics_text, "lyrics text", 12); /* synchronised_id */ output_byte(m_lyrics.synchronised_id, 1); /* text coding */ output_byte(m_lyrics.text_coding, 8); /* language */ for(i = 0; i < 3; i ++) output_byte(m_lyrics.language[i], 8); /* synchronised or not */ if(m_lyrics.synchronised_id == 0) { /* lyrics size */ output_byte(m_lyrics.lyrics_size, 22); /* lyrics text */ for(i = 0; i < m_lyrics.lyrics_size; i ++) output_byte(m_lyrics.lyrics_text[i], 8); } else { /* timestamp format */ output_byte(m_lyrics.timestamp_format, 2); bitused += 2; memcpy(m_lyrics.lyrics_text, "lyrics", 7); m_lyrics.lyrics_timestamp = 1; m_lyrics.lyrics_size = 7; /* lyrics size */ output_byte(m_lyrics.lyrics_size+4, 22); /* lyrics text */ for(i = 0; i < m_lyrics.lyrics_size; i ++) output_byte(m_lyrics.lyrics_text[i], 8); /* timestamp */ output_byte(m_lyrics.lyrics_timestamp, 32); bitused += 32; } free(m_lyrics.lyrics_text); bitused += (m_lyrics.lyrics_size*8+1+8+24+22); } return bitused; } int aatf_decoding_header(int freqIdx, int channel_config) { output_byte(SYNCWORD, 12); // syncword output_byte(ID, 2); // ID output_byte(freqIdx, 4); // sampling_frequency_index output_byte(channel_config, 2); // num_channel output_byte(CODING_PROFILE, 2); // coding_profile return (12+2+4+2+2); } int aatf_info_header(int nr_of_blocks, int aatf_flag, int bitrate, int aatf_buffer_fullness) { int i; int bit_count; // int DRM_present; // wlei [20060320] int general_info_present; int text_info_present; int bitstream_type; bit_count = 0; // DRM_present = (aatf_flag & 0x4); // wlei [20060320] general_info_present = (aatf_flag & 0x2); text_info_present = (aatf_flag & 0x1); bitstream_type = BITSTREAM_TYPE; output_byte(nr_of_blocks, 2); // number_of_raw_data_blocks_in_frame; bit_count += 2; // 2006-01-19 xusen, deleted frameLenght in aatf header // output_byte(0, 13); // frame_length, real writing delayed; // bit_count += 13; output_byte(aatf_flag, 3); // aatf_flag; bit_count += 3; output_byte(BITSTREAM_TYPE, 1); //bitstream_type bit_count += 1; output_byte(aatf_buffer_fullness, 11); // aatf_buffer_fullness bit_count += 11; // wlei [20060320] // if(DRM_present) // bit_count += DRM_element(); if (general_info_present) bit_count += general_info_element(); if(text_info_present) bit_count += text_info_element(); return bit_count; } int WriteAATFHeader(int nr_of_blocks, int freqIdx, int nch, int bitrate, int aatf_buffer_fullness, int aatf_flag) { int bit_count; int channel_config; if(nch == 1) channel_config = 0; else if(nch == 2) channel_config = 1; else if(nch == 6) channel_config = 2; else channel_config = 3; bit_count = 0; bit_count += aatf_decoding_header(freqIdx, channel_config); bit_count += aatf_info_header(nr_of_blocks, aatf_flag, bitrate, aatf_buffer_fullness); bit_count += ByteAlign(); // lixun 2008-7-28, follow spec. here should do byte alignment if (nr_of_blocks == 0) bit_count += aatf_error_check(); //->not implemented else bit_count += aatf_header_error_check(); //->not implemented /* remove due to byteAlign before -- lixun 2008-7-28 */ //output_byte(0, 1); // 2006-01-19 xusen //bit_count += 4; //bit_count += 1; return bit_count; }
[ "[email protected]@6c8d3a4c-d4d5-11dd-b6b4-918b84bbd919" ]
[ [ [ 1, 1122 ] ] ]
c742c201da5a76a9a821fc213266f355fd171d17
6bdb3508ed5a220c0d11193df174d8c215eb1fce
/Codes/Halak/CloningContext.h
4d7e0436958f2f6b89bad30909c3c6328941eddd
[]
no_license
halak/halak-plusplus
d09ba78640c36c42c30343fb10572c37197cfa46
fea02a5ae52c09ff9da1a491059082a34191cd64
refs/heads/master
2020-07-14T09:57:49.519431
2011-07-09T14:48:07
2011-07-09T14:48:07
66,716,624
0
0
null
null
null
null
UTF-8
C++
false
false
1,304
h
#pragma once #ifndef __HALAK_CLONINGCONTEXT_H__ #define __HALAK_CLONINGCONTEXT_H__ # include <Halak/FWD.h> # include <map> namespace Halak { class CloningContext { public: CloningContext(); ~CloningContext(); template <typename T> inline T* Clone(T* original); template <typename T> inline T* CloneOrNull(T* original); template <typename T> inline SharedPointer<T> Clone(SharedPointer<T> original); template <typename T> inline SharedPointer<T> CloneOrNull(SharedPointer<T> original); template <typename T> inline WeakPointer<T> Clone(WeakPointer<T> original); template <typename T> inline WeakPointer<T> CloneOrNull(WeakPointer<T> original); private: template <typename T> inline T* CloneActually(T* original, T* fallback); template <typename T> inline SharedPointer<T> CloneActually(SharedPointer<T> original, SharedPointer<T> fallback); private: std::map<ICloneable*, ICloneable*> clones; std::map<ICloneablePtr, ICloneablePtr> sharedClones; }; } # include <Halak/CloningContext.inl> #endif
[ [ [ 1, 35 ] ] ]
2c0ad55f6e4f2d8326ca5aa8e0c9f083e4b4c5f0
478570cde911b8e8e39046de62d3b5966b850384
/apicompatanamdw/bcdrivers/os/ossrv/stdcpp/apps/BCCSRuntimeSup/inc/BCCSRuntimeSup.h
58e4a2d03fc9a8103cb005bfdcf60d5d29400680
[]
no_license
SymbianSource/oss.FCL.sftools.ana.compatanamdw
a6a8abf9ef7ad71021d43b7f2b2076b504d4445e
1169475bbf82ebb763de36686d144336fcf9d93b
refs/heads/master
2020-12-24T12:29:44.646072
2010-11-11T14:03:20
2010-11-11T14:03:20
72,994,432
0
0
null
null
null
null
UTF-8
C++
false
false
4,654
h
/* * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * * Initial Contributors: * Nokia Corporation - initial contribution. * * Contributors: * * Description: * */ #ifndef BCCSRUNTIMESUP_H #define BCCSRUNTIMESUP_H // INCLUDES #include <StifLogger.h> #include <TestScripterInternal.h> #include <StifTestModule.h> // CONSTANTS //const ?type ?constant_var = ?constant; // MACROS //#define ?macro ?macro_def #define TEST_CLASS_VERSION_MAJOR 50 #define TEST_CLASS_VERSION_MINOR 9 #define TEST_CLASS_VERSION_BUILD 38 // Logging path _LIT( KBCCSRuntimeSupLogPath, "\\logs\\testframework\\BCCSRuntimeSup\\" ); // Log file _LIT( KBCCSRuntimeSupLogFile, "BCCSRuntimeSup.txt" ); _LIT( KBCCSRuntimeSupLogFileWithTitle, "BCCSRuntimeSup_[%S].txt" ); // FUNCTION PROTOTYPES //?type ?function_name(?arg_list); // FORWARD DECLARATIONS //class ?FORWARD_CLASSNAME; class CBCCSRuntimeSup; // DATA TYPES //enum ?declaration //typedef ?declaration //extern ?data_type; // CLASS DECLARATION /** * CBCCSRuntimeSup test class for STIF Test Framework TestScripter. * ?other_description_lines * * @lib ?library * @since ?Series60_version */ NONSHARABLE_CLASS(CBCCSRuntimeSup) : public CScriptBase { public: // Constructors and destructor /** * Two-phased constructor. */ static CBCCSRuntimeSup* NewL( CTestModuleIf& aTestModuleIf ); /** * Destructor. */ virtual ~CBCCSRuntimeSup(); public: // New functions /** * ?member_description. * @since ?Series60_version * @param ?arg1 ?description * @return ?description */ //?type ?member_function( ?type ?arg1 ); public: // Functions from base classes /** * From CScriptBase Runs a script line. * @since ?Series60_version * @param aItem Script line containing method name and parameters * @return Symbian OS error code */ virtual TInt RunMethodL( CStifItemParser& aItem ); protected: // New functions /** * ?member_description. * @since ?Series60_version * @param ?arg1 ?description * @return ?description */ //?type ?member_function( ?type ?arg1 ); protected: // Functions from base classes /** * From ?base_class ?member_description */ //?type ?member_function(); private: /** * C++ default constructor. */ CBCCSRuntimeSup( CTestModuleIf& aTestModuleIf ); /** * By default Symbian 2nd phase constructor is private. */ void ConstructL(); // Prohibit copy constructor if not deriving from CBase. // ?classname( const ?classname& ); // Prohibit assigment operator if not deriving from CBase. // ?classname& operator=( const ?classname& ); /** * Frees all resources allocated from test methods. * @since ?Series60_version */ void Delete(); /** * Test methods are listed below. */ /** * Example test method. * @since ?Series60_version * @param aItem Script line containing parameters. * @return Symbian OS error code. */ virtual TInt TestAPI( CStifItemParser& aItem ); /** * Method used to log version of test class */ void SendTestClassVersion(); //ADD NEW METHOD DEC HERE //[TestMethods] - Do not remove public: // Data // ?one_line_short_description_of_data //?data_declaration; protected: // Data // ?one_line_short_description_of_data //?data_declaration; private: // Data // ?one_line_short_description_of_data //?data_declaration; // Reserved pointer for future extension //TAny* iReserved; public: // Friend classes //?friend_class_declaration; protected: // Friend classes //?friend_class_declaration; private: // Friend classes //?friend_class_declaration; }; #endif // BCCSRUNTIMESUP_H // End of File
[ "none@none" ]
[ [ [ 1, 184 ] ] ]
0bf42410d4de50475369b1cb804604f062e28d76
656aba8d1c0379c82261b34de6875704d7133645
/trunk/Sources/Common/UnitTests/AgentTest/AgentTest.cpp
d3128819652debd9bcfaf858d15a8262798aa338
[]
no_license
BackupTheBerlios/exspecto-svn
7ac87d6f30896add78adeebc68fffe720ec46d56
c0cd6af554231680e5bf404e25330907b194bd24
refs/heads/master
2020-12-24T13:28:04.023732
2008-03-10T15:04:43
2008-03-10T15:04:43
40,664,795
0
0
null
null
null
null
UTF-8
C++
false
false
750
cpp
#include <tchar.h> #include <cppunit/CompilerOutputter.h> #include <cppunit/extensions/TestFactoryRegistry.h> #include <cppunit/ui/text/TestRunner.h> int _tmain(int argc, _TCHAR* argv[]) { // Get the top level suite from the registry CPPUNIT_NS::Test *suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest(); // Adds the test to the list of test to run CPPUNIT_NS::TextUi::TestRunner runner; runner.addTest( suite ); // Change the default outputter to a compiler error format outputter runner.setOutputter( new CPPUNIT_NS::CompilerOutputter( &runner.result(), CPPUNIT_NS::stdCOut() ) ); // Run the test. bool wasSucessful = runner.run(); // Return error code 1 if the one of test failed. return wasSucessful ? 0 : 1; }
[ "parshind@284ff1dd-de15-0410-891b-f61abf421a23" ]
[ [ [ 1, 24 ] ] ]
57fe5e6c11843fa1b3edd3c2b1d46c37825dcb9a
14298a990afb4c8619eea10988f9c0854ec49d29
/PowerBill四川电信专用版本/ibill_source/EditTransFrm.cpp
969b1ff9a9a624466944092db59755b94c575ba0
[]
no_license
sridhar19091986/xmlconvertsql
066344074e932e919a69b818d0038f3d612e6f17
bbb5bbaecbb011420d701005e13efcd2265aa80e
refs/heads/master
2021-01-21T17:45:45.658884
2011-05-30T12:53:29
2011-05-30T12:53:29
42,693,560
0
0
null
null
null
null
GB18030
C++
false
false
1,309
cpp
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "EditTransFrm.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "RzButton" #pragma link "RzCmboBx" #pragma link "RzEdit" #pragma link "RzPanel" #pragma link "RzSpnEdt" #pragma resource "*.dfm" TfrmEditTrans *frmEditTrans; //--------------------------------------------------------------------------- __fastcall TfrmEditTrans::TfrmEditTrans(TComponent* Owner,AnsiString AValue,AnsiString AContext) : TForm(Owner) { Value = AValue; Context = AContext; txtValue->Text = Value; txtContext->Text = Context; } //--------------------------------------------------------------------------- void __fastcall TfrmEditTrans::btnOkClick(TObject *Sender) { try { StrToInt(txtValue->Text); } catch(...) { MessageBox(Handle,"值必须是一个整数!","提示",MB_OK | MB_ICONWARNING); txtValue->SetFocus(); txtValue->SelectAll(); return; } if(txtValue->Text == Value && txtContext->Text == Context) ModalResult = mrCancel; else ModalResult = mrOk; } //---------------------------------------------------------------------------
[ "cn.wei.hp@e7bd78f4-57e5-8052-e4e7-673d445fef99" ]
[ [ [ 1, 44 ] ] ]
5e78bceadbf38d03d38babce8974f44d2b445c28
74c8da5b29163992a08a376c7819785998afb588
/NetAnimal/Game/wheel/WheelController/include/AutoEngineDecorator.h
8952fd5818881f7dd7f039dff34a069f8f31aa69
[]
no_license
dbabox/aomi
dbfb46c1c9417a8078ec9a516cc9c90fe3773b78
4cffc8e59368e82aed997fe0f4dcbd7df626d1d0
refs/heads/master
2021-01-13T14:05:10.813348
2011-06-07T09:36:41
2011-06-07T09:36:41
null
0
0
null
null
null
null
GB18030
C++
false
false
1,417
h
#ifndef __Orz_AutoEngineDecorator_h__ #define __Orz_AutoEngineDecorator_h__ #include "WheelControllerConfig.h" #include "WheelEngineInterface.h" namespace Orz { class _OrzWheelControlleExport AutoEngineDecorator:public WheelEngineInterface, public EventHandler//, public KeyListener { public: AutoEngineDecorator(WheelEngineInterfacePtr engine); ~AutoEngineDecorator(void); private: virtual void addListener(WheelEngineListener * listener); virtual void removeListener(WheelEngineListener * listener); virtual void refreshMenuData(void); virtual void pushMessage(MsgBuffer & buffer); ///重载,被用于处理消息调用 virtual void doExecute(Event * evt); ///重载,被用于进入消息管理调用 virtual void doEnable(void); ///重载,被用于离开消息管理调用 virtual void doDisable(void); ///重载,被用于更新调用 virtual void doFrame(unsigned int step); /////通知键盘按下事件 //virtual bool onKeyPressed(const KeyEvent & evt); /////通知键盘释放事件 //virtual bool onKeyReleased(const KeyEvent & evt); WheelEngineInterfacePtr _engine; private: TimeType _currTime; void sendMsg(const Orz::MsgBuffer & head, const Orz::MsgBuffer & msg); }; typedef boost::shared_ptr<AutoEngineDecorator> AutoEngineDecoratorPtr; } #endif
[ [ [ 1, 59 ] ] ]
0898d7f3b847c5a5775474e8e341c666572baef9
1cacbe790f7c6e04ca6b0068c7b2231ed2b827e1
/Oolong Engine2/Examples/Renderer/Tutorials/08 Shaders Demo (3DShaders.com)/Classes/Shader/3DShaders.src/Trackball.h
41f5b738faf61c2c9a81d92b87026756c7f41b28
[ "BSD-3-Clause" ]
permissive
tianxiao/oolongengine
f3d2d888afb29e19ee93f28223fce6ea48f194ad
8d80085c65ff3eed548549657e7b472671789e6a
refs/heads/master
2020-05-30T06:02:32.967513
2010-05-05T05:52:03
2010-05-05T05:52:03
8,245,292
3
3
null
null
null
null
UTF-8
C++
false
false
1,182
h
// // Author: Philip Rideout // Copyright: 2002-2006 3Dlabs Inc. Ltd. All rights reserved. // License: see 3Dlabs-license.txt // #ifndef TRACKBALL_H #define TRACKBALL_H #include "Vector.h" #include <wx/timer.h> class TCanvas; // Processes mouse motion and keyboard input that affect camera orientation and position. class TTrackball { public: TTrackball(); void OnIdle(wxIdleEvent& event); void OnMouse(wxMouseEvent& event); void OnKeyDown(wxKeyEvent& event); void LoadMatrix() const; void SetMatrix() const; void MultMatrix() const; bool IsFrozen() const { return inertiaTheta == 0 && !validStart; } void Reset(bool all = false); void Stop(); int GetFrameCount(); void SetCanvas(TCanvas* canvas) { this->canvas = canvas; } static const float StartZoom; static const float InertiaThreshold; static const int Delay; private: long previous; int frames; TCanvas* canvas; bool validStart; vec3 vStart; vec3 vPrev; vec3 vInc; vec3 inertiaAxis; float inertiaTheta; float startZoom; mat4 mStart; mat4 xform; }; #endif
[ "mozeal@7fa7efda-f44a-0410-a86a-c1fddb4bcab7" ]
[ [ [ 1, 48 ] ] ]
ea28553fbad2890dc932d33b2ee63d131ce5c5b1
1775576281b8c24b5ce36b8685bc2c6919b35770
/tags/release_1.0/thing_edit.cpp
131b5249c4b977b2afe48a133df23545a10e42a4
[]
no_license
BackupTheBerlios/gtkslade-svn
933a1268545eaa62087f387c057548e03497b412
03890e3ba1735efbcccaf7ea7609d393670699c1
refs/heads/master
2016-09-06T18:35:25.336234
2006-01-01T11:05:50
2006-01-01T11:05:50
40,615,146
0
0
null
null
null
null
UTF-8
C++
false
false
20,032
cpp
#include "main.h" #include "map.h" #include "line_edit.h" #include "thing_edit.h" #include "tex_box.h" #include "editor_window.h" #include "tex_browser.h" #include "special_select.h" #include "checks.h" #include "args_edit.h" tex_box_t *thing_tbox = NULL; struct tedit_data_t { bool angle_consistent; int angle; bool type_consistent; int type; bool tid_consistent; int tid; bool special_consistent; int special; bool zheight_consistent; int zheight; BYTE args[5]; bool arg_consistent[5]; GtkWidget* entry_angle; GtkWidget* entry_type; GtkWidget* label_type; GtkWidget* entry_tid; GtkWidget* entry_special; GtkWidget* entry_zheight; }; tedit_data_t tedit_data; extern GtkWidget *editor_window; extern Map map; extern vector<int> set_flags; extern vector<int> unset_flags; extern vector<int> selected_items; extern int hilight_item; extern thing_t last_thing; void tedit_change_type_clicked(GtkWidget *widget, gpointer data) { int type = open_ttype_select_dialog(tedit_data.type); gtk_entry_set_text(GTK_ENTRY(tedit_data.entry_type), parse_string("%d", type).c_str()); } void tedit_browse_type_clicked(GtkWidget *widget, gpointer data) { string name = open_texture_browser(false, false, true, get_thing_type(tedit_data.type)->name); int type = get_thing_type_from_name(name)->type; gtk_entry_set_text(GTK_ENTRY(tedit_data.entry_type), parse_string("%d", type).c_str()); } gboolean tedit_sprite_clicked(GtkWidget *widget, GdkEventButton *event, gpointer data) { if (event->button == 1) tedit_browse_type_clicked(widget, data); return false; } void tedit_change_special_clicked(GtkWidget *widget, gpointer data) { int special = open_special_select_dialog(tedit_data.special); gtk_entry_set_text(GTK_ENTRY(tedit_data.entry_special), parse_string("%d", special).c_str()); } void tedit_find_tid_clicked(GtkWidget *widget, gpointer data) { int tid = get_free_tid(); gtk_entry_set_text(GTK_ENTRY(tedit_data.entry_tid), parse_string("%d", tid).c_str()); } void tedit_type_entry_changed(GtkEditable *editable, gpointer data) { GtkEntry* entry = (GtkEntry*)editable; string text = gtk_entry_get_text(entry); if (text == "") { tedit_data.type_consistent = false; thing_tbox->change_texture("", 3); gtk_label_set_text(GTK_LABEL(tedit_data.label_type), ""); } else { tedit_data.type = atoi(text.c_str()); tedit_data.type_consistent = true; thing_type_t* ttype = get_thing_type(tedit_data.type); thing_tbox->change_texture(ttype->spritename, 3, 2.0f, true); gtk_label_set_text(GTK_LABEL(tedit_data.label_type), ttype->name.c_str()); } } void tedit_angle_entry_changed(GtkEditable *editable, gpointer data) { GtkEntry* entry = (GtkEntry*)editable; string text = gtk_entry_get_text(entry); if (text == "") tedit_data.angle_consistent = false; else { tedit_data.angle = atoi(text.c_str()); tedit_data.angle_consistent = true; } } void tedit_tid_entry_changed(GtkEditable *editable, gpointer data) { GtkEntry* entry = (GtkEntry*)editable; string text = gtk_entry_get_text(entry); if (text == "") tedit_data.tid_consistent = false; else { tedit_data.tid = atoi(text.c_str()); tedit_data.tid_consistent = true; } } void tedit_special_entry_changed(GtkEditable *editable, gpointer data) { GtkEntry* entry = (GtkEntry*)editable; string text = gtk_entry_get_text(entry); if (text == "") tedit_data.special_consistent = false; else { tedit_data.special = atoi(text.c_str()); tedit_data.special_consistent = true; } } void tedit_zheight_entry_changed(GtkEditable *editable, gpointer data) { GtkEntry* entry = (GtkEntry*)editable; string text = gtk_entry_get_text(entry); if (text == "") tedit_data.zheight_consistent = false; else { tedit_data.zheight = atoi(text.c_str()); tedit_data.zheight_consistent = true; } } void angle_button_toggled(GtkToggleButton *button, gpointer data) { int angle = (int)data; tedit_data.angle = angle; gtk_entry_set_text(GTK_ENTRY(tedit_data.entry_angle), parse_string("%d", tedit_data.angle).c_str()); } GtkWidget* setup_angle_button(GtkRadioButton* group, int angle) { GtkWidget *button; if (group) button = gtk_radio_button_new_from_widget(group); else button = gtk_radio_button_new(NULL); gtk_button_set_alignment(GTK_BUTTON(button), 0.5, 0.5); g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(angle_button_toggled), (gpointer)angle); if (angle == tedit_data.angle && tedit_data.angle_consistent) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), true); else gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), false); return button; } void tedit_edit_args_clicked(GtkWidget *widget, gpointer data) { if (!tedit_data.type_consistent) return; thing_type_t *ttype = get_thing_type(tedit_data.type); open_args_edit(tedit_data.args, ttype->args, ttype->arg_types, tedit_data.arg_consistent); } GtkWidget* setup_thing_edit() { // Get thing properties tedit_data.angle_consistent = true; tedit_data.type_consistent = true; tedit_data.tid_consistent = true; tedit_data.special_consistent = true; tedit_data.zheight_consistent = true; memset(tedit_data.arg_consistent, 1, 5); if (selected_items.size() == 0) { tedit_data.angle = map.things[hilight_item]->angle; tedit_data.type = map.things[hilight_item]->type; tedit_data.tid = map.things[hilight_item]->tid; tedit_data.special = map.things[hilight_item]->special; memcpy(tedit_data.args, map.things[hilight_item]->args, 5); } else { tedit_data.angle = map.things[selected_items[0]]->angle; tedit_data.type = map.things[selected_items[0]]->type; tedit_data.tid = map.things[selected_items[0]]->tid; tedit_data.special = map.things[selected_items[0]]->special; memcpy(tedit_data.args, map.things[selected_items[0]]->args, 5); for (int a = 0; a < selected_items.size(); a++) { if (map.things[selected_items[a]]->angle != tedit_data.angle) tedit_data.angle_consistent = false; if (map.things[selected_items[a]]->type != tedit_data.type) tedit_data.type_consistent = false; if (map.things[selected_items[a]]->tid != tedit_data.tid) tedit_data.tid_consistent = false; if (map.things[selected_items[a]]->special != tedit_data.special) tedit_data.special_consistent = false; if (map.things[selected_items[a]]->z != tedit_data.zheight) tedit_data.zheight_consistent = false; for (int b = 0; b < 5; b++) { if (map.things[selected_items[a]]->args[b] != tedit_data.args[b]) tedit_data.arg_consistent[b] = false; } } } if (thing_tbox) { delete thing_tbox; thing_tbox = NULL; } GtkWidget *main_vbox = gtk_vbox_new(false, 0); // FLAGS FRAME GtkWidget *frame = gtk_frame_new("Flags"); gtk_container_set_border_width(GTK_CONTAINER(frame), 4); gtk_box_pack_start(GTK_BOX(main_vbox), frame, true, true, 0); GtkWidget *hbox = gtk_hbox_new(false, 0); gtk_container_set_border_width(GTK_CONTAINER(hbox), 4); GtkWidget *vbox = gtk_vbox_new(false, 0); gtk_box_pack_start(GTK_BOX(vbox), setup_flag_checkbox("Appears On Easy", 2, THING_EASY), false, false, 0); gtk_box_pack_start(GTK_BOX(vbox), setup_flag_checkbox("Appears On Medium", 2, THING_MEDIUM), false, false, 0); gtk_box_pack_start(GTK_BOX(vbox), setup_flag_checkbox("Appears On Hard", 2, THING_HARD), false, false, 0); gtk_box_pack_start(GTK_BOX(vbox), setup_flag_checkbox("Deaf (Only wakes on sight)", 2, THING_DEAF), false, false, 0); if (map.hexen) gtk_box_pack_start(GTK_BOX(vbox), setup_flag_checkbox("Dormant", 2, THING_DORMANT), false, false, 0); else gtk_box_pack_start(GTK_BOX(vbox), setup_flag_checkbox("Appears In Multiplayer", 2, THING_MULTI), false, false, 0); gtk_box_pack_start(GTK_BOX(hbox), vbox, false, false, 0); if (map.hexen) { vbox = gtk_vbox_new(false, 0); gtk_box_pack_start(GTK_BOX(vbox), setup_flag_checkbox("Appears To Fighter", 2, THING_FIGHTER), false, false, 0); gtk_box_pack_start(GTK_BOX(vbox), setup_flag_checkbox("Appears To Cleric", 2, THING_CLERIC), false, false, 0); gtk_box_pack_start(GTK_BOX(vbox), setup_flag_checkbox("Appears To Mage", 2, THING_MAGE), false, false, 0); gtk_box_pack_start(GTK_BOX(vbox), setup_flag_checkbox("Appears In Single Player", 2, THING_SINGLE), false, false, 0); gtk_box_pack_start(GTK_BOX(vbox), setup_flag_checkbox("Appears In Cooperative", 2, THING_COOPERATIVE), false, false, 0); gtk_box_pack_start(GTK_BOX(hbox), vbox, false, false, 0); vbox = gtk_vbox_new(false, 0); gtk_box_pack_start(GTK_BOX(vbox), setup_flag_checkbox("Appears In Deathmatch", 2, THING_DEATHMATCH), false, false, 0); } if (map.zdoom) { gtk_box_pack_start(GTK_BOX(vbox), setup_flag_checkbox("Translucent", 2, THING_TRANSLUCENT), false, false, 0); gtk_box_pack_start(GTK_BOX(vbox), setup_flag_checkbox("Invisible", 2, THING_INVISIBLE), false, false, 0); gtk_box_pack_start(GTK_BOX(vbox), setup_flag_checkbox("Friendly", 2, THING_FRIENDLY), false, false, 0); gtk_box_pack_start(GTK_BOX(vbox), setup_flag_checkbox("Stands Still", 2, THING_STANDSTILL), false, false, 0); } gtk_box_pack_start(GTK_BOX(hbox), vbox, false, false, 0); gtk_container_add(GTK_CONTAINER(frame), hbox); hbox = gtk_hbox_new(false, 0); // TYPE FRAME frame = gtk_frame_new("Type"); gtk_container_set_border_width(GTK_CONTAINER(frame), 4); GtkWidget *table = gtk_table_new(4, 5, true); gtk_table_set_row_spacings(GTK_TABLE(table), 4); gtk_table_set_col_spacings(GTK_TABLE(table), 4); gtk_container_set_border_width(GTK_CONTAINER(table), 4); gtk_container_add(GTK_CONTAINER(frame), table); gtk_box_pack_start(GTK_BOX(hbox), frame, true, true, 0); // Texbox frame = gtk_frame_new(NULL); gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN); thing_tbox = new tex_box_t("", 3, 2.0f, rgba_t(180, 180, 180, 255, 0)); gtk_container_add(GTK_CONTAINER(frame), thing_tbox->widget); gtk_table_attach_defaults(GTK_TABLE(table), frame, 0, 3, 0, 3); gtk_widget_set_events(thing_tbox->widget, GDK_BUTTON_PRESS_MASK); g_signal_connect(G_OBJECT(thing_tbox->widget), "button_press_event", G_CALLBACK(tedit_sprite_clicked), NULL); // Entry tedit_data.entry_type = gtk_entry_new(); gtk_widget_set_size_request(tedit_data.entry_type, 32, -1); g_signal_connect(G_OBJECT(tedit_data.entry_type), "changed", G_CALLBACK(tedit_type_entry_changed), NULL); gtk_table_attach_defaults(GTK_TABLE(table), tedit_data.entry_type, 3, 5, 0, 1); // Change button GtkWidget *button = gtk_button_new_with_label("Change"); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(tedit_change_type_clicked), NULL); gtk_table_attach(GTK_TABLE(table), button, 3, 5, 1, 2, GTK_FILL, GTK_SHRINK, 0, 0); // Browse button button = gtk_button_new_with_label("Browse"); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(tedit_browse_type_clicked), NULL); gtk_table_attach(GTK_TABLE(table), button, 3, 5, 2, 3, GTK_FILL, GTK_SHRINK, 0, 0); // Label tedit_data.label_type = gtk_label_new(""); gtk_table_attach_defaults(GTK_TABLE(table), tedit_data.label_type, 0, 5, 3, 4); if (tedit_data.type_consistent) { thing_type_t* ttype = get_thing_type(tedit_data.type); thing_tbox->change_texture(ttype->spritename, 3, 2.0f); gtk_entry_set_text(GTK_ENTRY(tedit_data.entry_type), parse_string("%d", ttype->type).c_str()); gtk_label_set_text(GTK_LABEL(tedit_data.label_type), ttype->name.c_str()); } // ANGLE FRAME frame = gtk_frame_new("Angle"); gtk_container_set_border_width(GTK_CONTAINER(frame), 4); gtk_box_pack_start(GTK_BOX(hbox), frame, false, false, 0); tedit_data.entry_angle = gtk_entry_new(); g_signal_connect(G_OBJECT(tedit_data.entry_angle), "changed", G_CALLBACK(tedit_angle_entry_changed), NULL); vbox = gtk_vbox_new(false, 0); gtk_container_set_border_width(GTK_CONTAINER(vbox), 4); gtk_container_add(GTK_CONTAINER(frame), vbox); frame = gtk_aspect_frame_new(NULL, 0.5, 0.5, 1.0, true); table = gtk_table_new(5, 5, true); gtk_container_add(GTK_CONTAINER(frame), table); gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE); gtk_box_pack_start(GTK_BOX(vbox), frame, true, true, 0); GtkWidget* btn_angle_unknown = gtk_radio_button_new(NULL); gtk_table_attach_defaults(GTK_TABLE(table), setup_angle_button(GTK_RADIO_BUTTON(btn_angle_unknown), 90), 2, 3, 0, 1); gtk_table_attach_defaults(GTK_TABLE(table), setup_angle_button(GTK_RADIO_BUTTON(btn_angle_unknown), 45), 3, 4, 1, 2); gtk_table_attach_defaults(GTK_TABLE(table), setup_angle_button(GTK_RADIO_BUTTON(btn_angle_unknown), 0), 4, 5, 2, 3); gtk_table_attach_defaults(GTK_TABLE(table), setup_angle_button(GTK_RADIO_BUTTON(btn_angle_unknown), 315), 3, 4, 3, 4); gtk_table_attach_defaults(GTK_TABLE(table), setup_angle_button(GTK_RADIO_BUTTON(btn_angle_unknown), 270), 2, 3, 4, 5); gtk_table_attach_defaults(GTK_TABLE(table), setup_angle_button(GTK_RADIO_BUTTON(btn_angle_unknown), 225), 1, 2, 3, 4); gtk_table_attach_defaults(GTK_TABLE(table), setup_angle_button(GTK_RADIO_BUTTON(btn_angle_unknown), 180), 0, 1, 2, 3); gtk_table_attach_defaults(GTK_TABLE(table), setup_angle_button(GTK_RADIO_BUTTON(btn_angle_unknown), 135), 1, 2, 1, 2); gtk_widget_set_size_request(tedit_data.entry_angle, 32, -1); gtk_box_pack_start(GTK_BOX(vbox), tedit_data.entry_angle, false, false, 4); if (tedit_data.angle_consistent) gtk_entry_set_text(GTK_ENTRY(tedit_data.entry_angle), parse_string("%d", tedit_data.angle).c_str()); gtk_box_pack_start(GTK_BOX(main_vbox), hbox, true, true, 0); if (map.hexen) { GtkWidget* hbox2 = gtk_hbox_new(false, 0); // TID FRAME frame = gtk_frame_new("Thing ID"); gtk_container_set_border_width(GTK_CONTAINER(frame), 4); gtk_box_pack_start(GTK_BOX(hbox2), frame, true, true, 0); hbox = gtk_hbox_new(false, 0); gtk_container_set_border_width(GTK_CONTAINER(hbox), 4); gtk_container_add(GTK_CONTAINER(frame), hbox); // Entry tedit_data.entry_tid = gtk_entry_new(); gtk_widget_set_size_request(tedit_data.entry_tid, 32, -1); g_signal_connect(G_OBJECT(tedit_data.entry_tid), "changed", G_CALLBACK(tedit_tid_entry_changed), NULL); gtk_box_pack_start(GTK_BOX(hbox), tedit_data.entry_tid, true, true, 0); // Button button = gtk_button_new_with_label("Find Unused"); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(tedit_find_tid_clicked), NULL); gtk_box_pack_start(GTK_BOX(hbox), button, false, false, 4); if (tedit_data.tid_consistent) gtk_entry_set_text(GTK_ENTRY(tedit_data.entry_tid), parse_string("%d", tedit_data.tid).c_str()); // Z HEIGHT FRAME frame = gtk_frame_new("Z Height"); gtk_container_set_border_width(GTK_CONTAINER(frame), 4); gtk_box_pack_start(GTK_BOX(hbox2), frame, false, false, 0); hbox = gtk_hbox_new(false, 0); gtk_container_set_border_width(GTK_CONTAINER(hbox), 4); gtk_container_add(GTK_CONTAINER(frame), hbox); // Entry tedit_data.entry_zheight = gtk_entry_new(); gtk_widget_set_size_request(tedit_data.entry_zheight, 32, -1); g_signal_connect(G_OBJECT(tedit_data.entry_zheight), "changed", G_CALLBACK(tedit_zheight_entry_changed), NULL); gtk_box_pack_start(GTK_BOX(hbox), tedit_data.entry_zheight, true, true, 0); if (tedit_data.zheight_consistent) gtk_entry_set_text(GTK_ENTRY(tedit_data.entry_zheight), parse_string("%d", tedit_data.zheight).c_str()); // SPECIAL FRAME frame = gtk_frame_new("Action Special"); gtk_container_set_border_width(GTK_CONTAINER(frame), 4); gtk_box_pack_start(GTK_BOX(hbox2), frame, true, true, 0); hbox = gtk_hbox_new(false, 0); gtk_container_set_border_width(GTK_CONTAINER(hbox), 4); gtk_container_add(GTK_CONTAINER(frame), hbox); // Entry tedit_data.entry_special = gtk_entry_new(); gtk_widget_set_size_request(tedit_data.entry_special, 32, -1); g_signal_connect(G_OBJECT(tedit_data.entry_special), "changed", G_CALLBACK(tedit_special_entry_changed), NULL); gtk_box_pack_start(GTK_BOX(hbox), tedit_data.entry_special, true, true, 0); // Button button = gtk_button_new_with_label("Change"); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(tedit_change_special_clicked), NULL); gtk_box_pack_start(GTK_BOX(hbox), button, false, false, 4); if (tedit_data.special_consistent) gtk_entry_set_text(GTK_ENTRY(tedit_data.entry_special), parse_string("%d", tedit_data.special).c_str()); // ARGS FRAME frame = gtk_frame_new("Args"); gtk_container_set_border_width(GTK_CONTAINER(frame), 4); gtk_box_pack_start(GTK_BOX(hbox2), frame, false, false, 0); hbox = gtk_hbox_new(false, 0); gtk_container_set_border_width(GTK_CONTAINER(hbox), 4); gtk_container_add(GTK_CONTAINER(frame), hbox); button = gtk_button_new_with_label("Edit Args"); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(tedit_edit_args_clicked), NULL); gtk_box_pack_start(GTK_BOX(hbox), button, true, true, 0); gtk_box_pack_start(GTK_BOX(main_vbox), hbox2, false, false, 0); } return main_vbox; } void apply_thing_edit() { // Get things to be changed vector<thing_t*> edit_things; edit_things.push_back(&last_thing); if (selected_items.size() == 0) edit_things.push_back(map.things[hilight_item]); else { for (int a = 0; a < selected_items.size(); a++) edit_things.push_back(map.things[selected_items[a]]); } // Set changed flags for (int a = 0; a < set_flags.size(); a++) { for (int b = 0; b < edit_things.size(); b++) edit_things[b]->set_flag(set_flags[a]); } // Unset changed flags for (int a = 0; a < unset_flags.size(); a++) { for (int b = 0; b < edit_things.size(); b++) edit_things[b]->clear_flag(unset_flags[a]); } // Type if (tedit_data.type_consistent) { for (int a = 0; a < edit_things.size(); a++) { edit_things[a]->type = tedit_data.type; edit_things[a]->ttype = get_thing_type(tedit_data.type); } } // Angle if (tedit_data.angle_consistent) { for (int a = 0; a < edit_things.size(); a++) edit_things[a]->angle = tedit_data.angle; } if (map.hexen) { // TID if (tedit_data.tid_consistent) { for (int a = 0; a < edit_things.size(); a++) edit_things[a]->tid = tedit_data.tid; } // Z Height if (tedit_data.tid_consistent) { for (int a = 0; a < edit_things.size(); a++) edit_things[a]->z = tedit_data.zheight; } // Action Special if (tedit_data.special_consistent) { for (int a = 0; a < edit_things.size(); a++) edit_things[a]->special = tedit_data.special; } // Args for (int a = 0; a < 5; a++) { if (tedit_data.arg_consistent[a]) { for (int b = 0; b < edit_things.size(); b++) edit_things[b]->args[a] = tedit_data.args[a]; } } } } void open_thing_edit() { set_flags.clear(); unset_flags.clear(); GtkWidget *dialog = gtk_dialog_new_with_buttons("Edit Thing", GTK_WINDOW(editor_window), GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), setup_thing_edit()); gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ON_PARENT); //gtk_window_set_resizable(GTK_WINDOW(dialog), false); gtk_window_set_default_size(GTK_WINDOW(dialog), 370, -1); gtk_widget_show_all(dialog); int response = gtk_dialog_run(GTK_DIALOG(dialog)); if (response == GTK_RESPONSE_ACCEPT) { apply_thing_edit(); map.change_level(MC_THINGS); force_map_redraw(true, false); } gtk_widget_destroy(dialog); gtk_window_present(GTK_WINDOW(editor_window)); }
[ "veilofsorrow@0f6d0948-3201-0410-bbe6-95a89488c5be" ]
[ [ [ 1, 584 ] ] ]
d97323d94e1d13f16172e6d32b9658e55e4d7ac5
997e067ab6b591e93e3968ae1852003089dca848
/src/game/collision.hpp
53ea2385181418c277b2b34c2074a011d2a76261
[ "LicenseRef-scancode-other-permissive", "Zlib" ]
permissive
floff/ddracemax_old
06cbe9f60e7cef66e58b40c5f586921a1c881ff3
f1356177c49a3bc20632df9a84a51bc491c37f7d
refs/heads/master
2016-09-05T11:59:55.623581
2011-01-14T04:58:25
2011-01-14T04:58:25
777,555
1
0
null
null
null
null
UTF-8
C++
false
false
1,180
hpp
/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ #ifndef GAME_MAPRES_COL_H #define GAME_MAPRES_COL_H #include <base/vmath.hpp> enum { COLFLAG_SOLID=1, COLFLAG_DEATH=2, COLFLAG_NOHOOK=4, COLFLAG_NOLASER=8, }; int col_init(); int col_is_solid(int x, int y); void col_set(int x, int y, int flag); int col_get(int x, int y); int col_width(); int col_height(); int col_intersect_line(vec2 pos0, vec2 pos1, vec2 *out_collision, vec2 *out_before_collision, bool allow_through = false); int col_intersect_nolaser(vec2 pos0, vec2 pos1, vec2 *out_collision, vec2 *out_before_collision); int col_intersect_air(vec2 pos0, vec2 pos1, vec2 *out_collision, vec2 *out_before_collision); //race int col_is_teleport(int x, int y); int col_is_checkpoint(int x, int y); int col_is_begin(int x, int y); int col_is_nolaser(int x, int y); int col_is_end(int x, int y); int col_is_boost(int x, int y); int col_is_freeze(int x, int y); int col_is_unfreeze(int x, int y); int col_is_ehook_start(int x, int y); int col_is_ehook_end(int x, int y); int col_is_kick(int x, int y); vec2 boost_accel(int index); vec2 teleport(int z); #endif
[ [ [ 1, 34 ], [ 37, 40 ] ], [ [ 35, 36 ] ] ]
2f44da951a6b39785d43fef62e225c7f007a89f0
94b5dbeae59dcd378b2e57982b6640afac824405
/SpriteEngine/Frame.hpp
308438cdcb5c00f502aa1a963454d06e10b58adb
[]
no_license
Mikechaos/Super-Bodhi
e106fa4ac33151b9b9f86a9fe6590e4f5d5bc1d5
3e2b28046239e0780ee043a5a5e7e6d6e391434b
refs/heads/master
2020-12-30T14:56:45.867331
2011-02-24T17:47:51
2011-02-24T17:47:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
862
hpp
#ifndef FRAME_H #define FRAME_H #include <SFML/Graphics.hpp> #include "BaseImage.hpp" // Une Frame est composée d'un pointeur sur une image, d'un SubRect et d'une couleur // La couleur par défaut d'une Frame est le blanc. class Frame { public: // Accès public à l'image, au Rect et à la couleur BaseImage* image; sf::Rect<int> rect; sf::Color color; // Par défaut Frame(const sf::Color& NewColor = sf::Color::White); // Par copie Frame(const Frame& Cpy); // Image et Rect Frame(BaseImage *NewImage, const sf::Rect<int>& NewRect, const sf::Color& NewColor = sf::Color::White); // Image (Le Rect est au dimension de l'image) Frame(BaseImage *NewImage, const sf::Color& NewColor = sf::Color::White); // destructeur ~Frame(); }; #endif // FRAME_H
[ "mike@mike-desktop.(none)" ]
[ [ [ 1, 39 ] ] ]
6aac22a8c340a0c31bbb0a586cfd75c60ff3d761
23939b88feae85abfd72601120a54b637661c164
/Link.h
c8a04a65e47651440ee085282633d7fff155a21f
[]
no_license
klanestro/textCalc
e9feae14be270cd22de347e2e4b764fadfb0709c
2634f92702aaf7d9a61187b2a34b998d92780672
refs/heads/master
2021-01-19T13:50:28.692058
2010-01-21T09:29:53
2010-01-21T09:29:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,098
h
// Link.h: interface for the CLink class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_LINK_H__81E1AA46_8C87_11D3_9F2C_F2073F59A624__INCLUDED_) #define AFX_LINK_H__81E1AA46_8C87_11D3_9F2C_F2073F59A624__INCLUDED_ #if _MSC_VER >= 1000 #pragma once #endif // _MSC_VER >= 1000 enum State { ST_NOT_VISITED, ST_VISITED, ST_VISIT_FAILED, ST_HIGHLIGHTED }; enum Mode { OPEN, EDIT, PRINT }; class CLink { public: CLink(); virtual ~CLink(); CString m_sActualLink; BOOL Open (int how = OPEN ); BOOL OpenUsingCom (int how = OPEN ); BOOL OpenUsingShellExecute (int how = OPEN ); LONG GetRegKey (HKEY key, LPCTSTR subkey, LPTSTR retdata); BOOL OpenUsingRegisteredClass (int how = OPEN ); void SetHyperLink (CString & sActualLink); CString GetActualHyperLink () { return m_sActualLink; }; void SetActualHyperLink (const CString & sActualLink); void CheckActualHyperLink (); }; #endif // !defined(AFX_LINK_H__81E1AA46_8C87_11D3_9F2C_F2073F59A624__INCLUDED_)
[ [ [ 1, 51 ] ] ]
772eb4200e3f641f4bccd5172b695ab1c4f3103e
c2abb873c8b352d0ec47757031e4a18b9190556e
/src/ogreIncludes/CEGUI/CEGUIWidgetModule.h
e31a5e10c9f3938ac19e865b898bea21322239d7
[]
no_license
twktheainur/vortex-ee
70b89ec097cd1c74cde2b75f556448965d0d345d
8b8aef42396cbb4c9ce063dd1ab2f44d95e994c6
refs/heads/master
2021-01-10T02:26:21.913972
2009-01-30T12:53:21
2009-01-30T12:53:21
44,046,528
0
0
null
null
null
null
UTF-8
C++
false
false
4,663
h
/*********************************************************************** filename: CEGUIWidgetModule.h created: Sun Sep 25 2005 author: Paul D Turner <[email protected]> *************************************************************************/ /*************************************************************************** * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team * * 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 BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. ***************************************************************************/ #ifndef _CEGUIWidgetModule_h_ #define _CEGUIWidgetModule_h_ #include "CEGUIExceptions.h" #include "CEGUIWindowFactoryManager.h" #if (defined( __WIN32__ ) || defined( _WIN32 )) # ifdef CEGUIWIDGETMODULE_EXPORTS # define CEGUIWIDGETMODULE_API __declspec(dllexport) # else # if defined(__MINGW32__) # define CEGUIWIDGETMODULE_API # else # define CEGUIWIDGETMODULE_API __declspec(dllimport) # endif # endif #else # define CEGUIWIDGETMODULE_API #endif #define CEGUI_DECLARE_WIDGET_MODULE( moduleName )\ \ class CEGUI::WindowFactory;\ \ extern "C" CEGUIWIDGETMODULE_API void registerFactory(const CEGUI::String& type_name);\ extern "C" CEGUIWIDGETMODULE_API CEGUI::uint registerAllFactories(void);\ void doSafeFactoryRegistration(CEGUI::WindowFactory* factory); #define CEGUI_DEFINE_FACTORY( className )\ namespace CEGUI {\ class className ## Factory : public WindowFactory\ {\ public:\ className ## Factory(void) : WindowFactory(className::WidgetTypeName) { }\ Window* createWindow(const String& name)\ { return new className(d_type, name); }\ void destroyWindow(Window* window)\ { delete window; }\ };\ }\ static CEGUI::className ## Factory s_ ## className ## Factory; #define CEGUI_START_FACTORY_MAP( module )\ struct module ## MapEntry\ {\ const CEGUI::utf8* d_name;\ CEGUI::WindowFactory* d_factory;\ };\ \ module ## MapEntry module ## FactoriesMap[] =\ {\ #define CEGUI_END_FACTORY_MAP {0,0}}; #define CEGUI_FACTORY_MAP_ENTRY( class )\ {CEGUI::class::WidgetTypeName, &s_ ## class ## Factory}, #define CEGUI_DEFINE_WIDGET_MODULE( module )\ extern "C" void registerFactory(const CEGUI::String& type_name)\ {\ module ## MapEntry* entry = module ## FactoriesMap;\ while (entry->d_name)\ {\ if (entry->d_name == type_name)\ {\ doSafeFactoryRegistration(entry->d_factory);\ return;\ }\ ++entry;\ }\ \ throw CEGUI::UnknownObjectException("::registerFactory - The window factory for type '" + type_name + "' is not known in this module.");\ }\ \ extern "C" CEGUI::uint registerAllFactories(void)\ {\ CEGUI::uint count = 0;\ module ## MapEntry* entry = module ## FactoriesMap;\ while (entry->d_name)\ {\ doSafeFactoryRegistration(entry->d_factory);\ ++entry;\ ++count;\ }\ return count;\ }\ \ void doSafeFactoryRegistration(CEGUI::WindowFactory* factory)\ {\ assert(factory != 0);\ \ CEGUI::WindowFactoryManager& wfm = CEGUI::WindowFactoryManager::getSingleton();\ if (wfm.isFactoryPresent(factory->getTypeName()))\ {\ CEGUI::Logger::getSingleton().logEvent(\ "Widget factory '" + factory->getTypeName() + "' appears to be already registered, skipping.",\ CEGUI::Informative);\ }\ else\ {\ wfm.addFactory(factory);\ }\ } #endif // end of guard _CEGUIWidgetModule_h_
[ "seb.owk@37e2baaa-b253-11dd-9381-bf584fb1fa83" ]
[ [ [ 1, 133 ] ] ]
657b335059bac68ef7fc79f5ea1a3bd242a30012
ce262ae496ab3eeebfcbb337da86d34eb689c07b
/SERenderers/SE_OpenGL_Renderer/SEOpenGLRendering/SEOpenGLResourcesED.cpp
58927d72ebe4ced44f0c3365b6dbe6bb637f4a1d
[]
no_license
pizibing/swingengine
d8d9208c00ec2944817e1aab51287a3c38103bea
e7109d7b3e28c4421c173712eaf872771550669e
refs/heads/master
2021-01-16T18:29:10.689858
2011-06-23T04:27:46
2011-06-23T04:27:46
33,969,301
0
0
null
null
null
null
GB18030
C++
false
false
9,258
cpp
// Swing Engine Version 1 Source Code // Most of techniques in the engine are mainly based on David Eberly's // Wild Magic 4 open-source code.The author of Swing Engine learned a lot // from Eberly's experience of architecture and algorithm. // Several sub-systems are totally new,and others are re-implimented or // re-organized based on Wild Magic 4's sub-systems. // Copyright (c) 2007-2010. All Rights Reserved // // Eberly's permission: // Geometric Tools, Inc. // http://www.geometrictools.com // Copyright (c) 1998-2006. All Rights Reserved // // This library is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation; either version 2.1 of the License, or (at // your option) any later version. The license is available for reading at // the location: // http://www.gnu.org/copyleft/lgpl.html #include "SEOpenGLRendererPCH.h" #include "SEOpenGLRenderer.h" #include "SEOpenGLResources.h" using namespace Swing; //---------------------------------------------------------------------------- // 资源开启与关闭. //---------------------------------------------------------------------------- void SEOpenGLRenderer::SetVProgramRC(SERendererConstant* pRC) { cgSetParameterValuefr((CGparameter)pRC->GetID(), pRC->GetDataCount(), pRC->GetData()); SE_GL_DEBUG_CG_PROGRAM; } //---------------------------------------------------------------------------- void SEOpenGLRenderer::SetVProgramUC(SEUserConstant* pUC) { cgSetParameterValuefr((CGparameter)pUC->GetID(), pUC->GetDataCount(), pUC->GetData()); SE_GL_DEBUG_CG_PROGRAM; } //---------------------------------------------------------------------------- void SEOpenGLRenderer::SetGProgramRC(SERendererConstant* pRC) { cgSetParameterValuefr((CGparameter)pRC->GetID(), pRC->GetDataCount(), pRC->GetData()); SE_GL_DEBUG_CG_PROGRAM; } //---------------------------------------------------------------------------- void SEOpenGLRenderer::SetGProgramUC(SEUserConstant* pUC) { cgSetParameterValuefr((CGparameter)pUC->GetID(), pUC->GetDataCount(), pUC->GetData()); SE_GL_DEBUG_CG_PROGRAM; } //---------------------------------------------------------------------------- void SEOpenGLRenderer::SetPProgramRC(SERendererConstant* pRC) { cgSetParameterValuefr((CGparameter)pRC->GetID(), pRC->GetDataCount(), pRC->GetData()); SE_GL_DEBUG_CG_PROGRAM; } //---------------------------------------------------------------------------- void SEOpenGLRenderer::SetPProgramUC(SEUserConstant* pUC) { cgSetParameterValuefr((CGparameter)pUC->GetID(), pUC->GetDataCount(), pUC->GetData()); SE_GL_DEBUG_CG_PROGRAM; } //---------------------------------------------------------------------------- void SEOpenGLRenderer::UpdateVProgramConstants(SEVertexProgram* pVProgram) { SEProgramData* pData = (SEProgramData*)pVProgram->UserData; cgUpdateProgramParameters(pData->ID); SE_GL_DEBUG_CG_PROGRAM; } //---------------------------------------------------------------------------- void SEOpenGLRenderer::UpdateGProgramConstants(SEGeometryProgram* pGProgram) { SEProgramData* pData = (SEProgramData*)pGProgram->UserData; cgUpdateProgramParameters(pData->ID); SE_GL_DEBUG_CG_PROGRAM; } //---------------------------------------------------------------------------- void SEOpenGLRenderer::UpdatePProgramConstants(SEPixelProgram* pPProgram) { SEProgramData* pData = (SEProgramData*)pPProgram->UserData; cgUpdateProgramParameters(pData->ID); SE_GL_DEBUG_CG_PROGRAM; } //---------------------------------------------------------------------------- void SEOpenGLRenderer::OnEnableVProgram(SEResourceIdentifier* pID) { SEVProgramID* pResource = (SEVProgramID*)pID; cgGLEnableProfile(m_CgLatestVProfile); SE_GL_DEBUG_CG_PROGRAM; cgGLBindProgram(pResource->ID); SE_GL_DEBUG_CG_PROGRAM; } //---------------------------------------------------------------------------- void SEOpenGLRenderer::OnDisableVProgram(SEResourceIdentifier*) { cgGLDisableProfile(m_CgLatestVProfile); SE_GL_DEBUG_CG_PROGRAM; } //---------------------------------------------------------------------------- void SEOpenGLRenderer::OnEnablePProgram(SEResourceIdentifier* pID) { SEPProgramID* pResource = (SEPProgramID*)pID; cgGLEnableProfile(m_CgLatestPProfile); SE_GL_DEBUG_CG_PROGRAM; cgGLBindProgram(pResource->ID); SE_GL_DEBUG_CG_PROGRAM; } //---------------------------------------------------------------------------- void SEOpenGLRenderer::OnDisablePProgram(SEResourceIdentifier*) { cgGLDisableProfile(m_CgLatestPProfile); SE_GL_DEBUG_CG_PROGRAM; } //---------------------------------------------------------------------------- void SEOpenGLRenderer::OnEnableTexture(SEResourceIdentifier* pID) { SETextureID* pResource = (SETextureID*)pID; SESamplerInformation* pSI = m_apActiveSamplers[m_iCurrentSampler]; CGparameter hParam = (CGparameter)pSI->GetID(); cgGLSetTextureParameter(hParam, pResource->ID); SE_GL_DEBUG_CG_PROGRAM; cgGLEnableTextureParameter(hParam); SE_GL_DEBUG_CG_PROGRAM; } //---------------------------------------------------------------------------- void SEOpenGLRenderer::OnDisableTexture(SEResourceIdentifier*) { SESamplerInformation* pSI = m_apActiveSamplers[m_iCurrentSampler]; CGparameter hParam = (CGparameter)pSI->GetID(); cgGLDisableTextureParameter(hParam); SE_GL_DEBUG_CG_PROGRAM; } //---------------------------------------------------------------------------- void SEOpenGLRenderer::OnEnableVBuffer(SEResourceIdentifier* pID, SEVertexProgram*) { // Bind当前vertex buffer. SEVBufferID* pResource = (SEVBufferID*)pID; glBindBuffer(GL_ARRAY_BUFFER, pResource->ID); const SEAttributes& rRAttr = pResource->IAttr; GLsizei iSize = (GLsizei)(sizeof(float)*rRAttr.GetChannelCount()); const float* afData = 0; if( rRAttr.HasPosition() ) { glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(rRAttr.GetPositionChannels(), GL_FLOAT, iSize, afData + rRAttr.GetPositionOffset()); } if( rRAttr.HasNormal() ) { // OpenGL不允许用户指定normal vector的分量个数. // 因此,rRAttr.GetNChannels函数返回的分量个数应该为3. glEnableClientState(GL_NORMAL_ARRAY); glNormalPointer(GL_FLOAT, iSize, afData + rRAttr.GetNormalOffset()); } if( rRAttr.HasColor(0) ) { glEnableClientState(GL_COLOR_ARRAY); glColorPointer(rRAttr.GetColorChannels(0), GL_FLOAT, iSize, afData + rRAttr.GetColorOffset(0)); } if( rRAttr.HasColor(1) ) { glEnableClientState(GL_SECONDARY_COLOR_ARRAY); glSecondaryColorPointer(rRAttr.GetColorChannels(1), GL_FLOAT, iSize, afData + rRAttr.GetColorOffset(1)); } for( int iUnit = 0; iUnit < rRAttr.GetMaxTCoords(); iUnit++ ) { if( rRAttr.HasTCoord(iUnit) ) { glClientActiveTexture(GL_TEXTURE0 + iUnit); glActiveTexture(GL_TEXTURE0 + iUnit); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(rRAttr.GetTCoordChannels(iUnit), GL_FLOAT, iSize, afData + rRAttr.GetTCoordOffset(iUnit)); } } } //---------------------------------------------------------------------------- void SEOpenGLRenderer::OnDisableVBuffer(SEResourceIdentifier* pID, SEVertexProgram*) { SEVBufferID* pResource = (SEVBufferID*)pID; const SEAttributes& rRAttr = pResource->IAttr; // Unbind当前vertex buffer. glBindBuffer(GL_ARRAY_BUFFER, 0); if( rRAttr.HasPosition() ) { glDisableClientState(GL_VERTEX_ARRAY); } if( rRAttr.HasNormal() ) { glDisableClientState(GL_NORMAL_ARRAY); } if( rRAttr.HasColor(0) ) { glDisableClientState(GL_COLOR_ARRAY); } if( rRAttr.HasColor(1) ) { glDisableClientState(GL_SECONDARY_COLOR_ARRAY); } for( int iUnit = 0; iUnit < rRAttr.GetMaxTCoords(); iUnit++ ) { if( rRAttr.HasTCoord(iUnit) ) { glClientActiveTexture(GL_TEXTURE0 + iUnit); glActiveTexture(GL_TEXTURE0 + iUnit); glDisableClientState(GL_TEXTURE_COORD_ARRAY); } } } //---------------------------------------------------------------------------- void SEOpenGLRenderer::OnEnableIBuffer(SEResourceIdentifier* pID) { // Bind当前index buffer. SEIBufferID* pResource = (SEIBufferID*)pID; glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, pResource->ID); } //---------------------------------------------------------------------------- void SEOpenGLRenderer::OnDisableIBuffer(SEResourceIdentifier*) { // Unbind当前index buffer. glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); } //----------------------------------------------------------------------------
[ "[email protected]@876e9856-8d94-11de-b760-4d83c623b0ac" ]
[ [ [ 1, 255 ] ] ]
e682e95ae475855c04e28ae9beb93aefc6488ea6
ea613c6a4d531be9b5d41ced98df1a91320c59cc
/7-Zip/CPP/7zip/Archive/Nsis/NsisHandler.h
718462747c48273db193d225901e6d39fbe5b231
[]
no_license
f059074251/interested
939f938109853da83741ee03aca161bfa9ce0976
b5a26ad732f8ffdca64cbbadf9625dd35c9cdcb2
refs/heads/master
2021-01-15T14:49:45.217066
2010-09-16T10:42:30
2010-09-16T10:42:30
34,316,088
1
0
null
null
null
null
UTF-8
C++
false
false
817
h
// NSisHandler.h #ifndef __NSIS_HANDLER_H #define __NSIS_HANDLER_H #include "Common/MyCom.h" #include "../IArchive.h" #include "NsisIn.h" #include "../../Common/CreateCoder.h" namespace NArchive { namespace NNsis { class CHandler: public IInArchive, PUBLIC_ISetCompressCodecsInfo public CMyUnknownImp { CMyComPtr<IInStream> _inStream; CInArchive _archive; DECL_EXTERNAL_CODECS_VARS bool GetUncompressedSize(int index, UInt32 &size); bool GetCompressedSize(int index, UInt32 &size); UString GetMethod(bool useItemFilter, UInt32 dictionary) const; public: MY_QUERYINTERFACE_BEGIN2(IInArchive) QUERY_ENTRY_ISetCompressCodecsInfo MY_QUERYINTERFACE_END MY_ADDREF_RELEASE INTERFACE_IInArchive(;) DECL_ISetCompressCodecsInfo }; }} #endif
[ "[email protected]@8d1da77e-e9f6-11de-9c2a-cb0f5ba72f9d" ]
[ [ [ 1, 43 ] ] ]
b0b4f3df5a26b0835f98de02011a8501d7136edf
42b578d005c2e8870a03fe02807e5607fec68f40
/src/xdde.h
1b18e1cb341e8931f83d10e1269887725cd4ee82
[ "MIT" ]
permissive
hylom/xom
e2b02470cd984d0539ded408d13f9945af6e5f6f
a38841cfe50c3e076b07b86700dfd01644bf4d4a
refs/heads/master
2021-01-23T02:29:51.908501
2009-10-30T08:41:30
2009-10-30T08:41:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,283
h
#ifndef _XDDE_H_ # define _XDDE_H_ # include <ddeml.h> #ifndef DDE_CLIENT_ONLY struct DdeCallbackInfo { UINT type; UINT fmt; HCONV hconv; HSZ topic; HSZ item; HDDEDATA hdata; DWORD data1; DWORD data2; }; # define DDE_EXECUTE_ITEM ((char *)1) struct DdeItemList { HSZ hsz_item; HDDEDATA (__stdcall *callback)(DdeCallbackInfo *); const char *item; int (__stdcall *matcher)(const DdeItemList *, HSZ); }; struct DdeTopicList { HSZ hsz_topic; DdeItemList *items; const char *topic; }; extern const char DdeServerName[]; extern DdeTopicList DdeServerTopicList[]; #endif /* not DDE_CLIENT_ONLY */ class Dde { static DWORD dde_inst; static void cleanup (); public: class Exception { public: int e; Exception (); Exception (int); }; protected: class DdeString { HSZ hsz; DdeString (const DdeString &); DdeString &operator = (const DdeString &); public: DdeString (const char *string); ~DdeString (); operator HSZ () const; }; #ifndef DDE_CLIENT_ONLY static HSZ hsz_server; static void register_server (); static void create_strings (); static void delete_strings (); public: static int verify_context (CONVCONTEXT *); static HDDEDATA wild_connect (HSZ, HSZ, CONVCONTEXT *); static DdeItemList *find_topic (HSZ, HSZ, HSZ); static HDDEDATA doprocess (DdeCallbackInfo &); #endif public: Dde (); ~Dde (); static void initialize (); static DWORD instance (); static HCONV initiate (const char *, const char *); static void terminate (HCONV); static void execute (HCONV, long, const char *, int); static void execute (HCONV, long, const char *); static void poke (HCONV, long, const char *, const char *, int); static void poke (HCONV, long, const char *, const char *); static HDDEDATA request (HCONV, long, const char *); }; class DdeDataP { protected: HDDEDATA hdata; DWORD len; BYTE *d; DdeDataP (const DdeDataP &); DdeDataP &operator = (const DdeDataP &); public: DdeDataP (HDDEDATA); int length () const; const char *data () const; }; class DdeData: public DdeDataP { public: DdeData (HDDEDATA); ~DdeData (); }; class DdeDataAccess: public DdeDataP { public: DdeDataAccess (HDDEDATA); ~DdeDataAccess (); }; inline DWORD Dde::instance () { if (!dde_inst) initialize (); return dde_inst; } inline Dde::Exception::Exception (int e_) : e (e_) { } inline Dde::Exception::Exception () : e (DdeGetLastError (instance ())) { } inline Dde::DdeString::DdeString (const char *string) { hsz = DdeCreateStringHandle (instance (), *string ? string : " ", CP_WINANSI); if (!hsz) throw Exception (); } inline Dde::DdeString::~DdeString () { if (hsz) DdeFreeStringHandle (instance (), hsz); } inline Dde::DdeString::operator HSZ () const { return hsz; } inline HCONV Dde::initiate (const char *serv, const char *topic) { DdeString xserv (serv), xtopic (topic); HCONV h = DdeConnect (instance (), xserv, xtopic, 0); if (!h) throw Exception (); return h; } inline void Dde::terminate (HCONV h) { if (!DdeDisconnect (h)) throw Exception (); } inline void Dde::execute (HCONV hconv, long timeout, const char *data, int l) { if (!DdeClientTransaction ((BYTE *)data, l, hconv, 0, 0, XTYP_EXECUTE, timeout, 0)) throw Exception (); } inline void Dde::execute (HCONV hconv, long timeout, const char *data) { execute (hconv, timeout, data, strlen (data) + 1); } inline void Dde::poke (HCONV hconv, long timeout, const char *item, const char *data, int l) { DdeString xitem (item); if (!DdeClientTransaction ((BYTE *)data, l, hconv, xitem, CF_TEXT, XTYP_POKE, timeout, 0)) throw Exception (); } inline void Dde::poke (HCONV hconv, long timeout, const char *item, const char *data) { poke (hconv, timeout, item, data, strlen (data) + 1); } inline HDDEDATA Dde::request (HCONV hconv, long timeout, const char *item) { DdeString xitem (item); HDDEDATA data = DdeClientTransaction (0, 0, hconv, xitem, CF_TEXT, XTYP_REQUEST, timeout, 0); if (!data) throw Exception (); return data; } inline DdeDataP::DdeDataP (HDDEDATA h_) : hdata (h_) { d = DdeAccessData (hdata, &len); } inline DdeDataP::length () const { return len; } inline const char * DdeDataP::data () const { return (const char *)d; } inline DdeData::DdeData (HDDEDATA h_) : DdeDataP (h_) { if (!d) { int e = DdeGetLastError (Dde::instance ()); DdeFreeDataHandle (hdata); throw Dde::Exception (e); } } inline DdeData::~DdeData () { if (d) DdeUnaccessData (hdata); DdeFreeDataHandle (hdata); } inline DdeDataAccess::DdeDataAccess (HDDEDATA h_) : DdeDataP (h_) { if (!d) throw Dde::Exception (); } inline DdeDataAccess::~DdeDataAccess () { if (d) DdeUnaccessData (hdata); } #endif
[ [ [ 1, 278 ] ] ]
556fd3fd98fe79911534742f4441ec81d09e6f16
9340e21ef492eec9f19d1e4ef2ef33a19354ca6e
/cing/src/common/eString.h
c499bc0a6f5c10c93973135eaab99d6ef6108819
[]
no_license
jamessqr/Cing
e236c38fe729fd9d49ccd1584358eaad475f7686
c46045d9d0c2b4d9e569466971bbff1662be4e7a
refs/heads/master
2021-01-17T22:55:17.935520
2011-05-14T18:35:30
2011-05-14T18:35:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,626
h
/* This source file is part of the Cing project For the latest info, see http://www.cing.cc Copyright (c) 2006-2009 Julio Obelleiro and Jorge Cano This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _Cing_String_H_ #define _Cing_String_H_ // Precompiled headers #include "Cing-Precompiled.h" #include <string> #include <iostream> #include <sstream> // Ogre Unicode support //#undef OGRE_UNICODE_SUPPORT //#define OGRE_UNICODE_SUPPORT 1 //#define INT32 int //#define UINT32 unsigned short //#include <iterator> //#include <string> #include "OgreUTFString.h" namespace Cing { // Forward declarations class String; /// String utils template< typename T> String toString( T input ); String intToString(int inputNumber); int stringToInt(const String& str); /** * @internal * Class to make easy work with strings. It is based on std::string */ class String: public std::string { public: String() {} String(const std::string& input) : std::string( input ) {} // for automatic cast when using operator = String(const char * input) : std::string( input ) {} // Get string data char charAt ( int index ); int indexOf ( const std::string& str ); int indexOf ( const std::string& str, int fromIndex ); int length () const { return (int)size(); } String substring ( int beginIndex ); String substring ( int beginIndex, int endIndex ); const char* toChar () const { return c_str(); } //Ogre::UTFString toUTF () const; // Compare bool equals ( const std::string& str ); // Modify string void toLowerCases (); void toUpperCases (); void replaceSubStr ( const String& subStrToFind, const String& subStrToReplace ); }; // Template method definition template<typename T> String toString( T input ) { std::stringstream s; s << input; return s.str(); } } // namespace Cing #endif // _String_H_
[ [ [ 1, 1 ], [ 4, 4 ], [ 6, 6 ], [ 11, 11 ], [ 16, 16 ], [ 20, 21 ], [ 24, 24 ], [ 29, 31 ], [ 42, 43 ], [ 45, 45 ], [ 55, 55 ], [ 61, 61 ], [ 86, 86 ], [ 98, 98 ] ], [ [ 2, 3 ], [ 5, 5 ], [ 7, 10 ], [ 12, 15 ], [ 17, 19 ], [ 22, 23 ], [ 25, 28 ], [ 32, 41 ], [ 44, 44 ], [ 46, 54 ], [ 56, 60 ], [ 62, 85 ], [ 87, 97 ], [ 99, 99 ] ] ]
763ec25af42f793270fc2a7047a91c5865fab5bb
d2af4bec60dd35fc40f4784f378efcf5acd13522
/Hooking Engine/PrototypeI_Final/PrototypeI/Logger.cpp
3f82467a68d7b7347a84ade05c700c08e792b1d5
[]
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
208
cpp
#include "logger.h" Log::Log(char* filename) { m_stream.clear(); m_stream.open(filename); } void Log::Write(char* logline) { m_stream<<logline<<endl; } Log::~Log() { m_stream.close(); }
[ [ [ 1, 17 ] ] ]
16544c07dfab99328566d3c82950f7bb00f95c07
c5534a6df16a89e0ae8f53bcd49a6417e8d44409
/trunk/Dependencies/Xerces/include/xercesc/validators/common/CMStateSet.hpp
4c72a8348ddf57b76585954a3e08d7ee1f9d4f76
[]
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
9,895
hpp
/* * Copyright 1999-2001,2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * $Id: CMStateSet.hpp 191054 2005-06-17 02:56:35Z jberry $ */ // DESCRIPTION: // // This class is a specialized bitset class for the content model code of // the validator. It assumes that its never called with two objects of // different bit counts, and that bit sets smaller than 64 bits are far // and away the most common. So it can be a lot more optimized than a general // purpose utility bitset class // #if !defined(CMSTATESET_HPP) #define CMSTATESET_HPP #include <xercesc/util/ArrayIndexOutOfBoundsException.hpp> #include <xercesc/util/RuntimeException.hpp> #include <xercesc/util/PlatformUtils.hpp> #include <xercesc/framework/MemoryManager.hpp> #include <string.h> XERCES_CPP_NAMESPACE_BEGIN class CMStateSet : public XMemory { public : // ----------------------------------------------------------------------- // Constructors and Destructor // ----------------------------------------------------------------------- CMStateSet( const unsigned int bitCount , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) : fBitCount(bitCount) , fByteArray(0) , fMemoryManager(manager) { // // See if we need to allocate the byte array or whether we can live // within the 64 bit high performance scheme. // if (fBitCount > 64) { fByteCount = fBitCount / 8; if (fBitCount % 8) fByteCount++; fByteArray = (XMLByte*) fMemoryManager->allocate(fByteCount*sizeof(XMLByte)); //new XMLByte[fByteCount]; } // Init all the bits to zero zeroBits(); } /* * This method with the 'for' statement (commented out) cannot be made inline * because the antiquated CC (CFront) compiler under HPUX 10.20 does not allow * the 'for' statement inside any inline method. Unfortunately, * we have to support it. So instead, we use memcpy(). */ CMStateSet(const CMStateSet& toCopy) : XMemory(toCopy) , fBitCount(toCopy.fBitCount) , fByteArray(0) , fMemoryManager(toCopy.fMemoryManager) { // // See if we need to allocate the byte array or whether we can live // within the 64 bit high performance scheme. // if (fBitCount > 64) { fByteCount = fBitCount / 8; if (fBitCount % 8) fByteCount++; fByteArray = (XMLByte*) fMemoryManager->allocate(fByteCount*sizeof(XMLByte)); //new XMLByte[fByteCount]; memcpy((void *) fByteArray, (const void *) toCopy.fByteArray, fByteCount * sizeof(XMLByte)); // for (unsigned int index = 0; index < fByteCount; index++) // fByteArray[index] = toCopy.fByteArray[index]; } else { fBits1 = toCopy.fBits1; fBits2 = toCopy.fBits2; } } ~CMStateSet() { if (fByteArray) fMemoryManager->deallocate(fByteArray); //delete [] fByteArray; } // ----------------------------------------------------------------------- // Set manipulation methods // ----------------------------------------------------------------------- void operator&=(const CMStateSet& setToAnd) { if (fBitCount < 65) { fBits1 &= setToAnd.fBits1; fBits2 &= setToAnd.fBits2; } else { for (unsigned int index = 0; index < fByteCount; index++) fByteArray[index] &= setToAnd.fByteArray[index]; } } void operator|=(const CMStateSet& setToOr) { if (fBitCount < 65) { fBits1 |= setToOr.fBits1; fBits2 |= setToOr.fBits2; } else { for (unsigned int index = 0; index < fByteCount; index++) fByteArray[index] |= setToOr.fByteArray[index]; } } bool operator==(const CMStateSet& setToCompare) const { if (fBitCount != setToCompare.fBitCount) return false; if (fBitCount < 65) { return ((fBits1 == setToCompare.fBits1) && (fBits2 == setToCompare.fBits2)); } for (unsigned int index = 0; index < fByteCount; index++) { if (fByteArray[index] != setToCompare.fByteArray[index]) return false; } return true; } CMStateSet& operator=(const CMStateSet& srcSet) { if (this == &srcSet) return *this; // They have to be the same size if (fBitCount != srcSet.fBitCount) ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Bitset_NotEqualSize, fMemoryManager); if (fBitCount < 65) { fBits1 = srcSet.fBits1; fBits2 = srcSet.fBits2; } else { for (unsigned int index = 0; index < fByteCount; index++) fByteArray[index] = srcSet.fByteArray[index]; } return *this; } bool getBit(const unsigned int bitToGet) const { if (bitToGet >= fBitCount) ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Bitset_BadIndex, fMemoryManager); if (fBitCount < 65) { unsigned int mask = (0x1UL << (bitToGet % 32)); if (bitToGet < 32) return ((fBits1 & mask) != 0); else return ((fBits2 & mask) != 0); } // Create the mask and byte values const XMLByte mask1 = XMLByte(0x1 << (bitToGet % 8)); const unsigned int byteOfs = bitToGet >> 3; // And access the right bit and byte return ((fByteArray[byteOfs] & mask1) != 0); } bool isEmpty() const { if (fBitCount < 65) return ((fBits1 == 0) && (fBits2 == 0)); for (unsigned int index = 0; index < fByteCount; index++) { if (fByteArray[index] != 0) return false; } return true; } void setBit(const unsigned int bitToSet) { if (bitToSet >= fBitCount) ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Bitset_BadIndex, fMemoryManager); if (fBitCount < 65) { const unsigned int mask = (0x1UL << (bitToSet % 32)); if (bitToSet < 32) { fBits1 &= ~mask; fBits1 |= mask; } else { fBits2 &= ~mask; fBits2 |= mask; } } else { // Create the mask and byte values const XMLByte mask1 = XMLByte(0x1 << (bitToSet % 8)); const unsigned int byteOfs = bitToSet >> 3; // And access the right bit and byte fByteArray[byteOfs] &= ~mask1; fByteArray[byteOfs] |= mask1; } } void zeroBits() { if (fBitCount < 65) { fBits1 = 0; fBits2 = 0; } else { for (unsigned int index = 0; index < fByteCount; index++) fByteArray[index] = 0; } } int hashCode() const { if (fBitCount < 65) { return fBits1+ fBits2 * 31; } else { int hash = 0; for (int index = fByteCount - 1; index >= 0; index--) hash = fByteArray[index] + hash * 31; return hash; } } private : // ----------------------------------------------------------------------- // Unimplemented constructors and operators // ----------------------------------------------------------------------- CMStateSet(); // ----------------------------------------------------------------------- // Private data members // // fBitCount // The count of bits that the outside world wants to support, // so its the max bit index plus one. // // fByteCount // If the bit count is > 64, then we use the fByteArray member to // store the bits, and this indicates its size in bytes. Otherwise // its value is meaningless and unset. // // fBits1 // fBits2 // When the bit count is <= 64 (very common), these hold the bits. // Otherwise, the fByteArray member holds htem. // // fByteArray // The array of bytes used when the bit count is > 64. It is // allocated as required. // ----------------------------------------------------------------------- unsigned int fBitCount; unsigned int fByteCount; unsigned int fBits1; unsigned int fBits2; XMLByte* fByteArray; MemoryManager* fMemoryManager; }; XERCES_CPP_NAMESPACE_END #endif
[ "Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57" ]
[ [ [ 1, 323 ] ] ]
bb52f014b8ad2d5b7c5b5ee4ee16e0c98bbac2e9
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/boost/archive/detail/polymorphic_iarchive_impl.hpp
a7a164ce29f152803af404d90b626d8b4cdca7ca
[ "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
6,757
hpp
#ifndef BOOST_ARCHIVE_DETAIL_POLYMORPHIC_IARCHIVE_IMPL_HPP #define BOOST_ARCHIVE_DETAIL_POLYMORPHIC_IARCHIVE_IMPL_HPP // MS compatible compilers support #pragma once #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 // polymorphic_iarchive_impl.hpp // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . // Use, modification and distribution is subject to 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 for updates, documentation, and revision history. #include <cstddef> #include <string> #include <ostream> #include <boost/noncopyable.hpp> #include <boost/cstdint.hpp> #include <boost/config.hpp> #if defined(BOOST_NO_STDC_NAMESPACE) namespace std{ using ::size_t; } // namespace std #endif #include <boost/archive/polymorphic_iarchive.hpp> #include <boost/archive/detail/abi_prefix.hpp> // must be the last header namespace boost { template<class T> class shared_ptr; namespace serialization { class extended_type_info; } // namespace serialization namespace archive { namespace detail{ class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_iserializer; class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_iserializer; template<class ArchiveImplementation> class polymorphic_iarchive_impl : public polymorphic_iarchive, // note: gcc dynamic cross cast fails if the the derivation below is // not public. I think this is a mistake. public /*protected*/ ArchiveImplementation, private boost::noncopyable { private: // these are used by the serialization library. virtual void load_object( void *t, const basic_iserializer & bis ){ ArchiveImplementation::load_object(t, bis); } virtual const basic_pointer_iserializer * load_pointer( void * & t, const basic_pointer_iserializer * bpis_ptr, const basic_pointer_iserializer * (*finder)( const boost::serialization::extended_type_info & type ) ){ return ArchiveImplementation::load_pointer(t, bpis_ptr, finder); } virtual void set_library_version(unsigned int archive_library_version){ ArchiveImplementation::set_library_version(archive_library_version); } virtual unsigned int get_library_version() const{ return ArchiveImplementation::get_library_version(); } virtual unsigned int get_flags() const { return ArchiveImplementation::get_flags(); } virtual void delete_created_pointers(){ ArchiveImplementation::delete_created_pointers(); } virtual void reset_object_address( const void * new_address, const void * old_address ){ ArchiveImplementation::reset_object_address(new_address, old_address); } virtual void load_binary(void * t, std::size_t size){ ArchiveImplementation::load_binary(t, size); } // primitive types the only ones permitted by polymorphic archives virtual void load(bool & t){ ArchiveImplementation::load(t); } virtual void load(char & t){ ArchiveImplementation::load(t); } virtual void load(signed char & t){ ArchiveImplementation::load(t); } virtual void load(unsigned char & t){ ArchiveImplementation::load(t); } #ifndef BOOST_NO_CWCHAR #ifndef BOOST_NO_INTRINSIC_WCHAR_T virtual void load(wchar_t & t){ ArchiveImplementation::load(t); } #endif #endif virtual void load(short & t){ ArchiveImplementation::load(t); } virtual void load(unsigned short & t){ ArchiveImplementation::load(t); } virtual void load(int & t){ ArchiveImplementation::load(t); } virtual void load(unsigned int & t){ ArchiveImplementation::load(t); } virtual void load(long & t){ ArchiveImplementation::load(t); } virtual void load(unsigned long & t){ ArchiveImplementation::load(t); } #if !defined(BOOST_NO_INTRINSIC_INT64_T) virtual void load(boost::int64_t & t){ ArchiveImplementation::load(t); } virtual void load(boost::uint64_t & t){ ArchiveImplementation::load(t); } #endif virtual void load(float & t){ ArchiveImplementation::load(t); } virtual void load(double & t){ ArchiveImplementation::load(t); } virtual void load(std::string & t){ ArchiveImplementation::load(t); } #ifndef BOOST_NO_STD_WSTRING virtual void load(std::wstring & t){ ArchiveImplementation::load(t); } #endif // used for xml and other tagged formats default does nothing virtual void load_start(const char * name){ ArchiveImplementation::load_start(name); } virtual void load_end(const char * name){ ArchiveImplementation::load_end(name); } virtual void register_basic_serializer(const basic_iserializer & bis){ ArchiveImplementation::register_basic_serializer(bis); } virtual void lookup_basic_helper( const boost::serialization::extended_type_info * const eti, boost::shared_ptr<void> & sph ){ ArchiveImplementation::lookup_basic_helper(eti, sph); } virtual void insert_basic_helper( const boost::serialization::extended_type_info * const eti, boost::shared_ptr<void> & sph ){ ArchiveImplementation::insert_basic_helper(eti, sph); } public: // this can't be inherited because they appear in mulitple // parents typedef mpl::bool_<true> is_loading; typedef mpl::bool_<false> is_saving; // the >> operator template<class T> polymorphic_iarchive & operator>>(T & t){ return polymorphic_iarchive::operator>>(t); } // the & operator template<class T> polymorphic_iarchive & operator&(T & t){ return polymorphic_iarchive::operator&(t); } // all current archives take a stream as constructor argument template <class _Elem, class _Tr> polymorphic_iarchive_impl( std::basic_istream<_Elem, _Tr> & is, unsigned int flags = 0 ) : ArchiveImplementation(is, flags) {} }; } // namespace detail } // namespace archive } // namespace boost #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas #endif // BOOST_ARCHIVE_DETAIL_POLYMORPHIC_IARCHIVE_IMPL_HPP
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 209 ] ] ]
58404be2c095c43bcb850297b308d7266eab95c0
36d0ddb69764f39c440089ecebd10d7df14f75f3
/プログラム/Game/Object/GameScene/StatusScreen.cpp
3d8faec8116fc331e45e4d375ddc7b7fcb0eefdb
[]
no_license
weimingtom/tanuki-mo-issyo
3f57518b4e59f684db642bf064a30fc5cc4715b3
ab57362f3228354179927f58b14fa76b3d334472
refs/heads/master
2021-01-10T01:36:32.162752
2009-04-19T10:37:37
2009-04-19T10:37:37
48,733,344
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
3,964
cpp
/*******************************************************************************/ /** * @file StatusScreen.cpp. * * @brief ステータススクリーンクラスソース定義. * * @date 2008/12/15. * * @version 1.00. * * @author Ryosuke Ogawa. */ /*******************************************************************************/ /*===== インクルード ==========================================================*/ #include "StatusScreen.h" /*=============================================================================*/ /** * @brief コンストラクタ. * * @param[in] device ゲームデバイス. * @param[in] objectManager オブジェクトマネージャ. * @param[in] option ゲームオプション. * @param[in] gameSceneState ゲームシーンステート. */ StatusScreen::StatusScreen(IGameDevice &device, ObjectManager &objectManager, Option &option, GameSceneState &gameSceneState, Player &player) : m_device(device), m_objectManager(objectManager), m_option(option), m_gameSceneState(gameSceneState), m_player(player), m_isTerminated(false), m_skillPoint(device,objectManager,option,gameSceneState, m_player), m_hitPoint(device,objectManager,option,gameSceneState, m_player), m_score(device,objectManager,option,gameSceneState, m_player), m_playerTime(device,objectManager,option,gameSceneState, m_player), m_nextBlock(device, objectManager, option, gameSceneState, m_player), m_characterType(device, objectManager, option, gameSceneState, m_player), m_attack(device, objectManager, option, gameSceneState, m_player), m_defence(device, objectManager, option, gameSceneState, m_player) { } /*=============================================================================*/ /** * @brief デストラクタ. * */ StatusScreen::~StatusScreen() { } /*=============================================================================*/ /** * @brief 初期化処理. * */ void StatusScreen::Initialize() { m_skillPoint.Initialize(); m_hitPoint.Initialize(); m_score.Initialize(); m_playerTime.Initialize(); m_nextBlock.Initialize(); m_characterType.Initialize(); m_attack.Initialize(); m_defence.Initialize(); } /*=============================================================================*/ /** * @brief 終了処理. * */ void StatusScreen::Terminate() { m_skillPoint.Terminate(); m_hitPoint.Terminate(); m_score.Terminate(); m_playerTime.Terminate(); m_nextBlock.Terminate(); m_characterType.Terminate(); m_attack.Terminate(); m_defence.Terminate(); m_isTerminated = true; } /*=============================================================================*/ /** * @brief 終了しているかどうか. * * @return 終了フラグ. */ bool StatusScreen::IsTerminated() { return m_isTerminated; } /*=============================================================================*/ /** * @brief オブジェクトの描画処理. * */ void StatusScreen::RenderObject() { m_skillPoint.RenderObject(); m_hitPoint.RenderObject(); m_score.RenderObject(); m_playerTime.RenderObject(); m_nextBlock.RenderObject(); m_characterType.RenderObject(); m_attack.RenderObject(); m_defence.RenderObject(); } /*=============================================================================*/ /** * @brief オブジェクトの更新処理. * * @param[in] frameTimer 更新タイマ. */ void StatusScreen::UpdateObject(float frameTimer) { m_skillPoint.UpdateObject(frameTimer); m_hitPoint.UpdateObject(frameTimer); m_score.UpdateObject(frameTimer); m_playerTime.UpdateObject(frameTimer); m_nextBlock.UpdateObject(frameTimer); m_characterType.UpdateObject(frameTimer); m_attack.UpdateObject(frameTimer); m_defence.UpdateObject(frameTimer); } /*===== EOF ===================================================================*/
[ "rs.drip@aa49b5b2-a402-11dd-98aa-2b35b7097d33" ]
[ [ [ 1, 136 ] ] ]
7debfcae2132a289cd070a8982ffc67f131aa419
82e5361cc4ac3f14f1a1b0bb5076777f19856e3a
/win32/StdAfx.cpp
10b83af0258bfc6ef34c9a593e250c8511af30fd
[]
no_license
rakusai/buco
7d8a1c96630594b3453183aaba86dc81b4ec9b87
23190751611ccb018abe59d8d3fac1af027a475d
refs/heads/master
2020-04-25T20:36:19.940758
2008-02-07T15:33:05
2008-02-07T15:33:05
2,123,100
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
279
cpp
// stdafx.cpp : 標準インクルードファイルを含むソース ファイル // Buco.pch : 生成されるプリコンパイル済ヘッダー // stdafx.obj : 生成されるプリコンパイル済タイプ情報 #include "stdafx.h"
[ "rakusai@28e12d17-5845-0410-a0b5-dc453db87596" ]
[ [ [ 1, 8 ] ] ]
fb9465cf2cbf6de976b4c56313beff673a5df0ad
d1dc408f6b65c4e5209041b62cd32fb5083fe140
/src/gui/Shape.h
cddebd3dee6f485a5616e8cc4b3da1af234f343f
[]
no_license
dmitrygerasimuk/dune2themaker-fossfriendly
7b4bed2dfb2b42590e4b72bd34bb0f37f6c81e37
89a6920b216f3964241eeab7cf1a631e1e63f110
refs/heads/master
2020-03-12T03:23:40.821001
2011-02-19T12:01:30
2011-02-19T12:01:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
624
h
/* * Rectangle.h * * Created on: 31-okt-2010 * Author: Stefan */ #ifndef SHAPE_H_ #define SHAPE_H_ class Shape { public: Shape(int theX, int theY, int theHeight, int theWidth); Shape(); ~Shape(); void setX(int value) { x = value; } void setY(int value) { y = value; } void setHeight(int value) { height = value; } void setWidth(int value) { width = value; } int getX() { return x; } int getY() { return y; } int getHeight() { return height; } int getWidth() { return width; } protected: private: int x, y, height, width; }; #endif /* SHAPE_H_ */
[ "stefanhen83@52bf4e17-6a1c-0410-83a1-9b5866916151" ]
[ [ [ 1, 33 ] ] ]
c83f24508c49204c1619c31e3f6c4753359c28a8
5ac13fa1746046451f1989b5b8734f40d6445322
/minimangalore/Nebula2/code/mangalore/ui/canvas.cc
d9bd33bd1be938ee729a9bd85da65d93ead8b49e
[]
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
3,999
cc
//------------------------------------------------------------------------------ // ui/canvas.cc // (C) 2005 Radon Labs GmbH //------------------------------------------------------------------------------ #include "ui/canvas.h" #include "ui/server.h" #include "foundation/factory.h" #include "graphics/lightentity.h" #include "kernel/nfileserver2.h" #include "game/time/guitimesource.h" namespace UI { ImplementRtti(UI::Canvas, UI::Element); ImplementFactory(UI::Canvas); //------------------------------------------------------------------------------ /** */ Canvas::Canvas() { // empty } //------------------------------------------------------------------------------ /** */ Canvas::~Canvas() { // empty } //------------------------------------------------------------------------------ /** Recursively finds the first Nebula canvas node in the hierarchy. */ nTransformNode* Canvas::FindCanvasNodeInHierarchy(nTransformNode* root) { n_assert(root); // check if root is a canvas, if yes, break recursion if (root->HasAttr("rlGui")) { // create a new element nString guiType = root->GetStringAttr("rlGuiType"); if ("Canvas" == guiType) { return root; } } // recurse into children nRoot* child; for (child = root->GetHead(); child; child = child->GetSucc()) { if (child->IsA(this->transformNodeClass)) { nTransformNode* result = this->FindCanvasNodeInHierarchy((nTransformNode*)child); if (result) { return result; } } } return 0; } //------------------------------------------------------------------------------ /** This creates a graphics entity representing the visual of the canvas and converts the resource name into a Nebula2 node pointer. */ void Canvas::OnCreate(UI::Element* parent) { // canvases don't have parents n_assert(0 == parent); // create graphics entity, first check if it actually exists... n_assert(this->resourceName.IsValid()); nString resPath; resPath.Format("gfxlib:%s.n2", this->resourceName.Get()); if (nFileServer2::Instance()->FileExists(resPath)) { this->graphicsEntity = Graphics::Entity::Create(); this->graphicsEntity->SetTimeSource(Game::GuiTimeSource::Instance()); this->graphicsEntity->SetResourceName(this->resourceName); this->graphicsEntity->SetRenderFlag(nRenderContext::DoOcclusionQuery, false); this->graphicsEntity->OnActivate(); // find the Nebula node which represents the canvas nTransformNode* rootNode = this->graphicsEntity->GetResource().GetNode(); nTransformNode* canvasNode = this->FindCanvasNodeInHierarchy(rootNode); n_assert(canvasNode); this->SetGfxNode(canvasNode); // establish link between UIServer's light source and new graphics entity Graphics::LightEntity* lightEntity = Server::Instance()->GetLightEntity(); this->graphicsEntity->AddLink(Graphics::Entity::LightLink, lightEntity); lightEntity->AddLink(Graphics::Entity::LightLink, this->graphicsEntity); // create child elements Element::OnCreate(parent); } } //------------------------------------------------------------------------------ /** */ void Canvas::OnDestroy() { if (this->graphicsEntity.isvalid()) { this->graphicsEntity->OnDeactivate(); this->graphicsEntity = 0; } Element::OnDestroy(); } //------------------------------------------------------------------------------ /** */ void Canvas::OnRender() { if (this->IsVisible()) { // first distribute to children Element::OnRender(); // then render our graphics entity this->graphicsEntity->Render(); } } } // namespace UI
[ "BawooiT@d1c0eb94-fc07-11dd-a7be-4b3ef3b0700c" ]
[ [ [ 1, 138 ] ] ]
9f21ca01ac0642474217532db8931bc3523ddc6b
63db2a4036ba87e5da35bca4925464002c3c19d6
/big_exercise/qt/myqt/1-basic_dialog/messageboxs-1.5/messagebox.cpp
55a0b2d8e764d4bd3285ea1c40129d5b9e63eef6
[]
no_license
gicsfree/exercise_aka
6c6ae3ef737e1a3da23001871a3b8c4dea9e7713
d831bc14d719fcd90a06e29d1832c5ea20abb988
refs/heads/master
2022-05-09T11:29:33.265928
2011-09-23T11:48:10
2011-09-23T11:48:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,021
cpp
#include "messagebox.h" #include <QtGui> MessageBox::MessageBox(QWidget *parent) : QDialog(parent) { setWindowTitle(tr("Message Box Example")); label = new QLabel; QPushButton *btn1 = new QPushButton("Question"); QPushButton *btn2 = new QPushButton("Information"); QPushButton *btn3 = new QPushButton("Warning"); QPushButton *btn4 = new QPushButton("Critical"); QPushButton *btn5 = new QPushButton("About"); QPushButton *btn6 = new QPushButton("About Qt"); QPushButton *btn7 = new QPushButton("Custom"); QGridLayout *grid = new QGridLayout; grid->addWidget(btn1,0,0); grid->addWidget(btn2,0,1); grid->addWidget(btn3,1,0); grid->addWidget(btn4,1,1); grid->addWidget(btn5,2,0); grid->addWidget(btn6,2,1); grid->addWidget(btn7,3,0); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->setMargin(10); mainLayout->setSpacing(20); mainLayout->addWidget(label); mainLayout->addLayout(grid); setLayout(mainLayout); connect(btn1,SIGNAL(clicked()),this,SLOT(slotQuestion())); connect(btn2,SIGNAL(clicked()),this,SLOT(slotInformation())); connect(btn3,SIGNAL(clicked()),this,SLOT(slotWarning())); connect(btn4,SIGNAL(clicked()),this,SLOT(slotCritical())); connect(btn5,SIGNAL(clicked()),this,SLOT(slotAbout())); connect(btn6,SIGNAL(clicked()),this,SLOT(slotAboutQt())); connect(btn7,SIGNAL(clicked()),this,SLOT(slotCustom())); } void MessageBox::slotQuestion() { switch(QMessageBox::question(this,"Question",tr("It's end of document,search from begin?"), QMessageBox::Ok|QMessageBox::Cancel,QMessageBox::Ok)) { case QMessageBox::Ok: label->setText(" Question button / Ok "); break; case QMessageBox::Cancel: label->setText(" Question button / Cancel "); break; default: break; } return; } void MessageBox::slotInformation() { QMessageBox::information(this,"Information",tr("anything you want tell user")); return; } void MessageBox::slotWarning() { switch(QMessageBox::warning(this,"Warning",tr("Save changes to document?"), QMessageBox::Save|QMessageBox::Discard|QMessageBox::Cancel,QMessageBox::Save)) { case QMessageBox::Save: label->setText(" Warning button / Save "); break; case QMessageBox::Discard: label->setText(" Warning button / Discard "); break; case QMessageBox::Cancel: label->setText(" Warning button / Cancel "); break; default: break; } return; } void MessageBox::slotCritical() { QMessageBox::critical(this,"Critical",tr("tell user a critical error")); label->setText(" Critical MessageBox "); return; } void MessageBox::slotAbout() { QMessageBox::about(this,"About",tr("Message box example!")); label->setText(" About MessageBox "); return; } void MessageBox::slotAboutQt() { QMessageBox::aboutQt(this,"About Qt"); label->setText(" About Qt MessageBox "); return; } void MessageBox::slotCustom() { QMessageBox customMsgBox; customMsgBox.setWindowTitle("Custom message box"); QPushButton *lockButton = customMsgBox.addButton(tr("Lock"),QMessageBox::ActionRole); QPushButton *unlockButton = customMsgBox.addButton(tr("Unlock"),QMessageBox::ActionRole); QPushButton *cancelButton = customMsgBox.addButton(QMessageBox::Cancel); customMsgBox.setIconPixmap(QPixmap("./images/linuxredhat.png")); customMsgBox.setText(tr("This is a custom message box")); customMsgBox.exec(); if(customMsgBox.clickedButton() == lockButton) label->setText(" Custom MessageBox / Lock "); if(customMsgBox.clickedButton() == unlockButton) label->setText(" Custom MessageBox / Unlock "); if(customMsgBox.clickedButton() == cancelButton) label->setText(" Custom MessageBox / Cancel "); return; }
[ [ [ 1, 130 ] ] ]
152a672a4cb64d629a872b8cf23564ae1b0f232c
1b2eb18a7d77e160bf992f952767198fe00fe10e
/trunk/096/pkg/OLD/skills/musicianship/include/bardSkill.inc
1d26845be0ebfe6bf4cbccba6c291967e2daaa48
[]
no_license
BackupTheBerlios/poldistro-svn
96fd832f9a7479bdc4d00501af45a14a3c571c0f
251f022debb3e4d4ff3c9c43f3bf1029f15e47b1
refs/heads/master
2020-05-18T14:11:44.348758
2006-05-20T16:06:44
2006-05-20T16:06:44
40,800,663
1
0
null
null
null
null
UTF-8
C++
false
false
1,415
inc
// $Id: bardSkill.inc 834 2005-11-02 14:09:50Z austin $ /* * bardSkillCheck(character, instrument, attribute, difficulty) * * Purpose * Checks skill success/failure and plays appropriate sounds * based on SkillCheck() function. Performs a Client Version * check for playing a more broad selection of sounds if the * client supports them. * * Parameters * character: Mobile reference of player using bard skill. * instrument: Instrument character is using for barding. * attribute: Attribute of the skill that is being used. * difficulty: Diffuculty to pass to SkillCheck() function. * * Return value * Returns an integer. 1 on success, 0 on failure. * */ function bardSkillCheck( character, instrument, bard_skill, bard_difficulty, award_diff:=0, advance_flags:=3) // Gets a dictionary for success/fail. var soundCheck := bardSoundCheck(character, instrument, bard_skill); SkillCheck(character, MUSICIANSHIP, 1); if( (AP_GetSkill(character, MUSICIANSHIP) < 10) && (bard_skill != MUSICIANSHIP) ) SendSysMessage(character, "You are not skilled enough in the musical arts."); return 0; endif if(SkillCheck(character, bard_skill, bard_difficulty, award_diff, advance_flags) > 0 ) PlaySoundEffect( character, soundCheck.success ); return 1; else PlaySoundEffect( character, soundCheck.fail ); return 0; endif return 0; endfunction
[ "austin@9d346cd0-66fc-0310-bdc5-e57197e5a75e" ]
[ [ [ 1, 43 ] ] ]
d65a99941b57f64146f40b343ee43ac194f2d638
bf278d024957a59c6f1efb36aa8b76069eff22a5
/setting.cpp
228946b5fdacf360ffe1e68a35cec5c8088cc6b8
[ "BSD-3-Clause", "BSL-1.0" ]
permissive
byplayer/yamy
b84741fe738f5abac33edb934951ea91454fb4ca
031e57e81caeb881a0a219e2a11429795a59d845
refs/heads/master
2020-05-22T12:46:55.516053
2010-05-19T15:57:38
2010-05-19T15:57:38
3,842,546
6
0
null
null
null
null
UTF-8
C++
false
false
45,302
cpp
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // setting.cpp #include "misc.h" #include "dlgsetting.h" #include "errormessage.h" #include "mayu.h" #include "mayurc.h" #include "registry.h" #include "setting.h" #include "windowstool.h" #include "vkeytable.h" #include "array.h" #include <algorithm> #include <fstream> #include <iomanip> #include <sys/stat.h> namespace Event { Key prefixed(_T("prefixed")); Key before_key_down(_T("before-key-down")); Key after_key_up(_T("after-key-up")); Key *events[] = { &prefixed, &before_key_down, &after_key_up, NULL, }; } // get mayu filename static bool getFilenameFromRegistry( tstringi *o_name, tstringi *o_filename, Setting::Symbols *o_symbols) { Registry reg(MAYU_REGISTRY_ROOT); int index; reg.read(_T(".mayuIndex"), &index, 0); _TCHAR buf[100]; _sntprintf(buf, NUMBER_OF(buf), _T(".mayu%d"), index); tstringi entry; if (!reg.read(buf, &entry)) return false; tregex getFilename(_T("^([^;]*);([^;]*);(.*)$")); tsmatch getFilenameResult; if (!boost::regex_match(entry, getFilenameResult, getFilename)) return false; if (o_name) *o_name = getFilenameResult.str(1); if (o_filename) *o_filename = getFilenameResult.str(2); if (o_symbols) { tstringi symbols = getFilenameResult.str(3); tregex symbol(_T("-D([^;]*)(.*)$")); tsmatch symbolResult; while (boost::regex_search(symbols, symbolResult, symbol)) { o_symbols->insert(symbolResult.str(1)); symbols = symbolResult.str(2); } } return true; } // get home directory path void getHomeDirectories(HomeDirectories *o_pathes) { tstringi filename; #ifndef USE_INI if (getFilenameFromRegistry(NULL, &filename, NULL) && !filename.empty()) { tregex getPath(_T("^(.*[/\\\\])[^/\\\\]*$")); tsmatch getPathResult; if (boost::regex_match(filename, getPathResult, getPath)) o_pathes->push_back(getPathResult.str(1)); } const _TCHAR *home = _tgetenv(_T("HOME")); if (home) o_pathes->push_back(home); const _TCHAR *homedrive = _tgetenv(_T("HOMEDRIVE")); const _TCHAR *homepath = _tgetenv(_T("HOMEPATH")); if (homedrive && homepath) o_pathes->push_back(tstringi(homedrive) + homepath); const _TCHAR *userprofile = _tgetenv(_T("USERPROFILE")); if (userprofile) o_pathes->push_back(userprofile); _TCHAR buf[GANA_MAX_PATH]; DWORD len = GetCurrentDirectory(NUMBER_OF(buf), buf); if (0 < len && len < NUMBER_OF(buf)) o_pathes->push_back(buf); #else //USE_INI _TCHAR buf[GANA_MAX_PATH]; #endif //USE_INI if (GetModuleFileName(GetModuleHandle(NULL), buf, NUMBER_OF(buf))) o_pathes->push_back(pathRemoveFileSpec(buf)); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // SettingLoader // is there no more tokens ? bool SettingLoader::isEOL() { return m_ti == m_tokens.end(); } // get next token Token *SettingLoader::getToken() { if (isEOL()) throw ErrorMessage() << _T("too few words."); return &*(m_ti ++); } // look next token Token *SettingLoader::lookToken() { if (isEOL()) throw ErrorMessage() << _T("too few words."); return &*m_ti; } // argument "(" bool SettingLoader::getOpenParen(bool i_doesThrow, const _TCHAR *i_name) { if (!isEOL() && lookToken()->isOpenParen()) { getToken(); return true; } if (i_doesThrow) throw ErrorMessage() << _T("there must be `(' after `&") << i_name << _T("'."); return false; } // argument ")" bool SettingLoader::getCloseParen(bool i_doesThrow, const _TCHAR *i_name) { if (!isEOL() && lookToken()->isCloseParen()) { getToken(); return true; } if (i_doesThrow) throw ErrorMessage() << _T("`&") << i_name << _T("': too many arguments."); return false; } // argument "," bool SettingLoader::getComma(bool i_doesThrow, const _TCHAR *i_name) { if (!isEOL() && lookToken()->isComma()) { getToken(); return true; } if (i_doesThrow) throw ErrorMessage() << _T("`&") << i_name << _T("': comma expected."); return false; } // <INCLUDE> void SettingLoader::load_INCLUDE() { SettingLoader loader(m_soLog, m_log); loader.m_defaultAssignModifier = m_defaultAssignModifier; loader.m_defaultKeySeqModifier = m_defaultKeySeqModifier; if (!loader.load(m_setting, (*getToken()).getString())) m_isThereAnyError = true; } // <SCAN_CODES> void SettingLoader::load_SCAN_CODES(Key *o_key) { for (int j = 0; j < Key::MAX_SCAN_CODES_SIZE && !isEOL(); ++ j) { ScanCode sc; sc.m_flags = 0; while (true) { Token *t = getToken(); if (t->isNumber()) { sc.m_scan = (u_char)t->getNumber(); o_key->addScanCode(sc); break; } if (*t == _T("E0-")) sc.m_flags |= ScanCode::E0; else if (*t == _T("E1-")) sc.m_flags |= ScanCode::E1; else throw ErrorMessage() << _T("`") << *t << _T("': invalid modifier."); } } } // <DEFINE_KEY> void SettingLoader::load_DEFINE_KEY() { Token *t = getToken(); Key key; // <KEY_NAMES> if (*t == _T('(')) { key.addName(getToken()->getString()); while (t = getToken(), *t != _T(')')) key.addName(t->getString()); if (*getToken() != _T("=")) throw ErrorMessage() << _T("there must be `=' after `)'."); } else { key.addName(t->getString()); while (t = getToken(), *t != _T("=")) key.addName(t->getString()); } load_SCAN_CODES(&key); m_setting->m_keyboard.addKey(key); } // <DEFINE_MODIFIER> void SettingLoader::load_DEFINE_MODIFIER() { Token *t = getToken(); Modifier::Type mt; if (*t == _T("shift") ) mt = Modifier::Type_Shift; else if (*t == _T("alt") || *t == _T("meta") || *t == _T("menu") ) mt = Modifier::Type_Alt; else if (*t == _T("control") || *t == _T("ctrl") ) mt = Modifier::Type_Control; else if (*t == _T("windows") || *t == _T("win") ) mt = Modifier::Type_Windows; else throw ErrorMessage() << _T("`") << *t << _T("': invalid modifier name."); if (*getToken() != _T("=")) throw ErrorMessage() << _T("there must be `=' after modifier name."); while (!isEOL()) { t = getToken(); Key *key = m_setting->m_keyboard.searchKeyByNonAliasName(t->getString()); if (!key) throw ErrorMessage() << _T("`") << *t << _T("': invalid key name."); m_setting->m_keyboard.addModifier(mt, key); } } // <DEFINE_SYNC_KEY> void SettingLoader::load_DEFINE_SYNC_KEY() { Key *key = m_setting->m_keyboard.getSyncKey(); key->initialize(); key->addName(_T("sync")); if (*getToken() != _T("=")) throw ErrorMessage() << _T("there must be `=' after `sync'."); load_SCAN_CODES(key); } // <DEFINE_ALIAS> void SettingLoader::load_DEFINE_ALIAS() { Token *name = getToken(); if (*getToken() != _T("=")) throw ErrorMessage() << _T("there must be `=' after `alias'."); Token *t = getToken(); Key *key = m_setting->m_keyboard.searchKeyByNonAliasName(t->getString()); if (!key) throw ErrorMessage() << _T("`") << *t << _T("': invalid key name."); m_setting->m_keyboard.addAlias(name->getString(), key); } // <DEFINE_SUBSTITUTE> void SettingLoader::load_DEFINE_SUBSTITUTE() { typedef std::list<ModifiedKey> AssignedKeys; AssignedKeys assignedKeys; do { ModifiedKey mkey; mkey.m_modifier = load_MODIFIER(Modifier::Type_ASSIGN, m_defaultAssignModifier); mkey.m_key = load_KEY_NAME(); assignedKeys.push_back(mkey); } while (!(*lookToken() == _T("=>") || *lookToken() == _T("="))); getToken(); KeySeq *keySeq = load_KEY_SEQUENCE(_T(""), false, Modifier::Type_ASSIGN); ModifiedKey mkey = keySeq->getFirstModifiedKey(); if (!mkey.m_key) throw ErrorMessage() << _T("no key is specified for substitute."); for (AssignedKeys::iterator i = assignedKeys.begin(); i != assignedKeys.end(); ++ i) m_setting->m_keyboard.addSubstitute(*i, mkey); } // <DEFINE_OPTION> void SettingLoader::load_DEFINE_OPTION() { Token *t = getToken(); if (*t == _T("KL-")) { if (*getToken() != _T("=")) { throw ErrorMessage() << _T("there must be `=' after `def option KL-'."); } load_ARGUMENT(&m_setting->m_correctKanaLockHandling); } else if (*t == _T("delay-of")) { if (*getToken() != _T("!!!")) { throw ErrorMessage() << _T("there must be `!!!' after `def option delay-of'."); } if (*getToken() != _T("=")) { throw ErrorMessage() << _T("there must be `=' after `def option delay-of !!!'."); } load_ARGUMENT(&m_setting->m_oneShotRepeatableDelay); } else if (*t == _T("sts4mayu")) { if (*getToken() != _T("=")) { throw ErrorMessage() << _T("there must be `=' after `def option sts4mayu'."); } load_ARGUMENT(&m_setting->m_sts4mayu); } else if (*t == _T("cts4mayu")) { if (*getToken() != _T("=")) { throw ErrorMessage() << _T("there must be `=' after `def option cts4mayu'."); } load_ARGUMENT(&m_setting->m_cts4mayu); } else if (*t == _T("mouse-event")) { if (*getToken() != _T("=")) { throw ErrorMessage() << _T("there must be `=' after `def option mouse-event'."); } load_ARGUMENT(&m_setting->m_mouseEvent); } else if (*t == _T("drag-threshold")) { if (*getToken() != _T("=")) { throw ErrorMessage() << _T("there must be `=' after `def option drag-threshold'."); } load_ARGUMENT(&m_setting->m_dragThreshold); } else { throw ErrorMessage() << _T("syntax error `def option ") << *t << _T("'."); } } // <KEYBOARD_DEFINITION> void SettingLoader::load_KEYBOARD_DEFINITION() { Token *t = getToken(); // <DEFINE_KEY> if (*t == _T("key")) load_DEFINE_KEY(); // <DEFINE_MODIFIER> else if (*t == _T("mod")) load_DEFINE_MODIFIER(); // <DEFINE_SYNC_KEY> else if (*t == _T("sync")) load_DEFINE_SYNC_KEY(); // <DEFINE_ALIAS> else if (*t == _T("alias")) load_DEFINE_ALIAS(); // <DEFINE_SUBSTITUTE> else if (*t == _T("subst")) load_DEFINE_SUBSTITUTE(); // <DEFINE_OPTION> else if (*t == _T("option")) load_DEFINE_OPTION(); // else throw ErrorMessage() << _T("syntax error `") << *t << _T("'."); } // <..._MODIFIER> Modifier SettingLoader::load_MODIFIER( Modifier::Type i_mode, Modifier i_modifier, Modifier::Type *o_mode) { if (o_mode) *o_mode = Modifier::Type_begin; Modifier isModifierSpecified; enum { PRESS, RELEASE, DONTCARE } flag = PRESS; int i; for (i = i_mode; i < Modifier::Type_ASSIGN; ++ i) { i_modifier.dontcare(Modifier::Type(i)); isModifierSpecified.on(Modifier::Type(i)); } Token *t = NULL; continue_loop: while (!isEOL()) { t = lookToken(); const static struct { const _TCHAR *m_s; Modifier::Type m_mt; } map[] = { // <BASIC_MODIFIER> { _T("S-"), Modifier::Type_Shift }, { _T("A-"), Modifier::Type_Alt }, { _T("M-"), Modifier::Type_Alt }, { _T("C-"), Modifier::Type_Control }, { _T("W-"), Modifier::Type_Windows }, // <KEYSEQ_MODIFIER> { _T("U-"), Modifier::Type_Up }, { _T("D-"), Modifier::Type_Down }, // <ASSIGN_MODIFIER> { _T("R-"), Modifier::Type_Repeat }, { _T("IL-"), Modifier::Type_ImeLock }, { _T("IC-"), Modifier::Type_ImeComp }, { _T("I-"), Modifier::Type_ImeComp }, { _T("NL-"), Modifier::Type_NumLock }, { _T("CL-"), Modifier::Type_CapsLock }, { _T("SL-"), Modifier::Type_ScrollLock }, { _T("KL-"), Modifier::Type_KanaLock }, { _T("MAX-"), Modifier::Type_Maximized }, { _T("MIN-"), Modifier::Type_Minimized }, { _T("MMAX-"), Modifier::Type_MdiMaximized }, { _T("MMIN-"), Modifier::Type_MdiMinimized }, { _T("T-"), Modifier::Type_Touchpad }, { _T("TS-"), Modifier::Type_TouchpadSticky }, { _T("M0-"), Modifier::Type_Mod0 }, { _T("M1-"), Modifier::Type_Mod1 }, { _T("M2-"), Modifier::Type_Mod2 }, { _T("M3-"), Modifier::Type_Mod3 }, { _T("M4-"), Modifier::Type_Mod4 }, { _T("M5-"), Modifier::Type_Mod5 }, { _T("M6-"), Modifier::Type_Mod6 }, { _T("M7-"), Modifier::Type_Mod7 }, { _T("M8-"), Modifier::Type_Mod8 }, { _T("M9-"), Modifier::Type_Mod9 }, { _T("L0-"), Modifier::Type_Lock0 }, { _T("L1-"), Modifier::Type_Lock1 }, { _T("L2-"), Modifier::Type_Lock2 }, { _T("L3-"), Modifier::Type_Lock3 }, { _T("L4-"), Modifier::Type_Lock4 }, { _T("L5-"), Modifier::Type_Lock5 }, { _T("L6-"), Modifier::Type_Lock6 }, { _T("L7-"), Modifier::Type_Lock7 }, { _T("L8-"), Modifier::Type_Lock8 }, { _T("L9-"), Modifier::Type_Lock9 }, }; for (int i = 0; i < NUMBER_OF(map); ++ i) if (*t == map[i].m_s) { getToken(); Modifier::Type mt = map[i].m_mt; if (static_cast<int>(i_mode) <= static_cast<int>(mt)) throw ErrorMessage() << _T("`") << *t << _T("': invalid modifier at this context."); switch (flag) { case PRESS: i_modifier.press(mt); break; case RELEASE: i_modifier.release(mt); break; case DONTCARE: i_modifier.dontcare(mt); break; } isModifierSpecified.on(mt); flag = PRESS; if (o_mode && *o_mode < mt) { if (mt < Modifier::Type_BASIC) *o_mode = Modifier::Type_BASIC; else if (mt < Modifier::Type_KEYSEQ) *o_mode = Modifier::Type_KEYSEQ; else if (mt < Modifier::Type_ASSIGN) *o_mode = Modifier::Type_ASSIGN; } goto continue_loop; } if (*t == _T("*")) { getToken(); flag = DONTCARE; continue; } if (*t == _T("~")) { getToken(); flag = RELEASE; continue; } break; } for (i = Modifier::Type_begin; i != Modifier::Type_end; ++ i) if (!isModifierSpecified.isOn(Modifier::Type(i))) switch (flag) { case PRESS: break; case RELEASE: i_modifier.release(Modifier::Type(i)); break; case DONTCARE: i_modifier.dontcare(Modifier::Type(i)); break; } // fix up and down bool isDontcareUp = i_modifier.isDontcare(Modifier::Type_Up); bool isDontcareDown = i_modifier.isDontcare(Modifier::Type_Down); bool isOnUp = i_modifier.isOn(Modifier::Type_Up); bool isOnDown = i_modifier.isOn(Modifier::Type_Down); if (isDontcareUp && isDontcareDown) ; else if (isDontcareUp) i_modifier.on(Modifier::Type_Up, !isOnDown); else if (isDontcareDown) i_modifier.on(Modifier::Type_Down, !isOnUp); else if (isOnUp == isOnDown) { i_modifier.dontcare(Modifier::Type_Up); i_modifier.dontcare(Modifier::Type_Down); } // fix repeat if (!isModifierSpecified.isOn(Modifier::Type_Repeat)) i_modifier.dontcare(Modifier::Type_Repeat); return i_modifier; } // <KEY_NAME> Key *SettingLoader::load_KEY_NAME() { Token *t = getToken(); Key *key = m_setting->m_keyboard.searchKey(t->getString()); if (!key) throw ErrorMessage() << _T("`") << *t << _T("': invalid key name."); return key; } // <KEYMAP_DEFINITION> void SettingLoader::load_KEYMAP_DEFINITION(const Token *i_which) { Keymap::Type type = Keymap::Type_keymap; Token *name = getToken(); // <KEYMAP_NAME> tstringi windowClassName; tstringi windowTitleName; KeySeq *keySeq = NULL; Keymap *parentKeymap = NULL; bool isKeymap2 = false; bool doesLoadDefaultKeySeq = false; if (!isEOL()) { Token *t = lookToken(); if (*i_which == _T("window")) { // <WINDOW> if (t->isOpenParen()) // "(" <WINDOW_CLASS_NAME> "&&" <WINDOW_TITLE_NAME> ")" // "(" <WINDOW_CLASS_NAME> "||" <WINDOW_TITLE_NAME> ")" { getToken(); windowClassName = getToken()->getRegexp(); t = getToken(); if (*t == _T("&&")) type = Keymap::Type_windowAnd; else if (*t == _T("||")) type = Keymap::Type_windowOr; else throw ErrorMessage() << _T("`") << *t << _T("': unknown operator."); windowTitleName = getToken()->getRegexp(); if (!getToken()->isCloseParen()) throw ErrorMessage() << _T("there must be `)'."); } else if (t->isRegexp()) { // <WINDOW_CLASS_NAME> getToken(); type = Keymap::Type_windowAnd; windowClassName = t->getRegexp(); } } else if (*i_which == _T("keymap")) ; else if (*i_which == _T("keymap2")) isKeymap2 = true; else ASSERT(false); if (!isEOL()) doesLoadDefaultKeySeq = true; } m_currentKeymap = m_setting->m_keymaps.add( Keymap(type, name->getString(), windowClassName, windowTitleName, NULL, NULL)); if (doesLoadDefaultKeySeq) { Token *t = lookToken(); // <KEYMAP_PARENT> if (*t == _T(":")) { getToken(); t = getToken(); parentKeymap = m_setting->m_keymaps.searchByName(t->getString()); if (!parentKeymap) throw ErrorMessage() << _T("`") << *t << _T("': unknown keymap name."); } if (!isEOL()) { t = getToken(); if (!(*t == _T("=>") || *t == _T("="))) throw ErrorMessage() << _T("`") << *t << _T("': syntax error."); keySeq = SettingLoader::load_KEY_SEQUENCE(); } } if (keySeq == NULL) { FunctionData *fd; if (type == Keymap::Type_keymap && !isKeymap2) fd = createFunctionData(_T("KeymapParent")); else if (type == Keymap::Type_keymap && !isKeymap2) fd = createFunctionData(_T("Undefined")); else // (type == Keymap::Type_windowAnd || type == Keymap::Type_windowOr) fd = createFunctionData(_T("KeymapParent")); ASSERT( fd ); keySeq = m_setting->m_keySeqs.add( KeySeq(name->getString()).add(ActionFunction(fd))); } m_currentKeymap->setIfNotYet(keySeq, parentKeymap); } // &lt;ARGUMENT&gt; void SettingLoader::load_ARGUMENT(bool *o_arg) { *o_arg = !(*getToken() == _T("false")); } // &lt;ARGUMENT&gt; void SettingLoader::load_ARGUMENT(int *o_arg) { *o_arg = getToken()->getNumber(); } // &lt;ARGUMENT&gt; void SettingLoader::load_ARGUMENT(unsigned int *o_arg) { *o_arg = getToken()->getNumber(); } // &lt;ARGUMENT&gt; void SettingLoader::load_ARGUMENT(long *o_arg) { *o_arg = getToken()->getNumber(); } // &lt;ARGUMENT&gt; void SettingLoader::load_ARGUMENT(unsigned __int64 *o_arg) { *o_arg = getToken()->getNumber(); } // &lt;ARGUMENT&gt; void SettingLoader::load_ARGUMENT(__int64 *o_arg) { *o_arg = getToken()->getNumber(); } // &lt;ARGUMENT&gt; void SettingLoader::load_ARGUMENT(tstringq *o_arg) { *o_arg = getToken()->getString(); } // &lt;ARGUMENT&gt; void SettingLoader::load_ARGUMENT(std::list<tstringq> *o_arg) { while (true) { if (!lookToken()->isString()) return; o_arg->push_back(getToken()->getString()); if (!lookToken()->isComma()) return; getToken(); } } // &lt;ARGUMENT&gt; void SettingLoader::load_ARGUMENT(tregex *o_arg) { *o_arg = getToken()->getRegexp(); } // &lt;ARGUMENT_VK&gt; void SettingLoader::load_ARGUMENT(VKey *o_arg) { Token *t = getToken(); int vkey = 0; while (true) { if (t->isNumber()) { vkey |= static_cast<BYTE>(t->getNumber()); break; } else if (*t == _T("E-")) vkey |= VKey_extended; else if (*t == _T("U-")) vkey |= VKey_released; else if (*t == _T("D-")) vkey |= VKey_pressed; else { const VKeyTable *vkt; for (vkt = g_vkeyTable; vkt->m_name; ++ vkt) if (*t == vkt->m_name) break; if (!vkt->m_name) throw ErrorMessage() << _T("`") << *t << _T("': unknown virtual key name."); vkey |= vkt->m_code; break; } t = getToken(); } if (!(vkey & VKey_released) && !(vkey & VKey_pressed)) vkey |= VKey_released | VKey_pressed; *o_arg = static_cast<VKey>(vkey); } // &lt;ARGUMENT_WINDOW&gt; void SettingLoader::load_ARGUMENT(ToWindowType *o_arg) { Token *t = getToken(); if (t->isNumber()) { if (ToWindowType_toBegin <= t->getNumber()) { *o_arg = static_cast<ToWindowType>(t->getNumber()); return; } } else if (getTypeValue(o_arg, t->getString())) return; throw ErrorMessage() << _T("`") << *t << _T("': invalid target window."); } // &lt;ARGUMENT&gt; void SettingLoader::load_ARGUMENT(GravityType *o_arg) { Token *t = getToken(); if (getTypeValue(o_arg, t->getString())) return; throw ErrorMessage() << _T("`") << *t << _T("': unknown gravity symbol."); } // &lt;ARGUMENT&gt; void SettingLoader::load_ARGUMENT(MouseHookType *o_arg) { Token *t = getToken(); if (getTypeValue(o_arg, t->getString())) return; throw ErrorMessage() << _T("`") << *t << _T("': unknown MouseHookType symbol."); } // &lt;ARGUMENT&gt; void SettingLoader::load_ARGUMENT(MayuDialogType *o_arg) { Token *t = getToken(); if (getTypeValue(o_arg, t->getString())) return; throw ErrorMessage() << _T("`") << *t << _T("': unknown dialog box."); } // &lt;ARGUMENT_LOCK&gt; void SettingLoader::load_ARGUMENT(ModifierLockType *o_arg) { Token *t = getToken(); if (getTypeValue(o_arg, t->getString())) return; throw ErrorMessage() << _T("`") << *t << _T("': unknown lock name."); } // &lt;ARGUMENT_LOCK&gt; void SettingLoader::load_ARGUMENT(ToggleType *o_arg) { Token *t = getToken(); if (getTypeValue(o_arg, t->getString())) return; throw ErrorMessage() << _T("`") << *t << _T("': unknown toggle name."); } // &lt;ARGUMENT_SHOW_WINDOW&gt; void SettingLoader::load_ARGUMENT(ShowCommandType *o_arg) { Token *t = getToken(); if (getTypeValue(o_arg, t->getString())) return; throw ErrorMessage() << _T("`") << *t << _T("': unknown show command."); } // &lt;ARGUMENT_TARGET_WINDOW&gt; void SettingLoader::load_ARGUMENT(TargetWindowType *o_arg) { Token *t = getToken(); if (getTypeValue(o_arg, t->getString())) return; throw ErrorMessage() << _T("`") << *t << _T("': unknown target window type."); } // &lt;bool&gt; void SettingLoader::load_ARGUMENT(BooleanType *o_arg) { Token *t = getToken(); if (getTypeValue(o_arg, t->getString())) return; throw ErrorMessage() << _T("`") << *t << _T("': must be true or false."); } // &lt;ARGUMENT&gt; void SettingLoader::load_ARGUMENT(LogicalOperatorType *o_arg) { Token *t = getToken(); if (getTypeValue(o_arg, t->getString())) return; throw ErrorMessage() << _T("`") << *t << _T("': must be 'or' or 'and'."); } // &lt;ARGUMENT&gt; void SettingLoader::load_ARGUMENT(Modifier *o_arg) { Modifier modifier; for (int i = Modifier::Type_begin; i != Modifier::Type_end; ++ i) modifier.dontcare(static_cast<Modifier::Type>(i)); *o_arg = load_MODIFIER(Modifier::Type_ASSIGN, modifier); } // &lt;ARGUMENT&gt; void SettingLoader::load_ARGUMENT(const Keymap **o_arg) { Token *t = getToken(); const Keymap *&keymap = *o_arg; keymap = m_setting->m_keymaps.searchByName(t->getString()); if (!keymap) throw ErrorMessage() << _T("`") << *t << _T("': unknown keymap name."); } // &lt;ARGUMENT&gt; void SettingLoader::load_ARGUMENT(const KeySeq **o_arg) { Token *t = getToken(); const KeySeq *&keySeq = *o_arg; if (t->isOpenParen()) { keySeq = load_KEY_SEQUENCE(_T(""), true); getToken(); // close paren } else if (*t == _T("$")) { t = getToken(); keySeq = m_setting->m_keySeqs.searchByName(t->getString()); if (!keySeq) throw ErrorMessage() << _T("`$") << *t << _T("': unknown keyseq name."); } else throw ErrorMessage() << _T("`") << *t << _T("': it is not keyseq."); } // &lt;ARGUMENT&gt; void SettingLoader::load_ARGUMENT(StrExprArg *o_arg) { Token *t = getToken(); StrExprArg::Type type = StrExprArg::Literal; if (*t == _T("$") && t->isQuoted() == false && lookToken()->getType() == Token::Type_string) { type = StrExprArg::Builtin; t = getToken(); } *o_arg = StrExprArg(t->getString(), type); } // &lt;ARGUMENT&gt; void SettingLoader::load_ARGUMENT(WindowMonitorFromType *o_arg) { Token *t = getToken(); if (getTypeValue(o_arg, t->getString())) return; throw ErrorMessage() << _T("`") << *t << _T("': unknown monitor from type."); } // <KEY_SEQUENCE> KeySeq *SettingLoader::load_KEY_SEQUENCE( const tstringi &i_name, bool i_isInParen, Modifier::Type i_mode) { KeySeq keySeq(i_name); while (!isEOL()) { Modifier::Type mode; Modifier modifier = load_MODIFIER(i_mode, m_defaultKeySeqModifier, &mode); keySeq.setMode(mode); Token *t = lookToken(); if (t->isCloseParen() && i_isInParen) break; else if (t->isOpenParen()) { getToken(); // open paren KeySeq *ks = load_KEY_SEQUENCE(_T(""), true, i_mode); getToken(); // close paren keySeq.add(ActionKeySeq(ks)); } else if (*t == _T("$")) { // <KEYSEQ_NAME> getToken(); t = getToken(); KeySeq *ks = m_setting->m_keySeqs.searchByName(t->getString()); if (ks == NULL) throw ErrorMessage() << _T("`$") << *t << _T("': unknown keyseq name."); if (!ks->isCorrectMode(i_mode)) throw ErrorMessage() << _T("`$") << *t << _T("': Some of R-, IL-, IC-, NL-, CL-, SL-, KL-, MAX-, MIN-, MMAX-, MMIN-, T-, TS-, M0...M9- and L0...L9- are used in the keyseq. They are prohibited in this context."); keySeq.setMode(ks->getMode()); keySeq.add(ActionKeySeq(ks)); } else if (*t == _T("&")) { // <FUNCTION_NAME> getToken(); t = getToken(); // search function ActionFunction af(createFunctionData(t->getString()), modifier); if (af.m_functionData == NULL) throw ErrorMessage() << _T("`&") << *t << _T("': unknown function name."); af.m_functionData->load(this); keySeq.add(af); } else { // <KEYSEQ_MODIFIED_KEY_NAME> ModifiedKey mkey; mkey.m_modifier = modifier; mkey.m_key = load_KEY_NAME(); keySeq.add(ActionKey(mkey)); } } return m_setting->m_keySeqs.add(keySeq); } // <KEY_ASSIGN> void SettingLoader::load_KEY_ASSIGN() { typedef std::list<ModifiedKey> AssignedKeys; AssignedKeys assignedKeys; ModifiedKey mkey; mkey.m_modifier = load_MODIFIER(Modifier::Type_ASSIGN, m_defaultAssignModifier); if (*lookToken() == _T("=")) { getToken(); m_defaultKeySeqModifier = load_MODIFIER(Modifier::Type_KEYSEQ, m_defaultKeySeqModifier); m_defaultAssignModifier = mkey.m_modifier; return; } while (true) { mkey.m_key = load_KEY_NAME(); assignedKeys.push_back(mkey); if (*lookToken() == _T("=>") || *lookToken() == _T("=")) break; mkey.m_modifier = load_MODIFIER(Modifier::Type_ASSIGN, m_defaultAssignModifier); } getToken(); ASSERT(m_currentKeymap); KeySeq *keySeq = load_KEY_SEQUENCE(); for (AssignedKeys::iterator i = assignedKeys.begin(); i != assignedKeys.end(); ++ i) m_currentKeymap->addAssignment(*i, keySeq); } // <EVENT_ASSIGN> void SettingLoader::load_EVENT_ASSIGN() { std::list<ModifiedKey> assignedKeys; ModifiedKey mkey; mkey.m_modifier.dontcare(); //set all modifiers to dontcare Token *t = getToken(); Key **e; for (e = Event::events; *e; ++ e) if (*t == (*e)->getName()) { mkey.m_key = *e; break; } if (!*e) throw ErrorMessage() << _T("`") << *t << _T("': invalid event name."); t = getToken(); if (!(*t == _T("=>") || *t == _T("="))) throw ErrorMessage() << _T("`=' is expected."); ASSERT(m_currentKeymap); KeySeq *keySeq = load_KEY_SEQUENCE(); m_currentKeymap->addAssignment(mkey, keySeq); } // <MODIFIER_ASSIGNMENT> void SettingLoader::load_MODIFIER_ASSIGNMENT() { // <MODIFIER_NAME> Token *t = getToken(); Modifier::Type mt; while (true) { Keymap::AssignMode am = Keymap::AM_notModifier; if (*t == _T("!") ) am = Keymap::AM_true, t = getToken(); else if (*t == _T("!!") ) am = Keymap::AM_oneShot, t = getToken(); else if (*t == _T("!!!")) am = Keymap::AM_oneShotRepeatable, t = getToken(); if (*t == _T("shift")) mt = Modifier::Type_Shift; else if (*t == _T("alt") || *t == _T("meta") || *t == _T("menu") ) mt = Modifier::Type_Alt; else if (*t == _T("control") || *t == _T("ctrl") ) mt = Modifier::Type_Control; else if (*t == _T("windows") || *t == _T("win") ) mt = Modifier::Type_Windows; else if (*t == _T("mod0") ) mt = Modifier::Type_Mod0; else if (*t == _T("mod1") ) mt = Modifier::Type_Mod1; else if (*t == _T("mod2") ) mt = Modifier::Type_Mod2; else if (*t == _T("mod3") ) mt = Modifier::Type_Mod3; else if (*t == _T("mod4") ) mt = Modifier::Type_Mod4; else if (*t == _T("mod5") ) mt = Modifier::Type_Mod5; else if (*t == _T("mod6") ) mt = Modifier::Type_Mod6; else if (*t == _T("mod7") ) mt = Modifier::Type_Mod7; else if (*t == _T("mod8") ) mt = Modifier::Type_Mod8; else if (*t == _T("mod9") ) mt = Modifier::Type_Mod9; else throw ErrorMessage() << _T("`") << *t << _T("': invalid modifier name."); if (am == Keymap::AM_notModifier) break; m_currentKeymap->addModifier(mt, Keymap::AO_overwrite, am, NULL); if (isEOL()) return; t = getToken(); } // <ASSIGN_OP> t = getToken(); Keymap::AssignOperator ao; if (*t == _T("=") ) ao = Keymap::AO_new; else if (*t == _T("+=")) ao = Keymap::AO_add; else if (*t == _T("-=")) ao = Keymap::AO_sub; else throw ErrorMessage() << _T("`") << *t << _T("': is unknown operator."); // <ASSIGN_MODE>? <KEY_NAME> while (!isEOL()) { // <ASSIGN_MODE>? t = getToken(); Keymap::AssignMode am = Keymap::AM_normal; if (*t == _T("!") ) am = Keymap::AM_true, t = getToken(); else if (*t == _T("!!") ) am = Keymap::AM_oneShot, t = getToken(); else if (*t == _T("!!!")) am = Keymap::AM_oneShotRepeatable, t = getToken(); // <KEY_NAME> Key *key = m_setting->m_keyboard.searchKey(t->getString()); if (!key) throw ErrorMessage() << _T("`") << *t << _T("': invalid key name."); // we can ignore warning C4701 m_currentKeymap->addModifier(mt, ao, am, key); if (ao == Keymap::AO_new) ao = Keymap::AO_add; } } // <KEYSEQ_DEFINITION> void SettingLoader::load_KEYSEQ_DEFINITION() { if (*getToken() != _T("$")) throw ErrorMessage() << _T("there must be `$' after `keyseq'"); Token *name = getToken(); if (*getToken() != _T("=")) throw ErrorMessage() << _T("there must be `=' after keyseq naem"); load_KEY_SEQUENCE(name->getString(), false, Modifier::Type_ASSIGN); } // <DEFINE> void SettingLoader::load_DEFINE() { m_setting->m_symbols.insert(getToken()->getString()); } // <IF> void SettingLoader::load_IF() { if (!getToken()->isOpenParen()) throw ErrorMessage() << _T("there must be `(' after `if'."); Token *t = getToken(); // <SYMBOL> or ! bool not = false; if (*t == _T("!")) { not = true; t = getToken(); // <SYMBOL> } bool doesSymbolExist = (m_setting->m_symbols.find(t->getString()) != m_setting->m_symbols.end()); bool doesRead = ((doesSymbolExist && !not) || (!doesSymbolExist && not)); if (0 < m_canReadStack.size()) doesRead = doesRead && m_canReadStack.back(); if (!getToken()->isCloseParen()) throw ErrorMessage() << _T("there must be `)'."); m_canReadStack.push_back(doesRead); if (!isEOL()) { size_t len = m_canReadStack.size(); load_LINE(); if (len < m_canReadStack.size()) { bool r = m_canReadStack.back(); m_canReadStack.pop_back(); m_canReadStack[len - 1] = r && doesRead; } else if (len == m_canReadStack.size()) m_canReadStack.pop_back(); else ; // `end' found } } // <ELSE> <ELSEIF> void SettingLoader::load_ELSE(bool i_isElseIf, const tstringi &i_token) { bool doesRead = !load_ENDIF(i_token); if (0 < m_canReadStack.size()) doesRead = doesRead && m_canReadStack.back(); m_canReadStack.push_back(doesRead); if (!isEOL()) { size_t len = m_canReadStack.size(); if (i_isElseIf) load_IF(); else load_LINE(); if (len < m_canReadStack.size()) { bool r = m_canReadStack.back(); m_canReadStack.pop_back(); m_canReadStack[len - 1] = doesRead && r; } else if (len == m_canReadStack.size()) m_canReadStack.pop_back(); else ; // `end' found } } // <ENDIF> bool SettingLoader::load_ENDIF(const tstringi &i_token) { if (m_canReadStack.size() == 0) throw ErrorMessage() << _T("unbalanced `") << i_token << _T("'"); bool r = m_canReadStack.back(); m_canReadStack.pop_back(); return r; } // <LINE> void SettingLoader::load_LINE() { Token *i_token = getToken(); // <COND_SYMBOL> if (*i_token == _T("if") || *i_token == _T("and")) load_IF(); else if (*i_token == _T("else")) load_ELSE(false, i_token->getString()); else if (*i_token == _T("elseif") || *i_token == _T("elsif") || *i_token == _T("elif") || *i_token == _T("or")) load_ELSE(true, i_token->getString()); else if (*i_token == _T("endif")) load_ENDIF(_T("endif")); else if (0 < m_canReadStack.size() && !m_canReadStack.back()) { while (!isEOL()) getToken(); } else if (*i_token == _T("define")) load_DEFINE(); // <INCLUDE> else if (*i_token == _T("include")) load_INCLUDE(); // <KEYBOARD_DEFINITION> else if (*i_token == _T("def")) load_KEYBOARD_DEFINITION(); // <KEYMAP_DEFINITION> else if (*i_token == _T("keymap") || *i_token == _T("keymap2") || *i_token == _T("window")) load_KEYMAP_DEFINITION(i_token); // <KEY_ASSIGN> else if (*i_token == _T("key")) load_KEY_ASSIGN(); // <EVENT_ASSIGN> else if (*i_token == _T("event")) load_EVENT_ASSIGN(); // <MODIFIER_ASSIGNMENT> else if (*i_token == _T("mod")) load_MODIFIER_ASSIGNMENT(); // <KEYSEQ_DEFINITION> else if (*i_token == _T("keyseq")) load_KEYSEQ_DEFINITION(); else throw ErrorMessage() << _T("syntax error `") << *i_token << _T("'."); } // prefix sort predicate used in load(const string &) static bool prefixSortPred(const tstringi &i_a, const tstringi &i_b) { return i_b.size() < i_a.size(); } /* _UNICODE: read file (UTF-16 LE/BE, UTF-8, locale specific multibyte encoding) _MBCS: read file */ bool readFile(tstring *o_data, const tstringi &i_filename) { // get size of file #if 0 // bcc's _wstat cannot obtain file size struct _stat sbuf; if (_tstat(i_filename.c_str(), &sbuf) < 0 || sbuf.st_size == 0) return false; #else // so, we use _wstati64 for bcc struct stati64_t sbuf; if (_tstati64(i_filename.c_str(), &sbuf) < 0 || sbuf.st_size == 0) return false; // following check is needed to cast sbuf.st_size to size_t safely // this cast occurs because of above workaround for bcc if (sbuf.st_size > UINT_MAX) return false; #endif // open FILE *fp = _tfopen(i_filename.c_str(), _T("rb")); if (!fp) return false; // read file Array<BYTE> buf(static_cast<size_t>(sbuf.st_size) + 1); if (fread(buf.get(), static_cast<size_t>(sbuf.st_size), 1, fp) != 1) { fclose(fp); return false; } buf.get()[sbuf.st_size] = 0; // mbstowcs() requires null // terminated string #ifdef _UNICODE // if (buf.get()[0] == 0xffU && buf.get()[1] == 0xfeU && sbuf.st_size % 2 == 0) // UTF-16 Little Endien { size_t size = static_cast<size_t>(sbuf.st_size) / 2; o_data->resize(size); BYTE *p = buf.get(); for (size_t i = 0; i < size; ++ i) { wchar_t c = static_cast<wchar_t>(*p ++); c |= static_cast<wchar_t>(*p ++) << 8; (*o_data)[i] = c; } fclose(fp); return true; } // if (buf.get()[0] == 0xfeU && buf.get()[1] == 0xffU && sbuf.st_size % 2 == 0) // UTF-16 Big Endien { size_t size = static_cast<size_t>(sbuf.st_size) / 2; o_data->resize(size); BYTE *p = buf.get(); for (size_t i = 0; i < size; ++ i) { wchar_t c = static_cast<wchar_t>(*p ++) << 8; c |= static_cast<wchar_t>(*p ++); (*o_data)[i] = c; } fclose(fp); return true; } // try multibyte charset size_t wsize = mbstowcs(NULL, reinterpret_cast<char *>(buf.get()), 0); if (wsize != size_t(-1)) { Array<wchar_t> wbuf(wsize); mbstowcs(wbuf.get(), reinterpret_cast<char *>(buf.get()), wsize); o_data->assign(wbuf.get(), wbuf.get() + wsize); fclose(fp); return true; } // try UTF-8 { Array<wchar_t> wbuf(static_cast<size_t>(sbuf.st_size)); BYTE *f = buf.get(); BYTE *end = buf.get() + sbuf.st_size; wchar_t *d = wbuf.get(); enum { STATE_1, STATE_2of2, STATE_2of3, STATE_3of3 } state = STATE_1; while (f != end) { switch (state) { case STATE_1: if (!(*f & 0x80)) // 0xxxxxxx: 00-7F *d++ = static_cast<wchar_t>(*f++); else if ((*f & 0xe0) == 0xc0) { // 110xxxxx 10xxxxxx: 0080-07FF *d = ((static_cast<wchar_t>(*f++) & 0x1f) << 6); state = STATE_2of2; } else if ((*f & 0xf0) == 0xe0) // 1110xxxx 10xxxxxx 10xxxxxx: // 0800 - FFFF { *d = ((static_cast<wchar_t>(*f++) & 0x0f) << 12); state = STATE_2of3; } else goto not_UTF_8; break; case STATE_2of2: case STATE_3of3: if ((*f & 0xc0) != 0x80) goto not_UTF_8; *d++ |= (static_cast<wchar_t>(*f++) & 0x3f); state = STATE_1; break; case STATE_2of3: if ((*f & 0xc0) != 0x80) goto not_UTF_8; *d |= ((static_cast<wchar_t>(*f++) & 0x3f) << 6); state = STATE_3of3; break; } } o_data->assign(wbuf.get(), d); fclose(fp); return true; not_UTF_8: ; } #endif // _UNICODE // assume ascii o_data->resize(static_cast<size_t>(sbuf.st_size)); for (off_t i = 0; i < sbuf.st_size; ++ i) (*o_data)[i] = buf.get()[i]; fclose(fp); return true; } // load (called from load(Setting *, const tstringi &) only) void SettingLoader::load(const tstringi &i_filename) { m_currentFilename = i_filename; tstring data; if (!readFile(&data, m_currentFilename)) { Acquire a(m_soLog); *m_log << m_currentFilename << _T(" : error: file not found") << std::endl; #if 1 *m_log << data << std::endl; #endif m_isThereAnyError = true; return; } // prefix if (m_prefixesRefCcount == 0) { static const _TCHAR *prefixes[] = { _T("="), _T("=>"), _T("&&"), _T("||"), _T(":"), _T("$"), _T("&"), _T("-="), _T("+="), _T("!!!"), _T("!!"), _T("!"), _T("E0-"), _T("E1-"), // <SCAN_CODE_EXTENTION> _T("S-"), _T("A-"), _T("M-"), _T("C-"), // <BASIC_MODIFIER> _T("W-"), _T("*"), _T("~"), _T("U-"), _T("D-"), // <KEYSEQ_MODIFIER> _T("R-"), _T("IL-"), _T("IC-"), _T("I-"), // <ASSIGN_MODIFIER> _T("NL-"), _T("CL-"), _T("SL-"), _T("KL-"), _T("MAX-"), _T("MIN-"), _T("MMAX-"), _T("MMIN-"), _T("T-"), _T("TS-"), _T("M0-"), _T("M1-"), _T("M2-"), _T("M3-"), _T("M4-"), _T("M5-"), _T("M6-"), _T("M7-"), _T("M8-"), _T("M9-"), _T("L0-"), _T("L1-"), _T("L2-"), _T("L3-"), _T("L4-"), _T("L5-"), _T("L6-"), _T("L7-"), _T("L8-"), _T("L9-"), }; m_prefixes = new std::vector<tstringi>; for (size_t i = 0; i < NUMBER_OF(prefixes); ++ i) m_prefixes->push_back(prefixes[i]); std::sort(m_prefixes->begin(), m_prefixes->end(), prefixSortPred); } m_prefixesRefCcount ++; // create parser Parser parser(data.c_str(), data.size()); parser.setPrefixes(m_prefixes); while (true) { try { if (!parser.getLine(&m_tokens)) break; m_ti = m_tokens.begin(); } catch (ErrorMessage &e) { if (m_log && m_soLog) { Acquire a(m_soLog); *m_log << m_currentFilename << _T("(") << parser.getLineNumber() << _T(") : error: ") << e << std::endl; } m_isThereAnyError = true; continue; } try { load_LINE(); if (!isEOL()) throw WarningMessage() << _T("back garbage is ignored."); } catch (WarningMessage &w) { if (m_log && m_soLog) { Acquire a(m_soLog); *m_log << i_filename << _T("(") << parser.getLineNumber() << _T(") : warning: ") << w << std::endl; } } catch (ErrorMessage &e) { if (m_log && m_soLog) { Acquire a(m_soLog); *m_log << i_filename << _T("(") << parser.getLineNumber() << _T(") : error: ") << e << std::endl; } m_isThereAnyError = true; } } // m_prefixes -- m_prefixesRefCcount; if (m_prefixesRefCcount == 0) delete m_prefixes; if (0 < m_canReadStack.size()) { Acquire a(m_soLog); *m_log << m_currentFilename << _T("(") << parser.getLineNumber() << _T(") : error: unbalanced `if'. ") << _T("you forget `endif', didn'i_token you?") << std::endl; m_isThereAnyError = true; } } // is the filename readable ? bool SettingLoader::isReadable(const tstringi &i_filename, int i_debugLevel) const { if (i_filename.empty()) return false; #ifdef UNICODE tifstream ist(to_string(i_filename).c_str()); #else tifstream ist(i_filename.c_str()); #endif if (ist.good()) { if (m_log && m_soLog) { Acquire a(m_soLog, 0); *m_log << _T(" loading: ") << i_filename << std::endl; } return true; } else { if (m_log && m_soLog) { Acquire a(m_soLog, i_debugLevel); *m_log << _T("not found: ") << i_filename << std::endl; } return false; } } #if 0 // get filename from registry bool SettingLoader::getFilenameFromRegistry(tstringi *o_path) const { // get from registry Registry reg(MAYU_REGISTRY_ROOT); int index; reg.read(_T(".mayuIndex"), &index, 0); char buf[100]; snprintf(buf, NUMBER_OF(buf), _T(".mayu%d"), index); if (!reg.read(buf, o_path)) return false; // parse registry entry Regexp getFilename(_T("^[^;]*;([^;]*);(.*)$")); if (!getFilename.doesMatch(*o_path)) return false; tstringi path = getFilename[1]; tstringi options = getFilename[2]; if (!(0 < path.size() && isReadable(path))) return false; *o_path = path; // set symbols Regexp symbol(_T("-D([^;]*)")); while (symbol.doesMatch(options)) { m_setting->symbols.insert(symbol[1]); options = options.substr(symbol.subBegin(1)); } return true; } #endif // get filename bool SettingLoader::getFilename(const tstringi &i_name, tstringi *o_path, int i_debugLevel) const { // the default filename is ".mayu" const tstringi &name = i_name.empty() ? tstringi(_T(".mayu")) : i_name; bool isFirstTime = true; while (true) { // find file from registry if (i_name.empty()) { // called not from 'include' Setting::Symbols symbols; if (getFilenameFromRegistry(NULL, o_path, &symbols)) { if (o_path->empty()) // find file from home directory { HomeDirectories pathes; getHomeDirectories(&pathes); for (HomeDirectories::iterator i = pathes.begin(); i != pathes.end(); ++ i) { *o_path = *i + _T("\\") + name; if (isReadable(*o_path, i_debugLevel)) goto add_symbols; } return false; } else { if (!isReadable(*o_path, i_debugLevel)) return false; } add_symbols: for (Setting::Symbols::iterator i = symbols.begin(); i != symbols.end(); ++ i) m_setting->m_symbols.insert(*i); return true; } } if (!isFirstTime) return false; // find file from home directory HomeDirectories pathes; getHomeDirectories(&pathes); for (HomeDirectories::iterator i = pathes.begin(); i != pathes.end(); ++ i) { *o_path = *i + _T("\\") + name; if (isReadable(*o_path, i_debugLevel)) return true; } if (!i_name.empty()) return false; // called by 'include' if (!DialogBox(g_hInst, MAKEINTRESOURCE(IDD_DIALOG_setting), NULL, dlgSetting_dlgProc)) return false; } } // constructor SettingLoader::SettingLoader(SyncObject *i_soLog, tostream *i_log) : m_setting(NULL), m_isThereAnyError(false), m_soLog(i_soLog), m_log(i_log), m_currentKeymap(NULL) { m_defaultKeySeqModifier = m_defaultAssignModifier.release(Modifier::Type_ImeComp); } /* load m_setting If called by "include", 'filename' describes filename. Otherwise the 'filename' is empty. */ bool SettingLoader::load(Setting *i_setting, const tstringi &i_filename) { m_setting = i_setting; m_isThereAnyError = false; tstringi path; if (!getFilename(i_filename, &path)) { if (i_filename.empty()) { Acquire a(m_soLog); getFilename(i_filename, &path, 0); // show filenames return false; } else throw ErrorMessage() << _T("`") << i_filename << _T("': no such file or other error."); } // create global keymap's default keySeq ActionFunction af(createFunctionData(_T("OtherWindowClass"))); KeySeq *globalDefault = m_setting->m_keySeqs.add(KeySeq(_T("")).add(af)); // add default keymap m_currentKeymap = m_setting->m_keymaps.add( Keymap(Keymap::Type_windowOr, _T("Global"), _T(""), _T(""), globalDefault, NULL)); /* // add keyboard layout name if (filename.empty()) { char keyboardLayoutName[KL_NAMELENGTH]; if (GetKeyboardLayoutName(keyboardLayoutName)) { tstringi kl = tstringi(_T("KeyboardLayout/")) + keyboardLayoutName; m_setting->symbols.insert(kl); Acquire a(m_soLog); *m_log << _T("KeyboardLayout: ") << kl << std::endl; } } */ // load load(path); // finalize if (i_filename.empty()) m_setting->m_keymaps.adjustModifier(m_setting->m_keyboard); return !m_isThereAnyError; } std::vector<tstringi> *SettingLoader::m_prefixes; // m_prefixes terminal symbol size_t SettingLoader::m_prefixesRefCcount; /* reference count of m_prefixes */
[ [ [ 1, 1697 ] ] ]
aa8cc135c913d3ce48350cbbfe41af9863575a8d
c7120eeec717341240624c7b8a731553494ef439
/src/cplusplus/freezone-samp/src/core/geo/detail/geo_info_getter_asnum.hpp
9a80a322b0ca64a71d8bc5d31c55f1e45582b6f9
[]
no_license
neverm1ndo/gta-paradise-sa
d564c1ed661090336621af1dfd04879a9c7db62d
730a89eaa6e8e4afc3395744227527748048c46d
refs/heads/master
2020-04-27T22:00:22.221323
2010-09-04T19:02:28
2010-09-04T19:02:28
174,719,907
1
0
null
2019-03-09T16:44:43
2019-03-09T16:44:43
null
UTF-8
C++
false
false
494
hpp
#ifndef GEO_INFO_GETTER_ASNUM_HPP #define GEO_INFO_GETTER_ASNUM_HPP #include "geo_info_getter_db.hpp" namespace geo { class info_getter_asnum: public info_getter_db { public: info_getter_asnum(GeoIPTag* gi); virtual ~info_getter_asnum(); public: // info_getter virtual void process_ip_info(ip_info& info); protected: virtual std::string get_db_info_prefix() const; }; } // namespace geo { #endif // GEO_INFO_GETTER_ASNUM_HPP
[ "dimonml@19848965-7475-ded4-60a4-26152d85fbc5" ]
[ [ [ 1, 16 ] ] ]
e65e04245bf72732ef682864b8868e9f8ef34122
4ab592fb354f75b42181d5375d485031960aaa7d
/DES_GOBSTG/DES_GOBSTG/Header/Export_Lua_HGE.h
104c947838d9994de9d3a7566cf174d6773fe733
[]
no_license
CBE7F1F65/cca610e2e115c51cef211fafb0f66662
806ced886ed61762220b43300cb993ead00949dc
b3cdff63d689e2b1748e9cd93cedd7e8389a7057
refs/heads/master
2020-12-24T14:55:56.999923
2010-07-23T04:24:59
2010-07-23T04:24:59
32,192,699
0
0
null
null
null
null
UTF-8
C++
false
false
5,622
h
#ifndef __NOTUSELUA #include "Export_Lua.h" class Export_Lua_HGE : public Export_Lua { public: static bool _LuaRegistFunction(LuaObject * obj); static bool _LuaRegistConst(LuaObject * obj); /* HGE */ static void _LuaHelper_GetVertex(LuaObject * obj, hgeVertex * vertex); static void _LuaHelper_GetTriple(LuaObject * obj, hgeTriple * triple); static void _LuaHelper_GetQuad(LuaObject * obj, hgeQuad * quad); static int LuaFn_hge_Struct_hgeQuad(LuaState * ls); static int LuaFn_hge_System_SetState(LuaState * ls); static int LuaFn_hge_System_GetState(LuaState * ls); static int LuaFn_hge_System_Log(LuaState * ls); static int LuaFn_hge_System_GetErrorMessage(LuaState * ls); static int LuaFn_hge_System_Launch(LuaState * ls); static int LuaFn_hge_System_Snapshot(LuaState * ls); static int LuaFn_hge_System_Transform3DPoint(LuaState * ls); static int LuaFn_hge_Resource_Load(LuaState * ls); static int LuaFn_hge_Resource_Free(LuaState * ls); static int LuaFn_hge_Resource_AttachPack(LuaState * ls); static int LuaFn_hge_Resource_RemovePack(LuaState * ls); static int LuaFn_hge_Resource_SetPath(LuaState * ls); static int LuaFn_hge_Resource_MakePath(LuaState * ls); static int LuaFn_hge_Resource_EnumFiles(LuaState * ls); static int LuaFn_hge_Resource_EnumFolders(LuaState * ls); static int LuaFn_hge_Resource_CreatePack(LuaState * ls); static int LuaFn_hge_Resource_AddFileInPack(LuaState * ls); static int LuaFn_hge_Resource_GetCRC(LuaState * ls); static int LuaFn_hge_Resource_GetPackFirstFileName(LuaState * ls); static int LuaFn_hge_Ini_SetInt(LuaState * ls); static int LuaFn_hge_Ini_GetInt(LuaState * ls); static int LuaFn_hge_Ini_SetFloat(LuaState * ls); static int LuaFn_hge_Ini_GetFloat(LuaState * ls); static int LuaFn_hge_Ini_SetString(LuaState * ls); static int LuaFn_hge_Ini_GetString(LuaState * ls); static int LuaFn_hge_Random_Seed(LuaState * ls); static int LuaFn_hge_Random_Int(LuaState * ls); static int LuaFn_hge_Random_Float(LuaState * ls); static int LuaFn_hge_Timer_GetTime(LuaState * ls); static int LuaFn_hge_Timer_GetDelta(LuaState * ls); static int LuaFn_hge_Timer_GetFPS(LuaState * ls); static int LuaFn_hge_Timer_GetWorstFPS(LuaState * ls); static int LuaFn_hge_Timer_GetCurrentSystemTime(LuaState * ls); static int LuaFn_hge_Effect_Load(LuaState * ls); static int LuaFn_hge_Effect_Free(LuaState * ls); static int LuaFn_hge_Effect_Play(LuaState * ls); static int LuaFn_hge_Stream_Load(LuaState * ls); static int LuaFn_hge_Stream_Free(LuaState * ls); static int LuaFn_hge_Stream_Play(LuaState * ls); static int LuaFn_hge_Channel_SetPanning(LuaState * ls); static int LuaFn_hge_Channel_SetVolume(LuaState * ls); static int LuaFn_hge_Channel_SetPitch(LuaState * ls); static int LuaFn_hge_Channel_Pause(LuaState * ls); static int LuaFn_hge_Channel_Resume(LuaState * ls); static int LuaFn_hge_Channel_Stop(LuaState * ls); static int LuaFn_hge_Channel_IsPlaying(LuaState * ls); static int LuaFn_hge_Channel_GetLength(LuaState * ls); static int LuaFn_hge_Channel_GetPos(LuaState * ls); static int LuaFn_hge_Channel_SetPos(LuaState * ls); static int LuaFn_hge_Channel_SetStartPos(LuaState * ls); static int LuaFn_hge_Channel_SlideTo(LuaState * ls); static int LuaFn_hge_Channel_IsSliding(LuaState * ls); static int LuaFn_hge_Channel_SetLoop(LuaState * ls); static int LuaFn_hge_Channel_RemoveLoop(LuaState * ls); static int LuaFn_hge_Input_GetMousePos(LuaState * ls); static int LuaFn_hge_Input_SetMousePos(LuaState * ls); static int LuaFn_hge_Input_GetMouseWheel(LuaState * ls); static int LuaFn_hge_Input_IsMouseOver(LuaState * ls); static int LuaFn_hge_Input_KeyDown(LuaState * ls); static int LuaFn_hge_Input_KeyUp(LuaState * ls); static int LuaFn_hge_Input_GetKeyState(LuaState * ls); static int LuaFn_hge_Input_GetKeyName(LuaState * ls); static int LuaFn_hge_Input_GetKey(LuaState * ls); static int LuaFn_hge_Input_GetChar(LuaState * ls); static int LuaFn_hge_Input_GetEvent(LuaState * ls); static int LuaFn_hge_Input_GetDIKey(LuaState * ls); static int LuaFn_hge_Input_SetDIKey(LuaState * ls); static int LuaFn_hge_Input_GetDIJoy(LuaState * ls); static int LuaFn_hge_Input_HaveJoy(LuaState * ls); static int LuaFn_hge_Gfx_BeginScene(LuaState * ls); static int LuaFn_hge_Gfx_EndScene(LuaState * ls); static int LuaFn_hge_Gfx_Clear(LuaState * ls); static int LuaFn_hge_Gfx_RenderLine(LuaState * ls); static int LuaFn_hge_Gfx_RenderTriple(LuaState * ls); static int LuaFn_hge_Gfx_RenderQuad(LuaState * ls); static int LuaFn_hge_Gfx_StartBatch(LuaState * ls); static int LuaFn_hge_Gfx_FinishBatch(LuaState * ls); static int LuaFn_hge_Gfx_SetClipping(LuaState * ls); static int LuaFn_hge_Gfx_SetTransform(LuaState * ls); static int LuaFn_hge_Target_Create(LuaState * ls); static int LuaFn_hge_Target_Free(LuaState * ls); static int LuaFn_hge_Target_GetTexture(LuaState * ls); static int LuaFn_hge_Texture_Create(LuaState * ls); static int LuaFn_hge_Texture_Load(LuaState * ls); static int LuaFn_hge_Texture_Free(LuaState * ls); static int LuaFn_hge_Texture_GetWH(LuaState * ls); static int LuaFn_hge_Texture_Lock(LuaState * ls); static int LuaFn_hge_Texture_Unlock(LuaState * ls); static int LuaFn_hge_Font_Load(LuaState * ls); static int LuaFn_hge_Font_Free(LuaState * ls); static int LuaFn_hge_Gfx_RenderText(LuaState * ls); static int LuaFn_hge_Gfx_RenderTextToTarget(LuaState * ls); public: static hgeChannelSyncInfo channelsyncinfo; }; #endif
[ "CBE7F1F65@4a173d03-4959-223b-e14c-e2eaa5fc8a8b" ]
[ [ [ 1, 131 ] ] ]
36d078e2440b8e9c5ef88b48174af9fe64e35fa2
d752d83f8bd72d9b280a8c70e28e56e502ef096f
/EXEGen/Resource Compiler/ResourceDirectory.cpp
6cc0099251eb57c766244be727c68f75ba22985d
[]
no_license
apoch/epoch-language.old
f87b4512ec6bb5591bc1610e21210e0ed6a82104
b09701714d556442202fccb92405e6886064f4af
refs/heads/master
2021-01-10T20:17:56.774468
2010-03-07T09:19:02
2010-03-07T09:19:02
34,307,116
0
0
null
null
null
null
UTF-8
C++
false
false
8,011
cpp
// // The Epoch Language Project // Win32 EXE Generator // // Helper interfaces for the resource manager // #include "pch.h" #include "Resource Compiler/ResourceDirectory.h" #include "Resource Compiler/ResourceEmitter.h" #include "Linker/LinkWriter.h" using namespace ResourceCompiler; // // Construct and initialize a resource directory header structure // DirectoryHeader::DirectoryHeader(DWORD characteristics, DWORD timedatestamp, WORD majorversion, WORD minorversion, WORD numnamedentries, WORD numidentries) : Characteristics(characteristics), TimeDateStamp(timedatestamp), MajorVersion(majorversion), MinorVersion(minorversion), NumNamedEntries(numnamedentries), NumIDEntries(numidentries) { } // // Retrieve the size of a resource directory header structure // DWORD DirectoryHeader::GetSize() const { return GetSizeStatic(); } DWORD DirectoryHeader::GetSizeStatic() { return (sizeof(DWORD) * 2) + (sizeof(WORD) * 4); } // // Write a resource directory structure to disk // void DirectoryHeader::Emit(LinkWriter& writer, bool pointstoleaf, DWORD virtualbaseaddress) { writer.EmitDWORD(Characteristics); writer.EmitDWORD(TimeDateStamp); writer.EmitWORD(MajorVersion); writer.EmitWORD(MinorVersion); writer.EmitWORD(NumNamedEntries); writer.EmitWORD(NumIDEntries); } // // Construct and initialize a directory entry structure // DirectoryEntry::DirectoryEntry(DWORD name, DWORD offsettodata) : Name(name), OffsetToData(offsettodata) { } // // Retrieve the size that a directory entry requires on disk // DWORD DirectoryEntry::GetSize() const { return GetSizeStatic(); } DWORD DirectoryEntry::GetSizeStatic() { return sizeof(DWORD) * 2; } // // Write a resource directory entry to disk // void DirectoryEntry::Emit(LinkWriter& writer, bool pointstoleaf, DWORD virtualbaseaddress) { writer.EmitDWORD(Name); writer.EmitDWORD(OffsetToData | (pointstoleaf ? 0 : 0x80000000)); // Set the high-order bit to flag a node entry (as opposed to a leaf entry) } // // Construct and initialize a resource leaf entry // // Leaf entries provide the actual offset and size of the // given resource data, along with other useful info // DirectoryLeaf::DirectoryLeaf(DWORD offsettodata, DWORD size, DWORD codepage, DWORD boundresid) : OffsetToData(offsettodata), Size(size), CodePage(codepage), Reserved(0), BoundResourceID(boundresid) { } // // Determine how much space the leaf entry requires on disk // DWORD DirectoryLeaf::GetSize() const { return GetSizeStatic(); } DWORD DirectoryLeaf::GetSizeStatic() { return sizeof(DWORD) * 4; } // // Write the leaf entry to disk // void DirectoryLeaf::Emit(LinkWriter& writer, bool pointstoleaf, DWORD virtualbaseaddress) { writer.EmitDWORD(OffsetToData + virtualbaseaddress); writer.EmitDWORD(Size); writer.EmitDWORD(CodePage); writer.EmitDWORD(Reserved); } // // Construct and initialize the resource directory tracker // ResourceDirectory::ResourceDirectory() { std::auto_ptr<DirectoryHeader> ptr(new DirectoryHeader(0, 0, 0, 0, 0, 0)); RootTierHeader = ptr.get(); RootTier.push_back(ptr.release()); } // // Destruct and clean up the directory data // ResourceDirectory::~ResourceDirectory() { for(std::list<DirectoryBase*>::iterator iter = RootTier.begin(); iter != RootTier.end(); ++iter) delete *iter; for(std::list<DirectoryBase*>::iterator iter = IDTier.begin(); iter != IDTier.end(); ++iter) delete *iter; for(std::list<DirectoryBase*>::iterator iter = LanguageTier.begin(); iter != LanguageTier.end(); ++iter) delete *iter; for(std::list<DirectoryBase*>::iterator iter = LeafTier.begin(); iter != LeafTier.end(); ++iter) delete *iter; for(std::map<DWORD, ResourceEmitter*>::iterator iter = ResourceEmitters.begin(); iter != ResourceEmitters.end(); ++iter) delete iter->second; } // // Add a resource to the directory // // Note that the emitter object is now owned by the directory // manager and will be cleaned up when the manager is deleted. // void ResourceDirectory::AddResource(DWORD type, DWORD id, DWORD language, ResourceEmitter* emitter) { if(ResourceEmitters.find(id) != ResourceEmitters.end()) { delete emitter; std::ostringstream msg; msg << "Resource ID " << id << " is already in use!"; throw Exception(msg.str()); } ResourceEmitters[id] = emitter; ++RootTierHeader->NumIDEntries; RootTier.push_back(new DirectoryEntry(type, 0)); IDTier.push_back(new DirectoryHeader(0, 0, 0, 0, 0, 1)); IDTier.push_back(new DirectoryEntry(id, 0)); LanguageTier.push_back(new DirectoryHeader(0, 0, 0, 0, 0, 1)); LanguageTier.push_back(new DirectoryEntry(language, 0)); LeafTier.push_back(new DirectoryLeaf(0, emitter->GetSize(), 0, id)); } // // Traverse the directory and update each section's offsets // to point to the correct locations // void ResourceDirectory::ComputeOffsets() { DWORD offset = 0; // Compute the offset of the end of the root block offset = DirectoryHeader::GetSizeStatic() + DirectoryEntry::GetSizeStatic() * (RootTierHeader->NumIDEntries + RootTierHeader->NumNamedEntries); // Populate offset fields of records in the root tier for(std::list<DirectoryBase*>::const_iterator iter = RootTier.begin(); iter != RootTier.end(); ++iter) { if((*iter)->SetOffset(offset)) offset += DirectoryHeader::GetSizeStatic() + DirectoryEntry::GetSizeStatic(); } // Populate offset fields of records in the ID tier for(std::list<DirectoryBase*>::const_iterator iter = IDTier.begin(); iter != IDTier.end(); ++iter) { if((*iter)->SetOffset(offset)) offset += DirectoryHeader::GetSizeStatic() + DirectoryEntry::GetSizeStatic(); } // Populate offset fields of records in the language tier for(std::list<DirectoryBase*>::const_iterator iter = LanguageTier.begin(); iter != LanguageTier.end(); ++iter) { if((*iter)->SetOffset(offset)) offset += DirectoryLeaf::GetSizeStatic(); } DirectorySize = offset; ResourceSize = 0; // Now compute resource data offsets for(std::map<DWORD, ResourceEmitter*>::iterator iter = ResourceEmitters.begin(); iter != ResourceEmitters.end(); ++iter) { // Update leaf entry with correct relative offset for(std::list<DirectoryBase*>::const_iterator leafiter = LeafTier.begin(); leafiter != LeafTier.end(); ++leafiter) { DirectoryLeaf* leaf = dynamic_cast<DirectoryLeaf*>(*leafiter); if(leaf == NULL) throw Exception("Resource directory leaf list contains a non-leaf node!"); if(leaf->BoundResourceID == iter->first) { leaf->OffsetToData = offset; break; } } iter->second->SetOffset(offset); offset += iter->second->GetSize(); ResourceSize += iter->second->GetSize(); } } // // Determine how much disk space the resources will require // DWORD ResourceDirectory::GetSize() const { return ResourceSize + DirectorySize; } // // Emit the resource directory and all resources to disk // void ResourceDirectory::Emit(LinkWriter& writer, DWORD virtualbaseaddress) { for(std::list<DirectoryBase*>::const_iterator iter = RootTier.begin(); iter != RootTier.end(); ++iter) (*iter)->Emit(writer, false, virtualbaseaddress); for(std::list<DirectoryBase*>::const_iterator iter = IDTier.begin(); iter != IDTier.end(); ++iter) (*iter)->Emit(writer, false, virtualbaseaddress); for(std::list<DirectoryBase*>::const_iterator iter = LanguageTier.begin(); iter != LanguageTier.end(); ++iter) (*iter)->Emit(writer, true, virtualbaseaddress); for(std::list<DirectoryBase*>::const_iterator iter = LeafTier.begin(); iter != LeafTier.end(); ++iter) (*iter)->Emit(writer, false, virtualbaseaddress); for(std::map<DWORD, ResourceEmitter*>::const_iterator iter = ResourceEmitters.begin(); iter != ResourceEmitters.end(); ++iter) iter->second->Emit(writer); }
[ "[email protected]", "don.apoch@localhost" ]
[ [ [ 1, 172 ], [ 174, 280 ] ], [ [ 173, 173 ] ] ]
c60f30321d28edad777ae2edb2fd100ac4dfcd13
3856c39683bdecc34190b30c6ad7d93f50dce728
/LastProject/Source/OctTree.h
aa27d00045078389ff87fac3fa621fb1efaf2077
[]
no_license
yoonhada/nlinelast
7ddcc28f0b60897271e4d869f92368b22a80dd48
5df3b6cec296ce09e35ff0ccd166a6937ddb2157
refs/heads/master
2021-01-20T09:07:11.577111
2011-12-21T22:12:36
2011-12-21T22:12:36
34,231,967
0
0
null
null
null
null
UTF-8
C++
false
false
1,337
h
#pragma once #include <list> class OctTree { public: typedef struct _AREA { D3DXVECTOR3 vMin; D3DXVECTOR3 vMax; BOOL bExist; _AREA() { bExist = FALSE; } }AREA, *LPAREA; typedef std::list< LPAREA > LPAREALIST; private: VOID Initialize(); VOID Release(); VOID Cleanup(); // Build VOID GetMinMax( LPD3DXVECTOR3 _pvVertex, INT _iSize ); VOID BuildOctTree( INT _iLevel ); OctTree* AddChild( D3DXVECTOR3 _vMin, D3DXVECTOR3 _vMax ); BOOL SubDivide( INT _iLevel ); BOOL IsDivide(); VOID SetChildArea( LPAREA _pArea ); // GenerateBoundBox VOID Traverse( D3DXVECTOR3 _Vertex ); VOID GetBoundBox( LPAREALIST& _pArealist ); BOOL CmpMinMax( const D3DXVECTOR3& _vMin, const D3DXVECTOR3& _vMax, const D3DXVECTOR3& _vVertex ); public: OctTree() { this->Initialize(); } virtual ~OctTree() { this->Release(); } VOID Build( INT _iLevel, D3DXVECTOR3 _vMin, D3DXVECTOR3 _vMax ); VOID Build( INT _iLevel, LPD3DXVECTOR3 _pvVertex, INT _iSize ); VOID GenerateBoundBox( LPAREALIST& _pAreaList, LPD3DXVECTOR3 _pvVertex, INT _iSize ); VOID GenerateIndex( D3DXVECTOR3& _pvVertex ); private: enum { LUF = 0, LUB, LDF, LDB, RUF, RUB, RDF, RDB }; OctTree* m_pChild[ 8 ]; AREA m_Area; INT m_iLevel; public: };
[ "[email protected]@d02aaf57-2019-c8cd-d06c-d029ef2af4e0", "[email protected]@d02aaf57-2019-c8cd-d06c-d029ef2af4e0" ]
[ [ [ 1, 49 ], [ 51, 57 ], [ 59, 70 ] ], [ [ 50, 50 ], [ 58, 58 ] ] ]
f3281dc152516f3d9bb7a6f269d8e2b10a54c5a5
0b66a94448cb545504692eafa3a32f435cdf92fa
/tags/0.3/cbear.berlios.de/windows/com/traits.hpp
fceae8439b28f6317dae2e8486872db3e0667e53
[ "MIT" ]
permissive
BackupTheBerlios/cbear-svn
e6629dfa5175776fbc41510e2f46ff4ff4280f08
0109296039b505d71dc215a0b256f73b1a60b3af
refs/heads/master
2021-03-12T22:51:43.491728
2007-09-28T01:13:48
2007-09-28T01:13:48
40,608,034
0
0
null
null
null
null
UTF-8
C++
false
false
6,870
hpp
/* The MIT License Copyright (c) 2005 C Bear (http://cbear.berlios.de) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef CBEAR_BERLIOS_DE_WINDOWS_COM_TRAITS_HPP_INCLUDED #define CBEAR_BERLIOS_DE_WINDOWS_COM_TRAITS_HPP_INCLUDED #include <cbear.berlios.de/base/undefined.hpp> #include <cbear.berlios.de/windows/message_box.hpp> #include <cbear.berlios.de/policy/main.hpp> // BOOST_STATIC_ASSERT #include <boost/static_assert.hpp> // boost::mpl::if_ #include <boost/mpl/if.hpp> // boost::is_class #include <boost/type_traits/is_class.hpp> // boost::is_enum #include <boost/type_traits/is_enum.hpp> namespace cbear_berlios_de { namespace windows { namespace com { template<class Type> struct traits; enum io_type { in = 1, out = 2, in_out = in|out, }; typedef ::VARTYPE vartype_t; template<class Type> struct class_traits { typedef Type type; typedef typename type::internal_policy internal_policy; typedef typename internal_policy::type internal_type; static const vartype_t vt = type::vt; template<io_type Io> struct io_traits; template<> struct io_traits<in> { typedef internal_type internal_result; typedef const type &wrap_result; static internal_result internal(wrap_result X) { return X.internal(); } static wrap_result wrap(internal_result &X) { return type::wrap_ref(X); } }; template<> struct io_traits<in_out> { typedef internal_type *internal_result; typedef type &wrap_result; static internal_result internal(wrap_result X) { return &X.internal(); } static wrap_result wrap(internal_result &X) { return type::wrap_ref(*X); } }; template<> struct io_traits<out> { typedef internal_type *internal_result; typedef type &wrap_result; static internal_result internal(wrap_result X) { X = type(); return &X.internal(); } static wrap_result wrap(internal_result &X) { internal_policy::construct(*X); return type::wrap_ref(*X); } }; }; template<class Type, vartype_t Vt> struct default_traits { typedef Type type; typedef policy::standard_policy<type> internal_policy; typedef type internal_type; static const vartype_t vt = Vt; template<io_type Io> struct io_traits; template<> struct io_traits<in> { typedef internal_type internal_result; typedef type wrap_result; static internal_result internal(wrap_result X) { return X; } static wrap_result wrap(internal_result &X) { return X; } }; template<> struct io_traits<in_out> { typedef internal_type *internal_result; typedef type &wrap_result; static internal_result internal(wrap_result X) { return &X; } static wrap_result wrap(internal_result &X) { return *X; } }; template<> struct io_traits<out> { typedef internal_type *internal_result; typedef type &wrap_result; static internal_result internal(wrap_result X) { X = type(); return &X; } static wrap_result wrap(internal_result &X) { internal_policy::construct(*X); return *X; } }; }; struct undefined_traits { template<io_type> struct io_traits { typedef base::undefined internal_result; }; }; template<class Type> struct enum_traits: default_traits<Type, ::VT_INT> {}; template<class Type> struct traits: boost::mpl::if_<boost::is_class<Type>, class_traits<Type>, typename boost::mpl::if_<boost::is_enum<Type>, enum_traits<Type>, undefined_traits>::type>::type { }; template<io_type Io, class Type> struct io_traits: traits<Type>::template io_traits<Io> {}; template<io_type Io, class Type> struct internal_result { typedef typename io_traits<Io, Type>::internal_result type; }; template<io_type Io, class Type> typename internal_result<Io, Type>::type internal(const Type &X) { return io_traits<Io, Type>::internal(X); } template<io_type Io, class Type> typename internal_result<Io, Type>::type internal(Type &X) { return io_traits<Io, Type>::internal(X); } template<class Type> struct internal_in_result: internal_result<in, Type> {}; template<class Type> typename internal_in_result<Type>::type internal_in(const Type &X) { return internal<in>(X); } template<class Type> struct internal_in_out_result: internal_result<in_out, Type> {}; template<class Type> typename internal_in_out_result<Type>::type internal_in_out(Type &X) { return internal<in_out>(X); } template<class Type> struct internal_out_result: internal_result<out, Type> {}; template<class Type> typename internal_out_result<Type>::type internal_out(Type &X) { return internal<out>(X); } template<io_type Io, class Type> struct wrap_result { typedef typename io_traits<Io, Type>::wrap_result type; }; template<io_type Io, class Type> typename wrap_result<Io, Type>::type wrap( typename internal_result<Io, Type>::type &X) { return io_traits<Io, Type>::wrap(X); } template<class Type> struct wrap_in_result: wrap_result<in, Type> {}; template<class Type> typename wrap_in_result<Type>::type wrap_in( typename internal_in_result<Type>::type &X) { return wrap<in, Type>(X); } template<class Type> struct wrap_in_out_result: wrap_result<in_out, Type> {}; template<class Type> typename wrap_in_out_result<Type>::type wrap_in_out( typename internal_in_out_result<Type>::type &X) { return wrap<in_out, Type>(X); } template<class Type> struct wrap_out_result: wrap_result<out, Type> {}; template<class Type> typename wrap_out_result<Type>::type wrap_out( typename internal_out_result<Type>::type &X) { return wrap<out, Type>(X); } #define CBEAR_BERLIOS_DE_WINDOWS_COM_DECLARE_DEFAULT_TRAITS(T, VT) \ template<> struct traits<T>: default_traits<T, VT> {} } } } #endif
[ "sergey_shandar@e6e9985e-9100-0410-869a-e199dc1b6838" ]
[ [ [ 1, 290 ] ] ]
dfcaa6d8b9515190704a88a262a8b77788d21152
e2e49023f5a82922cb9b134e93ae926ed69675a1
/tools/aoslcpp/include/aosl/change_activate.hpp
e8ec9eafae08928e91860a254331e3af991a116a
[]
no_license
invy/mjklaim-freewindows
c93c867e93f0e2fe1d33f207306c0b9538ac61d6
30de8e3dfcde4e81a57e9059dfaf54c98cc1135b
refs/heads/master
2021-01-10T10:21:51.579762
2011-12-12T18:56:43
2011-12-12T18:56:43
54,794,395
1
0
null
null
null
null
UTF-8
C++
false
false
4,537
hpp
// Copyright (C) 2005-2010 Code Synthesis Tools CC // // This program was generated by CodeSynthesis XSD, an XML Schema // to C++ data binding compiler, in the Proprietary License mode. // You should have received a proprietary license from Code Synthesis // Tools CC prior to generating this code. See the license text for // conditions. // /** * @file * @brief Generated from change_activate.xsd. */ #ifndef AOSLCPP_AOSL__CHANGE_ACTIVATE_HPP #define AOSLCPP_AOSL__CHANGE_ACTIVATE_HPP // Begin prologue. // #include <aoslcpp/common.hpp> // // End prologue. #include <xsd/cxx/config.hxx> #if (XSD_INT_VERSION != 3030000L) #error XSD runtime version mismatch #endif #include <xsd/cxx/pre.hxx> #include "aosl/change_activate_forward.hpp" #include <memory> // std::auto_ptr #include <limits> // std::numeric_limits #include <algorithm> // std::binary_search #include <xsd/cxx/xml/char-utf8.hxx> #include <xsd/cxx/tree/exceptions.hxx> #include <xsd/cxx/tree/elements.hxx> #include <xsd/cxx/tree/containers.hxx> #include <xsd/cxx/tree/list.hxx> #include <xsd/cxx/xml/dom/parsing-header.hxx> #include <xsd/cxx/tree/containers-wildcard.hxx> #ifndef XSD_DONT_INCLUDE_INLINE #define XSD_DONT_INCLUDE_INLINE #include "aosl/change.hpp" #undef XSD_DONT_INCLUDE_INLINE #else #include "aosl/change.hpp" #endif // XSD_DONT_INCLUDE_INLINE /** * @brief C++ namespace for the %artofsequence.org/aosl/1.0 * schema namespace. */ namespace aosl { /** * @brief Class corresponding to the %change_activate schema type. * * Change that will activate the Object or do nothing if it's already * activated. * * @nosubgrouping */ class Change_activate: public ::aosl::Change { public: /** * @name Constructors */ //@{ /** * @brief Create an instance from the ultimate base and * initializers for required elements and attributes. */ Change_activate (const ObjectType&); /** * @brief Create an instance from a DOM element. * * @param e A DOM element to extract the data from. * @param f Flags to create the new instance with. * @param c A pointer to the object that will contain the new * instance. */ Change_activate (const ::xercesc::DOMElement& e, ::xml_schema::Flags f = 0, ::xml_schema::Container* c = 0); /** * @brief Copy constructor. * * @param x An instance to make a copy of. * @param f Flags to create the copy with. * @param c A pointer to the object that will contain the copy. * * For polymorphic object models use the @c _clone function instead. */ Change_activate (const Change_activate& x, ::xml_schema::Flags f = 0, ::xml_schema::Container* c = 0); /** * @brief Copy the instance polymorphically. * * @param f Flags to create the copy with. * @param c A pointer to the object that will contain the copy. * @return A pointer to the dynamically allocated copy. * * This function ensures that the dynamic type of the instance is * used for copying and should be used for polymorphic object * models instead of the copy constructor. */ virtual Change_activate* _clone (::xml_schema::Flags f = 0, ::xml_schema::Container* c = 0) const; //@} /** * @brief Destructor. */ virtual ~Change_activate (); }; } #ifndef XSD_DONT_INCLUDE_INLINE #include "aosl/change.inl" #endif // XSD_DONT_INCLUDE_INLINE #include <iosfwd> namespace aosl { ::std::ostream& operator<< (::std::ostream&, const Change_activate&); } #include <iosfwd> #include <xercesc/sax/InputSource.hpp> #include <xercesc/dom/DOMDocument.hpp> #include <xercesc/dom/DOMErrorHandler.hpp> namespace aosl { } #include <iosfwd> #include <xercesc/dom/DOMDocument.hpp> #include <xercesc/dom/DOMErrorHandler.hpp> #include <xercesc/framework/XMLFormatter.hpp> #include <xsd/cxx/xml/dom/auto-ptr.hxx> namespace aosl { void operator<< (::xercesc::DOMElement&, const Change_activate&); } #ifndef XSD_DONT_INCLUDE_INLINE #include "aosl/change_activate.inl" #endif // XSD_DONT_INCLUDE_INLINE #include <xsd/cxx/post.hxx> // Begin epilogue. // // // End epilogue. #endif // AOSLCPP_AOSL__CHANGE_ACTIVATE_HPP
[ "klaim@localhost" ]
[ [ [ 1, 190 ] ] ]
e6391d5bb70c4c1e5dd48456e1318e8d5c30e31d
b25b2850eba2be6109b08753f95f0c91a198788d
/ImageTargets/jni/ImageTargets.cpp
9763c08c7df178c338345e3a2d3084e9af9c5788
[]
no_license
yaoyaowd/demo
2f6f884d634f12ce803775b860d44755e4ba1401
382ee07a350742d63d212cd3bcfb61053cc4d7d0
refs/heads/master
2016-08-07T13:18:01.182751
2011-10-15T16:40:37
2011-10-15T16:40:37
2,567,941
0
0
null
null
null
null
UTF-8
C++
false
false
15,060
cpp
/*============================================================================== Copyright (c) 2010-2011 QUALCOMM Incorporated. All Rights Reserved. Qualcomm Confidential and Proprietary @file ImageTargets.cpp @brief Sample for ImageTargets ==============================================================================*/ #include <jni.h> #include <android/log.h> #include <stdio.h> #include <string.h> #include <assert.h> #ifdef USE_OPENGL_ES_1_1 #include <GLES/gl.h> #include <GLES/glext.h> #else #include <GLES2/gl2.h> #include <GLES2/gl2ext.h> #endif #include <QCAR/QCAR.h> #include <QCAR/CameraDevice.h> #include <QCAR/Renderer.h> #include <QCAR/VideoBackgroundConfig.h> #include <QCAR/Trackable.h> #include <QCAR/Tool.h> #include <QCAR/Tracker.h> #include <QCAR/CameraCalibration.h> #include "SampleUtils.h" #include "Texture.h" #include "CubeShaders.h" #include "Teapot.h" #ifdef __cplusplus extern "C" { #endif // Textures: int textureCount = 0; Texture** textures = 0; // OpenGL ES 2.0 specific: #ifdef USE_OPENGL_ES_2_0 unsigned int shaderProgramID = 0; GLint vertexHandle = 0; GLint normalHandle = 0; GLint textureCoordHandle = 0; GLint mvpMatrixHandle = 0; #endif // Screen dimensions: unsigned int screenWidth = 0; unsigned int screenHeight = 0; // Indicates whether screen is in portrait (true) or landscape (false) mode bool isActivityInPortraitMode = false; // The projection matrix used for rendering virtual objects: QCAR::Matrix44F projectionMatrix; // Constants: static const float kObjectScale = 3.f; JNIEXPORT int JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_getOpenGlEsVersionNative(JNIEnv *, jobject) { #ifdef USE_OPENGL_ES_1_1 return 1; #else return 2; #endif } JNIEXPORT void JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_setActivityPortraitMode(JNIEnv *, jobject, jboolean isPortrait) { isActivityInPortraitMode = isPortrait; } JNIEXPORT void JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_onQCARInitializedNative(JNIEnv *, jobject) { // Comment in to enable tracking of up to 2 targets simultaneously and // split the work over multiple frames: // QCAR::setHint(QCAR::HINT_MAX_SIMULTANEOUS_IMAGE_TARGETS, 2); // QCAR::setHint(QCAR::HINT_IMAGE_TARGET_MULTI_FRAME_ENABLED, 1); } JNIEXPORT void JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_renderFrame(JNIEnv *, jobject) { //LOG("Java_com_qualcomm_QCARSamples_ImageTargets_GLRenderer_renderFrame"); // Clear color and depth buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Render video background: QCAR::State state = QCAR::Renderer::getInstance().begin(); #ifdef USE_OPENGL_ES_1_1 // Set GL11 flags: glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnable(GL_TEXTURE_2D); glDisable(GL_LIGHTING); #endif glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); // Did we find any trackables this frame? for(int tIdx = 0; tIdx < state.getNumActiveTrackables(); tIdx++) { // Get the trackable: const QCAR::Trackable* trackable = state.getActiveTrackable(tIdx); QCAR::Matrix44F modelViewMatrix = QCAR::Tool::convertPose2GLMatrix(trackable->getPose()); // Choose the texture based on the target name: int textureIndex = (!strcmp(trackable->getName(), "stones")) ? 0 : 1; const Texture* const thisTexture = textures[textureIndex]; #ifdef USE_OPENGL_ES_1_1 // Load projection matrix: glMatrixMode(GL_PROJECTION); glLoadMatrixf(projectionMatrix.data); // Load model view matrix: glMatrixMode(GL_MODELVIEW); glLoadMatrixf(modelViewMatrix.data); glTranslatef(0.f, 0.f, kObjectScale); glScalef(kObjectScale, kObjectScale, kObjectScale); // Draw object: glBindTexture(GL_TEXTURE_2D, thisTexture->mTextureID); glTexCoordPointer(2, GL_FLOAT, 0, (const GLvoid*) &teapotTexCoords[0]); glVertexPointer(3, GL_FLOAT, 0, (const GLvoid*) &teapotVertices[0]); glNormalPointer(GL_FLOAT, 0, (const GLvoid*) &teapotNormals[0]); glDrawElements(GL_TRIANGLES, NUM_TEAPOT_OBJECT_INDEX, GL_UNSIGNED_SHORT, (const GLvoid*) &teapotIndices[0]); #else QCAR::Matrix44F modelViewProjection; SampleUtils::translatePoseMatrix(0.0f, 0.0f, kObjectScale, &modelViewMatrix.data[0]); SampleUtils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale, &modelViewMatrix.data[0]); SampleUtils::multiplyMatrix(&projectionMatrix.data[0], &modelViewMatrix.data[0] , &modelViewProjection.data[0]); glUseProgram(shaderProgramID); glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &teapotVertices[0]); glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &teapotNormals[0]); glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &teapotTexCoords[0]); glEnableVertexAttribArray(vertexHandle); glEnableVertexAttribArray(normalHandle); glEnableVertexAttribArray(textureCoordHandle); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, thisTexture->mTextureID); glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE, (GLfloat*)&modelViewProjection.data[0] ); glDrawElements(GL_TRIANGLES, NUM_TEAPOT_OBJECT_INDEX, GL_UNSIGNED_SHORT, (const GLvoid*) &teapotIndices[0]); SampleUtils::checkGlError("ImageTargets renderFrame"); #endif } glDisable(GL_DEPTH_TEST); #ifdef USE_OPENGL_ES_1_1 glDisable(GL_TEXTURE_2D); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); #else glDisableVertexAttribArray(vertexHandle); glDisableVertexAttribArray(normalHandle); glDisableVertexAttribArray(textureCoordHandle); #endif QCAR::Renderer::getInstance().end(); } void configureVideoBackground() { // Get the default video mode: QCAR::CameraDevice& cameraDevice = QCAR::CameraDevice::getInstance(); QCAR::VideoMode videoMode = cameraDevice. getVideoMode(QCAR::CameraDevice::MODE_DEFAULT); // Configure the video background QCAR::VideoBackgroundConfig config; config.mEnabled = true; config.mSynchronous = true; config.mPosition.data[0] = 0.0f; config.mPosition.data[1] = 0.0f; if (isActivityInPortraitMode) { //LOG("configureVideoBackground PORTRAIT"); config.mSize.data[0] = videoMode.mHeight * (screenHeight / (float)videoMode.mWidth); config.mSize.data[1] = screenHeight; } else { //LOG("configureVideoBackground LANDSCAPE"); config.mSize.data[0] = screenWidth; config.mSize.data[1] = videoMode.mHeight * (screenWidth / (float)videoMode.mWidth); } // Set the config: QCAR::Renderer::getInstance().setVideoBackgroundConfig(config); } JNIEXPORT void JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_initApplicationNative( JNIEnv* env, jobject obj, jint width, jint height) { LOG("Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_initApplicationNative"); // Store screen dimensions screenWidth = width; screenHeight = height; // Handle to the activity class: jclass activityClass = env->GetObjectClass(obj); jmethodID getTextureCountMethodID = env->GetMethodID(activityClass, "getTextureCount", "()I"); if (getTextureCountMethodID == 0) { LOG("Function getTextureCount() not found."); return; } textureCount = env->CallIntMethod(obj, getTextureCountMethodID); if (!textureCount) { LOG("getTextureCount() returned zero."); return; } textures = new Texture*[textureCount]; jmethodID getTextureMethodID = env->GetMethodID(activityClass, "getTexture", "(I)Lcom/qualcomm/QCARSamples/ImageTargets/Texture;"); if (getTextureMethodID == 0) { LOG("Function getTexture() not found."); return; } // Register the textures for (int i = 0; i < textureCount; ++i) { jobject textureObject = env->CallObjectMethod(obj, getTextureMethodID, i); if (textureObject == NULL) { LOG("GetTexture() returned zero pointer"); return; } textures[i] = Texture::create(env, textureObject); } } JNIEXPORT void JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_deinitApplicationNative( JNIEnv* env, jobject obj) { LOG("Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_deinitApplicationNative"); // Release texture resources if (textures != 0) { for (int i = 0; i < textureCount; ++i) { delete textures[i]; textures[i] = NULL; } delete[]textures; textures = NULL; textureCount = 0; } } JNIEXPORT void JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_startCamera(JNIEnv *, jobject) { LOG("Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_startCamera"); // Initialize the camera: if (!QCAR::CameraDevice::getInstance().init()) return; // Configure the video background configureVideoBackground(); // Select the default mode: if (!QCAR::CameraDevice::getInstance().selectVideoMode( QCAR::CameraDevice::MODE_DEFAULT)) return; // Start the camera: if (!QCAR::CameraDevice::getInstance().start()) return; // Uncomment to enable flash //if(QCAR::CameraDevice::getInstance().setFlashTorchMode(true)) // LOG("IMAGE TARGETS : enabled torch"); // Uncomment to enable infinity focus mode, or any other supported focus mode // See CameraDevice.h for supported focus modes //if(QCAR::CameraDevice::getInstance().setFocusMode(QCAR::CameraDevice::FOCUS_MODE_INFINITY)) // LOG("IMAGE TARGETS : enabled infinity focus"); // Start the tracker: QCAR::Tracker::getInstance().start(); // Cache the projection matrix: const QCAR::Tracker& tracker = QCAR::Tracker::getInstance(); const QCAR::CameraCalibration& cameraCalibration = tracker.getCameraCalibration(); projectionMatrix = QCAR::Tool::getProjectionGL(cameraCalibration, 2.0f, 2000.0f); } JNIEXPORT void JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_stopCamera(JNIEnv *, jobject) { LOG("Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_stopCamera"); QCAR::Tracker::getInstance().stop(); QCAR::CameraDevice::getInstance().stop(); QCAR::CameraDevice::getInstance().deinit(); } JNIEXPORT jboolean JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_toggleFlash(JNIEnv*, jobject, jboolean flash) { return QCAR::CameraDevice::getInstance().setFlashTorchMode((flash==JNI_TRUE)) ? JNI_TRUE : JNI_FALSE; } JNIEXPORT jboolean JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_autofocus(JNIEnv*, jobject) { return QCAR::CameraDevice::getInstance().startAutoFocus()?JNI_TRUE:JNI_FALSE; } JNIEXPORT jboolean JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_setFocusMode(JNIEnv*, jobject, jint mode) { return QCAR::CameraDevice::getInstance().setFocusMode(mode)?JNI_TRUE:JNI_FALSE; } JNIEXPORT void JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_initRendering( JNIEnv* env, jobject obj) { LOG("Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_initRendering"); // Define clear color glClearColor(0.0f, 0.0f, 0.0f, QCAR::requiresAlpha() ? 0.0f : 1.0f); // Now generate the OpenGL texture objects and add settings for (int i = 0; i < textureCount; ++i) { glGenTextures(1, &(textures[i]->mTextureID)); glBindTexture(GL_TEXTURE_2D, textures[i]->mTextureID); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, textures[i]->mWidth, textures[i]->mHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*) textures[i]->mData); } #ifndef USE_OPENGL_ES_1_1 shaderProgramID = SampleUtils::createProgramFromBuffer(cubeMeshVertexShader, cubeFragmentShader); vertexHandle = glGetAttribLocation(shaderProgramID, "vertexPosition"); normalHandle = glGetAttribLocation(shaderProgramID, "vertexNormal"); textureCoordHandle = glGetAttribLocation(shaderProgramID, "vertexTexCoord"); mvpMatrixHandle = glGetUniformLocation(shaderProgramID, "modelViewProjectionMatrix"); #endif } JNIEXPORT void JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_updateRendering( JNIEnv* env, jobject obj, jint width, jint height) { LOG("Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_updateRendering"); // Update screen dimensions screenWidth = width; screenHeight = height; // Reconfigure the video background configureVideoBackground(); } #ifdef __cplusplus } #endif
[ [ [ 1, 457 ] ] ]
20cb89f4534ef87d13efb532b9db7c8b73c22192
51574a600a87ecfaaec8ea0e46b3809884859680
/MotionPlan/SparseGridMapView.h
f524bb28daff6a738efe574b5ad54efd2f3a1c4f
[]
no_license
suilevap/motion-plan
b5ad60a8448b118c3742c8c9c42b29fd5e41ef3e
d9f5693938287f2179ca2cb4eb75bda51b97bbb0
refs/heads/master
2021-01-10T03:29:50.373970
2011-12-20T22:39:55
2011-12-20T22:39:55
49,495,165
0
0
null
null
null
null
UTF-8
C++
false
false
1,372
h
#pragma once #ifndef MOTIONPLAN_SPARSEGRIDMAPVIEW_H_ #define MOTIONPLAN_SPARSEGRIDMAPVIEW_H_ #include "GridMapView.h" #include <vector> #include "Point.h" #include "EdgeInfo.h" #include "DistanceEvaluator.h" #include "FastVector.h" // _ template<class CellType> class SparseGridMapView : public GridMapView<CellType, float> { private: int* _mapSparse; int GetSparseId(int node); int GetSparseMainNode(int node); protected: bool IsCellSparse(int node); void AddCellSparse(int node); void RemoveCellSparse(int node); void GetNeighborsPartialFromSparsed( int nodeNeighboor1, int nodeNeighboor2, FastVector<AStar::EdgeInfo<int,float>>& neighbors, float d, float sparceCellD); void GetNeighborsPartialFromNotSparsed( int nodeNeighboor1, FastVector<AStar::EdgeInfo<int,float>>& neighbors, float d, float sparceCellD); public: SparseGridMapView(float width, float height, float cellSize); virtual ~SparseGridMapView(void); virtual Point<float> GetPoint(int node); virtual int GetNode(Point<float>& point); virtual int GetNodeWrite(Point<float>& point); virtual void GetNeighbors(int node, FastVector<AStar::EdgeInfo<int,float>>& neighbors); virtual void SetCell(int node, CellType cell); }; #include "SparseGridMapView.inl" #endif//MOTIONPLAN_SPARSEGRIDMAPVIEW_H_
[ "suilevap@localhost" ]
[ [ [ 1, 56 ] ] ]
24a5488699f8af66e28329d4903ec4075df36fd9
1e976ee65d326c2d9ed11c3235a9f4e2693557cf
/CaptionBordStatic.h
8e7d5be98935791bd5d47e7352b44430439670d6
[]
no_license
outcast1000/Jaangle
062c7d8d06e058186cb65bdade68a2ad8d5e7e65
18feb537068f1f3be6ecaa8a4b663b917c429e3d
refs/heads/master
2020-04-08T20:04:56.875651
2010-12-25T10:44:38
2010-12-25T10:44:38
19,334,292
3
0
null
null
null
null
UTF-8
C++
false
false
1,465
h
// /* // * // * Copyright (C) 2003-2010 Alexandros Economou // * // * This file is part of Jaangle (http://www.jaangle.com) // * // * 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, 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 GNU Make; see the file COPYING. If not, write to // * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. // * http://www.gnu.org/copyleft/gpl.html // * // */ #pragma once #include "LabelEx.h" // CLabelEx //#define BORDERSTATIC_MAXTEXTLEN 300 class CCaptionBordStatic : public CLabelEx { DECLARE_DYNAMIC(CCaptionBordStatic) public: CCaptionBordStatic(); virtual ~CCaptionBordStatic(); protected: afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void OnLButtonUp(UINT nFlags, CPoint point); DECLARE_MESSAGE_MAP() private: BOOL m_bMouseDown; CPoint m_mouseDownPoint; };
[ "outcast1000@dc1b949e-fa36-4f9e-8e5c-de004ec35678" ]
[ [ [ 1, 49 ] ] ]
4a840d1696b8ee49da2449e06260912b6e877f8f
9e4b72c504df07f6116b2016693abc1566b38310
/stl.cpp
5b8eba0ea06d96e98d73bbf0b726dfd8425245a1
[ "MIT" ]
permissive
mmeeks/rep-snapper
73311cadd3d8753462cf87a7e279937d284714aa
3a91de735dc74358c0bd2259891f9feac7723f14
refs/heads/master
2016-08-04T08:56:55.355093
2010-12-05T19:03:03
2010-12-05T19:03:03
704,101
0
1
null
null
null
null
UTF-8
C++
false
false
88,864
cpp
/* -------------------------------------------------------- * * * stl.cpp * * Copyright 2009+ Michael Holm - www.kulitorum.com * * This file is part of RepSnapper and is made available under * the terms of the GNU General Public License, version 2, or at your * option, any later version, incorporated herein by reference. * * ------------------------------------------------------------------------- */ #include "stdafx.h" #include "string.h" #include "stl.h" #include "gcode.h" #include "UI.h" #include "math.h" #include <boost/numeric/conversion/bounds.hpp> #ifdef WIN32 # include <GL/glut.h> // Header GLUT Library # pragma warning( disable : 4018 4267) #endif #include <iostream> #include <fstream> #include <algorithm> #include "ivcon.h" #if defined(ENABLE_GPC) && ENABLE_GPC #ifndef WIN32 extern "C" { #include "gpc.h" #endif #ifndef WIN32 } #endif #endif // for PointHash #ifdef __GNUC__ # define _BACKWARD_BACKWARD_WARNING_H 1 // kill annoying warning # include <ext/hash_map> namespace std { using namespace __gnu_cxx; } #else # include <hash_map> using namespace stdext; #endif /* extern "C" { #include "triangle.h" } */ #define MIN(A,B) ((A)<(B)? (A):(B)) #define MAX(A,B) ((A)>(B)? (A):(B)) #define ABS(a) (((a) < 0) ? -(a) : (a)) /* A number that speaks for itself, every kissable digit. */ #define PI 3.141592653589793238462643383279502884197169399375105820974944592308 #define CUTTING_PLANE_DEBUG 0 using namespace std; #ifndef M_PI #define M_PI 3.14159265358979323846 #endif /* call me before glutting */ void checkGlutInit() { static bool inited = false; if (inited) return; inited = true; int argc; char *argv[] = { (char *) "repsnapper" }; glutInit (&argc, argv); } void renderBitmapString(Vector3f pos, void* font, string text) { char asd[100]; char *a = &asd[0]; checkGlutInit(); sprintf(asd,text.c_str()); glRasterPos3f(pos.x, pos.y, pos.z); for (uint c=0;c<text.size();c++) glutBitmapCharacter(font, (int)*a++); } // STL constructor STL::STL() { Min.x = Min.y = Min.z = 0.0f; Max.x = Max.y = Max.z = 200.0f; CalcBoundingBoxAndZoom(); } # define COR3_MAX 200000 # define FACE_MAX 200000 # define ORDER_MAX 10 #define STL_READ_HEADER_SIZE 4 #define STL_READ_HEADER_TEXT "soli" extern float cor3[3][COR3_MAX]; extern float face_normal[3][FACE_MAX]; extern int face[ORDER_MAX][FACE_MAX]; extern int face_num; void STL::GetObjectsFromIvcon() { //face_num = count //face_normal[0][face nr] //face_normal[1][face nr] //face_normal[2][face nr] //face[ivert][face_num] = icor3; // Vertices in cor3[i][cor3_num] = temp[i]; triangles.reserve(face_num); for(int i=0;i<face_num;i++) { Triangle Tri; uint v1 = face[0][i]; uint v2 = face[1][i]; uint v3 = face[2][i]; Tri.A = Vector3f(cor3[0][v1], cor3[1][v1], cor3[2][v1]); Tri.B = Vector3f(cor3[0][v2], cor3[1][v2], cor3[2][v2]); Tri.C = Vector3f(cor3[0][v3], cor3[1][v3], cor3[2][v3]); Min.x = MIN(Min.x, Tri.A.x); Min.x = MIN(Min.x, Tri.B.x); Min.x = MIN(Min.x, Tri.C.x); Min.y = MIN(Min.y, Tri.A.y); Min.y = MIN(Min.y, Tri.B.y); Min.y = MIN(Min.y, Tri.C.y); Min.z = MIN(Min.z, Tri.A.z); Min.z = MIN(Min.z, Tri.B.z); Min.z = MIN(Min.z, Tri.C.z); Max.x = MAX(Max.x, Tri.A.x); Max.x = MAX(Max.x, Tri.B.x); Max.x = MAX(Max.x, Tri.C.x); Max.y = MAX(Max.y, Tri.A.y); Max.y = MAX(Max.y, Tri.B.y); Max.y = MAX(Max.y, Tri.C.y); Max.z = MAX(Max.z, Tri.A.z); Max.z = MAX(Max.z, Tri.B.z); Max.z = MAX(Max.z, Tri.C.z); Tri.Normal= Vector3f(face_normal[0][i], face_normal[1][i], face_normal[2][i]); triangles.push_back(Tri); } } bool STL::Read(string filename, bool force_binary) { triangles.clear(); Min.x = Min.y = Min.z = 500.0f; Max.x = Max.y = Max.z = -500.0f; unsigned int count; ifstream infile; try { infile.open(filename.c_str(), ios::in | ios::binary); if(!infile.good()) return false; // Ascii or binary? char header[STL_READ_HEADER_SIZE+1] = STL_READ_HEADER_TEXT; // +1 for the \0 on the c-style string infile.read(reinterpret_cast < char * > (&header), STL_READ_HEADER_SIZE*sizeof(char)); // Header Min.x = Min.y = Min.z = 99999999.0f; Max.x = Max.y = Max.z = -99999999.0f; // Check if the header is valid for an ASCII STL if (strcmp(header,STL_READ_HEADER_TEXT) == 0 && !force_binary) { infile.close(); FILE* file = fopen(filename.c_str(), "r"); int result = stla_read(file); if(result) { // Maybe it *is* a binary file, although the header would make you think not if(Read(filename, true) == true) return true; // if this fails, forced binary reading failed too, error stringstream error; error << "Error reading file: " << filename; fl_alert(error.str().c_str()); return false; } fclose(file); GetObjectsFromIvcon(); // ReadAsciiFile(); } else { infile.seekg(80, ios_base::beg); infile.read(reinterpret_cast < char * > (&count), sizeof(unsigned int)); // N_Triangles triangles.reserve(count); for(uint i = 0; i < count; i++) { float a,b,c; infile.read(reinterpret_cast < char * > (&a), sizeof(float)); infile.read(reinterpret_cast < char * > (&b), sizeof(float)); infile.read(reinterpret_cast < char * > (&c), sizeof(float)); Vector3f N(a,b,c); infile.read(reinterpret_cast < char * > (&a), sizeof(float)); infile.read(reinterpret_cast < char * > (&b), sizeof(float)); infile.read(reinterpret_cast < char * > (&c), sizeof(float)); Vector3f Ax(a,b,c); infile.read(reinterpret_cast < char * > (&a), sizeof(float)); infile.read(reinterpret_cast < char * > (&b), sizeof(float)); infile.read(reinterpret_cast < char * > (&c), sizeof(float)); Vector3f Bx(a,b,c); infile.read(reinterpret_cast < char * > (&a), sizeof(float)); infile.read(reinterpret_cast < char * > (&b), sizeof(float)); infile.read(reinterpret_cast < char * > (&c), sizeof(float)); Vector3f Cx(a,b,c); // if(N.lengthSquared() != 1.0f) { Vector3f AA=Cx-Ax; Vector3f BB=Cx-Bx; N.x = AA.y * BB.z - BB.y * AA.z; N.y = AA.z * BB.x - BB.z * AA.x; N.z = AA.x * BB.y - BB.x * AA.y; N.normalize(); } unsigned short xxx; infile.read(reinterpret_cast < char * > (&xxx), sizeof(unsigned short)); Triangle T(N,Ax,Bx,Cx); triangles.push_back(T); Min.x = MIN(Ax.x, Min.x); Min.y = MIN(Ax.y, Min.y); Min.z = MIN(Ax.z, Min.z); Max.x = MAX(Ax.x, Max.x); Max.y = MAX(Ax.y, Max.y); Max.z = MAX(Ax.z, Max.z); Min.x = MIN(Bx.x, Min.x); Min.y = MIN(Bx.y, Min.y); Min.z = MIN(Bx.z, Min.z); Max.x = MAX(Bx.x, Max.x); Max.y = MAX(Bx.y, Max.y); Max.z = MAX(Bx.z, Max.z); Min.x = MIN(Cx.x, Min.x); Min.y = MIN(Cx.y, Min.y); Min.z = MIN(Cx.z, Min.z); Max.x = MAX(Cx.x, Max.x); Max.y = MAX(Cx.y, Max.y); Max.z = MAX(Cx.z, Max.z); } }// binary } catch (ifstream::failure e) { cout << "Exception opening/reading file"; string error = e.what(); } OptimizeRotation(); CalcBoundingBoxAndZoom(); return true; } void STL::CalcBoundingBoxAndZoom() { Center = (Max + Min )/2; } void STL::displayInfillOld(const ProcessController &PC, CuttingPlane &plane, uint LayerNr, vector<int>& altInfillLayers) { if(PC.DisplayinFill) { // inFill vector<Vector2f> infill; CuttingPlane infillCuttingPlane = plane; if(PC.ShellOnly == false) { switch( PC.m_ShrinkQuality ) { case SHRINK_FAST: infillCuttingPlane.ClearShrink(); infillCuttingPlane.ShrinkFast(PC.ExtrudedMaterialWidth*0.5f, PC.Optimization, PC.DisplayCuttingPlane, false, PC.ShellCount); break; #if defined(ENABLE_GPC) && ENABLE_GPC case SHRINK_NICE: infillCuttingPlane.ShrinkNice(PC.ExtrudedMaterialWidth*0.5f, PC.Optimization, PC.DisplayCuttingPlane, false, PC.ShellCount); break; #endif case SHRINK_LOGICK: break; } // check if this if a layer we should use the alternate infill distance on float infillDistance = PC.InfillDistance; if (std::find(altInfillLayers.begin(), altInfillLayers.end(), LayerNr) != altInfillLayers.end()) { infillDistance = PC.AltInfillDistance; } infillCuttingPlane.CalcInFill(infill, LayerNr, infillDistance, PC.InfillRotation, PC.InfillRotationPrLayer, PC.DisplayDebuginFill); } glColor4f(1,1,0,1); glPointSize(5); glBegin(GL_LINES); for(size_t i=0;i<infill.size();i+=2) { if(infill.size() > i+1) { glVertex3f(infill[i ].x, infill[i ].y, plane.getZ()); glVertex3f(infill[i+1].x, infill[i+1].y, plane.getZ()); } } glEnd(); } } void STL::draw(const ProcessController &PC, float opasity) { // polygons glEnable(GL_LIGHTING); glEnable(GL_POINT_SMOOTH); float no_mat[] = {0.0f, 0.0f, 0.0f, 1.0f}; // float mat_ambient[] = {0.7f, 0.7f, 0.7f, 1.0f}; // float mat_ambient_color[] = {0.8f, 0.8f, 0.2f, 1.0f}; float mat_diffuse[] = {0.1f, 0.5f, 0.8f, opasity}; float mat_specular[] = {1.0f, 1.0f, 1.0f, 1.0f}; // float no_shininess = 0.0f; // float low_shininess = 5.0f; float high_shininess = 100.0f; // float mat_emission[] = {0.3f, 0.2f, 0.2f, 0.0f}; HSVtoRGB(PC.PolygonHue, PC.PolygonSat, PC.PolygonVal, mat_diffuse[0], mat_diffuse[1], mat_diffuse[2]); mat_specular[0] = mat_specular[1] = mat_specular[2] = PC.Highlight; /* draw sphere in first row, first column * diffuse reflection only; no ambient or specular */ glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialf(GL_FRONT, GL_SHININESS, high_shininess); glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); glEnable (GL_POLYGON_OFFSET_FILL); if(PC.DisplayPolygons) { glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); // glDepthMask(GL_TRUE); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //define blending factors glBegin(GL_TRIANGLES); for(size_t i=0;i<triangles.size();i++) { /* switch(triangles[i].axis) { case NEGX: glColor4f(1,0,0,PC.PolygonOpasity); break; case POSX: glColor4f(0.5f,0,0,PC.PolygonOpasity); break; case NEGY: glColor4f(0,1,0,PC.PolygonOpasity); break; case POSY: glColor4f(0,0.5f,0,PC.PolygonOpasity); break; case NEGZ: glColor4f(0,0,1,PC.PolygonOpasity); break; case POSZ: glColor4f(0,0,0.3f,PC.PolygonOpasity); break; default: glColor4f(0.2f,0.2f,0.2f,PC.PolygonOpasity); break; }*/ glNormal3fv((GLfloat*)&triangles[i].Normal); glVertex3fv((GLfloat*)&triangles[i].A); glVertex3fv((GLfloat*)&triangles[i].B); glVertex3fv((GLfloat*)&triangles[i].C); } glEnd(); } glDisable (GL_POLYGON_OFFSET_FILL); glDisable(GL_BLEND); // WireFrame if(PC.DisplayWireframe) { if(!PC.DisplayWireframeShaded) glDisable(GL_LIGHTING); float r,g,b; HSVtoRGB(PC.WireframeHue, PC.WireframeSat, PC.WireframeVal, r,g,b); HSVtoRGB(PC.WireframeHue, PC.WireframeSat, PC.WireframeVal, mat_diffuse[0], mat_diffuse[1], mat_diffuse[2]); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glColor3f(r,g,b); for(size_t i=0;i<triangles.size();i++) { glBegin(GL_LINE_LOOP); glLineWidth(1); glNormal3fv((GLfloat*)&triangles[i].Normal); glVertex3fv((GLfloat*)&triangles[i].A); glVertex3fv((GLfloat*)&triangles[i].B); glVertex3fv((GLfloat*)&triangles[i].C); glEnd(); } } glDisable(GL_LIGHTING); // normals if(PC.DisplayNormals) { float r,g,b; HSVtoRGB(PC.NormalsHue, PC.NormalsSat, PC.NormalsVal, r,g,b); glColor3f(r,g,b); glBegin(GL_LINES); for(size_t i=0;i<triangles.size();i++) { Vector3f center = (triangles[i].A+triangles[i].B+triangles[i].C)/3.0f; glVertex3fv((GLfloat*)&center); Vector3f N = center + (triangles[i].Normal*PC.NormalsLength); glVertex3fv((GLfloat*)&N); } glEnd(); } // Endpoints if(PC.DisplayEndpoints) { float r,g,b; HSVtoRGB(PC.EndpointsHue, PC.EndpointsSat, PC.EndpointsVal, r,g,b); glColor3f(r,g,b); glPointSize(PC.EndPointSize); glEnable(GL_POINT_SMOOTH); glBegin(GL_POINTS); for(size_t i=0;i<triangles.size();i++) { glVertex3f(triangles[i].A.x, triangles[i].A.y, triangles[i].A.z); glVertex3f(triangles[i].B.x, triangles[i].B.y, triangles[i].B.z); glVertex3f(triangles[i].C.x, triangles[i].C.y, triangles[i].C.z); } glEnd(); } glDisable(GL_DEPTH_TEST); // Make Layers if(PC.DisplayCuttingPlane) { uint LayerNr = 0; uint LayerCount = (uint)ceil((Max.z+PC.LayerThickness*0.5f)/PC.LayerThickness); vector<int> altInfillLayers; PC.GetAltInfillLayers(altInfillLayers, LayerCount); float zSize = (Max.z-Min.z); float z=PC.CuttingPlaneValue*zSize+Min.z; float zStep = zSize; if(PC.DisplayAllLayers) { z=Min.z; zStep = PC.LayerThickness; } while(z<Max.z) { for(size_t o=0;o<PC.rfo.Objects.size();o++) { for(size_t f=0;f<PC.rfo.Objects[o].files.size();f++) { Matrix4f T = PC.GetSTLTransformationMatrix(o,f); Vector3f t = T.getTranslation(); t+= Vector3f(PC.PrintMargin.x+PC.RaftSize*PC.RaftEnable, PC.PrintMargin.y+PC.RaftSize*PC.RaftEnable, 0); T.setTranslation(t); CuttingPlane plane; T=Matrix4f::IDENTITY; CalcCuttingPlane(z, plane, T); // output is alot of un-connected line segments with individual vertices float hackedZ = z; while (plane.LinkSegments(hackedZ, PC.Optimization) == false) // If segment linking fails, re-calc a new layer close to this one, and use that. { // This happens when there's triangles missing in the input STL break; hackedZ+= 0.1f; CalcCuttingPlane(hackedZ, plane, T); // output is alot of un-connected line segments with individual vertices } switch( PC.m_ShrinkQuality ) { case SHRINK_FAST: plane.ShrinkFast(PC.ExtrudedMaterialWidth*0.5f, PC.Optimization, PC.DisplayCuttingPlane, false, PC.ShellCount); displayInfillOld(PC, plane, LayerNr, altInfillLayers); break; #if defined(ENABLE_GPC) && ENABLE_GPC case SHRINK_NICE: plane.ShrinkNice(PC.ExtrudedMaterialWidth*0.5f, PC.Optimization, PC.DisplayCuttingPlane, false, PC.ShellCount); displayInfillOld(PC, plane, LayerNr, altInfillLayers); break; #endif case SHRINK_LOGICK: plane.ShrinkLogick(PC.ExtrudedMaterialWidth, PC.Optimization, PC.DisplayCuttingPlane, PC.ShellCount); plane.Draw(PC.DrawVertexNumbers, PC.DrawLineNumbers, PC.DrawCPOutlineNumbers, PC.DrawCPLineNumbers, PC.DrawCPVertexNumbers); displayInfillOld(PC, plane, LayerNr, altInfillLayers); break; } LayerNr++; } } z+=zStep; } }// If display cuttingplane if(PC.DisplayBBox) { // Draw bbox glColor3f(1,0,0); glLineWidth(1); glBegin(GL_LINE_LOOP); glVertex3f(Min.x, Min.y, Min.z); glVertex3f(Min.x, Max.y, Min.z); glVertex3f(Max.x, Max.y, Min.z); glVertex3f(Max.x, Min.y, Min.z); glEnd(); glBegin(GL_LINE_LOOP); glVertex3f(Min.x, Min.y, Max.z); glVertex3f(Min.x, Max.y, Max.z); glVertex3f(Max.x, Max.y, Max.z); glVertex3f(Max.x, Min.y, Max.z); glEnd(); glBegin(GL_LINES); glVertex3f(Min.x, Min.y, Min.z); glVertex3f(Min.x, Min.y, Max.z); glVertex3f(Min.x, Max.y, Min.z); glVertex3f(Min.x, Max.y, Max.z); glVertex3f(Max.x, Max.y, Min.z); glVertex3f(Max.x, Max.y, Max.z); glVertex3f(Max.x, Min.y, Min.z); glVertex3f(Max.x, Min.y, Max.z); glEnd(); } } uint findClosestUnused(std::vector<Vector3f> lines, Vector3f point, std::vector<bool> &used) { uint closest = -1; float closestDist = boost::numeric::bounds<float>::highest(); size_t count = lines.size(); for(uint i=0;i<count;i++) { if(used[i] == false) { float dist = (lines[i]-point).length(); if(dist < closestDist) { closestDist = dist; closest = i; } } } return closest; } uint findOtherEnd(uint p) { uint a = p%2; if(a == 0) return p+1; return p-1; } CuttingPlane::CuttingPlane() { } CuttingPlane::~CuttingPlane() { } void MakeAcceleratedGCodeLine(Vector3f start, Vector3f end, float DistanceToReachFullSpeed, float extrusionFactor, GCode &code, float z, float minSpeedXY, float maxSpeedXY, float minSpeedZ, float maxSpeedZ, bool UseIncrementalEcode, bool Use3DGcode, float &E, bool EnableAcceleration) { if((end-start).length() < 0.05) // ignore micro moves return; static Command lastCommand; Command command; if(EnableAcceleration) { if(end != start) //If we are going to somewhere else { float len; lastCommand.where = start; Vector3f direction = end-start; len = direction.length(); // total distance direction.normalize(); // Set start feedrage command.Code = SETSPEED; command.where = start; if(UseIncrementalEcode) command.e = E; // move or extrude? else command.e = 0.0f; // move or extrude? command.f = minSpeedXY; code.commands.push_back(command); lastCommand = command; if(len < DistanceToReachFullSpeed*2) { // TODO: First point of acceleration is the middle of the line segment command.Code = COORDINATEDMOTION; command.where = (start+end)*0.5f; float extrudedMaterial = (lastCommand.where - command.where).length()*extrusionFactor; if(UseIncrementalEcode) E+=extrudedMaterial; else E = extrudedMaterial; command.e = E; // move or extrude? float lengthFactor = (len/2.0f)/DistanceToReachFullSpeed; command.f = (maxSpeedXY-minSpeedXY)*lengthFactor+minSpeedXY; code.commands.push_back(command); lastCommand = command; // And then decelerate command.Code = COORDINATEDMOTION; command.where = end; if(UseIncrementalEcode) E+=extrudedMaterial; else E = extrudedMaterial; command.e = E; // move or extrude? command.f = minSpeedXY; code.commands.push_back(command); lastCommand = command; }// if we will never reach full speed else { // Move to max speed command.Code = COORDINATEDMOTION; command.where = start+(direction*DistanceToReachFullSpeed); float extrudedMaterial = (lastCommand.where - command.where).length()*extrusionFactor; if(UseIncrementalEcode) E+=extrudedMaterial; else E = extrudedMaterial; command.e = E; // move or extrude? command.f = maxSpeedXY; code.commands.push_back(command); lastCommand = command; // Sustian speed till deacceleration starts command.Code = COORDINATEDMOTION; command.where = end-(direction*DistanceToReachFullSpeed); extrudedMaterial = (lastCommand.where - command.where).length()*extrusionFactor; if(UseIncrementalEcode) E+=extrudedMaterial; else E = extrudedMaterial; command.e = E; // move or extrude? command.f = maxSpeedXY; code.commands.push_back(command); lastCommand = command; // deacceleration untill end command.Code = COORDINATEDMOTION; command.where = end; extrudedMaterial = (lastCommand.where - command.where).length()*extrusionFactor; if(UseIncrementalEcode) E+=extrudedMaterial; else E = extrudedMaterial; command.e = E; // move or extrude? command.f = minSpeedXY; code.commands.push_back(command); lastCommand = command; } // if we will reach full speed }// if we are going somewhere } // Firmware acceleration else // No accleration { // Make a accelerated line from lastCommand.where to lines[thisPoint] if(end != start) //If we are going to somewhere else { lastCommand.where = start; if(Use3DGcode) { { command.Code = EXTRUDEROFF; code.commands.push_back(command); lastCommand = command; float speed = minSpeedXY; command.Code = COORDINATEDMOTION3D; command.where = start; command.e = E; // move or extrude? command.f = speed; code.commands.push_back(command); lastCommand = command; } // we need to move before extruding command.Code = EXTRUDERON; code.commands.push_back(command); lastCommand = command; float speed = minSpeedXY; command.Code = COORDINATEDMOTION3D; command.where = end; command.e = E; // move or extrude? command.f = speed; code.commands.push_back(command); lastCommand = command; // Done, switch extruder off command.Code = EXTRUDEROFF; code.commands.push_back(command); lastCommand = command; } else // 5d gcode, no acceleration { Vector3f direction = end-start; direction.normalize(); // set start speed to max if(lastCommand.f != maxSpeedXY) { command.Code = SETSPEED; command.where = Vector3f(start.x, start.y, z); command.f=maxSpeedXY; command.e = E; code.commands.push_back(command); lastCommand = command; } // store endPoint command.Code = COORDINATEDMOTION; command.where = end; float extrudedMaterial = (lastCommand.where - command.where).length()*extrusionFactor; if(UseIncrementalEcode) E+=extrudedMaterial; else E = extrudedMaterial; command.e = E; // move or extrude? command.f = maxSpeedXY; code.commands.push_back(command); lastCommand = command; } // 5D gcode }// If we are going to somewhere else*/ }// If using firmware acceleration } void CuttingPlane::MakeGcode(const std::vector<Vector2f> &infill, GCode &code, float &E, float z, float MinPrintSpeedXY, float MaxPrintSpeedXY, float MinPrintSpeedZ, float MaxPrintSpeedZ, float DistanceToReachFullSpeed, float extrusionFactor, bool UseIncrementalEcode, bool Use3DGcode, bool EnableAcceleration) // Convert Cuttingplane to GCode { // Make an array with all lines, then link'em static Vector3f LastPosition;// = Vector3f(0,0,z); LastPosition.z = z; static float lastLayerZ = 0; Command command; if(lastLayerZ == 0) lastLayerZ = z; // Set speed for next move command.Code = SETSPEED; command.where = Vector3f(0,0,lastLayerZ); command.e = E; // move command.f = MinPrintSpeedZ; // Use Min Z speed code.commands.push_back(command); command.comment = ""; // Move Z axis command.Code = ZMOVE; command.where = Vector3f(0,0,z); command.e = E; // move command.f = MinPrintSpeedZ; // Use Min Z speed code.commands.push_back(command); command.comment = ""; std::vector<Vector3f> lines; for(size_t i=0;i<infill.size();i++) lines.push_back(Vector3f(infill[i].x, infill[i].y, z)); if( optimizers.size() != 0 ) { // new method for( uint i = 1; i < optimizers.size()-1; i++) { optimizers[i]->RetrieveLines(lines); } } else { // old method // Copy polygons if(offsetPolygons.size() != 0) { for(size_t p=0;p<offsetPolygons.size();p++) { for(size_t i=0;i<offsetPolygons[p].points.size();i++) { Vector2f P3 = offsetVertices[offsetPolygons[p].points[i]]; Vector2f P4 = offsetVertices[offsetPolygons[p].points[(i+1)%offsetPolygons[p].points.size()]]; lines.push_back(Vector3f(P3.x, P3.y, z)); lines.push_back(Vector3f(P4.x, P4.y, z)); } } } } // Find closest point to last point std::vector<bool> used; used.resize(lines.size()); for(size_t i=0;i<used.size();i++) used[i] = false; uint thisPoint = findClosestUnused(lines, LastPosition, used); if(thisPoint == -1) // No lines = no gcode return; used[thisPoint] = true; while(thisPoint != -1) { // float len; // Make a MOVE accelerated line from LastPosition to lines[thisPoint] if(LastPosition != lines[thisPoint]) //If we are going to somewhere else { MakeAcceleratedGCodeLine(LastPosition, lines[thisPoint], DistanceToReachFullSpeed, 0.0f, code, z, MinPrintSpeedXY, MaxPrintSpeedXY, MinPrintSpeedZ, MaxPrintSpeedZ, UseIncrementalEcode, Use3DGcode, E, EnableAcceleration); }// If we are going to somewhere else LastPosition = lines[thisPoint]; used[thisPoint] = true; // Find other end of line thisPoint = findOtherEnd(thisPoint); used[thisPoint] = true; // store thisPoint // Make a PLOT accelerated line from LastPosition to lines[thisPoint] // if(EnableAcceleration) MakeAcceleratedGCodeLine(LastPosition, lines[thisPoint], DistanceToReachFullSpeed, extrusionFactor, code, z, MinPrintSpeedXY, MaxPrintSpeedXY, MinPrintSpeedZ, MaxPrintSpeedZ, UseIncrementalEcode, Use3DGcode, E, EnableAcceleration); /* else { command.Code = COORDINATEDMOTION; command.where = lines[thisPoint]; len = (LastPosition - command.where).length(); if(UseIncrementalEcode) E+=len*extrusionFactor; else E = len*extrusionFactor; command.e = E; // move or extrude? command.f = MinPrintSpeedXY; code.commands.push_back(command); }*/ LastPosition = lines[thisPoint]; thisPoint = findClosestUnused(lines, LastPosition, used); if(thisPoint != -1) used[thisPoint] = true; } lastLayerZ = z; } // intersect lines with plane void STL::CalcCuttingPlane(float where, CuttingPlane &plane, const Matrix4f &T) { #if CUTTING_PLANE_DEBUG cout << "intersect with z " << where << "\n"; #endif plane.Clear(); plane.SetZ(where); Vector3f min = T*Min; Vector3f max = T*Max; plane.Min.x = min.x; plane.Min.y = min.y; plane.Max.x = max.x; plane.Max.y = max.y; Vector2f lineStart; Vector2f lineEnd; bool foundOne = false; for (size_t i = 0; i < triangles.size(); i++) { foundOne=false; CuttingPlane::Segment line(-1,-1); Vector3f P1 = T*triangles[i].A; Vector3f P2 = T*triangles[i].B; // Are the points on opposite sides of the plane ? if ((where <= P1.z) != (where <= P2.z)) { float t = (where-P1.z)/(float)(P2.z-P1.z); Vector3f p = P1+((Vector3f)(P2-P1)*t); lineStart = Vector2f(p.x,p.y); line.start = plane.RegisterPoint(lineStart); foundOne = true; } P1 = T*triangles[i].B; P2 = T*triangles[i].C; if ((where <= P1.z) != (where <= P2.z)) { float t = (where-P1.z)/(float)(P2.z-P1.z); Vector3f p = P1+((Vector3f)(P2-P1)*t); if(foundOne) { lineEnd = Vector2f(p.x,p.y); line.end = plane.RegisterPoint(lineEnd); } else { lineStart = Vector2f(p.x,p.y); line.start = plane.RegisterPoint(lineStart); } } P1 = T*triangles[i].C; P2 = T*triangles[i].A; if ((where <= P1.z) != (where <= P2.z)) { float t = (where-P1.z)/(float)(P2.z-P1.z); Vector3f p = P1+((Vector3f)(P2-P1)*t); lineEnd = Vector2f(p.x,p.y); line.end = plane.RegisterPoint(lineEnd); if( line.end == line.start ) continue; } // Check segment normal against triangle normal. Flip segment, as needed. if (line.start != -1 && line.end != -1 && line.end != line.start) // if we found a intersecting triangle { Vector3f Norm = triangles[i].Normal; Vector2f triangleNormal = Vector2f(Norm.x, Norm.y); Vector2f segmentNormal = (lineEnd - lineStart).normal(); triangleNormal.normalise(); segmentNormal.normalise(); if( (triangleNormal-segmentNormal).lengthSquared() > 0.2f) // if normals does not align, flip the segment line.Swap(); plane.AddLine(line); } } } vector<InFillHit> HitsBuffer; void CuttingPlane::CalcInFill(vector<Vector2f> &infill, uint LayerNr, float InfillDistance, float InfillRotation, float InfillRotationPrLayer, bool DisplayDebuginFill) { int c=0; float step = InfillDistance; bool examine = false; float Length = sqrtf(2)*( ((Max.x)>(Max.y)? (Max.x):(Max.y)) - ((Min.x)<(Min.y)? (Min.x):(Min.y)) )/2.0f; // bbox of lines to intersect the poly with float rot = InfillRotation/180.0f*M_PI; rot += (float)LayerNr*InfillRotationPrLayer/180.0f*M_PI; Vector2f InfillDirX(cosf(rot), sinf(rot)); Vector2f InfillDirY(-InfillDirX.y, InfillDirX.x); Vector2f Center = (Max+Min)/2.0f; for(float x = -Length ; x < Length ; x+=step) { bool examineThis = false; HitsBuffer.clear(); Vector2f P1 = (InfillDirX * Length)+(InfillDirY*x)+ Center; Vector2f P2 = (InfillDirX * -Length)+(InfillDirY*x) + Center; if(DisplayDebuginFill) { glBegin(GL_LINES); glColor3f(0,0.2f,0); glVertex3f(P1.x, P1.y, Z); glVertex3f(P2.x, P2.y, Z); glEnd(); } float Examine = 0.5f; if(DisplayDebuginFill) if(!examine && ((Examine-0.5f)*2 * Length <= x)) { examineThis = examine = true; glColor3f(1,1,1); // Draw the line glVertex3f(P1.x, P1.y, Z); glVertex3f(P2.x, P2.y, Z); } if(offsetPolygons.size() != 0) { for(size_t p=0;p<offsetPolygons.size();p++) { for(size_t i=0;i<offsetPolygons[p].points.size();i++) { Vector2f P3 = offsetVertices[offsetPolygons[p].points[i]]; Vector2f P4 = offsetVertices[offsetPolygons[p].points[(i+1)%offsetPolygons[p].points.size()]]; Vector3f point; InFillHit hit; if(IntersectXY(P1,P2,P3,P4,hit)) { HitsBuffer.push_back(hit); } } } } /* else if(vertices.size() != 0) { // Fallback, collide with lines rather then polygons for(size_t i=0;i<lines.size();i++) { Vector2f P3 = vertices[lines[i].start]; Vector2f P4 = vertices[lines[i].end]; Vector3f point; InFillHit hit; if(IntersectXY(P1,P2,P3,P4,hit)) { if(examineThis) int a=0; HitsBuffer.push_back(hit); } } }*/ // Sort hits // Sort the vector using predicate and std::sort std::sort(HitsBuffer.begin(), HitsBuffer.end(), InFillHitCompareFunc); if(examineThis) { glPointSize(4); glBegin(GL_POINTS); for(size_t i=0;i<HitsBuffer.size();i++) glVertex3f(HitsBuffer[0].p.x, HitsBuffer[0].p.y, Z); glEnd(); glPointSize(1); } // Verify hits intregrety // Check if hit extists in table restart_check: for(size_t i=0;i<HitsBuffer.size();i++) { bool found = false; for(size_t j=i+1;j<HitsBuffer.size();j++) if( ABS(HitsBuffer[i].d - HitsBuffer[j].d) < 0.0001) { found = true; // Delete both points, and continue HitsBuffer.erase(HitsBuffer.begin()+j); if(i != 0 && i != HitsBuffer.size()-1) //If we are "Going IN" to solid material, and there's more points, keep one of the points HitsBuffer.erase(HitsBuffer.begin()+i); goto restart_check; } if(found) continue; } // Sort hits by distance and transfer to InFill Buffer if(HitsBuffer.size() != 0 && HitsBuffer.size() % 2) continue; // There's a uneven number of hits, skip this infill line (U'll live) c=0; // Color counter while(HitsBuffer.size()) { infill.push_back(HitsBuffer[0].p); if(examineThis) { switch(c) { case 0: glColor3f(1,0,0); break; case 1: glColor3f(0,1,0); break; case 2: glColor3f(0,0,1); break; case 3: glColor3f(1,1,0); break; case 4: glColor3f(0,1,1); break; case 5: glColor3f(1,0,1); break; case 6: glColor3f(1,1,1); break; case 7: glColor3f(1,0,0); break; case 8: glColor3f(0,1,0); break; case 9: glColor3f(0,0,1); break; case 10: glColor3f(1,1,0); break; case 11: glColor3f(0,1,1); break; case 12: glColor3f(1,0,1); break; case 13: glColor3f(1,1,1); break; } c++; glPointSize(10); glBegin(GL_POINTS); glVertex3f(HitsBuffer[0].p.x, HitsBuffer[0].p.y, Z); glEnd(); glPointSize(1); } HitsBuffer.erase(HitsBuffer.begin()); } } } // calculates intersection and checks for parallel lines. // also checks that the intersection point is actually on // the line segment p1-p2 bool IntersectXY(const Vector2f &p1, const Vector2f &p2, const Vector2f &p3, const Vector2f &p4, InFillHit &hit) { // BBOX test if(MIN(p1.x,p2.x) > MAX(p3.x,p4.x)) return false; if(MAX(p1.x,p2.x) < MIN(p3.x,p4.x)) return false; if(MIN(p1.y,p2.y) > MAX(p3.y,p4.y)) return false; if(MAX(p1.y,p2.y) < MIN(p3.y,p4.y)) return false; if(ABS(p1.x-p3.x) < 0.01 && ABS(p1.y - p3.y) < 0.01) { hit.p = p1; hit.d = sqrtf( (p1.x-hit.p.x) * (p1.x-hit.p.x) + (p1.y-hit.p.y) * (p1.y-hit.p.y)); hit.t = 0.0f; return true; } if(ABS(p2.x-p3.x) < 0.01 && ABS(p2.y - p3.y) < 0.01) { hit.p = p2; hit.d = sqrtf( (p1.x-hit.p.x) * (p1.x-hit.p.x) + (p1.y-hit.p.y) * (p1.y-hit.p.y)); hit.t = 1.0f; return true; } if(ABS(p1.x-p4.x) < 0.01 && ABS(p1.y - p4.y) < 0.01) { hit.p = p1; hit.d = sqrtf( (p1.x-hit.p.x) * (p1.x-hit.p.x) + (p1.y-hit.p.y) * (p1.y-hit.p.y)); hit.t = 0.0f; return true; } if(ABS(p2.x-p4.x) < 0.01 && ABS(p2.y - p4.y) < 0.01) { hit.p = p2; hit.d = sqrtf( (p1.x-hit.p.x) * (p1.x-hit.p.x) + (p1.y-hit.p.y) * (p1.y-hit.p.y)); hit.t = 1.0f; return true; } InFillHit hit2; float t0,t1; if(intersect2D_Segments(p1,p2,p3,p4,hit.p, hit2.p, t0,t1) == 1) { hit.d = sqrtf( (p1.x-hit.p.x) * (p1.x-hit.p.x) + (p1.y-hit.p.y) * (p1.y-hit.p.y)); hit.t = t0; return true; } return false; /* float xD1,yD1,xD2,yD2,xD3,yD3; float dot,deg,len1,len2; float segmentLen1,segmentLen2; float ua,ub,div; // calculate differences xD1=p2.x-p1.x; xD2=p4.x-p3.x; yD1=p2.y-p1.y; yD2=p4.y-p3.y; xD3=p1.x-p3.x; yD3=p1.y-p3.y; // calculate the lengths of the two lines len1=sqrt(xD1*xD1+yD1*yD1); len2=sqrt(xD2*xD2+yD2*yD2); // calculate angle between the two lines. dot=(xD1*xD2+yD1*yD2); // dot product deg=dot/(len1*len2); // if ABS(angle)==1 then the lines are parallell, // so no intersection is possible if(ABS(deg)==1) return false; // find intersection Pt between two lines hit.p=Vector2f (0,0); div=yD2*xD1-xD2*yD1; ua=(xD2*yD3-yD2*xD3)/div; ub=(xD1*yD3-yD1*xD3)/div; hit.p.x=p1.x+ua*xD1; hit.p.y=p1.y+ua*yD1; // calculate the combined length of the two segments // between Pt-p1 and Pt-p2 xD1=hit.p.x-p1.x; xD2=hit.p.x-p2.x; yD1=hit.p.y-p1.y; yD2=hit.p.y-p2.y; segmentLen1=sqrt(xD1*xD1+yD1*yD1)+sqrt(xD2*xD2+yD2*yD2); // calculate the combined length of the two segments // between Pt-p3 and Pt-p4 xD1=hit.p.x-p3.x; xD2=hit.p.x-p4.x; yD1=hit.p.y-p3.y; yD2=hit.p.y-p4.y; segmentLen2=sqrt(xD1*xD1+yD1*yD1)+sqrt(xD2*xD2+yD2*yD2); // if the lengths of both sets of segments are the same as // the lenghts of the two lines the point is actually // on the line segment. // if the point isn't on the line, return null if(ABS(len1-segmentLen1)>0.00 || ABS(len2-segmentLen2)>0.00) return false; hit.d = segmentLen1-segmentLen2; return true;*/ } /* int PntOnLine(Vector2f p1, Vector2f p2, Vector2f t) { * * given a line through P:(px,py) Q:(qx,qy) and T:(tx,ty) * return 0 if T is not on the line through <--P--Q--> * 1 if T is on the open ray ending at P: <--P * 2 if T is on the closed interior along: P--Q * 3 if T is on the open ray beginning at Q: Q--> * * Example: consider the line P = (3,2), Q = (17,7). A plot * of the test points T(x,y) (with 0 mapped onto '.') yields: * * 8| . . . . . . . . . . . . . . . . . 3 3 * Y 7| . . . . . . . . . . . . . . 2 2 Q 3 3 Q = 3 * 6| . . . . . . . . . . . 2 2 2 2 2 . . . * a 5| . . . . . . . . 2 2 2 2 2 2 . . . . . * x 4| . . . . . 2 2 2 2 2 2 . . . . . . . . * i 3| . . . 2 2 2 2 2 . . . . . . . . . . . * s 2| 1 1 P 2 2 . . . . . . . . . . . . . . P = 1 * 1| 1 1 . . . . . . . . . . . . . . . . . * +-------------------------------------- * 1 2 3 4 5 X-axis 10 15 19 * * Point-Line distance is normalized with the Infinity Norm * avoiding square-root code and tightening the test vs the * Manhattan Norm. All math is done on the field of integers. * The latter replaces the initial ">= MAX(...)" test with * "> (ABS(qx-px) + ABS(qy-py))" loosening both inequality * and norm, yielding a broader target line for selection. * The tightest test is employed here for best discrimination * in merging collinear (to grid coordinates) vertex chains * into a larger, spanning vectors within the Lemming editor. if ( ABS((p2.y-p1.y)*(t.x-p1.x)-(t.y-p1.y)*(p2.x-p1.x)) >= (MAX(ABS(p2.x-p1.x), ABS(p2.y-p1.y)))) return(0); if (((p2.x<=p1.x)&&(p1.x<=t.x)) || ((p2.y<=p1.y)&&(p1.y<=t.y))) return(1); if (((t.x<=p1.x)&&(p1.x<=p2.x)) || ((t.y<=p1.y)&&(p1.y<=p2.y))) return(1); if (((p1.x<=p2.x)&&(p2.x<=t.x)) || ((p1.y<=p2.y)&&(p2.y<=t.y))) return(3); if (((t.x<=p2.x)&&(p2.x<=p1.x)) || ((t.y<=p2.y)&&(p2.y<=p1.y))) return(3); return(2); } */ float dist ( float x1, float y1, float x2, float y2) { return sqrt( ((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)) ) ; } int PntOnLine(Vector2f p1, Vector2f p2, Vector2f t, float &where) { float A = t.x - p1.x; float B = t.y - p1.y; float C = p2.x - p1.x; float D = p2.y - p1.y; where = ABS(A * D - C * B) / sqrt(C * C + D * D); if(where > 0.01) return 0; float dot = A * C + B * D; float len_sq = C * C + D * D; where = dot / len_sq; /* float xx,yy; xx = p1.x + where * C; yy = p1.y + where * D; glPointSize(8); glBegin(GL_POINTS); glColor3f(1,0,1); glVertex2f(xx, yy); glEnd(); */ if(where <= 0.0f) // before p1 { // where = param; return 1; /* xx = p1.x; yy = p1.y; where = dist(t.x, t.y, xx, yy);//your distance function return 1;*/ } else if(where >= 1.0f) // after p2 { // where = param; return 3; /* xx = p2.x; yy = p2.y; where = dist(t.x, t.y, xx, yy);//your distance function return 3;*/ } else // between p1 and p2 { // where = param; return 2; // fast exit, don't need where for this case /* xx = p1.x + param * C; yy = p1.y + param * D; where = dist(t.x, t.y, xx, yy);//your distance function return 2;*/ } } class OverlapLine{ public: OverlapLine(Vector2f start, Vector2f end){s=start;e=end;}; bool overlaps(Vector2f p1, Vector2f p2) { int res[2]; float t1,t2; if(p1 == s || p2==s) return 1; if(p1 == e || p2==e) return 3; res[0] = PntOnLine(s,e,p1, t1); // Is p1 on my line? if(res[0] == 0) return false; res[1] = PntOnLine(s,e,p2, t2); // Is p2 on my line? if(res[1] == 0) return false; glPointSize(2); glBegin(GL_POINTS); glColor3f(1,0,0); glVertex2f(s.x, s.y); glColor3f(0,1,0); glVertex2f(e.x, e.y); glEnd(); if(res[0] != res[1]) // expanding both ends { Vector2f i1 = s+(e-s)*t1; Vector2f i2 = s+(e-s)*t2; if(t1 < 0 && t1 < t2) // Move p1 s = p1; else if(t2 < 0) // Move p1 s = p2; if(t1 > 1 && t1 > t2) e = p1; else if(t2 > 1) // e = p2; /* glPointSize(5); glBegin(GL_POINTS); glColor3f(1,0,0); glVertex2f(s.x, s.y); glColor3f(0,1,0); glVertex2f(e.x, e.y); glEnd(); */ return true; } glPointSize(1); glBegin(GL_POINTS); glColor3f(0.5,0.5,0.5); glVertex2f(s.x, s.y); glColor3f(0.5,0.5,0.5); glVertex2f(e.x, e.y); glEnd(); return false; } Vector2f s,e; }; /* * Unfortunately, finding connections via co-incident points detected by * the PointHash is not perfect. For reasons unknown (probably rounding * errors), this is often not enough. We fall-back to finding a nearest * match from any detached points and joining them, with new synthetic * segments. */ bool CuttingPlane::CleanupConnectSegments(float z) { vector<int> vertex_types; vector<int> vertex_counts; vertex_types.resize (vertices.size()); vertex_counts.resize (vertices.size()); // which vertices are referred to, and how much: for (uint i = 0; i < lines.size(); i++) { vertex_types[lines[i].start]++; vertex_types[lines[i].end]--; vertex_counts[lines[i].start]++; vertex_counts[lines[i].end]++; } // the count should be zero for all connected lines, // positive for those ending no-where, and negative for // those starting no-where. std::vector<int> detached_points; for (uint i = 0; i < vertex_types.size(); i++) { if (vertex_types[i]) { #if CUTTING_PLANE_DEBUG cout << "detached point " << i << "\t" << vertex_types[i] << " refs at " << vertices[i].x << "\t" << vertices[i].y << "\n"; #endif detached_points.push_back (i); } } // Lets hope we have an even number of detached points if (detached_points.size() % 2) { cout << "oh dear - an odd number of detached points => an un-pairable impossibility\n"; return false; } // pair them nicely to their matching type for (uint i = 0; i < detached_points.size(); i++) { float nearest_dist_sq = (std::numeric_limits<float>::max)(); int nearest = 0; int n = detached_points[i]; if (n < 0) continue; const Vector2f &p = vertices[n]; for (uint j = i + 1; j < detached_points.size(); j++) { int pt = detached_points[j]; if (pt < 0) continue; // already connected // don't connect a start to a start if (vertex_types[n] == vertex_types[pt]) continue; const Vector2f &q = vertices[pt]; float dist_sq = pow (p.x - q.x, 2) + pow (p.y - q.y, 2); if (dist_sq < nearest_dist_sq) { nearest_dist_sq = dist_sq; nearest = j; } } assert (nearest != 0); // allow points 1mm apart to be joined, not more if (nearest_dist_sq > 1.0) { cout << "oh dear - the nearest connecting point is " << sqrt (nearest_dist_sq) << "mm away - aborting\n"; return false; } #if CUTTING_PLANE_DEBUG cout << "add join of length " << sqrt (nearest_dist_sq) << "\n" ; #endif CuttingPlane::Segment seg(detached_points[nearest], detached_points[i]); if (vertex_types[n] < 0) // start but no end at this point seg.Swap(); AddLine (seg); detached_points[nearest] = -1; } return true; } /* * sometimes we find adjacent polygons with shared boundary * points and lines; these cause grief and slowness in * LinkSegments, so try to identify and join those polygons * now. */ bool CuttingPlane::CleanupSharedSegments(float z) { vector<int> vertex_counts; vertex_counts.resize (vertices.size()); for (uint i = 0; i < lines.size(); i++) { vertex_counts[lines[i].start]++; vertex_counts[lines[i].end]++; } // ideally all points have an entrance and // an exit, if we have co-incident lines, then // we have more than one; do we ? std::vector<int> duplicate_points; for (uint i = 0; i < vertex_counts.size(); i++) { #if CUTTING_PLANE_DEBUG cout << "vtx " << i << " count: " << vertex_counts[i] << "\n"; #endif if (vertex_counts[i] > 2) duplicate_points.push_back (i); } if (duplicate_points.size() == 0) return true; // all sane for (uint i = 0; i < duplicate_points.size(); i++) { std::vector<int> dup_lines; // find all line segments with this point in use for (uint j = 0; j < lines.size(); j++) { if (lines[j].start == duplicate_points[i] || lines[j].end == duplicate_points[i]) dup_lines.push_back (j); } // identify and eliminate identical line segments // NB. hopefully by here dup_lines.size is small. std::vector<int> lines_to_delete; for (uint j = 0; j < dup_lines.size(); j++) { const Segment &jr = lines[dup_lines[j]]; for (uint k = j + 1; k < dup_lines.size(); k++) { const Segment &kr = lines[dup_lines[k]]; if ((jr.start == kr.start && jr.end == kr.end) || (jr.end == kr.start && jr.start == kr.end)) { lines_to_delete.push_back (dup_lines[j]); lines_to_delete.push_back (dup_lines[k]); } } } // we need to remove from the end first to avoid disturbing // the order of removed items std::sort(lines_to_delete.begin(), lines_to_delete.end()); for (int r = lines_to_delete.size() - 1; r >= 0; r--) { #if CUTTING_PLANE_DEBUG cout << "delete co-incident line: " << lines_to_delete[r] << "\n"; #endif lines.erase(lines.begin() + lines_to_delete[r]); } } return true; } /* * Attempt to link all the Segments in 'lines' together. */ bool CuttingPlane::LinkSegments(float z, float Optimization) { if (vertices.size() == 0) return true; if (!CleanupSharedSegments (z)) return false; if (!CleanupConnectSegments (z)) return false; vector<vector<int> > planepoints; planepoints.resize(vertices.size()); for (uint i = 0; i < lines.size(); i++) planepoints[lines[i].start].push_back(i); // Build polygons vector<bool> used; used.resize(lines.size()); for (uint i=0;i>used.size();i++) used[i] = false; for (uint current = 0; current < lines.size(); current++) { if (used[current]) continue; // already used used[current] = true; uint startPoint = lines[current].start; uint endPoint = lines[current].end; Poly poly; poly.points.push_back (endPoint); int count = lines.size()+100; while (endPoint != startPoint && count != 0) // While not closed { const vector<int> &pathsfromhere = planepoints[endPoint]; // Find the next line. if (pathsfromhere.size() == 0) // no where to go ... { // lets get to the bottom of this data set: cout.precision (8); cout.width (12); cout << "\r\npolygon was cut at z " << z << " LinkSegments at vertex " << endPoint; cout << "\n " << vertices.size() << " vertices:\nvtx\tpos x\tpos y\trefs\n"; for (uint i = 0; i < vertices.size(); i++) { int refs = 0, pol = 0; for (uint j = 0; j < lines.size(); j++) { if (lines[j].start == i) { refs++; pol++; } if (lines[j].end == i) { refs++; pol--; } } cout << i << "\t" << vertices[i].x << "\t" << vertices[i].y << "\t" << refs << " pol " << pol; if (refs % 2) // oh dear, a dangling vertex cout << " odd, dangling vertex\n"; cout << "\n"; } cout << "\n " << lines.size() << " lines:\nline\tstart vtx\tend vtx\n"; for (uint i = 0; i < lines.size(); i++) { if (i == endPoint) cout << "problem line:\n"; cout << i << "\t" << lines[i].start << "\t" << lines[i].end << "\n"; } cout << "\n " << vertices.size() << " vertices:\nvtx\tpos x\tpos y\tlinked to\n"; for (uint i = 0; i < planepoints.size(); i++) { if (i == endPoint) cout << "problem vertex:\n"; cout << i << "\t" << vertices[i].x << "\t" << vertices[i].y << "\t"; int j; switch (planepoints[i].size()) { case 0: cout << "nothing - error !\n"; break; case 1: cout << "neighbour: " << planepoints[i][0]; break; default: cout << "Unusual - multiple: \n"; for (j = 0; j < planepoints[i].size(); j++) cout << planepoints[i][j] << " "; cout << " ( " << j << " other vertices )"; break; } cout << "\n"; } // model failure - we will get called recursivelly // for a different z and different cutting plane. return false; } if (pathsfromhere.size() != 1) cout << "Risky co-incident node during shrinking\n"; // TODO: we need to do better here, some idas: // a) calculate the shortest path back to our start node, and // choose that and/or // b) identify all 2+ nodes and if they share start/end // directions eliminate them to join the polygons. int i; for (i = 0; i < pathsfromhere.size() && used[pathsfromhere[i]]; i++); if (i >= pathsfromhere.size()) { cout << "no-where unused to go"; return false; } used[pathsfromhere[i]] = true; const Segment &nextsegment = lines[pathsfromhere[i]]; assert( nextsegment.start == endPoint ); endPoint = nextsegment.end; poly.points.push_back (endPoint); count--; } // Check if loop is complete if (count != 0) polygons.push_back (poly); // This is good else { // We will be called for a slightly different z cout << "\r\nentered loop at LinkSegments " << z; return false; } } // Cleanup polygons CleanupPolygons(Optimization); return true; } /* // Orientate polygons, based on a triangulation struct triangulateio in; struct triangulateio mid; struct triangulateio out; struct triangulateio vorout; * Define the input points. * in.pointlist = 0; in.pointmarkerlist = 0; in.numberofpointattributes = 0; in.pointattributelist = 0; // in.numberofholes = 0; in.numberofregions = 0; in.regionlist = 0; for(unsigned int p=0; p<polygons.size();p++) { uint count = polygons[p].points.size(); in.numberofpoints = count; in.pointlist = (REAL *) malloc(in.numberofpoints * 2 * sizeof(REAL)); in.numberofsegments = count; in.numberofpointattributes = 0; in.segmentlist = (int *) malloc(in.numberofpoints * 2 * sizeof(int)); uint v=0; for(unsigned int i=0; i<count;i++) { in.segmentlist[v] = i; in.pointlist[v++] = vertices[polygons[p].points[i]].x; in.segmentlist[v] = i; in.pointlist[v++] = vertices[polygons[p].points[i]].y; } * in.numberofpointattributes = 1; in.pointlist = (REAL *) malloc(in.numberofpoints * 2 * sizeof(REAL)); in.pointlist[0] = 0.0; in.pointlist[1] = 0.0; in.pointlist[2] = 1.0; in.pointlist[3] = 0.0; in.pointlist[4] = 1.0; in.pointlist[5] = 10.0; in.pointlist[6] = 0.0; in.pointlist[7] = 10.0; in.pointattributelist = (REAL *) malloc(in.numberofpoints * in.numberofpointattributes * sizeof(REAL)); in.pointattributelist[0] = 0.0; in.pointattributelist[1] = 1.0; in.pointattributelist[2] = 11.0; in.pointattributelist[3] = 10.0; in.pointmarkerlist = (int *) malloc(in.numberofpoints * sizeof(int)); in.pointmarkerlist[0] = 0; in.pointmarkerlist[1] = 2; in.pointmarkerlist[2] = 0; in.pointmarkerlist[3] = 0; in.numberofsegments = 0; in.numberofholes = 0; in.numberofregions = 1; in.regionlist = (REAL *) malloc(in.numberofregions * 4 * sizeof(REAL)); in.regionlist[0] = 0.5; in.regionlist[1] = 5.0; */ /* Regional attribute (for whole mesh). * in.regionlist = 0; in.segmentmarkerlist = 0; // in.regionlist[2] = 7.0; * Area constraint that will not be used. * // in.regionlist[3] = 0.1; printf("Input point set:\n\n"); // report ( &in, 1, 0, 0, 0, 0, 0 ); * Make necessary initializations so that Triangle can return a triangulation in `mid' and a Voronoi diagram in `vorout'. * mid.pointlist = (REAL *) NULL; mid.pointattributelist = (REAL *) NULL; mid.pointmarkerlist = (int *) NULL; mid.trianglelist = (int *) NULL; mid.triangleattributelist = (REAL *) NULL; mid.neighborlist = (int *) NULL; mid.segmentlist = (int *) NULL; mid.segmentmarkerlist = (int *) NULL; mid.edgelist = (int *) NULL; mid.edgemarkerlist = (int *) NULL; vorout.pointlist = (REAL *) NULL; vorout.pointattributelist = (REAL *) NULL; vorout.edgelist = (int *) NULL; vorout.normlist = (REAL *) NULL; * Triangulate the points. Switches are chosen to read and write a PSLG (p), preserve the convex hull (c), number everything from zero (z), assign a regional attribute to each element (A), produce an edge list (e), produce a Voronoi diagram (v), produce a triangle neighbor list (n). * // triangulate ( "pczAevn", &in, &mid, &vorout ); triangulate ( "pczAevn", &in, &mid, &vorout );//pAzYYe glBegin(GL_LINES); for(int i=0;i<mid.numberofedges;i++) { if(mid.edgemarkerlist[i] == 0) // Shared edge glColor3f(1,0,0); else if(mid.edgemarkerlist[i] == 1) glColor3f(1.0f,0.5f,0.0f); else glColor3f(1.0f,1.5f,1.0f); Vector3f p1 = Vector3f(mid.pointlist[mid.edgelist[i*2]*2], mid.pointlist[mid.edgelist[i*2]*2+1], z-2); Vector3f p2 = Vector3f(mid.pointlist[mid.edgelist[i*2+1]*2], mid.pointlist[mid.edgelist[i*2+1]*2+1], z-2); glVertex3f(p1.x, p1.y, p1.z); glVertex3f(p2.x, p2.y, p2.z); } glEnd(); for(int i=0;i<mid.numberoftriangles;i++) { glBegin(GL_LINE_LOOP); if(mid.triangleattributelist[i] == 0) // Shared edge glColor3f(0,1,0); else glColor3f(0.0f,0.5f,1.0f); Vector3f p1 = Vector3f(mid.pointlist[mid.trianglelist[i*3]*2], mid.pointlist[mid.trianglelist[i*3]*2+1], z-4); Vector3f p2 = Vector3f(mid.pointlist[mid.trianglelist[i*3+1]*2], mid.pointlist[mid.trianglelist[i*3+1]*2+1], z-4); Vector3f p3 = Vector3f(mid.pointlist[mid.trianglelist[i*3+2]*2], mid.pointlist[mid.trianglelist[i*3+2]*2+1], z-4); glVertex3f(p1.x, p1.y, p1.z); glVertex3f(p2.x, p2.y, p2.z); glVertex3f(p3.x, p3.y, p3.z); glEnd(); } } * printf("Initial triangulation:\n\n"); // report ( &mid, 1, 1, 1, 1, 1, 0 ); printf("Initial Voronoi diagram:\n\n"); // report ( &vorout, 0, 0, 0, 0, 1, 1 ); // Attach area constraints to the triangles in preparation for // refining the triangulation. mid.trianglearealist = (REAL *) malloc(mid.numberoftriangles * sizeof(REAL) ); mid.trianglearealist[0] = 3.0; mid.trianglearealist[1] = 1.0; // Make necessary initializations so that Triangle can return a // triangulation in `out'. out.pointlist = (REAL *) NULL; out.pointattributelist = (REAL *) NULL; out.trianglelist = (int *) NULL; out.triangleattributelist = (REAL *) NULL; // Refine the triangulation according to the attached // triangle area constraints. triangulate ( "prazBP", &mid, &out, (struct triangulateio *) NULL ); */ /* Free all allocated arrays, including those allocated by Triangle. */ /* free(in.pointlist); free(in.pointattributelist); free(in.pointmarkerlist); free(in.regionlist); free(mid.pointlist); free(mid.pointattributelist); free(mid.pointmarkerlist); free(mid.trianglelist); free(mid.triangleattributelist); free(mid.trianglearealist); free(mid.neighborlist); free(mid.segmentlist); free(mid.segmentmarkerlist); free(mid.edgelist); free(mid.edgemarkerlist); free(vorout.pointlist); free(vorout.pointattributelist); free(vorout.edgelist); free(vorout.normlist); free(out.pointlist); free(out.pointattributelist); free(out.trianglelist); free(out.triangleattributelist); */ uint CuttingPlane::selfIntersectAndDivideRecursive(float z, uint startPolygon, uint startVertex, vector<outline> &outlines, const Vector2f endVertex, uint &level) { level++; outline result; for(size_t p=startPolygon; p<offsetPolygons.size();p++) { size_t count = offsetPolygons[p].points.size(); for(size_t v=startVertex; v<count;v++) { for(size_t p2=0; p2<offsetPolygons.size();p2++) { size_t count2 = offsetPolygons[p2].points.size(); for(size_t v2=0; v2<count2;v2++) { if((p==p2) && (v == v2)) // Dont check a point against itself continue; Vector2f P1 = offsetVertices[offsetPolygons[p].points[v]]; Vector2f P2 = offsetVertices[offsetPolygons[p].points[(v+1)%count]]; Vector2f P3 = offsetVertices[offsetPolygons[p2].points[v2]]; Vector2f P4 = offsetVertices[offsetPolygons[p2].points[(v2+1)%count2]]; InFillHit hit; result.push_back(P1); if(P1 != P3 && P2 != P3 && P1 != P4 && P2 != P4) if(IntersectXY(P1,P2,P3,P4,hit)) { if( (hit.p-endVertex).length() < 0.01) { // outlines.push_back(result); // return (v+1)%count; } result.push_back(hit.p); // v=selfIntersectAndDivideRecursive(z, p2, (v2+1)%count2, outlines, hit.p, level); // outlines.push_back(result); // return; } } } } } outlines.push_back(result); level--; return startVertex; } void CuttingPlane::recurseSelfIntersectAndDivide(float z, vector<locator> &EndPointStack, vector<outline> &outlines, vector<locator> &visited) { // pop an entry from the stack. // Trace it till it hits itself // store a outline // When finds splits, store locator on stack and recurse while(EndPointStack.size()) { locator start(EndPointStack.back().p, EndPointStack.back().v, EndPointStack.back().t); visited.push_back(start); // add to visited list EndPointStack.pop_back(); // remove from to-do stack // search for the start point outline result; for(size_t p=start.p; p<offsetPolygons.size();p++) { for(size_t v=start.v; v<offsetPolygons[p].points.size();v++) { Vector2f P1 = offsetVertices[offsetPolygons[p].points[v]]; Vector2f P2 = offsetVertices[offsetPolygons[p].points[(v+1)%offsetPolygons[p].points.size()]]; result.push_back(P1); // store this point for(size_t p2=0; p2<offsetPolygons.size();p2++) { size_t count2 = offsetPolygons[p2].points.size(); for(size_t v2=0; v2<count2;v2++) { if((p==p2) && (v == v2)) // Dont check a point against itself continue; Vector2f P3 = offsetVertices[offsetPolygons[p2].points[v2]]; Vector2f P4 = offsetVertices[offsetPolygons[p2].points[(v2+1)%offsetPolygons[p2].points.size()]]; InFillHit hit; if(P1 != P3 && P2 != P3 && P1 != P4 && P2 != P4) { if(IntersectXY(P1,P2,P3,P4,hit)) { bool alreadyVisited=false; size_t i; for(i=0;i<visited.size();i++) { if(visited[i].p == p && visited[i].v == v) { alreadyVisited = true; break; } } if(alreadyVisited == false) { EndPointStack.push_back(locator(p,v+1,hit.t)); // continue from here later on p=p2;v=v2; // continue along the intersection line Vector2f P1 = offsetVertices[offsetPolygons[p].points[v]]; Vector2f P2 = offsetVertices[offsetPolygons[p].points[(v+1)%offsetPolygons[p].points.size()]]; } result.push_back(hit.p); // Did we hit the starting point? if (start.p == p && start.v == v) // we have a loop { outlines.push_back(result); result.clear(); recurseSelfIntersectAndDivide(z, EndPointStack, outlines, visited); return; } glPointSize(10); glColor3f(1,1,1); glBegin(GL_POINTS); glVertex3f(hit.p.x, hit.p.y, z); glEnd(); } } } } } } } } float angleBetween(Vector2f V1, Vector2f V2) { float dotproduct, lengtha, lengthb, result; dotproduct = (V1.x * V2.x) + (V1.y * V2.y); lengtha = sqrt(V1.x * V1.x + V1.y * V1.y); lengthb = sqrt(V2.x * V2.x + V2.y * V2.y); result = acos( dotproduct / (lengtha * lengthb) ); if(result > 0) result += M_PI; else result -= M_PI; return result; } bool not_equal(const float& val1, const float& val2) { float diff = val1 - val2; return ((-Epsilon > diff) || (diff > Epsilon)); } bool is_equal(const float& val1, const float& val2) { float diff = val1 - val2; return ((-Epsilon <= diff) && (diff <= Epsilon)); } bool intersect(const float& x1, const float& y1, const float& x2, const float& y2, const float& x3, const float& y3, const float& x4, const float& y4, float& ix, float& iy) { float ax = x2 - x1; float bx = x3 - x4; float lowerx; float upperx; float uppery; float lowery; if (ax < float(0.0)) { lowerx = x2; upperx = x1; } else { upperx = x2; lowerx = x1; } if (bx > float(0.0)) { if ((upperx < x4) || (x3 < lowerx)) return false; } else if ((upperx < x3) || (x4 < lowerx)) return false; float ay = y2 - y1; float by = y3 - y4; if (ay < float(0.0)) { lowery = y2; uppery = y1; } else { uppery = y2; lowery = y1; } if (by > float(0.0)) { if ((uppery < y4) || (y3 < lowery)) return false; } else if ((uppery < y3) || (y4 < lowery)) return false; float cx = x1 - x3; float cy = y1 - y3; float d = (by * cx) - (bx * cy); float f = (ay * bx) - (ax * by); if (f > float(0.0)) { if ((d < float(0.0)) || (d > f)) return false; } else if ((d > float(0.0)) || (d < f)) return false; float e = (ax * cy) - (ay * cx); if (f > float(0.0)) { if ((e < float(0.0)) || (e > f)) return false; } else if ((e > float(0.0)) || (e < f)) return false; float ratio = (ax * -by) - (ay * -bx); if (not_equal(ratio,float(0.0))) { ratio = ((cy * -bx) - (cx * -by)) / ratio; ix = x1 + (ratio * ax); iy = y1 + (ratio * ay); } else { if (is_equal((ax * -cy),(-cx * ay))) { ix = x3; iy = y3; } else { ix = x4; iy = y4; } } return true; } CuttingPlaneOptimizer::CuttingPlaneOptimizer(CuttingPlane* cuttingPlane, float z) { Z = z; vector<Poly>* planePolygons = &cuttingPlane->GetPolygons(); vector<Vector2f>* planeVertices = &cuttingPlane->GetVertices(); std::list<Polygon2f*> unsortedPolys; // first add solids. This builds the tree, placing the holes afterwards is easier/faster for(uint p = 0; p < planePolygons->size(); p++) { Poly* poly = &((*planePolygons)[p]); poly->calcHole(*planeVertices); if( !poly->hole ) { Polygon2f* newPoly = new Polygon2f(); newPoly->hole = poly->hole; newPoly->index = p; size_t count = poly->points.size(); for(size_t i=0; i<count;i++) { newPoly->vertices.push_back(((*planeVertices)[poly->points[i]])); } PushPoly(newPoly); } } // then add holes for(uint p = 0; p < planePolygons->size(); p++) { Poly* poly = &((*planePolygons)[p]); if( poly->hole ) { Polygon2f* newPoly = new Polygon2f(); newPoly->hole = poly->hole; size_t count = poly->points.size(); for (size_t i = 0; i < count; i++) { newPoly->vertices.push_back(((*planeVertices)[poly->points[i]])); } PushPoly(newPoly); } } } void CuttingPlaneOptimizer::Dispose() { for(list<Polygon2f*>::iterator pIt =positivePolygons.begin(); pIt!=positivePolygons.end(); pIt++) { delete (*pIt); *pIt = NULL; } } void CuttingPlaneOptimizer::MakeOffsetPolygons(vector<Poly>& polys, vector<Vector2f>& vectors) { for(list<Polygon2f*>::iterator pIt=this->positivePolygons.begin(); pIt!=this->positivePolygons.end(); pIt++) { DoMakeOffsetPolygons(*pIt, polys, vectors); } } void CuttingPlaneOptimizer::DoMakeOffsetPolygons(Polygon2f* pPoly, vector<Poly>& polys, vector<Vector2f>& vectors) { Poly p; for( vector<Vector2f>::iterator pIt = pPoly->vertices.begin(); pIt!=pPoly->vertices.end(); pIt++) { p.points.push_back(vectors.size()); vectors.push_back(*pIt); } p.hole = pPoly->hole; polys.push_back(p); for( list<Polygon2f*>::iterator pIt = pPoly->containedSolids.begin(); pIt!=pPoly->containedSolids.end(); pIt++) { DoMakeOffsetPolygons(*pIt, polys, vectors); } for( list<Polygon2f*>::iterator pIt = pPoly->containedHoles.begin(); pIt!=pPoly->containedHoles.end(); pIt++) { DoMakeOffsetPolygons(*pIt, polys, vectors); } } void CuttingPlaneOptimizer::RetrieveLines(vector<Vector3f>& lines) { for(list<Polygon2f*>::iterator pIt=this->positivePolygons.begin(); pIt!=this->positivePolygons.end(); pIt++) { DoRetrieveLines(*pIt, lines); } } void CuttingPlaneOptimizer::DoRetrieveLines(Polygon2f* pPoly, vector<Vector3f>& lines) { if( pPoly->vertices.size() == 0) return; lines.reserve(lines.size()+pPoly->vertices.size()*2); { vector<Vector2f>::iterator pIt = pPoly->vertices.begin(); lines.push_back(Vector3f(pIt->x, pIt->y, Z)); pIt++; for( ; pIt!=pPoly->vertices.end(); pIt++) { lines.push_back(Vector3f(pIt->x, pIt->y, Z)); lines.push_back(Vector3f(pIt->x, pIt->y, Z)); } lines.push_back(Vector3f(pPoly->vertices.front().x, pPoly->vertices.front().y, Z)); } for( list<Polygon2f*>::iterator pIt = pPoly->containedSolids.begin(); pIt!=pPoly->containedSolids.end(); pIt++) { DoRetrieveLines(*pIt, lines); } for( list<Polygon2f*>::iterator pIt = pPoly->containedHoles.begin(); pIt!=pPoly->containedHoles.end(); pIt++) { DoRetrieveLines(*pIt, lines); } } void CuttingPlaneOptimizer::PushPoly(Polygon2f* poly) { poly->PlaceInList(positivePolygons); } void CuttingPlaneOptimizer::Draw() { float color = 1; Polygon2f::DisplayPolygons(positivePolygons, Z, 0,color,0,1); for(list<Polygon2f*>::iterator pIt =positivePolygons.begin(); pIt!=positivePolygons.end(); pIt++) { Polygon2f::DrawRecursive(*pIt, Z, color); } } void CuttingPlaneOptimizer::Shrink(float distance, list<Polygon2f*> &resPolygons) { for(list<Polygon2f*>::iterator pIt =positivePolygons.begin(); pIt!=positivePolygons.end(); pIt++) { list<Polygon2f*> parentPolygons; (*pIt)->Shrink(distance, parentPolygons, resPolygons); } } void CuttingPlane::ShrinkLogick(float extrudedWidth, float optimization, bool DisplayCuttingPlane, int ShellCount) { CuttingPlaneOptimizer* cpo = new CuttingPlaneOptimizer(this, Z); optimizers.push_back(cpo); CuttingPlaneOptimizer* clippingPlane = new CuttingPlaneOptimizer(Z); cpo->Shrink(extrudedWidth*0.5, clippingPlane->positivePolygons); optimizers.push_back(clippingPlane); for(int outline = 2; outline <= ShellCount+1; outline++) { CuttingPlaneOptimizer* newOutline = new CuttingPlaneOptimizer(Z); optimizers.back()->Shrink(extrudedWidth, newOutline->positivePolygons); optimizers.push_back(newOutline); } optimizers.back()->MakeOffsetPolygons(offsetPolygons, offsetVertices); } void CuttingPlane::ShrinkFast(float distance, float optimization, bool DisplayCuttingPlane, bool useFillets, int ShellCount) { distance*=ShellCount; glColor4f(1,1,1,1); for(size_t p=0; p<polygons.size();p++) { Poly offsetPoly; if(DisplayCuttingPlane) glBegin(GL_LINE_LOOP); size_t count = polygons[p].points.size(); for(size_t i=0; i<count;i++) { Vector2f Na = Vector2f(vertices[polygons[p].points[(i-1+count)%count]].x, vertices[polygons[p].points[(i-1+count)%count]].y); Vector2f Nb = Vector2f(vertices[polygons[p].points[i]].x, vertices[polygons[p].points[i]].y); Vector2f Nc = Vector2f(vertices[polygons[p].points[(i+1)%count]].x, vertices[polygons[p].points[(i+1)%count]].y); Vector2f V1 = (Nb-Na).getNormalized(); Vector2f V2 = (Nc-Nb).getNormalized(); Vector2f biplane = (V2 - V1).getNormalized(); float a = angleBetween(V1,V2); bool convex = V1.cross(V2) < 0; Vector2f p; if(convex) p = Nb+biplane*distance/(cos((M_PI-a)*0.5f)); else p = Nb-biplane*distance/(sin(a*0.5f)); /* if(DisplayCuttingPlane) glEnd(); if(convex) glColor3f(1,0,0); else glColor3f(0,1,0); ostringstream oss; oss << a; renderBitmapString(Vector3f (Nb.x, Nb.y, Z) , GLUT_BITMAP_8_BY_13 , oss.str()); if(DisplayCuttingPlane) glBegin(GL_LINE_LOOP); glColor3f(1,1,0); */ /* Vector2f N1 = Vector2f(-V1.y, V1.x); Vector2f N2 = Vector2f(-V2.y, V2.x); N1.normalise(); N2.normalise(); Vector2f Normal = N1+N2; Normal.normalise(); int vertexNr = polygons[p].points[i]; Vector2f p = vertices[vertexNr] - (Normal * distance);*/ offsetPoly.points.push_back(offsetVertices.size()); offsetVertices.push_back(p); if(DisplayCuttingPlane) glVertex3f(p.x, p.y, Z); } if(DisplayCuttingPlane) glEnd(); offsetPolygons.push_back(offsetPoly); } // CleanupOffsetPolygons(0.1f); // selfIntersectAndDivide(); //make this work for z-tensioner_1off.stl rotated 45d on X axis } #if defined(ENABLE_GPC) && ENABLE_GPC #define RESOLUTION 4 #define FREE(p) {if (p) {free(p); (p)= NULL;}} #endif void CuttingPlane::ShrinkNice(float distance, float optimization, bool DisplayCuttingPlane, bool useFillets, int ShellCount) { #if defined(ENABLE_GPC) && ENABLE_GPC offsetPolygons.clear(); distance *= ShellCount; gpc_polygon solids; solids.num_contours = 0; gpc_polygon holes; holes.num_contours = 0; gpc_polygon all_holes; gpc_polygon all_solids; for(int p=0; p<polygons.size();p++) { polygons[p].calcHole(vertices); Poly offsetPoly; uint count = polygons[p].points.size(); for(int i=0; i<count;i++) { Vector2f Na = Vector2f(vertices[polygons[p].points[(i-1+count)%count]].x, vertices[polygons[p].points[(i-1+count)%count]].y); Vector2f Nb = Vector2f(vertices[polygons[p].points[i%count]].x, vertices[polygons[p].points[i%count]].y); Vector2f V1 = (Nb-Na); Vector2f delta = V1.getNormalized(); Vector2f N1 = Vector2f(-delta.y, delta.x); vector<Vector2f> LineOutline; Vector2f P1 = Na+N1*distance; Vector2f P3 = Nb-N1*distance; Vector2f P4 = Nb+N1*distance; float a = atan2( P1.y-Na.y , P1.x-Na.x ); float step = M_PI/RESOLUTION; int steps=RESOLUTION+1; Vector2f point; while(steps--) { point.x = Na.x+cos(a)*distance; point.y = Na.y+sin(a)*distance; LineOutline.push_back(point); a+=step; } LineOutline.push_back(P3); LineOutline.push_back(P4); gpc_vertex_list *outline = new gpc_vertex_list; outline->vertex = new gpc_vertex[LineOutline.size()]; if(polygons[p].hole == true) for(int v=0;v<LineOutline.size();v++) { outline->vertex[LineOutline.size()-1-v].x = LineOutline[v].x; outline->vertex[LineOutline.size()-1-v].y = LineOutline[v].y; } else for(int v=0;v<LineOutline.size();v++) { outline->vertex[v].x = LineOutline[v].x; outline->vertex[v].y = LineOutline[v].y; } outline->num_vertices = LineOutline.size(); LineOutline.clear(); // add this outline to the boolean solution if(polygons[p].hole == true) { if(holes.num_contours == 0) { holes.num_contours = 1; holes.hole = new int; *holes.hole = 1; holes.contour = outline; } else { gpc_polygon new_hole; new_hole.num_contours = 1; new_hole.hole = new int; *new_hole.hole = 1; new_hole.contour = outline; gpc_polygon_clip(GPC_UNION, &holes, &new_hole, &all_holes); holes=all_holes; delete new_hole.hole; delete new_hole.contour->vertex; delete new_hole.contour; } } else // it's a solid { if(solids.num_contours == 0) { solids.num_contours = 1; solids.hole = new int; *solids.hole = 0; solids.contour = outline; } else { gpc_add_contour(&solids, outline, 0); gpc_polygon new_solid; new_solid.num_contours = 1; new_solid.hole = new int; *new_solid.hole = 0; new_solid.contour = outline; gpc_polygon_clip(GPC_UNION, &solids, &new_solid, &all_solids); solids=all_solids; delete new_solid.hole; delete new_solid.contour->vertex; delete new_solid.contour; } } } // for all segments }// for all polygons // delete the largest of the solids outlines, and the smallest of the holes outlines for(int p=0;p<solids.num_contours;p++) { // if(solids.hole[p] == 0) // seeme we have to check everything { if(!VertexIsOutsideOriginalPolygon( Vector2f(solids.contour[p].vertex[0].x, solids.contour[p].vertex[0].y), Z)) { FREE(solids.contour[p].vertex); // FREE(solids.hole); // FREE(solids.contour); solids.num_contours--; for(int c=p;c<solids.num_contours;c++) { solids.contour[c] =solids.contour[c+1]; solids.hole[c] = solids.hole[c+1]; } p--; } } } // delete the largest of the solids outlines, and the smallest of the holes outlines for(int p=0;p<holes.num_contours;p++) { if(holes.hole[p] == 1) { FREE(holes.contour[p].vertex); // FREE(solids.hole); // FREE(solids.contour); holes.num_contours--; for(int c=p;c<holes.num_contours;c++) { holes.contour[c] =holes.contour[c+1]; holes.hole[c] = holes.hole[c+1]; } p--; } } gpc_polygon poly_res; gpc_polygon_clip(GPC_DIFF, &solids, &holes, &poly_res); offsetPolygons.clear(); offsetVertices.clear(); glLineWidth(4); for(int p=0;p<poly_res.num_contours;p++) { glBegin(GL_LINE_LOOP); Poly pol; for(int v=0;v<poly_res.contour[p].num_vertices;v++) { pol.points.push_back(offsetVertices.size()); offsetVertices.push_back(Vector2f(poly_res.contour[p].vertex[v].x, poly_res.contour[p].vertex[v].y)); glVertex3f(poly_res.contour[p].vertex[v].x, poly_res.contour[p].vertex[v].y, Z); } offsetPolygons.push_back(pol); glEnd(); } glLineWidth(1); CleanupOffsetPolygons(0.1f); #endif } /* bool Point2f::FindNextPoint(Point2f* origin, Point2f* destination, bool expansion) { assert(ConnectedPoints.size() >= 2 ); if( ConnectedPoints.size() == 2 ) { if( ConnectedPoints.front() == origin ) { destination = ConnectedPoints.back(); ConnectedPoints.clear(); return true; } else { if( ConnectedPoints.back() == origin ) { destination = ConnectedPoints.front(); ConnectedPoints.clear(); return true; } destination = NULL; return false; } } float originAngle = AngleTo(origin); float minAngle = PI*4; float maxAngle = -PI*4; for(list<Point2f*>::iterator it = ConnectedPoints.begin(); it != ConnectedPoints.end(); ) { if( *it != origin ) { float angle = AngleTo(*it)-originAngle; if( expansion ) { if( angle > 0 ) angle -= PI*2; if( angle < minAngle ) { minAngle = angle; destination = *it; } } else { if( angle < 0 ) angle += PI*2; if( angle > maxAngle ) { maxAngle = angle; destination = *it; } } it++; } else { it = ConnectedPoints.erase(it); } } ConnectedPoints.remove(destination); return true; } float Point2f::AngleTo(Point2f* point) { return atan2f(Point.y-point->Point.y, Point.x-point->Point.x); } */ /*********************************************************************************************/ /*** ***/ /*** Bisector/Fillet/Boolean version ***/ /*** ***/ /*********************************************************************************************/ /*void CuttingPlane::Shrink(float distance, float z, bool DisplayCuttingPlane, bool useFillets) { }*/ /* * We bucket space up into a grid of size 1/mult and generate hash values * from this. We use a margin of 2 * float_epsilon to detect values near * the bottom or right hand edge of the bucket, and check the adjacent * grid entries for similar values within float_epsilon of us. */ struct PointHash::Impl { typedef std::vector< std::pair< uint, Vector2f > > IdxPointList; hash_map<uint, IdxPointList> points; typedef hash_map<uint, IdxPointList>::iterator iter; typedef hash_map<uint, IdxPointList>::const_iterator const_iter; static uint GetHashes (uint *hashes, float x, float y) { uint xh = x * mult; uint yh = y * mult; int xt, yt; uint c = 0; hashes[c++] = xh + yh * 1000000; if ((xt = (uint)((x + 2*PointHash::float_epsilon) * PointHash::mult) - xh)) hashes[c++] = xh + xt + yh * 1000000; if ((yt = (uint)((y + 2*PointHash::float_epsilon) * PointHash::mult) - yh)) hashes[c++] = xh + (yt + yh) * 1000000; if (xt && yt) hashes[c++] = xh + xt + (yt + yh) * 1000000; #if CUTTING_PLANE_DEBUG > 1 cout << "hashes for " << x << ", " << y << " count: " << c << ": "; for (int i = 0; i < c; i++) cout << hashes[i] << ", "; cout << "\n"; #endif return c; } }; const float PointHash::mult = 100; const float PointHash::float_epsilon = 0.001; PointHash::PointHash() { impl = new Impl(); } PointHash::~PointHash() { clear(); delete impl; } PointHash::PointHash(const PointHash &copy) { impl = new Impl(); Impl::const_iter it; for (it = copy.impl->points.begin(); it != copy.impl->points.end(); it++) impl->points[it->first] = it->second; } void PointHash::clear() { impl->points.clear(); } int PointHash::IndexOfPoint(const Vector2f &p) { uint hashes[4]; uint c = Impl::GetHashes (hashes, p.x, p.y); for (uint i = 0; i < c; i++) { Impl::const_iter iter = impl->points.find (hashes[i]); if (iter == impl->points.end()) continue; const Impl::IdxPointList &pts = iter->second; for (uint j = 0; j < pts.size(); j++) { const Vector2f &v = pts[j].second; if( ABS(v.x - p.x) < float_epsilon && ABS(v.y - p.y) < float_epsilon) return pts[j].first; #if CUTTING_PLANE_DEBUG > 1 else if( ABS(v.x-p.x) < 0.01 && ABS(v.y-p.y) < 0.01) cout << "hash " << hashes[i] << " missed idx " << pts[j].first << " by " << (v.x - p.x) << ", " << (v.y - p.y) << " hash: " << v.x << ", " << v.y << " vs. p " << p.x << ", " << p.y << "\n"; #endif } } return -1; } void PointHash::InsertPoint (uint idx, const Vector2f &p) { uint hashes[4]; int c = Impl::GetHashes (hashes, p.x, p.y); for (int i = 0; i < c; i++) { Impl::IdxPointList &pts = impl->points[hashes[i]]; pts.push_back (pair<uint, Vector2f>( idx, p )); #if CUTTING_PLANE_DEBUG > 1 cout << "insert " << hashes[i] << " idx " << idx << " vs. p " << p.x << ", " << p.y << "\n"; #endif } } void CuttingPlane::AddLine(const Segment &line) { lines.push_back(line); } int CuttingPlane::RegisterPoint(const Vector2f &p) { int res; if( (res = points.IndexOfPoint(p)) >= 0) { #if CUTTING_PLANE_DEBUG > 1 cout << "found vertex idx " << res << " at " << p.x << ", " << p.y << "\n"; #endif return res; } res = vertices.size(); vertices.push_back(p); #if CUTTING_PLANE_DEBUG > 1 cout << "insert vertex idx " << res << " at " << p.x << ", " << p.y << "\n"; #endif points.InsertPoint(res, p); return res; } bool CuttingPlane::VertexIsOutsideOriginalPolygon( Vector2f point, float z) { // Shoot a ray along +X and count the number of intersections. // If n_intersections is euqal, return true, else return false Vector2f EndP(point.x+10000, point.y); int intersectcount = 0; for(size_t p=0; p<polygons.size();p++) { size_t count = polygons[p].points.size(); for(size_t i=0; i<count;i++) { Vector2f P1 = Vector2f( vertices[polygons[p].points[(i-1+count)%count]] ); Vector2f P2 = Vector2f( vertices[polygons[p].points[i]]); if(P1.y == P2.y) // Skip hortisontal lines, we can't intersect with them, because the test line in horitsontal continue; InFillHit hit; if(IntersectXY(point,EndP,P1,P2,hit)) intersectcount++; } } return intersectcount%2; } #define RESOLUTION 4 #define FREE(p) {if (p) {free(p); (p)= NULL;}} void CuttingPlane::Draw(bool DrawVertexNumbers, bool DrawLineNumbers, bool DrawOutlineNumbers, bool DrawCPLineNumbers, bool DrawCPVertexNumbers) { // Draw the raw poly's in red glColor3f(1,0,0); for(size_t p=0; p<polygons.size();p++) { glLineWidth(1); glBegin(GL_LINE_LOOP); for(size_t v=0; v<polygons[p].points.size();v++) glVertex3f(vertices[polygons[p].points[v]].x, vertices[polygons[p].points[v]].y, Z); glEnd(); if(DrawOutlineNumbers) { ostringstream oss; oss << p; renderBitmapString(Vector3f(polygons[p].center.x, polygons[p].center.y, Z) , GLUT_BITMAP_8_BY_13 , oss.str()); } } for(size_t o=1;o<optimizers.size()-1;o++) { optimizers[o]->Draw(); } glPointSize(1); glBegin(GL_POINTS); glColor4f(1,0,0,1); for(size_t v=0;v<vertices.size();v++) { glVertex3f(vertices[v].x, vertices[v].y, Z); } glEnd(); glColor4f(1,1,0,1); glPointSize(3); glBegin(GL_POINTS); for(size_t p=0;p<polygons.size();p++) { for(size_t v=0;v<polygons[p].points.size();v++) { glVertex3f(vertices[polygons[p].points[v]].x, vertices[polygons[p].points[v]].y, Z); } } glEnd(); if(DrawVertexNumbers) { for(size_t v=0;v<vertices.size();v++) { ostringstream oss; oss << v; renderBitmapString(Vector3f (vertices[v].x, vertices[v].y, Z) , GLUT_BITMAP_8_BY_13 , oss.str()); } } if(DrawLineNumbers) { for(size_t l=0;l<lines.size();l++) { ostringstream oss; oss << l; Vector2f Center = (vertices[lines[l].start]+vertices[lines[l].end]) *0.5f; glColor4f(1,0.5,0,1); renderBitmapString(Vector3f (Center.x, Center.y, Z) , GLUT_BITMAP_8_BY_13 , oss.str()); } } if(DrawCPVertexNumbers) { for(size_t p=0; p<polygons.size();p++) { for(size_t v=0; v<polygons[p].points.size();v++) { ostringstream oss; oss << v; renderBitmapString(Vector3f(vertices[polygons[p].points[v]].x, vertices[polygons[p].points[v]].y, Z) , GLUT_BITMAP_8_BY_13 , oss.str()); } } } if(DrawCPLineNumbers) { Vector3f loc; loc.z = Z; for(size_t p=0; p<polygons.size();p++) { for(size_t v=0; v<polygons[p].points.size();v++) { loc.x = (vertices[polygons[p].points[v]].x + vertices[polygons[p].points[(v+1)%polygons[p].points.size()]].x) /2; loc.y = (vertices[polygons[p].points[v]].y + vertices[polygons[p].points[(v+1)%polygons[p].points.size()]].y) /2; ostringstream oss; oss << v; renderBitmapString(loc, GLUT_BITMAP_8_BY_13 , oss.str()); } } } // Pathfinder a(offsetPolygons, offsetVertices); } void STL::OptimizeRotation() { // Find the axis that has the largest surface // Rotate to point this face towards -Z // if dist center <|> 0.1 && Normal points towards, add area Vector3f AXIS_VECTORS[3]; AXIS_VECTORS[0] = Vector3f(1,0,0); AXIS_VECTORS[1] = Vector3f(0,1,0); AXIS_VECTORS[2] = Vector3f(0,0,1); float area[6]; for(uint i=0;i<6;i++) area[i] = 0.0f; for(size_t i=0;i<triangles.size();i++) { triangles[i].axis = NOT_ALIGNED; for(size_t triangleAxis=0;triangleAxis<3;triangleAxis++) { if (triangles[i].Normal.cross(AXIS_VECTORS[triangleAxis]).length() < 0.1) { int positive=0; if(triangles[i].Normal[triangleAxis] > 0)// positive positive=1; AXIS axisNr = (AXIS)(triangleAxis*2+positive); triangles[i].axis = axisNr; if( ! (ABS(Min[triangleAxis]-triangles[i].A[triangleAxis]) < 1.1 || ABS(Max[triangleAxis]-triangles[i].A[triangleAxis]) < 1.1) ) // not close to boundingbox edges? { triangles[i].axis = NOT_ALIGNED; // Not close to bounding box break; } area[axisNr] += triangles[i].area(); break; } } } AXIS down = NOT_ALIGNED; float LargestArea = 0; for(uint i=0;i<6;i++) { if(area[i] > LargestArea) { LargestArea = area[i]; down = (AXIS)i; } } switch(down) { case NEGX: RotateObject(Vector3f(0,-1,0), M_PI/2.0f); break; case POSX: RotateObject(Vector3f(0,1,0), M_PI/2.0f); break; case NEGY: RotateObject(Vector3f(1,0,0), M_PI/2.0f); break; case POSY: RotateObject(Vector3f(-1,0,0), M_PI/2.0f); break; case POSZ: RotateObject(Vector3f(1,0,0), M_PI); break; } CenterAroundXY(); } void STL::RotateObject(Vector3f axis, float angle) { Vector3f min,max; min.x = min.y = min.z = 99999999.0f; max.x = max.y = max.z = -99999999.0f; for(size_t i=0; i<triangles.size() ; i++) { triangles[i].Normal = triangles[i].Normal.rotate(angle, axis.x, axis.y, axis.z); triangles[i].A = triangles[i].A.rotate(angle, axis.x, axis.y, axis.z); triangles[i].B = triangles[i].B.rotate(angle, axis.x, axis.y, axis.z); triangles[i].C = triangles[i].C.rotate(angle, axis.x, axis.y, axis.z); min.x = MIN(min.x, triangles[i].A.x); min.y = MIN(min.y, triangles[i].A.y); min.z = MIN(min.z, triangles[i].A.z); max.x = MAX(max.x, triangles[i].A.x); max.y = MAX(max.y, triangles[i].A.y); max.z = MAX(max.z, triangles[i].A.z); min.x = MIN(min.x, triangles[i].B.x); min.y = MIN(min.y, triangles[i].B.y); min.z = MIN(min.z, triangles[i].B.z); max.x = MAX(max.x, triangles[i].B.x); max.y = MAX(max.y, triangles[i].B.y); max.z = MAX(max.z, triangles[i].B.z); min.x = MIN(min.x, triangles[i].C.x); min.y = MIN(min.y, triangles[i].C.y); min.z = MIN(min.z, triangles[i].C.z); max.x = MAX(max.x, triangles[i].C.x); max.y = MAX(max.y, triangles[i].C.y); max.z = MAX(max.z, triangles[i].C.z); } Min = min; Max = max; } float Triangle::area() { return ( ((C-A).cross(B-A)).length() ); } void CuttingPlane::CleanupPolygons (float Optimization) { float allowedError = Optimization; for (size_t p = 0; p < polygons.size(); p++) { for (size_t v = 0; v < polygons[p].points.size() + 1; ) { Vector2f p1 = vertices[polygons[p].points[(v-1+polygons[p].points.size())%polygons[p].points.size()]]; Vector2f p2 = vertices[polygons[p].points[v%polygons[p].points.size()]]; Vector2f p3 = vertices[polygons[p].points[(v+1)%polygons[p].points.size()]]; Vector2f v1 = (p2-p1); Vector2f v2 = (p3-p2); v1.normalize(); v2.normalize(); if ((v1-v2).lengthSquared() < allowedError) polygons[p].points.erase(polygons[p].points.begin()+(v%polygons[p].points.size())); else v++; } } } void CuttingPlane::CleanupOffsetPolygons(float Optimization) { float allowedError = Optimization; for(size_t p=0;p<offsetPolygons.size();p++) { for(size_t v=0;v<offsetPolygons[p].points.size();) { Vector2f p1 =offsetVertices[offsetPolygons[p].points[(v-1+offsetPolygons[p].points.size())%offsetPolygons[p].points.size()]]; Vector2f p2 =offsetVertices[offsetPolygons[p].points[v]]; Vector2f p3 =offsetVertices[offsetPolygons[p].points[(v+1)%offsetPolygons[p].points.size()]]; Vector2f v1 = (p2-p1); Vector2f v2 = (p3-p2); v1.normalize(); v2.normalize(); if((v1-v2).lengthSquared() < allowedError) { offsetPolygons[p].points.erase(offsetPolygons[p].points.begin()+v); } else v++; } } } void STL::CenterAroundXY() { Vector3f displacement = -Min; for(size_t i=0; i<triangles.size() ; i++) { triangles[i].A = triangles[i].A + displacement; triangles[i].B = triangles[i].B + displacement; triangles[i].C = triangles[i].C + displacement; } Max += displacement; Min += displacement; CalcBoundingBoxAndZoom(); } void Poly::calcHole(vector<Vector2f> &offsetVertices) { if(points.size() == 0) return; // hole is undefined Vector2f p(-6000, -6000); int v=0; center = Vector2f(0,0); for(size_t vert=0;vert<points.size();vert++) { center += offsetVertices[points[vert]]; if(offsetVertices[points[vert]].x > p.x) { p = offsetVertices[points[vert]]; v=vert; } else if(offsetVertices[points[vert]].x == p.x && offsetVertices[points[vert]].y > p.y) { p.y = offsetVertices[points[vert]].y; v=vert; } } center /= points.size(); // we have the x-most vertex (with the highest y if there was a contest), v Vector2f V1 = offsetVertices[points[(v-1+points.size())%points.size()]]; Vector2f V2 = offsetVertices[points[v]]; Vector2f V3 = offsetVertices[points[(v+1)%points.size()]]; Vector2f Va=V2-V1; Vector2f Vb=V3-V1; hole = Va.cross(Vb) > 0; }
[ "repsnapper@686d4eb6-aa70-4f30-b8fa-ee57029aed71", "Logick@686d4eb6-aa70-4f30-b8fa-ee57029aed71", "mmeeks@686d4eb6-aa70-4f30-b8fa-ee57029aed71", "Rick@686d4eb6-aa70-4f30-b8fa-ee57029aed71", "michael@686d4eb6-aa70-4f30-b8fa-ee57029aed71", "joaz@686d4eb6-aa70-4f30-b8fa-ee57029aed71", "fcrick@686d4eb6-aa70-4f30-b8fa-ee57029aed71" ]
[ [ [ 1, 14 ], [ 16, 20 ], [ 22, 22 ], [ 28, 32 ], [ 43, 43 ], [ 57, 63 ], [ 72, 77 ], [ 90, 93 ], [ 97, 98 ], [ 100, 114 ], [ 117, 133 ], [ 135, 135 ], [ 151, 153 ], [ 155, 161 ], [ 164, 167 ], [ 172, 174 ], [ 178, 182 ], [ 187, 194 ], [ 196, 196 ], [ 198, 202 ], [ 223, 223 ], [ 231, 232 ], [ 235, 235 ], [ 237, 237 ], [ 239, 239 ], [ 245, 261 ], [ 312, 319 ], [ 322, 323 ], [ 326, 326 ], [ 328, 351 ], [ 353, 377 ], [ 382, 387 ], [ 389, 390 ], [ 392, 408 ], [ 410, 427 ], [ 429, 438 ], [ 446, 446 ], [ 450, 450 ], [ 452, 452 ], [ 455, 455 ], [ 457, 457 ], [ 459, 459 ], [ 461, 461 ], [ 479, 479 ], [ 495, 495 ], [ 497, 498 ], [ 500, 504 ], [ 506, 507 ], [ 509, 530 ], [ 532, 534 ], [ 536, 536 ], [ 539, 539 ], [ 541, 541 ], [ 543, 544 ], [ 546, 547 ], [ 549, 551 ], [ 553, 557 ], [ 559, 559 ], [ 561, 569 ], [ 574, 774 ], [ 776, 777 ], [ 782, 782 ], [ 793, 793 ], [ 795, 795 ], [ 800, 802 ], [ 805, 808 ], [ 810, 812 ], [ 814, 858 ], [ 860, 861 ], [ 867, 875 ], [ 879, 879 ], [ 881, 882 ], [ 885, 886 ], [ 890, 892 ], [ 895, 896 ], [ 898, 899 ], [ 901, 904 ], [ 909, 910 ], [ 913, 916 ], [ 918, 918 ], [ 920, 920 ], [ 926, 926 ], [ 929, 929 ], [ 938, 944 ], [ 946, 973 ], [ 976, 981 ], [ 983, 984 ], [ 988, 989 ], [ 997, 1000 ], [ 1002, 1005 ], [ 1007, 1009 ], [ 1011, 1029 ], [ 1031, 1032 ], [ 1035, 1036 ], [ 1038, 1041 ], [ 1044, 1045 ], [ 1049, 1054 ], [ 1056, 1057 ], [ 1059, 1089 ], [ 1091, 1114 ], [ 1116, 1121 ], [ 1123, 1128 ], [ 1130, 1135 ], [ 1137, 1175 ], [ 1177, 1177 ], [ 1179, 1209 ], [ 1211, 1218 ], [ 1220, 1250 ], [ 1252, 1271 ], [ 1273, 1385 ], [ 1429, 1429 ], [ 1559, 1559 ], [ 1561, 1562 ], [ 1574, 1577 ], [ 1580, 1580 ], [ 1589, 1590 ], [ 1592, 1592 ], [ 1599, 1599 ], [ 1653, 1653 ], [ 1679, 1680 ], [ 1683, 1683 ], [ 1687, 1687 ], [ 1690, 1691 ], [ 1693, 1703 ], [ 1705, 1717 ], [ 1719, 1723 ], [ 1725, 1731 ], [ 1733, 1767 ], [ 1769, 1775 ], [ 1777, 1794 ], [ 1796, 1842 ], [ 1844, 1903 ], [ 2030, 2047 ], [ 2049, 2049 ], [ 2053, 2053 ], [ 2055, 2055 ], [ 2059, 2059 ], [ 2084, 2084 ], [ 2092, 2092 ], [ 2095, 2095 ], [ 2106, 2106 ], [ 2127, 2127 ], [ 2129, 2129 ], [ 2137, 2137 ], [ 2139, 2139 ], [ 2218, 2218 ], [ 2248, 2248 ], [ 2289, 2289 ], [ 2308, 2308 ], [ 2337, 2338 ], [ 2398, 2399 ], [ 2624, 2624 ], [ 2630, 2630 ], [ 2668, 2668 ], [ 2670, 2681 ], [ 2822, 2829 ], [ 2831, 2831 ], [ 2834, 2834 ], [ 2837, 2849 ], [ 2851, 2852 ], [ 2854, 2854 ], [ 2863, 2864 ], [ 2872, 2872 ], [ 2893, 2893 ], [ 2895, 2896 ], [ 2899, 2900 ], [ 2909, 2909 ], [ 2912, 2915 ], [ 2918, 2918 ], [ 2920, 2920 ], [ 2950, 2967 ], [ 2969, 2970 ], [ 2973, 2973 ], [ 2977, 2982 ], [ 2985, 2986 ], [ 2988, 2991 ], [ 2993, 2996 ], [ 2998, 2998 ], [ 3000, 3000 ], [ 3003, 3023 ], [ 3025, 3048 ], [ 3051, 3057 ], [ 3059, 3059 ], [ 3062, 3062 ], [ 3064, 3064 ], [ 3068, 3074 ], [ 3077, 3082 ], [ 3084, 3084 ], [ 3087, 3087 ], [ 3089, 3089 ], [ 3093, 3113 ], [ 3115, 3123 ], [ 3126, 3126 ], [ 3131, 3132 ], [ 3135, 3135 ], [ 3138, 3138 ], [ 3140, 3141 ], [ 3143, 3143 ], [ 3145, 3147 ] ], [ [ 15, 15 ], [ 23, 23 ], [ 26, 27 ], [ 64, 69 ], [ 115, 116 ], [ 136, 150 ], [ 162, 163 ], [ 169, 171 ], [ 175, 177 ], [ 195, 195 ], [ 197, 197 ], [ 203, 222 ], [ 224, 230 ], [ 233, 234 ], [ 236, 236 ], [ 238, 238 ], [ 240, 244 ], [ 262, 277 ], [ 279, 279 ], [ 281, 281 ], [ 283, 311 ], [ 352, 352 ], [ 378, 381 ], [ 388, 388 ], [ 391, 391 ], [ 409, 409 ], [ 428, 428 ], [ 439, 441 ], [ 447, 449 ], [ 451, 451 ], [ 453, 454 ], [ 456, 456 ], [ 458, 458 ], [ 460, 460 ], [ 462, 470 ], [ 474, 478 ], [ 480, 483 ], [ 485, 485 ], [ 487, 488 ], [ 490, 494 ], [ 496, 496 ], [ 499, 499 ], [ 505, 505 ], [ 508, 508 ], [ 531, 531 ], [ 540, 540 ], [ 570, 573 ], [ 775, 775 ], [ 778, 780 ], [ 783, 792 ], [ 794, 794 ], [ 796, 799 ], [ 803, 804 ], [ 809, 809 ], [ 865, 866 ], [ 876, 878 ], [ 893, 894 ], [ 905, 908 ], [ 911, 912 ], [ 921, 925 ], [ 927, 927 ], [ 930, 931 ], [ 933, 935 ], [ 937, 937 ], [ 945, 945 ], [ 974, 975 ], [ 985, 986 ], [ 991, 991 ], [ 993, 993 ], [ 995, 996 ], [ 1010, 1010 ], [ 1033, 1034 ], [ 1042, 1042 ], [ 1046, 1046 ], [ 1090, 1090 ], [ 1433, 1433 ], [ 1469, 1469 ], [ 1569, 1570 ], [ 1573, 1573 ], [ 1582, 1582 ], [ 1594, 1594 ], [ 1597, 1597 ], [ 1652, 1652 ], [ 1671, 1671 ], [ 1675, 1675 ], [ 1677, 1678 ], [ 1684, 1684 ], [ 1686, 1686 ], [ 1688, 1688 ], [ 1692, 1692 ], [ 1904, 2008 ], [ 2011, 2014 ], [ 2016, 2029 ], [ 2048, 2048 ], [ 2050, 2052 ], [ 2054, 2054 ], [ 2056, 2058 ], [ 2060, 2083 ], [ 2085, 2091 ], [ 2093, 2094 ], [ 2096, 2105 ], [ 2107, 2126 ], [ 2128, 2128 ], [ 2130, 2136 ], [ 2138, 2138 ], [ 2140, 2171 ], [ 2173, 2191 ], [ 2193, 2200 ], [ 2202, 2217 ], [ 2219, 2247 ], [ 2249, 2288 ], [ 2290, 2307 ], [ 2309, 2336 ], [ 2339, 2397 ], [ 2400, 2401 ], [ 2403, 2404 ], [ 2602, 2623 ], [ 2625, 2629 ], [ 2631, 2667 ], [ 2741, 2741 ], [ 2743, 2744 ], [ 2746, 2746 ], [ 2751, 2751 ], [ 2772, 2775 ], [ 2794, 2797 ], [ 2799, 2799 ], [ 2801, 2801 ], [ 2809, 2809 ], [ 2811, 2811 ], [ 2817, 2817 ], [ 2819, 2821 ], [ 2830, 2830 ], [ 2832, 2833 ], [ 2835, 2836 ], [ 2853, 2853 ], [ 2855, 2862 ], [ 2865, 2871 ], [ 2873, 2892 ], [ 2894, 2894 ], [ 2897, 2898 ], [ 2901, 2908 ], [ 2910, 2911 ], [ 2916, 2917 ], [ 2919, 2919 ], [ 2921, 2949 ], [ 2971, 2971 ], [ 2974, 2974 ], [ 3024, 3024 ], [ 3049, 3050 ], [ 3060, 3060 ], [ 3083, 3083 ], [ 3085, 3086 ], [ 3088, 3088 ], [ 3090, 3092 ], [ 3114, 3114 ], [ 3127, 3127 ], [ 3130, 3130 ], [ 3133, 3134 ], [ 3136, 3137 ], [ 3139, 3139 ], [ 3142, 3142 ], [ 3144, 3144 ], [ 3148, 3148 ], [ 3150, 3153 ] ], [ [ 21, 21 ], [ 24, 25 ], [ 44, 56 ], [ 70, 71 ], [ 78, 89 ], [ 94, 96 ], [ 99, 99 ], [ 134, 134 ], [ 320, 321 ], [ 324, 325 ], [ 327, 327 ], [ 471, 473 ], [ 538, 538 ], [ 545, 545 ], [ 548, 548 ], [ 552, 552 ], [ 781, 781 ], [ 859, 859 ], [ 862, 864 ], [ 880, 880 ], [ 883, 884 ], [ 887, 889 ], [ 897, 897 ], [ 900, 900 ], [ 917, 917 ], [ 919, 919 ], [ 928, 928 ], [ 932, 932 ], [ 936, 936 ], [ 982, 982 ], [ 987, 987 ], [ 990, 990 ], [ 992, 992 ], [ 994, 994 ], [ 1001, 1001 ], [ 1006, 1006 ], [ 1030, 1030 ], [ 1037, 1037 ], [ 1043, 1043 ], [ 1047, 1048 ], [ 1055, 1055 ], [ 1058, 1058 ], [ 1115, 1115 ], [ 1122, 1122 ], [ 1129, 1129 ], [ 1136, 1136 ], [ 1176, 1176 ], [ 1178, 1178 ], [ 1210, 1210 ], [ 1219, 1219 ], [ 1251, 1251 ], [ 1272, 1272 ], [ 1386, 1428 ], [ 1430, 1432 ], [ 1434, 1468 ], [ 1470, 1558 ], [ 1560, 1560 ], [ 1563, 1568 ], [ 1571, 1572 ], [ 1578, 1579 ], [ 1581, 1581 ], [ 1583, 1588 ], [ 1591, 1591 ], [ 1593, 1593 ], [ 1595, 1596 ], [ 1598, 1598 ], [ 1600, 1651 ], [ 1654, 1670 ], [ 1672, 1674 ], [ 1676, 1676 ], [ 1681, 1682 ], [ 1685, 1685 ], [ 1689, 1689 ], [ 1704, 1704 ], [ 1732, 1732 ], [ 1768, 1768 ], [ 1776, 1776 ], [ 1795, 1795 ], [ 1843, 1843 ], [ 2009, 2010 ], [ 2015, 2015 ], [ 2172, 2172 ], [ 2192, 2192 ], [ 2201, 2201 ], [ 2601, 2601 ], [ 2669, 2669 ], [ 2682, 2719 ], [ 2721, 2740 ], [ 2742, 2742 ], [ 2745, 2745 ], [ 2747, 2750 ], [ 2752, 2771 ], [ 2776, 2793 ], [ 2798, 2798 ], [ 2800, 2800 ], [ 2802, 2808 ], [ 2810, 2810 ], [ 2812, 2816 ], [ 2818, 2818 ], [ 2972, 2972 ], [ 2975, 2976 ], [ 2983, 2984 ], [ 2987, 2987 ], [ 2992, 2992 ], [ 2999, 2999 ], [ 3001, 3002 ], [ 3058, 3058 ], [ 3061, 3061 ], [ 3063, 3063 ], [ 3065, 3067 ], [ 3075, 3076 ] ], [ [ 33, 34 ], [ 37, 37 ], [ 42, 42 ], [ 278, 278 ], [ 280, 280 ], [ 282, 282 ], [ 484, 484 ], [ 486, 486 ], [ 489, 489 ], [ 2405, 2600 ], [ 2720, 2720 ] ], [ [ 35, 35 ], [ 38, 39 ], [ 41, 41 ], [ 154, 154 ], [ 168, 168 ], [ 183, 186 ], [ 2850, 2850 ], [ 3124, 3125 ], [ 3128, 3129 ], [ 3149, 3149 ], [ 3154, 3159 ] ], [ [ 36, 36 ], [ 40, 40 ], [ 535, 535 ], [ 537, 537 ], [ 542, 542 ], [ 558, 558 ], [ 560, 560 ], [ 813, 813 ], [ 1718, 1718 ], [ 1724, 1724 ], [ 2402, 2402 ], [ 2968, 2968 ], [ 2997, 2997 ] ], [ [ 442, 445 ] ] ]
3fcf6f69a78c8472cceb93daabba852572971564
2f9d5566c598bcae0b4ea614f5088830741f4b46
/src/Engine/EventEngine/IEventListener.h
ed40329e0bb00bbcf25513f4b03dceef40e2cbff
[]
no_license
fcazalet/Bomberman-like-reseau
d5acda6a428e2ab5c027b1b1b0b9838b2c025556
b74e9f16b7a7c45e36a079ecc3dc941c677cf915
refs/heads/master
2021-01-16T21:52:38.352545
2011-04-19T19:42:15
2011-04-19T19:42:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
587
h
#ifndef IEVENTLISTENER_H #define IEVENTLISTENER_H namespace Engine { typedef struct { std::map<SDLKey,bool> keyState; SDL_Event event; } stateEvent; /** Interface des écouteurs **/ class IEventListener { public: IEventListener(){}; virtual ~IEventListener()=0; /** Execute les actions suivant les événements **/ virtual void executeAction(const stateEvent &event)=0; protected: private: }; } #endif // IEVENTLISTENER_H
[ [ [ 1, 30 ] ] ]
266f843503ff3aba8dbd76654d976460069e95a6
9324000ac1cb567bd4862547cbdccf0923446095
/foliage/timer.hpp
0fa51b4354d5e68cbef3899e2d590a071b242a02
[]
no_license
mguillemot/kamaku.foliage
cf63d49e1e5ddd7c30b75acfc1841028d109cba4
18c225346916e240bc19bf5570a8c414bbb4153b
refs/heads/master
2016-08-03T20:09:17.929309
2007-09-04T18:15:17
2007-09-04T18:15:17
2,226,835
0
0
null
null
null
null
UTF-8
C++
false
false
562
hpp
#ifndef _FOLIAGE__TIMER #define _FOLIAGE__TIMER #include "basic_types.hpp" #ifdef __PPC__ #include <xtime_l.h> #else #include <SDL.h> #endif namespace Foliage { class Timer { public: Timer(); void start(); void stop(); void reset(); Uint32 duration() const; // in microseconds //TODO: use milliseond timer (microsecond timer wraps in 70 min, could be insufficient) private: #ifdef __PPC__ XTime _started, _stopped; #else Uint32 _started, _stopped; #endif }; } #endif //_FOLIAGE__TIMER
[ "erhune@1bdb3d1c-df69-384c-996e-f7b9c3edbfcf", "Erhune@1bdb3d1c-df69-384c-996e-f7b9c3edbfcf" ]
[ [ [ 1, 3 ], [ 11, 21 ], [ 24, 25 ], [ 31, 35 ] ], [ [ 4, 10 ], [ 22, 23 ], [ 26, 30 ] ] ]
9b136735f3de330ae74740cd6bdf7b0d1efe7e1b
dd296e4ce663222db78a3aa7230cabe4b6620747
/Programs/m2tools/m2modder/m2modder.cpp
f399540ffdb38877e1aa4dbd8b1c854408ce318e
[]
no_license
vienis/mcbuddiapfel
42213684b253d7a0dae8b785c58a13853d6c9efd
e4d5c6b91d2f9f3b2d0de011cca3298a4e266d89
refs/heads/master
2021-01-10T02:13:50.149299
2011-01-22T13:56:56
2011-01-22T13:56:56
36,045,662
2
0
null
null
null
null
UTF-8
C++
false
false
32,511
cpp
/* * m2modder.cpp * * Created on: 10.12.2008 * Author: Tigurius */ #include <stdio.h> #include <string.h> #include <stdlib.h> typedef float Vec3D[3]; typedef float Vec2D[2]; #include "modelheaders.h" FILE *Input; char *f; int FileSize; ModelHeader *header; ModelBoneDef *bones; ModelRenderFlags *rf; ModelTextureDef *tex; ModelTexUnit *texunit; //ModelView *view; ModelTransDef *transparency; ModelAnimation *animations; ModelParticleEmitterDef *particles; ModelRibbonEmitterDef *ribbons; ModelAttachmentDef *attachments; ModelCameraDef *cameras; short *texUnitMapping; bool changed=false; void displayAnimBlock(AnimationBlock *block,int k) { int *Times; float *Keys; AnimSubStructure *temp; printf("Interpolation Type: %d NumTimestamps: %d NumValues: %d\n",block->type,block->nTimes,block->nKeys); temp=(AnimSubStructure *)(f+block->ofsTimes+8*k); Times=(int *)(f+temp->ofs); for(int i=0;i<temp->n;i++) printf("%d(%d)",i,Times[i]); temp=(AnimSubStructure *)(f+block->ofsKeys+8*k); Keys=(float *)(f+temp->ofs); for(int i=0;i<temp->n;i++) printf("%d - %.3f\n",i,Keys[i]); } void displayAnimBlockShort(AnimationBlock *block, int k) { int *Times; short *Keys; AnimSubStructure *temp; printf("Interpolation Type: %d NumTimestamps: %d NumValues: %d\n",block->type,block->nTimes,block->nKeys); temp=(AnimSubStructure *)(f+block->ofsTimes+8*k); Times=(int *)(f+temp->ofs); temp=(AnimSubStructure *)(f+block->ofsKeys+8*k); Keys=(short *)(f+temp->ofs); for(int i=0;i<block->nKeys;i++) printf("%d(%d)- %d\n",i,Times[i],Keys[i]); } void displayAnimBlockFFF(AnimationBlock *block,int k) { int *Times; float *Keys; printf("Interpolation Type: %d NumTimestamps: %d NumValues: %d\n",block->type,block->nTimes,block->nKeys); AnimSubStructure *temp; temp=(AnimSubStructure *)(f+block->ofsTimes+8*k); Times=(int *)(f+temp->ofs); temp=(AnimSubStructure *)(f+block->ofsKeys+8*k); Keys=(float *)(f+temp->ofs); for(int i=0;i<block->nKeys;i++) printf("%d(%d)- %8.3f %8.3f %8.3f\n",i,Times[i],Keys[i*3],Keys[i*3+1],Keys[i*3+2]); } void editAnimBlock(AnimationBlock *block) { int i,k; float tf; printf("Which Substructure?(0- %d): ",block->nKeys-1); scanf("%d",&k); displayAnimBlock(block,k); AnimSubStructure *temp; temp=(AnimSubStructure *)(f+block->ofsKeys+8*k); float * Keys; for(i=0;i<temp->n;i++) Keys=(float *)(f+temp->ofs); do{ printf("Edit which key? (-1 to return)\n"); scanf("%d",&i); if((i>=0)&&(i<temp->n)) { printf("New Value? (Cur Value %.3f)\n",Keys[i]); scanf("%f",&tf); Keys[i]=tf; changed=true; } else if(i!=-1) printf("Key %d isn't valid\n",i); }while(i!=-1); } void editAnimBlockShort(AnimationBlock *block) { int i,k; short tf; short *Keys; printf("Which Substructure?(0- %d): ",block->nKeys-1); scanf("%d",&k); displayAnimBlockShort(block,k); AnimSubStructure *temp; temp=(AnimSubStructure *)(f+block->ofsKeys+8*k); for(i=0;i<temp->n;i++) Keys=(short *)(f+temp->ofs); do{ printf("Edit which key? (-1 to return)\n"); scanf("%d",&i); if((i>=0)&&(i<block->nKeys)) { printf("New Value? (Cur Value %d)\n",Keys[i]); scanf("%d",&tf); Keys[i]=tf; changed=true; } else if(i!=-1) printf("Key %d isn't valid\n",i); }while(i!=-1); } void editAnimBlockFFF(AnimationBlock *block) { int i,k; float tf,*Keys; printf("Which Substructure?(0- %d): ",block->nKeys-1); scanf("%d",&k); displayAnimBlockFFF(block,k); AnimSubStructure *temp; temp=(AnimSubStructure *)(f+block->ofsKeys+8*k); for(i=0;i<temp->n;i++) Keys=(float *)(f+temp->ofs); do{ printf("Edit which key? (-1 to return)\n"); scanf("%d",&i); if((i>=0)&&(i<block->nKeys)) { for(int j=0;j<3;j++) { printf("New Value %d? (Cur Value %.3f)\n",j,Keys[i*3+j]); scanf("%f",&tf); Keys[i*3+j]=tf; } changed=true; } else if(i!=-1) printf("Key %d isn't valid\n",i); }while(i!=-1); } void displayFakeAnimBlock(FakeAnimationBlock *block){ AnimSubStructure *temp; int *Times; float *Keys; printf("NumTimestamps: %d NumValues: %d\n",block->nTimes,block->nKeys); Times=(int *)(f+block->ofsTimes); Keys=(float *)(f+block->ofsKeys); for(int i=0;i<block->nKeys;i++) printf("%d(%d)- %.3f\n",i,Times[i],Keys[i]); } void editFakeAnimBlock(FakeAnimationBlock *block){ int i; float tf,*Keys; displayFakeAnimBlock(block); Keys=(float *)(f+block->ofsKeys); do{ printf("Edit which key? (-1 to return)\n"); scanf("%d",&i); if((i>=0)&&(i<block->nKeys)) { printf("New Value? (Cur Value %.3f)\n",Keys[i]); scanf("%f",&tf); Keys[i]=tf; changed=true; } else if(i!=-1) printf("Key %d isn't valid\n",i); }while(i!=-1); } //now in *.skins /*void editTextureUnits() { int i,j,theView; char t; ViewChoose: printf("Choose which view (0-3):\n"); scanf("%d",&i); if((i<0)||(i>3)) goto ViewChoose; theView=i; texunit=(ModelTexUnit *)(f+view[theView].ofsTex); do { system("clear"); printf("Texture Units\n\n"); printf("Test %x %d %d\n",header->ofsTexUnitLookup,texUnitMapping[0],texUnitMapping[1]); for(i=0;i<view[theView].nTex;i++) printf("%d - %s(%d) Mapped to %d(%d) flags %d RF=%d RFlags=%d Blend=%d\n",i,(char *)(f+tex[texunit[i].textureid].nameOfs),texunit[i].textureid,texUnitMapping[texunit[i].texunit],texunit[i].texunit,texunit[i].flags,texunit[i].flagsIndex,rf[texunit[i].flagsIndex].flags,rf[texunit[i].flagsIndex].blend); printf("\n t - Change Texture\n m - Change Mapping\n g - Change flag\n r - Change Render Flag Used\n f - Change Render Flag\n b - Change Render Blend\n q - Return to Main Menu\n\n"); t=getchar(); if(t=='r') { i=-1; do{ printf("\nChange a Texture Unit Render Flag (number of tex unit or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<view[theView].nTex)) { printf("New Render Flag\n"); scanf ("%d",&j); if((j>=0)||(j<header->nRenderFlags)) { texunit[i].flagsIndex=j; changed=true; } else printf("%d is an invalid render flag number\n",j); } }while(i!=-1); } else if(t=='t') { printf("Textures\n"); for(i=0;i<header->nTextures;i++) printf(" %d - %s\n",i,(char *)(f+tex[i].nameOfs)); i=-1; do{ printf("\nChange a Texture Unit Texture Used (number of tex unit or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<view[theView].nTex)) { printf("New Texture Number\n"); scanf ("%d",&j); if((j>=0)||(j<header->nTextures)) { texunit[i].textureid=j; changed=true; } else printf("%d is an invalid texture number\n",j); } }while(i!=-1); } else if(t=='f') { i=-1; do{ printf("\nChange a Render Flag - Flag (number of render flag or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nRenderFlags)) { printf("New Flag (1 - Unlit, 2 - Unfogged, 4 - 2 Sided, 8 ?, 16 Disable Zbuffer)\n"); scanf ("%d",&j); rf[i].flags=j; changed=true; } }while(i!=-1); } else if(t=='g') { i=-1; do{ printf("\nChange a Flag (number of texture unit or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<view[theView].nTex)) { printf("New Flag\n"); scanf ("%d",&j); texunit[i].flags=j; changed=true; } }while(i!=-1); } else if(t=='m') { i=-1; do{ printf("\nChange a Mapping (number of texture unit or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<view[theView].nTex)) { printf("New Mapping\n"); scanf ("%d",&j); texunit[i].texunit=j; changed=true; } }while(i!=-1); } else if(t=='b') { i=-1; do{ printf("\nChange a Render Flag - Blend (number of render flag or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nRenderFlags)) { printf("New Blend Mode (0 - Opaque, 1 - Alpha testing, 2 - Alpha Blending, 3 - Additive, 4 - Additive Alpha, 5 - Modulate, 6 - Deeprun Tram Glass\n"); scanf ("%d",&j); rf[i].blend=j; changed=true; } }while(i!=-1); } else if(t=='q') return; } while (1); }*/ void editAnimations() { do{ int i,j; char t; system("clear"); printf("Animation Sequences\n"); for(i=0;i<header->nAnimations;i++) printf("%d animID: %d\n",i,animations[i].animID); printf("\n a - Change Animation\n q - Return to Main Menu\n\n"); t=getchar(); if(t=='a') { i=-1; do{ printf("\nChange an animID - Blend (number of animation or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nAnimations)) { printf("New animID\n"); scanf ("%d",&j); animations[i].animID=j; changed=true; } }while(i!=-1); } else if(t=='q') return; }while(1); } void printBoneTree(ModelBoneDef *B, int id) { if(B->parent!=-1) { printBoneTree(&bones[B->parent],B->parent); printf("->"); } printf("%d",id); } void editBone(int i) { do{ int j; float f; char t; system("clear"); printf("Editing Bone %d\n",i); printf(" "); printBoneTree(&bones[i],i); printf("\n Pivot Point %8.3f %8.3f %8.3f\n",bones[i].pivot[0],bones[i].pivot[1],bones[i].pivot[2]); printf(" Flags 0x%08x\n",bones[i].flags); printf("\n t - Edit Translation\n r - Edit Rotation\n s - Edit Scaling\n f - Edit Flags\n p - Edit Pivot Point\n q - Return to Main Menu\n\n"); t=getchar(); if(t=='t') editAnimBlockFFF(&bones[i].translation); else if(t=='r') editAnimBlockFFF(&bones[i].rotation); else if(t=='s') editAnimBlockFFF(&bones[i].scaling); else if(t=='f') { printf("\nCurrent Flags 0x%08x\n",bones[i].flags); printf("New Flag Value\n"); printf(" 8 - Billboarded\n"); printf(" 200 - Transformed\n"); scanf ("%x",&j); bones[i].flags=j; changed=true; } else if(t=='p') { printf("\nCurrent Pivot Point %8.3f %8.3f %8.3f\n",bones[i].pivot[0],bones[i].pivot[1],bones[i].pivot[2]); printf("New Pivot X\n"); scanf ("%f",&bones[i].pivot[0]); printf("New Pivot Y\n"); scanf ("%f",&bones[i].pivot[1]); printf("New Pivot Z\n"); scanf ("%f",&bones[i].pivot[2]); changed=true; } else if(t=='q') return; }while(1); } void editBones() { do{ int i,j; char t; system("clear"); printf("Bones\n"); for(i=0;i<header->nBones;i++) { printBoneTree(&bones[i],i); printf("\n"); } printf("\n e - Edit Bone\n q - Return to Main Menu\n\n"); t=getchar(); if(t=='e') { i=-1; do{ printf("\nChange a Bone (number of bone or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nBones)) editBone(i); }while(i!=-1); } else if(t=='q') return; }while(1); } char textureType[255]; void setTextureType(int i) { if(i==0) strcpy(textureType,"Hard Coded"); else if(i==1) strcpy(textureType,"Player Skin"); else if(i==2) strcpy(textureType,"Cape"); else if(i==6) strcpy(textureType,"Hair"); else if(i==8) strcpy(textureType,"Tauren Fur"); else if(i==11) strcpy(textureType,"Creature Skin 1"); else if(i==12) strcpy(textureType,"Creature Skin 2"); else if(i==13) strcpy(textureType,"Creature Skin 3"); else strcpy(textureType,"Unknown"); } void editTextures() { do{ int i,j; char t; system("clear"); printf("Textures\n"); for(i=0;i<header->nTextures;i++) { setTextureType(tex[i].type); printf("%d Type: %s (%d) Unknown: 0x%04x Flags: 0x%04x\n",i,textureType,tex[i].type,tex[i].flags>>16,tex[i].flags&0xffff); if(tex[i].type==0) printf("\tTexture: %s\n",(char *)(f+tex[i].nameOfs)); } printf("\n t - Change Texture Type\n n - Change Texture File Name\n f - Change Texture Flags\n q - Return to Main Menu\n"); t=getchar(); if(t=='t') { i=-1; do{ printf("\nChange a texture type (number of texture or -1 to quit)\n\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nTextures)) { printf("New texture type (currently %d)\n",tex[i].type); printf("0 - Hard Coded\n"); printf("1 - Player Skin\n"); printf("2 - Cape\n"); printf("6 - Hair\n"); printf("8 - Tauren Fur\n"); printf("11 - Creature Skin 1\n"); printf("12 - Creature Skin 2\n"); printf("13 - Creature Skin 3\n"); scanf ("%d",&j); tex[i].type=j; changed=true; } }while(i!=-1); } if(t=='n') { i=-1; do{ printf("\nChange a texture file name (number of texture or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nTextures)) { char newName[255]; printf("New texture file name (currently %s max new length 15)\n",(char *)(f+tex[i].nameOfs)); scanf ("%s",newName); if(strlen(newName)<16) { strcpy((char *)(f+tex[i].nameOfs),newName); tex[i].nameLen=strlen(newName)+1; changed=true; } else printf("Length of %s too long (%d characters while max of 15)\n",newName,strlen(newName)); } }while(i!=-1); } if(t=='f') { i=-1; do{ printf("\nChange a texture flag (number of texture or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nTextures)) { printf("New texture type (currently 0x%04x)\n",tex[i].flags&0xffff); printf("1 - Texture Wrap X\n"); printf("2 - Texture Wrap Y\n"); scanf ("%d",&j); tex[i].flags=(tex[i].flags&0xffff0000)|(j&(0xffff)); changed=true; } }while(i!=-1); } else if(t=='q') return; }while(1); } void editParticles() { do{ int i,j; char t; system("clear"); printf("Textures\n"); for(i=0;i<header->nParticleEmitters;i++) { setTextureType(tex[i].type); printf("%d Flags: %02x Bone: %d Pos: %.2f %.2f %.2f Texture: %d Blend: %d Type: %d\n",i,particles[i].flags,particles[i].bone,particles[i].pos[0],particles[i].pos[1],particles[i].pos[2],particles[i].texture,particles[i].blend,particles[i].emittertype); displayFakeAnimBlock(&(particles[i].p.colors)); //printf("\tSizes %.2f %.2f %.2f\n",particles[i].p.sizes[0],particles[i].p.sizes[1],particles[i].p.sizes[2]); //these are now fakeanimblocks :O printf("\tSlowdown %.2f Rotation %.2f\n",particles[i].p.slowdown,particles[i].p.rotation); } printf("\n f - Change Flags\n n - Change Bones\n p - Change Position\n r - Change Rotation\n t - Change Texture\n c - Change Colors\n b - Change Blending\n y - Change Emitter Type\n s - Change Sizes\n a - Edit Animation Block\n q - Return to Main Menu\n"); t=getchar(); if(t=='p') { i=-1; do{ printf("\nChange a postion (number of particle or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nParticleEmitters)) { float Pos[3]; printf("New Position (format \"x y z\")\n"); scanf ("%f %f %f",&Pos[0],&Pos[1],&Pos[2]); for(j=0;j<3;j++) particles[i].pos[j]=Pos[j]; changed=true; } }while(i!=-1); } else if(t=='s') { i=-1; do{ printf("\nChange the sizes (number of particle or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nParticleEmitters)) { printf("Current Size:\n"); editFakeAnimBlock(&(particles[i].p.sizes)); changed=true; } }while(i!=-1); } else if(t=='a') { i=-1; printf("Animation Block Types\n"); printf("0 - Emission Speed\n"); printf("1 - Speed Variation (range 0 to 1)\n"); printf("2 - Rotation\\Tumble Spread (range 0 to pi)\n"); printf("3 - ? (range: 0 to 2pi)\n"); printf("4 - Gravity\n"); printf("5 - Lifespan\n"); printf("6 - Emission Rate\n"); printf("7 - Emission Area Length\n"); printf("8 - Emission Area Width\n"); printf("9 - Gravity? (much stronger)\n"); do{ printf("Edit Animation Block (number of particle or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nParticleEmitters)) { float Pos[3]; printf("Which Block(0-9)\n"); scanf ("%d",&j); if(j<6) editAnimBlock(&(particles[i].params[j])); else if(j=6) editAnimBlock(&(particles[i].rate)); else if(j<10) editAnimBlock(&(particles[i].params2[j-7])); else printf("Not valid!"); } }while(i!=-1); } if(t=='b') { i=-1; do{ printf("\nChange a blend mode (number of particle or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nParticleEmitters)) { printf("New Blend Mode (0 - Opaque, 1 - Alpha testing, 2 - Alpha Blending, 3 - Additive, 4 - Additive Alpha, 5 - Modulate, 6 - Deeprun Tram Glass\n"); scanf ("%d",&j); particles[i].blend=j; changed=true; } }while(i!=-1); } if(t=='f') { i=-1; do{ printf("\nChange flags (number of particle or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nParticleEmitters)) { printf("New Flag\n"); scanf ("%x",&j); particles[i].flags=j; changed=true; } }while(i!=-1); } if(t=='r') { i=-1; do{ printf("\nChange rotation (number of particle or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nParticleEmitters)) { printf("New Rotation\n"); scanf ("%f",&(particles[i].p.rotation)); changed=true; } }while(i!=-1); } if(t=='n') { i=-1; do{ printf("\nChange Bones (number of particle or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nParticleEmitters)) { printf("New Bone\n"); scanf ("%d",&j); particles[i].bone=j; changed=true; } }while(i!=-1); } if(t=='y') { i=-1; do{ printf("\nChange a emitter type (number of particle or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nParticleEmitters)) { printf("New Emitter Type (1 - Plane 2 - Sphere 3 - Unknown\n"); scanf ("%d",&j); particles[i].emittertype=j; changed=true; } }while(i!=-1); } if(t=='t') { printf("Textures\n"); for(i=0;i<header->nTextures;i++) printf(" %d - %s\n",i,(char *)(f+tex[i].nameOfs)); i=-1; do{ printf("\nChange a texture (number of particle or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nParticleEmitters)) { printf("New Texture\n"); scanf ("%d",&j); particles[i].texture=j; changed=true; } }while(i!=-1); } if(t=='c') { i=-1; do{ printf("\nChange particle colors (number of particle or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nParticleEmitters)) { printf("Current Colors:\n"); editFakeAnimBlock(&(particles[i].p.colors)); changed=true; } }while(i!=-1); } if(t=='q') return; }while(1); } void editRibbons() { do{ char t; int i; system("cls"); printf("Ribbons\n"); for(i=0;i<header->nRibbonEmitters;i++) printf("%d Bone: %2d Pos: %6.2f %6.2f %6.2f\n",i,ribbons[i].bone,ribbons[i].pos[0],ribbons[i].pos[1],ribbons[i].pos[2]); printf("\n l - Change Length\n t - Change Texture\n b - Change Bone\n p - Change Position\n c - Edit Color\n o - Edit Opacity\n a - edit above\n u - Edit Under\n r - Edit Resolution\n g - Edit Gravity\n q - Return to Main Menu\n"); t=getchar(); if(t=='q') return; else if(t=='c') { i=-1; do{ printf("\nChange the color (number of ribbon or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nRibbonEmitters)) { printf("Current Color:\n"); editAnimBlock(&(ribbons[i].color)); changed=true; } }while(i!=-1); } else if(t=='o') { i=-1; do{ printf("\nChange the Opacity (number of ribbon or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nRibbonEmitters)) { printf("Current Opacity:\n"); editAnimBlockShort(&(ribbons[i].opacity)); changed=true; } }while(i!=-1); } else if(t=='a') { i=-1; do{ printf("\nChange the Above (number of ribbon or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nRibbonEmitters)) { printf("Current Above:\n"); editAnimBlock(&(ribbons[i].above)); changed=true; } }while(i!=-1); } else if(t=='u') { i=-1; do{ printf("\nChange the Below (number of ribbon or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nRibbonEmitters)) { printf("Current Below:\n"); editAnimBlock(&(ribbons[i].below)); changed=true; } }while(i!=-1); } else if(t=='p') { int i; i=-1; do{ printf("\nChange a postion (number of ribbon or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nRibbonEmitters)) { float Pos[3]; printf("New Position (format \"x y z\")\n"); scanf ("%f %f %f",&Pos[0],&Pos[1],&Pos[2]); for(int j=0;j<3;j++) ribbons[i].pos[j]=Pos[j]; changed=true; } }while(i!=-1); } else if(t=='n') { int i; i=-1; do{ printf("\nChange Bones (number of bone or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nRibbonEmitters)) { printf("New Bone\n"); int j; scanf ("%d",&j); ribbons[i].bone=j; changed=true; } }while(i!=-1); } else if(t=='l') { int i; i=-1; do{ printf("\nChange Length (number of bone or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nRibbonEmitters)) { printf("Current Lenght:\t %f\n",ribbons[i].length); printf("New Length\n"); float j; scanf ("%f",&j); ribbons[i].length=j; changed=true; } }while(i!=-1); } else if(t=='b') { int i; i=-1; do{ printf("\nChange Bone (number of ribbon or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nRibbonEmitters)) { printf("Current Bone:\t %d\n",ribbons[i].bone); printf("New Bone\n"); int j; scanf ("%d",&j); ribbons[i].bone=j; changed=true; } }while(i!=-1); } else if(t=='r') { int i; i=-1; do{ printf("\nChange Resolution (number of bone or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nRibbonEmitters)) { printf("Current Res:\t %f\n",ribbons[i].res); printf("New Res\n"); float j; scanf ("%f",&j); ribbons[i].res=j; changed=true; } }while(i!=-1); } else if(t=='g') { int i; i=-1; do{ printf("\nChange Gravity (number of bone or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nRibbonEmitters)) { printf("Current Gravity:\t %f\n",ribbons[i].unk); printf("New Gravity\n"); float j; scanf ("%f",&j); ribbons[i].unk=j; changed=true; } }while(i!=-1); } else if(t=='t') { printf("Textures\n"); for(int i=0;i<header->nTextures;i++) printf(" %d - %d\n",i,tex[i].nameOfs); int i; i=-1; do{ printf("\nChange a texture (number of ribbon or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nRibbonEmitters)) { printf("New TexOffset\n"); int j; scanf ("%d",&j); ribbons[i].ofsTextures=j; changed=true; } }while(i!=-1); } } while(1); } void editTransparency(){ do{ char t; system("cls"); printf("Transparency\n"); for(int i=0;i<header->nTransparency;i++) displayAnimBlockShort(&(transparency[i].trans),0); printf("\n e - Set Transparency\n q - Return to Main Menu\n"); t=getchar(); if(t=='q') return; else if(t=='e') { int j; printf("Which Transparency?(0-%d)\n",header->nTransparency-1); scanf("%f",&j); printf("Transparency\n"); editAnimBlockShort(&(transparency[j].trans)); } } while(1); } void editAttachments(){ do{ int i,j; char t; system("cls"); printf("Attachments\n"); for(i=0;i<header->nAttachments;i++) printf("%d\n",attachments[i].id); printf("\n e - Set Bone\n p - Edit Position\n q - Return to Main Menu\n"); t=getchar(); if(t=='q') return; else if(t=='p') { i=-1; do{ printf("\nChange a postion (number of attachment or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nAttachments)) { float Pos[3]; printf("Position is %f %f %f\n",attachments[i].pos[0],attachments[i].pos[1],attachments[i].pos[2]); printf("New Position (format \"x y z\")\n"); scanf ("%f %f %f",&Pos[0],&Pos[1],&Pos[2]); for(j=0;j<3;j++) attachments[i].pos[j]=Pos[j]; changed=true; } }while(i!=-1); } else if(t=='e') { i=-1; do{ printf("Which Attachment?(0-%d)\n",(header->nAttachments)-1); scanf("%d",&i); if((i>=0)&&(i<header->nAttachments)) { int j; printf("Bone is:\t"); printf("%d\n",attachments[i].bone); printf("Please enter new Bone\t"); scanf("%d",&j); attachments[i].bone=j; changed=true; } }while(i!=-1); } } while(1); } void editTilt(){ do{ char t; system("cls"); printf("Tilt Value\n"); printf("%d",header->type); printf("\n e - Edit Tilt Value\n q - Return to Main Menu\n"); t=getchar(); if(t=='q') return; else if(t=='e') { int j; printf("New Tilt-value\n"); scanf("%d",&j); header->type=j; } } while(1); } void editCameras(){ do{ int i,j; char t; system("cls"); printf("Cameras\n"); printf("%d",header->nCameras); printf("\n e - Edit Target\n o - Edit Position\n p - Edit Position Animblock\n r - Edit Target Animblock\n r - Edit Rotation Animblock\n q - Return to Main Menu\n"); t=getchar(); if(t=='q') return; else if(t=='p') { i=-1; do{ printf("Which Camera?(0-%d)\n",(header->nCameras)-1); scanf("%d",&i); if((i>=0)&&(i<header->nCameras)) { editAnimBlock(&(cameras[i].transPos)); changed=true; } }while(i!=-1); } else if(t=='t') { i=-1; do{ printf("Which Camera?(0-%d)\n",(header->nCameras)-1); scanf("%d",&i); if((i>=0)&&(i<header->nCameras)) { editAnimBlock(&(cameras[i].transTarget)); changed=true; } }while(i!=-1); } else if(t=='r') { i=-1; do{ printf("Which Camera?(0-%d)\n",(header->nCameras)-1); scanf("%d",&i); if((i>=0)&&(i<header->nCameras)) { editAnimBlock(&(cameras[i].rot)); changed=true; } }while(i!=-1); } if(t=='o') { i=-1; do{ printf("\nChange a postion (number of camera or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nCameras)) { float Pos[3]; printf("Current Position: %f %f %f\n",cameras[i].pos[0],cameras[i].pos[1],cameras[i].pos[2]); printf("New Position (format \"x y z\")\n"); scanf ("%f %f %f",&Pos[0],&Pos[1],&Pos[2]); for(j=0;j<3;j++) cameras[i].pos[j]=Pos[j]; changed=true; } }while(i!=-1); } if(t=='e') { i=-1; do{ printf("\nChange a target (number of camera or -1 to quit)\n"); scanf ("%d",&i); if((i>=0)&&(i<header->nCameras)) { float Pos[3]; printf("Current Target: %f %f %f\n",cameras[i].target[0],cameras[i].target[1],cameras[i].target[2]); printf("New Target (format \"x y z\")\n"); scanf ("%f %f %f",&Pos[0],&Pos[1],&Pos[2]); for(j=0;j<3;j++) cameras[i].target[j]=Pos[j]; changed=true; } }while(i!=-1); } } while(1); } int main(int argc, char **argv) { char t; int i,j; if(argc<2) { printf("M2Modder V1.0 (April 7th, 2006) by John 'Cryect' Rittenhouse\n"); printf("Updatet and extended by Tigurius - Dec 2008-Feb 2009"); printf(" m2modder <filename.m2>\n"); return 0; } printf("M2Modder V1.0 (April 7th, 2006) by John 'Cryect' Rittenhouse\n"); printf("Updatet and extended by Tigurius - Dec 2008-Feb 2009"); printf(" Loading Model %s\n",argv[1]); Input=fopen(argv[1],"rb+"); if(Input==NULL) { printf(" ERROR: Could not load file %s\n",argv[1]); return 0; } fseek(Input,0,SEEK_END); FileSize=ftell(Input); fseek(Input,0,SEEK_SET); f=new char[FileSize]; fread(f,FileSize,1,Input); fclose(Input); header=(ModelHeader *)f; rf=(ModelRenderFlags *)(f+header->ofsRenderFlags); tex=(ModelTextureDef *)(f+header->ofsTextures); //view= (ModelView*)(f+ header->ofsViews); //texunit=(ModelTexUnit *)(f+view->ofsTex); animations=(ModelAnimation *)(f+header->ofsAnimations); transparency=(ModelTransDef *)(f+header->ofsTransparency); particles=(ModelParticleEmitterDef *)(f+header->ofsParticleEmitters); bones=(ModelBoneDef *)(f+header->ofsBones); ribbons=(ModelRibbonEmitterDef *)(f+header->ofsRibbonEmitters); texUnitMapping=(short *)(f+header->ofsTexUnitLookup); attachments=(ModelAttachmentDef *)(f+header->ofsAttachments); cameras=(ModelCameraDef *)(f+header->ofsCameras); do{ system("cls"); printf("M2Modder V1.0 (April 7th, 2006) by John 'Cryect' Rittenhouse\n"); printf("Updatet by Tigurius - Dec 2008-Feb 2009"); printf(" Currently Editing %s ",argv[1]); if(changed) printf("which has changed\n"); else printf("which has not changed\n"); printf("\n t - Edit Textures Definations\n b - Edit Bones\n a - Edit Animation IDs\n p - Edit Particles\n r - Edit Ribbons\n w - Edit Attachments\n o - Edit Transparency\n y - Edit Tilt\n c - Edit Cameras\n q - Quit\n x - Quit Without Saving\n\n"); t=getchar(); if(t=='t') editTextures(); else if(t=='b') editBones(); else if(t=='a') editAnimations(); else if(t=='p') editParticles(); else if(t=='r') editRibbons(); else if(t=='w') editAttachments(); else if(t=='o') editTransparency(); else if(t=='y') editTilt(); else if(t=='c') editCameras(); else if(t=='q') break; else if(t=='x') return 0; }while(1); if(changed) { printf("Saving Changes\n"); Input=fopen(argv[1],"wb"); fwrite(f,FileSize,1,Input); fclose(Input); } return 0; }
[ "[email protected]@af0300bf-f729-58c1-2b4a-178d59e24212" ]
[ [ [ 1, 1335 ] ] ]
02f58f2654f06ee3811b0bdbd2e80937a1cf705f
5dc78c30093221b4d2ce0e522d96b0f676f0c59a
/src/modules/physics/box2d/PulleyJoint.h
11741a2113081963ff20c648571895118a41c42c
[ "Zlib" ]
permissive
JackDanger/love
f03219b6cca452530bf590ca22825170c2b2eae1
596c98c88bde046f01d6898fda8b46013804aad6
refs/heads/master
2021-01-13T02:32:12.708770
2009-07-22T17:21:13
2009-07-22T17:21:13
142,595
1
0
null
null
null
null
UTF-8
C++
false
false
2,896
h
/** * Copyright (c) 2006-2009 LOVE Development Team * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. **/ #ifndef LOVE_PHYSICS_BOX2D_PULLEY_JOINT_H #define LOVE_PHYSICS_BOX2D_PULLEY_JOINT_H // Module #include "Joint.h" namespace love { namespace physics { namespace box2d { /** * The PulleyJoint The pulley connects two bodies to ground and * to each other. As one body goes up, the other goes down. The * total length of the pulley rope is conserved according to the * initial configuration: length1 + ratio * length2 <= constant. **/ class PulleyJoint : public Joint { private: // The Box2D DistanceJoint object. b2PulleyJoint * joint; public: /** * Creates a PulleyJoint connecting body1 to body2. **/ PulleyJoint(Body * body1, Body * body2, b2Vec2 groundAnchor1, b2Vec2 groundAnchor2, b2Vec2 anchor1, b2Vec2 anchor2, float ratio); virtual ~PulleyJoint(); /** * Gets the ground anchors position in world * coordinates. **/ int getGroundAnchors(lua_State * L); /** * Sets the max rope lengths (a value of zero keeps it * unchanged). Beware that Box2D also imposes a maximum, * so the smallest of these is actually set. **/ void setMaxLengths(float maxlength1, float maxlength2); /** * Gets the max rope lengths. **/ int getMaxLengths(lua_State * L); /** * Sets the total length of the rope and updates the * MaxLengths values accordingly. **/ void setConstant(float length); /** * Gets the total length of the rope. **/ float getConstant() const; /** * Gets the current length of the segment attached to body1. **/ float getLength1() const; /** * Gets the current length of the segment attached to body2. **/ float getLength2() const; /** * Sets the pulley ratio. **/ void setRatio(float ratio); /** * Gets the pulley ratio. **/ float getRatio() const; }; } // box2d } // physics } // love #endif // LOVE_PHYSICS_BOX2D_PULLEY_JOINT_H
[ "tenoch@3494dbca-881a-0410-bd34-8ecbaf855390" ]
[ [ [ 1, 108 ] ] ]
17cbef7545e6967aafe060f8367f423a1efbd0aa
49d4b13f55f09359560d0b9111455d08c6b43625
/stvs/trunk/inc/STA_Normalize.hpp
69f566b6447b664c52ef598d0f51835eecb7062b
[]
no_license
aniskhan25/stvs
6c53c27a6dbfa6b4105576ef9ecdae4b8a467a19
457fcf9393417d1a3b4aa963dc215a13d8f296a3
refs/heads/master
2016-09-11T06:37:25.202638
2011-09-22T06:28:14
2011-09-22T06:28:14
32,129,030
0
0
null
null
null
null
UTF-8
C++
false
false
1,783
hpp
#ifndef _NORMALIZE_H #define _NORMALIZE_H // includes #include "struct.hpp" #include "STA_Reduce.hpp" /// <summary> /// This namespace wraps the static pathway's functionality. /// </summary> namespace Static { /// <summary> /// A class with functions to apply different normalizations to the feature maps. /// </summary> class Normalize { /// <summary> /// Source image size. /// </summary> siz_t im_size_; /// <summary> /// No. of pixels in source image. /// </summary> unsigned int size_; /// <summary> /// Reduction operator results (host). /// </summary> summary_stats_data *result; /// <summary> /// Reduction operator results (device). /// </summary> summary_stats_data *d_result; /// <summary> /// Object of Reduce class used for reduction operations. /// </summary> Static::Reduce oReduce; void Init(); void Clean(); public: /// <summary> /// Default contructor for Normalize class. /// </summary> inline Normalize( siz_t const & im_size) { im_size_ = im_size; size_ = im_size.w*im_size.h; Init(); } /// <summary> /// Destructor for Normalize class. /// </summary> inline ~Normalize(){ Clean();} void Apply( float *out , float* in , siz_t im_size ); }; // class normalize __global__ void KernelNormalizeNL( float* maps , summary_stats_data* result , siz_t im_size ); __global__ void KernelNormalizeItti( float* maps , summary_stats_data* result , siz_t im_size ); __global__ void KernelNormalizePCFusion( float* out , float* maps , summary_stats_data* result , siz_t im_size ); } // namespace Static #endif // _NORMALIZE_H
[ "[email protected]@9aaba9b0-769e-e9e7-77e3-716b6806c03d" ]
[ [ [ 1, 94 ] ] ]
e1965cb737a576526f4ca75f8babf5758350c2f9
d609fb08e21c8583e5ad1453df04a70573fdd531
/trunk/OpenXP/界面控件/include/HSuperlink.h
6d7b37d0007f8b77298ccb7111e09779df5d8058
[]
no_license
svn2github/openxp
d68b991301eaddb7582b8a5efd30bc40e87f2ac3
56db08136bcf6be6c4f199f4ac2a0850cd9c7327
refs/heads/master
2021-01-19T10:29:42.455818
2011-09-17T10:27:15
2011-09-17T10:27:15
21,675,919
0
1
null
null
null
null
UTF-8
C++
false
false
2,235
h
#ifndef __HSUPERLINK__H__ #define __HSUPERLINK__H__ #pragma once class UI_CONTROL_API HSuperLink : public CStatic { public: HSuperLink(); virtual ~HSuperLink(); public: void SetURL(CString strURL); CString GetURL() const; void SetColours(COLORREF crLinkColour, COLORREF crVisitedColour, COLORREF crHoverColour = -1); COLORREF GetLinkColour() const; COLORREF GetVisitedColour() const; COLORREF GetHoverColour() const; void SetVisited(BOOL bVisited = TRUE); BOOL GetVisited() const; void SetLinkCursor(HCURSOR hCursor); HCURSOR GetLinkCursor() const; void SetUnderline(BOOL bUnderline = TRUE); BOOL GetUnderline() const; void SetAutoSize(BOOL bAutoSize = TRUE); BOOL GetAutoSize() const; HINSTANCE GotoURL(LPCTSTR url, int showcmd); public: virtual BOOL PreTranslateMessage(MSG* pMsg); protected: virtual void PreSubclassWindow(); protected: void ReportError(int nError); LONG GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata); void PositionWindow(); void SetDefaultCursor(); protected: COLORREF m_crLinkColour, m_crVisitedColour; // Hyperlink colours COLORREF m_crHoverColour; // Hover colour BOOL m_bOverControl; // cursor over control? BOOL m_bVisited; // Has it been visited? BOOL m_bUnderline; // underline hyperlink? BOOL m_bAdjustToFit; // Adjust window size to fit text? CString m_strURL; // hyperlink URL CFont m_Font; // Underline font if necessary HCURSOR m_hLinkCursor; // Cursor for hyperlink CToolTipCtrl m_ToolTip; // The tooltip protected: //{{AFX_MSG(HSuperLink) afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor); afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); afx_msg void OnMouseMove(UINT nFlags, CPoint point); //}}AFX_MSG afx_msg void OnClicked(); DECLARE_MESSAGE_MAP() }; #endif
[ "[email protected]@f92b348d-55a1-4afa-8193-148a6675784b" ]
[ [ [ 1, 67 ] ] ]
e0b7629de9d2b8eeeaf7dd64c7778d2d7eca5ad9
9340e21ef492eec9f19d1e4ef2ef33a19354ca6e
/cing/src/common/MathUtils.h
0f467693756e0c16d68524d4bdecfd52e8f7bac2
[]
no_license
jamessqr/Cing
e236c38fe729fd9d49ccd1584358eaad475f7686
c46045d9d0c2b4d9e569466971bbff1662be4e7a
refs/heads/master
2021-01-17T22:55:17.935520
2011-05-14T18:35:30
2011-05-14T18:35:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,440
h
/* This source file is part of the Cing project For the latest info, see http://www.cing.cc Copyright (c) 2006-2009 Julio Obelleiro and Jorge Cano This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _Cing_MathUtils_H_ #define _Cing_MathUtils_H_ // Precompiled headers #include "Cing-Precompiled.h" #include "CommonPrereqs.h" #include "CommonTypes.h" #include "PerlinNoise.h" #include "framework/UserAppGlobals.h" #include "common/LogManager.h" #include "OgreBitwise.h" #include <numeric> # include <cmath> // Undefine previous min/max definitions ( from other libs ) #ifdef max #undef max #endif // max #ifdef min #undef min #endif // min /** * @file * This file contains several mathematical util functions */ namespace Cing { // Constants const float PI = 3.14159265359f; const float HALF_PI = 1.57079632679f; const float TWO_PI = 6.28318530717f; const float EPSILON = 0.00001f; /** * @brief Returns the next power of 2 of a given number * @param[in] number Number from which the next power of two will be returned * @return the next power of 2 of a given number */ inline int firstPO2From( int number ) { return Ogre::Bitwise::firstPO2From(number); } /* * @brief Returns the min of the two received values * @return the min of the two received values */ template < typename T > T min( T value1, T value2 ) { return (value1 < value2)? value1: value2; } /* * @brief Returns the max of the two received values * @return the max of the two received values */ template < typename T > T max( T value1, T value2 ) { return (value1 > value2)? value1: value2; } /** * @brief Returns the absolute value of the received number * @param[in] number Number to get the absolute value * @return the absolute value of the received number */ template< typename T > T abs ( T value ) { return std::abs( value ); } /** * @brief Converts degrees into radians * @param[in] deg Degrees to convert * @return Radians equivalent to the degrees received */ inline float degToRad ( float deg ) { return static_cast< float >( (PI * deg) / 180.0f ); } /** * @brief Converts degrees into radians * @param[in] deg Degrees to convert * @return Radians equivalent to the degrees received */ inline float radians ( float deg ) { return static_cast< float >( (PI * deg) / 180.0f ); } /** * @brief Converts radians into degrees * @param[in] rad Radians to convert * @return Degrees equivalent to the radians received */ inline float radToDeg ( float rad ) { return static_cast< float >( (180.0f * rad) / PI ); } /** * @brief Converts radians into degrees * @param[in] rad Radians to convert * @return Degrees equivalent to the radians received */ inline float degrees ( float rad ) { return static_cast< float >( (180.0f * rad) / PI ); } /** * @internal * @brief Starts random number generator seed * @param[in] seed Seed to set */ inline void setRandomSeed( unsigned int seed ) { srand(seed); } /** * @internal * @brief Starts random number generator seed * @param[in] seed Seed to set */ inline void randomSeed( int seed ) { srand( (unsigned int) seed); } /** * @brief Returns a random number in a range min..max (int version) * @param[in] min Min number for the generated random value * @param[in] max Max number for the generated random value */ inline int random( int min, int max ) { // Check min is higher than max if ( min > max ) { return random(max, min); } return min + ( rand() % ( max - min+1 ) ); } /** * @brief Returns a random number in a range 0..max (int version) * @param[in] max Max number for the generated random value */ inline int random( int max ) { return random( 0, max ); } /** * @brief Returns a random number in a range min..max (floating numbers version) * @param[in] min Min number for the generated random value * @param[in] max Max number for the generated random value */ template< typename T > inline T random( T min, T max ) { // Check min is higher than max if ( min > max ) { return random(max, min); } // Number 0..1 T normalizedRandom = static_cast<T>( rand()) / RAND_MAX; // Return float in range min..max return min + ( normalizedRandom * ( max - min ) ); } /** * @brief Returns a random number in a range 0..max (floating numbers version) * @param[in] max Max number for the generated random value */ template< typename T > inline T random( T max ) { return random( (T)0, max ); } /** * @brief Compares two float numbers with an error margin * @param[in] f1 first float to compare * @param[in] f2 second float to compare * @return true if both floats are equal (approx) | false otherwise */ inline bool equal( float f1, float f2 ) { // Compare the abs difference between the float if( fabs( f1 - f2 ) < EPSILON ) return true; else return false; } /** * @brief Calculates the distance between two points in space * @param[in] pos1 first position * @param[in] pos2 second position * @return the distance between two points in space */ inline float dist( const Vector& pos1, const Vector& pos2 ) { return pos1.distance( pos2 ); } /** * @brief Calculates the distance between two points in space * @param[in] pos1 first position * @param[in] pos2 second position * @return the distance between two points in space */ inline float dist( float x1, float y1, float x2, float y2 ) { return sqrt((x1-x2)*(x1-x2) + ((y1-y2)*(y1-y2))); } /** * @brief Calculates the distance between two points in space * @param[in] pos1 first position * @param[in] pos2 second position * @return the distance between two points in space */ inline float dist( float x1, float y1, float z1, float x2, float y2, float z2 ) { return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) + (z1-z2)*(z1-z2)); } /** * @brief Calculates the magnitude (or length) of a vector. */ inline float mag( float x1, float y1) { return sqrt((x1*x1) + (y1*y1) ); } /** * @brief Calculates the magnitude (or length) of a vector. */ inline float mag( float x1, float y1, float z1) { return sqrt((x1*x1) + (y1*y1) + (z1*z1)); } /** * @brief Maps a value from one range to another. * * @param[in] value value to map * @param[in] low1 minimum value of input range * @param[in] hight1 max value of input range * @param[in] low2 minimum value of output range * @param[in] hight2 max value of output range * @code * map(v,0,1,100,200); * @endcode */ inline float map( float value, float low1, float hight1, float low2, float hight2 ) { // Clamp value with limits of input range value = (value < low1) ? low1 : value; value = (value > hight1) ? hight1 : value; // Map to range 0..1 float v = (value-low1) / std::abs(hight1-low1); // Map to output range return v * std::abs(hight2-low2) + low2; } /* * @brief Constrains a value so it does not exceed a range * * @param value value to constrain * @param min min value of the valid range * @param min min value of the valid range * * @return the constrained value */ inline float constrain( float value, float min, float max ) { if ( value > max ) return max; if ( value < min ) return min; return value; } /** * @brief Returns the angle between two vectors. They must be normalized * * @param the angle between two vectors */ inline float angleBetweenVectors( const Vector& v1, const Vector& v2 ) { return acos( v1.dotProduct( v2 ) ); } /** * @brief Returns the Perlin noise value at specified coordinates * The resulting value will always be between 0.0 and 1.0 * * @param float: x coordinate in noise space */ inline float noise( float x ) { return 1.0; } /** * @brief Returns the Perlin noise value at specified coordinates * The resulting value will always be between 0.0 and 1.0 * * @param float: x coordinate in noise space */ inline float noise( float x, float y ) { return abs(_noise.get(x,y)); } /** * @brief Returns the Perlin noise value at specified coordinates * The resulting value will always be between 0.0 and 1.0 * * @param float: x coordinate in noise space */ inline float noise( float x, float y, float z ) { return 1.0; } /** * @brief Calculates a number between two numbers at a specific increment * The resulting value will always be between 0.0 and 1.0 * * @param float: value1 * @param float: value2 * @param float: amt from 0 to 1 */ inline float lerp( float value1, float value2, float amt ) { return value1 + amt * (value2 - value1); } /* * @brief Stores values and returns the average of all of them */ struct Average { Average() { nValues = 3; values.reserve( nValues ); index = 0; } /// @param nValues number of values to store Average( int _nValues ) { nValues = _nValues; values.reserve( nValues ); index = 0; } /// @brief ads a value to average void addValue( double value ) { if ( values.size() < nValues ) values.push_back( value ); else values[index] = value; // calculate new index index = (++index) % values.capacity(); } /// @brief returns the ave double getValue() { double sum = std::accumulate( values.begin(), values.end(), 0.0 ); return sum / (double)values.size(); } std::vector< double > values; size_t nValues; size_t index; }; } // namespace Cing #endif // _MathUtils_H_
[ [ [ 1, 31 ], [ 34, 34 ], [ 36, 39 ], [ 49, 58 ], [ 62, 109 ], [ 117, 123 ], [ 131, 140 ], [ 152, 230 ], [ 232, 235 ], [ 239, 239 ], [ 250, 250 ], [ 259, 259 ], [ 266, 266 ], [ 272, 322 ], [ 342, 342 ], [ 369, 373 ], [ 375, 375 ], [ 377, 377 ], [ 380, 414 ] ], [ [ 32, 33 ], [ 35, 35 ], [ 40, 48 ], [ 59, 61 ], [ 110, 116 ], [ 124, 130 ], [ 141, 151 ], [ 231, 231 ], [ 236, 238 ], [ 240, 249 ], [ 251, 258 ], [ 260, 265 ], [ 267, 271 ], [ 323, 341 ], [ 343, 368 ], [ 374, 374 ], [ 376, 376 ], [ 378, 379 ] ] ]
5e97b0e6f4f61d20f09b5a98404e995579f09382
d54d8b1bbc9575f3c96853e0c67f17c1ad7ab546
/hlsdk-2.3-p3/singleplayer/utils/vgui/include/VGUI_FileInputStream.h
e74ce591c423920194b6313aef3775832e966a26
[]
no_license
joropito/amxxgroup
637ee71e250ffd6a7e628f77893caef4c4b1af0a
f948042ee63ebac6ad0332f8a77393322157fa8f
refs/heads/master
2021-01-10T09:21:31.449489
2010-04-11T21:34:27
2010-04-11T21:34:27
47,087,485
1
0
null
null
null
null
WINDOWS-1252
C++
false
false
1,040
h
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // // $NoKeywords: $ //============================================================================= #ifndef VGUI_FILEINPUTSTREAM_H #define VGUI_FILEINPUTSTREAM_H //TODO : figure out how to get stdio out of here, I think std namespace is broken for FILE for forward declaring does not work in vc6 #include<stdio.h> #include<VGUI_InputStream.h> namespace vgui { class VGUIAPI FileInputStream : public InputStream { private: FILE* _fp; public: FileInputStream(const char* fileName,bool textMode); public: virtual void seekStart(bool& success); virtual void seekRelative(int count,bool& success); virtual void seekEnd(bool& success); virtual int getAvailable(bool& success); virtual uchar readUChar(bool& success); virtual void readUChar(uchar* buf,int count,bool& success); virtual void close(bool& success); virtual void close(); }; } #endif
[ "joropito@23c7d628-c96c-11de-a380-73d83ba7c083" ]
[ [ [ 1, 38 ] ] ]
738dec9b5930ce18c03101184af8a2f63cc0338f
3eae1d8c99d08bca129aceb7c2269bd70e106ff0
/trunk/Codes/CLR/Libraries/SPOT/spot_native_Microsoft_SPOT_Reflection.cpp
a81f840a41a113f6f4a97cd123984007881bcab8
[]
no_license
yuaom/miniclr
9bfd263e96b0d418f6f6ba08cfe4c7e2a8854082
4d41d3d5fb0feb572f28cf71e0ba02acb9b95dc1
refs/heads/master
2023-06-07T09:10:33.703929
2010-12-27T14:41:18
2010-12-27T14:41:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,835
cpp
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Copyright (c) Microsoft Corporation. All rights reserved. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #include "SPOT.h" HRESULT Library_spot_native_Microsoft_SPOT_Reflection::GetTypesImplementingInterface___STATIC__SZARRAY_mscorlibSystemType__mscorlibSystemType( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_CORE(); TINYCLR_HEADER(); CLR_RT_HeapBlock& top = stack.PushValueAndClear(); int tot = 0; CLR_RT_HeapBlock* pArray = NULL; CLR_RT_TypeDef_Instance tdMatch; TINYCLR_CHECK_HRESULT(Library_corlib_native_System_RuntimeType::GetTypeDescriptor( stack.Arg0(), tdMatch )); if((tdMatch.m_target->flags & CLR_RECORD_TYPEDEF::TD_Semantics_Mask) != CLR_RECORD_TYPEDEF::TD_Semantics_Interface) { TINYCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } for(int pass=0; pass<2; pass++) { int count = 0; TINYCLR_FOREACH_ASSEMBLY_IN_CURRENT_APPDOMAIN(g_CLR_RT_TypeSystem) { const CLR_RECORD_TYPEDEF* td = pASSM->GetTypeDef( 0 ); int tblSize = pASSM->m_pTablesSize[ TBL_TypeDef ]; for(int i=0; i<tblSize; i++, td++) { if(td->flags & CLR_RECORD_TYPEDEF::TD_Abstract) continue; CLR_RT_TypeDef_Index idx; idx.Set( pASSM->m_idx, i ); if(CLR_RT_ExecutionEngine::IsInstanceOf( idx, tdMatch )) { if(pass == 0) { tot++; } else { pArray[ count ].SetReflection( idx ); } count++; } } } TINYCLR_FOREACH_ASSEMBLY_IN_CURRENT_APPDOMAIN_END(); if(pass == 0) { if(tot == 0) break; TINYCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( top, tot, g_CLR_RT_WellKnownTypes.m_Type )); CLR_RT_HeapBlock_Array* array = top.DereferenceArray(); pArray = (CLR_RT_HeapBlock*)array->GetFirstElement(); } } TINYCLR_NOCLEANUP(); } HRESULT Library_spot_native_Microsoft_SPOT_Reflection::IsTypeLoaded___STATIC__BOOLEAN__mscorlibSystemType( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_CORE(); TINYCLR_HEADER(); CLR_RT_TypeDef_Instance inst; stack.SetResult_Boolean( CLR_RT_ReflectionDef_Index::Convert( stack.Arg0(), inst, NULL ) ); TINYCLR_NOCLEANUP_NOLABEL(); } HRESULT Library_spot_native_Microsoft_SPOT_Reflection::GetTypeHash___STATIC__U4__mscorlibSystemType( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_CORE(); TINYCLR_HEADER(); CLR_UINT32 hash; if(CLR_RT_ReflectionDef_Index::Convert( stack.Arg0(), hash ) == false) { hash = 0; } stack.SetResult( hash, DATATYPE_U4 ); TINYCLR_NOCLEANUP_NOLABEL(); } HRESULT Library_spot_native_Microsoft_SPOT_Reflection::GetAssemblyHash___STATIC__U4__mscorlibSystemReflectionAssembly( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_CORE(); TINYCLR_HEADER(); CLR_RT_Assembly_Instance inst; CLR_UINT32 hash; if(CLR_RT_ReflectionDef_Index::Convert( stack.Arg0(), inst )) { hash = inst.m_assm->ComputeAssemblyHash(); } else { hash = 0; } stack.SetResult( hash, DATATYPE_U4 ); TINYCLR_NOCLEANUP_NOLABEL(); } HRESULT Library_spot_native_Microsoft_SPOT_Reflection::GetAssemblies___STATIC__SZARRAY_mscorlibSystemReflectionAssembly( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_CORE(); TINYCLR_HEADER(); CLR_RT_HeapBlock& top = stack.PushValueAndClear(); #if defined(TINYCLR_APPDOMAINS) TINYCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.GetCurrentAppDomain()->GetAssemblies( top )); #else int count = 0; CLR_RT_HeapBlock* pArray = NULL; for(int pass=0; pass<2; pass++) { TINYCLR_FOREACH_ASSEMBLY(g_CLR_RT_TypeSystem) { if(pASSM->m_header->flags & CLR_RECORD_ASSEMBLY::c_Flags_Patch) continue; if(pass == 0) { count++; } else { CLR_RT_Assembly_Index idx; idx.Set( pASSM->m_idx ); pArray->SetReflection( idx ); pArray++; } } TINYCLR_FOREACH_ASSEMBLY_END(); if(pass == 0) { TINYCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( top, count, g_CLR_RT_WellKnownTypes.m_Assembly )); pArray = (CLR_RT_HeapBlock*)top.DereferenceArray()->GetFirstElement(); } } #endif //TINYCLR_APPDOMAINS TINYCLR_NOCLEANUP(); } HRESULT Library_spot_native_Microsoft_SPOT_Reflection::GetAssemblyInfo___STATIC__BOOLEAN__SZARRAY_U1__MicrosoftSPOTReflectionAssemblyInfo( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_CORE(); TINYCLR_HEADER(); CLR_RT_HeapBlock_Array* array = NULL; CLR_RT_Assembly* assm = NULL; CLR_RECORD_ASSEMBLY* header; array = stack.Arg0().DereferenceArray(); FAULT_ON_NULL(array); header = (CLR_RECORD_ASSEMBLY*)array->GetFirstElement(); if(header->GoodAssembly()) { CLR_RT_HeapBlock* dst = stack.Arg1().Dereference(); FAULT_ON_NULL(dst); TINYCLR_CHECK_HRESULT(CLR_RT_Assembly::CreateInstance( header, assm )); TINYCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance( dst[ Library_spot_native_Microsoft_SPOT_Reflection__AssemblyInfo::FIELD__m_name ], assm->m_szName )); { CLR_RT_HeapBlock& refs = dst[ Library_spot_native_Microsoft_SPOT_Reflection__AssemblyInfo::FIELD__m_refs ]; CLR_UINT32 numRef = assm->m_pTablesSize[ TBL_AssemblyRef ]; TINYCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( refs, numRef, g_CLR_RT_WellKnownTypes.m_UInt32 )); { const CLR_RECORD_ASSEMBLYREF* ar = assm->GetAssemblyRef( 0 ); CLR_UINT32* dst = (CLR_UINT32*)refs.DereferenceArray()->GetFirstElement(); while(numRef--) { *dst++ = assm->ComputeAssemblyHash( ar++ ); } } } dst[ Library_spot_native_Microsoft_SPOT_Reflection__AssemblyInfo::FIELD__m_flags ].SetInteger( assm->m_header->flags , DATATYPE_U4 ); dst[ Library_spot_native_Microsoft_SPOT_Reflection__AssemblyInfo::FIELD__m_size ].SetInteger( ROUNDTOMULTIPLE(assm->m_header->TotalSize(), CLR_INT32), DATATYPE_I4 ); dst[ Library_spot_native_Microsoft_SPOT_Reflection__AssemblyInfo::FIELD__m_hash ].SetInteger( assm->ComputeAssemblyHash() , DATATYPE_U4 ); stack.SetResult_Boolean( true ); } else { stack.SetResult_Boolean( false ); } TINYCLR_CLEANUP(); if(assm) { assm->DestroyInstance(); } TINYCLR_CLEANUP_END(); } HRESULT Library_spot_native_Microsoft_SPOT_Reflection::GetTypeFromHash___STATIC__mscorlibSystemType__U4( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_CORE(); TINYCLR_HEADER(); CLR_RT_HeapBlock& top = stack.PushValueAndClear(); CLR_RT_TypeDef_Index res; if(g_CLR_RT_TypeSystem.FindTypeDef( stack.Arg0().NumericByRefConst().u4, res )) { top.SetReflection( res ); } TINYCLR_NOCLEANUP_NOLABEL(); } HRESULT Library_spot_native_Microsoft_SPOT_Reflection::GetAssemblyFromHash___STATIC__mscorlibSystemReflectionAssembly__U4( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_CORE(); TINYCLR_HEADER(); CLR_RT_HeapBlock& top = stack.PushValueAndClear(); CLR_UINT32 hash = stack.Arg0().NumericByRefConst().u4; TINYCLR_FOREACH_ASSEMBLY_IN_CURRENT_APPDOMAIN(g_CLR_RT_TypeSystem) { if(pASSM->ComputeAssemblyHash() == hash) { CLR_RT_Assembly_Index idx; idx.Set( pASSM->m_idx ); top.SetReflection( idx ); TINYCLR_SET_AND_LEAVE(S_OK); } } TINYCLR_FOREACH_ASSEMBLY_IN_CURRENT_APPDOMAIN_END(); TINYCLR_NOCLEANUP(); }
[ [ [ 1, 266 ] ] ]
0c0456e41b9028388e953d708e46ca39c131f661
2a687747fd31e4609077d9d1304a4d305260a3bd
/lib/include/sbml/validator/L2v4CompatibilityValidator.h
777602fd21139c4b65fb84ce86fc8e7e86d0f8f0
[ "Apache-2.0" ]
permissive
stumoodie/MetabolicNotationSubsystem
85686f13a51d931eab9d7a76dc9eb5e3bca9ba6d
8631f1b175157e111848930c434f359f77d566f5
refs/heads/master
2021-01-25T05:35:01.624757
2011-05-27T09:33:06
2011-05-27T09:33:06
1,808,887
0
0
null
null
null
null
UTF-8
C++
false
false
1,841
h
/** * @cond doxygen-libsbml-internal * * @file L2v4CompatibilityValidator.h * @brief Checks whether an SBML model can be converted from L2v4 * @author Sarah Keating * * $Id: L2v4CompatibilityValidator.h 8704 2009-01-04 02:26:05Z mhucka $ * $HeadURL: https://sbml.svn.sourceforge.net/svnroot/sbml/trunk/libsbml/src/validator/L2v4CompatibilityValidator.h $ * *<!--------------------------------------------------------------------------- * This file is part of libSBML. Please visit http://sbml.org for more * information about SBML, and the latest version of libSBML. * * Copyright 2005-2009 California Institute of Technology. * Copyright 2002-2005 California Institute of Technology and * Japan Science and Technology Corporation. * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation. A copy of the license agreement is provided * in the file named "LICENSE.txt" included with this software distribution and * also available online as http://sbml.org/software/libsbml/license.html *----------------------------------------------------------------------- -->*/ #ifndef L2v4CompatibilityValidator_h #define L2v4CompatibilityValidator_h #ifdef __cplusplus #include <sbml/validator/Validator.h> class L2v4CompatibilityValidator: public Validator { public: L2v4CompatibilityValidator () : Validator( LIBSBML_CAT_SBML_L2V3_COMPAT ) { } virtual ~L2v4CompatibilityValidator () { } /** * Initializes this Validator with a set of Constraints. */ virtual void init (); }; #endif /* __cplusplus */ #endif /* L2v4CompatibilityValidator_h */ /** @endcond doxygen-libsbml-internal */
[ [ [ 1, 56 ] ] ]
40863eca515c5155826a4210c3e76f5c7189d143
85d9531c984cd9ffc0c9fe8058eb1210855a2d01
/QxOrm/inl/QxDao/QxSqlQueryHelper_FetchAll_WithRelation.inl
eb83e0a41b24fc888ae0efdded24be3bda7a01eb
[]
no_license
padenot/PlanningMaker
ac6ece1f60345f857eaee359a11ee6230bf62226
d8aaca0d8cdfb97266091a3ac78f104f8d13374b
refs/heads/master
2020-06-04T12:23:15.762584
2011-02-23T21:36:57
2011-02-23T21:36:57
1,125,341
0
1
null
null
null
null
UTF-8
C++
false
false
4,929
inl
/**************************************************************************** ** ** http://www.qxorm.com/ ** http://sourceforge.net/projects/qxorm/ ** Original file by Lionel Marty ** ** This file is part of the QxOrm library ** ** 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. ** ** GNU Lesser General Public License Usage ** This file must be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file 'license.lgpl.txt' included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** If you have questions regarding the use of this file, please contact : ** [email protected] ** ****************************************************************************/ namespace qx { namespace dao { namespace detail { template <class T> struct QxSqlQueryHelper_FetchAll_WithRelation { static void sql(qx::IxSqlRelationX * pRelationX, QString & sql, qx::IxSqlQueryBuilder & builder) { BOOST_STATIC_ASSERT(qx::trait::is_qx_registered<T>::value); if (! pRelationX || (pRelationX->count() <= 0)) { qAssert(false); QxSqlQueryHelper_FetchAll<T>::sql(sql, builder); return; } long l1(0), l2(0), l3(0), l4(0); qx::IxDataMember * p = NULL; qx::IxDataMember * pId = builder.getDataId(); qx::IxSqlRelation * pRelation = NULL; qx::QxSqlRelationParams params(0, 0, (& sql), (& builder), NULL, NULL); QString table = builder.table(); sql = "SELECT "; if (pId) { sql += (table + "." + pId->getName() + " AS " + pId->getSqlAlias(& table) + ", "); } while ((p = builder.nextData(l1))) { sql += (table + "." + p->getName() + " AS " + p->getSqlAlias(& table) + ", "); } while ((pRelation = builder.nextRelation(l2))) { params.setIndex(l2); if (pRelationX->exist(pRelation->getKey())) { pRelation->eagerSelect(params); } else { pRelation->lazySelect(params); } } sql = sql.left(sql.count() - 2); // Remove last ", " sql += " FROM " + table + ", "; while ((pRelation = builder.nextRelation(l3))) { params.setIndex(l3); if (pRelationX->exist(pRelation->getKey())) { pRelation->eagerFrom(params); } else { pRelation->lazyFrom(params); } } sql = sql.left(sql.count() - 2); // Remove last ", " while ((pRelation = builder.nextRelation(l4))) { params.setIndex(l4); if (pRelationX->exist(pRelation->getKey())) { pRelation->eagerJoin(params); } else { pRelation->lazyJoin(params); } } } static void resolveInput(qx::IxSqlRelationX * pRelationX, T & t, QSqlQuery & query, qx::IxSqlQueryBuilder & builder) { Q_UNUSED(pRelationX); Q_UNUSED(t); Q_UNUSED(query); Q_UNUSED(builder); } static void resolveOutput(qx::IxSqlRelationX * pRelationX, T & t, QSqlQuery & query, qx::IxSqlQueryBuilder & builder) { BOOST_STATIC_ASSERT(qx::trait::is_qx_registered<T>::value); if (! pRelationX || (pRelationX->count() <= 0)) { qAssert(false); QxSqlQueryHelper_FetchAll<T>::resolveOutput(t, query, builder); return; } long l1(0), l2(0); qx::IxDataMember * p = NULL; qx::IxDataMember * pId = builder.getDataId(); qx::IxSqlRelation * pRelation = NULL; short iOffsetId = (pId ? 1 : 0); QVariant vId = query.value(0); QVariant vIdRelation; bool bComplex = builder.getCartesianProduct(); bool bByPass = (bComplex && builder.existIdX(0, vId, vId)); qx::QxSqlRelationParams params(0, (builder.getDataCount() + iOffsetId), NULL, (& builder), (& query), (& t)); if (! bByPass) { if (pId) { pId->fromVariant((& t), vId); } while ((p = builder.nextData(l1))) { p->fromVariant((& t), query.value(l1 + iOffsetId - 1)); } if (bComplex) { builder.insertIdX(0, vId, vId, (& t)); } } while ((pRelation = builder.nextRelation(l2))) { params.setIndex(l2); bool bEager = pRelationX->exist(pRelation->getKey()); if (bComplex) { vIdRelation = pRelation->getIdFromQuery(bEager, params); } bool bValidId = (bComplex && qx::trait::is_valid_primary_key(vIdRelation)); bByPass = (bValidId && builder.existIdX(l2, vId, vIdRelation)); if (bByPass) { pRelation->updateOffset(bEager, params); continue; } if (bEager) { pRelation->eagerFetch_ResolveOutput(params); } else { pRelation->lazyFetch_ResolveOutput(params); } if (bValidId) { builder.insertIdX(l2, vId, vIdRelation, (& t)); } } } }; } // namespace detail } // namespace dao } // namespace qx
[ [ [ 1, 100 ] ] ]
46772f3cc0e66dd37042276b31f5080da58045c0
04fec4cbb69789d44717aace6c8c5490f2cdfa47
/include/wx/generic/splitter.h
ebd34dfa5935544504b7b71f710629b51e604143
[]
no_license
aaryanapps/whiteTiger
04f39b00946376c273bcbd323414f0a0b675d49d
65ed8ffd530f20198280b8a9ea79cb22a6a47acd
refs/heads/master
2021-01-17T12:07:15.264788
2010-10-11T20:20:26
2010-10-11T20:20:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
13,917
h
///////////////////////////////////////////////////////////////////////////// // Name: wx/splitter.h // Purpose: wxSplitterWindow class // Author: Julian Smart // Modified by: // Created: 01/02/97 // RCS-ID: $Id: splitter.h 49563 2007-10-31 20:46:21Z VZ $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_GENERIC_SPLITTER_H_ #define _WX_GENERIC_SPLITTER_H_ #include "wx/window.h" // base class declaration #include "wx/containr.h" // wxControlContainer class WXDLLEXPORT wxSplitterEvent; // --------------------------------------------------------------------------- // splitter constants // --------------------------------------------------------------------------- enum wxSplitMode { wxSPLIT_HORIZONTAL = 1, wxSPLIT_VERTICAL }; enum { wxSPLIT_DRAG_NONE, wxSPLIT_DRAG_DRAGGING, wxSPLIT_DRAG_LEFT_DOWN }; // --------------------------------------------------------------------------- // wxSplitterWindow maintains one or two panes, with // an optional vertical or horizontal split which // can be used with the mouse or programmatically. // --------------------------------------------------------------------------- // TODO: // 1) Perhaps make the borders sensitive to dragging in order to create a split. // The MFC splitter window manages scrollbars as well so is able to // put sash buttons on the scrollbars, but we probably don't want to go down // this path. // 2) for wxWidgets 2.0, we must find a way to set the WS_CLIPCHILDREN style // to prevent flickering. (WS_CLIPCHILDREN doesn't work in all cases so can't be // standard). class WXDLLEXPORT wxSplitterWindow: public wxWindow { public: //////////////////////////////////////////////////////////////////////////// // Public API // Default constructor wxSplitterWindow() { Init(); } // Normal constructor wxSplitterWindow(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSP_3D, const wxString& name = wxT("splitter")) { Init(); Create(parent, id, pos, size, style, name); } virtual ~wxSplitterWindow(); bool Create(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSP_3D, const wxString& name = wxT("splitter")); // Gets the only or left/top pane wxWindow *GetWindow1() const { return m_windowOne; } // Gets the right/bottom pane wxWindow *GetWindow2() const { return m_windowTwo; } // Sets the split mode void SetSplitMode(int mode) { wxASSERT_MSG( mode == wxSPLIT_VERTICAL || mode == wxSPLIT_HORIZONTAL, _T("invalid split mode") ); m_splitMode = (wxSplitMode)mode; } // Gets the split mode wxSplitMode GetSplitMode() const { return m_splitMode; } // Initialize with one window void Initialize(wxWindow *window); // Associates the given window with window 2, drawing the appropriate sash // and changing the split mode. // Does nothing and returns false if the window is already split. // A sashPosition of 0 means choose a default sash position, // negative sashPosition specifies the size of right/lower pane as it's // absolute value rather than the size of left/upper pane. virtual bool SplitVertically(wxWindow *window1, wxWindow *window2, int sashPosition = 0) { return DoSplit(wxSPLIT_VERTICAL, window1, window2, sashPosition); } virtual bool SplitHorizontally(wxWindow *window1, wxWindow *window2, int sashPosition = 0) { return DoSplit(wxSPLIT_HORIZONTAL, window1, window2, sashPosition); } // Removes the specified (or second) window from the view // Doesn't actually delete the window. bool Unsplit(wxWindow *toRemove = (wxWindow *) NULL); // Replaces one of the windows with another one (neither old nor new // parameter should be NULL) bool ReplaceWindow(wxWindow *winOld, wxWindow *winNew); // Make sure the child window sizes are updated. This is useful // for reducing flicker by updating the sizes before a // window is shown, if you know the overall size is correct. void UpdateSize(); // Is the window split? bool IsSplit() const { return (m_windowTwo != NULL); } // Sets the sash size void SetSashSize(int width) { m_sashSize = width; } // Sets the border size void SetBorderSize(int WXUNUSED(width)) { } // Gets the sash size int GetSashSize() const; // Gets the border size int GetBorderSize() const; // Set the sash position void SetSashPosition(int position, bool redraw = true); // Gets the sash position int GetSashPosition() const { return m_sashPosition; } // Set the sash gravity void SetSashGravity(double gravity); // Gets the sash gravity double GetSashGravity() const { return m_sashGravity; } // If this is zero, we can remove panes by dragging the sash. void SetMinimumPaneSize(int min); int GetMinimumPaneSize() const { return m_minimumPaneSize; } // NB: the OnXXX() functions below are for backwards compatibility only, // don't use them in new code but handle the events instead! // called when the sash position is about to change, may return a new value // for the sash or -1 to prevent the change from happening at all virtual int OnSashPositionChanging(int newSashPosition); // Called when the sash position is about to be changed, return // false from here to prevent the change from taking place. // Repositions sash to minimum position if pane would be too small. // newSashPosition here is always positive or zero. virtual bool OnSashPositionChange(int newSashPosition); // If the sash is moved to an extreme position, a subwindow // is removed from the splitter window, and the app is // notified. The app should delete or hide the window. virtual void OnUnsplit(wxWindow *removed); // Called when the sash is double-clicked. // The default behaviour is to remove the sash if the // minimum pane size is zero. virtual void OnDoubleClickSash(int x, int y); //////////////////////////////////////////////////////////////////////////// // Implementation // Paints the border and sash void OnPaint(wxPaintEvent& event); // Handles mouse events void OnMouseEvent(wxMouseEvent& ev); // Adjusts the panes void OnSize(wxSizeEvent& event); // In live mode, resize child windows in idle time void OnInternalIdle(); // Draws the sash virtual void DrawSash(wxDC& dc); // Draws the sash tracker (for whilst moving the sash) virtual void DrawSashTracker(int x, int y); // Tests for x, y over sash virtual bool SashHitTest(int x, int y, int tolerance = 5); // Resizes subwindows virtual void SizeWindows(); void SetNeedUpdating(bool needUpdating) { m_needUpdating = needUpdating; } bool GetNeedUpdating() const { return m_needUpdating ; } #ifdef __WXMAC__ virtual bool MacClipGrandChildren() const { return true ; } #endif protected: // event handlers #if defined(__WXMSW__) || defined(__WXMAC__) void OnSetCursor(wxSetCursorEvent& event); #endif // wxMSW // send the given event, return false if the event was processed and vetoed // by the user code bool DoSendEvent(wxSplitterEvent& event); // common part of all ctors void Init(); // common part of SplitVertically() and SplitHorizontally() bool DoSplit(wxSplitMode mode, wxWindow *window1, wxWindow *window2, int sashPosition); // adjusts sash position with respect to min. pane and window sizes int AdjustSashPosition(int sashPos) const; // get either width or height depending on the split mode int GetWindowSize() const; // convert the user specified sash position which may be > 0 (as is), < 0 // (specifying the size of the right pane) or 0 (use default) to the real // position to be passed to DoSetSashPosition() int ConvertSashPosition(int sashPos) const; // set the real sash position, sashPos here must be positive // // returns true if the sash position has been changed, false otherwise bool DoSetSashPosition(int sashPos); // set the sash position and send an event about it having been changed void SetSashPositionAndNotify(int sashPos); // callbacks executed when we detect that the mouse has entered or left // the sash virtual void OnEnterSash(); virtual void OnLeaveSash(); // set the cursor appropriate for the current split mode void SetResizeCursor(); // redraw the splitter if its "hotness" changed if necessary void RedrawIfHotSensitive(bool isHot); // return the best size of the splitter equal to best sizes of its // subwindows virtual wxSize DoGetBestSize() const; wxSplitMode m_splitMode; wxWindow* m_windowOne; wxWindow* m_windowTwo; int m_dragMode; int m_oldX; int m_oldY; int m_sashPosition; // Number of pixels from left or top double m_sashGravity; int m_sashSize; wxSize m_lastSize; int m_requestedSashPosition; int m_sashPositionCurrent; // while dragging int m_firstX; int m_firstY; int m_minimumPaneSize; wxCursor m_sashCursorWE; wxCursor m_sashCursorNS; wxPen *m_sashTrackerPen; // when in live mode, set this to true to resize children in idle bool m_needUpdating:1; bool m_permitUnsplitAlways:1; bool m_isHot:1; bool m_checkRequestedSashPosition:1; private: WX_DECLARE_CONTROL_CONTAINER(); DECLARE_DYNAMIC_CLASS(wxSplitterWindow) DECLARE_EVENT_TABLE() DECLARE_NO_COPY_CLASS(wxSplitterWindow) }; // ---------------------------------------------------------------------------- // event class and macros // ---------------------------------------------------------------------------- // we reuse the same class for all splitter event types because this is the // usual wxWin convention, but the three event types have different kind of // data associated with them, so the accessors can be only used if the real // event type matches with the one for which the accessors make sense class WXDLLEXPORT wxSplitterEvent : public wxNotifyEvent { public: wxSplitterEvent(wxEventType type = wxEVT_NULL, wxSplitterWindow *splitter = (wxSplitterWindow *)NULL) : wxNotifyEvent(type) { SetEventObject(splitter); if (splitter) m_id = splitter->GetId(); } // SASH_POS_CHANGED methods // setting the sash position to -1 prevents the change from taking place at // all void SetSashPosition(int pos) { wxASSERT( GetEventType() == wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED || GetEventType() == wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING); m_data.pos = pos; } int GetSashPosition() const { wxASSERT( GetEventType() == wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED || GetEventType() == wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING); return m_data.pos; } // UNSPLIT event methods wxWindow *GetWindowBeingRemoved() const { wxASSERT( GetEventType() == wxEVT_COMMAND_SPLITTER_UNSPLIT ); return m_data.win; } // DCLICK event methods int GetX() const { wxASSERT( GetEventType() == wxEVT_COMMAND_SPLITTER_DOUBLECLICKED ); return m_data.pt.x; } int GetY() const { wxASSERT( GetEventType() == wxEVT_COMMAND_SPLITTER_DOUBLECLICKED ); return m_data.pt.y; } private: friend class WXDLLIMPEXP_FWD_CORE wxSplitterWindow; // data for the different types of event union { int pos; // position for SASH_POS_CHANGED event wxWindow *win; // window being removed for UNSPLIT event struct { int x, y; } pt; // position of double click for DCLICK event } m_data; DECLARE_DYNAMIC_CLASS_NO_COPY(wxSplitterEvent) }; typedef void (wxEvtHandler::*wxSplitterEventFunction)(wxSplitterEvent&); #define wxSplitterEventHandler(func) \ (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxSplitterEventFunction, &func) #define wx__DECLARE_SPLITTEREVT(evt, id, fn) \ wx__DECLARE_EVT1(wxEVT_COMMAND_SPLITTER_ ## evt, id, wxSplitterEventHandler(fn)) #define EVT_SPLITTER_SASH_POS_CHANGED(id, fn) \ wx__DECLARE_SPLITTEREVT(SASH_POS_CHANGED, id, fn) #define EVT_SPLITTER_SASH_POS_CHANGING(id, fn) \ wx__DECLARE_SPLITTEREVT(SASH_POS_CHANGING, id, fn) #define EVT_SPLITTER_DCLICK(id, fn) \ wx__DECLARE_SPLITTEREVT(DOUBLECLICKED, id, fn) #define EVT_SPLITTER_UNSPLIT(id, fn) \ wx__DECLARE_SPLITTEREVT(UNSPLIT, id, fn) #endif // _WX_GENERIC_SPLITTER_H_
[ [ [ 1, 406 ] ] ]
08333ff08c261bd2ca02f172afb0ed7bd5af7477
b73f27ba54ad98fa4314a79f2afbaee638cf13f0
/test/TestAppUtility/ShellExtTest.h
f2a7bf463b2051bdd79d1947c7712ddf646262e7
[]
no_license
weimingtom/httpcontentparser
4d5ed678f2b38812e05328b01bc6b0c161690991
54554f163b16a7c56e8350a148b1bd29461300a0
refs/heads/master
2021-01-09T21:58:30.326476
2009-09-23T08:05:31
2009-09-23T08:05:31
48,733,304
3
0
null
null
null
null
UTF-8
C++
false
false
481
h
#ifndef _TESTAPPUTILITY_SHELLEXTTEST_H__ #define _TESTAPPUTILITY_SHELLEXTTEST_H__ #include <cppunit/extensions/HelperMacros.h> class ShellExtTest : public CPPUNIT_NS::TestFixture { public: ShellExtTest(void); ~ShellExtTest(void); CPPUNIT_TEST_SUITE(ShellExtTest); CPPUNIT_TEST(testShellExt); CPPUNIT_TEST_SUITE_END(); private: void testShellExt(); bool copyhook_installed; bool appcontrol_installed; }; #endif // _TESTAPPUTILITY_SHELLEXTTEST_H__
[ [ [ 1, 22 ] ] ]
97fe81ca50ae43d7362bc167651e66e4e4d9a74d
000b887c9052e3af1cfb46e671c0f71a56576af1
/LD18_Source/src/base.hpp
d29d6818dcd5798942e9ac9b9842fb450b2a939a
[]
no_license
PhilCK/LD18
781c999a395f64ead76bcc174908e8ec9eb21f58
a9ca4bd0224900382fb9ffda5ea934a70057b16f
refs/heads/master
2021-01-10T18:40:44.982764
2010-08-23T19:32:41
2010-08-23T19:32:41
855,157
1
0
null
null
null
null
UTF-8
C++
false
false
722
hpp
// base.hpp #ifndef __base_hpp__ #define __base_hpp__ #include <Gosu/Gosu.hpp> namespace Base { namespace Layer { enum DrawLayers { VOID_LAYER, BACKGROUND_LAYER, BUILDING_LAYER, BLOOD_SPLATTER_LAYER, ZOMBIE_LAYER, PEOPLE_LINEUP_LAYER, PLAYER_LAYER, PEOPLE_THROWN_LAYER, UI_LAYER }; }; namespace Directory { #ifdef WIN32 static const std::wstring MediaDir = Gosu::resourcePrefix() + L"media\\"; #else static const std::wstring MediaDir = Gosu::resourcePrefix() + L"media/"; #endif }; namespace Screen { static const int Width = 600; static const int Height = 800; static const bool Fullscreen = false; } }; #endif
[ [ [ 1, 44 ] ] ]
dfd393d049e543431933059735d9e3d3fd9a2e53
4b51d32f40ef5a36c98a53d2a1eab7e6f362cb00
/CapaIndices/Common/IndiceManagerFactory.cpp
14f5668a97b5782e190d236380912e63b4668128
[]
no_license
damian-pisaturo/datos7506
bcff7f1e9e69af8051ebf464107b92f91be560e4
a67aac89eccd619cdc02a7e6940980f346981895
refs/heads/master
2016-09-06T16:48:18.612868
2007-12-10T22:12:28
2007-12-10T22:12:28
32,679,551
0
0
null
null
null
null
UTF-8
C++
false
false
1,642
cpp
#include "IndiceManagerFactory.h" IndiceManagerFactory IndiceManagerFactory::instance; IndiceManager* IndiceManagerFactory::getIndiceManager(unsigned char tipoIndice, int tipoDato, ListaTipos* listaTipos, unsigned char tipoEstructura, unsigned short tamNodo, unsigned int tamBucket, const string& nombreArchivo) const { if ((tipoDato != TipoDatos::TIPO_COMPUESTO) && (listaTipos)) delete listaTipos; if ( (tipoIndice == TipoIndices::GRIEGO) || (tipoIndice == TipoIndices::ROMANO) ){ switch (tipoDato) { case TipoDatos::TIPO_ENTERO: return new IndiceEnteroManager(tamNodo, nombreArchivo, tipoEstructura); case TipoDatos::TIPO_SHORT: return new IndiceShortManager(tamNodo, nombreArchivo, tipoEstructura); case TipoDatos::TIPO_CHAR: return new IndiceCharManager(tamNodo, nombreArchivo, tipoEstructura); case TipoDatos::TIPO_BOOL: return new IndiceBooleanManager(tamNodo, nombreArchivo, tipoEstructura); case TipoDatos::TIPO_FLOAT: return new IndiceRealManager(tamNodo, nombreArchivo, tipoEstructura); case TipoDatos::TIPO_FECHA: return new IndiceFechaManager(tamNodo, nombreArchivo, tipoEstructura); case TipoDatos::TIPO_STRING: return new IndiceVariableManager(tamNodo, nombreArchivo, tipoEstructura); case TipoDatos::TIPO_COMPUESTO: return new IndiceCompuestoManager(tamNodo, nombreArchivo, tipoEstructura, listaTipos); default: return NULL; } }else if (tipoIndice == TipoIndices::HASH) return new IndiceHashManager(tamBucket, nombreArchivo); else return NULL; }
[ "dpisaturo@4ef8b2a0-b237-0410-b753-5dc98fa25004", "ecaravatti@4ef8b2a0-b237-0410-b753-5dc98fa25004", "manugarciacab@4ef8b2a0-b237-0410-b753-5dc98fa25004", "nfantone@4ef8b2a0-b237-0410-b753-5dc98fa25004" ]
[ [ [ 1, 4 ], [ 6, 7 ], [ 9, 12 ], [ 16, 16 ], [ 36, 36 ], [ 40, 42 ] ], [ [ 5, 5 ], [ 13, 13 ] ], [ [ 8, 8 ] ], [ [ 14, 15 ], [ 17, 35 ], [ 37, 39 ] ] ]
81e3c574af2ba67afa2048638578fd93ca1faacf
e1f7c2f6dd66916fe5b562d9dd4c0a5925197ec4
/Engine/Game/include/Game.h
02904c574d4dce28b0dacee438e789f9ecf0643e
[]
no_license
OtterOrder/agengineproject
de990ad91885b54a0c63adf66ff2ecc113e0109d
0b92a590af4142369e2946f692d5f30a06d32135
refs/heads/master
2020-05-27T07:44:25.593878
2011-05-01T14:52:05
2011-05-01T14:52:05
32,115,301
0
0
null
null
null
null
UTF-8
C++
false
false
483
h
#pragma once #include "AGGame.h" #include "AGTypes.h" #include "AGUtilities.h" #include "AG3DScene.h" #include "AG3DCamera.h" #include "AG3DGraphicEntity.h" class Game : public AGGame { private: AG3DScene* _mScene; AG3DCamera* _mCamera; u32 _mMouseInputsId; float _mResX; float _mResY; public: Game () {}; ~Game () {}; void InitEngine (); void Init (); void Destroy (); void Update (); }; AGGame* gGame = new Game;
[ "alban.chagnoleau@fe70d4ac-e33c-11de-8d18-5b59c22968bc" ]
[ [ [ 1, 33 ] ] ]
ff7e106d9620a3b367922d0ff92a6bda9cd859fd
854ee643a4e4d0b7a202fce237ee76b6930315ec
/arcemu_svn/src/arcemu-world/ProcCondHandler.h
3a0ac4309504e21752368324cc6035e11fee7144
[]
no_license
miklasiak/projekt
df37fa82cf2d4a91c2073f41609bec8b2f23cf66
064402da950555bf88609e98b7256d4dc0af248a
refs/heads/master
2021-01-01T19:29:49.778109
2008-11-10T17:14:14
2008-11-10T17:14:14
34,016,391
2
0
null
null
null
null
UTF-8
C++
false
false
3,255
h
/* * ArcEmu MMORPG Server * Copyright (C) 2005-2007 Ascent Team <http://www.ascentemu.com/> * Copyright (C) 2008 <http://www.ArcEmu.org/> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ #ifndef _PROCHANDLER_H_ #define _PROCHANDLER_H_ //this should be a value greater then one from dbc. Note that we waist memory if we pick a too large one // 65spellids would mean : 65k*4 bytes = 256KByte memory compiled in 32k bit mode. That is nothing :P #define MAX_SPELL_ID_FROMDBC 65535 struct SpellEntry; struct ProcTriggerSpell; class Unit; enum ProcCondHandlerRes { PROCCOND_CONTINUE_EXECUTION = 1, //we meet conditions and should cast this spell PROCCOND_BREAK_EXECUTION = 2, //it is not time to take further actions PROCCOND_FATAL_EXIT = 3, //should not happen }; struct ProcCondSharedDataStruct { Unit *owner; //the proc is registered to this guy uint32 ProcFlags; //contains the ProcFlags that called prochandler Unit *victim; //depending on procflags this can represent the target the suffered the event. Ex : damagde received, damage applied SpellEntry *CastingSpell; //in case this is a spellcast Proc then we have a value here uint32 Fulldmg; //un case of a damage proc this contains full damage that can char receive uint32 Absdmg; //fulldmg - absdmg = damage applied to target std::list< struct ProcTriggerSpell >::iterator cur_itr; //we are iterating through a list of registered handlers. We are at this one atm; int dmg_overwrite[3]; //we can force spell effects to take values as we desire like spells that recover health based on dmg }; //we registerer our functions in handler lists. This is made through function since we set non used //slots to NULL with function .... void InitProcCondHandlers(); //an idea is to make this for spellhashes instead of ids //at this step i just move old way to this one and maybe in next phase improve it extern ProcCondHandlerRes (*G_ProcCondHandlers[MAX_SPELL_ID_FROMDBC])(ProcCondSharedDataStruct *shareddata); /////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////// // Same thing but PPM related conditions /////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////// extern float (*G_ProcPPMCondHandlers[MAX_SPELL_ID_FROMDBC])(ProcCondSharedDataStruct *shareddata); #endif
[ "[email protected]@3074cc92-8d2b-11dd-8ab4-67102e0efeef" ]
[ [ [ 1, 67 ] ] ]
4e38864ea5a91903a5657895e3c40da45eff3138
57f014e835e566614a551f70f2da15145c7683ab
/src/contour/curveitem.h
92d79d5348a8b0fddf62cb6b4d3386809abfa20d
[]
no_license
vcer007/contour
d5c3a1bbd7f5c948fbda9d9bbc7d40333640568d
6917e4b4f24882df2111ca4af5634645cb2700eb
refs/heads/master
2020-05-30T05:35:15.107140
2011-05-23T12:59:00
2011-05-23T12:59:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
609
h
#ifndef CURVEITEM_H #define CURVEITEM_H #include "contourstruct.h" #include <QGraphicsItem> void drawGridPoints(GridData* data); class CurveItem :public QGraphicsItem { public: enum {Type = UserType +3}; CurveItem(QGraphicsItem* parent=0); ~CurveItem(); void setCurve(CCurve *curve); int type() const { return Type; } QRectF boundingRect() const; QPainterPath shap() const; void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0); private: CCurve *_curve; }; #endif
[ [ [ 1, 36 ] ] ]
96f6791cbc065b5d1bcd04d38f19d35007255057
90834e9db9d61688c796d0a30e77dd3acc2a9492
/SauerbratenRemote/src/engine/3dgui.cpp
bd996dcf0b0b5a19062dec20ec7643cc24ce4ce7
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference", "MIT", "Zlib" ]
permissive
zot/Plexus-original
1a79894797ca209af566bb67f72d6164869d7742
f9c3c66c697066e63ea0509c5ff9a8d6b27e369a
refs/heads/master
2020-09-20T21:51:57.194398
2009-04-21T12:45:19
2009-04-21T12:45:19
224,598,317
0
0
null
null
null
null
UTF-8
C++
false
false
37,451
cpp
// creates multiple gui windows that float inside the 3d world // special feature is that its mostly *modeless*: you can use this menu while playing, without turning menus on or off // implementationwise, it is *stateless*: it keeps no internal gui structure, hit tests are instant, usage & implementation is greatly simplified #include "pch.h" #include "engine.h" #ifdef TC #include "../remote/tc.h" #endif #include "textedit.h" static bool layoutpass, actionon = false; static int mousebuttons = 0; static struct gui *windowhit = NULL; static float firstx, firsty; static enum {FIELDCOMMIT, FIELDABORT, FIELDEDIT, FIELDSHOW} fieldmode = FIELDSHOW; static bool fieldsactive = false; static bool hascursor; float cursorx = 0.5f, cursory = 0.5f; #define SHADOW 4 #define ICON_SIZE (FONTH-SHADOW) #define SKIN_W 256 #define SKIN_H 128 #define SKIN_SCALE 4 #define INSERT (3*SKIN_SCALE) VARP(guiautotab, 6, 16, 40); VARP(guiclicktab, 0, 0, 1); struct gui : g3d_gui { struct list { int parent, w, h; }; int nextlist; static vector<list> lists; static float hitx, hity; static int curdepth, curlist, xsize, ysize, curx, cury; static bool shouldmergehits, shouldautotab; static void reset() { lists.setsize(0); } static int ty, tx, tpos, *tcurrent, tcolor; //tracking tab size and position since uses different layout method... void allowautotab(bool on) { shouldautotab = on; } void autotab() { if(tcurrent) { if(layoutpass && !tpos) tcurrent = NULL; //disable tabs because you didn't start with one if(shouldautotab && !curdepth && (layoutpass ? 0 : cury) + ysize > guiautotab*FONTH) tab(NULL, tcolor); } } bool shouldtab() { if(tcurrent && shouldautotab) { if(layoutpass) { int space = guiautotab*FONTH - ysize; if(space < 0) return true; int l = lists[curlist].parent; while(l >= 0) { space -= lists[l].h; if(space < 0) return true; l = lists[l].parent; } } else { int space = guiautotab*FONTH - cury; if(ysize > space) return true; int l = lists[curlist].parent; while(l >= 0) { if(lists[l].h > space) return true; l = lists[l].parent; } } } return false; } bool visible() { return (!tcurrent || tpos==*tcurrent) && !layoutpass; } //tab is always at top of page void tab(const char *name, int color) { if(curdepth != 0) return; if(color) tcolor = color; tpos++; if(!name) { static string title; s_sprintf(title)("%d", tpos); name = title; } int w = text_width(name) - 2*INSERT; if(layoutpass) { ty = max(ty, ysize); ysize = 0; } else { cury = -ysize; int h = FONTH-2*INSERT, x1 = curx + tx, x2 = x1 + w + ((skinx[3]-skinx[2]) + (skinx[5]-skinx[4]))*SKIN_SCALE, y1 = cury - ((skiny[5]-skiny[1])-(skiny[3]-skiny[2]))*SKIN_SCALE-h, y2 = cury; bool hit = tcurrent && windowhit==this && hitx>=x1 && hity>=y1 && hitx<x2 && hity<y2; if(hit && (!guiclicktab || mousebuttons&G3D_DOWN)) { *tcurrent = tpos; //roll-over to switch tab color = 0xFF0000; } skin_(x1-skinx[visible()?2:6]*SKIN_SCALE, y1-skiny[1]*SKIN_SCALE, w, h, visible()?10:19, 9); text_(name, x1 + (skinx[3]-skinx[2])*SKIN_SCALE - INSERT, y1 + (skiny[2]-skiny[1])*SKIN_SCALE - INSERT, tcolor, visible()); } tx += w + ((skinx[5]-skinx[4]) + (skinx[3]-skinx[2]))*SKIN_SCALE; } bool ishorizontal() const { return curdepth&1; } bool isvertical() const { return !ishorizontal(); } void pushlist() { if(layoutpass) { if(curlist>=0) { lists[curlist].w = xsize; lists[curlist].h = ysize; } list &l = lists.add(); l.parent = curlist; curlist = lists.length()-1; xsize = ysize = 0; } else { curlist = nextlist++; xsize = lists[curlist].w; ysize = lists[curlist].h; } curdepth++; } void poplist() { list &l = lists[curlist]; if(layoutpass) { l.w = xsize; l.h = ysize; } curlist = l.parent; curdepth--; if(curlist>=0) { xsize = lists[curlist].w; ysize = lists[curlist].h; if(ishorizontal()) cury -= l.h; else curx -= l.w; layout(l.w, l.h); } } int text (const char *text, int color, const char *icon) { autotab(); return button_(text, color, icon, false, false); } int button(const char *text, int color, const char *icon) { autotab(); return button_(text, color, icon, true, false); } int title (const char *text, int color, const char *icon) { autotab(); return button_(text, color, icon, false, true); } void separator() { autotab(); line_(5); } void progress(float percent) { autotab(); line_(FONTH*2/5, percent); } //use to set min size (useful when you have progress bars) void strut(int size) { layout(isvertical() ? size*FONTW : 0, isvertical() ? 0 : size*FONTH); } //add space between list items void space(int size) { layout(isvertical() ? 0 : size*FONTW, isvertical() ? size*FONTH : 0); } int layout(int w, int h) { if(layoutpass) { if(ishorizontal()) { xsize += w; ysize = max(ysize, h); } else { xsize = max(xsize, w); ysize += h; } return 0; } else { bool hit = ishit(w, h); if(ishorizontal()) curx += w; else cury += h; return (hit && visible()) ? mousebuttons|G3D_ROLLOVER : 0; } } void mergehits(bool on) { shouldmergehits = on; } bool ishit(int w, int h, int x = curx, int y = cury) { if(shouldmergehits) return windowhit==this && (ishorizontal() ? hitx>=x && hitx<x+w : hity>=y && hity<y+h); if(ishorizontal()) h = ysize; else w = xsize; return windowhit==this && hitx>=x && hity>=y && hitx<x+w && hity<y+h; } int image(Texture *t, float scale, bool overlaid) { autotab(); if(scale==0) scale = 1; int size = (int)(scale*2*FONTH)-SHADOW; if(visible()) icon_(t, overlaid, false, curx, cury, size, ishit(size+SHADOW, size+SHADOW)); return layout(size+SHADOW, size+SHADOW); } int texture(Texture *t, float scale, int rotate, int xoff, int yoff, Texture *glowtex, const vec &glowcolor) { autotab(); if(scale==0) scale = 1; int size = (int)(scale*2*FONTH)-SHADOW; if(t!=notexture && visible()) icon_(t, true, true, curx, cury, size, ishit(size+SHADOW, size+SHADOW), rotate, xoff, yoff, glowtex, glowcolor); return layout(size+SHADOW, size+SHADOW); } void slider(int &val, int vmin, int vmax, int color, char *label) { autotab(); int x = curx; int y = cury; line_(10); if(visible()) { if(!label) { static string s; s_sprintf(s)("%d", val); label = s; } int w = text_width(label); bool hit; int px, py; if(ishorizontal()) { hit = ishit(FONTH, ysize, x, y); px = x + (FONTH-w)/2; py = y + (ysize-FONTH) - ((ysize-FONTH)*(val-vmin))/((vmax==vmin) ? 1 : (vmax-vmin)); //vmin at bottom } else { hit = ishit(xsize, FONTH, x, y); px = x + FONTH/2 - w/2 + ((xsize-w)*(val-vmin))/((vmax==vmin) ? 1 : (vmax-vmin)); //vmin at left py = y; } if(hit) color = 0xFF0000; text_(label, px, py, color, hit && actionon); if(hit && actionon) { int vnew = (vmin < vmax ? 1 : -1)+vmax-vmin; if(ishorizontal()) vnew = int(vnew*(y+ysize-FONTH/2-hity)/(ysize-FONTH)); else vnew = int(vnew*(hitx-x-FONTH/2)/(xsize-w)); vnew += vmin; vnew = vmin < vmax ? clamp(vnew, vmin, vmax) : clamp(vnew, vmax, vmin); if(vnew != val) val = vnew; } } } char *field(const char *name, int color, int length, int height, const char *initval, int initmode) { editor *e = useeditor(name, initmode, false, initval); // generate a new editor if necessary if(layoutpass) { if(initval && e->mode==EDITORFOCUSED && (e!=currentfocus() || fieldmode == FIELDSHOW)) { if(strcmp(e->lines[0].text, initval)) e->clear(initval); } e->linewrap = (length<0); e->maxx = (e->linewrap) ? -1 : length; e->maxy = (height<=0)?1:-1; e->pixelwidth = abs(length)*FONTW; if(e->linewrap && e->maxy==1) { int temp; text_bounds(e->lines[0].text, temp, e->pixelheight, e->pixelwidth); //only single line editors can have variable height } else e->pixelheight = FONTH*max(height, 1); } int h = e->pixelheight; int w = e->pixelwidth + FONTW; bool wasvertical = isvertical(); if(wasvertical && e->maxy != 1) pushlist(); char *result = NULL; if(visible() && !layoutpass) { bool hit = ishit(w, h); if(hit) { if(mousebuttons&G3D_DOWN) //mouse request focus { useeditor(name, initmode, true); e->mark(false); fieldmode = FIELDEDIT; } } bool editing = (fieldmode != FIELDSHOW) && (e==currentfocus()); if(hit && editing && (mousebuttons&G3D_PRESSED)!=0) e->hit(int(floor(hitx-(curx+FONTW/2))), int(floor(hity-cury)), (mousebuttons&G3D_DRAGGED)!=0); //mouse request position if(editing && ((fieldmode==FIELDCOMMIT) || (fieldmode==FIELDABORT) || !hit)) // commit field if user pressed enter or wandered out of focus { if(fieldmode==FIELDCOMMIT || (fieldmode!=FIELDABORT && !hit)) result = e->currentline().text; e->active = (e->mode!=EDITORFOCUSED); fieldmode = FIELDSHOW; } else fieldsactive = true; e->draw(curx+FONTW/2, cury, color, hit && editing); notextureshader->set(); glDisable(GL_TEXTURE_2D); if(editing) glColor3f(1, 0, 0); else glColor3ub(color>>16, (color>>8)&0xFF, color&0xFF); glBegin(GL_LINE_LOOP); rect_(curx, cury, w, h); glEnd(); glEnable(GL_TEXTURE_2D); defaultshader->set(); } layout(w, h); if(e->maxy != 1) { int slines = e->lines.length()-e->pixelheight/FONTH; if(slines > 0) { int pos = e->scrolly; slider(e->scrolly, slines, 0, color, NULL); if(pos != e->scrolly) e->cy = e->scrolly; } if(wasvertical) poplist(); } return result; } void rect_(float x, float y, float w, float h, int usetc = -1) { static const GLfloat tc[4][2] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; if(usetc>=0) glTexCoord2fv(tc[usetc]); glVertex2f(x, y); if(usetc>=0) glTexCoord2fv(tc[(usetc+1)%4]); glVertex2f(x + w, y); if(usetc>=0) glTexCoord2fv(tc[(usetc+2)%4]); glVertex2f(x + w, y + h); if(usetc>=0) glTexCoord2fv(tc[(usetc+3)%4]); glVertex2f(x, y + h); xtraverts += 4; } void text_(const char *text, int x, int y, int color, bool shadow) { if(shadow) draw_text(text, x+SHADOW, y+SHADOW, 0x00, 0x00, 0x00, 0xC0); draw_text(text, x, y, color>>16, (color>>8)&0xFF, color&0xFF); } void background(int color, int inheritw, int inherith) { if(layoutpass) return; glDisable(GL_TEXTURE_2D); notextureshader->set(); glColor4ub(color>>16, (color>>8)&0xFF, color&0xFF, 0x80); int w = xsize, h = ysize; if(inheritw>0) { int parentw = curlist; while(inheritw>0 && lists[parentw].parent>=0) { parentw = lists[parentw].parent; inheritw--; } w = lists[parentw].w; } if(inherith>0) { int parenth = curlist; while(inherith>0 && lists[parenth].parent>=0) { parenth = lists[parenth].parent; inherith--; } h = lists[parenth].h; } glBegin(GL_QUADS); rect_(curx, cury, w, h); glEnd(); glEnable(GL_TEXTURE_2D); defaultshader->set(); } void icon_(Texture *t, bool overlaid, bool tiled, int x, int y, int size, bool hit, int rotate = 0, int xoff = 0, int yoff = 0, Texture *glowtex = NULL, const vec &glowcolor = vec(1, 1, 1)) { float xs, ys, xt, yt; if(tiled) { xt = min(1.0f, t->xs/(float)t->ys), yt = min(1.0f, t->ys/(float)t->xs); xs = size; ys = size; } else { xt = 1.0f; yt = 1.0f; float scale = float(size)/max(t->xs, t->ys); //scale and preserve aspect ratio xs = t->xs*scale; ys = t->ys*scale; x += int((size-xs)/2); y += int((size-ys)/2); } if(hit && actionon) { glDisable(GL_TEXTURE_2D); notextureshader->set(); glColor4f(0, 0, 0, 0.75f); glBegin(GL_QUADS); rect_(x+SHADOW, y+SHADOW, xs, ys); glEnd(); glEnable(GL_TEXTURE_2D); defaultshader->set(); } if(tiled) { static Shader *rgbonlyshader = NULL; if(!rgbonlyshader) rgbonlyshader = lookupshaderbyname("rgbonly"); rgbonlyshader->set(); } float tc[4][2] = { { 0, 0 }, { 1, 0 }, { 1, 1 }, { 0, 1 } }; if(rotate) { if((rotate&5) == 1) { swap(xoff, yoff); loopk(4) swap(tc[k][0], tc[k][1]); } if(rotate >= 2 && rotate <= 4) { xoff *= -1; loopk(4) tc[k][0] *= -1; } if(rotate <= 2 || rotate == 5) { yoff *= -1; loopk(4) tc[k][1] *= -1; } } loopk(4) { tc[k][0] = tc[k][0]/xt - float(xoff)/t->xs; tc[k][1] = tc[k][1]/yt - float(yoff)/t->ys; } vec color = hit ? vec(1, 0.5f, 0.5f) : (overlaid ? vec(1, 1, 1) : light); glColor3fv(color.v); glBindTexture(GL_TEXTURE_2D, t->id); glBegin(GL_QUADS); glTexCoord2fv(tc[0]); glVertex2f(x, y); glTexCoord2fv(tc[1]); glVertex2f(x+xs, y); glTexCoord2fv(tc[2]); glVertex2f(x+xs, y+ys); glTexCoord2fv(tc[3]); glVertex2f(x, y+ys); glEnd(); if(glowtex) { if(hit || overlaid) { loopk(3) color[k] *= glowcolor[k]; glColor3fv(color.v); } else glColor3fv(glowcolor.v); glBlendFunc(GL_SRC_ALPHA, GL_ONE); glBindTexture(GL_TEXTURE_2D, glowtex->id); glBegin(GL_QUADS); glTexCoord2fv(tc[0]); glVertex2f(x, y); glTexCoord2fv(tc[1]); glVertex2f(x+xs, y); glTexCoord2fv(tc[2]); glVertex2f(x+xs, y+ys); glTexCoord2fv(tc[3]); glVertex2f(x, y+ys); glEnd(); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } if(tiled) defaultshader->set(); if(overlaid) { #ifdef TC char buf[256]; extern char *tc_guipath; snprintf(buf, sizeof(buf), "%s%cguioverlay.png", (tc_guipath == NULL || *tc_guipath == '\0') ? "data" : tc_guipath, PATHDIV); if(!overlaytex || 0 != strcmp(buf, overlaytex->name)) overlaytex = textureload(buf); #else if(!overlaytex) overlaytex = textureload("data/guioverlay.png"); #endif glColor3fv(light.v); glBindTexture(GL_TEXTURE_2D, overlaytex->id); glBegin(GL_QUADS); rect_(x, y, xs, ys, 0); glEnd(); } } void line_(int size, float percent = 1.0f) { if(visible()) { #ifdef TC char buf[256]; extern char *tc_guipath; snprintf(buf, sizeof(buf), "%s%cguislider.png", (tc_guipath == NULL || *tc_guipath == '\0') ? "data" : tc_guipath, PATHDIV); if(!slidertex || 0 != strcmp(buf, slidertex->name)) slidertex = textureload(buf); #else if(!slidertex) slidertex = textureload("data/guislider.png"); #endif glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, slidertex->id); glBegin(GL_QUADS); if(percent < 0.99f) { glColor4f(light.x, light.y, light.z, 0.375f); if(ishorizontal()) rect_(curx + FONTH/2 - size, cury, size*2, ysize, 0); else rect_(curx, cury + FONTH/2 - size, xsize, size*2, 1); } glColor3fv(light.v); if(ishorizontal()) rect_(curx + FONTH/2 - size, cury + ysize*(1-percent), size*2, ysize*percent, 0); else rect_(curx, cury + FONTH/2 - size, xsize*percent, size*2, 1); glEnd(); } layout(ishorizontal() ? FONTH : 0, ishorizontal() ? 0 : FONTH); } int button_(const char *text, int color, const char *icon, bool clickable, bool center) { const int padding = 10; int w = 0; if(icon) w += ICON_SIZE; if(icon && text) w += padding; if(text) w += text_width(text); if(visible()) { bool hit = ishit(w, FONTH); if(hit && clickable) color = 0xFF0000; int x = curx; if(isvertical() && center) x += (xsize-w)/2; if(icon) { #ifdef TC char tname[256]; extern char *tc_guipath; snprintf(tname, sizeof(tname), "%s%cicons%c%s.jpg", (tc_guipath == NULL || *tc_guipath == '\0') ? "packages" : tc_guipath, PATHDIV, PATHDIV, icon); #else s_sprintfd(tname)("packages/icons/%s.jpg", icon); #endif icon_(textureload(tname), false, false, x, cury, ICON_SIZE, clickable && hit); x += ICON_SIZE; } if(icon && text) x += padding; if(text) text_(text, x, cury, color, center || (hit && clickable && actionon)); } return layout(w, FONTH); } static Texture *skintex, *overlaytex, *slidertex; static const int skinx[], skiny[]; static const struct patch { ushort left, right, top, bottom; uchar flags; } patches[]; void skin_(int x, int y, int gapw, int gaph, int start, int n)//int vleft, int vright, int vtop, int vbottom, int start, int n) { #ifdef TC char buf[256]; extern char *tc_guipath; snprintf(buf, sizeof(buf), "%s%cguiskin.png", (tc_guipath == NULL || *tc_guipath == '\0') ? "data" : tc_guipath, PATHDIV); if(!skintex || 0 != strcmp(buf, skintex->name)) skintex = textureload(buf); #else if(!skintex) skintex = textureload("data/guiskin.png"); #endif glBindTexture(GL_TEXTURE_2D, skintex->id); int gapx1 = INT_MAX, gapy1 = INT_MAX, gapx2 = INT_MAX, gapy2 = INT_MAX; float wscale = 1.0f/(SKIN_W*SKIN_SCALE), hscale = 1.0f/(SKIN_H*SKIN_SCALE); loopj(gui2d ? 1 : 2) { bool quads = false; if(!gui2d) glDepthFunc(j ? GL_LEQUAL : GL_GREATER); glColor4f(j ? light.x : 1.0f, j ? light.y : 1.0f, j ? light.z : 1.0f, gui2d || j ? 0.80f : 0.35f); //ghost when its behind something in depth loopi(n) { const patch &p = patches[start+i]; int left = skinx[p.left]*SKIN_SCALE, right = skinx[p.right]*SKIN_SCALE, top = skiny[p.top]*SKIN_SCALE, bottom = skiny[p.bottom]*SKIN_SCALE; float tleft = left*wscale, tright = right*wscale, ttop = top*hscale, tbottom = bottom*hscale; if(p.flags&0x1) { gapx1 = left; gapx2 = right; } else if(left >= gapx2) { left += gapw - (gapx2-gapx1); right += gapw - (gapx2-gapx1); } if(p.flags&0x10) { gapy1 = top; gapy2 = bottom; } else if(top >= gapy2) { top += gaph - (gapy2-gapy1); bottom += gaph - (gapy2-gapy1); } //multiple tiled quads if necessary rather than a single stretched one int ystep = bottom-top; int yo = y+top; while(ystep > 0) { if(p.flags&0x10 && yo+ystep-(y+top) > gaph) { ystep = gaph+y+top-yo; tbottom = ttop+ystep*hscale; } int xstep = right-left; int xo = x+left; float tright2 = tright; while(xstep > 0) { if(p.flags&0x01 && xo+xstep-(x+left) > gapw) { xstep = gapw+x+left-xo; tright = tleft+xstep*wscale; } if(!quads) { quads = true; glBegin(GL_QUADS); } glTexCoord2f(tleft, ttop); glVertex2f(xo, yo); glTexCoord2f(tright, ttop); glVertex2f(xo+xstep, yo); glTexCoord2f(tright, tbottom); glVertex2f(xo+xstep, yo+ystep); glTexCoord2f(tleft, tbottom); glVertex2f(xo, yo+ystep); xtraverts += 4; if(!(p.flags&0x01)) break; xo += xstep; } tright = tright2; if(!(p.flags&0x10)) break; yo += ystep; } } if(quads) glEnd(); else break; //if it didn't happen on the first pass, it won't happen on the second.. } if(!gui2d) glDepthFunc(GL_ALWAYS); } vec origin, scale, *savedorigin; float dist; g3d_callback *cb; bool gui2d; static float basescale, maxscale; static bool passthrough; static vec light; void adjustscale() { int w = xsize + (skinx[2]-skinx[1])*SKIN_SCALE + (skinx[10]-skinx[9])*SKIN_SCALE, h = ysize + (skiny[8]-skiny[6])*SKIN_SCALE; if(tcurrent) h += ((skiny[5]-skiny[1])-(skiny[3]-skiny[2]))*SKIN_SCALE + FONTH-2*INSERT; else h += (skiny[5]-skiny[3])*SKIN_SCALE; float aspect = float(screen->h)/float(screen->w), fit = 1.0f; if(w*aspect*basescale>1.0f) fit = 1.0f/(w*aspect*basescale); if(h*basescale*fit>maxscale) fit *= maxscale/(h*basescale*fit); origin = vec(0.5f-((w-xsize)/2 - (skinx[2]-skinx[1])*SKIN_SCALE)*aspect*scale.x*fit, 0.5f + (0.5f*h-(skiny[8]-skiny[6])*SKIN_SCALE)*scale.y*fit, 0); scale = vec(aspect*scale.x*fit, scale.y*fit, 1); } void start(int starttime, float initscale, int *tab, bool allowinput) { if(gui2d) { initscale *= 0.025f; if(allowinput) hascursor = true; } basescale = initscale; if(layoutpass) scale.x = scale.y = scale.z = basescale*min((totalmillis-starttime)/300.0f, 1.0f); passthrough = scale.x<basescale || !allowinput; curdepth = -1; curlist = -1; tpos = 0; tx = 0; ty = 0; tcurrent = tab; tcolor = 0xFFFFFF; pushlist(); if(layoutpass) nextlist = curlist; else { if(tcurrent && !*tcurrent) tcurrent = NULL; cury = -ysize; curx = -xsize/2; glPushMatrix(); if(gui2d) { glTranslatef(origin.x, origin.y, origin.z); glScalef(scale.x, scale.y, scale.z); light = vec(1, 1, 1); } else { float yaw = atan2f(origin.y-camera1->o.y, origin.x-camera1->o.x); glTranslatef(origin.x, origin.y, origin.z); glRotatef(yaw/RAD-90, 0, 0, 1); glRotatef(-90, 1, 0, 0); glScalef(-scale.x, scale.y, scale.z); vec dir; lightreaching(origin, light, dir, 0, 0.5f); float intensity = vec(yaw, 0.0f).dot(dir); light.mul(1.0f + max(intensity, 0.0f)); } skin_(curx-skinx[2]*SKIN_SCALE, cury-skiny[5]*SKIN_SCALE, xsize, ysize, 0, 9); if(!tcurrent) skin_(curx-skinx[5]*SKIN_SCALE, cury-skiny[5]*SKIN_SCALE, xsize, 0, 9, 1); } } void end() { if(layoutpass) { xsize = max(tx, xsize); ysize = max(ty, ysize); ysize = max(ysize, (skiny[6]-skiny[5])*SKIN_SCALE); if(tcurrent) *tcurrent = max(1, min(*tcurrent, tpos)); if(gui2d) adjustscale(); if(!windowhit && !passthrough) { int intersects = INTERSECT_MIDDLE; if(gui2d) { hitx = (cursorx - origin.x)/scale.x; hity = (cursory - origin.y)/scale.y; } else { vec planenormal = vec(origin).sub(camera1->o).set(2, 0).normalize(), intersectionpoint; intersects = intersect_plane_line(camera1->o, worldpos, origin, planenormal, intersectionpoint); vec intersectionvec = vec(intersectionpoint).sub(origin), xaxis(-planenormal.y, planenormal.x, 0); hitx = xaxis.dot(intersectionvec)/scale.x; hity = -intersectionvec.z/scale.y; } if((mousebuttons & G3D_PRESSED) && (fabs(hitx-firstx) > 2 || fabs(hity - firsty) > 2)) mousebuttons |= G3D_DRAGGED; if(intersects>=INTERSECT_MIDDLE && hitx>=-xsize/2 && hitx<=xsize/2 && hity<=0) { if(hity>=-ysize || (tcurrent && hity>=-ysize-(FONTH-2*INSERT)-((skiny[5]-skiny[1])-(skiny[3]-skiny[2]))*SKIN_SCALE && hitx<=tx-xsize/2)) windowhit = this; } } } else { if(tcurrent && tx<xsize) skin_(curx+tx-skinx[5]*SKIN_SCALE, -ysize-skiny[5]*SKIN_SCALE, xsize-tx, FONTH, 9, 1); glPopMatrix(); } poplist(); } }; Texture *gui::skintex = NULL, *gui::overlaytex = NULL, *gui::slidertex = NULL; //chop skin into a grid const int gui::skiny[] = {0, 7, 21, 34, 48, 56, 104, 111, 116, 128}, gui::skinx[] = {0, 11, 23, 37, 105, 119, 137, 151, 215, 229, 245, 256}; //Note: skinx[3]-skinx[2] = skinx[7]-skinx[6] // skinx[5]-skinx[4] = skinx[9]-skinx[8] const gui::patch gui::patches[] = { //arguably this data can be compressed - it depends on what else needs to be skinned in the future {1,2,3,5, 0}, // body {2,9,4,5, 0x01}, {9,10,3,5, 0}, {1,2,5,6, 0x10}, {2,9,5,6, 0x11}, {9,10,5,6, 0x10}, {1,2,6,8, 0}, {2,9,6,8, 0x01}, {9,10,6,8, 0}, {5,6,3,4, 0x01}, // top {2,3,1,2, 0}, // selected tab {3,4,1,2, 0x01}, {4,5,1,2, 0}, {2,3,2,3, 0x10}, {3,4,2,3, 0x11}, {4,5,2,3, 0x10}, {2,3,3,4, 0}, {3,4,3,4, 0x01}, {4,5,3,4, 0}, {6,7,1,2, 0}, // deselected tab {7,8,1,2, 0x01}, {8,9,1,2, 0}, {6,7,2,3, 0x10}, {7,8,2,3, 0x11}, {8,9,2,3, 0x10}, {6,7,3,4, 0}, {7,8,3,4, 0x01}, {8,9,3,4, 0}, }; vector<gui::list> gui::lists; float gui::basescale, gui::maxscale = 1, gui::hitx, gui::hity; bool gui::passthrough, gui::shouldmergehits = false, gui::shouldautotab = true; vec gui::light; int gui::curdepth, gui::curlist, gui::xsize, gui::ysize, gui::curx, gui::cury; int gui::ty, gui::tx, gui::tpos, *gui::tcurrent, gui::tcolor; static vector<gui> guis2d, guis3d; VARP(guipushdist, 1, 4, 64); bool menukey(int code, bool isdown, int cooked) { if(code==-1 && g3d_windowhit(isdown, true)) return true; else if(code==-3 && g3d_windowhit(isdown, false)) return true; editor *e = currentfocus(); if((fieldmode == FIELDSHOW) || !e) { if(windowhit) switch(code) { case -4: // window "management" if(isdown) { if(windowhit->gui2d) { vec origin = *guis2d.last().savedorigin; int i = windowhit - &guis2d[0]; for(int j = guis2d.length()-1; j > i; j--) *guis2d[j].savedorigin = *guis2d[j-1].savedorigin; *windowhit->savedorigin = origin; if(guis2d.length() > 1) { if(camera1->o.dist(*windowhit->savedorigin) <= camera1->o.dist(*guis2d.last().savedorigin)) windowhit->savedorigin->add(camdir); } } else windowhit->savedorigin->add(vec(camdir).mul(guipushdist)); } return true; case -5: if(isdown) { if(windowhit->gui2d) { vec origin = *guis2d[0].savedorigin; loopj(guis2d.length()-1) *guis2d[j].savedorigin = *guis2d[j + 1].savedorigin; *guis2d.last().savedorigin = origin; if(guis2d.length() > 1) { if(camera1->o.dist(*guis2d.last().savedorigin) >= camera1->o.dist(*guis2d[0].savedorigin)) guis2d.last().savedorigin->sub(camdir); } } else windowhit->savedorigin->sub(vec(camdir).mul(guipushdist)); } return true; } return false; } switch(code) { case SDLK_ESCAPE: //cancel editing without commit if(isdown) fieldmode = FIELDABORT; return true; case SDLK_RETURN: case SDLK_TAB: if(cooked && (e->maxy != 1)) break; case SDLK_KP_ENTER: if(isdown) fieldmode = FIELDCOMMIT; //signal field commit (handled when drawing field) return true; case SDLK_HOME: case SDLK_END: case SDLK_PAGEUP: case SDLK_PAGEDOWN: case SDLK_DELETE: case SDLK_BACKSPACE: case SDLK_UP: case SDLK_DOWN: case SDLK_LEFT: case SDLK_RIGHT: case -4: case -5: break; default: if(!cooked || (code<32)) return false; } if(!isdown) return true; e->key(code, cooked); return true; } void g3d_cursorpos(float &x, float &y) { if(guis2d.length()) { x = cursorx; y = cursory; } else x = y = 0.5f; } void g3d_resetcursor() { cursorx = cursory = 0.5f; } #ifdef TC void tc_movecursor(int x, int y, bool hide) { if (hide) { cursorx = cursory = 2.0; return; } //fprintf(stderr, "Mouse pos is %d x %d\n", x, y); cursorx = x / (float) screen->w; cursory = y / (float) screen->h; } void tc_getcursorpos(float &x, float &y) { x = cursorx; y = cursory; } void tc_setcursorpos(float x, float y) { cursorx = x; cursory = y; } #endif bool g3d_movecursor(int dx, int dy) { #ifdef TC extern int tcmode; if (tcmode) return false; #endif if(!guis2d.length() || !hascursor) return false; const float CURSORSCALE = 500.0f; cursorx = max(0.0f, min(1.0f, cursorx+dx*(screen->h/(screen->w*CURSORSCALE)))); cursory = max(0.0f, min(1.0f, cursory+dy/CURSORSCALE)); return true; } VARNP(guifollow, useguifollow, 0, 1, 1); VARNP(gui2d, usegui2d, 0, 1, 1); void g3d_addgui(g3d_callback *cb, vec &origin, int flags) { bool gui2d = flags&GUI_FORCE_2D || (flags&GUI_2D && usegui2d); if(!gui2d && flags&GUI_FOLLOW && useguifollow) origin.z = player->o.z-(player->eyeheight-1); gui &g = (gui2d ? guis2d : guis3d).add(); g.cb = cb; g.origin = origin; g.savedorigin = &origin; g.dist = camera1->o.dist(g.origin); g.gui2d = gui2d; } void g3d_limitscale(float scale) { gui::maxscale = scale; } int g3d_sort(gui *a, gui *b) { return (int)(a->dist>b->dist)*2-1; } bool g3d_windowhit(bool on, bool act) { extern int cleargui(int n); if(act) { if(on) { firstx = gui::hitx; firsty = gui::hity; } mousebuttons |= (actionon=on) ? G3D_DOWN : G3D_UP; } else if(!on && windowhit) cleargui(1); return (guis2d.length() && hascursor) || (windowhit && !windowhit->gui2d); } void g3d_render() { windowhit = NULL; if(actionon) mousebuttons |= G3D_PRESSED; gui::reset(); guis2d.setsize(0); guis3d.setsize(0); // call all places in the engine that may want to render a gui from here, they call g3d_addgui() extern void g3d_texturemenu(); g3d_texturemenu(); g3d_mainmenu(); cl->g3d_gamemenus(); guis2d.sort(g3d_sort); guis3d.sort(g3d_sort); readyeditors(); bool wasfocused = (fieldmode!=FIELDSHOW); fieldsactive = false; hascursor = false; layoutpass = true; loopv(guis2d) guis2d[i].cb->gui(guis2d[i], true); loopv(guis3d) guis3d[i].cb->gui(guis3d[i], true); layoutpass = false; if(guis2d.length() || guis3d.length()) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } if(guis3d.length()) { glDepthFunc(GL_ALWAYS); glDepthMask(GL_FALSE); loopvrev(guis3d) guis3d[i].cb->gui(guis3d[i], false); glDepthFunc(GL_LESS); glDepthMask(GL_TRUE); } if(guis2d.length()) { glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(0, 1, 1, 0, -1, 1); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glDisable(GL_DEPTH_TEST); loopvrev(guis2d) guis2d[i].cb->gui(guis2d[i], false); glEnable(GL_DEPTH_TEST); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); } if(guis2d.length() || guis3d.length()) { glDisable(GL_BLEND); } flusheditors(); if(!fieldsactive) fieldmode = FIELDSHOW; //didn't draw any fields, so loose focus - mainly for menu closed if((fieldmode!=FIELDSHOW) != wasfocused) { SDL_EnableUNICODE(fieldmode!=FIELDSHOW); keyrepeat(fieldmode!=FIELDSHOW || editmode); } mousebuttons = 0; }
[ "bill@sheba.(none)", "[email protected]", "[email protected]" ]
[ [ [ 1, 8 ], [ 13, 24 ], [ 26, 503 ], [ 510, 510 ], [ 512, 523 ], [ 530, 530 ], [ 532, 569 ], [ 575, 575 ], [ 577, 591 ], [ 598, 598 ], [ 600, 937 ], [ 960, 960 ], [ 962, 964 ], [ 967, 1093 ] ], [ [ 9, 12 ], [ 504, 509 ], [ 511, 511 ], [ 524, 529 ], [ 531, 531 ], [ 570, 574 ], [ 576, 576 ], [ 592, 597 ], [ 599, 599 ] ], [ [ 25, 25 ], [ 938, 959 ], [ 961, 961 ], [ 965, 966 ] ] ]
cdd735868bc05f2c940bb964e2be8c3f443c5f64
777399eafeb952743fcb973fbba392842c2e9b14
/CyberneticWarrior/CyberneticWarrior/source/CFire.cpp
fbfb999458590ec36174f05a74d74d83b166e297
[]
no_license
Warbeleth/cyberneticwarrior
7c0af33ada4d461b90dc843c6a25cd5dc2ba056a
21959c93d638b5bc8a881f75119d33d5708a3ea9
refs/heads/master
2021-01-10T14:31:27.017284
2010-11-23T23:16:28
2010-11-23T23:16:28
53,352,209
0
0
null
null
null
null
UTF-8
C++
false
false
1,253
cpp
#include "PrecompiledHeader.h" #include "CFire.h" #include "CGame.h" #include "CSinglePlayerState.h" CFire::CFire(void) { this->SetType(OBJ_FIRE); this->SetImageID(CSinglePlayerState::GetInstance()->GetWeaponID()); m_rRender.top = 610; m_rRender.left = 550; m_rRender.right = 610; m_rRender.bottom = 550; } CFire::~CFire(void) { } void CFire::Update(float fElapsedTime) { CBaseProjectile::Update( fElapsedTime ); if( m_bDead ) CGame::GetInstance()->GetMessageSystemPointer()->SendMsg( new CDestroyFireMessage( this, this->GetOwner()) ); } bool CFire::CheckCollision(CBase *pBase) { if(CBaseProjectile::CheckCollision( pBase )) { // Destroy the bullet //CGame::GetInstance()->GetMessageSystemPointer()->SendMsg( new CDestroyFireMessage( this, CSinglePlayerState::GetInstance()->GetPlayerPointer()) ); if(this->GetOwner()->GetType() == OBJ_ENEMY) { if(pBase->GetType() != OBJ_ENEMY) CGame::GetInstance()->GetMessageSystemPointer()->SendMsg( new CDestroyFireMessage( this, this->GetOwner()) ); } else { CGame::GetInstance()->GetMessageSystemPointer()->SendMsg( new CDestroyFireMessage( this, this->GetOwner()) ); } return true; } else return false; }
[ "[email protected]", "atmuccio@d49f6b0b-9fae-41b6-31ce-67b77e794db9" ]
[ [ [ 1, 10 ], [ 15, 16 ], [ 18, 18 ], [ 20, 20 ], [ 27, 30 ], [ 35, 43 ], [ 45, 46 ], [ 48, 49 ] ], [ [ 11, 14 ], [ 17, 17 ], [ 19, 19 ], [ 21, 26 ], [ 31, 34 ], [ 44, 44 ], [ 47, 47 ] ] ]
c44f5ba6e659cc633a98c47510a73eab39d1c1dc
0b55a33f4df7593378f58b60faff6bac01ec27f3
/Konstruct/Client/Dimensions/HeadButt.h
d53589663b1eb64ec48d39b4f30111d67ac4b418
[]
no_license
RonOHara-GG/dimgame
8d149ffac1b1176432a3cae4643ba2d07011dd8e
bbde89435683244133dca9743d652dabb9edf1a4
refs/heads/master
2021-01-10T21:05:40.480392
2010-09-01T20:46:40
2010-09-01T20:46:40
32,113,739
1
0
null
null
null
null
UTF-8
C++
false
false
296
h
#pragma once #include "strike.h" class BearHug; class HeadButt : public Strike { public: HeadButt(void); ~HeadButt(void); bool Activate(PlayerCharacter* pSkillOwner); bool Update(PlayerCharacter* pSkillOwner, float fDeltaTime); protected: Skill* m_pCurrentBearHug; };
[ "bflassing@0c57dbdb-4d19-7b8c-568b-3fe73d88484e" ]
[ [ [ 1, 18 ] ] ]
8d5aee3790f100664c21b45b5cd002e968be5bd4
283d1a3bae9162d16f7755a1b024a6bf709282bc
/SJ 3 Top 03conveyor/src/calibration/ofxLabGui/guiTypeLogger.h
f07b7bd63280f70653c87420444e3a26561fda52
[]
no_license
imclab/SanJoseZero1
aac1ada36a0f21ca43f3d2541c1458600d9ab762
4a99dea9850c056ff1930e6e6deebbf02f82956e
refs/heads/master
2021-01-22T15:22:46.078940
2010-10-28T21:35:44
2010-10-28T21:35:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,258
h
#pragma once #include "guiBaseObject.h" #include "guiColor.h" #include "simpleColor.h" #include "guiValue.h" #include "simpleLogger.h" class guiTypeLogger : public guiBaseObject{ public: guiTypeLogger(){ log = NULL; pct = 0; } //------------------------------------------------ void setup(string loggerName, simpleLogger * logger, float loggerWidth, float loggerHeight){ log = logger; name = loggerName; updateText(); setDimensions(loggerWidth, loggerHeight); hitArea.width = 20; outlineColor.selected = outlineColor.color; } //-----------------------------------------------. bool updateGui(float x, float y, bool firstHit, bool isRelative){ if( state == SG_STATE_SELECTED){ pct = ( y - ( hitArea.y ) ) / hitArea.height; pct = ofClamp(pct, 0, 1); return true; } return false; } //-----------------------------------------------. void drawRecords(float x, float y, float width, float height){ if( log == NULL)return; if( log->logs.size() == 0)return; ofPushStyle(); float yPos = 13; int startPos = (float)(log->logs.size()-1) * (1.0-pct); for(int i = startPos; i >= 0; i--){ string str = log->logs[i].logStr; if( str.length() * 8> width ){ int newLen = (float)width / 8; //newLen = ofClamp(newLen, 1, 999999); str = str.substr(0, newLen); } displayText.renderString(str, x, y + yPos); yPos += 13.6; if(yPos +14 >= height)break; } ofPopStyle(); } //-----------------------------------------------. void render(){ ofPushStyle(); glPushMatrix(); //draw the background ofFill(); glColor4fv(bgColor.getColorF()); ofRect(boundingBox.x, boundingBox.y, boundingBox.width, boundingBox.height); glColor4fv(textColor.getColorF()); guiBaseObject::renderText(); ofFill(); glColor4fv(fgColor.getColorF()); ofRect(hitArea.x, hitArea.y + (hitArea.height - 5) * pct, hitArea.width, 5); ofNoFill(); glColor4fv(outlineColor.getColorF()); ofRect(boundingBox.x, boundingBox.y, boundingBox.width, boundingBox.height); ofRect(hitArea.x , hitArea.y, hitArea.width, hitArea.height); glColor4fv(textColor.getColorF()); if(log != NULL)drawRecords(hitArea.x+hitArea.width + 5, hitArea.y, boundingBox.width-(hitArea.width + 5), boundingBox.height); glPopMatrix(); ofPopStyle(); } float pct; simpleLogger * log; };
[ [ [ 1, 97 ] ] ]
6fd728d27ec5bca56f46056ba707c6db03c40f82
1b3a26845c00ede008ea66d26f370c3542641f45
/pymfclib/pymctrlbar.cpp
965fd2d96340aa5d610ab5a720138ed4c4011836
[]
no_license
atsuoishimoto/pymfc
26617fac259ed0ffd685a038b47702db0bdccd5f
1341ef3be6ca85ea1fa284689edbba1ac29c72cb
refs/heads/master
2021-01-01T05:50:51.613190
2010-12-29T07:38:01
2010-12-29T07:38:01
33,760,622
0
0
null
null
null
null
UTF-8
C++
false
false
7,446
cpp
// Copyright (c) 2001- Atsuo Ishimoto // See LICENSE for details. #include "stdafx.h" #include "pymwndbase.h" #include "pymwnd.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif int CControlBar_EnableDocking(void *o, int left, int top, int right, int bottom, int any, int multi) { PyMFC_PROLOGUE(CWnd_SetFont); { PyMFCLeavePython lp; DWORD flag=0; if (left) { flag |= CBRS_ALIGN_LEFT; } if (top) { flag |= CBRS_ALIGN_TOP; } if (right) { flag |= CBRS_ALIGN_RIGHT; } if (bottom) { flag |= CBRS_ALIGN_BOTTOM; } if (any) { flag |= CBRS_ALIGN_ANY; } CControlBar *bar = getCWnd<CControlBar>(o); bar->EnableDocking(flag); return 1; } PyMFC_EPILOGUE(0); } void *new_CStatusBar(PyObject *obj) { PyMFC_PROLOGUE(new_CStatusBar); return static_cast<CWnd*>(new PyMFCWnd<CStatusBar, PyMFCMsgParser>(obj)); PyMFC_EPILOGUE(0); } int CStatusBar_Create(void *o, void *parent, PyObject *lens) { PyMFC_PROLOGUE(CStatusBar_Create); CStatusBar *bar = getCWnd<CStatusBar>(o); CWnd *p = getCWnd<CWnd>(parent); PyDTSequence panes(lens, false); int n = panes.getSize(); std::vector<int> width; for (int i = 0; i < n; i++) { width.push_back(panes.getItem(i).getInt()); } { PyMFCLeavePython lp; BOOL ret = bar->Create(p); if (!ret) { throw PyMFC_WIN32ERR(); } // set numbers of pane std::vector<UINT> ids(n, 0); ret = bar->SetIndicators(&ids[0], n); HFONT hFont = (HFONT)bar->SendMessage(WM_GETFONT); CClientDC dcScreen(NULL); HGDIOBJ hOldFont = NULL; if (hFont != NULL) hOldFont = dcScreen.SelectObject(hFont); // set pane width for (int i = 0; i < n; i++) { UINT nID, nStyle; int cxWidth; bar->GetPaneInfo(i, nID, nStyle, cxWidth); cxWidth = dcScreen.GetTextExtent(std::string(width[i], 'A').c_str()).cx; bar->SetPaneInfo(i, nID, nStyle, cxWidth); } if (hOldFont != NULL) { dcScreen.SelectObject(hOldFont); } } return TRUE; PyMFC_EPILOGUE(0); } int CStatusBar_SetPaneText(void *o, int idx, TCHAR *s) { PyMFC_PROLOGUE(CStatusBar_SetPaneText); CStatusBar *bar = getCWnd<CStatusBar>(o); { PyMFCLeavePython lp; if (!bar->SetPaneText(idx, s)) { throw PyMFC_WIN32ERR(); } } return TRUE; PyMFC_EPILOGUE(0); } int CStatusBar_CalcFixedSize(void *o, SIZE *size) { PyMFC_PROLOGUE(CStatusBar_CalcFixedSize); CStatusBar *bar = getCWnd<CStatusBar>(o); { PyMFCLeavePython lp; CSize s = bar->CalcFixedLayout(FALSE, TRUE); size->cx = s.cx; size->cy = s.cy; } return TRUE; PyMFC_EPILOGUE(0); } class PyMFCToolBar:public PyMFCWnd<CToolBar, PyMFCMsgParser> { public: PyMFCToolBar(PyObject *p):PyMFCWnd<CToolBar, PyMFCMsgParser>(p) {} ~PyMFCToolBar() { int a = 0; } void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler) { // does nothing } }; void *new_CToolBar(PyObject *obj) { PyMFC_PROLOGUE(new_CToolBar); return static_cast<CWnd*>(new PyMFCToolBar(obj)); PyMFC_EPILOGUE(0); } int CToolBar_Create(void *o, void *parent, TCHAR *title, int id, int left, int top, int right, int bottom) { PyMFC_PROLOGUE(CToolBar_Create); DWORD flag=0; if (left) { flag |= CBRS_ALIGN_LEFT; } if (top) { flag |= CBRS_ALIGN_TOP; } if (right) { flag |= CBRS_ALIGN_RIGHT; } if (bottom) { flag |= CBRS_ALIGN_BOTTOM; } CToolBar *bar = getCWnd<CToolBar>(o); CWnd *p = getCWnd<CWnd>(parent); BOOL ret; { PyMFCLeavePython lp; ret = bar->CreateEx(p, TBSTYLE_FLAT, CBRS_TOP| WS_CHILD | WS_VISIBLE | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, CRect(0,0,0,0), id); bar->SetBarStyle(bar->GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); } return ret; PyMFC_EPILOGUE(0); } int CToolBar_SetButtons(void *o, PyObject *buttonIds){ PyMFC_PROLOGUE(CToolBar_SetButtons); PyDTSequence idlist(buttonIds, false); int n = idlist.getSize(); std::vector<UINT> v_buttonIds; for (int i = 0; i < n; i++) { v_buttonIds.push_back(idlist.getItem(i).getInt()); } CToolBar *bar = getCWnd<PyMFCToolBar>(o); { PyMFCLeavePython lp; BOOL ret = bar->SetButtons(&(v_buttonIds[0]), v_buttonIds.size()); if (!ret) { throw PyMFC_WIN32ERR(); } } return TRUE; PyMFC_EPILOGUE(0); } int CToolBar_SetBitmap(void *o, HBITMAP hbmp) { PyMFC_PROLOGUE(CToolBar_SetBitmap); CToolBar *bar = getCWnd<PyMFCToolBar>(o); { PyMFCLeavePython lp; BOOL ret = bar->SetBitmap((HBITMAP)hbmp); if (!ret) { throw PyMFC_WIN32ERR(); } } return TRUE; PyMFC_EPILOGUE(0); } int CToolBar_SetImageList(void *o, void *imageList) { PyMFC_PROLOGUE(CToolBar_SetImageList); CToolBar *bar = getCWnd<PyMFCToolBar>(o); { PyMFCLeavePython lp; CImageList *cimg = (CImageList *)imageList; CToolBarCtrl &ctrl = bar->GetToolBarCtrl(); ctrl.SetImageList(cimg); } return TRUE; PyMFC_EPILOGUE(0); } int CToolBar_SetButtonInfo(void *o, int index, int id, int style, int iImage) { PyMFC_PROLOGUE(CToolBar_SetButtonInfo); CToolBar *bar = getCWnd<PyMFCToolBar>(o); { PyMFCLeavePython lp; bar->SetButtonInfo(index, id, style, iImage); } return TRUE; PyMFC_EPILOGUE(0); } PyObject *CToolBar_GetButtonInfo(void *o, int index) { PyMFC_PROLOGUE(CToolBar_GetButtonInfo); CToolBar *bar = getCWnd<PyMFCToolBar>(o); UINT id, style; int iImage; { PyMFCLeavePython lp; bar->GetButtonInfo(index, id, style, iImage); } PyDTTuple ret(3); ret.setItem(0, id); ret.setItem(1, iImage); ret.setItem(2, style); return ret.detach(); PyMFC_EPILOGUE(0); } int CToolBar_GetButtonIndex(void *o, int id) { PyMFC_PROLOGUE(CToolBar_GetButtonIndex); CToolBar *bar = getCWnd<PyMFCToolBar>(o); return bar->CommandToIndex(id); PyMFC_EPILOGUE(0); } PyObject *CToolBar_GetItemRect(void *o, int index) { PyMFC_PROLOGUE(CToolBar_GetItemRect); CToolBar *bar = getCWnd<PyMFCToolBar>(o); RECT rc; { PyMFCLeavePython lp; bar->GetItemRect(index, &rc); } PyDTTuple ret(4); ret.setItem(0, rc.left); ret.setItem(1, rc.top); ret.setItem(2, rc.right); ret.setItem(3, rc.bottom); return ret.detach(); PyMFC_EPILOGUE(0); } int CToolBar_GetButtonStyle(void *o, int index) { PyMFC_PROLOGUE(CToolBar_GetButtonStyle); CToolBar *bar = getCWnd<PyMFCToolBar>(o); return bar->GetButtonStyle(index); PyMFC_EPILOGUE(0); } void CToolBar_SetButtonStyle(void *o, int index, int style, int checked, int indeterminate, int disabled, int pressed) { PyMFC_PROLOGUE(CToolBar_SetButtonStyle); CToolBar *bar = getCWnd<PyMFCToolBar>(o); if (checked != -1) { if (checked) { style |= TBBS_CHECKED; } else { style &= ~TBBS_CHECKED; } } if (indeterminate != -1) { if (indeterminate) { style |= TBBS_INDETERMINATE; } else { style &= ~TBBS_INDETERMINATE; } } if (disabled != -1) { if (disabled) { style |= TBBS_DISABLED; } else { style &= ~TBBS_DISABLED; } } if (pressed != -1) { if (pressed) { style |= TBBS_PRESSED; } else { style &= ~TBBS_PRESSED; } } bar->SetButtonStyle(index, style); PyMFC_VOID_EPILOGUE(); }
[ [ [ 1, 372 ] ] ]
5533f9612d7e1005cdd0ad7b06cb45002312c507
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/PatchClient/BetaPatchClient.h
8b1cf50e55d59436f8894043533e2e3c1feeac75
[]
no_license
willrebuild/flyffsf
e5911fb412221e00a20a6867fd00c55afca593c7
d38cc11790480d617b38bb5fc50729d676aef80d
refs/heads/master
2021-01-19T20:27:35.200154
2011-02-10T12:34:43
2011-02-10T12:34:43
32,710,780
3
0
null
null
null
null
UTF-8
C++
false
false
1,638
h
// BetaPatchClient.h : main header file for the BETAPATCHCLIENT application // #if !defined(AFX_BETAPATCHCLIENT_H__CB6FDBED_0695_4D26_8042_AFE31500A8C5__INCLUDED_) #define AFX_BETAPATCHCLIENT_H__CB6FDBED_0695_4D26_8042_AFE31500A8C5__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 ///////////////////////////////////////////////////////////////////////////// // CBetaPatchClientApp: // See BetaPatchClient.cpp for the implementation of this class // enum CHECK_TYPE { CHECK_TRUE, CHECK_FALSE, CHECK_SKIP, }; class CBetaPatchClientApp : public CWinApp { public: CBetaPatchClientApp(); void RunClient(); // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CBetaPatchClientApp) public: virtual BOOL InitInstance(); //}}AFX_VIRTUAL // Implementation protected: void InitLanguage(); CHECK_TYPE CheckSingleInstance(); BOOL InitPath(); BOOL CheckDirectXVersion(); //{{AFX_MSG(CBetaPatchClientApp) // 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_BETAPATCHCLIENT_H__CB6FDBED_0695_4D26_8042_AFE31500A8C5__INCLUDED_)
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 63 ] ] ]
54f7fada7f98fd5d5c1c1db5e849700a991b7186
8fcf3f01e46f8933b356f763c61938ab11061a38
/Controller/MathFunction.cpp
8815244392bd585a5584227fcd6abdf3d96ec9bc
[]
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
2,344
cpp
#include "mathfunction.h" double MathFunction::integral(IExpression* function, double x1, double x2, int steps) { } double MathFunction::tangent(IExpression* function, double x1, double delta) { double x2 = x1 + delta; double y1 = function->eval(x1); double y2 = function->eval(x2); // DeltaY / DeltaX return (y2 - y1)/(x2 - x1); } double MathFunction::zero(IExpression* function, double x1, double x2, double delta, bool* found) { // Inverser les valeurs si besoin double tmp; if (x1 > x2) { tmp = x1; x1 = x2; x2 = tmp; } // Passer en un zero negatif if(x1 == 0) x1 -= delta; // N'encadre pas le zero if(differentSign(function, x1, x2)) { // Milieu de l'intervalle double middle; while (fabs(x1 - x2) > delta) { middle = (x1 + x2) / 2; // Partie gauche inutile if(function->eval(x1) * function->eval(middle) > 0) x1 = middle; // Partie droite inule else x2 = middle; } if(found != NULL) *found = false; return x2; } else { if(found != NULL) *found = false; return INFINITY; } } double MathFunction::maximum(IExpression* function, double x1, double x2, double delta) { // Pour recuperer le max double max = function->eval(x1); // Pour calculer la nouvelle valeur double nextMax = 0; for(double i = x1 ; i <= x2 ; i+= delta) if ((nextMax = function->eval(i)) > max) max = nextMax; return max; } double MathFunction::minimum(IExpression* function, double x1, double x2, double delta) { // Pour recuperer le min double min = function->eval(x1); // Pour calculer la nouvelle valeur double nextMin = 0; for(double i = x1 ; i <= x2 ; i+= delta) if ((nextMin = function->eval(i)) < min) min = nextMin; return min; } bool MathFunction::differentSign(IExpression* function, double x1, double x2, double delta) { double y1 = function->eval(x1); double y2 = function->eval(x2); return (y1 > 0 && y2 < 0) || (y1 < 0 && y2 > 0); }
[ "jonesbusy@fa255007-c97c-c9ae-ff28-e9f0558300b6" ]
[ [ [ 1, 104 ] ] ]
a36036141123609f409bdc4dbe34b19839c2e9df
2aa37ad4e32d8208f4b116fe32a723690b0d9502
/rubystuff/rubywin-0.0.4.3/textcolordlg.h
d57e9a7c0a1698c294b157853f90214f4c2f0694
[]
no_license
srirammca53/update_status
213070d809629971302192444dd48c0f8d245fdc
a5bf9d16d9f3a81329f1a7801274ad716b40c3e8
refs/heads/master
2020-04-05T23:40:26.156836
2011-08-02T13:35:17
2011-08-02T13:35:17
2,142,552
1
0
null
null
null
null
UTF-8
C++
false
false
746
h
/*---------------------------------- textcolordlg.h $Date: 2001/06/24 08:58:21 $ Copyright (C) 2001 Masaki Suketa -----------------------------------*/ #ifndef TEXTCOLORDLG_H #define TEXTCOLORDLG_H #include "dlgbase.h" #include "reditprop.h" class TEXTCOLORDLG :public DLGBASE { public: TEXTCOLORDLG(); virtual ~TEXTCOLORDLG(){} protected: LRESULT CALLBACK DlgProc(UINT msg, WPARAM wParam, LPARAM lParam); private: BOOL WmCommand(WPARAM wParam, LPARAM lParam); BOOL WmInitDialog(WPARAM wParam, LPARAM lParam); BOOL IdOK(WPARAM wParam, LPARAM lParam); BOOL IdcPbTextcolor(WPARAM wParam, LPARAM lParam); vector<COLORREF> m_ColorSample; vector<HWND> m_hColorSample; }; #endif
[ [ [ 1, 27 ] ] ]
0c5329bf7a49cd02075af713d60d4699ffc5b66d
1c84fe02ecde4a78fb03d3c28dce6fef38ebaeff
/StateEnemyWander.h
03370b7a7bd0a437afb9db566908c00d5934a703
[]
no_license
aadarshasubedi/beesiege
c29cb8c3fce910771deec5bb63bcb32e741c1897
2128b212c5c5a68e146d3f888bb5a8201c8104f7
refs/heads/master
2016-08-12T08:37:10.410041
2007-12-16T20:57:33
2007-12-16T20:57:33
36,995,410
0
0
null
null
null
null
UTF-8
C++
false
false
605
h
#ifndef STATEENEMYWANDER_H #define STATEENEMYWANDER_H #include "FSMState.h" class Enemy; class StateEnemyWander: public FSMState { public: // ctor StateEnemyWander(FSMAIControl* control, int type=FSM_ENEMY_WANDER); // see base class void Enter(); void Exit(); void Update(float fTime); FSMState* CheckTransitions(float fTime); private: enum AIControlType { LOCUST_AI_CONTROL, DRAGONFLY_AI_CONTROL, BOSS_AI_CONTROL }; AIControlType m_eType; // the enemy's view radius float m_fViewRadius; }; NiSmartPointer(StateEnemyWander); #endif
[ [ [ 1, 40 ] ] ]
3d22cae4b33c816a97ee6edde6138aced4a685ac
a705a17ff1b502ec269b9f5e3dc3f873bd2d3b9c
/src/main.cpp
5a5128d4697fd4549ff7083da1978143e4579df8
[]
no_license
cantidio/ChicolinusQuest
82431a36516d17271685716590fe7aaba18226a0
9b77adabed9325bba23c4d99a3815e7f47456a4d
refs/heads/master
2021-01-25T07:27:54.263356
2011-08-09T11:17:53
2011-08-09T11:17:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
425
cpp
#include "game.hpp" int main() { int a; Game game; return game.run(); int layer_w = 400; int screen_w = 320; int pos_x = 450; // ( (400 - (320 mod 400)) / 400) * 400 int init_x1 = ( pos_x % layer_w ); int end_x1 = layer_w - init_x1; int init_x2 = 0; int end_x2 = init_x1; printf("coisa1: %d - %d\n", init_x1, end_x1); printf("coisa2: %d - %d\n", init_x2, end_x2); return 0; }
[ [ [ 1, 24 ] ] ]
604d148e04ba324d671f46520b6b5a18857d5cc6
e9944cc3f8c362cd0314a2d7a01291ed21de19ee
/ xcommon/Public/XDebug.cpp
a9427bab9ed83be2cd440739b22638efdd7d1b09
[]
no_license
wermanhme1990/xcommon
49d7185a28316d46992ad9311ae9cdfe220cb586
c9b1567da1f11e7a606c6ed638a9fde1f6ece577
refs/heads/master
2016-09-06T12:43:43.593776
2008-12-05T04:24:11
2008-12-05T04:24:11
39,864,906
2
0
null
null
null
null
GB18030
C++
false
false
1,736
cpp
/******************************************************************** Copyright (c) 2002-2003 汉王科技有限公司. 版权所有. 文件名称: XDebug.cpp 文件内容: 版本历史: 1.0 作者: xuejuntao [email protected] 2008/10/06 *********************************************************************/ #include "stdafx.h" #include "XDebug.h" #include <stdio.h> #include <memory> void WINAPI XTraceW(LPCWSTR pwhFormat, ...) { const LONG cnMaxLen = 1024; WCHAR athBuffer[cnMaxLen]; LPWSTR pwhBuffer = NULL; LONG nLen = 0; va_list argList; va_start(argList, pwhFormat); nLen = _vscwprintf(pwhFormat, argList); if (nLen < 0) { va_end(argList); return; } if (nLen < cnMaxLen) { pwhBuffer = athBuffer; vswprintf_s(pwhBuffer, cnMaxLen - 1, pwhFormat, argList); OutputDebugStringW(pwhBuffer); } else { if(pwhBuffer = (LPWSTR)_alloca((nLen + 2) * sizeof(WCHAR))) { vswprintf_s(pwhBuffer, nLen + 1, pwhFormat, argList); OutputDebugStringW(pwhBuffer); } } va_end(argList); } void WINAPI XTraceA(LPCSTR pchFormat, ...) { const LONG cnMaxLen = 1024; CHAR athBuffer[cnMaxLen]; LPSTR pchBuffer = NULL; LONG nLen = 0; va_list argList; va_start(argList, pchFormat); nLen = _vscprintf(pchFormat, argList); if (nLen < 0) { va_end(argList); return; } if (nLen < cnMaxLen) { pchBuffer = athBuffer; vsprintf_s(pchBuffer, cnMaxLen - 1, pchFormat, argList); OutputDebugStringA(pchBuffer); } else { if (pchBuffer = (LPSTR)_alloca((nLen + 2) * sizeof(CHAR))) { vsprintf_s(pchBuffer, nLen + 1, pchFormat, argList); OutputDebugStringA(pchBuffer); } } va_end(argList); }
[ [ [ 1, 75 ] ] ]
9bea8ac07fbdec7a6680c4ecb631a64c8721784c
580738f96494d426d6e5973c5b3493026caf8b6a
/Include/Vcl/webform.hpp
5c4b56129f566e3e5ad7f7fc9cbd751dcc47530d
[]
no_license
bravesoftdz/cbuilder-vcl
6b460b4d535d17c309560352479b437d99383d4b
7b91ef1602681e094a6a7769ebb65ffd6f291c59
refs/heads/master
2021-01-10T14:21:03.726693
2010-01-11T11:23:45
2010-01-11T11:23:45
48,485,606
2
1
null
null
null
null
UTF-8
C++
false
false
56,737
hpp
// Borland C++ Builder // Copyright (c) 1995, 2002 by Borland Software Corporation // All rights reserved // (DO NOT EDIT: machine generated header) 'WebForm.pas' rev: 6.00 #ifndef WebFormHPP #define WebFormHPP #pragma delphiheader begin #pragma option push -w- #pragma option push -Vx #include <Contnrs.hpp> // Pascal unit #include <MidItems.hpp> // Pascal unit #include <WebModu.hpp> // Pascal unit #include <SiteComp.hpp> // Pascal unit #include <DB.hpp> // Pascal unit #include <WebComp.hpp> // Pascal unit #include <HTTPProd.hpp> // Pascal unit #include <HTTPApp.hpp> // Pascal unit #include <Messages.hpp> // Pascal unit #include <Classes.hpp> // Pascal unit #include <SysInit.hpp> // Pascal unit #include <System.hpp> // Pascal unit //-- user supplied ----------------------------------------------------------- namespace Webform { //-- type declarations ------------------------------------------------------- __interface IGetAdapterVariableName; typedef System::DelphiInterface<IGetAdapterVariableName> _di_IGetAdapterVariableName; __interface INTERFACE_UUID("{0D4BF7F5-332A-11D4-A474-00C04F6BB853}") IGetAdapterVariableName : public IInterface { public: virtual AnsiString __fastcall GetAdapterVariableName(void) = 0 ; __property AnsiString AdapterVariableName = {read=GetAdapterVariableName}; }; __interface IGetAdapterOfDisplay; typedef System::DelphiInterface<IGetAdapterOfDisplay> _di_IGetAdapterOfDisplay; __interface INTERFACE_UUID("{CB84BC96-4C65-11D4-A48B-00C04F6BB853}") IGetAdapterOfDisplay : public IInterface { public: virtual Classes::TComponent* __fastcall GetAdapter(void) = 0 ; }; __interface IGetVariablesContainerOfDisplay; typedef System::DelphiInterface<IGetVariablesContainerOfDisplay> _di_IGetVariablesContainerOfDisplay; __interface INTERFACE_UUID("{D36B6884-33DE-4E50-8397-45A085C09D95}") IGetVariablesContainerOfDisplay : public IInterface { public: virtual Classes::TComponent* __fastcall GetVariablesContainer(void) = 0 ; }; __interface IGetAdapterModeOfDisplay; typedef System::DelphiInterface<IGetAdapterModeOfDisplay> _di_IGetAdapterModeOfDisplay; __interface INTERFACE_UUID("{C4175F0B-BF2F-4C2A-ADAA-50F7DD3A8BE2}") IGetAdapterModeOfDisplay : public IInterface { public: virtual AnsiString __fastcall GetAdapterModeOfDisplay(void) = 0 ; virtual AnsiString __fastcall GetAdapterModeOfAdapter(void) = 0 ; }; class DELPHICLASS TAbstractControlRequirements; class PASCALIMPLEMENTATION TAbstractControlRequirements : public System::TObject { typedef System::TObject inherited; public: virtual void __fastcall RequiresMultipartForm(void) = 0 ; virtual bool __fastcall IsFunctionDefined(const AnsiString AName) = 0 ; virtual void __fastcall DefineFunction(const AnsiString AName, const AnsiString ABody) = 0 ; virtual void __fastcall DefineVariable(const AnsiString AName, const AnsiString AValue, bool AAdapter) = 0 ; virtual bool __fastcall IsVariableDefined(const AnsiString AName) = 0 ; public: #pragma option push -w-inl /* TObject.Create */ inline __fastcall TAbstractControlRequirements(void) : System::TObject() { } #pragma option pop #pragma option push -w-inl /* TObject.Destroy */ inline __fastcall virtual ~TAbstractControlRequirements(void) { } #pragma option pop }; __interface IGetControlRequirements; typedef System::DelphiInterface<IGetControlRequirements> _di_IGetControlRequirements; __interface INTERFACE_UUID("{4AB9249B-D98D-462D-9AE0-6820D208EF8E}") IGetControlRequirements : public IInterface { public: virtual void __fastcall GetControlRequirements(TAbstractControlRequirements* ARequirements) = 0 ; }; class DELPHICLASS TAdapterControlGroup; class PASCALIMPLEMENTATION TAdapterControlGroup : public Miditems::TWebControlGroup { typedef Miditems::TWebControlGroup inherited; private: Classes::TComponent* FAdapter; Sitecomp::TNotifyList* FNotifyList; AnsiString FAdapterMode; bool FAddDefaultFields; void __fastcall SetAddDefaultFields(const bool Value); protected: void __fastcall GetControlRequirements(TAbstractControlRequirements* ARequirements); virtual void __fastcall ImplGetControlRequirements(TAbstractControlRequirements* ARequirements); AnsiString __fastcall GetAdapterModeOfDisplay(); AnsiString __fastcall GetAdapterModeOfAdapter(); void __fastcall GetDesigntimeWarnings(Sitecomp::TAbstractDesigntimeWarnings* AWarnings); void __fastcall AddNotify(System::TObject* ANotify); void __fastcall RemoveNotify(System::TObject* ANotify); void __fastcall NotifyAdapterChange(Classes::TComponent* Sender); Classes::TComponent* __fastcall GetAdapter(void); Webcomp::TWebComponentList* __fastcall GetVisibleFields(void); void __fastcall GetFieldsList(Classes::TStrings* List); Classes::TComponent* __fastcall FindField(const AnsiString AName); bool __fastcall IsFieldInUse(const AnsiString AName); AnsiString __fastcall GetAdapterVariableName(); virtual void __fastcall Notification(Classes::TComponent* AComponent, Classes::TOperation Operation); void __fastcall SetAdapter(const Classes::TComponent* Value); void __fastcall CreateDefaultFields(void); virtual void __fastcall AdapterChange(void); public: __fastcall virtual TAdapterControlGroup(Classes::TComponent* AOwner); __fastcall virtual ~TAdapterControlGroup(void); __property bool AddDefaultFields = {read=FAddDefaultFields, write=SetAddDefaultFields, default=1}; __property Webcomp::TWebComponentList* VisibleFields = {read=GetVisibleFields}; __property Classes::TComponent* Adapter = {read=GetAdapter, write=SetAdapter}; __property AnsiString AdapterMode = {read=FAdapterMode, write=FAdapterMode}; private: void *__IWebDataFields; /* Sitecomp::IWebDataFields */ void *__INotifyAdapterChange; /* Sitecomp::INotifyAdapterChange */ void *__IGetAdapterVariableName; /* Webform::IGetAdapterVariableName */ void *__IGetAdapterOfDisplay; /* Webform::IGetAdapterOfDisplay */ void *__INotifyList; /* Sitecomp::INotifyList */ void *__IGetVariablesContainerOfDisplay; /* Webform::IGetVariablesContainerOfDisplay [GetVariablesContainer=GetAdapter] */ void *__IGetDesigntimeWarnings; /* Sitecomp::IGetDesigntimeWarnings */ void *__IGetAdapterModeOfDisplay; /* Webform::IGetAdapterModeOfDisplay */ void *__IGetControlRequirements; /* Webform::IGetControlRequirements */ public: operator IGetControlRequirements*(void) { return (IGetControlRequirements*)&__IGetControlRequirements; } operator IGetAdapterModeOfDisplay*(void) { return (IGetAdapterModeOfDisplay*)&__IGetAdapterModeOfDisplay; } operator IGetDesigntimeWarnings*(void) { return (IGetDesigntimeWarnings*)&__IGetDesigntimeWarnings; } operator IGetVariablesContainerOfDisplay*(void) { return (IGetVariablesContainerOfDisplay*)&__IGetVariablesContainerOfDisplay; } operator INotifyList*(void) { return (INotifyList*)&__INotifyList; } operator IGetAdapterOfDisplay*(void) { return (IGetAdapterOfDisplay*)&__IGetAdapterOfDisplay; } operator IGetAdapterVariableName*(void) { return (IGetAdapterVariableName*)&__IGetAdapterVariableName; } operator INotifyAdapterChange*(void) { return (INotifyAdapterChange*)&__INotifyAdapterChange; } operator IWebDataFields*(void) { return (IWebDataFields*)&__IWebDataFields; } }; class DELPHICLASS TAbstractFormRequirements; class PASCALIMPLEMENTATION TAbstractFormRequirements : public System::TObject { typedef System::TObject inherited; public: virtual bool __fastcall IsFunctionDefined(const AnsiString AName) = 0 ; virtual void __fastcall DefineFunction(const AnsiString AName, const AnsiString ABody) = 0 ; virtual bool __fastcall IsVariableDefined(const AnsiString AName) = 0 ; virtual void __fastcall DefineVariable(const AnsiString AName, const AnsiString AValue) = 0 ; public: #pragma option push -w-inl /* TObject.Create */ inline __fastcall TAbstractFormRequirements(void) : System::TObject() { } #pragma option pop #pragma option push -w-inl /* TObject.Destroy */ inline __fastcall virtual ~TAbstractFormRequirements(void) { } #pragma option pop }; __interface IGetFormRequirements; typedef System::DelphiInterface<IGetFormRequirements> _di_IGetFormRequirements; __interface INTERFACE_UUID("{C990BD6A-9250-4C70-B873-F54B3A71DADD}") IGetFormRequirements : public IInterface { public: virtual void __fastcall GetFormRequirements(TAbstractFormRequirements* ARequirements) = 0 ; }; #pragma option push -b- enum TDisplayFieldHideOption { hoHideOnNoInputAccess, hoHideOnNoDisplayAccess, hoHideOnFieldNotVisible, hoHideAlways }; #pragma option pop typedef Set<TDisplayFieldHideOption, hoHideOnNoInputAccess, hoHideAlways> TDisplayFieldHideOptions; class DELPHICLASS TAdapterDataDisplay; class PASCALIMPLEMENTATION TAdapterDataDisplay : public Miditems::TWebDataDisplay { typedef Miditems::TWebDataDisplay inherited; private: AnsiString FFieldName; TDisplayFieldHideOptions FHideOptions; Httpprod::THTMLAlign FAlign; Httpprod::THTMLVAlign FVAlign; protected: virtual AnsiString __fastcall FormatCaption(); Classes::TComponent* __fastcall FindAssociatedField(void); virtual AnsiString __fastcall GetCaption(); virtual void __fastcall SetCaption(AnsiString Value); virtual AnsiString __fastcall FieldConditions(Webcomp::TWebContentOptions* Options); AnsiString __fastcall GetAdapterModeOfAdapter(); AnsiString __fastcall FormatColumnHeading(Webcomp::TWebContentOptions* Options); AnsiString __fastcall FormatColumnData(const AnsiString Content, Webcomp::TWebContentOptions* Options); virtual AnsiString __fastcall ImplFormatColumnHeading(Webcomp::TWebContentOptions* Options); virtual AnsiString __fastcall ImplFormatColumnData(const AnsiString Content, Webcomp::TWebContentOptions* Options); void __fastcall GetDesigntimeWarnings(Sitecomp::TAbstractDesigntimeWarnings* AWarnings); Classes::TComponent* __fastcall GetVariablesContainer(void); virtual AnsiString __fastcall ImplContent(Webcomp::TWebContentOptions* Options, System::TObject* ParentLayout); void __fastcall GetControlRequirements(TAbstractControlRequirements* ARequirements); virtual void __fastcall ImplGetControlRequirements(TAbstractControlRequirements* ARequirements); void __fastcall RestoreDefaults(void); virtual void __fastcall ImplRestoreDefaults(void); AnsiString __fastcall GetFieldName(); void __fastcall SetFieldName(const AnsiString Value); AnsiString __fastcall GetAdapterVariableName(); public: __fastcall virtual TAdapterDataDisplay(Classes::TComponent* AOwner); __property AnsiString FieldName = {read=GetFieldName, write=SetFieldName}; __property TDisplayFieldHideOptions HideOptions = {read=FHideOptions, write=FHideOptions, default=4}; __property Httpprod::THTMLAlign Align = {read=FAlign, write=FAlign, default=0}; __property Httpprod::THTMLVAlign VAlign = {read=FVAlign, write=FVAlign, default=0}; public: #pragma option push -w-inl /* TWebDataDisplay.Destroy */ inline __fastcall virtual ~TAdapterDataDisplay(void) { } #pragma option pop private: void *__IWebGetFieldName; /* Sitecomp::IWebGetFieldName */ void *__IWebSetFieldName; /* Sitecomp::IWebSetFieldName */ void *__IGetAdapterVariableName; /* Webform::IGetAdapterVariableName */ void *__IRestoreDefaults; /* Miditems::IRestoreDefaults */ void *__IGetControlRequirements; /* Webform::IGetControlRequirements */ void *__IGetVariablesContainerOfDisplay; /* Webform::IGetVariablesContainerOfDisplay */ void *__IGetDesigntimeWarnings; /* Sitecomp::IGetDesigntimeWarnings */ void *__IFormatColumn; /* Miditems::IFormatColumn */ public: operator IFormatColumn*(void) { return (IFormatColumn*)&__IFormatColumn; } operator IGetDesigntimeWarnings*(void) { return (IGetDesigntimeWarnings*)&__IGetDesigntimeWarnings; } operator IGetVariablesContainerOfDisplay*(void) { return (IGetVariablesContainerOfDisplay*)&__IGetVariablesContainerOfDisplay; } operator IGetControlRequirements*(void) { return (IGetControlRequirements*)&__IGetControlRequirements; } operator IRestoreDefaults*(void) { return (IRestoreDefaults*)&__IRestoreDefaults; } operator IGetAdapterVariableName*(void) { return (IGetAdapterVariableName*)&__IGetAdapterVariableName; } operator IWebSetFieldName*(void) { return (IWebSetFieldName*)&__IWebSetFieldName; } operator IWebGetFieldName*(void) { return (IWebGetFieldName*)&__IWebGetFieldName; } }; typedef TMetaClass*TAdapterDataDisplayClass; class DELPHICLASS TAdapterActionsListHelper; class PASCALIMPLEMENTATION TAdapterActionsListHelper : public System::TObject { typedef System::TObject inherited; private: Classes::TComponent* FComponent; Webcomp::TWebContainerComponentHelper* FHelper; bool FAddDefaultActions; void __fastcall CreateDefaultActions(void); void __fastcall SetAddDefaultActions(const bool Value); protected: Webcomp::TWebComponentList* __fastcall GetVisibleActions(void); void __fastcall GetActionsList(Classes::TStrings* List); Classes::TComponent* __fastcall FindAction(const AnsiString AName); bool __fastcall IsActionInUse(const AnsiString AName); AnsiString __fastcall GetNewFieldPrefix(); AnsiString __fastcall GetAddFieldsItem(); AnsiString __fastcall GetAddAllFieldsItem(); AnsiString __fastcall GetAddFieldsDlgCaption(); public: __fastcall TAdapterActionsListHelper(Classes::TComponent* AComponent, Webcomp::TWebContainerComponentHelper* AHelper); __property bool AddDefaultActions = {read=FAddDefaultActions, write=SetAddDefaultActions, nodefault}; public: #pragma option push -w-inl /* TObject.Destroy */ inline __fastcall virtual ~TAdapterActionsListHelper(void) { } #pragma option pop }; #pragma option push -b- enum TColumnHTMLElementType { coltDefault, coltText, coltImage, coltList }; #pragma option pop class DELPHICLASS TCustomAdapterDisplayColumn; class PASCALIMPLEMENTATION TCustomAdapterDisplayColumn : public TAdapterDataDisplay { typedef TAdapterDataDisplay inherited; private: TColumnHTMLElementType FDisplayType; int FImageWidth; int FImageHeight; protected: virtual void __fastcall ImplGetControlRequirements(TAbstractControlRequirements* ARequirements); virtual AnsiString __fastcall ImplFormatColumnHeading(Webcomp::TWebContentOptions* Options); bool __fastcall CanAddClass(Classes::TComponent* AParent, TMetaClass* AClass); virtual bool __fastcall ImplCanAddClass(Classes::TComponent* AParent, TMetaClass* AClass); AnsiString __fastcall FormatTextDisplay(const AnsiString VarName, const AnsiString HTMLName); AnsiString __fastcall FormatListDisplay(const AnsiString VarName, const AnsiString HTMLName); AnsiString __fastcall FormatImage(const AnsiString VarName, const AnsiString HTMLName, Webcomp::TWebContentOptions* Options); virtual AnsiString __fastcall ControlContent(Webcomp::TWebContentOptions* Options); virtual void __fastcall ImplRestoreDefaults(void); public: __fastcall virtual TCustomAdapterDisplayColumn(Classes::TComponent* AOwner); /* virtual class method */ virtual bool __fastcall IsColumn(TMetaClass* vmt); __property TColumnHTMLElementType DisplayType = {read=FDisplayType, write=FDisplayType, default=0}; __property int ImageWidth = {read=FImageWidth, write=FImageWidth, default=-1}; __property int ImageHeight = {read=FImageHeight, write=FImageHeight, default=-1}; public: #pragma option push -w-inl /* TWebDataDisplay.Destroy */ inline __fastcall virtual ~TCustomAdapterDisplayColumn(void) { } #pragma option pop }; class DELPHICLASS TCustomAdapterCommandColumn; class PASCALIMPLEMENTATION TCustomAdapterCommandColumn : public Miditems::TWebControlGroup { typedef Miditems::TWebControlGroup inherited; private: AnsiString FStyle; AnsiString FCustom; AnsiString FStyleRule; AnsiString FCaption; Miditems::TCaptionAttributes* FCaptionAttributes; int FDisplayColumns; TAdapterActionsListHelper* FAdapterActionsListHelper; Webcomp::TLayoutAttributes* FLayoutAttributes; Httpprod::THTMLAlign FAlign; Httpprod::THTMLVAlign FVAlign; AnsiString __fastcall GetCaption(); void __fastcall SetCaptionAttributes(const Miditems::TCaptionAttributes* Value); void __fastcall SetCaption(const AnsiString Value); Webcomp::TWebComponentList* __fastcall GetVisibleActions(void); bool __fastcall GetAddDefaultCommands(void); void __fastcall SetAddDefaultCommands(const bool Value); bool __fastcall IsCaptionStored(void); protected: virtual Webcomp::TLayoutAttributes* __fastcall GetLayoutAttributes(void); void __fastcall NotifyAdapterChange(Classes::TComponent* Sender); Sitecomp::TAdapterDisplayCharacteristics __fastcall GetAdapterDisplayCharacteristics(void); virtual AnsiString __fastcall ImplContent(Webcomp::TWebContentOptions* Options, System::TObject* ParentLayout); virtual bool __fastcall ImplCanAddClass(Classes::TComponent* AParent, TMetaClass* AClass); AnsiString __fastcall FormatColumnHeading(Webcomp::TWebContentOptions* Options); AnsiString __fastcall FormatColumnData(const AnsiString Content, Webcomp::TWebContentOptions* Options); __property TAdapterActionsListHelper* AdapterActionsListHelper = {read=FAdapterActionsListHelper}; public: __fastcall virtual TCustomAdapterCommandColumn(Classes::TComponent* AOwner); __fastcall virtual ~TCustomAdapterCommandColumn(void); __property Webcomp::TWebComponentList* VisibleCommands = {read=GetVisibleActions}; __property int DisplayColumns = {read=FDisplayColumns, write=FDisplayColumns, default=-1}; __property AnsiString Style = {read=FStyle, write=FStyle}; __property AnsiString Custom = {read=FCustom, write=FCustom}; __property AnsiString StyleRule = {read=FStyleRule, write=FStyleRule}; __property Miditems::TCaptionAttributes* CaptionAttributes = {read=FCaptionAttributes, write=SetCaptionAttributes}; __property AnsiString Caption = {read=GetCaption, write=SetCaption, stored=IsCaptionStored}; __property bool AddDefaultCommands = {read=GetAddDefaultCommands, write=SetAddDefaultCommands, default=1}; __property Httpprod::THTMLAlign Align = {read=FAlign, write=FAlign, default=0}; __property Httpprod::THTMLVAlign VAlign = {read=FVAlign, write=FVAlign, default=0}; private: void *__IWebActionsList; /* Sitecomp::IWebActionsList */ void *__IAddFieldsEditor; /* Webcomp::IAddFieldsEditor */ void *__IFormatColumn; /* Miditems::IFormatColumn */ void *__IGetAdapterDisplayCharacteristics; /* Sitecomp::IGetAdapterDisplayCharacteristics */ void *__INotifyAdapterChange; /* Sitecomp::INotifyAdapterChange */ public: operator INotifyAdapterChange*(void) { return (INotifyAdapterChange*)&__INotifyAdapterChange; } operator IGetAdapterDisplayCharacteristics*(void) { return (IGetAdapterDisplayCharacteristics*)&__IGetAdapterDisplayCharacteristics; } operator IFormatColumn*(void) { return (IFormatColumn*)&__IFormatColumn; } operator IAddFieldsEditor*(void) { return (IAddFieldsEditor*)&__IAddFieldsEditor; } operator IWebActionsList*(void) { return (IWebActionsList*)&__IWebActionsList; } }; class DELPHICLASS TAdapterCommandColumn; class PASCALIMPLEMENTATION TAdapterCommandColumn : public TCustomAdapterCommandColumn { typedef TCustomAdapterCommandColumn inherited; __published: __property Style ; __property Custom ; __property StyleRule ; __property CaptionAttributes ; __property Caption ; __property DisplayColumns = {default=-1}; __property AddDefaultCommands = {default=1}; __property Align = {default=0}; __property VAlign = {default=0}; public: #pragma option push -w-inl /* TCustomAdapterCommandColumn.Create */ inline __fastcall virtual TAdapterCommandColumn(Classes::TComponent* AOwner) : TCustomAdapterCommandColumn(AOwner) { } #pragma option pop #pragma option push -w-inl /* TCustomAdapterCommandColumn.Destroy */ inline __fastcall virtual ~TAdapterCommandColumn(void) { } #pragma option pop }; class DELPHICLASS TGeneratedFunctions; class PASCALIMPLEMENTATION TGeneratedFunctions : public System::TObject { typedef System::TObject inherited; private: Classes::TStrings* FScript; Classes::TStrings* FNames; AnsiString __fastcall GetScript(int I); int __fastcall GetItemCount(void); AnsiString __fastcall GetName(int I); public: __fastcall TGeneratedFunctions(void); __fastcall virtual ~TGeneratedFunctions(void); void __fastcall Add(const AnsiString AName, const AnsiString AScript); bool __fastcall Exists(const AnsiString AName); __property AnsiString Script[int I] = {read=GetScript}; __property int ItemCount = {read=GetItemCount, nodefault}; __property AnsiString Names[int I] = {read=GetName}; }; class DELPHICLASS TControlRequirements; class PASCALIMPLEMENTATION TControlRequirements : public TAbstractControlRequirements { typedef TAbstractControlRequirements inherited; private: TGeneratedFunctions* FGeneratedFunctions; bool FNeedMultipartForm; Classes::TStrings* FVariables; public: virtual void __fastcall RequiresMultipartForm(void); virtual bool __fastcall IsFunctionDefined(const AnsiString AName); virtual void __fastcall DefineFunction(const AnsiString AName, const AnsiString ABody); virtual void __fastcall DefineVariable(const AnsiString AName, const AnsiString AValue, bool AAdapter); virtual bool __fastcall IsVariableDefined(const AnsiString AName); __fastcall TControlRequirements(void); __fastcall virtual ~TControlRequirements(void); __property bool NeedMultipartForm = {read=FNeedMultipartForm, nodefault}; }; __interface IGetAdapterFormLayout; typedef System::DelphiInterface<IGetAdapterFormLayout> _di_IGetAdapterFormLayout; class DELPHICLASS TAdapterFormLayout; __interface INTERFACE_UUID("{C51059F2-AA91-11D4-A502-00C04F6BB853}") IGetAdapterFormLayout : public IInterface { public: virtual TAdapterFormLayout* __fastcall GetAdapterFormLayout(void) = 0 ; }; class DELPHICLASS TCustomAdapterForm; class PASCALIMPLEMENTATION TCustomAdapterForm : public Miditems::TWebControlGroup { typedef Miditems::TWebControlGroup inherited; private: AnsiString FStyle; AnsiString FCustom; AnsiString FStyleRule; Webcomp::TLayoutAttributes* FLayoutAttributes; TControlRequirements* FControlRequirements; TAdapterFormLayout* FFormLayout; Miditems::TFormMethod FFormMethod; AnsiString __fastcall FormatForm(System::TObject* ParentLayout, Webcomp::TWebContentOptions* Options); AnsiString __fastcall GetHTMLFormTag(Webcomp::TWebContentOptions* Options); TControlRequirements* __fastcall GetControlRequirements(void); protected: virtual Webcomp::TLayoutAttributes* __fastcall GetLayoutAttributes(void); TAdapterFormLayout* __fastcall GetAdapterFormLayout(void); void __fastcall GetFormRequirements(TAbstractFormRequirements* ARequirements); AnsiString __fastcall GetHTMLFormName(); AnsiString __fastcall GetHTMLFormVarName(); virtual bool __fastcall ImplCanAddClass(Classes::TComponent* AParent, TMetaClass* AClass); virtual AnsiString __fastcall ImplContent(Webcomp::TWebContentOptions* Options, System::TObject* ParentLayout); public: __fastcall virtual TCustomAdapterForm(Classes::TComponent* AOwner); __fastcall virtual ~TCustomAdapterForm(void); __property AnsiString Style = {read=FStyle, write=FStyle}; __property AnsiString Custom = {read=FCustom, write=FCustom}; __property AnsiString StyleRule = {read=FStyleRule, write=FStyleRule}; __property Miditems::TFormMethod FormMethod = {read=FFormMethod, write=FFormMethod, default=0}; private: void *__IHTMLForm; /* Miditems::IHTMLForm */ void *__IGetFormRequirements; /* Webform::IGetFormRequirements */ void *__IGetAdapterFormLayout; /* Webform::IGetAdapterFormLayout */ public: operator IGetAdapterFormLayout*(void) { return (IGetAdapterFormLayout*)&__IGetAdapterFormLayout; } operator IGetFormRequirements*(void) { return (IGetFormRequirements*)&__IGetFormRequirements; } operator IHTMLForm*(void) { return (IHTMLForm*)&__IHTMLForm; } }; class DELPHICLASS TAdapterForm; class PASCALIMPLEMENTATION TAdapterForm : public TCustomAdapterForm { typedef TCustomAdapterForm inherited; __published: __property Style ; __property Custom ; __property StyleRule ; __property FormMethod = {default=0}; public: #pragma option push -w-inl /* TCustomAdapterForm.Create */ inline __fastcall virtual TAdapterForm(Classes::TComponent* AOwner) : TCustomAdapterForm(AOwner) { } #pragma option pop #pragma option push -w-inl /* TCustomAdapterForm.Destroy */ inline __fastcall virtual ~TAdapterForm(void) { } #pragma option pop }; __interface IAdapterDisplay; typedef System::DelphiInterface<IAdapterDisplay> _di_IAdapterDisplay; __interface INTERFACE_UUID("{73506462-4D5E-11D4-A48B-00C04F6BB853}") IAdapterDisplay : public IInterface { }; class DELPHICLASS TCustomAdapterGrid; class PASCALIMPLEMENTATION TCustomAdapterGrid : public TAdapterControlGroup { typedef TAdapterControlGroup inherited; private: TAdapterFormLayout* FTableLayout; Miditems::TGridAttributes* FTableAttributes; Miditems::TGridRowAttributes* FHeadingAttributes; Miditems::TGridRowAttributes* FRowAttributes; AnsiString __fastcall FormatTable(Webcomp::TLayoutWebContent* Layout, Webcomp::TWebContentOptions* Options); void __fastcall SetHeadingAttributes(const Miditems::TGridRowAttributes* Value); void __fastcall SetRowAttributes(const Miditems::TGridRowAttributes* Value); void __fastcall SetTableAttributes(const Miditems::TGridAttributes* Value); protected: TAdapterFormLayout* __fastcall GetAdapterFormLayout(void); AnsiString __fastcall GetNewFieldPrefix(); AnsiString __fastcall GetAddFieldsItem(); AnsiString __fastcall GetAddAllFieldsItem(); AnsiString __fastcall GetAddFieldsDlgCaption(); Sitecomp::TAdapterDisplayCharacteristics __fastcall GetAdapterDisplayCharacteristics(void); virtual bool __fastcall ImplCanAddClass(Classes::TComponent* AParent, TMetaClass* AClass); virtual AnsiString __fastcall ImplContent(Webcomp::TWebContentOptions* Options, System::TObject* ParentLayout); public: __fastcall virtual TCustomAdapterGrid(Classes::TComponent* AOwner); __fastcall virtual ~TCustomAdapterGrid(void); __property Miditems::TGridAttributes* TableAttributes = {read=FTableAttributes, write=SetTableAttributes}; __property Miditems::TGridRowAttributes* HeadingAttributes = {read=FHeadingAttributes, write=SetHeadingAttributes}; __property Miditems::TGridRowAttributes* RowAttributes = {read=FRowAttributes, write=SetRowAttributes}; private: void *__IAdapterDisplay; /* Webform::IAdapterDisplay */ void *__IGetAdapterDisplayCharacteristics; /* Sitecomp::IGetAdapterDisplayCharacteristics */ void *__IAddFieldsEditor; /* Webcomp::IAddFieldsEditor */ void *__IGetAdapterFormLayout; /* Webform::IGetAdapterFormLayout */ public: operator IGetAdapterFormLayout*(void) { return (IGetAdapterFormLayout*)&__IGetAdapterFormLayout; } operator IAddFieldsEditor*(void) { return (IAddFieldsEditor*)&__IAddFieldsEditor; } operator IGetAdapterDisplayCharacteristics*(void) { return (IGetAdapterDisplayCharacteristics*)&__IGetAdapterDisplayCharacteristics; } operator IAdapterDisplay*(void) { return (IAdapterDisplay*)&__IAdapterDisplay; } }; class DELPHICLASS TAdapterGrid; class PASCALIMPLEMENTATION TAdapterGrid : public TCustomAdapterGrid { typedef TCustomAdapterGrid inherited; __published: __property TableAttributes ; __property HeadingAttributes ; __property RowAttributes ; __property Adapter ; __property AdapterMode ; __property AddDefaultFields = {default=1}; public: #pragma option push -w-inl /* TCustomAdapterGrid.Create */ inline __fastcall virtual TAdapterGrid(Classes::TComponent* AOwner) : TCustomAdapterGrid(AOwner) { } #pragma option pop #pragma option push -w-inl /* TCustomAdapterGrid.Destroy */ inline __fastcall virtual ~TAdapterGrid(void) { } #pragma option pop }; class DELPHICLASS TCustomAdapterFieldGroup; class PASCALIMPLEMENTATION TCustomAdapterFieldGroup : public TAdapterControlGroup { typedef TAdapterControlGroup inherited; private: AnsiString FStyle; AnsiString FCustom; AnsiString FStyleRule; Webcomp::TLayoutAttributes* FLayoutAttributes; TAdapterFormLayout* FFormLayout; AnsiString __fastcall FormatFields(System::TObject* ParentLayout, Webcomp::TWebContentOptions* Options); protected: AnsiString __fastcall GetNewFieldPrefix(); AnsiString __fastcall GetAddFieldsItem(); AnsiString __fastcall GetAddAllFieldsItem(); AnsiString __fastcall GetAddFieldsDlgCaption(); TAdapterFormLayout* __fastcall GetAdapterFormLayout(void); virtual Webcomp::TLayoutAttributes* __fastcall GetLayoutAttributes(void); Sitecomp::TAdapterDisplayCharacteristics __fastcall GetAdapterDisplayCharacteristics(void); virtual bool __fastcall ImplCanAddClass(Classes::TComponent* AParent, TMetaClass* AClass); virtual AnsiString __fastcall ImplContent(Webcomp::TWebContentOptions* Options, System::TObject* ParentLayout); public: __fastcall virtual TCustomAdapterFieldGroup(Classes::TComponent* AOwner); __fastcall virtual ~TCustomAdapterFieldGroup(void); __property AnsiString Style = {read=FStyle, write=FStyle}; __property AnsiString Custom = {read=FCustom, write=FCustom}; __property AnsiString StyleRule = {read=FStyleRule, write=FStyleRule}; private: void *__IAdapterDisplay; /* Webform::IAdapterDisplay */ void *__IGetAdapterDisplayCharacteristics; /* Sitecomp::IGetAdapterDisplayCharacteristics */ void *__IAddFieldsEditor; /* Webcomp::IAddFieldsEditor */ void *__IGetAdapterFormLayout; /* Webform::IGetAdapterFormLayout */ public: operator IGetAdapterFormLayout*(void) { return (IGetAdapterFormLayout*)&__IGetAdapterFormLayout; } operator IAddFieldsEditor*(void) { return (IAddFieldsEditor*)&__IAddFieldsEditor; } operator IGetAdapterDisplayCharacteristics*(void) { return (IGetAdapterDisplayCharacteristics*)&__IGetAdapterDisplayCharacteristics; } operator IAdapterDisplay*(void) { return (IAdapterDisplay*)&__IAdapterDisplay; } }; class DELPHICLASS TAdapterFieldGroup; class PASCALIMPLEMENTATION TAdapterFieldGroup : public TCustomAdapterFieldGroup { typedef TCustomAdapterFieldGroup inherited; __published: __property Style ; __property Custom ; __property StyleRule ; __property Adapter ; __property AdapterMode ; __property AddDefaultFields = {default=1}; public: #pragma option push -w-inl /* TCustomAdapterFieldGroup.Create */ inline __fastcall virtual TAdapterFieldGroup(Classes::TComponent* AOwner) : TCustomAdapterFieldGroup(AOwner) { } #pragma option pop #pragma option push -w-inl /* TCustomAdapterFieldGroup.Destroy */ inline __fastcall virtual ~TAdapterFieldGroup(void) { } #pragma option pop }; #pragma option push -b- enum TInputFieldHTMLElementType { iftDefault, iftTextInput, iftPasswordInput, iftSelect, iftSelectMultiple, iftRadio, iftCheckBox, iftTextArea, iftFile }; #pragma option pop #pragma option push -b- enum TDisplayFieldHTMLElementType { dftDefault, dftText, dftImage, dftList }; #pragma option pop #pragma option push -b- enum TDisplayFieldViewMode { vmDefault, vmInput, vmDisplay, vmToggleOnAccess }; #pragma option pop class DELPHICLASS TCustomAdapterDisplayField; class PASCALIMPLEMENTATION TCustomAdapterDisplayField : public TAdapterDataDisplay { typedef TAdapterDataDisplay inherited; private: int FDisplayWidth; TDisplayFieldHTMLElementType FDisplayType; TInputFieldHTMLElementType FInputType; int FSelectRows; int FImageWidth; int FImageHeight; int FMaxLength; int FDisplayRows; Miditems::TTextAreaWrap FWrap; TDisplayFieldViewMode FViewMode; int FDisplayColumns; AnsiString __fastcall FormatTextInput(const AnsiString VarName, const AnsiString HTMLName); AnsiString __fastcall FormatPasswordInput(const AnsiString VarName, const AnsiString HTMLName); AnsiString __fastcall FormatSelect(const AnsiString VarName, const AnsiString HTMLName, bool Multiple); bool __fastcall CalcInputElementType(TInputFieldHTMLElementType &AType); bool __fastcall CalcDisplayElementType(TDisplayFieldHTMLElementType &AType); bool __fastcall CalcDisplayFieldViewMode(TDisplayFieldViewMode &AMode); AnsiString __fastcall FormatTextDisplay(const AnsiString VarName, const AnsiString HTMLName); AnsiString __fastcall FormatListDisplay(const AnsiString VarName, const AnsiString HTMLName); AnsiString __fastcall FormatRadioGroup(const AnsiString VarName, const AnsiString HTMLName); AnsiString __fastcall FormatCheckBoxGroup(const AnsiString VarName, const AnsiString HTMLName); AnsiString __fastcall FormatInputGroup(const AnsiString FunctionName, const AnsiString VarName, const AnsiString HTMLName, int DisplayColumns); AnsiString __fastcall FormatTextArea(const AnsiString VarName, const AnsiString HTMLName); AnsiString __fastcall FormatImage(const AnsiString VarName, const AnsiString HTMLName, Webcomp::TWebContentOptions* Options); AnsiString __fastcall FormatFileInput(const AnsiString VarName, const AnsiString HTMLName); protected: virtual Webcomp::TLayoutAttributes* __fastcall GetLayoutAttributes(void); void __fastcall AddAttributes(AnsiString &Attrs); virtual AnsiString __fastcall ControlContent(Webcomp::TWebContentOptions* Options); virtual void __fastcall ImplGetControlRequirements(TAbstractControlRequirements* ARequirements); virtual void __fastcall ImplRestoreDefaults(void); virtual AnsiString __fastcall ImplContent(Webcomp::TWebContentOptions* Options, System::TObject* ParentLayout); public: __fastcall virtual TCustomAdapterDisplayField(Classes::TComponent* AOwner); __property int DisplayWidth = {read=FDisplayWidth, write=FDisplayWidth, default=-1}; __property TDisplayFieldViewMode ViewMode = {read=FViewMode, write=FViewMode, default=0}; __property TDisplayFieldHTMLElementType DisplayType = {read=FDisplayType, write=FDisplayType, default=0}; __property TInputFieldHTMLElementType InputType = {read=FInputType, write=FInputType, default=0}; __property int ImageWidth = {read=FImageWidth, write=FImageWidth, default=-1}; __property int ImageHeight = {read=FImageHeight, write=FImageHeight, default=-1}; __property int SelectRows = {read=FSelectRows, write=FSelectRows, default=0}; __property int MaxLength = {read=FMaxLength, write=FMaxLength, default=-1}; __property Miditems::TTextAreaWrap TextAreaWrap = {read=FWrap, write=FWrap, default=0}; __property int DisplayRows = {read=FDisplayRows, write=FDisplayRows, default=-1}; __property int DisplayColumns = {read=FDisplayColumns, write=FDisplayColumns, default=1}; public: #pragma option push -w-inl /* TWebDataDisplay.Destroy */ inline __fastcall virtual ~TCustomAdapterDisplayField(void) { } #pragma option pop private: void *__IGetControlRequirements; /* Webform::IGetControlRequirements */ public: operator IGetControlRequirements*(void) { return (IGetControlRequirements*)&__IGetControlRequirements; } }; class DELPHICLASS TAdapterDisplayColumn; class PASCALIMPLEMENTATION TAdapterDisplayColumn : public TCustomAdapterDisplayColumn { typedef TCustomAdapterDisplayColumn inherited; __published: __property Caption ; __property CaptionAttributes ; __property FieldName ; __property DisplayType = {default=0}; __property ImageWidth = {default=-1}; __property ImageHeight = {default=-1}; __property HideOptions = {default=4}; __property Style ; __property Custom ; __property StyleRule ; __property Align = {default=0}; __property VAlign = {default=0}; public: #pragma option push -w-inl /* TCustomAdapterDisplayColumn.Create */ inline __fastcall virtual TAdapterDisplayColumn(Classes::TComponent* AOwner) : TCustomAdapterDisplayColumn(AOwner) { } #pragma option pop public: #pragma option push -w-inl /* TWebDataDisplay.Destroy */ inline __fastcall virtual ~TAdapterDisplayColumn(void) { } #pragma option pop }; class DELPHICLASS TAdapterDisplayField; class PASCALIMPLEMENTATION TAdapterDisplayField : public TCustomAdapterDisplayField { typedef TCustomAdapterDisplayField inherited; __published: __property Style ; __property Custom ; __property StyleRule ; __property Caption ; __property DisplayColumns = {default=1}; __property CaptionAttributes ; __property DisplayWidth = {default=-1}; __property FieldName ; __property DisplayType = {default=0}; __property CaptionPosition = {default=0}; __property Align = {default=0}; __property VAlign = {default=0}; __property ImageWidth = {default=-1}; __property ImageHeight = {default=-1}; __property SelectRows = {default=0}; __property MaxLength = {default=-1}; __property TextAreaWrap = {default=0}; __property DisplayRows = {default=-1}; __property ViewMode = {default=0}; __property HideOptions = {default=4}; __property InputType = {default=0}; public: #pragma option push -w-inl /* TCustomAdapterDisplayField.Create */ inline __fastcall virtual TAdapterDisplayField(Classes::TComponent* AOwner) : TCustomAdapterDisplayField(AOwner) { } #pragma option pop public: #pragma option push -w-inl /* TWebDataDisplay.Destroy */ inline __fastcall virtual ~TAdapterDisplayField(void) { } #pragma option pop }; class DELPHICLASS TCustomAdapterEditColumn; class PASCALIMPLEMENTATION TCustomAdapterEditColumn : public TCustomAdapterDisplayField { typedef TCustomAdapterDisplayField inherited; protected: virtual AnsiString __fastcall ImplContent(Webcomp::TWebContentOptions* Options, System::TObject* ParentLayout); public: #pragma option push -w-inl /* TCustomAdapterDisplayField.Create */ inline __fastcall virtual TCustomAdapterEditColumn(Classes::TComponent* AOwner) : TCustomAdapterDisplayField(AOwner) { } #pragma option pop public: #pragma option push -w-inl /* TWebDataDisplay.Destroy */ inline __fastcall virtual ~TCustomAdapterEditColumn(void) { } #pragma option pop }; class DELPHICLASS TAdapterEditColumn; class PASCALIMPLEMENTATION TAdapterEditColumn : public TCustomAdapterEditColumn { typedef TCustomAdapterEditColumn inherited; __published: __property Style ; __property Custom ; __property StyleRule ; __property Caption ; __property DisplayColumns = {default=1}; __property CaptionAttributes ; __property DisplayWidth = {default=-1}; __property FieldName ; __property DisplayType = {default=0}; __property CaptionPosition = {default=0}; __property Align = {default=0}; __property VAlign = {default=0}; __property ImageWidth = {default=-1}; __property ImageHeight = {default=-1}; __property SelectRows = {default=0}; __property MaxLength = {default=-1}; __property TextAreaWrap = {default=0}; __property DisplayRows = {default=-1}; __property ViewMode = {default=0}; __property HideOptions = {default=4}; __property InputType = {default=0}; public: #pragma option push -w-inl /* TCustomAdapterDisplayField.Create */ inline __fastcall virtual TAdapterEditColumn(Classes::TComponent* AOwner) : TCustomAdapterEditColumn(AOwner) { } #pragma option pop public: #pragma option push -w-inl /* TWebDataDisplay.Destroy */ inline __fastcall virtual ~TAdapterEditColumn(void) { } #pragma option pop }; class DELPHICLASS TAdapterDisplayReferenceGroup; class PASCALIMPLEMENTATION TAdapterDisplayReferenceGroup : public Miditems::TWebDisplayReferenceGroup { typedef Miditems::TWebDisplayReferenceGroup inherited; protected: void __fastcall OnDisplayComponentChange(System::TObject* ASender); virtual void __fastcall DisplayComponentChange(void); virtual void __fastcall AdapterChange(void); void __fastcall GetDesigntimeWarnings(Sitecomp::TAbstractDesigntimeWarnings* AWarnings); Sitecomp::TAdapterDisplayCharacteristics __fastcall GetAdapterDisplayCharacteristics(void); void __fastcall NotifyAdapterChange(Classes::TComponent* Sender); virtual void __fastcall SetWebDisplayComponent(const Classes::TComponent* AComponent); public: __fastcall virtual TAdapterDisplayReferenceGroup(Classes::TComponent* AOwner); __fastcall virtual ~TAdapterDisplayReferenceGroup(void); __property Classes::TComponent* DisplayComponent = {read=GetWebDisplayComponent, write=SetWebDisplayComponent}; private: void *__IGetDesigntimeWarnings; /* Sitecomp::IGetDesigntimeWarnings */ void *__INotifyAdapterChange; /* Sitecomp::INotifyAdapterChange */ void *__IGetAdapterDisplayCharacteristics; /* Sitecomp::IGetAdapterDisplayCharacteristics */ public: operator IGetAdapterDisplayCharacteristics*(void) { return (IGetAdapterDisplayCharacteristics*)&__IGetAdapterDisplayCharacteristics; } operator INotifyAdapterChange*(void) { return (INotifyAdapterChange*)&__INotifyAdapterChange; } operator IGetDesigntimeWarnings*(void) { return (IGetDesigntimeWarnings*)&__IGetDesigntimeWarnings; } }; class DELPHICLASS TCustomAdapterCommandGroup; class PASCALIMPLEMENTATION TCustomAdapterCommandGroup : public TAdapterDisplayReferenceGroup { typedef TAdapterDisplayReferenceGroup inherited; private: AnsiString FStyle; AnsiString FCustom; AnsiString FStyleRule; TAdapterFormLayout* FFormLayout; TAdapterActionsListHelper* FAdapterActionsListHelper; Webcomp::TWebComponentList* __fastcall GetVisibleCommands(void); bool __fastcall GetAddDefaultCommands(void); void __fastcall SetAddDefaultCommands(const bool Value); protected: TAdapterFormLayout* __fastcall GetAdapterFormLayout(void); AnsiString __fastcall GetAdapterModeOfDisplay(); AnsiString __fastcall GetAdapterModeOfAdapter(); Classes::TComponent* __fastcall GetAdapter(void); virtual bool __fastcall ImplCanAddClass(Classes::TComponent* AParent, TMetaClass* AClass); virtual AnsiString __fastcall ImplContent(Webcomp::TWebContentOptions* Options, System::TObject* ParentLayout); __property Classes::TComponent* Adapter = {read=GetAdapter}; __property TAdapterActionsListHelper* AdapterActionsListHelper = {read=FAdapterActionsListHelper}; public: __fastcall virtual TCustomAdapterCommandGroup(Classes::TComponent* AOwner); __fastcall virtual ~TCustomAdapterCommandGroup(void); __property AnsiString Custom = {read=FCustom, write=FCustom}; __property AnsiString Style = {read=FStyle, write=FStyle}; __property AnsiString StyleRule = {read=FStyleRule, write=FStyleRule}; __property Webcomp::TWebComponentList* VisibleCommands = {read=GetVisibleCommands}; __property bool AddDefaultCommands = {read=GetAddDefaultCommands, write=SetAddDefaultCommands, default=1}; private: void *__IWebActionsList; /* Sitecomp::IWebActionsList */ void *__IGetAdapterOfDisplay; /* Webform::IGetAdapterOfDisplay */ void *__IGetVariablesContainerOfDisplay; /* Webform::IGetVariablesContainerOfDisplay [GetVariablesContainer=GetAdapter] */ void *__IAddFieldsEditor; /* Webcomp::IAddFieldsEditor */ void *__IGetAdapterModeOfDisplay; /* Webform::IGetAdapterModeOfDisplay */ void *__IGetAdapterFormLayout; /* Webform::IGetAdapterFormLayout */ public: operator IGetAdapterFormLayout*(void) { return (IGetAdapterFormLayout*)&__IGetAdapterFormLayout; } operator IGetAdapterModeOfDisplay*(void) { return (IGetAdapterModeOfDisplay*)&__IGetAdapterModeOfDisplay; } operator IAddFieldsEditor*(void) { return (IAddFieldsEditor*)&__IAddFieldsEditor; } operator IGetVariablesContainerOfDisplay*(void) { return (IGetVariablesContainerOfDisplay*)&__IGetVariablesContainerOfDisplay; } operator IGetAdapterOfDisplay*(void) { return (IGetAdapterOfDisplay*)&__IGetAdapterOfDisplay; } operator IWebActionsList*(void) { return (IWebActionsList*)&__IWebActionsList; } }; class DELPHICLASS TAdapterCommandGroup; class PASCALIMPLEMENTATION TAdapterCommandGroup : public TCustomAdapterCommandGroup { typedef TCustomAdapterCommandGroup inherited; __published: __property DisplayComponent ; __property Custom ; __property Style ; __property StyleRule ; __property AddDefaultCommands = {default=1}; public: #pragma option push -w-inl /* TCustomAdapterCommandGroup.Create */ inline __fastcall virtual TAdapterCommandGroup(Classes::TComponent* AOwner) : TCustomAdapterCommandGroup(AOwner) { } #pragma option pop #pragma option push -w-inl /* TCustomAdapterCommandGroup.Destroy */ inline __fastcall virtual ~TAdapterCommandGroup(void) { } #pragma option pop }; #pragma option push -b- enum TActionButtonHideOption { bhoHideOnNoExecuteAccess, bhoHideOnActionNotVisible, bhoHideOnDisabledAction, bhoHideAlways }; #pragma option pop typedef Set<TActionButtonHideOption, bhoHideOnNoExecuteAccess, bhoHideAlways> TActionButtonHideOptions; #pragma option push -b- enum TCommandHTMLElementType { ctDefault, ctButton, ctImage, ctAnchor, ctEventImages }; #pragma option pop class DELPHICLASS TCustomAdapterActionButton; class PASCALIMPLEMENTATION TCustomAdapterActionButton : public Miditems::TWebButton { typedef Miditems::TWebButton inherited; private: AnsiString FActionName; TCommandHTMLElementType FDisplayType; AnsiString FPageName; AnsiString FErrorPageName; int FImageWidth; int FImageHeight; TActionButtonHideOptions FHideOptions; int FDisplayColumns; Sitecomp::_di_IActionImageProducer FImageProducer; Webcomp::TLayoutAttributes* FLayoutAttributes; Httpprod::THTMLAlign FAlign; Httpprod::THTMLVAlign FVAlign; void __fastcall SetImageProducer(const Sitecomp::_di_IActionImageProducer Value); Classes::TComponent* __fastcall GetImageProducerComponent(void); AnsiString __fastcall GetImageProducerVariableName(); protected: virtual Webcomp::TLayoutAttributes* __fastcall GetLayoutAttributes(void); virtual void __fastcall Notification(Classes::TComponent* AComponent, Classes::TOperation Operation); AnsiString __fastcall GetAdapterModeOfAdapter(); AnsiString __fastcall GetHTMLFormVarName(); void __fastcall GetDesigntimeWarnings(Sitecomp::TAbstractDesigntimeWarnings* AWarnings); void __fastcall GetControlRequirements(TAbstractControlRequirements* ARequirements); virtual void __fastcall ImplGetControlRequirements(TAbstractControlRequirements* ARequirements); void __fastcall RestoreDefaults(void); virtual void __fastcall ImplRestoreDefaults(void); virtual AnsiString __fastcall ImplContent(Webcomp::TWebContentOptions* Options, System::TObject* ParentLayout); AnsiString __fastcall GetActionName(); void __fastcall SetActionName(const AnsiString AValue); virtual void __fastcall SetCaption(const AnsiString Value); virtual AnsiString __fastcall GetCaption(); AnsiString __fastcall GetAdapterVariableName(); Classes::TComponent* __fastcall FindAssociatedAction(void); public: __fastcall virtual TCustomAdapterActionButton(Classes::TComponent* AOwner); __fastcall virtual ~TCustomAdapterActionButton(void); __property AnsiString ActionName = {read=GetActionName, write=SetActionName}; __property AnsiString PageName = {read=FPageName, write=FPageName}; __property AnsiString ErrorPageName = {read=FErrorPageName, write=FErrorPageName}; __property TCommandHTMLElementType DisplayType = {read=FDisplayType, write=FDisplayType, default=0}; __property int ImageWidth = {read=FImageWidth, write=FImageWidth, default=-1}; __property int ImageHeight = {read=FImageHeight, write=FImageHeight, default=-1}; __property TActionButtonHideOptions HideOptions = {read=FHideOptions, write=FHideOptions, default=2}; __property int DisplayColumns = {read=FDisplayColumns, write=FDisplayColumns, default=-1}; __property Sitecomp::_di_IActionImageProducer ImageProducer = {read=FImageProducer, write=SetImageProducer}; __property Httpprod::THTMLAlign Align = {read=FAlign, write=FAlign, default=0}; __property Httpprod::THTMLVAlign VAlign = {read=FVAlign, write=FVAlign, default=0}; private: void *__IWebGetActionName; /* Sitecomp::IWebGetActionName */ void *__IWebSetActionName; /* Sitecomp::IWebSetActionName */ void *__IRestoreDefaults; /* Miditems::IRestoreDefaults */ void *__IGetControlRequirements; /* Webform::IGetControlRequirements */ void *__IGetAdapterVariableName; /* Webform::IGetAdapterVariableName */ void *__IGetDesigntimeWarnings; /* Sitecomp::IGetDesigntimeWarnings */ public: operator IGetDesigntimeWarnings*(void) { return (IGetDesigntimeWarnings*)&__IGetDesigntimeWarnings; } operator IGetAdapterVariableName*(void) { return (IGetAdapterVariableName*)&__IGetAdapterVariableName; } operator IGetControlRequirements*(void) { return (IGetControlRequirements*)&__IGetControlRequirements; } operator IRestoreDefaults*(void) { return (IRestoreDefaults*)&__IRestoreDefaults; } operator IWebSetActionName*(void) { return (IWebSetActionName*)&__IWebSetActionName; } operator IWebGetActionName*(void) { return (IWebGetActionName*)&__IWebGetActionName; } }; class DELPHICLASS TAdapterActionButton; class PASCALIMPLEMENTATION TAdapterActionButton : public TCustomAdapterActionButton { typedef TCustomAdapterActionButton inherited; __published: __property ActionName ; __property Style ; __property Custom ; __property Caption ; __property StyleRule ; __property PageName ; __property ErrorPageName ; __property HideOptions = {default=2}; __property DisplayType = {default=0}; __property ImageWidth = {default=-1}; __property ImageHeight = {default=-1}; __property DisplayColumns = {default=-1}; __property ImageProducer ; __property Align = {default=0}; __property VAlign = {default=0}; public: #pragma option push -w-inl /* TCustomAdapterActionButton.Create */ inline __fastcall virtual TAdapterActionButton(Classes::TComponent* AOwner) : TCustomAdapterActionButton(AOwner) { } #pragma option pop #pragma option push -w-inl /* TCustomAdapterActionButton.Destroy */ inline __fastcall virtual ~TAdapterActionButton(void) { } #pragma option pop }; #pragma option push -b- enum TLayoutState { lsUnknown, lsFields, lsButtons }; #pragma option pop class PASCALIMPLEMENTATION TAdapterFormLayout : public Webcomp::TLayoutWebContent { typedef Webcomp::TLayoutWebContent inherited; private: AnsiString FParentIndent; int FFieldLevel; int FTableLevel; TLayoutState FLayoutState; bool FInTable; bool FInRow; AnsiString FTableHeader; int FColumnCount; int FColumnIndex; bool FBreakButtons; int FButtonIndex; AnsiString FTableIndent; AnsiString FFieldIndent; protected: TAdapterFormLayout* __fastcall GetAdapterFormLayout(void); AnsiString __fastcall GetTableIndent(); AnsiString __fastcall GetChildTableIndent(); AnsiString __fastcall GetFieldIndent(); virtual AnsiString __fastcall ImplLayoutButton(const AnsiString HTMLButton, Webcomp::TLayoutAttributes* Attributes); virtual AnsiString __fastcall ImplLayoutField(const AnsiString HTMLField, Webcomp::TLayoutAttributes* Attributes); virtual AnsiString __fastcall ImplLayoutLabelAndField(const AnsiString HTMLLabel, const AnsiString HTMLField, Webcomp::TLayoutAttributes* Attributes); virtual AnsiString __fastcall ImplLayoutTable(const AnsiString HTMLTable, Webcomp::TLayoutAttributes* Attributes); AnsiString __fastcall StartFields(int ColCount); AnsiString __fastcall EndButtons(); AnsiString __fastcall StartButtons(); AnsiString __fastcall EndFields(); AnsiString __fastcall StartTable(); AnsiString __fastcall EndTable(); AnsiString __fastcall StartRow(); AnsiString __fastcall EndRow(); AnsiString __fastcall NextColumn(int SubItemCount); AnsiString __fastcall EndField(); public: __fastcall TAdapterFormLayout(System::TObject* AParentLayout); AnsiString __fastcall EndLayout(); __property int ColumnCount = {read=FColumnCount, write=FColumnCount, nodefault}; __property bool BreakButtons = {read=FBreakButtons, write=FBreakButtons, nodefault}; __property AnsiString TableHeader = {read=FTableHeader, write=FTableHeader}; __property AnsiString FieldIndent = {read=GetFieldIndent}; __property AnsiString TableIndent = {read=GetTableIndent}; __property AnsiString ChildTableIndent = {read=GetChildTableIndent}; public: #pragma option push -w-inl /* TObject.Destroy */ inline __fastcall virtual ~TAdapterFormLayout(void) { } #pragma option pop private: void *__IGetAdapterFormLayout; /* Webform::IGetAdapterFormLayout */ public: operator IGetAdapterFormLayout*(void) { return (IGetAdapterFormLayout*)&__IGetAdapterFormLayout; } }; class DELPHICLASS TCustomAdapterErrorList; class PASCALIMPLEMENTATION TCustomAdapterErrorList : public Webcomp::TWebContainedComponent { typedef Webcomp::TWebContainedComponent inherited; private: Classes::TComponent* FAdapter; Webcomp::TLayoutAttributes* FLayoutAttributes; Classes::TComponent* __fastcall GetAdapter(void); void __fastcall SetAdapter(const Classes::TComponent* Value); Webcomp::TLayoutAttributes* __fastcall GetLayoutAttributes(void); protected: void __fastcall GetDesigntimeWarnings(Sitecomp::TAbstractDesigntimeWarnings* AWarnings); AnsiString __fastcall Content(Webcomp::TWebContentOptions* Options, System::TObject* Layout); virtual AnsiString __fastcall ImplContent(Webcomp::TWebContentOptions* Options, System::TObject* Layout); virtual void __fastcall Notification(Classes::TComponent* AComponent, Classes::TOperation Operation); public: __fastcall virtual TCustomAdapterErrorList(Classes::TComponent* AOwner); __fastcall virtual ~TCustomAdapterErrorList(void); __property Classes::TComponent* Adapter = {read=GetAdapter, write=SetAdapter}; private: void *__IWebContent; /* Webcomp::IWebContent */ void *__IGetDesigntimeWarnings; /* Sitecomp::IGetDesigntimeWarnings */ public: operator IGetDesigntimeWarnings*(void) { return (IGetDesigntimeWarnings*)&__IGetDesigntimeWarnings; } operator IWebContent*(void) { return (IWebContent*)&__IWebContent; } }; class DELPHICLASS TAdapterErrorList; class PASCALIMPLEMENTATION TAdapterErrorList : public TCustomAdapterErrorList { typedef TCustomAdapterErrorList inherited; __published: __property Adapter ; public: #pragma option push -w-inl /* TCustomAdapterErrorList.Create */ inline __fastcall virtual TAdapterErrorList(Classes::TComponent* AOwner) : TCustomAdapterErrorList(AOwner) { } #pragma option pop #pragma option push -w-inl /* TCustomAdapterErrorList.Destroy */ inline __fastcall virtual ~TAdapterErrorList(void) { } #pragma option pop }; class DELPHICLASS TDesigntimeWarnings; class PASCALIMPLEMENTATION TDesigntimeWarnings : public Sitecomp::TAbstractDesigntimeWarnings { typedef Sitecomp::TAbstractDesigntimeWarnings inherited; private: Classes::TStrings* FStrings; Contnrs::TObjectList* FObjects; public: virtual void __fastcall AddString(AnsiString AWarning); virtual void __fastcall AddObject(System::TObject* AObject); __property Classes::TStrings* Strings = {read=FStrings}; __fastcall TDesigntimeWarnings(void); __fastcall virtual ~TDesigntimeWarnings(void); }; //-- var, const, procedure --------------------------------------------------- #define sMultipartForm "multipart/form-data" #define sFormPost "post" #define sFormGet "get" #define sDisplayText "<%%= %0:s.DisplayText %%>" #define sFieldText "<%%= %0:s.EditText %%>" extern PACKAGE Classes::TComponent* __fastcall FindVariablesContainer(Classes::TComponent* AComponent); extern PACKAGE Classes::TComponent* __fastcall FindVariablesContainerInParent(Classes::TComponent* AComponent); extern PACKAGE AnsiString __fastcall MakeAdapterVariableName(Classes::TComponent* AComponent); extern PACKAGE AnsiString __fastcall MakeAdapterHTMLName(AnsiString AVarName); extern PACKAGE AnsiString __fastcall GetAdapterModeOfAdapterInParent(Classes::TComponent* AComponent); extern PACKAGE bool __fastcall CalcDisplayFieldViewMode(Classes::TComponent* AField, const AnsiString AAdapterMode, TDisplayFieldViewMode AViewMode, TDisplayFieldViewMode &AMode); extern PACKAGE bool __fastcall CalcDisplayFieldHTMLElementType(Classes::TComponent* AField, const AnsiString AAdapterMode, TDisplayFieldHTMLElementType ADisplayType, TDisplayFieldHTMLElementType &AType); } /* namespace Webform */ using namespace Webform; #pragma option pop // -w- #pragma option pop // -Vx #pragma delphiheader end. //-- end unit ---------------------------------------------------------------- #endif // WebForm
[ "bitscode@7bd08ab0-fa70-11de-930f-d36749347e7b" ]
[ [ [ 1, 1283 ] ] ]
50c3e9e0b381b7d6640190a57a55db265363603f
cc336f796b029620d6828804a866824daa6cc2e0
/paplayer/GYMCodec/gym_play.cpp
cdb6513c3fdea1db3c21f21e270a68fef399bd84
[]
no_license
tokyovigilante/xbmc-sources-fork
84fa1a4b6fec5570ce37a69d667e9b48974e3dc3
ac3c6ef8c567f1eeb750ce6e74c63c2d53fcde11
refs/heads/master
2021-01-19T10:11:37.336476
2009-03-09T20:33:58
2009-03-09T20:33:58
29,232
2
0
null
null
null
null
UTF-8
C++
false
false
4,428
cpp
#include <stdio.h> #include <memory.h> #include <math.h> #include "gym_play.h" #include "psg.h" #include "ym2612.h" //int Seg_L[1600], Seg_R[1600]; int* Seg_L; int* Seg_R; int Seg_Lenght; #define CLOCK_NTSC 53700000 //53693175 unsigned int Sound_Extrapol[312][2]; #ifdef __cplusplus extern "C" { #endif /* #ifdef __cplusplus */ int VDP_Current_Line = 0; int GYM_Dumping = 0; int Update_GYM_Dump(char v0, char v1, char v2) { return 0; } #ifdef __cplusplus } #endif /* #ifdef __cplusplus */ unsigned char *jump_gym_time_pos(unsigned char *gym_start, unsigned int gym_size, unsigned int new_pos) { unsigned int loop, num_zeros = 0; for (loop = 0; num_zeros < new_pos; loop++) { if (loop > gym_size) { return 0; } switch(gym_start[loop]) { case(0x00): num_zeros++; continue; case(0x01): loop += 2; continue; case(0x02): loop += 2; continue; case(0x03): loop += 1; continue; } } return (gym_start + loop); } void Write_Sound_Stereo(short *Dest, int lenght) { int i, out_L, out_R; short *dest = Dest; for(i = 0; i < Seg_Lenght; i++) { out_L = Seg_L[i]; Seg_L[i] = 0; if (out_L < -0x7FFF) *dest++ = -0x7FFF; else if (out_L > 0x7FFF) *dest++ = 0x7FFF; else *dest++ = (short) out_L; out_R = Seg_R[i]; Seg_R[i] = 0; if (out_R < -0x7FFF) *dest++ = -0x7FFF; else if (out_R > 0x7FFF) *dest++ = 0x7FFF; else *dest++ = (short) out_R; } } void Start_Play_GYM(int sampleRate) { Seg_Lenght = (int) ceil(sampleRate / 60.0); /* memset(Seg_L, 0, Seg_Lenght << 2); memset(Seg_R, 0, Seg_Lenght << 2);*/ YM2612_Init(CLOCK_NTSC / 7, sampleRate, YM2612_Improv); PSG_Init(CLOCK_NTSC / 15, sampleRate); } unsigned char *GYM_Next(unsigned char *gym_start, unsigned char *gym_pos, unsigned int gym_size, unsigned int gym_loop) { unsigned char c, c2; unsigned char dac_data[1600]; int *buf[2]; int dacMax = 0, i = 0; int oldPos = 0; double curPos = 0; double dacSize; int step; int *dacBuf[2]; int retCode = 1; YM_Buf[0] = PSG_Buf[0] = buf[0] = Seg_L; YM_Buf[1] = PSG_Buf[1] = buf[1] = Seg_R; YM_Len = PSG_Len = 0; memset(dac_data, 0, sizeof(dac_data)); if (!gym_pos) { return 0; } if ((unsigned int)(gym_pos - gym_start) >= gym_size) { if (gym_loop) { gym_pos = jump_gym_time_pos(gym_start, gym_size, gym_loop - 1); } else { return 0; } } do { c = *gym_pos++; switch(c) { case 0: if (YM2612_Enable) { // if dacMax is zero, dacSize will be NaN - so what, we won't // be using it in that case anyway :p dacSize = (double)Seg_Lenght / dacMax; for (i = 0; i < dacMax; i++) { oldPos = (int)curPos; YM2612_Write(0, 0x2A); YM2612_Write(1, dac_data[i]); if (i == dacMax - 1) { step = Seg_Lenght - oldPos; } else { curPos += dacSize; step = (int)curPos - oldPos; } dacBuf[0] = buf[0] + (int)oldPos; dacBuf[1] = buf[1] + (int)oldPos; YM2612_DacAndTimers_Update(dacBuf, step); } YM2612_Update(buf, Seg_Lenght); } if (PSG_Enable) { if (PSG_Improv) { PSG_Update_SIN(buf, Seg_Lenght); } else { PSG_Update(buf, Seg_Lenght); } } break; case 1: c2 = *gym_pos++; if (c2 == 0x2A) { c2 = *gym_pos++; dac_data[dacMax++] = c2; } else { YM2612_Write(0, c2); c2 = *gym_pos++; YM2612_Write(1, c2); } break; case 2: c2 = *gym_pos++; YM2612_Write(2, c2); c2 = *gym_pos++; YM2612_Write(3, c2); break; case 3: c2 = *gym_pos++; PSG_Write(c2); break; } } while (c); return gym_pos; } unsigned char *Play_GYM(void *Dump_Buf, unsigned char *gym_start, unsigned char *gym_pos, unsigned int gym_size, unsigned int gym_loop) { unsigned char *new_gym_pos = GYM_Next(gym_start, gym_pos, gym_size, gym_loop); if (new_gym_pos == 0) { return 0; } Write_Sound_Stereo((short *)Dump_Buf, Seg_Lenght); return new_gym_pos; }
[ "spiff_@568bbfeb-2a22-0410-94d2-cc84cf5bfa90" ]
[ [ [ 1, 235 ] ] ]
5d8360546a3bcdac2f9eb0c6517986f407d9365f
cd0987589d3815de1dea8529a7705caac479e7e9
/webkit/WebKit/blackberry/WebKitSupport/WebPlugin.h
5a7cdbbfcc4e48286934c87aabc417c804b205f3
[ "BSD-2-Clause" ]
permissive
azrul2202/WebKit-Smartphone
0aab1ff641d74f15c0623f00c56806dbc9b59fc1
023d6fe819445369134dee793b69de36748e71d7
refs/heads/master
2021-01-15T09:24:31.288774
2011-07-11T11:12:44
2011-07-11T11:12:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,638
h
/* * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. */ #ifndef WebPlugin_h #define WebPlugin_h #include "CString.h" #include "PlatformString.h" namespace WebCore { class HTMLElement; class IntRect; class IntSize; class PluginWidget; class WebMediaPlayerProxy; } namespace Olympia { namespace WebKit { class WebPage; class WebPlugin : public RefCounted<WebPlugin> { public: WebPlugin(WebPage* webPage, int width, int height, WebCore::HTMLElement* node, const Vector<WTF::String>& paramNames, const Vector<WTF::String>& paramValues, const WTF::String& url = WTF::String()); ~WebPlugin(); void setGeometry(const WebCore::IntRect&); void destroy(); void detach(); int playerID() const { return m_playerID; } int width() const { return m_width; } int height() const { return m_height; } bool isLoaded() const { return m_isLoaded; } void setLoaded(bool isLoaded) { m_isLoaded = isLoaded; } bool shouldBeCancelled() const { return m_shouldBeCancelled; } void setShouldBeCancelled(bool shouldBeCancelled) { m_shouldBeCancelled = shouldBeCancelled; } WTF::String url() const { return m_url; } // JS control. void play(); void pause(); void load(const WTF::String& url, WebCore::WebMediaPlayerProxy* proxy); float time(); float duration() const { return m_duration;} void seek(float time); void setVolume(float volume); float volume() const { return m_volume;} void setMuted(bool muted); bool muted() const { return m_muted; } void setSize(const WebCore::IntSize& size); bool autoplay() const { return m_autoplay; } void setAutoplay(bool autoplay) { m_autoplay = autoplay; } WebCore::HTMLElement* element() const { return m_element; } void setElement(WebCore::HTMLElement* element) { m_element = element; } void setWidget(RefPtr<WebCore::PluginWidget> widget); PassRefPtr<WebCore::PluginWidget> widget() const; void readyStateChanged(int state); void volumeChanged(int volume); void durationChanged(float duration); private: int m_playerID; WebPage* m_webPage; int m_width; int m_height; WebCore::HTMLElement* m_element; WebCore::WebMediaPlayerProxy * m_proxy; WTF::String m_url; RefPtr<WebCore::PluginWidget> m_widget; bool m_isLoaded; bool m_shouldBeCancelled; bool m_muted; bool m_autoplay; float m_volume; float m_duration; Vector<WTF::String> m_paramNames; Vector<WTF::String> m_paramValues; }; } } #endif
[ [ [ 1, 91 ] ] ]
7d85ed990a311b9535f3e5212b89caa57e243617
6e563096253fe45a51956dde69e96c73c5ed3c18
/dhnetsdk/Demo/ClientState.cpp
f5317b99ca5b6fdb1d48a949554c2df921f4b742
[]
no_license
15831944/phoebemail
0931b76a5c52324669f902176c8477e3bd69f9b1
e10140c36153aa00d0251f94bde576c16cab61bd
refs/heads/master
2023-03-16T00:47:40.484758
2010-10-11T02:31:02
2010-10-11T02:31:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,845
cpp
// lientState.cpp : implementation file // #include "stdafx.h" #include "netsdkdemo.h" #include "clientState.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CClientState dialog CClientState::CClientState(CWnd* pParent /*=NULL*/) : CDialog(CClientState::IDD, pParent) { m_dev = 0; memset(&m_myState, 0, sizeof(NET_CLIENT_STATE)); //{{AFX_DATA_INIT(CClientState) m_isNoMoreShow = FALSE; //}}AFX_DATA_INIT } CClientState::~CClientState() { } void CClientState::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CClientState) DDX_Check(pDX, IDC_NOSHOW, m_isNoMoreShow); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CClientState, CDialog) //{{AFX_MSG_MAP(CClientState) ON_WM_TIMER() ON_WM_CLOSE() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // ClientState message handlers void CClientState::UpdateState() { if (!m_dev) { return; } CDevMgr::GetDevMgr().GetAlarmInfo(m_dev->LoginID, &m_myState); CString str; str.Format("(%s [%s])",m_dev->Name, m_dev->IP); CString strTmp; CString strDiskError = ConvertString(MSG_CLIENTSTATE_DISKERR); for (int i=0; i<32; i++) { // if (m_myState.diskerror[i]) if (m_myState.dError & (0x01<<i)) { strTmp.Format(" %d", i+1); strDiskError += strTmp; } } CString strDiskFull = ConvertString(MSG_CLIENTSTATE_DISKFULL); //if (m_myState.diskfull) if (m_myState.dFull) { strDiskFull += ConvertString("Full"); } else { strDiskFull += ConvertString("Not"); } CString strShelter = ConvertString(MSG_CLIENTSTATE_SHELTER); for (i=0; i<16; i++) { if (m_myState.shelter[i]) { strTmp.Format(" %d", i+1); strShelter += strTmp; } } CString strAlarm = ConvertString(MSG_CLIENTSTATE_ALARM); for (i=0; i<m_dev->Info.byAlarmInPortNum; i++) { // if (m_myState.alarmout[i]) if (m_myState.cState.alarm[i]) { strTmp.Format(" %d", i+1); strAlarm += strTmp; } } CString strMD = ConvertString(MSG_CLIENTSTATE_MOTION); CString strVideoLost = ConvertString(MSG_CLIENTSTATE_VIDEOLOST); CString strSD = ConvertString(MSG_CLIENTSTATE_SOUND); for (i=0; i<m_dev->Info.byChanNum; i++) { if (m_myState.cState.motiondection[i]) { strTmp.Format(" %d", i+1); strMD += strTmp; } if (m_myState.cState.videolost[i]) { strTmp.Format(" %d", i+1); strVideoLost += strTmp; } if (m_myState.soundalarm[i]) { strTmp.Format(" %d", i+1); strSD += strTmp; } } CString strSerial = ConvertString(MSG_CLIENTSTATE_SERIAL); strTmp.Format("%s", m_dev->Info.sSerialNumber); strSerial += strTmp; CString strAlmDec = ConvertString(MSG_CLIENTSTATE_ALMDEC); strAlmDec += ": \n"; for (i = 0; i < 16; i++) { for(int j = 0; j < 8; j++) { if (m_myState.almDecoder[i] & (1<<j)) { strTmp.Format("%d", 1); } else { strTmp.Format("%d", 0); } strAlmDec += strTmp; } strAlmDec += " "; } str += ConvertString(MSG_CLIENTSTATE_CLIENTSTATE); str = str + "\n" + "\n"+ strDiskError + "\n" + "\n"+ strDiskFull + "\n" + "\n"+ strShelter + "\n" + "\n"+ strAlarm + "\n" + "\n"+ strMD + "\n" + "\n"+ strVideoLost + "\n" + "\n"+ strSD + "\n" + "\n"+ strAlmDec + "\n" + "\n"+ strSerial; GetDlgItem(IDC_CLIENT_STATE)->SetWindowText(str); } ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// // CClientState message handlers BOOL CClientState::OnInitDialog() { CDialog::OnInitDialog(); g_SetWndStaticText(this); return TRUE; } void CClientState::StartRefresh() { SetTimer((UINT)this,200,0); } void CClientState::StopRefresh() { KillTimer((UINT)this); } void CClientState::OnTimer(UINT nIDEvent) { UpdateState(); CDialog::OnTimer(nIDEvent); } void CClientState::SetDevice(DeviceNode *dev) { m_dev = dev; } DeviceNode* CClientState::GetDevice() { return m_dev; } void CClientState::OnClose() { StopRefresh(); CDialog::OnClose(); } void CClientState::OnOK() { StopRefresh(); CDialog::OnOK(); } BOOL CClientState::PreTranslateMessage(MSG* pMsg) { if (WM_KEYDOWN == pMsg->message && (VK_ESCAPE == pMsg->wParam)) { return TRUE; } return CDialog::PreTranslateMessage(pMsg); }
[ "guoqiao@a83c37f4-16cc-5f24-7598-dca3a346d5dd" ]
[ [ [ 1, 219 ] ] ]
e61eebcc7178438d627c4f8a1775c062d2fd1234
036f83e4ba5370b4ec50da6d1d1561d85dedbde0
/learning-cpp/ifstream_get.cpp
44e0c7d7da2b05a6f69084d4ebe6bba77c4988b7
[]
no_license
losvald/high-school
8ba4487889093451b519c3f582d0dce8a5a6f5b8
4bfe295ad4ef1badf8a01d19e2ab3a65d59c1ce8
refs/heads/master
2016-09-06T03:48:25.747372
2008-01-17T10:56:55
2008-01-17T10:56:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
390
cpp
#include <string.h> #include <conio.h> #include <iostream.h> #include <fstream.h> #include <ctype.h> int main() { ifstream in("vjerot13.txt", ios::in); ofstream out("vj.txt", ios::out); char c; const bool da = true; while (da) { in.get(c); if(c == '!') break; if(c != ' ') out << c; } getch(); }
[ [ [ 1, 19 ] ] ]
cc849b21b489bf856bb28223f7064757ac038777
41543fd481e363d8c4794edc97e767c8defb2273
/http/src/parser_base.cpp
6d7488088e8793ce987d67ecdf5a7713403efae1
[ "BSL-1.0" ]
permissive
ExpLife0011/libHTTP
550904eddf17f5fa89a2ff9fd563ff5746cbc29b
c53b85c7192f5b2cf506a71f36ec44e9b99ada1a
refs/heads/master
2020-03-08T16:35:52.022125
2010-05-14T18:13:36
2010-05-14T18:13:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
82
cpp
#include <http/parser_base.hpp> namespace http { } // namespace http
[ "rhenders@oliver.(none)" ]
[ [ [ 1, 8 ] ] ]
afece9537bb7d4bf30e17a434a3439653b17aa3e
5ee08487a9cdb4aa377457d7589871b0934d7884
/HINTS/MSYS.CPP
ec15c1dd53db1d8136f7ec9804c413b4b7c9ae35
[]
no_license
v0idkr4ft/algo.vga
0cf5affdebd02a49401865d002679d16ac8efb09
72c97a01d1e004f62da556048b0ef5b7df34b89c
refs/heads/master
2021-05-27T18:48:48.823361
2011-04-26T03:58:02
2011-04-26T03:58:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,046
cpp
#include <dos.h> #include <bios.h> #include <stdio.h> #include <math.h> #include <conio.h> #define SCAN_Q 16 #define CTRL 0x0004 #define ALT 0x0008 // functions... unsigned char Get_Ascii(void) { if (_bios_keybrd(_KEYBRD_READY)) return(_bios_keybrd(_KEYBRD_READ)); else return(0); } unsigned int Get_Control_keys(unsigned int mask) { return(mask & _bios_keybrd(_KEYBRD_SHIFTSTATUS)); } unsigned char Get_Scancode(void) { asm mov ah,01 asm int 16h asm jz empty asm xor ah,ah asm int 16h asm xchg al,ah asm xor ah,ah asm jmp done empty: asm xor ax,ax done: } main(void) { unsigned char key; int done=0; while (!done) { if ( (key = Get_Scancode()) ) { printf("\nScan code = %d ",key); } if (Get_Control_keys(CTRL)) printf("\nControl key pressed"); if (Get_Control_keys(ALT)) printf("\nalt key pressed"); if (key==SCAN_Q) done=1; } }
[ [ [ 1, 57 ] ] ]
c9bd4cbb417911b85a78d6a6586c7e8fd09218f2
4f469243a2e6fc370f0d1859ec68de5efce90fa1
/infected/src/game/shared/hl2mp/weapon_freeze.cpp
4813f039b435e0d3c1f1555af5f4a00219666de7
[]
no_license
sideshowdave7/hl2-infected-mod
c710d3958cc143381eba28b7237c8f4ccdd49982
a69fe39a2e13cbac3978ecf57c84cd8e9aa7bb0d
refs/heads/master
2020-12-24T15:41:30.546220
2011-04-30T03:05:50
2011-04-30T03:05:50
61,587,106
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
17,705
cpp
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// // // Purpose: // //=============================================================================// #include "cbase.h" #include "npcevent.h" #include "in_buttons.h" #ifdef CLIENT_DLL #include "c_hl2mp_player.h" #else #include "hl2mp_player.h" #endif #include "weapon_hl2mpbasehlmpcombatweapon.h" #ifdef CLIENT_DLL #define CWeaponFreeze C_WeaponFreeze #endif extern ConVar sk_auto_reload_time; extern ConVar sk_plr_num_shotgun_pellets; class CWeaponFreeze : public CBaseHL2MPCombatWeapon { public: DECLARE_CLASS( CWeaponFreeze, CBaseHL2MPCombatWeapon ); DECLARE_NETWORKCLASS(); DECLARE_PREDICTABLE(); private: CNetworkVar( bool, m_bNeedPump ); // When emptied completely CNetworkVar( bool, m_bDelayedFire1 ); // Fire primary when finished reloading CNetworkVar( bool, m_bDelayedFire2 ); // Fire secondary when finished reloading CNetworkVar( bool, m_bDelayedReload ); // Reload when finished pump public: virtual const Vector& GetBulletSpread( void ) { static Vector cone = VECTOR_CONE_10DEGREES; return cone; } virtual int GetMinBurst() { return 1; } virtual int GetMaxBurst() { return 3; } bool StartReload( void ); bool Reload( void ); void FillClip( void ); void FinishReload( void ); void CheckHolsterReload( void ); void Pump( void ); // void WeaponIdle( void ); void ItemHolsterFrame( void ); void ItemPostFrame( void ); void PrimaryAttack( void ); void SecondaryAttack( void ); void DryFire( void ); virtual float GetFireRate( void ) { return 0.7; }; DECLARE_ACTTABLE(); CWeaponFreeze(void); private: CWeaponFreeze( const CWeaponFreeze & ); }; IMPLEMENT_NETWORKCLASS_ALIASED( WeaponFreeze, DT_WeaponFreeze ) BEGIN_NETWORK_TABLE( CWeaponFreeze, DT_WeaponFreeze ) #ifdef CLIENT_DLL RecvPropBool( RECVINFO( m_bNeedPump ) ), RecvPropBool( RECVINFO( m_bDelayedFire1 ) ), RecvPropBool( RECVINFO( m_bDelayedFire2 ) ), RecvPropBool( RECVINFO( m_bDelayedReload ) ), #else SendPropBool( SENDINFO( m_bNeedPump ) ), SendPropBool( SENDINFO( m_bDelayedFire1 ) ), SendPropBool( SENDINFO( m_bDelayedFire2 ) ), SendPropBool( SENDINFO( m_bDelayedReload ) ), #endif END_NETWORK_TABLE() #ifdef CLIENT_DLL BEGIN_PREDICTION_DATA( CWeaponFreeze ) DEFINE_PRED_FIELD( m_bNeedPump, FIELD_BOOLEAN, FTYPEDESC_INSENDTABLE ), DEFINE_PRED_FIELD( m_bDelayedFire1, FIELD_BOOLEAN, FTYPEDESC_INSENDTABLE ), DEFINE_PRED_FIELD( m_bDelayedFire2, FIELD_BOOLEAN, FTYPEDESC_INSENDTABLE ), DEFINE_PRED_FIELD( m_bDelayedReload, FIELD_BOOLEAN, FTYPEDESC_INSENDTABLE ), END_PREDICTION_DATA() #endif LINK_ENTITY_TO_CLASS( weapon_freeze, CWeaponFreeze ); PRECACHE_WEAPON_REGISTER(weapon_freeze); acttable_t CWeaponFreeze::m_acttable[] = { { ACT_MP_STAND_IDLE, ACT_HL2MP_IDLE_SHOTGUN, false }, { ACT_MP_CROUCH_IDLE, ACT_HL2MP_IDLE_CROUCH_SHOTGUN, false }, { ACT_MP_RUN, ACT_HL2MP_RUN_SHOTGUN, false }, { ACT_MP_CROUCHWALK, ACT_HL2MP_WALK_CROUCH_SHOTGUN, false }, { ACT_MP_ATTACK_STAND_PRIMARYFIRE, ACT_HL2MP_GESTURE_RANGE_ATTACK_SHOTGUN, false }, { ACT_MP_ATTACK_CROUCH_PRIMARYFIRE, ACT_HL2MP_GESTURE_RANGE_ATTACK_SHOTGUN, false }, { ACT_MP_RELOAD_STAND, ACT_HL2MP_GESTURE_RELOAD_SHOTGUN, false }, { ACT_MP_RELOAD_CROUCH, ACT_HL2MP_GESTURE_RELOAD_SHOTGUN, false }, { ACT_MP_JUMP, ACT_HL2MP_JUMP_SHOTGUN, false }, }; IMPLEMENT_ACTTABLE(CWeaponFreeze); //----------------------------------------------------------------------------- // Purpose: Override so only reload one shell at a time // Input : // Output : //----------------------------------------------------------------------------- bool CWeaponFreeze::StartReload( void ) { if ( m_bNeedPump ) return false; CBaseCombatCharacter *pOwner = GetOwner(); if ( pOwner == NULL ) return false; if (pOwner->GetAmmoCount(m_iPrimaryAmmoType) <= 0) return false; if (m_iClip1 >= GetMaxClip1()) return false; int j = min(1, pOwner->GetAmmoCount(m_iPrimaryAmmoType)); if (j <= 0) return false; SendWeaponAnim( ACT_SHOTGUN_RELOAD_START ); //Tony; BUG BUG BUG!!! shotgun does one shell at a time!!! -- player model only has a single reload!!! so I'm just going to dispatch the singular for now. ToHL2MPPlayer( pOwner )->DoAnimationEvent( PLAYERANIMEVENT_RELOAD ); // Make shotgun shell visible SetBodygroup(1,0); pOwner->m_flNextAttack = gpGlobals->curtime; m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration(); m_bInReload = true; return true; } //----------------------------------------------------------------------------- // Purpose: Override so only reload one shell at a time // Input : // Output : //----------------------------------------------------------------------------- bool CWeaponFreeze::Reload( void ) { // Check that StartReload was called first if (!m_bInReload) { Warning("ERROR: Shotgun Reload called incorrectly!\n"); } CBaseCombatCharacter *pOwner = GetOwner(); if ( pOwner == NULL ) return false; if (pOwner->GetAmmoCount(m_iPrimaryAmmoType) <= 0) return false; if (m_iClip1 >= GetMaxClip1()) return false; int j = min(1, pOwner->GetAmmoCount(m_iPrimaryAmmoType)); if (j <= 0) return false; FillClip(); // Play reload on different channel as otherwise steals channel away from fire sound WeaponSound(RELOAD); SendWeaponAnim( ACT_VM_RELOAD ); pOwner->m_flNextAttack = gpGlobals->curtime; m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration(); return true; } //----------------------------------------------------------------------------- // Purpose: Play finish reload anim and fill clip // Input : // Output : //----------------------------------------------------------------------------- void CWeaponFreeze::FinishReload( void ) { // Make shotgun shell invisible SetBodygroup(1,1); CBaseCombatCharacter *pOwner = GetOwner(); if ( pOwner == NULL ) return; m_bInReload = false; // Finish reload animation SendWeaponAnim( ACT_SHOTGUN_RELOAD_FINISH ); pOwner->m_flNextAttack = gpGlobals->curtime; m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration(); } //----------------------------------------------------------------------------- // Purpose: Play finish reload anim and fill clip // Input : // Output : //----------------------------------------------------------------------------- void CWeaponFreeze::FillClip( void ) { CBaseCombatCharacter *pOwner = GetOwner(); if ( pOwner == NULL ) return; // Add them to the clip if ( pOwner->GetAmmoCount( m_iPrimaryAmmoType ) > 0 ) { if ( Clip1() < GetMaxClip1() ) { m_iClip1++; pOwner->RemoveAmmo( 1, m_iPrimaryAmmoType ); } } } //----------------------------------------------------------------------------- // Purpose: Play weapon pump anim // Input : // Output : //----------------------------------------------------------------------------- void CWeaponFreeze::Pump( void ) { CBaseCombatCharacter *pOwner = GetOwner(); if ( pOwner == NULL ) return; m_bNeedPump = false; if ( m_bDelayedReload ) { m_bDelayedReload = false; StartReload(); } WeaponSound( SPECIAL1 ); // Finish reload animation SendWeaponAnim( ACT_SHOTGUN_PUMP ); pOwner->m_flNextAttack = gpGlobals->curtime + SequenceDuration(); m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration(); } //----------------------------------------------------------------------------- // Purpose: // // //----------------------------------------------------------------------------- void CWeaponFreeze::DryFire( void ) { WeaponSound(EMPTY); SendWeaponAnim( ACT_VM_DRYFIRE ); m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration(); } //----------------------------------------------------------------------------- // Purpose: // // //----------------------------------------------------------------------------- void CWeaponFreeze::PrimaryAttack( void ) { // Only the player fires this way so we can cast CBasePlayer *pPlayer = ToBasePlayer( GetOwner() ); if (!pPlayer) { return; } // MUST call sound before removing a round from the clip of a CMachineGun WeaponSound(SINGLE); //pPlayer->DoMuzzleFlash(); SendWeaponAnim( ACT_VM_PRIMARYATTACK ); // Don't fire again until fire animation has completed m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration(); m_iClip1 -= 1; // player "shoot" animation pPlayer->SetAnimation( PLAYER_ATTACK1 ); ToHL2MPPlayer(pPlayer)->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY ); Vector vecSrc = pPlayer->Weapon_ShootPosition( ); Vector vecAiming = pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES ); FireBulletsInfo_t info( 7, vecSrc, vecAiming, GetBulletSpread(), MAX_TRACE_LENGTH, m_iPrimaryAmmoType ); info.m_pAttacker = pPlayer; // Fire the bullets, and force the first shot to be perfectly accuracy pPlayer->FireBullets( info ); QAngle punch; punch.Init( SharedRandomFloat( "shotgunpax", -2, -1 ), SharedRandomFloat( "shotgunpay", -2, 2 ), 0 ); pPlayer->ViewPunch( punch ); if (!m_iClip1 && pPlayer->GetAmmoCount(m_iPrimaryAmmoType) <= 0) { // HEV suit - indicate out of ammo condition pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); } trace_t tr; // do the traceline UTIL_TraceLine( vecSrc, vecAiming, MASK_ALL, pPlayer,COLLISION_GROUP_NPC, &tr ); // do if statements to check what we hit ... add if player is human, etc, etc if ( tr.m_pEnt ) { // This will ignite the player tr.m_pEnt->SetAbsVelocity(0); tr.m_pEnt->Freeze(); tr.m_pEnt->SetGravity(2000000); } } //----------------------------------------------------------------------------- // Purpose: // // //----------------------------------------------------------------------------- void CWeaponFreeze::SecondaryAttack( void ) { // Only the player fires this way so we can cast CBasePlayer *pPlayer = ToBasePlayer( GetOwner() ); if (!pPlayer) { return; } pPlayer->m_nButtons &= ~IN_ATTACK2; // MUST call sound before removing a round from the clip of a CMachineGun WeaponSound(WPN_DOUBLE); pPlayer->DoMuzzleFlash(); SendWeaponAnim( ACT_VM_SECONDARYATTACK ); // Don't fire again until fire animation has completed m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration(); m_iClip1 -= 2; // Shotgun uses same clip for primary and secondary attacks // player "shoot" animation pPlayer->SetAnimation( PLAYER_ATTACK1 ); //Tony; does shotgun have a second anim? ToHL2MPPlayer(pPlayer)->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY ); Vector vecSrc = pPlayer->Weapon_ShootPosition(); Vector vecAiming = pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES ); FireBulletsInfo_t info( 12, vecSrc, vecAiming, GetBulletSpread(), MAX_TRACE_LENGTH, m_iPrimaryAmmoType ); info.m_pAttacker = pPlayer; // Fire the bullets, and force the first shot to be perfectly accuracy pPlayer->FireBullets( info ); pPlayer->ViewPunch( QAngle(SharedRandomFloat( "shotgunsax", -5, 5 ),0,0) ); if (!m_iClip1 && pPlayer->GetAmmoCount(m_iPrimaryAmmoType) <= 0) { // HEV suit - indicate out of ammo condition pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); } m_bNeedPump = true; } //----------------------------------------------------------------------------- // Purpose: Override so shotgun can do mulitple reloads in a row //----------------------------------------------------------------------------- void CWeaponFreeze::ItemPostFrame( void ) { CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if (!pOwner) { return; } if ( m_bNeedPump && ( pOwner->m_nButtons & IN_RELOAD ) ) { m_bDelayedReload = true; } if (m_bInReload) { // If I'm primary firing and have one round stop reloading and fire if ((pOwner->m_nButtons & IN_ATTACK ) && (m_iClip1 >=1) && !m_bNeedPump ) { m_bInReload = false; m_bNeedPump = false; m_bDelayedFire1 = true; } // If I'm secondary firing and have two rounds stop reloading and fire else if ((pOwner->m_nButtons & IN_ATTACK2 ) && (m_iClip1 >=2) && !m_bNeedPump ) { m_bInReload = false; m_bNeedPump = false; m_bDelayedFire2 = true; } else if (m_flNextPrimaryAttack <= gpGlobals->curtime) { // If out of ammo end reload if (pOwner->GetAmmoCount(m_iPrimaryAmmoType) <=0) { FinishReload(); return; } // If clip not full reload again if (m_iClip1 < GetMaxClip1()) { Reload(); return; } // Clip full, stop reloading else { FinishReload(); return; } } } else { // Make shotgun shell invisible SetBodygroup(1,1); } if ((m_bNeedPump) && (m_flNextPrimaryAttack <= gpGlobals->curtime)) { Pump(); return; } // Shotgun uses same timing and ammo for secondary attack if ((m_bDelayedFire2 || pOwner->m_nButtons & IN_ATTACK2)&&(m_flNextPrimaryAttack <= gpGlobals->curtime)) { m_bDelayedFire2 = false; if ( (m_iClip1 <= 1 && UsesClipsForAmmo1())) { // If only one shell is left, do a single shot instead if ( m_iClip1 == 1 ) { PrimaryAttack(); } else if (!pOwner->GetAmmoCount(m_iPrimaryAmmoType)) { DryFire(); } else { StartReload(); } } // Fire underwater? else if (GetOwner()->GetWaterLevel() == 3 && m_bFiresUnderwater == false) { WeaponSound(EMPTY); m_flNextPrimaryAttack = gpGlobals->curtime + 0.2; return; } else { // If the firing button was just pressed, reset the firing time if ( pOwner->m_afButtonPressed & IN_ATTACK ) { m_flNextPrimaryAttack = gpGlobals->curtime; } SecondaryAttack(); } } else if ( (m_bDelayedFire1 || pOwner->m_nButtons & IN_ATTACK) && m_flNextPrimaryAttack <= gpGlobals->curtime) { m_bDelayedFire1 = false; if ( (m_iClip1 <= 0 && UsesClipsForAmmo1()) || ( !UsesClipsForAmmo1() && !pOwner->GetAmmoCount(m_iPrimaryAmmoType) ) ) { if (!pOwner->GetAmmoCount(m_iPrimaryAmmoType)) { DryFire(); } else { StartReload(); } } // Fire underwater? else if (pOwner->GetWaterLevel() == 3 && m_bFiresUnderwater == false) { WeaponSound(EMPTY); m_flNextPrimaryAttack = gpGlobals->curtime + 0.2; return; } else { // If the firing button was just pressed, reset the firing time CBasePlayer *pPlayer = ToBasePlayer( GetOwner() ); if ( pPlayer && pPlayer->m_afButtonPressed & IN_ATTACK ) { m_flNextPrimaryAttack = gpGlobals->curtime; } PrimaryAttack(); } } if ( pOwner->m_nButtons & IN_RELOAD && UsesClipsForAmmo1() && !m_bInReload ) { // reload when reload is pressed, or if no buttons are down and weapon is empty. StartReload(); } else { // no fire buttons down m_bFireOnEmpty = false; if ( !HasAnyAmmo() && m_flNextPrimaryAttack < gpGlobals->curtime ) { // weapon isn't useable, switch. if ( !(GetWeaponFlags() & ITEM_FLAG_NOAUTOSWITCHEMPTY) && pOwner->SwitchToNextBestWeapon( this ) ) { m_flNextPrimaryAttack = gpGlobals->curtime + 0.3; return; } } else { // weapon is useable. Reload if empty and weapon has waited as long as it has to after firing if ( m_iClip1 <= 0 && !(GetWeaponFlags() & ITEM_FLAG_NOAUTORELOAD) && m_flNextPrimaryAttack < gpGlobals->curtime ) { if (StartReload()) { // if we've successfully started to reload, we're done return; } } } WeaponIdle( ); return; } } //----------------------------------------------------------------------------- // Purpose: Constructor //----------------------------------------------------------------------------- CWeaponFreeze::CWeaponFreeze( void ) { m_bReloadsSingly = true; m_bNeedPump = false; m_bDelayedFire1 = false; m_bDelayedFire2 = false; m_fMinRange1 = 0.0; m_fMaxRange1 = 500; m_fMinRange2 = 0.0; m_fMaxRange2 = 200; } //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponFreeze::ItemHolsterFrame( void ) { // Must be player held if ( GetOwner() && GetOwner()->IsPlayer() == false ) return; // We can't be active if ( GetOwner()->GetActiveWeapon() == this ) return; // If it's been longer than three seconds, reload if ( ( gpGlobals->curtime - m_flHolsterTime ) > sk_auto_reload_time.GetFloat() ) { // Reset the timer m_flHolsterTime = gpGlobals->curtime; if ( GetOwner() == NULL ) return; if ( m_iClip1 == GetMaxClip1() ) return; // Just load the clip with no animations int ammoFill = min( (GetMaxClip1() - m_iClip1), GetOwner()->GetAmmoCount( GetPrimaryAmmoType() ) ); GetOwner()->RemoveAmmo( ammoFill, GetPrimaryAmmoType() ); m_iClip1 += ammoFill; } } //================================================== // Purpose: //================================================== /* void CWeaponFreeze::WeaponIdle( void ) { //Only the player fires this way so we can cast CBasePlayer *pPlayer = GetOwner() if ( pPlayer == NULL ) return; //If we're on a target, play the new anim if ( pPlayer->IsOnTarget() ) { SendWeaponAnim( ACT_VM_IDLE_ACTIVE ); } } */
[ [ [ 1, 19 ], [ 21, 25 ], [ 27, 28 ], [ 30, 65 ], [ 67, 68 ], [ 70, 71 ], [ 73, 73 ], [ 75, 88 ], [ 90, 96 ], [ 98, 99 ], [ 101, 116 ], [ 118, 124 ], [ 126, 166 ], [ 168, 206 ], [ 208, 230 ], [ 232, 253 ], [ 255, 282 ], [ 284, 295 ], [ 297, 308 ], [ 310, 310 ], [ 312, 328 ], [ 330, 348 ], [ 350, 350 ], [ 355, 362 ], [ 364, 412 ], [ 414, 590 ], [ 592, 607 ], [ 609, 641 ], [ 643, 656 ] ], [ [ 20, 20 ], [ 26, 26 ], [ 29, 29 ], [ 66, 66 ], [ 69, 69 ], [ 72, 72 ], [ 74, 74 ], [ 89, 89 ], [ 97, 97 ], [ 100, 100 ], [ 117, 117 ], [ 125, 125 ], [ 167, 167 ], [ 207, 207 ], [ 231, 231 ], [ 254, 254 ], [ 283, 283 ], [ 296, 296 ], [ 309, 309 ], [ 311, 311 ], [ 329, 329 ], [ 349, 349 ], [ 351, 354 ], [ 363, 363 ], [ 413, 413 ], [ 591, 591 ], [ 608, 608 ], [ 642, 642 ] ] ]
fa292b0e3a31a5212d6aa8a2dfda22bb66ebcff7
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/_Common/xUtil3D.h
63666a459443345ac8e9e357405401b290a40e27
[]
no_license
willrebuild/flyffsf
e5911fb412221e00a20a6867fd00c55afca593c7
d38cc11790480d617b38bb5fc50729d676aef80d
refs/heads/master
2021-01-19T20:27:35.200154
2011-02-10T12:34:43
2011-02-10T12:34:43
32,710,780
3
0
null
null
null
null
UHC
C++
false
false
4,356
h
#ifndef __XUTIL3D_H__ #define __XUTIL3D_H__ void QuaternionRotationToYPW( const D3DXQUATERNION& qRot, D3DXVECTOR3& vYPW ); void SetBB( D3DXVECTOR3 *pBBVList, const D3DXVECTOR3 &vMin, const D3DXVECTOR3 &vMax ); // AABB간의 충돌검출 int IsTouchAABB( const D3DXVECTOR3 &vMin1, const D3DXVECTOR3 &vMax1, const D3DXVECTOR3 &vMin2, const D3DXVECTOR3 &vMax2 ); BOOL IsTouchAABB_Line( const D3DXVECTOR3 &vMin, const D3DXVECTOR3 &vMax, const D3DXVECTOR3 &v1, const D3DXVECTOR3 &v2, D3DXVECTOR3 *pvIntersect ); BOOL IsTouchOBB_Line( const D3DXVECTOR3 &vMin, const D3DXVECTOR3 &vMax, const D3DXMATRIX &m, const D3DXVECTOR3 &v1, const D3DXVECTOR3 &v2, D3DXVECTOR3 *pvIntersect ); BOOL IsTouchRayTri( const D3DXVECTOR3 *v0, const D3DXVECTOR3 *v1, const D3DXVECTOR3 *v2, const D3DXVECTOR3 *vOrig, const D3DXVECTOR3 *vDir, FLOAT* pfDist ); void CalcSlideVec( D3DXVECTOR3 *pOut, const D3DXVECTOR3 &vDir, const D3DXVECTOR3 &vN ); inline void AngleToVector( D3DXVECTOR3 *vDelta, float fAngXZ, float fAngH, float fSpeed ) { float fDist; fAngXZ = D3DXToRadian(fAngXZ); fAngH = D3DXToRadian(fAngH); fDist = cosf(-fAngH) * fSpeed; vDelta->x = sinf(fAngXZ) * fDist; vDelta->z = -cosf(fAngXZ) * fDist; vDelta->y = -sinf(-fAngH) * fSpeed; } inline void AngleToVectorXZ( D3DXVECTOR3 *vDelta, float fAngXZ, float fSpeed ) { fAngXZ = D3DXToRadian(fAngXZ); vDelta->x = sinf(fAngXZ) * fSpeed; vDelta->z = -cosf(fAngXZ) * fSpeed; vDelta->y = 0; } // XZ평면의 각도와 높이쪽 각도를 한꺼번에 구함. inline void xGetDegree( float *pfAngXZ, float *pfAngH, const D3DXVECTOR3 &vDist ) { D3DXVECTOR3 vDistXZ = vDist; vDistXZ.y = 0; FLOAT fAngXZ = D3DXToDegree( (FLOAT)atan2( vDist.x, -vDist.z ) ); // 우선 XZ평면의 각도를 먼저 구함 FLOAT fLenXZ = D3DXVec3Length( &vDistXZ ); // y좌표를 무시한 XZ평면에서의 길이를 구함. FLOAT fAngH = D3DXToDegree( (FLOAT)atan2( fLenXZ, vDist.y ) ); // XZ평면의 길이와 y높이간의 각도를 구함. fAngH -= 90.0f; *pfAngXZ = fAngXZ; *pfAngH = fAngH; } //선분 클래스 (양 끝점은 Origin-Extent*Direction, Origin+Extent*Direction ) class Segment3 { public: Segment3( const D3DXVECTOR3& v1, const D3DXVECTOR3& v2 ); D3DXVECTOR3 Origin, Direction; float Extent; }; // oriented bound box class BBOX { public: D3DXVECTOR3 Center; float Extent[3]; D3DXVECTOR3 Axis[3]; void UpdateMartix( const D3DXVECTOR3 &vMin, const D3DXVECTOR3 &vMax, const D3DXMATRIX& matScale, const D3DXMATRIX& matRotation, const D3DXMATRIX& matWorld ); }; bool IntrSegment3Box3_Test( const Segment3& rkSegment, const BBOX& rkBox ); #if 0 // Ray와 AABB간의 충돌검출 BOOL IsTouchRayAABB( const D3DXVECTOR3 &vRayOrig, const D3DXVECTOR3 &vRayDir, const D3DXVECTOR3 &vBoxOrig, const D3DXVECTOR3 &vBoxSize ); BOOL IsTouchRayAABB2( const D3DXVECTOR3& vRayOrig, const D3DXVECTOR3& vRayDir, const D3DXVECTOR3& vBoxOrig, const D3DXVECTOR3& vBoxSize ); BOOL IsTouchRayAABB3( const D3DXVECTOR3& vRayOrig, const D3DXVECTOR3& vRayDir, const D3DXVECTOR3& vBoxOrig, const D3DXVECTOR3& vBoxSize ); BOOL IsTouchRaySphere( const D3DXVECTOR3& vRayOrig, const D3DXVECTOR3& vRayDir, const D3DXVECTOR3& vPos, float fR ); BOOL IsTouchRaySphere2( const D3DXVECTOR3& vRayOrig, const D3DXVECTOR3& vRayDir, const D3DXVECTOR3& vPos, float fR ); void CalcRay( D3DXVECTOR3 *pvRayOrig, D3DXVECTOR3 *pvRayDir, int nScrW, int nScrH, int nMouX, int nMouY, const D3DXMATRIX &mProj, const D3DXMATRIX &mView, const D3DXMATRIX *pmWorld = NULL ); void CalcFaceNormal( D3DXVECTOR3 *pNormal, const D3DXVECTOR3 &v1, const D3DXVECTOR3 &v2, const D3DXVECTOR3 &v3 ); void CalcFaceUnitNormal( D3DXVECTOR3 *pNormal, const D3DXVECTOR3 &v1, const D3DXVECTOR3 &v2, const D3DXVECTOR3 &v3 ); // XZ평면상에서의 원점을 기준으로 한 벡터의 각도 inline FLOAT xGetDegreeXZ( float x, float z ) { return D3DXToDegree( (FLOAT)atan2( x, -z ) ); } // XZ평면의 벡터길이와 y좌표간의 각도. inline FLOAT xGetDegreeH( float fLenXZ, float y ) { return D3DXToDegree( (FLOAT)atan2( fLenXZ, y ) ); } #endif // if 0 #endif
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 120 ] ] ]
5171a9b1269e87e4d41dede0d35b3b79d6097f49
fac8de123987842827a68da1b580f1361926ab67
/src/base/datatypes.h
05efb9141e1308be252566f956759427f7cf4c07
[]
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
985
h
#ifndef base_datatypes #define base_datatypes #include <string> #include <vector> #include <map> typedef unsigned char u8 ; typedef unsigned short int u16; typedef unsigned int u32; typedef unsigned __int64 u64; typedef char i8 ; typedef short int i16; typedef int i32; typedef __int64 i64; typedef float f32; typedef double f64; //typedef long double f80; typedef bool bit; typedef std::string str; #define DT_void 0x00 #define DT_bit 0x01 #define DT_u8 0x02 #define DT_u16 0x03 #define DT_u32 0x04 #define DT_u64 0x05 #define DT_i8 0x06 #define DT_i16 0x07 #define DT_i32 0x08 #define DT_i64 0x09 #define DT_f32 0x0A #define DT_f64 0x0B #define DT_f80 0x0C #define DT_str 0x0D #define DT_rec 0x0E #ifndef NULL #define NULL 0 #endif #ifndef NULL #define NULL 0 #endif #define IN #define OUT #endif
[ "uraymeiviar@bb790a93-564d-0410-8b31-212e73dc95e4" ]
[ [ [ 1, 49 ] ] ]
55b89a7d31cd20bcd7eae29b87c635254654b6f1
709cd826da3ae55945fd7036ecf872ee7cdbd82a
/Term/WildMagic2/Applications/Application2/WmlApplication.cpp
9ec204f79b99ea5553be78e960e9483b766c0691
[]
no_license
argapratama/kucgbowling
20dbaefe1596358156691e81ccceb9151b15efb0
65e40b6f33c5511bddf0fa350c1eefc647ace48a
refs/heads/master
2018-01-08T15:27:44.784437
2011-06-19T15:23:39
2011-06-19T15:23:39
36,738,655
0
0
null
null
null
null
UTF-8
C++
false
false
14,410
cpp
// Magic Software, Inc. // http://www.magic-software.com // http://www.wild-magic.com // Copyright (c) 2003. All Rights Reserved // // The Wild Magic Library (WML) source code is supplied under the terms of // the license agreement http://www.magic-software.com/License/WildMagic.pdf // and may not be copied or disclosed except in accordance with the terms of // that agreement. #include "WmlApplication.h" #include "WmlCommand.h" using namespace Wml; Application* Application::ms_pkApplication = NULL; Command* Application::ms_pkCommand = NULL; char* Application::ms_acWindowTitle = NULL; int Application::ms_iWindowID = 0; int Application::ms_iXPos = 0; int Application::ms_iYPos = 0; int Application::ms_iWidth = 0; int Application::ms_iHeight = 0; ColorRGB Application::ms_kBackgroundColor; bool Application::ms_bUseCLI; RendererPtr Application::ms_spkRenderer; CameraPtr Application::ms_spkCamera; //---------------------------------------------------------------------------- Application::Application (char* acWindowTitle, int iXPos, int iYPos, int iWidth, int iHeight, const ColorRGB& rkBackgroundColor, bool bUseCLI) { assert( ms_pkApplication == NULL ); ms_pkApplication = this; ms_acWindowTitle = acWindowTitle; ms_iXPos = iXPos; ms_iYPos = iYPos; ms_iWidth = iWidth; ms_iHeight = iHeight; ms_kBackgroundColor = rkBackgroundColor; ms_bUseCLI = bUseCLI; m_iDoRoll = 0; m_iDoYaw = 0; m_iDoPitch = 0; m_spkMotionObject = NULL; } //---------------------------------------------------------------------------- Application::~Application () { assert( ms_pkApplication != NULL ); ms_pkApplication = NULL; delete ms_pkCommand; } //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- // application callbacks //---------------------------------------------------------------------------- bool Application::OnPrecreate () { return true; } //---------------------------------------------------------------------------- bool Application::OnInitialize () { ms_spkRenderer->SetBackgroundColor(ms_kBackgroundColor); ms_spkRenderer->SetCamera(ms_spkCamera); m_bTurretActive = false; m_fTrnSpeed = 0.01f; m_fRotSpeed = 0.01f; m_bUArrowPressed = false; m_bDArrowPressed = false; m_bLArrowPressed = false; m_bRArrowPressed = false; m_bPgUpPressed = false; m_bPgDnPressed = false; m_bHomePressed = false; m_bEndPressed = false; m_fLastTime = -1.0f; m_fAccumulatedTime = 0.0f; m_fFrameRate = 0.0f; m_iClicks = 0; m_iTimer = 30; m_iMaxTimer = 30; return true; } //---------------------------------------------------------------------------- void Application::OnTerminate () { ms_spkRenderer->SetCamera(NULL); ms_spkCamera = NULL; ms_spkRenderer = NULL; m_spkMotionObject = NULL; } //---------------------------------------------------------------------------- void Application::OnMove (int iX, int iY) { if ( ms_spkRenderer ) ms_spkRenderer->Move(iX,iY); ms_iXPos = iX; ms_iYPos = iY; } //---------------------------------------------------------------------------- void Application::OnReshape (int iWidth, int iHeight) { if ( ms_spkRenderer ) ms_spkRenderer->Resize(iWidth,iHeight); ms_iWidth = iWidth; ms_iHeight = iHeight; } //---------------------------------------------------------------------------- void Application::OnDisplay () { OnIdle(); } //---------------------------------------------------------------------------- void Application::OnIdle () { } //---------------------------------------------------------------------------- void Application::OnKeyDown (unsigned char ucKey, int, int) { // quit application if the ESCAPE key is pressed if ( ucKey == KEY_ESCAPE ) RequestTermination(); } //---------------------------------------------------------------------------- void Application::OnKeyUp (unsigned char, int, int) { } //---------------------------------------------------------------------------- void Application::OnSpecialKeyDown (int iKey, int, int) { if ( !m_bTurretActive ) return; if ( iKey == KEY_LEFT_ARROW ) { m_bLArrowPressed = true; return; } if ( iKey == KEY_RIGHT_ARROW ) { m_bRArrowPressed = true; return; } if ( iKey == KEY_UP_ARROW ) { m_bUArrowPressed = true; return; } if ( iKey == KEY_DOWN_ARROW ) { m_bDArrowPressed = true; return; } if ( iKey == KEY_PAGE_UP ) { m_bPgUpPressed = true; return; } if ( iKey == KEY_PAGE_DOWN ) { m_bPgDnPressed = true; return; } if ( iKey == KEY_HOME ) { m_bHomePressed = true; return; } if ( iKey == KEY_END ) { m_bEndPressed = true; return; } if ( iKey == KEY_F1 ) { m_iDoRoll = -1; return; } else if ( iKey == KEY_F2 ) { m_iDoRoll = +1; return; } if ( iKey == KEY_F3 ) { m_iDoYaw = -1; return; } else if ( iKey == KEY_F4 ) { m_iDoYaw = 1; return; } if ( iKey == KEY_F5 ) { m_iDoPitch = -1; return; } else if ( iKey == KEY_F6 ) { m_iDoPitch = 1; return; } } //---------------------------------------------------------------------------- void Application::OnSpecialKeyUp (int iKey, int, int) { if ( !m_bTurretActive ) return; if ( iKey == KEY_LEFT_ARROW ) { m_bLArrowPressed = false; return; } if ( iKey == KEY_RIGHT_ARROW ) { m_bRArrowPressed = false; return; } if ( iKey == KEY_UP_ARROW ) { m_bUArrowPressed = false; return; } if ( iKey == KEY_DOWN_ARROW ) { m_bDArrowPressed = false; return; } if ( iKey == KEY_PAGE_UP ) { m_bPgUpPressed = false; return; } if ( iKey == KEY_PAGE_DOWN ) { m_bPgDnPressed = false; return; } if ( iKey == KEY_HOME ) { m_bHomePressed = false; return; } if ( iKey == KEY_END ) { m_bEndPressed = false; return; } if ( iKey == KEY_F1 || iKey == KEY_F2 ) { m_iDoRoll = 0; return; } if ( iKey == KEY_F3 || iKey == KEY_F4 ) { m_iDoYaw = 0; return; } if ( iKey == KEY_F5 || iKey == KEY_F6 ) { m_iDoPitch = 0; return; } } //---------------------------------------------------------------------------- void Application::OnMouseClick (int, int, int, int, unsigned int) { } //---------------------------------------------------------------------------- void Application::OnMotion (int, int, unsigned int) { } //---------------------------------------------------------------------------- void Application::OnPassiveMotion (int, int) { } //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- // turret-based camera motion //---------------------------------------------------------------------------- void Application::SetTurretAxes () { m_akAxis[0] = ms_spkCamera->GetLeft(); m_akAxis[1] = ms_spkCamera->GetUp(); m_akAxis[2] = ms_spkCamera->GetDirection(); } //---------------------------------------------------------------------------- void Application::SetTurretAxes (const Vector3f& rkLeft, const Vector3f& rkUp, const Vector3f& rkDirection) { m_akAxis[0] = rkLeft; m_akAxis[1] = rkUp; m_akAxis[2] = rkDirection; } //---------------------------------------------------------------------------- void Application::MoveForward () { Vector3f kLoc = ms_spkCamera->GetLocation(); kLoc += m_fTrnSpeed*m_akAxis[2]; ms_spkCamera->SetLocation(kLoc); ms_spkCamera->Update(); } //---------------------------------------------------------------------------- void Application::MoveBackward () { Vector3f kLoc = ms_spkCamera->GetLocation(); kLoc -= m_fTrnSpeed*m_akAxis[2]; ms_spkCamera->SetLocation(kLoc); ms_spkCamera->Update(); } //---------------------------------------------------------------------------- void Application::MoveUp () { Vector3f kLoc = ms_spkCamera->GetLocation(); kLoc += m_fTrnSpeed*m_akAxis[1]; ms_spkCamera->SetLocation(kLoc); ms_spkCamera->Update(); } //---------------------------------------------------------------------------- void Application::MoveDown () { Vector3f kLoc = ms_spkCamera->GetLocation(); kLoc -= m_fTrnSpeed*m_akAxis[1]; ms_spkCamera->SetLocation(kLoc); ms_spkCamera->Update(); } //---------------------------------------------------------------------------- void Application::TurnLeft () { Matrix3f kIncr(m_akAxis[1],m_fRotSpeed); m_akAxis[0] = kIncr*m_akAxis[0]; m_akAxis[2] = kIncr*m_akAxis[2]; Vector3f kLeft = kIncr*ms_spkCamera->GetLeft(); Vector3f kUp = kIncr*ms_spkCamera->GetUp(); Vector3f kDirection = kIncr*ms_spkCamera->GetDirection(); ms_spkCamera->SetAxes(kLeft,kUp,kDirection); ms_spkCamera->Update(); } //---------------------------------------------------------------------------- void Application::TurnRight () { Matrix3f kIncr(m_akAxis[1],-m_fRotSpeed); m_akAxis[0] = kIncr*m_akAxis[0]; m_akAxis[2] = kIncr*m_akAxis[2]; Vector3f kLeft = kIncr*ms_spkCamera->GetLeft(); Vector3f kUp = kIncr*ms_spkCamera->GetUp(); Vector3f kDirection = kIncr*ms_spkCamera->GetDirection(); ms_spkCamera->SetAxes(kLeft,kUp,kDirection); ms_spkCamera->Update(); } //---------------------------------------------------------------------------- void Application::LookUp () { Matrix3f kIncr(m_akAxis[0],-m_fRotSpeed); Vector3f kLeft = kIncr*ms_spkCamera->GetLeft(); Vector3f kUp = kIncr*ms_spkCamera->GetUp(); Vector3f kDirection = kIncr*ms_spkCamera->GetDirection(); ms_spkCamera->SetAxes(kLeft,kUp,kDirection); ms_spkCamera->Update(); } //---------------------------------------------------------------------------- void Application::LookDown () { Matrix3f kIncr(m_akAxis[0],m_fRotSpeed); Vector3f kLeft = kIncr*ms_spkCamera->GetLeft(); Vector3f kUp = kIncr*ms_spkCamera->GetUp(); Vector3f kDirection = kIncr*ms_spkCamera->GetDirection(); ms_spkCamera->SetAxes(kLeft,kUp,kDirection); ms_spkCamera->Update(); } //---------------------------------------------------------------------------- bool Application::MoveCamera () { if ( m_bUArrowPressed ) { MoveForward(); return true; } if ( m_bDArrowPressed ) { MoveBackward(); return true; } if ( m_bHomePressed ) { MoveUp(); return true; } if ( m_bEndPressed ) { MoveDown(); return true; } if ( m_bLArrowPressed ) { TurnLeft(); return true; } if ( m_bRArrowPressed ) { TurnRight(); return true; } if ( m_bPgUpPressed ) { LookUp(); return true; } if ( m_bPgDnPressed ) { LookDown(); return true; } return false; } //---------------------------------------------------------------------------- bool Application::MoveObject () { if ( !m_spkMotionObject ) return false; Matrix3f kRot, kIncr; if ( m_iDoRoll ) { kRot = m_spkMotionObject->Rotate(); kIncr.FromAxisAngle(Vector3f::UNIT_X,m_iDoRoll*m_fRotSpeed); m_spkMotionObject->Rotate() = kIncr*kRot; return true; } if ( m_iDoYaw ) { kRot = m_spkMotionObject->Rotate(); kIncr.FromAxisAngle(Vector3f::UNIT_Y,m_iDoYaw*m_fRotSpeed); m_spkMotionObject->Rotate() = kIncr*kRot; return true; } if ( m_iDoPitch ) { kRot = m_spkMotionObject->Rotate(); kIncr.FromAxisAngle(Vector3f::UNIT_Z,m_iDoPitch*m_fRotSpeed); m_spkMotionObject->Rotate() = kIncr*kRot; return true; } return false; } //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- // performance measurements //---------------------------------------------------------------------------- void Application::ResetTime () { m_fLastTime = -1.0f; } //---------------------------------------------------------------------------- void Application::MeasureTime () { // start performance measurements if ( m_fLastTime == -1.0f ) { m_fLastTime = GetTimeInSeconds(); m_fAccumulatedTime = 0.0f; m_fFrameRate = 0.0f; m_iClicks = 0; m_iTimer = m_iMaxTimer; } // measure time float fCurrentTime = GetTimeInSeconds(); float fDelta = fCurrentTime - m_fLastTime; m_fLastTime = fCurrentTime; m_fAccumulatedTime += fDelta; } //---------------------------------------------------------------------------- void Application::UpdateClicks () { m_iClicks++; } //---------------------------------------------------------------------------- void Application::DrawFrameRate (int iX, int iY, const ColorRGB& rkColor) { if ( --m_iTimer == 0 ) { if ( m_fAccumulatedTime > 0.0f ) m_fFrameRate = m_iClicks/m_fAccumulatedTime; else m_fFrameRate = 0.0f; m_iTimer = m_iMaxTimer; } char acMessage[256]; sprintf(acMessage,"fps: %.1lf",(double)m_fFrameRate); ms_spkRenderer->Draw(iX,iY,rkColor,acMessage); } //----------------------------------------------------------------------------
[ [ [ 1, 544 ] ] ]
eca494c47ea62ec61b14dacc96bac57cb9767887
a9cf0c2a8904e42a206c3575b244f8b0850dd7af
/gui/console/media.cpp
26dfb3f415c5034a127c0fdb9d597675fe790cb6
[]
no_license
jayrulez/ourlib
3a38751ccb6a38785d4df6f508daeff35ccfd09f
e4727d638f2d69ea29114dc82b9687ea1fd17a2d
refs/heads/master
2020-04-22T15:42:00.891099
2010-01-06T20:00:17
2010-01-06T20:00:17
40,554,487
0
0
null
null
null
null
UTF-8
C++
false
false
448
cpp
/* @Group: BSC2D @Group Members: <ul> <li>Robert Campbell: 0701334</li> <li>Audley Gordon: 0802218</li> <li>Dale McFarlane: 0801042</li> <li>Dyonne Duberry: 0802189</li> <li>Xavier Lowe: 0802488</li> </ul> @ */ #include <iostream> #include <windows.h> #include <mmsystem.h> #include "media.h" media::media() { } media::~media() { } void media::play(char* f) { PlaySound(f,NULL,SND_FILENAME|SND_ASYNC); }
[ [ [ 1, 27 ] ] ]
d0ffd965ca20d27bbc4e01bdad93190922df2769
93176e72508a8b04769ee55bece71095d814ec38
/Utilities/BGL/boost/math/tools/config.hpp
3fbf288bca887261beb5f22742d20e3172695863
[]
no_license
inglada/OTB
a0171a19be1428c0f3654c48fe5c35442934cf13
8b6d8a7df9d54c2b13189e00ba8fcb070e78e916
refs/heads/master
2021-01-19T09:23:47.919676
2011-06-29T17:29:21
2011-06-29T17:29:21
1,982,100
4
5
null
null
null
null
UTF-8
C++
false
false
9,574
hpp
// Copyright (c) 2006-7 John Maddock // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_MATH_TOOLS_CONFIG_HPP #define BOOST_MATH_TOOLS_CONFIG_HPP #ifdef _MSC_VER #pragma once #endif #include <boost/cstdint.hpp> // for boost::uintmax_t #include <boost/config.hpp> #include <boost/detail/workaround.hpp> #include <algorithm> // for min and max #include <boost/config/no_tr1/cmath.hpp> #include <climits> #if (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)) # include <math.h> #endif #include <boost/math/tools/user.hpp> #include <boost/math/special_functions/detail/round_fwd.hpp> #if defined(__CYGWIN__) || defined(__FreeBSD__) || defined(__NetBSD__) \ || defined(__hppa) || defined(__NO_LONG_DOUBLE_MATH) # define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS #endif #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582)) // // Borland post 5.8.2 uses Dinkumware's std C lib which // doesn't have true long double precision. Earlier // versions are problematic too: // # define BOOST_MATH_NO_REAL_CONCEPT_TESTS # define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS # define BOOST_MATH_CONTROL_FP _control87(MCW_EM,MCW_EM) # include <float.h> #endif #if (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)) && ((LDBL_MANT_DIG == 106) || (__LDBL_MANT_DIG__ == 106)) // // Darwin's rather strange "double double" is rather hard to // support, it should be possible given enough effort though... // # define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS #endif #if defined(unix) && defined(__INTEL_COMPILER) && (__INTEL_COMPILER <= 1000) // // Intel compiler prior to version 10 has sporadic problems // calling the long double overloads of the std lib math functions: // calling ::powl is OK, but std::pow(long double, long double) // may segfault depending upon the value of the arguments passed // and the specific Linux distribution. // // We'll be conservative and disable long double support for this compiler. // // Comment out this #define and try building the tests to determine whether // your Intel compiler version has this issue or not. // # define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS #endif #if defined(unix) && defined(__INTEL_COMPILER) // // Intel compiler has sporadic issues compiling std::fpclassify depending on // the exact OS version used. Use our own code for this as we know it works // well on Intel processors: // #define BOOST_MATH_DISABLE_STD_FPCLASSIFY #endif #if defined(BOOST_MSVC) && !defined(_WIN32_WCE) // Better safe than sorry, our tests don't support hardware exceptions: # define BOOST_MATH_CONTROL_FP _control87(MCW_EM,MCW_EM) #endif #ifdef __IBMCPP__ # define BOOST_MATH_NO_DEDUCED_FUNCTION_POINTERS #endif #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)) # define BOOST_MATH_USE_C99 #endif #if (defined(__hpux) && !defined(__hppa)) # define BOOST_MATH_USE_C99 #endif #if defined(__GNUC__) && defined(_GLIBCXX_USE_C99) # define BOOST_MATH_USE_C99 #endif #if defined(__CYGWIN__) || defined(__HP_aCC) || defined(BOOST_INTEL) \ || defined(BOOST_NO_NATIVE_LONG_DOUBLE_FP_CLASSIFY) \ || (defined(__GNUC__) && !defined(BOOST_MATH_USE_C99)) # define BOOST_MATH_NO_NATIVE_LONG_DOUBLE_FP_CLASSIFY #endif #if defined(BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS) || BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590) # include "boost/type.hpp" # include "boost/non_type.hpp" # define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(t) boost::type<t>* = 0 # define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(t) boost::type<t>* # define BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE(t, v) boost::non_type<t, v>* = 0 # define BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v) boost::non_type<t, v>* # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(t) \ , BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(t) # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(t) \ , BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(t) # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(t, v) \ , BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE(t, v) # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v) \ , BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v) #else // no workaround needed: expand to nothing # define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(t) # define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(t) # define BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE(t, v) # define BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v) # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(t) # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(t) # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(t, v) # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v) #endif // defined BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS #if defined(__SUNPRO_CC) || defined(__hppa) || defined(__GNUC__) // Sun's compiler emits a hard error if a constant underflows, // as does aCC on PA-RISC, while gcc issues a large number of warnings: # define BOOST_MATH_SMALL_CONSTANT(x) 0 #else # define BOOST_MATH_SMALL_CONSTANT(x) x #endif #if BOOST_WORKAROUND(BOOST_MSVC, < 1400) // // Define if constants too large for a float cause "bad" // values to be stored in the data, rather than infinity // or a suitably large value. // # define BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS #endif // // Tune performance options for specific compilers: // #ifdef BOOST_MSVC # define BOOST_MATH_POLY_METHOD 3 #elif defined(BOOST_INTEL) # define BOOST_MATH_POLY_METHOD 2 # define BOOST_MATH_RATIONAL_METHOD 2 #elif defined(__GNUC__) # define BOOST_MATH_POLY_METHOD 3 # define BOOST_MATH_RATIONAL_METHOD 3 # define BOOST_MATH_INT_TABLE_TYPE(RT, IT) RT # define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##.0L #endif #if defined(BOOST_NO_LONG_LONG) && !defined(BOOST_MATH_INT_TABLE_TYPE) # define BOOST_MATH_INT_TABLE_TYPE(RT, IT) RT # define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##.0L #endif // // The maximum order of polynomial that will be evaluated // via an unrolled specialisation: // #ifndef BOOST_MATH_MAX_POLY_ORDER # define BOOST_MATH_MAX_POLY_ORDER 17 #endif // // Set the method used to evaluate polynomials and rationals: // #ifndef BOOST_MATH_POLY_METHOD # define BOOST_MATH_POLY_METHOD 1 #endif #ifndef BOOST_MATH_RATIONAL_METHOD # define BOOST_MATH_RATIONAL_METHOD 0 #endif // // decide whether to store constants as integers or reals: // #ifndef BOOST_MATH_INT_TABLE_TYPE # define BOOST_MATH_INT_TABLE_TYPE(RT, IT) IT #endif #ifndef BOOST_MATH_INT_VALUE_SUFFIX # define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##SUF #endif // // Helper macro for controlling the FP behaviour: // #ifndef BOOST_MATH_CONTROL_FP # define BOOST_MATH_CONTROL_FP #endif // // Helper macro for using statements: // #define BOOST_MATH_STD_USING \ using std::abs;\ using std::acos;\ using std::cos;\ using std::fmod;\ using std::modf;\ using std::tan;\ using std::asin;\ using std::cosh;\ using std::frexp;\ using std::pow;\ using std::tanh;\ using std::atan;\ using std::exp;\ using std::ldexp;\ using std::sin;\ using std::atan2;\ using std::fabs;\ using std::log;\ using std::sinh;\ using std::ceil;\ using std::floor;\ using std::log10;\ using std::sqrt;\ using boost::math::round;\ using boost::math::iround;\ using boost::math::lround;\ using boost::math::trunc;\ using boost::math::itrunc;\ using boost::math::ltrunc;\ using boost::math::modf; namespace boost{ namespace math{ namespace tools { template <class T> inline T max BOOST_PREVENT_MACRO_SUBSTITUTION(T a, T b, T c) { return (std::max)((std::max)(a, b), c); } template <class T> inline T max BOOST_PREVENT_MACRO_SUBSTITUTION(T a, T b, T c, T d) { return (std::max)((std::max)(a, b), (std::max)(c, d)); } } // namespace tools }} // namespace boost namespace math #if (defined(__linux__) && !defined(__UCLIBC__)) || defined(__QNX__) || defined(__IBMCPP__) #include <fenv.h> namespace boost{ namespace math{ namespace detail { struct fpu_guard { fpu_guard() { fegetexceptflag(&m_flags, FE_ALL_EXCEPT); feclearexcept(FE_ALL_EXCEPT); } ~fpu_guard() { fesetexceptflag(&m_flags, FE_ALL_EXCEPT); } private: fexcept_t m_flags; }; } // namespace detail }} // namespaces # define BOOST_FPU_EXCEPTION_GUARD boost::math::detail::fpu_guard local_guard_object; # define BOOST_MATH_INSTRUMENT_FPU do{ fexcept_t cpu_flags; fegetexceptflag(&cpu_flags, FE_ALL_EXCEPT); BOOST_MATH_INSTRUMENT_VARIABLE(cpu_flags); } while(0); #else // All other platforms. # define BOOST_FPU_EXCEPTION_GUARD # define BOOST_MATH_INSTRUMENT_FPU #endif #ifdef BOOST_MATH_INSTRUMENT #define BOOST_MATH_INSTRUMENT_CODE(x) \ std::cout << std::setprecision(35) << __FILE__ << ":" << __LINE__ << " " << x << std::endl; #define BOOST_MATH_INSTRUMENT_VARIABLE(name) BOOST_MATH_INSTRUMENT_CODE(BOOST_STRINGIZE(name) << " = " << name) #else #define BOOST_MATH_INSTRUMENT_CODE(x) #define BOOST_MATH_INSTRUMENT_VARIABLE(name) #endif #endif // BOOST_MATH_TOOLS_CONFIG_HPP
[ [ [ 1, 304 ] ] ]
3adc482c4661011ff60aa64d8582a367f64a3a37
3ea8b8900d21d0113209fd02bd462310bd0fce83
/libvorbis.cpp
4060a665860cfe0981efcf767d207c577646ed2b
[]
no_license
LazurasLong/bgmlib
56958b7dffd98d78f99466ce37c4abaddc7da5b1
a9d557ea76a383fae54dc3729aaea455c258777a
refs/heads/master
2022-12-04T02:58:36.450986
2011-08-16T17:44:46
2011-08-16T17:44:46
null
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
14,976
cpp
// Music Room BGM Library // ---------------------- // libvorbis.cpp - Ogg Vorbis stuff // ---------------------- // "©" Nmlgc, 2011 #include "platform.h" #include "infostruct.h" #include "packmethod.h" #include "ui.h" #include "libvorbis.h" #include <FXFile.h> #include <vorbis/vorbisenc.h> const int OV_BLOCK = 8192; // Vorbis Stuff // ------------ size_t FXFile_read(void* _DstBuf, size_t _Dummy_, size_t _Count, FXFile* _File) { return _File->readBlock(_DstBuf, _Count); } int FXFile_seek(FXFile* _File, ogg_int64_t off, int whence) { return _File->position(off, whence); } int FXFile_close(FXFile* _File) { return _File->close(); } int FXFile_tell(FXFile* _File) { return _File->position(); } // ------------ bool DumpDecrypt(GameInfo* GI, TrackInfo* TI, const FXString& OutFN) { bool Ret = false; FXFile Src; if(!GI->OpenBGMFile(Src, TI)) return Ret; Ret = GI->PM->Dump(GI, Src, TI->GetStart(), TI->FS, OutFN); Src.close(); return Ret; } // Virtual file // ------------ VFile::VFile() { Buf = NULL; Size = Read = Write = 0; } VFile::VFile(const ulong& _Size) { Create(_Size); } void VFile::Create(const ulong& _Size) { Size = _Size; Read = Write = 0; Buf = (char*)malloc(Size); } void VFile::Clear() { Size = Read = Write = 0; free(Buf); Buf = NULL; } VFile::~VFile() { Clear(); } size_t VFile_read(void* _DstBuf, size_t _Dummy_, size_t _Count, VFile* VF) { if(!VF->Buf) return 0; size_t Rem = VF->Write - VF->Read; if(Rem < _Count) _Count = Rem; memcpy(_DstBuf, VF->Buf + VF->Read, _Count); VF->Read += _Count; return _Count; } int VFile_seek(VFile* VF, ogg_int64_t off, int whence) { switch(whence) { case SEEK_SET: VF->Read = off; return 0; case SEEK_CUR: VF->Read += off; return 0; case SEEK_END: VF->Read = VF->Size - off; return 0; default: return -1; } } int VFile_tell(VFile* VF) { return VF->Read; } // ------------ // Encoding state // -------------- OggVorbis_EncState::OggVorbis_EncState() { out = NULL; memset(&stream_out, 0, sizeof(ogg_stream_state)); vorbis_info_init(&vi); memset(&vd, 0, sizeof(vorbis_dsp_state)); memset(&vb, 0, sizeof(vorbis_block)); } bool OggVorbis_EncState::setup(FXFile* _out, const float& freq, const float& quality) { int ret; out = _out; vorbis_info_init(&vi); ret = vorbis_encode_init_vbr(&vi, 2, freq, quality); if(ret) return false; ret = vorbis_analysis_init(&vd,&vi); ret = vorbis_block_init(&vd,&vb); return true; } uint OggVorbis_EncState::write_headers() { vorbis_comment vc; uint ret = 0; vorbis_comment_init(&vc); ret = write_headers(&vc); vorbis_comment_clear(&vc); return ret; } uint OggVorbis_EncState::write_headers(vorbis_comment* vc) { uint ret = 0; ogg_page og; ogg_packet header; ogg_packet header_comm; ogg_packet header_code; if(!vc && !stream_out.body_data) return 0; vorbis_analysis_headerout(&vd, vc, &header,&header_comm,&header_code); ogg_stream_packetin(&stream_out,&header); // automatically placed in its own page ogg_stream_packetin(&stream_out,&header_comm); ogg_stream_packetin(&stream_out,&header_code); // This ensures the actual audio data will start on a new page, as per spec while(ogg_stream_flush(&stream_out,&og)) { out->writeBlock(og.header,og.header_len); out->writeBlock(og.body,og.body_len); ret += og.header_len, og.body_len; } return ret; } uint OggVorbis_EncState::new_stream(FXFile* out, const float& freq, const float& quality, long serialno, vorbis_comment* vc) { ogg_stream_clear(&stream_out); clear(); setup(out, freq, quality); ogg_stream_init(&stream_out, serialno); return write_headers(vc); } uint OggVorbis_EncState::encode_pcm(char* buf, const int& size) { ogg_packet op; float **buffer; long i; uint ret = 0; // expose the buffer to submit data buffer=vorbis_analysis_buffer(&vd,size/4); // uninterleave samples for(i=0;i<size/4;i++) { buffer[0][i]=((buf[i*4+1]<<8)| (0x00ff&(int)buf[i*4]))/32768.f; buffer[1][i]=((buf[i*4+3]<<8)| (0x00ff&(int)buf[i*4+2]))/32768.f; } // tell the library how much we actually submitted vorbis_analysis_wrote(&vd,i); if(!stream_out.body_data) return 0; /* vorbis does some data preanalysis, then divvies up blocks for more involved (potentially parallel) processing. Get a single block for encoding now */ while(vorbis_analysis_blockout(&vd,&vb)==1) { // analysis, assume we want to use bitrate management vorbis_analysis(&vb,NULL); vorbis_bitrate_addblock(&vb); while(vorbis_bitrate_flushpacket(&vd,&op)) { ret += op.bytes; ogg_write_packet(*out, &stream_out, &op); } } return ret; } bool OggVorbis_EncState::encode_file(FXFile& in, const ulong& bytes, char* buf, const ulong& bufsize, volatile FXulong& d, volatile bool* StopReq) { ulong Rem = bytes; while(Rem > 0 && !(*StopReq)) { int Read = MIN(bufsize, Rem); in.readBlock(buf, Read); Rem -= Read; encode_pcm(buf, Read); d += Read; } // Finalize if(!(*StopReq)) encode_pcm(NULL, 0); return !(*StopReq); } void OggVorbis_EncState::clear() { vorbis_block_clear(&vb); vorbis_dsp_clear(&vd); vorbis_info_clear(&vi); } OggVorbis_EncState::~OggVorbis_EncState() { clear(); } // -------------- #ifdef SUPPORT_VORBIS_PM // Decodes [Size] bytes from [vf] into [buffer]. Loops according to the info in [TI]. ogg_int64_t ov_read_bgm(OggVorbis_File* vf, char* buffer, const ulong& size, TrackInfo* TI) { int Link; long Ret = 1; long Rem = size; ogg_int64_t Cur = ov_pcm_tell(vf); ulong L, E; TI->GetPos(FMT_SAMPLE, false, NULL, &L, &E); while(Rem > 0) { Ret = ov_read(vf, buffer + size - Rem, Rem, 0, 2, 1, &Link); Cur = ov_pcm_tell(vf); if(Cur >= E) { ov_pcm_seek_lap(vf, L != E ? L : 0); Ret -= (Cur - E) * 4; Cur = ov_pcm_tell(vf); } Rem -= Ret; } return Cur; } int ov_bitstream_seek(OggVorbis_File* vf, ogg_int64_t pos, bool seek_to_header) { ogg_int64_t seek; int link; char Temp[4]; ogg_int64_t total=ov_pcm_total(vf,-1); // which bitstream section does this pcm offset occur in? for(link=vf->links-1;link>=0;link--) { total-=vf->pcmlengths[link*2+1]; if(pos>=total)break; } if(seek_to_header) seek = vf->offsets[link]; else seek = vf->dataoffsets[link]; ov_raw_seek(vf, seek); ov_read(vf, Temp, 4, 0, 2, 1, &link); // Initialize bitstream to avoid crashes ov_raw_seek(vf, seek); return link; } #endif // Ogg packet copy functions // =============== void vorbis_write_headers(FXFile& out, ogg_stream_state* os, vorbis_dsp_state* vd, vorbis_comment* vc) { ogg_page og; ogg_packet header; ogg_packet header_comm; ogg_packet header_code; vorbis_analysis_headerout(vd, vc, &header,&header_comm,&header_code); ogg_stream_packetin(os,&header); // automatically placed in its own page ogg_stream_packetin(os,&header_comm); ogg_stream_packetin(os,&header_code); // This ensures the actual audio data will start on a new page, as per spec while(ogg_stream_flush(os,&og)) { out.writeBlock(og.header,og.header_len); out.writeBlock(og.body,og.body_len); } } void vorbis_write_headers(FXFile& out, ogg_stream_state* os, vorbis_info* vi, vorbis_comment* vc) { vorbis_dsp_state vd; vorbis_analysis_init(&vd, vi); vorbis_write_headers(out, os, &vd, vc); vorbis_dsp_clear(&vd); } void vorbis_write_headers(FXFile& out, ogg_stream_state* os, vorbis_info* vi, ogg_packet* header, vorbis_comment* vc, ogg_packet* header_code) { ogg_page og; ogg_packet dump[2]; ogg_packet header_comm; vorbis_dsp_state vd; // Because of lolvorbis "we declare everything _we_ see no public use for static", // we have to needlessly include [vi] as parameter, and allocate two fake packets // just to make it create that one comment packet. Great. vorbis_analysis_init(&vd, vi); vorbis_analysis_headerout(&vd, vc, &dump[0],&header_comm,&dump[1]); ogg_stream_packetin(os,header); // automatically placed in its own page ogg_stream_packetin(os,&header_comm); ogg_stream_packetin(os,header_code); // This ensures the actual audio data will start on a new page, as per spec while(ogg_stream_flush(os,&og)) { out.writeBlock(og.header,og.header_len); out.writeBlock(og.body,og.body_len); } vorbis_dsp_clear(&vd); } // Adapted from vcut.c // ------- typedef struct { int length; unsigned char *packet; } vcut_packet; // Copies [packet] to [p] static bool save_packet(vcut_packet* p, ogg_packet *packet) { p->length = packet->bytes; p->packet = (unsigned char*)realloc(p->packet, p->length); if(!p->packet) return false; memcpy(p->packet, packet->packet, p->length); return true; } // Returns... packet sample count... or something like that static long get_blocksize(vorbis_info* vi, ogg_packet *op, int& prevW) { int size = vorbis_packet_blocksize(vi, op); int ret = (size+prevW)/4; prevW = size; return ret; } // Reads an arbitrary amount of bytes from [file_in] into [sync_in]. // Return value: number of read bytes int ogg_update_sync(FXFile& file_in, ogg_sync_state* sync_in) { static const ulong Read = 4096; char *buffer = ogg_sync_buffer(sync_in, Read); int bytes = file_in.readBlock(buffer, Read); ogg_sync_wrote(sync_in, bytes); return bytes; } // Writes pages to the given file, or discards them if file is NULL. bool write_pages_to_file(ogg_stream_state *stream, FXFile& file, int flush) { ogg_page page; if(flush) { while(ogg_stream_flush(stream, &page)) { if(!file.isOpen()) continue; if(file.writeBlock(page.header,page.header_len) != page.header_len) return false; if(file.writeBlock(page.body,page.body_len) != page.body_len) return false; } } else { while(ogg_stream_pageout(stream, &page)) { if(!file.isOpen()) continue; if(file.writeBlock(page.header,page.header_len) != page.header_len) return false; if(file.writeBlock(page.body,page.body_len) != page.body_len) return false; } } return true; } // Submits [packet] to [stream_out], and writes filled pages to [out]. bool ogg_write_packet(FXFile& out, ogg_stream_state* stream_out, ogg_packet *packet) { int flush; /* According to the Vorbis I spec, we need to flush the stream after: * - the first (BOS) header packet * - the last header packet (packet #2) * - the second audio packet (packet #4), if the stream starts at * a non-zero granulepos */ flush = (stream_out->packetno == 2) || (stream_out->packetno == 4 && packet->granulepos != -1) || packet->b_o_s || packet->e_o_s; ogg_stream_packetin(stream_out, packet); if(!write_pages_to_file(stream_out, out, flush)) { BGMLib::UI_Stat_Safe("\nCouldn't write packet to output file\n"); return false; } return true; } // Copies audio packets from [file_in] to [file_out]. // Stops once a given number of samples, or the end of the input stream is reached ogg_int64_t ogg_packetcopy(FXFile& file_out, ogg_stream_state* stream_out, FXFile& file_in, ogg_stream_state* stream_in, ogg_sync_state* sync_in, vorbis_info* info_in, ogg_int64_t sample_end, ogg_int64_t sample_start) { bool eos = false; bool write = (sample_start == 0); ogg_page og; ogg_packet op; ogg_int64_t granulepos = 0; vcut_packet last_packet; // Last packet before [sample_start] // I don't know anything about what this variable is supposed to be, but it needs to be in this scope and it needs to be initialized with zero int prevW = 0; if(sample_end == 0) return 0; if(sample_end < 0) sample_end = 0x7fffffffffffffff + sample_end; memset(&last_packet, 0, sizeof(vcut_packet)); while(!eos) { int result=ogg_sync_pageout(sync_in,&og); if(result<0) { // missing or corrupt data at this page position BGMLib::UI_Stat_Safe("\nCorrupt or missing data in bitstream; continuing...\n"); } else if(result != 0) { // Init [stream_in] if necessary if(stream_in->body_data == NULL) { ogg_stream_init(stream_in, ogg_page_serialno(&og)); } result = ogg_stream_pagein(stream_in,&og); // If this fails, we have a broken Ogg, so we return to limit the damage if(result<0) eos = true; while(!eos) { result=ogg_stream_packetout(stream_in,&op); if(result<=0)break; // need more data // Don't copy headers, we're always submitting them ourselves if(op.packetno < 3) continue; if(info_in) { long new_gp = get_blocksize(info_in, &op, prevW); if(new_gp > -1 && stream_in->packetno > 4) granulepos += new_gp; if(!write) { if(granulepos >= sample_start) { // Write out last packet ogg_packet lp; lp.b_o_s = 0; lp.e_o_s = 0; lp.granulepos = 0; lp.packetno = stream_out->packetno; lp.bytes = last_packet.length; lp.packet = last_packet.packet; ogg_write_packet(file_out, stream_out, &lp); write = true; } else { // Might be the last packet before [sample_start]. Save it save_packet(&last_packet, &op); } } if(sample_start != 0 && write) { // If the packet supplies a granulepos value, don't overwrite it! if(op.granulepos == -1) op.granulepos = granulepos; op.granulepos -= sample_start; } if((granulepos - sample_start) > sample_end) { op.granulepos = sample_end; op.e_o_s = 1; } } if(op.e_o_s) eos = write = true; if(write) ogg_write_packet(file_out, stream_out, &op); } } else if(!eos) eos = ogg_update_sync(file_in, sync_in) == 0; } SAFE_FREE(last_packet.packet); return granulepos; } ogg_int64_t ogg_packetcopy(FXFile& file_out, ogg_stream_state* stream_out, OggVorbis_File* ov_in, ogg_int64_t sample_end, ogg_int64_t sample_start) { return ogg_packetcopy(file_out, stream_out, *((FXFile*)ov_in->datasource), &ov_in->os, &ov_in->oy, ov_in->vi, sample_end, sample_start); } // ------- // Quality to bitrate mapping. Adapted from vorbisenc.c. // C++ lesson #?: Too much static enforcement can piss off coders, because it forces them to copy stuff! // ------- const double rate_mapping_44_stereo[12]= { 22500.,32000.,40000.,48000.,56000.,64000., 80000.,96000.,112000.,128000.,160000.,250001. }; float vorbis_quality_to_bitrate(const float& q) { float ds = 0.0, _is; int is = 0.0; ds =modf(q, &_is); if(ds < 0) {is = _is; ds = 1.0+ds;} else {is = _is+1;} return((rate_mapping_44_stereo[is]*(1.-ds)+rate_mapping_44_stereo[is+1]*ds)*2.); } // ------- // ===============
[ [ [ 1, 584 ] ] ]