blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
9
125
content_id
stringlengths
40
40
detected_licenses
sequencelengths
0
4
license_type
stringclasses
2 values
repo_name
stringlengths
12
47
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
1 value
visit_date
stringlengths
19
19
revision_date
stringlengths
19
19
committer_date
stringlengths
19
19
github_id
int64
178k
175M
star_events_count
int64
0
27
fork_events_count
int64
0
9
gha_license_id
null
gha_event_created_at
stringclasses
1 value
gha_created_at
stringclasses
1 value
gha_language
null
src_encoding
stringclasses
5 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
1 class
length_bytes
int64
165
115k
extension
stringclasses
7 values
content
stringlengths
165
115k
authors
sequencelengths
1
4
author_lines
sequencelengths
1
4
ee314adc625320f5d9816b1570c675c1fe31b614
47f89380f778b6ee8311678e48970ea710e8c1a8
/atask/Repair.h
6b911bd6b6c802d679fbd160e8cb3032f8f21c47
[]
no_license
hoijui/E323AI
f53a0fb388b67557fc92f38835343a85ef01135a
c4fcac72b77cff352350326c01ecab2d0ba9b388
refs/heads/master
2021-01-17 23:26:30
2010-12-17 00:35:34
2010-12-17 00:35:34
358,032
0
0
null
null
null
null
UTF-8
C++
false
false
595
h
#ifndef E323_TASKREPAIR_H #define E323_TASKREPAIR_H #include "../ATask.h" class UnitType; struct RepairTask: public ATask { RepairTask(AIClasses* _ai): ATask(_ai) { t = TASK_REPAIR; } RepairTask(AIClasses* _ai, int target, CGroup& group); /* build type to string */ static std::map<buildType, std::string> buildStr; bool repairing; int target; /* overloaded */ void onUpdate(); /* overloaded */ bool onValidate(); /* overloaded */ void toStream(std::ostream& out) const; /* overloaded */ void onUnitDestroyed(int uid, int attacker); }; #endif
[ "slspam@land.ru" ]
[ [ [ 1, 29 ] ] ]
549af41db9a65d7fe1acf52e5054a2bf629b70d4
21da454a8f032d6ad63ca9460656c1e04440310e
/test/utest/StringTest.cpp
85fb41c510728e6ec167722582db6d8c20583906
[]
no_license
merezhang/wcpp
d9879ffb103513a6b58560102ec565b9dc5855dd
e22eb48ea2dd9eda5cd437960dd95074774b70b0
refs/heads/master
2021-01-10 06:29:42
2009-08-31 09:20:31
2009-08-31 09:20:31
46,339,619
0
0
null
null
null
null
UTF-8
C++
false
false
3,030
cpp
#include "StringTest.h" #include <wcpp/lang/wscUUID.h> #include <wcpp/lang/wscSystem.h> #include <wcpp/lang/wscLong.h> #include <wcpp/lang/wscThrowable.h> StringTest::StringTest(void) { } StringTest::~StringTest(void) { } ws_result StringTest::doTest(void) { trace( "========================================\n" ); trace( "case:StringTest - begin\n" ); test_wsString(); test_wsLong_ToString(); test_wscUUID_ToString(); trace( "case:StringTest - end\n" ); trace( "========================================\n" ); return ws_result( WS_RLT_SUCCESS ); } void StringTest::test_wscUUID_ToString(void) { trace( " -------------------------------- \n" ); trace( "func:test_wscUUID_ToString - begin\n" ); { ws_ptr<wsiString> str1, str2; wscUUID::ToString( wsiObject::sIID.uuid, &str1 ); ws_uuid uuid; wscUUID::ParseUUID( str1, uuid ); wscUUID::ToString( uuid, &str2 ); trace( "wsiObject::sIID : " ); trace( "{3F45A92B-A7D5-4d93-946C-373E56A8C17B}" ); trace( "\n" ); trace( "wsiObject::sIID ToString : " ); trace( str1->GetBuffer() ); trace( "\n" ); trace( "wsiObject::sIID ParseUUID : " ); trace( str2->GetBuffer() ); trace( "\n" ); } ws_ptr<wsiString> str1,str2; wscUUID::ToString( wsiSystem::sIID.uuid, &str1 ); ws_uuid uuid; wscUUID::ParseUUID( str2, uuid ); wscUUID::ToString( uuid, &str2 ); trace( "wsiSystem::sIID : " ); trace( "{FAC4AD98-7554-4561-AF17-9A5ADB66AD30}" ); trace( "\n" ); trace( "wsiSystem::sIID ToString : " ); trace( str1->GetBuffer() ); trace( "\n" ); trace( "wsiSystem::sIID ParseUUID : " ); trace( str2->GetBuffer() ); trace( "\n" ); trace( "func:test_wscUUID_ToString - end\n" ); trace( " -------------------------------- \n" ); } void StringTest::test_wsLong_ToString(void) { trace( " -------------------------------- \n" ); trace( "func:test_wsLong_ToString - begin\n" ); const int len = 8; ws_long values[len] = { -1, 0, 1, 2147483647, -2147483647, 2147483647, // -2147483648, }; ws_ptr<wsiString> str; trace( "ws_long [wsString]\n" ); for (int i=0; i<len; i++) { wscLong::ToString( values[i], &str ); trace( values[i] ); trace( " [" ); trace( str->GetBuffer() ); trace( "]\n" ); } trace( "func:test_wsLong_ToString - end\n" ); trace( " -------------------------------- \n" ); } void StringTest::test_wsString(void) { trace( " -------------------------------- \n" ); trace( "func:test_wsString - begin\n" ); ws_str str1; ws_str str2( static_cast<wsiString*>(WS_NULL) ); ws_str str3( "" ); ws_str str4( "hello" ); str1 = str4; str2 = str4; str3 = str4; str4 = ""; str3 = str4; str4.SetString( 0, 0 ); str3 = "abcdefg hijk lmn opq rst uvw xyz"; str4 = "hp"; trace( "func:test_wsString - end\n" ); trace( " -------------------------------- \n" ); }
[ "xukun0217@98f29a9a-77f1-11de-91f8-ab615253d9e8" ]
[ [ [ 1, 132 ] ] ]
ca0c3b13465618bea0dfd72c097003afb2d6d543
dae66863ac441ab98adbd2d6dc2cabece7ba90be
/examples/flexrun/ASWorkFlexRun.h
aad3385447c35be6ad42d6653b4001fb392c9140
[]
no_license
bitcrystal/flexcppbridge
2485e360f47f8d8d124e1d7af5237f7e30dd1980
474c17cfa271a9d260be6afb2496785e69e72ead
refs/heads/master
2021-01-10 14:14:30
2008-11-11 06:11:34
2008-11-11 06:11:34
48,993,836
0
0
null
null
null
null
UTF-8
C++
false
false
1,045
h
/* * The contents of this file are subject to the Mozilla Public License Version * 1.1 (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.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is the Flex C++ Bridge. * * The Initial Developer of the Original Code is * Anirudh Sasikumar (http://anirudhs.chaosnet.org/). * Portions created by the Initial Developer are Copyright (C) 2008 * the Initial Developer. All Rights Reserved. * * Contributor(s): * */ #pragma once #include "aswork.h" class CASWorkFlexRun : public CASWork { protected: virtual void Worker(); public: CASWorkFlexRun(void); virtual ~CASWorkFlexRun(void); virtual CASWork* Clone(); };
[ "anirudhsasikumar@1c1c0844-4f48-0410-9872-0bebc774e022" ]
[ [ [ 1, 37 ] ] ]
c4ab3dfaef1a8239e53b2ee0d4b5f79eeff19733
4e8581b6eaaabdd58b1151201d64b45c7147dac7
/src/Direction.h
4222efa696a82a056182af970d0fbd7670521d4c
[]
no_license
charmingbrew/bioinformatics-mscd-2011
c4a390bf25d2197d4e912d7976619cb02c666587
04d81d0f05001d3ed82911459cff6dddb3c7f252
refs/heads/master
2020-05-09 12:56:08
2011-05-17 05:55:14
2011-05-17 05:55:14
33,334,714
0
1
null
null
null
null
UTF-8
C++
false
false
1,025
h
class Node; /** * @file Direction.h * @class Direction * @brief Directions in a guide tree node. * A direction contains a direction (as in left * or right) OR a direction. * A direction can only have three states: * -# Empty: A node or a sequence can be placed. * -# Sequence: Only A sequence can be contained. * -# Node: Only a branch down the tree. * Never can it have both a sequence and a branch. * These should members should be called from the * Node Object. */ #ifndef _DIRECTION_H #define _DIRECTION_H #include "Sequence.h" class Direction { private: Node * next; Sequence * seq; public: Direction(); Direction(Sequence *seq); Direction(Node *n); Sequence *GetSequence(); void SetSequence(Sequence *s); Node *GetNode(); void SetNextNode(Node *next); void SetScore(); /// Checks for an empty Direction Object bool isOpen(); }; #endif // _DIRECTION_H
[ "jnnyboy570@gmail.com@e9cc6749-363d-4b58-5071-845f21bc09f4", "millardfillmoreesquire@e9cc6749-363d-4b58-5071-845f21bc09f4" ]
[ [ [ 1, 2 ], [ 4, 39 ] ], [ [ 3, 3 ] ] ]
e3d9c3f1e076ae554af9d032aa9628c1aa5df376
0f40e36dc65b58cc3c04022cf215c77ae31965a8
/src/apps/vis/writer/vis_writer_factory.cpp
f17a2d9662492c70428061ca51440dccfd7d2525
[ "MIT", "BSD-3-Clause" ]
permissive
venkatarajasekhar/shawn-1
08e6cd4cf9f39a8962c1514aa17b294565e849f8
d36c90dd88f8460e89731c873bb71fb97da85e82
refs/heads/master
2020-06-26 18:19:01
2010-10-26 17:40:48
2010-10-26 17:40:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,323
cpp
/************************************************************************ ** This file is part of the network simulator Shawn. ** ** Copyright (C) 2004-2007 by the SwarmNet (www.swarmnet.de) project ** ** Shawn is free software; you can redistribute it and/or modify it ** ** under the terms of the BSD License. Refer to the shawn-licence.txt ** ** file in the root of the Shawn source tree for further details. ** ************************************************************************/ #include "../buildfiles/_apps_enable_cmake.h" #ifdef ENABLE_VIS #include "apps/vis/writer/vis_writer_factory.h" #include "apps/vis/writer/vis_writer_keeper.h" #include "apps/vis/writer/vis_png_writer.h" #include "apps/vis/writer/vis_pdf_writer.h" namespace vis { WriterFactory:: WriterFactory( void ) {} WriterFactory::~WriterFactory() {} // ---------------------------------------------------------------------- std::string WriterFactory:: name( void ) const throw() { return "vis_writer"; } // ---------------------------------------------------------------------- std::string WriterFactory:: description( void ) const throw() { return "Vis filewriter objects"; } } #endif
[ "csinger08@users.sourceforge.net" ]
[ [ [ 1, 44 ] ] ]
59cfee9693984396770fc2f0acd89767985b10b0
188058ec6dbe8b1a74bf584ecfa7843be560d2e5
/GodDK/io/InputStream.cxx
e9fb7b8a2f429b4ea12c964b1cf68b8ad74d9c23
[]
no_license
mason105/red5cpp
636e82c660942e2b39c4bfebc63175c8539f7df0
fcf1152cb0a31560af397f24a46b8402e854536e
refs/heads/master
2021-01-10 07:21:31
2007-08-23 06:29:17
2007-08-23 06:29:17
36,223,621
0
0
null
null
null
null
UTF-8
C++
false
false
1,429
cxx
#ifdef HAVE_CONFIG_H # include "config.h" #endif #include "io/InputStream.h" #include "lang/String.h" using goddk::lang::String; #include "lang/NullPointerException.h" using goddk::lang::NullPointerException; using namespace goddk::io; jint InputStream::available() throw (IOExceptionPtr) { return 0; } void InputStream::close() throw (IOExceptionPtr) { } void InputStream::mark(jint readlimit) throw () { } bool InputStream::markSupported() throw () { return false; } jint InputStream::read(bytearray& b) throw (IOExceptionPtr) { return read(b.data(), 0, b.size()); } jint InputStream::read(byte* data, jint offset, jint length) throw (IOExceptionPtr) { if (!data) THROWEXCEPTIONPTR(NullPointerException) jint b = read(); if (b < 0) return -1; data[offset] = (byte) b; jint i = 1; try { while (i < length) { b = read(); if (b < 0) break; data[offset+i++] = (byte) b; } } catch (IOException&) { // ignore } return i; } jint InputStream::skip(jint n) throw (IOExceptionPtr) { jint remaining = n; byte skip[2048]; while (remaining > 0) { jint rc = read(skip, 0, remaining > 2048 ? 2048 : remaining); if (rc < 0) break; remaining -= rc; } return n - remaining; } void InputStream::reset() throw (IOExceptionPtr) { THROWEXCEPTIONPTR1(IOException,"reset not supported"); }
[ "soaris@46205fef-a337-0410-8429-7db05d171fc8" ]
[ [ [ 1, 87 ] ] ]
785a2968acee3a5b3ac23300a3b0314227b2f999
61fc00b53ce93f09a6a586a48ae9e484b74b6655
/src/tool/src/wrapper/chemical/wrapper_chemicalcmd_to_avoaction.cpp
c37769e8310891c503fa776faf653c6aa0dbd82b
[]
no_license
mickaelgadroy/wmavo
4162c5c7c8d9082060be91e774893e9b2b23099b
db4a986d345d0792991d0e3a3d728a4905362a26
refs/heads/master
2021-01-04 22:33:25
2011-11-04 10:44:50
2011-11-04 10:44:50
1,381,704
2
0
null
null
null
null
UTF-8
C++
false
false
59,177
cpp
/******************************************************************************* Copyright (C) 2010,2011 Mickael Gadroy, University of Reims Champagne-Ardenne (Fr) Project managers: Eric Henon and Michael Krajecki Financial support: Region Champagne-Ardenne (Fr) Some portions : Copyright (C) 2007-2009 Marcus D. Hanwell Copyright (C) 2006,2008,2009 Geoffrey R. Hutchison Copyright (C) 2006,2007 Donald Ephraim Curtis Copyright (C) 2008,2009 Tim Vandermeersch This file is part of WmAvo (WiiChem project) WmAvo - Integrate the Wiimote and the Nunchuk in Avogadro software for the handling of the atoms and the camera. For more informations, see the README file. WmAvo is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. WmAvo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with WmAvo. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "wrapper_chemicalcmd_to_avoaction.h" #include "wmtool.h" #include "moleculemanipulation.h" #include "contextmenu_to_avoaction.h" namespace Avogadro { const Eigen::Vector3d WrapperChemicalCmdToAvoAction::m_vect3d0(Eigen::Vector3d(0., 0., 0.)) ; Eigen::Transform3d WrapperChemicalCmdToAvoAction::m_transf3d0 ; const QPoint WrapperChemicalCmdToAvoAction::m_qpoint0(QPoint(0,0)) ; const double WrapperChemicalCmdToAvoAction::m_PI180=M_PI/180.0 ; const double WrapperChemicalCmdToAvoAction::m_180PI=180.0/M_PI ; WrapperChemicalCmdToAvoAction::WrapperChemicalCmdToAvoAction ( GLWidget *widget, WITD::ChemicalWrap *chemWrap, InputDevice::WmDevice *wmdev ) : m_widget(widget), m_moleculeManip(NULL), m_wmDev(wmdev), m_isCalculDistDiedre(false), m_isMoveAtom(false), m_tmpBarycenter(m_vect3d0), m_isRenderRect(false), m_rectP1(m_qpoint0), m_rectP2(m_qpoint0), m_needAnUpdateMore(false), m_isAtomDraw(false), m_isBondOrder(false), m_drawBeginAtom(false), m_drawCurrentAtom(false), m_drawBond(false), m_hasAddedBeginAtom(false), m_hasAddedCurAtom(false), m_hasAddedBond(false), m_beginPosDraw(m_vect3d0), m_curPosDraw(m_vect3d0), m_lastCursor(m_qpoint0), m_beginAtomDraw(NULL), m_curAtomDraw(NULL), m_bondDraw(NULL), m_timeFirst(0), m_timeSecond(0), m_canDrawOther(false) { /// Initiate the objects. m_moleculeManip = new MoleculeManipulation( widget->molecule() ) ; m_contextMenu = new ContextMenuToAvoAction( widget, m_moleculeManip, chemWrap ) ; m_transf3d0.matrix().setIdentity() ; /// Initiate some attributs to realize mouse simulations. m_testEventPress = false ; m_p = new QPoint(1,1) ; m_me1 = new QMouseEvent(QEvent::MouseButtonPress, *m_p, Qt::LeftButton, Qt::NoButton, Qt::NoModifier) ; m_me2 = new QMouseEvent(QEvent::MouseMove, *m_p, Qt::NoButton, Qt::LeftButton, Qt::NoModifier) ; m_me3 = new QMouseEvent(QEvent::MouseButtonRelease, *m_p, Qt::LeftButton, Qt::NoButton, Qt::NoModifier) ; m_time.start() ; m_nbUpdate1 = new WIWO<unsigned int>(20) ; m_nbUpdate2 = new WIWO<unsigned int>(20) ; m_nbUpdate3 = new WIWO<unsigned int>(20) ; } WrapperChemicalCmdToAvoAction::~WrapperChemicalCmdToAvoAction() { if( m_me1 != NULL ){ delete( m_me1 ) ; m_me1=NULL ; } if( m_me2 != NULL ){ delete( m_me2 ) ; m_me2=NULL ; } if( m_me3 != NULL ){ delete( m_me3 ) ; m_me3=NULL ; } if( m_p != NULL ){ delete( m_p ) ; m_p=NULL ; } if( m_nbUpdate1 != NULL ){ delete( m_nbUpdate1 ) ; m_nbUpdate1=NULL ; } if( m_nbUpdate2 != NULL ){ delete( m_nbUpdate2 ) ; m_nbUpdate2=NULL ; } if( m_nbUpdate3 != NULL ){ delete( m_nbUpdate3 ) ; m_nbUpdate3=NULL ; } } MoleculeManipulation* WrapperChemicalCmdToAvoAction::getMoleculeManip() { return m_moleculeManip ; } ContextMenuToAvoAction* WrapperChemicalCmdToAvoAction::getContextMenu() { return m_contextMenu ; } /** * Transform a wrapper action to an Avogadro action. * @param wmData All Wiimote data get. */ void WrapperChemicalCmdToAvoAction::transformWrapperActionToAvoAction( WITD::ChemicalWrapData_from *data ) { WITD::ChemicalWrapData_from::wrapperActions_t wa ; WITD::ChemicalWrapData_from::positionCamera_t pc ; WITD::ChemicalWrapData_from::positionPointed_t pp ; //bool upWa=data->getWrapperAction( wa ) ; //bool upPc=data->getPositionCamera( pc ) ; //bool upPp=data->getPositionPointed( pp ) ; wa = data->getWrapperAction() ; pc = data->getPositionCamera() ; pp = data->getPositionPointed() ; QPoint posCursor=pp.posCursor ; int state=wa.actionsWrapper ; Eigen::Vector3d pos3dCurrent=pp.pos3dCur ; Eigen::Vector3d pos3dLast=pp.pos3dLast ; double rotCamAxeXDeg=pc.angleRotateDegree[0] ; double rotCamAxeYDeg=pc.angleRotateDegree[1] ; double distCamXTranslate=pc.distanceTranslate[0] ; double distCamYTranslate=pc.distanceTranslate[1] ; double distCamZoom=pc.distanceTranslate[2] ; //cout << nbDotsDetected << " " << nbSourcesDetected << " " << distBetweenSource << endl ; // Adjustment for the rotation of atoms. if( WMAVO_IS2(state,WMAVO_CAM_ROTATE_BYWM) && m_widget->selectedPrimitives().size()>=2 ) { // Disable the context menu action. WMAVO_SETOFF2( state, WMAVO_CAM_ROTATE_BYWM ) ; WMAVO_SETON2( state, WMAVO_ATOM_MOVE ) ; WMAVO_SETON2( state, WMAVO_ATOM_ROTATE ) ; } const Eigen::Vector3d pointRef=m_moleculeManip->getBarycenterMolecule() ; transformWrapperActionToMoveAtom( state, pointRef, pos3dCurrent, pos3dLast, rotCamAxeXDeg, rotCamAxeYDeg ) ; transformWrapperActionToMoveMouse( state, posCursor ) ; transformWrapperActionToSelectAtom( state, posCursor ) ; transformWrapperActionToCreateAtomBond( state, pointRef, posCursor ) ; transformWrapperActionToDeleteAllAtomBond( state ) ; transformWrapperActionToRemoveAtomBond( state, posCursor ) ; transformWrapperActionToRotateCamera( state, pointRef, rotCamAxeXDeg, rotCamAxeYDeg ) ; transformWrapperActionToTranslateCamera( state, pointRef, distCamXTranslate, distCamYTranslate ) ; transformWrapperActionToZoomCamera( state, pointRef, distCamZoom ) ; transformWrapperActionToInitiateCamera( state, pointRef ) ; transformWrapperActionToSaturateAtoms( state ) ; transformWrapperActionToUseContextMenu( state, posCursor ) ; transformWrapperActionToAvoUpdate( state ) ; } void WrapperChemicalCmdToAvoAction::transformWrapperActionToAvoUpdate( int state ) { // // Update Avogadro to see modification. updateForAvoActions1( state ) ; updateForAvoActions2( state ) ; updateForAvoActions3( state ) ; } /** * Transform a wrapper action to an Avogadro action : move the mouse cursor. * @param wmavoAction All actions ask by the wrapper * @param posCursor The new position of the mouse cursor */ void WrapperChemicalCmdToAvoAction::transformWrapperActionToMoveMouse( int wmavoAction, const QPoint& posCursor ) { if( WMAVO_IS2(wmavoAction,WMAVO_CURSOR_MOVE) || WMAVO_IS2(wmavoAction,WMAVO_CREATE) ) { //cout << "WrapperChemicalCmdToAvoAction::transformWrapperActionToMoveMouse" << endl ; QCursor::setPos(posCursor) ; } } /** * Transform a wrapper action to an Avogadro action : select an atom, * (or a bond to initiate a rotation axe). * @param wmavoAction All actions ask by the wrapper * @param posCursor The position where a "click" is realised */ void WrapperChemicalCmdToAvoAction::transformWrapperActionToSelectAtom( int wmavoAction, const QPoint& posCursor ) { if( WMAVO_IS2(wmavoAction,WMAVO_SELECT) || WMAVO_IS2(wmavoAction,WMAVO_SELECT_MULTI) ) { //cout << "WrapperChemicalCmdToAvoAction::transformWrapperActionToSelectAtom" << endl ; if( WMAVO_IS2(wmavoAction,WMAVO_SELECT) ) { // Select only 1 object. /* { // Test to add a real mouse click // - Code occurs crash. // - It can't access to the menu pull-down. QPoint p=QCursor::pos() ; //QCoreApplication *app=QCoreApplication::instance() ; //QWidget *widget=app->widgetAt( p ) ; QWidget *widget=QApplication::widgetAt( p ) ; //QWidget *widget=QApplication::activeWindow() ; if( widget!=NULL ) { mytoolbox::dbgMsg( widget->accessibleName() ) ; QPoint p2=widget->mapFromGlobal(p) ; QEvent *me1 = new QMouseEvent( QEvent::MouseButtonPress, p2, Qt::LeftButton, Qt::NoButton, Qt::NoModifier ) ; QEvent *me3 = new QMouseEvent( QEvent::MouseButtonRelease, p2, Qt::LeftButton, Qt::NoButton, Qt::NoModifier ) ; QApplication::postEvent( widget, me1 ) ; QApplication::postEvent( widget, me3 ) ; } else { mytoolbox::dbgMsg( "nada" ) ; } } */ // Just one rumble. InputDevice::RumbleSettings rumble( false, false, 10 ) ; rumble.setStart( true ) ; rumble.setDistance( 0 ) ; InputDevice::WmDeviceData_to wmDevDataTo ; wmDevDataTo.setRumble( rumble ) ; m_wmDev->setDeviceDataTo( wmDevDataTo ) ; QPoint p=m_widget->mapFromGlobal(posCursor) ; bool hasAddHydrogen=m_moleculeManip->hasAddedHydrogen() ; Atom *atom=NULL ; Bond *bond=NULL ; // One method: // Not adapted here: atom = m_widget->computeClickedAtom( p ) ; // OR, // use the method below : QList<GLHit> hits=m_widget->hits( p.x()-5, p.y()-5, 10, 10 ) ; // Search the 1st primitive which is interesting. foreach( const GLHit& hit, hits ) { if( hit.type() == Primitive::AtomType ) { atom = m_widget->molecule()->atom( hit.name() ) ; break ; } if( hit.type() == Primitive::BondType ) { bond = m_widget->molecule()->bond( hit.name() ) ; break ; } } if( atom==NULL && bond==NULL ) { // No selection. m_widget->clearSelected() ; m_moleculeManip->resetRotationAxe() ; } else if( bond != NULL ) { // Bond selection. // Get the previous bond. Bond *oldBond=m_moleculeManip->getRotationAxeBond() ; // Check if identical with the new. if( oldBond!=NULL && oldBond==bond ) { // Disable it. m_moleculeManip->resetRotationAxe() ; PrimitiveList pl ; pl.append( oldBond ) ; m_widget->setSelected( pl, false ) ; } else { // Enable the new, and disable the old. m_moleculeManip->setRotationAxe( bond ) ; if( oldBond != NULL ) { // Unselect the previous bond used to the rotation axe. PrimitiveList pl ; pl.append( oldBond ) ; m_widget->setSelected( pl, false ) ; } // Select the new bond used to the rotation axe. PrimitiveList pl ; pl.append( bond ) ; m_widget->setSelected( pl, true ) ; } } else if( atom != NULL ) { // Atom seletion. m_moleculeManip->resetRotationAxe() ; if( m_isCalculDistDiedre ) { // Manage the selection of atom for the calculation of distance & Co. // It works with an association of the WmTool class. // Put the "calcul distance" mode of the WrapperChemicalCmdToAvoAction class to off. m_isCalculDistDiedre = false ; // Inform the WmTool class of the selected atom. emit sendAtomToCalculDistDiedre( atom ) ; // To wmTool. // Nota Bene : it is the WmTool class which infoms the WrapperChemicalCmdToAvoAction class when // it is necessary to select an atom for the "calcul distance" mode. } else { // Manage the selection of one atom. QList<Primitive*> hitList ; hitList.append(atom) ; m_widget->toggleSelected(hitList) ; //m_widget->setSelected(hitList, true) ; // Select H-neighbors. if( hasAddHydrogen && m_widget->isSelected(static_cast<Primitive*>(atom)) && !atom->isHydrogen() ) { Atom *a=NULL ; PrimitiveList pl ; foreach( unsigned long ai, atom->neighbors() ) { a = m_widget->molecule()->atomById(ai) ; if( a!=NULL && a->isHydrogen() ) pl.append( a ) ; } m_widget->setSelected( pl, true) ; } } } } else //if( WMAVO_IS2(wmavoAction,WMAVO_SELECT_MULTI) ) { // Multiple selection. // For the display of the selection rectangle. if( !m_isRenderRect ) { // Save the 1st point of the rectangle. m_isRenderRect = true ; m_rectP1 = posCursor ; } // Save the 2nd point of the rectangle. m_rectP2 = posCursor ; QPoint p1=m_widget->mapFromGlobal(m_rectP1) ; QPoint p2=m_widget->mapFromGlobal(m_rectP2) ; // Adjust the 1st point always at bottom/left, // the 2nd point always at up/right. int x1=( p1.x()<p2.x() ? p1.x() : p2.x() ) ; int y1=( p1.y()<p2.y() ? p1.y() : p2.y() ) ; int x2=( p1.x()>p2.x() ? p1.x() : p2.x() ) - 1 ; int y2=( p1.y()>p2.y() ? p1.y() : p2.y() ) - 1 ; // Inform the WmTool class of the 2 points of the selection rectangle for the display. emit renderedSelectRect( true, QPoint(x1,y1), QPoint(x2,y2) ) ; } } else { if( m_isRenderRect ) { // // 1. Realize the selection QList<GLHit> hitList ; PrimitiveList pList ; Primitive *p=NULL ; Atom *a=NULL ; QPoint p1=m_widget->mapFromGlobal(m_rectP1) ; QPoint p2=m_widget->mapFromGlobal(m_rectP2) ; int x1=( p1.x()<p2.x() ? p1.x() : p2.x() ) ; int y1=( p1.y()<p2.y() ? p1.y() : p2.y() ) ; int x2=( p1.x()>p2.x() ? p1.x() : p2.x() ) ; // - 1 ; int y2=( p1.y()>p2.y() ? p1.y() : p2.y() ) ; // - 1 ; // Perform an OpenGL selection and retrieve the list of hits. hitList = m_widget->hits( x1, y1, x2-x1, y2-y1 ) ; if( hitList.empty() ) { m_widget->clearSelected() ; } else { // Build a primitiveList for toggleSelected() method. foreach( const GLHit& hit, hitList ) { if( hit.type() == Primitive::AtomType ) { a = m_widget->molecule()->atom( hit.name() ) ; p = static_cast<Primitive *>( a ) ; if( p != NULL ) pList.append( p ) ; else mytoolbox::dbgMsg( "Bug in WrapperChemicalCmdToAvoAction::transformWrapperActionToSelectAtom : a NULL-object not expected." ) ; } } // Toggle the selection. m_widget->toggleSelected( pList ) ; // or setSelected() //cout << "toggle primitive" << endl ; } // // 2. Finish the action. m_isRenderRect = false ; m_needAnUpdateMore = true ; m_rectP1 = QPoint( 0, 0 ) ; m_rectP2 = QPoint( 0, 0 ) ; p1 = m_widget->mapFromGlobal(m_rectP1) ; p2 = m_widget->mapFromGlobal(m_rectP2) ; emit renderedSelectRect( false, p1, p2) ; } } } /** * Transform a wrapper action to an Avogadro action : move the selected atoms. * @param wmavoAction All actions ask by the wrapper * @param pointRef The position of the reference point * @param pos3dCurrent The current position calculate by the Wiimote * @param pos3dLast The last position calculate by the Wiimote * @param rotAtomDegX The desired X-axis angle * @param rotAtomDegY The desired Y-axis angle */ void WrapperChemicalCmdToAvoAction::transformWrapperActionToMoveAtom ( int wmavoAction, const Eigen::Vector3d& pointRef, const Eigen::Vector3d& pos3dCurrent, const Eigen::Vector3d& pos3dLast, double rotAtomDegX, double rotAtomDegY ) { if( WMAVO_IS2(wmavoAction,WMAVO_ATOM_MOVE) ) { // Object is in "travel mode", but just in the mode. // It is necessary to know what is the movement. if( WMAVO_IS2(wmavoAction,WMAVO_ATOM_TRANSLATE) || WMAVO_IS2(wmavoAction,WMAVO_ATOM_ROTATE) ) { // Work when an atom is moving. If no movement, do not pass here. //cout << "WrapperChemicalCmdToAvoAction::transformWrapperActionToMoveAtom" << endl ; Eigen::Vector3d vectAtomTranslate ; Eigen::Transform3d transfAtomRotate ; bool isMoved=calculateTransformationMatrix ( wmavoAction, pos3dCurrent, pos3dLast, pointRef, rotAtomDegX, rotAtomDegY, vectAtomTranslate, transfAtomRotate ) ; if( isMoved ) { if( !m_isMoveAtom ) m_isMoveAtom = true ; QList<Primitive*> pList=m_widget->selectedPrimitives().subList(Primitive::AtomType) ; if( WMAVO_IS2(wmavoAction,WMAVO_ATOM_TRANSLATE) ) m_moleculeManip->tranlateAtomBegin( pList, vectAtomTranslate ) ; else if( WMAVO_IS2(wmavoAction,WMAVO_ATOM_ROTATE) ) m_moleculeManip->rotateAtomBegin( pList, transfAtomRotate ) ; // Active rumble in the Wiimote only if one atom is selected. if( pList.size() == 1 ) { Atom *a=static_cast<Atom*>(pList.at(0)) ; if( a != NULL ) { Atom *an=m_moleculeManip->calculateNearestAtom( a->pos(), a ) ; Eigen::Vector3d dist = *(a->pos()) - *(an->pos()) ; double act = dist.norm() ; InputDevice::RumbleSettings rumble( false, true ) ; rumble.setStart( true ) ; rumble.setDistance( act, WMRUMBLE_MIN_DISTANCE, WMRUMBLE_MAX_DISTANCE ) ; InputDevice::WmDeviceData_to wmDevDataTo ; wmDevDataTo.setRumble( rumble ) ; m_wmDev->setDeviceDataTo( wmDevDataTo ) ; } } } } } else { // Finish the action. if( m_isMoveAtom ) // Caution, this attribut is initialised/used in moveAtom*() methods. { m_isMoveAtom = false ; QList<Primitive*> pList=m_widget->selectedPrimitives().subList(Primitive::AtomType) ; m_moleculeManip->moveAtomEnd( pList ) ; InputDevice::RumbleSettings rumble( false, false ) ; rumble.setStart( false ) ; rumble.setDistance( 0 ) ; InputDevice::WmDeviceData_to wmDevDataTo ; wmDevDataTo.setRumble( rumble ) ; m_wmDev->setDeviceDataTo( wmDevDataTo ) ; m_tmpBarycenter = m_vect3d0 ; } } } /** * Transform a wrapper action to an Avogadro action : create atom(s) and bond(s). * @param wmavoAction All actions ask by the wrapper * @param pointRef The position of the reference point * @param posCursor The position of the cursor */ void WrapperChemicalCmdToAvoAction::transformWrapperActionToCreateAtomBond ( int wmavoAction, const Eigen::Vector3d& pointRef, const QPoint &posCursor ) { if( WMAVO_IS2(wmavoAction,WMAVO_CREATE) || m_isAtomDraw ) // for m_isAtomDraw : Necessary for the action of "isCreateAtom". { //mytoolbox::dbgMsg( "WrapperChemicalCmdToAvoAction::transformWrapperActionToCreateAtomBond" ; Molecule *mol=m_widget->molecule() ; // molecule->lock()->tryLockForWrite() : // GLWidget::render(): Could not get read lock on molecule. // Lock the write on the molecule => so it locks the render too ... // This means the possibility that the Avogadro software can be really multi-thread // (or in anticipation). // The lock justifies it by the array used to store a new atom, and with the search // of a new id for this new atom y tutti quanti ... //if( molecule->lock()->tryLockForWrite() ) //{ // Add an atom. QPoint p=m_widget->mapFromGlobal(posCursor) ; if( !m_isAtomDraw ) { // The 1st action : a request of creation m_lastCursor = p ; Primitive* prim=m_widget->computeClickedPrimitive( p ) ; m_timeFirst = m_time.elapsed() ; if( prim == NULL ) { m_isAtomDraw = true ; m_drawBeginAtom = true ; m_drawCurrentAtom = false ; m_drawBond = false ; //cout << "cursor position:" << p.x() << "," << p.y() << endl ; //cout << "ref position:" << pointRef[0] << "," << pointRef[1] << "," << pointRef[2] << endl ; m_beginPosDraw = m_widget->camera()->unProject( p, pointRef ) ; m_curPosDraw = m_beginPosDraw ; } else if( prim->type() == Primitive::AtomType ) { m_isAtomDraw = true ; m_drawBeginAtom = false ; m_drawCurrentAtom = false ; m_drawBond = false ; m_beginAtomDraw = static_cast<Atom*>(prim) ; m_beginPosDraw = *(m_beginAtomDraw->pos()) ; m_curPosDraw = m_beginPosDraw ; } else if( prim->type() == Primitive::BondType ) { m_isBondOrder = true ; m_isAtomDraw = true ; m_drawBeginAtom = false ; m_drawCurrentAtom = false ; m_drawBond = false ; m_bondDraw = static_cast<Bond*>(prim) ; } //else // Nothing to do. // Request the temporary display of the 1st atom(by the WmTool class). if( m_isAtomDraw || m_isBondOrder ) emit renderedAtomBond( m_beginPosDraw, m_curPosDraw, m_drawBeginAtom, m_drawCurrentAtom, m_drawBond ) ; } else if( m_isAtomDraw && WMAVO_IS2(wmavoAction,WMAVO_CREATE) && !m_isBondOrder ) { // The 2nd action. // That means, the 1st atom has been "selected/created" and // the mouse is moving to create/select an 2nd atom with (new) bond. // Timeout before to create a 2nd atom. if( !m_canDrawOther ) { m_timeSecond = m_time.elapsed() ; if( (m_timeSecond-m_timeFirst) > 1000 ) m_canDrawOther = true ; } if( m_canDrawOther ) { m_curPosDraw = m_widget->camera()->unProject(p, pointRef) ; Atom *an = m_moleculeManip->calculateNearestAtom( &m_curPosDraw, NULL ) ; if( an != NULL ) { Eigen::Vector3d dist=m_curPosDraw - *(an->pos()) ; double act=dist.norm() ; // Activate rumble. InputDevice::RumbleSettings rumble( false, true ) ; rumble.setStart( true ) ; rumble.setDistance( act, WMRUMBLE_MIN_DISTANCE, WMRUMBLE_MAX_DISTANCE ) ; InputDevice::WmDeviceData_to wmDevDataTo ; wmDevDataTo.setRumble( rumble ) ; m_wmDev->setDeviceDataTo( wmDevDataTo ) ; } // Methode0 : SPEED !! Atom* a=NULL ; // Methode1 : SLOW !! //a = m_widget->computeClickedAtom( p ) ; // Methode2 : SLOW !! /* QList<GLHit> hits=m_widget->hits( p.x()-5, p.y()-5, 10, 10 ) ; foreach( const GLHit& hit, hits ) { if( hit.type() == Primitive::AtomType ) { // Le 1er element est le plus proche. a = m_widget->molecule()->atom( hit.name() ) ; break ; } }*/ if( a == NULL ) { double var1=m_beginPosDraw[0]-m_curPosDraw[0] ; double var2=m_beginPosDraw[1]-m_curPosDraw[1] ; double var3=m_beginPosDraw[2]-m_curPosDraw[2] ; double distVect=sqrt( var1*var1 + var2*var2 + var3*var3 ) ; // Draw a 2nd atom only if the distance is bigger than ... if( distVect > WMEX_DISTBEFORE_CREATE ) { //cout << "Display current atom & bond" << endl ; m_drawCurrentAtom = true ; if( m_beginAtomDraw!=NULL && m_beginAtomDraw->isHydrogen() && m_beginAtomDraw->bonds().count()>0 ) m_drawBond = false ; else m_drawBond = true ; m_curAtomDraw = a ; } else { m_drawCurrentAtom = false ; m_drawBond = false ; m_curAtomDraw = NULL ; } } else if( *(a->pos()) == m_beginPosDraw ) { //cout << "Display nothing" << endl ; m_drawCurrentAtom = false ; m_drawBond = false ; m_curAtomDraw = NULL ; } else //if( a ) { //cout << "Display Bond" << endl ; m_drawCurrentAtom = false ; m_drawBond = true ; // Limit the number of bond if Hydrogen Atom. if( a->isHydrogen() && a->bonds().count() > 0 ) m_drawBond = false ; if( m_drawBond && m_beginAtomDraw!=NULL && m_beginAtomDraw->isHydrogen() && m_beginAtomDraw->bonds().count() > 0 ) m_drawBond = false ; m_curAtomDraw = a ; m_curPosDraw = *(a->pos()) ; } // Request the temporary display of the atoms and bond (by the WmTool class). emit renderedAtomBond( m_beginPosDraw, m_curPosDraw, m_drawBeginAtom, m_drawCurrentAtom, m_drawBond ) ; } } else if( m_isAtomDraw && !WMAVO_IS2(wmavoAction,WMAVO_CREATE) ) { // The 3rd and last action : creation // - either adjust number of bond ; // - or create atoms(s) and bond. bool addSmth=false ; //QUndoCommand *undo=NULL ; if( m_isBondOrder ) { //int oldBondOrder = m_bondDraw->order() ; #if !AVO_DEPRECATED_FCT // 1. m_moleculeManip->changeOrderBondBy1( m_bondDraw ) ; #else // 2. undo = new ChangeBondOrderDrawCommand( m_bondDraw, oldBondOrder, m_addHydrogens ) ; m_widget->undoStack()->push( undo ) ; #endif } else //if( m_isAtomDraw && !m_isBondOrder ) { //cout << "End of the creation of atom/bond" << endl ; Atom* a=NULL ; Eigen::Vector3d addAtomPos ; InputDevice::RumbleSettings rumble( false, false ) ; rumble.setStart( false ) ; rumble.setDistance( 0 ) ; InputDevice::WmDeviceData_to wmDevDataTo ; wmDevDataTo.setRumble( rumble ) ; m_wmDev->setDeviceDataTo( wmDevDataTo ) ; if( m_beginAtomDraw == NULL ) { addSmth = true ; m_hasAddedBeginAtom = true ; } // Timeout before to create a 2nd atom. if( !m_canDrawOther ) { m_timeSecond = m_time.elapsed() ; if( (m_timeSecond-m_timeFirst) > 1000 ) m_canDrawOther = true ; } // Add 2nd atom & bond. if( m_canDrawOther ) { a = m_widget->computeClickedAtom( p ) ; if( a == NULL ) { // Create atome/bond. double var1=m_beginPosDraw[0]-m_curPosDraw[0] ; double var2=m_beginPosDraw[1]-m_curPosDraw[1] ; double var3=m_beginPosDraw[2]-m_curPosDraw[2] ; double distVect=sqrt( var1*var1 + var2*var2 + var3*var3 ) ; // Draw a 2nd atom only if the distance is bigger than ... if( distVect > 0.6 ) { addAtomPos = m_widget->camera()->unProject( p, pointRef ) ; addSmth = true ; m_hasAddedCurAtom = true ; if( m_drawBond /* !(m_curAtomDraw->isHydrogen() && m_curAtomDraw->bonds().count()>0) && !(m_beginAtomDraw->isHydrogen() && m_beginAtomDraw->bonds().count()>0) */ ) m_hasAddedBond = true ; } } else { // Create bond. if( *(a->pos()) != m_beginPosDraw && mol->bond(a,m_beginAtomDraw) == NULL && m_drawBond /* !(a->isHydrogen() && a->bonds().count()>0) && !(m_beginAtomDraw->isHydrogen() && m_beginAtomDraw->bonds().count()>0) */ ) { m_curAtomDraw = a ; addSmth = true ; m_hasAddedBond = true ; } } } if( mol->lock()->tryLockForWrite() ) { int atomicNumber=m_moleculeManip->getAtomicNumberCurrent() ; // Create just the 1st atom. if( m_hasAddedBeginAtom && !m_hasAddedCurAtom && !m_hasAddedBond ) m_beginAtomDraw = m_moleculeManip->addAtom( &m_beginPosDraw, atomicNumber ) ; // Create just the 2nd atom. if( !m_hasAddedBeginAtom && m_hasAddedCurAtom && !m_hasAddedBond ) m_curAtomDraw = m_moleculeManip->addAtom( &addAtomPos, atomicNumber ) ; // Create just the bond. if( !m_hasAddedBeginAtom && !m_hasAddedCurAtom && m_hasAddedBond ) m_bondDraw = m_moleculeManip->addBond( m_beginAtomDraw, a, 1 ) ; // Create the 2nd atom bonded at 1st. if( !m_hasAddedBeginAtom && m_hasAddedCurAtom && m_hasAddedBond ) m_curAtomDraw = m_moleculeManip->addAtom ( &addAtomPos, atomicNumber, m_beginAtomDraw, 1 ) ; // Create the 1st atom bonded at 2nd. if( m_hasAddedBeginAtom && !m_hasAddedCurAtom && m_hasAddedBond ) m_beginAtomDraw = m_moleculeManip->addAtom ( &m_beginPosDraw, atomicNumber, m_curAtomDraw, 1 ) ; // Create 2 atoms. if( m_hasAddedBeginAtom && m_hasAddedCurAtom ) { int order=0 ; PrimitiveList *pl=NULL ; if( m_hasAddedBond ) order = 1 ; pl = m_moleculeManip->addAtoms ( &m_beginPosDraw, atomicNumber, &addAtomPos, atomicNumber, order ) ; if( pl!=NULL && pl->size()>=2 ) { PrimitiveList::const_iterator ipl=pl->begin() ; m_beginAtomDraw = static_cast<Atom*>(*ipl) ; ipl++ ; m_curAtomDraw = static_cast<Atom*>(*ipl) ; } if( pl != NULL ) delete pl ; } // Substitute atom by atom. if( !m_hasAddedBeginAtom && !m_hasAddedCurAtom && !m_hasAddedBond && !m_canDrawOther ) m_moleculeManip->changeAtomicNumber( m_beginAtomDraw, atomicNumber ) ; GLfloat projectionMatrix[16] ; glGetFloatv( GL_PROJECTION_MATRIX, projectionMatrix ) ; //cout << "Projection Matrix:" << endl ; //cout<<" "<<projectionMatrix[0]<<" "<<projectionMatrix[4]<<" "<<projectionMatrix[8]<<" "<<projectionMatrix[12]<<endl; //cout<<" "<<projectionMatrix[1]<<" "<<projectionMatrix[5]<<" "<<projectionMatrix[9]<<" "<<projectionMatrix[13]<<endl; //cout<<" "<<projectionMatrix[2]<<" "<<projectionMatrix[6]<<" "<<projectionMatrix[10]<<" "<<projectionMatrix[14]<<endl; //cout<<" "<<projectionMatrix[3]<<" "<<projectionMatrix[7]<<" "<<projectionMatrix[11]<<" "<<projectionMatrix[15]<<endl; } mol->lock()->unlock() ; } mol->update() ; if( addSmth ) { InputDevice::RumbleSettings rumble( false, false, 10 ) ; rumble.setStart( true ) ; rumble.setDistance( 0 ) ; InputDevice::WmDeviceData_to wmDevDataTo ; wmDevDataTo.setRumble( rumble ) ; m_wmDev->setDeviceDataTo( wmDevDataTo ) ; } //addAdjustHydrogenRedoUndo( molecule ) ; // Initialization before next use. m_isBondOrder=false ; m_isAtomDraw=false ; m_drawBeginAtom=false ; m_drawCurrentAtom=false ; m_drawBond=false ; m_hasAddedBeginAtom=false ; m_hasAddedCurAtom=false ; m_hasAddedBond=false ; m_beginAtomDraw=NULL ; m_curAtomDraw=NULL ; m_bondDraw=NULL ; m_timeFirst=0 ; m_timeSecond=0 ; m_canDrawOther = false ; // "Push" all modifications & redraw of the molecule. emit renderedAtomBond( m_vect3d0, m_vect3d0, false, false, false ) ; } //} } } /** * Transform a wrapper action to an Avogadro action : delete all atom. * @param wmavoAction All actions ask by the wrapper */ void WrapperChemicalCmdToAvoAction::transformWrapperActionToDeleteAllAtomBond( int wmavoAction ) { if( WMAVO_IS2(wmavoAction,WMAVO_DELETEALL) ) { //mytoolbox::dbgMsg( "WrapperChemicalCmdToAvoAction::transformWrapperActionToDeleteAllAtomBond" ; m_moleculeManip->deleteAllElement() ; } } /** * Transform a wrapper action to an Avogadro action : delete atom(s). * @param wmavoAction All actions ask by the wrapper * @param posCursor The position of the cursor */ void WrapperChemicalCmdToAvoAction::transformWrapperActionToRemoveAtomBond( int wmavoAction, const QPoint &posCursor ) { if( WMAVO_IS2(wmavoAction,WMAVO_DELETE) ) { //mytoolbox::dbgMsg( "WrapperChemicalCmdToAvoAction::transformWrapperActionToRemoveAtomBond" ; Molecule *mol=m_widget->molecule() ; if( mol->lock()->tryLockForWrite() ) { QPoint p=m_widget->mapFromGlobal(posCursor) ; Primitive* prim=m_widget->computeClickedPrimitive( p ) ; PrimitiveList pl=m_widget->selectedPrimitives() ; if( prim == NULL ) { // Remove the selected atoms. #if !AVO_DEPRECATED_FCT m_moleculeManip->removeAtoms( &pl ) ; #else // 2. with undo/redo, not adjust hydrogen ... deleteSelectedElementUndoRedo( mol ) ; #endif } else { if( prim->type() == Primitive::AtomType ) { // Remove atom. Atom *atom = static_cast<Atom*>(prim) ; m_moleculeManip->removeAtom( atom ) ; } if( prim->type() == Primitive::BondType ) { // Remove bond. Bond *bond = static_cast<Bond*>(prim) ; #if !AVO_DEPRECATED_FCT // 1. m_moleculeManip->removeBond( bond ) ; #else // 2. deleteBondWithUndoRedo( bond ) ; #endif } } mol->lock()->unlock() ; } } } /** * Transform a wrapper action to an Avogadro action : rotate the camera. * @param wmavoAction All actions ask by the wrapper * @param pointRef The position of the reference point * @param rotCamAxeXDeg The desired angle on the X-axis of the screen * @param rotCamAxeYDeg The desired angle on the Y-axis of the screen */ void WrapperChemicalCmdToAvoAction::transformWrapperActionToRotateCamera ( int wmavoAction, const Eigen::Vector3d &pointRef, double rotCamAxeXDeg, double rotCamAxeYDeg ) { if( WMAVO_IS2(wmavoAction,WMAVO_CAM_ROTATE) ) { //mytoolbox::dbgMsg( "WrapperChemicalCmdToAvoAction::transformWrapperActionToRotateCamera" ; if( WMAVO_IS2(wmavoAction,WMAVO_CAM_ROTATE_BYWM) ) { // If use the cross of the Wiimote. // Use this method to get the wanted angle of rotation. // Value in (radian / Avogadro::ROTATION_SPEED) == the desired angle. double rotCamAxeXRad = (rotCamAxeXDeg*m_PI180) / Avogadro::ROTATION_SPEED ; double rotCamAxeYRad = (rotCamAxeYDeg*m_PI180) / Avogadro::ROTATION_SPEED ; Navigate::rotate( m_widget, pointRef, rotCamAxeXRad, rotCamAxeYRad ) ; } else if( WMAVO_IS2(wmavoAction,WMAVO_CAM_ROTATE_BYNC) ) { // Turn in a direction. // Do not search an unit speed or other, just a direction. Navigate::rotate( m_widget, pointRef, rotCamAxeXDeg, rotCamAxeYDeg ) ; } } } /** * Transform a wrapper action to an Avogadro action : translate the camera. * @param wmavoAction All actions ask by the wrapper * @param pointRef The position of the reference point * @param distCamXTranslate Desired distance on the X-axis of the screen * @param distCamYTranslate Desired distance on the Y-axis of the screen */ void WrapperChemicalCmdToAvoAction::transformWrapperActionToTranslateCamera ( int wmavoAction, const Eigen::Vector3d &pointRef, double distCamXTranslate, double distCamYTranslate ) { if( WMAVO_IS2(wmavoAction,WMAVO_CAM_TRANSLATE) ) { //mytoolbox::dbgMsg( "WrapperChemicalCmdToAvoAction::transformWrapperActionToTranslateCamera" ; Navigate::translate( m_widget, pointRef, distCamXTranslate, distCamYTranslate ) ; } } /** * Transform a wrapper action to an Avogadro action : zoom the camera. * @param wmavoAction All actions ask by the wrapper * @param pointRef The position of the reference point * @param distCamZoom Desired distance for the zoom on the Z-axis of the screen */ void WrapperChemicalCmdToAvoAction::transformWrapperActionToZoomCamera ( int wmavoAction, const Eigen::Vector3d &pointRef, double distCamZoom ) { if( WMAVO_IS2(wmavoAction,WMAVO_CAM_ZOOM) ) { //mytoolbox::dbgMsg( "WrapperChemicalCmdToAvoAction::transformWrapperActionToZoomCamera" ; Navigate::zoom( m_widget, pointRef, distCamZoom ) ; } } /** * Transform a wrapper action to an Avogadro action : initiate the camera. * @param wmavoAction All actions ask by the wrapper * @param pointRef The position of the reference point. */ void WrapperChemicalCmdToAvoAction::transformWrapperActionToInitiateCamera ( int wmavoAction, const Eigen::Vector3d &pointRef ) { if( WMAVO_IS2(wmavoAction,WMAVO_CAM_INITIAT) ) { //mytoolbox::dbgMsg( "WrapperChemicalCmdToAvoAction::transformWrapperActionToInitiateCamera" ; #if 0 // 1 //m_widget->camera()->setModelview( m_cameraInitialViewPoint ) ; if( !( ((rotCamAxeXDeg==90.0 || rotCamAxeXDeg==-90.0) && rotCamAxeYDeg==0.0) || ((rotCamAxeYDeg==90.0 || rotCamAxeYDeg==-90.0) && rotCamAxeXDeg==0.0) ) ) { // If not use the cross of the Wiimote. // 2 //mytoolbox::dbgMsg( "pointRefRot:" << pointRefRot[0] << pointRefRot[1] << pointRefRot[2] ; //Navigate::translate( m_widget, pointRefRot, -pointRefRot[0], -pointRefRot[1] ) ; // 3 Eigen::Vector3d barycenterScreen=m_widget->camera()->project(pointRefRot) ; QPoint barycenterScreen2(barycenterScreen[0], barycenterScreen[1]) ; //mytoolbox::dbgMsg( "pointRefRot:" << barycenterScreen[0] << barycenterScreen[1] << barycenterScreen[2] ; //Navigate::translate( m_widget, pointRefRot, -barycentreEcran[0], -barycentreEcran[1] ) ; // 4 //Navigate::zoom( m_widget, pointRefRot, m_widget->cam_beginPosDrawmera()->distance(pointRefRot)/*+10*/ ) ; //mytoolbox::dbgMsg( " distance:" << m_widget->camera()->distance(pointRefRot) ; // 5 Eigen::Vector3d transformedGoal = m_widget->camera()->modelview() * pointRefRot ; double distance=m_widget->camera()->distance(pointRefRot) ; double distanceToGoal = transformedGoal.norm() ; //mytoolbox::dbgMsg( " distance:" << distance ; //mytoolbox::dbgMsg( " distanceToGoal:" << distanceToGoal ; /* double distanceToGoal = transformedGoal.norm();m_beginPosDraw double t = ZOOM_SPEED * delta; const double minDistanceToGoal = 2.0 * CAMERA_NEAR_DISTANCE; double u = minDistanceToGoal / distanceToGoal - 1.0; if( t < u ) { t = u; Navigate::rotate( m_widget, pointRefRot, rotCamAxeXDeg, rotCamAxeYDeg ) ; } widget->camera()->modelview().pretranslate(transformedGoal * t); */ // 6 //m_widget->camera()->modelview().pretranslate(-transformedGoal /*+ (camBackTransformedZAxis*-40)*/ ) ; //m_widget->camera()->modelview().translate(-transformedGoal /*+ (camBackTransformedZAxis*-10)*/ ) ; // 7 //Eigen::Vector3d camBackTransformedZAxis=m_widget->camera()->transformedZAxis() ; //m_widget->camera()->modelview().translate( camBackTransformedZAxis*-10.0 ) ; distance=m_widget->camera()->distance(pointRefRot) ; distanceToGoal = transformedGoal.norm(); //mytoolbox::dbgMsg( " distance:" << distance ; //mytoolbox::dbgMsg( " distanceToGoal:" << distanceToGoal ; #endif //Eigen::Vector3d barycenterScreen=m_widget->camera()->project(pointRefRot) ; //QPoint barycenterScreen2(barycenterScreen[0], barycenterScreen[1]) ; //mytoolbox::dbgMsg( "pointRefRot:" << barycenterScreen[0] << barycenterScreen[1] << barycenterScreen[2] ; //Eigen::Transform3d cam=m_widget->camera()->modelview() ; /* OK Eigen::Vector3d right(cam(0,0), cam(1,0), cam(2,0)) ; Eigen::Vector3d up(cam(0,1), cam(1,1), cam(2,1)) ; Eigen::Vector3d dir(cam(0,2), cam(1,2), cam(2,2)) ; Eigen::Vector3d pos(cam(0,3), cam(1,3), cam(2,3)) ; cout << "right:" << right << endl ; cout << "dir:" << dir << endl ; cout << "up:" << up << endl ; cout << "pos:" << pos << endl ; */ /* OK cam(0,3) = 0 ; cam(1,3) = 0 ; cam(2,3) = -20 ; */ /* Oui, et non, apres quelques rotations de camera, le barycentre n'est plus centre. mytoolbox::dbgMsg( "pointRefRot:" << pointRefRot[0] << pointRefRot[1] ; cam(0,3) = -pointRefRot[0] ; cam(1,3) = -pointRefRot[1] ; cam(2,3) = -25 ; m_widget->camera()->setModelview(cam) ; */ Eigen::Vector3d barycenterScreen=m_widget->camera()->project( pointRef ) ; QPoint barycenterScreen2((int)barycenterScreen[0], (int)barycenterScreen[1]) ; GLint params[4] ; // Do not work (with .h and compilation flag, the final error is : ~"impossible to use without a first call of glinit"~). //int screen_pos_x = glutGet((GLenum)GLUT_WINDOW_X); //int screen_pos_y = glutGet((GLenum)GLUT_WINDOW_Y); //mytoolbox::dbgMsg( " :" << screen_pos_x << screen_pos_y ; glGetIntegerv( GL_VIEWPORT, params ) ; GLenum errCode ; const GLubyte *errString ; if( (errCode=glGetError()) != GL_NO_ERROR ) { errString = gluErrorString( errCode ) ; fprintf (stderr, "OpenGL Error: %s\n", errString); } GLdouble x=params[0] ; GLdouble y=params[1] ; GLdouble width=params[2] ; GLdouble height=params[3] ; QPoint widgetCenter( (int)((x+width)/2.0), (int)((y+height)/2.0) ) ; Navigate::translate( m_widget, pointRef, barycenterScreen2, widgetCenter ) ; Eigen::Transform3d cam=m_widget->camera()->modelview() ; cam(2,3) = -25 ; m_widget->camera()->setModelview(cam) ; } } /** * Transform a wrapper action to an Avogadro action : enable/disable the atom saturation. * @param wmavoAction All actions ask by the wrapper */ void WrapperChemicalCmdToAvoAction::transformWrapperActionToSaturateAtoms ( int wmavoAction ) { if( WMAVO_IS2(wmavoAction,WMAVO_SATURATE_ATOMS) ) { m_moleculeManip->invertHasAddHydrogen() ; } } /** * Transform a wrapper action to an context menu action. * @param wmavoAction All actions ask by the wrapper * @param posCursor The position of the cursor */ void WrapperChemicalCmdToAvoAction::transformWrapperActionToUseContextMenu( int &wmavoAction, const QPoint &posCursor ) { m_contextMenu->manageAction( wmavoAction, posCursor ) ; } /** * Update Avogadro according to the Avogadro actions realized. * Here, the update is for the Avogadro delete actions. * @param wmavoAction All actions ask by the wrapper */ void WrapperChemicalCmdToAvoAction::updateForAvoActions1( int wmavoAction ) { if( WMAVO_IS2(wmavoAction,WMAVO_DELETE) || WMAVO_IS2(wmavoAction,WMAVO_DELETEALL) /*|| WMAVO_IS2(wmavoAction,WMAVO_CREATE)*/ // Put in the transformWrapperActionToCreateAtomBond() method to // gain update during multiple creation. ) { //mytoolbox::dbgMsg( "WrapperChemicalCmdToAvoAction::updateForAvoActions1" ; // Update // If we have done stuff then trigger a redraw of the molecule m_widget->molecule()->update() ; /* // Not resolve an update problem ... m_widget->molecule()->update() ; m_widget->update() ; // update( &Region ), update( int, int, int, int ) ... m_widget->updateGeometry() ; m_widget->updateGL() ; m_widget->updateOverlayGL() ; m_widget->updatesEnabled() ; //m_widget->molecule()->updateAtom() ; m_widget->molecule()->updateMolecule() ; m_widget->molecule()->calculateGroupIndices() ; */ } } /** * Update Avogadro according to the Avogadro actions realized. * Here, the update is for a lot of Avogadro actions. * This is a special update, because it simulates a mouse click to realize update. * In fact, some optimization are available only when some Avogadro class realize * update. * <br/>To activate the quick render (the previous optimization) , it is necessary to simulate a mouse click. * Explanation, the quick render is activated when : * - Check the quick render option * Set (allowQuickRender) attribut to enable. Now Avogadro MAY accept * quick render. * - While a mouse movement, if the mouse is down * The call of GLWidget::mouseMoveEvent(), and only this method sets * the (quickRender) attribut at true. * * @param wmavoAction All actions ask by the wrapper */ void WrapperChemicalCmdToAvoAction::updateForAvoActions2( int wmavoAction ) { if( //(WMAVO_IS2(wmavoAction, WMAVO_MENU_ACTIVE) ? 0 // To update wmInfo in wmTool class // : 1 ) // To avoid a bug with periodic table. //|| WMAVO_IS2(wmavoAction,WMAVO_SELECT) || WMAVO_IS2(wmavoAction,WMAVO_SELECT_MULTI) || WMAVO_IS2(wmavoAction,WMAVO_CREATE) || WMAVO_IS2(wmavoAction,WMAVO_CAM_ROTATE) || WMAVO_IS2(wmavoAction,WMAVO_CAM_ZOOM) || WMAVO_IS2(wmavoAction,WMAVO_CAM_TRANSLATE) || WMAVO_IS2(wmavoAction,WMAVO_CAM_INITIAT) || m_needAnUpdateMore ) { //mytoolbox::dbgMsg( "WrapperChemicalCmdToAvoAction::updateForAvoActions2" ; if( m_needAnUpdateMore ) m_needAnUpdateMore = false ; if( !m_widget->quickRender() ) { // 1. No quick render. m_widget->update() ; } else { // 2. No compile : mouseMove is protected. // Call directly GLWidget->mouseMove signal. //emit m_widget->mouseMove(&me) ; // 3. Call directly Tool->mouseMouseEvent. No quick render. //m_widget->tool()->mouseMoveEvent( m_widget, &me) ; //m_widget->tool()->mouseMoveEvent( m_widget->current(), &me) ; // 4. Try Fake mouse event. WORKS !!! if( !m_testEventPress ) { m_testEventPress = true ; QApplication::sendEvent( m_widget->m_current, m_me1 ) ; } QApplication::sendEvent( m_widget->m_current, m_me2 ) ; // Test, but be carefull, you must allocate the event each time // it put in a queue, and delete the object after use. //QApplication::postEvent( app, me1 ) ; //QApplication::postEvent( app, me3 ) ; // Install something else. // 5. Try Fake mouse event. //qTestEventList events; //events.addMouseMove(p,1); //events.simulate(m_widget); } } else { // 4. Finish fake mouse event. if( m_widget->quickRender() && m_testEventPress ) { m_testEventPress = false ; QApplication::sendEvent( m_widget->m_current, m_me3 ) ; } } } /** * Update Avogadro according to the Avogadro actions realized. * Here, the update is for the Avogadro move actions. * @param wmavoAction All actions ask by the wrapper */ void WrapperChemicalCmdToAvoAction::updateForAvoActions3( int wmavoAction ) { if( WMAVO_IS2(wmavoAction,WMAVO_ATOM_MOVE) ) { // Object is in "travel mode", but just in the mode. // It is necessary to know what is the movement. if( (WMAVO_IS2(wmavoAction,WMAVO_ATOM_TRANSLATE) || WMAVO_IS2(wmavoAction,WMAVO_ATOM_ROTATE)) && m_widget->selectedPrimitives().size()>0 ) { //mytoolbox::dbgMsg( "WrapperChemicalCmdToAvoAction::updateForAvoActions3" ; // 1. No Quick Render. //m_widget->molecule()->update() ; // Update & Redraw (without quick Render) // 2. Quick Render seems activated, but it lags ... m_widget->molecule()->updateMolecule() ; // Update & Redraw. } } } /** * Calculate the transformation vector and/or matrix according to the need. * "Convert" the wiimote coordinate system to the Avogadro coordinate system. * @return TRUE if the transformation matrix is different to null ; FALSE else. * @param wmactions All actions ask by the wrapper * @param curPos The current position calculate by the Wiimote * @param lastPos The last position calculate by the Wiimote * @param refPoint_in The position of the reference point. * @param rotAtomdegX_in The desired X-axis angle * @param rotAtomdegY_in The desired Y-axis angle */ bool WrapperChemicalCmdToAvoAction::calculateTransformationMatrix ( int wmactions_in, const Eigen::Vector3d& curPos_in, const Eigen::Vector3d& lastPos_in, const Eigen::Vector3d& refPoint_in, double rotAtomdegX_in, double rotAtomdegY_in, Eigen::Vector3d &vectAtomTranslate_out, Eigen::Transform3d &transfAtomRotate_out ) { bool isMoved=false ; if( WMAVO_IS2(wmactions_in,WMAVO_ATOM_TRANSLATE) || WMAVO_IS2(wmactions_in,WMAVO_ATOM_ROTATE) ) { QPoint currentPoint((int)curPos_in[0], (int)curPos_in[1]) ; QPoint lastPoint((int)lastPos_in[0], (int)lastPos_in[1]) ; Eigen::Vector3d fromPos=m_widget->camera()->unProject( lastPoint, refPoint_in ) ; Eigen::Vector3d toPos=m_widget->camera()->unProject( currentPoint, refPoint_in ) ; Eigen::Vector3d camBackTransformedXAxis=m_widget->camera()->backTransformedXAxis() ; Eigen::Vector3d camBackTransformedYAxis=m_widget->camera()->backTransformedYAxis() ; Eigen::Vector3d camBackTransformedZAxis=m_widget->camera()->backTransformedZAxis() ; if( WMAVO_IS2(wmactions_in,WMAVO_ATOM_TRANSLATE) && !(curPos_in[0]==lastPos_in[0] && curPos_in[1]==lastPos_in[1]) ) { vectAtomTranslate_out = (toPos - fromPos) / WMAVO_ATOM_SMOOTHED_MOVE_XY ; //cout << "currentWmPos.x():" << currentWmPos.x() << " currentWmPos.y():" << currentWmPos.y() << endl ; //cout << " lastWmPos.x():" << lastWmPos.x() << " lastWmPos.y():" << lastWmPos.y() << endl ; //cout << " fromPos[0]:" << fromPos[0] << " fromPos[1]:" << fromPos[1] << " fromPos[2]:" << fromPos[2] << endl ; //cout << " toPos[0]:" << toPos[0] << " toPos[1]:" << toPos[1] << " fromPos[2]:" << fromPos[2] << endl ; //cout << " newVectAtomTranslate:" << m_vectAtomTranslate[0] << " " << m_vectAtomTranslate[1] << " " << m_vectAtomTranslate[2] << endl ; if( WMAVO_IS2(wmactions_in,WMAVO_ATOM_TRANSLATE) ) { // Z-movement. if( (curPos_in[2]-lastPos_in[2]) <= -WMAVO_WM_Z_MINPOINTING_MOVEALLOWED ) vectAtomTranslate_out += (camBackTransformedZAxis*WMAVO_ATOM_MAX_MOVE_Z) ; if( (curPos_in[2]-lastPos_in[2]) >= WMAVO_WM_Z_MINPOINTING_MOVEALLOWED ) vectAtomTranslate_out -= (camBackTransformedZAxis*WMAVO_ATOM_MAX_MOVE_Z) ; } isMoved = true ; //cout << " m_vectAtomTranslate:" << m_vectAtomTranslate[0] << " " << m_vectAtomTranslate[1] << " " << m_vectAtomTranslate[2] << endl ; } else if( WMAVO_IS2(wmactions_in,WMAVO_ATOM_ROTATE) ) { Eigen::Vector3d rotAxe=m_moleculeManip->getRotationAxe() ; if( m_tmpBarycenter == m_vect3d0 ) { // Calculate the barycenter of selected atoms. Eigen::Vector3d tmp=m_vect3d0 ; int i=0 ; Atom *a=NULL ; foreach( Primitive *p, m_widget->selectedPrimitives() ) { if( p->type() == Primitive::AtomType ) { a = static_cast<Atom*>(p) ; tmp += *(a->pos()) ; i++ ; } } m_tmpBarycenter = tmp / i ; } if( rotAxe != m_vect3d0 ) { Eigen::Vector3d rotAxePoint=m_moleculeManip->getRotationAxePoint() ; // Rotate the selected atoms about the center // rotate only selected primitives transfAtomRotate_out.matrix().setIdentity(); // Return to the center of the 3D-space. transfAtomRotate_out.translation() = rotAxePoint ; // Apply rotations. transfAtomRotate_out.rotate( Eigen::AngleAxisd( (rotAtomdegX_in/90.0)* 0.1, rotAxe) ) ; // /90.0 => Eliminate the initial 90° rotation by the Wiimote, // then to apply a step (in unknown metric). transfAtomRotate_out.rotate( Eigen::AngleAxisd( (rotAtomdegY_in/90.0)*-0.1, rotAxe ) ) ; // Return to the object. transfAtomRotate_out.translate( -rotAxePoint ) ; } else { // Rotation around the barycenter. // Rotate the selected atoms about the center // rotate only selected primitives transfAtomRotate_out.matrix().setIdentity(); // Return to the center of the 3D-space. transfAtomRotate_out.translation() = m_tmpBarycenter ; // Apply rotations. transfAtomRotate_out.rotate( Eigen::AngleAxisd( (rotAtomdegX_in/90.0)* 0.1, camBackTransformedYAxis) ) ; // /90.0 => Eliminate the initial 90° rotation by the Wiimote, // then to apply a step (in unknown metric). transfAtomRotate_out.rotate( Eigen::AngleAxisd( (rotAtomdegY_in/90.0)*-0.1, camBackTransformedXAxis) ) ; // Return to the object. transfAtomRotate_out.translate( -m_tmpBarycenter ) ; } isMoved = true ; } else { // Put all transformation "at zero". transfAtomRotate_out.matrix().setIdentity(); transfAtomRotate_out.translation() = m_vect3d0 ; vectAtomTranslate_out[0] = 0.0 ; vectAtomTranslate_out[1] = 0.0 ; vectAtomTranslate_out[2] = 0.0 ; isMoved = false ; } } return isMoved ; } /** * Receive the "calcul distance" feature from the WmTool class.. */ void WrapperChemicalCmdToAvoAction::receiveRequestToCalculDistance() { m_isCalculDistDiedre = true ; } }
[ "mickael.gadroy@gmail.com", "myck@myck-debian-i386.univ-reims.fr" ]
[ [ [ 1, 141 ], [ 144, 253 ], [ 256, 256 ], [ 259, 262 ], [ 264, 267 ], [ 276, 278 ], [ 280, 282 ], [ 284, 288 ], [ 291, 295 ], [ 301, 302 ], [ 304, 322 ], [ 325, 325 ], [ 328, 338 ], [ 342, 1483 ], [ 1486, 1504 ], [ 1508, 1509 ], [ 1513, 1513 ], [ 1515, 1515 ], [ 1527, 1527 ], [ 1552, 1579 ] ], [ [ 142, 143 ], [ 254, 255 ], [ 257, 258 ], [ 263, 263 ], [ 268, 275 ], [ 279, 279 ], [ 283, 283 ], [ 289, 290 ], [ 296, 300 ], [ 303, 303 ], [ 323, 324 ], [ 326, 327 ], [ 339, 341 ], [ 1484, 1485 ], [ 1505, 1507 ], [ 1510, 1512 ], [ 1514, 1514 ], [ 1516, 1526 ], [ 1528, 1551 ] ] ]
a7c2d371a8662864421098ac237ce6d3c4331ef9
a96b15c6a02225d27ac68a7ed5f8a46bddb67544
/SetGame/Application.hpp
76fef5eec3e63653410a8dbaf3329aa344342995
[]
no_license
joelverhagen/Gaza-2D-Game-Engine
0dca1549664ff644f61fe0ca45ea6efcbad54591
a3fe5a93e5d21a93adcbd57c67c888388b402938
refs/heads/master
2020-05-15 05:08:38
2011-04-03 22:22:01
2011-04-03 22:22:01
1,519,417
3
0
null
null
null
null
UTF-8
C++
false
false
511
hpp
#ifndef APPLICATION_HPP #define APPLICATION_HPP #include "Common.hpp" #include "GazaApplication.hpp" #include "GazaFrameSheet.hpp" #include "GazaImageManager.hpp" #include "GazaLogger.hpp" #include "GameState.hpp" #include "CardFrameSheetGenerator.hpp" class Application : public Gaza::Application { public: Application(); ~Application(); Gaza::ImageManager * getImageManager(); private: Gaza::ImageManager imageManager; Gaza::FrameSheetCollection * cardFrames; }; #endif
[ "joel.verhagen@gmail.com" ]
[ [ [ 1, 28 ] ] ]
cf2a06f81eb7045b31dd1a84c6a824280a9ec8aa
ea72aac3344f9474a0ba52c90ed35e24321b025d
/PathFinding/PathFinding/PathFinding.cpp
ee86e175b6437840cdb4904cdd62c789f72b837e
[]
no_license
nlelouche/ia-2009
3bd7f1e42280001024eaf7433462b2949858b1c2
44c07567c3b74044e59313532b5829f3a3466a32
refs/heads/master
2020-05-17 02:21:02
2009-03-31 01:12:44
2009-03-31 01:12:44
32,657,337
0
0
null
null
null
null
UTF-8
C++
false
false
2,208
cpp
#include "PathFinding.h" //-------------------------------------------------------------- PathFind::PathFind(int * _map[],int _rows,int _cols) : m_pkPath(NULL), m_pkClosedNodes(NULL), m_pkOpenNodes(NULL), m_CurrentNode(NULL), m_pkiPathIT(0), m_pkOpenNodesIT(0), m_pkClosedNodesIT(0) { // Copiamos el mapa pasado a un mapa fijo. for (int i = 0; i > LARGO_MAPA; i++){ m_Map[i] = (int)_map[i]; } /***/ } //-------------------------------------------------------------- PathFind::~PathFind(){ /***/ } //-------------------------------------------------------------- void PathFind::OpenNodes(Node * _node){ // m_pkOpenNodes.insert(_node); // Insertar nodo en la lista /***/ } //-------------------------------------------------------------- void PathFind::CloseNode(Node * _node){ /***/ } //-------------------------------------------------------------- bool PathFind::ExistOpenNodes(){ /***/ return false; } //-------------------------------------------------------------- bool PathFind::IsExitNode(Node *_node){ /***/ return false; } //-------------------------------------------------------------- Node * PathFind::LessValueNode(){ /***/ return m_CurrentNode; } //-------------------------------------------------------------- list<Node*> PathFind::GenerarCamino(){ /***/ return m_pkPath; } //-------------------------------------------------------------- bool PathFind::IsEndingNode(Node * _node){ return false; } //-------------------------------------------------------------- void PathFind::CalculateMap(Node * _initialNode, Node * _endingNode){ // Copiamos Posicion X,Y de nodos inicial y destino. //m_InitialPosition.Initial_X = _initial.Initial_X; //m_InitialPosition.Initial_Y = _initial.Initial_Y; //m_EndingPosition.Ending_X = _ending.Ending_X; //m_EndingPosition.Ending_Y = _ending.Ending_Y; OpenNodes(_initialNode); while (ExistOpenNodes()){ m_CurrentNode = LessValueNode(); if (IsEndingNode(m_CurrentNode)){ //GenerarCamino(); } else { CloseNode(m_CurrentNode); OpenNodes(m_CurrentNode); } } } //--------------------------------------------------------------
[ "calaverax@bb2752b8-1d7e-11de-9d52-39b120432c5d" ]
[ [ [ 1, 84 ] ] ]
e26d12af72425b08369187d42732ce82d4a10cea
709cd826da3ae55945fd7036ecf872ee7cdbd82a
/Term/WildMagic2/Source/Intersection/WmlIntrTri3Con3.cpp
a0d5a7f4353d6bec1785653a15cf4f674bd4a8f5
[]
no_license
argapratama/kucgbowling
20dbaefe1596358156691e81ccceb9151b15efb0
65e40b6f33c5511bddf0fa350c1eefc647ace48a
refs/heads/master
2018-01-08 15:27:44
2011-06-19 15:23:39
2011-06-19 15:23:39
36,738,655
0
0
null
null
null
null
UTF-8
C++
false
false
10,534
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 "WmlIntrTri3Con3.h" using namespace Wml; //---------------------------------------------------------------------------- template <class Real> bool Wml::TestIntersection (const Triangle3<Real>& rkTri, const Cone3<Real>& rkCone) { // NOTE. The following quantities computed in this function can be // precomputed and stored in the cone and triangle classes as an // optimization. // 1. The cone squared cosine. // 2. The triangle squared edge lengths |E0|^2 and |E1|^2. // 3. The third triangle edge E2 = E1 - E0 and squared length |E2|^2. // 4. The triangle normal N = Cross(E0,E1) or unitized normal // N = Cross(E0,E1)/Length(Cross(E0,E1)). // triangle is <P0,P1,P2>, edges are E0 = P1-P0, E1=P2-P0 int iOnConeSide = 0; Real fP0Test, fP1Test, fP2Test, fAdE, fEdE, fEdD, fC1, fC2; Real fCosSqr = rkCone.CosAngle()*rkCone.CosAngle(); // test vertex P0 Vector3<Real> kDiff0 = rkTri.Origin() - rkCone.Vertex(); Real fAdD0 = rkCone.Axis().Dot(kDiff0); if ( fAdD0 >= (Real)0.0 ) { // P0 is on cone side of plane fP0Test = fAdD0*fAdD0 - fCosSqr*(kDiff0.Dot(kDiff0)); if ( fP0Test >= (Real)0.0 ) { // P0 is inside the cone return true; } else { // P0 is outside the cone, but on cone side of plane iOnConeSide |= 1; } } // else P0 is not on cone side of plane // test vertex P1 Vector3<Real> kDiff1 = kDiff0 + rkTri.Edge0(); Real fAdD1 = rkCone.Axis().Dot(kDiff1); if ( fAdD1 >= (Real)0.0 ) { // P1 is on cone side of plane fP1Test = fAdD1*fAdD1 - fCosSqr*(kDiff1.Dot(kDiff1)); if ( fP1Test >= (Real)0.0 ) { // P1 is inside the cone return true; } else { // P1 is outside the cone, but on cone side of plane iOnConeSide |= 2; } } // else P1 is not on cone side of plane // test vertex P2 Vector3<Real> kDiff2 = kDiff0 + rkTri.Edge1(); Real fAdD2 = rkCone.Axis().Dot(kDiff2); if ( fAdD2 >= (Real)0.0 ) { // P2 is on cone side of plane fP2Test = fAdD2*fAdD2 - fCosSqr*(kDiff2.Dot(kDiff2)); if ( fP2Test >= (Real)0.0 ) { // P2 is inside the cone return true; } else { // P2 is outside the cone, but on cone side of plane iOnConeSide |= 4; } } // else P2 is not on cone side of plane // test edge <P0,P1> = E0 if ( iOnConeSide & 3 ) { fAdE = fAdD1 - fAdD0; fEdE = rkTri.Edge0().Dot(rkTri.Edge0()); fC2 = fAdE*fAdE - fCosSqr*fEdE; if ( fC2 < (Real)0.0 ) { fEdD = rkTri.Edge0().Dot(kDiff0); fC1 = fAdE*fAdD0 - fCosSqr*fEdD; if ( iOnConeSide & 1 ) { if ( iOnConeSide & 2 ) { // <P0,P1> fully on cone side of plane, fC0 = fP0Test if ( (Real)0.0 <= fC1 && fC1 <= -fC2 && fC1*fC1 >= fP0Test*fC2 ) { return true; } } else { // P0 on cone side (Dot(A,P0-V) >= 0), // P1 on opposite side (Dot(A,P1-V) <= 0) // (Dot(A,E0) <= 0), fC0 = fP0Test if ( (Real)0.0 <= fC1 && fC2*fAdD0 <= fC1*fAdE && fC1*fC1 >= fP0Test*fC2 ) { return true; } } } else { // P1 on cone side (Dot(A,P1-V) >= 0), // P0 on opposite side (Dot(A,P0-V) <= 0) // (Dot(A,E0) >= 0), fC0 = fP0Test (needs calculating) if ( fC1 <= -fC2 && fC2*fAdD0 <= fC1*fAdE ) { fP0Test = fAdD0*fAdD0 - fCosSqr*(kDiff0.Dot(kDiff0)); if ( fC1*fC1 >= fP0Test*fC2 ) return true; } } } } // else <P0,P1> does not intersect cone half space // test edge <P0,P2> = E1 if ( iOnConeSide & 5 ) { fAdE = fAdD2 - fAdD0; fEdE = rkTri.Edge1().Dot(rkTri.Edge1()); fC2 = fAdE*fAdE - fCosSqr*fEdE; if ( fC2 < (Real)0.0 ) { fEdD = rkTri.Edge1().Dot(kDiff0); fC1 = fAdE*fAdD0 - fCosSqr*fEdD; if ( iOnConeSide & 1 ) { if ( iOnConeSide & 4 ) { // <P0,P2> fully on cone side of plane, fC0 = fP0Test if ( (Real)0.0 <= fC1 && fC1 <= -fC2 && fC1*fC1 >= fP0Test*fC2 ) { return true; } } else { // P0 on cone side (Dot(A,P0-V) >= 0), // P2 on opposite side (Dot(A,P2-V) <= 0) // (Dot(A,E1) <= 0), fC0 = fP0Test if ( (Real)0.0 <= fC1 && fC2*fAdD0 <= fC1*fAdE && fC1*fC1 >= fP0Test*fC2 ) { return true; } } } else { // P2 on cone side (Dot(A,P2-V) >= 0), // P0 on opposite side (Dot(A,P0-V) <= 0) // (Dot(A,E1) >= 0), fC0 = fP0Test (needs calculating) if ( fC1 <= -fC2 && fC2*fAdD0 <= fC1*fAdE ) { fP0Test = fAdD0*fAdD0 - fCosSqr*(kDiff0.Dot(kDiff0)); if ( fC1*fC1 >= fP0Test*fC2 ) return true; } } } } // else <P0,P2> does not intersect cone half space // test edge <P1,P2> = E1-E0 = E2 if ( iOnConeSide & 6 ) { Vector3<Real> kE2 = rkTri.Edge1() - rkTri.Edge0(); fAdE = fAdD2 - fAdD1; fEdE = kE2.Dot(kE2); fC2 = fAdE*fAdE - fCosSqr*fEdE; if ( fC2 < (Real)0.0 ) { fEdD = kE2.Dot(kDiff1); fC1 = fAdE*fAdD1 - fCosSqr*fEdD; if ( iOnConeSide & 2 ) { if ( iOnConeSide & 4 ) { // <P1,P2> fully on cone side of plane, fC0 = fP1Test if ( (Real)0.0 <= fC1 && fC1 <= -fC2 && fC1*fC1 >= fP1Test*fC2 ) { return true; } } else { // P1 on cone side (Dot(A,P1-V) >= 0), // P2 on opposite side (Dot(A,P2-V) <= 0) // (Dot(A,E2) <= 0), fC0 = fP1Test if ( (Real)0.0 <= fC1 && fC2*fAdD1 <= fC1*fAdE && fC1*fC1 >= fP1Test*fC2 ) { return true; } } } else { // P2 on cone side (Dot(A,P2-V) >= 0), // P1 on opposite side (Dot(A,P1-V) <= 0) // (Dot(A,E2) >= 0), fC0 = fP1Test (needs calculating) if ( fC1 <= -fC2 && fC2*fAdD1 <= fC1*fAdE ) { fP1Test = fAdD1*fAdD1 - fCosSqr*(kDiff1.Dot(kDiff1)); if ( fC1*fC1 >= fP1Test*fC2 ) return true; } } } } // else <P1,P2> does not intersect cone half space // Test triangle <P0,P1,P2>. It is enough to handle only the case when // at least one Pi is on the cone side of the plane. In this case and // after the previous testing, if the triangle intersects the cone, the // set of intersection must contain the point of intersection between // the cone axis and the triangle. if ( iOnConeSide > 0 ) { Vector3<Real> kN = rkTri.Edge0().Cross(rkTri.Edge1()); Real fNdA = kN.Dot(rkCone.Axis()); Real fNdD = kN.Dot(kDiff0); Vector3<Real> kU = fNdD*rkCone.Axis() - fNdA*kDiff0; Vector3<Real> kNcU = kN.Cross(kU); Real fNcUdE0 = kNcU.Dot(rkTri.Edge0()), fNcUdE1, fNcUdE2, fNdN; if ( fNdA >= (Real)0.0 ) { if ( fNcUdE0 <= (Real)0.0 ) { fNcUdE1 = kNcU.Dot(rkTri.Edge1()); if ( fNcUdE1 >= (Real)0.0 ) { fNcUdE2 = fNcUdE1 - fNcUdE0; fNdN = kN.SquaredLength(); if ( fNcUdE2 <= fNdA*fNdN ) return true; } } } else { if ( fNcUdE0 >= (Real)0.0 ) { fNcUdE1 = kNcU.Dot(rkTri.Edge1()); if ( fNcUdE1 <= (Real)0.0 ) { fNcUdE2 = fNcUdE1 - fNcUdE0; fNdN = kN.SquaredLength(); if ( fNcUdE2 >= fNdA*fNdN ) return true; } } } } return false; } //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- // explicit instantiation //---------------------------------------------------------------------------- namespace Wml { template WML_ITEM bool TestIntersection<float> ( const Triangle3<float>&, const Cone3<float>&); template WML_ITEM bool TestIntersection<double> ( const Triangle3<double>&, const Cone3<double>&); } //----------------------------------------------------------------------------
[ "pocatnas@gmail.com" ]
[ [ [ 1, 301 ] ] ]
c7e21c79ce487e3bac74a8bd5a338c49635898f6
9df55ed98688ff13caec3061237a2a0895914577
/main.cpp
bd29e05649bceeeba97307229ac0bcc781176516
[]
no_license
tiashaun/sdl_tetris
f625ee0f06e642411f7a04b18b470aa0df61c1ca
4799cfa4b28cd21b8431f8b6a00bacfb89e794f0
refs/heads/master
2020-11-30 23:32:43
2009-12-06 20:33:43
2009-12-06 20:33:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
165
cpp
#include <iostream> #include <SDL/SDL.h> #include "Game.h" int main(int argc, char* argv[]) { Game *game = new Game(); game->startGame(); return 0; }
[ "jarod.luebbert@gmail.com" ]
[ [ [ 1, 10 ] ] ]
c6ae62bae17c0ec324ca0aa0d67cbb08a72dce4d
b08e948c33317a0a67487e497a9afbaf17b0fc4c
/Display/Font.h
03d4940ce4ff0bfd662810249e01fff5b4dea7da
[]
no_license
15831944/bastionlandscape
e1acc932f6b5a452a3bd94471748b0436a96de5d
c8008384cf4e790400f9979b5818a5a3806bd1af
refs/heads/master
2023-03-16 03:28:55
2010-05-21 15:00:07
2010-05-21 15:00:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,208
h
#ifndef __FONT_H__ #define __FONT_H__ #include "../Display/Display.h" namespace ElixirEngine { //----------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- class DisplayFontText : public DisplayObject { public: DisplayFontText(); virtual ~DisplayFontText(); virtual void SetText(const wstring& _wstrText) = 0; virtual void SetColor(const Vector4& _f4Color) = 0; }; //----------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- class DisplayFont : public CoreObject { public: DisplayFont(DisplayFontManagerRef _rFontManager); virtual ~DisplayFont(); virtual DisplayFontTextPtr CreateText() = 0; virtual void ReleaseText(DisplayFontTextPtr _pText) = 0; virtual DisplayRef GetDisplay() = 0; protected: DisplayFontManagerRef m_rFontManager; }; //----------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- class DisplayFontLoader : public CoreObject { public: DisplayFontLoader(DisplayFontManagerRef _rFontManager); virtual ~DisplayFontLoader(); virtual DisplayFontPtr Load(const string& _strFileName) = 0; virtual void Unload(DisplayFontPtr _pFont) = 0; protected: DisplayFontManagerRef m_rFontManager; }; //----------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- class DisplayFontManager : public CoreObject { public: DisplayFontManager(DisplayRef _rDisplay); virtual ~DisplayFontManager(); virtual bool Create(const boost::any& _rConfig); virtual void Update(); virtual void Release(); bool Load(const Key& _uNameKey, const string& _strFileName); void Unload(const Key& _uNameKey); DisplayFontPtr Get(const Key& _uNameKey); DisplayRef GetDisplay(); protected: struct Link { Link(); Link(DisplayFontPtr _pFont, DisplayFontLoaderPtr _pLoader); DisplayFontPtr m_pFont; DisplayFontLoaderPtr m_pLoader; }; typedef map<Key, Link> LinkMap; protected: bool RegisterLoader(const Key& _uExtensionKey, DisplayFontLoaderPtr _pLoader); void UnregisterLoader(const Key& _uExtensionKey); DisplayFontLoaderPtr GetLoader(const Key& _uExtensionKey); protected: DisplayRef m_rDisplay; LinkMap m_mFonts; DisplayFontLoaderPtrMap m_mLoaders; }; } #endif
[ "voodoohaust@97c0069c-804f-11de-81da-11cc53ed4329" ]
[ [ [ 1, 100 ] ] ]
83184b7823427dbb500e80b21cc18d05f9552848
406b4b18f5c58c689d2324f49db972377fe8feb6
/ANE/Include/Memory/IMemoryPool.h
cd118b1a3cd79d2f003a329221fb47c1e0b00b8c
[]
no_license
Mobiwoom/ane
e17167de36699c451ed92eab7bf733e7d41fe847
ec20667c556a99351024f3ae9c8880e944c5bfbd
refs/heads/master
2021-01-17 13:09:57
2010-03-23 16:30:17
2010-03-23 16:30:17
33,132,357
0
1
null
null
null
null
UTF-8
C++
false
false
258
h
#pragma once namespace Ane { class IMemoryPool { public: IMemoryPool(){} virtual ~IMemoryPool(){} virtual void* Alloc() = 0; virtual void* Alloc(unsigned int Size) = 0; virtual void Free(void* pMemory) = 0; }; }
[ "inthejm@5abed23c-1faa-11df-9e62-c93c6248c2ac" ]
[ [ [ 1, 14 ] ] ]
01e8ec44b80deffdd92d33706685a9deabbffac3
ea12fed4c32e9c7992956419eb3e2bace91f063a
/zombie/code/zombie/nscene/src/nscene/nsurfacenode_main.cc
74d5e83ef12b4c20b501095b24518e59c6cfe3b1
[]
no_license
ugozapad/TheZombieEngine
832492930df28c28cd349673f79f3609b1fe7190
8e8c3e6225c2ed93e07287356def9fbdeacf3d6a
refs/heads/master
2020-04-30 11:35:36
2011-02-24 14:18:43
2011-02-24 14:18:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,575
cc
#include "precompiled/pchnscene.h" //------------------------------------------------------------------------------ // nsurfacenode_main.cc // (C) 2002 RadonLabs GmbH //------------------------------------------------------------------------------ #include "nscene/nsurfacenode.h" #include "nscene/nsceneshader.h" #include "nscene/nscenegraph.h" #include "nscene/nshadertree.h" #include "gfx2/ngfxserver2.h" #include "gfx2/nshader2.h" #include "gfx2/ntexture2.h" #include "kernel/ntimeserver.h" #include "nscene/ncscene.h" #include "entity/nentity.h" #include "kernel/ndebug.h" #include "nscene/nanimator.h" nNebulaScriptClass(nSurfaceNode, "nabstractshadernode"); //------------------------------------------------------------------------------ /** */ nSurfaceNode::nSurfaceNode() : shaderArray(4, 4) { // empty } //------------------------------------------------------------------------------ /** */ nSurfaceNode::~nSurfaceNode() { this->UnloadResources(); } //------------------------------------------------------------------------------ /** Unload all shaders. */ void nSurfaceNode::UnloadShaders() { int i; for (i = 0; i < this->shaderArray.Size(); i++) { if (this->shaderArray[i].IsShaderValid()) { this->shaderArray[i].GetShader()->Release(); this->shaderArray[i].Invalidate(); } } for (i = 0; i < this->shaderTreeArray.Size(); ++i) { if (this->shaderTreeArray[i].isvalid()) { this->shaderTreeArray[i]->Release(); this->shaderTreeArray[i].invalidate(); } } } //------------------------------------------------------------------------------ /** Load shader resources. */ bool nSurfaceNode::LoadShaders() { // load shaders int i; for (i = 0; i < this->shaderArray.Size(); i++) { ShaderEntry& shaderEntry = this->shaderArray[i]; if (!shaderEntry.IsShaderValid() && shaderEntry.GetName()) { #if 0 // keep this commented while the shader database is not used // try to get shader by name from shader repository int shaderIndex = nSceneServer::Instance()->FindShader(shaderEntry.GetName()); if (shaderIndex != -1) { nSceneShader& sceneShader = nSceneServer::Instance()->GetShaderAt(shaderIndex); if (!sceneShader.IsValid()) { sceneShader.Validate(); n_assert(sceneShader.IsValid()); } sceneShader.GetShaderObject()->AddRef(); shaderEntry.SetShaderIndex(shaderIndex); shaderEntry.SetShader(sceneShader.GetShaderObject()); } else #endif { // create a new empty shader object nShader2* shd = nGfxServer2::Instance()->NewShader(shaderEntry.GetName()); n_assert(shd); if (!shd->IsLoaded()) { // load shader resource file shd->SetFilename(shaderEntry.GetName()); } if (shd) { // register shader object in scene shader database nSceneShader sceneShader; sceneShader.SetShader(shaderEntry.GetName());// filename sceneShader.SetShaderName(shaderEntry.GetName());// shader name int shaderIndex = nSceneServer::Instance()->FindShader(shaderEntry.GetName()); if (shaderIndex == -1) { shaderIndex = nSceneServer::Instance()->AddShader(sceneShader); n_assert(shaderIndex != -1); } // set shader object and index for local entry shaderEntry.SetShader(shd); shaderEntry.shaderIndex = shaderIndex; // create a degenerate decision tree for use in the render path nShaderTree* shaderTree = static_cast<nShaderTree*>( kernelServer->New("nshadertree") ); n_assert( shaderTree ); shaderTree->BeginNode( nVariable::InvalidHandle, 0 ); shaderTree->SetShaderObject( shd ); shaderTree->SetShaderIndexAt( 0, shaderIndex ); shaderTree->EndNode(); this->shaderTreeArray.Set( shaderEntry.GetPassIndex(), shaderTree ); } } } } return true; } //------------------------------------------------------------------------------ /** Load the resources needed by this object. */ bool nSurfaceNode::LoadResources() { if (this->LoadShaders()) { if (nAbstractShaderNode::LoadResources()) { return true; } } return false; } //------------------------------------------------------------------------------ /** Unload the resources if refcount has reached zero. */ void nSurfaceNode::UnloadResources() { nAbstractShaderNode::UnloadResources(); this->UnloadShaders(); } //------------------------------------------------------------------------------ /** Find shader object associated with fourcc code. */ nSurfaceNode::ShaderEntry* nSurfaceNode::FindShaderEntry(nFourCC fourcc) const { int i; int numShaders = this->shaderArray.Size(); for (i = 0; i < numShaders; i++) { ShaderEntry& shaderEntry = this->shaderArray[i]; if (shaderEntry.GetFourCC() == fourcc) { return &shaderEntry; } } // fallthrough: no loaded shader matches this fourcc code return 0; } //------------------------------------------------------------------------------ /** Return number of levels. */ int nSurfaceNode::GetNumLevels() { return (this->shaderArray.Size() > 0) ? 1 : 0; } //------------------------------------------------------------------------------ /** Return number of passes for a level */ int nSurfaceNode::GetNumLevelPasses(int /*level*/) { return this->shaderArray.Size(); } //------------------------------------------------------------------------------ /** Return number of passes for a level */ int nSurfaceNode::GetLevelPassIndex(int level, int pass) { n_assert_return((level == 0) && (pass < this->shaderArray.Size()), -1); return this->shaderArray[pass].GetPassIndex(); } //------------------------------------------------------------------------------ /** */ nShaderTree* nSurfaceNode::GetShaderTree(int /*level*/, int passIndex) { n_assert(passIndex < this->shaderTreeArray.Size()); return this->shaderTreeArray[passIndex]; } //------------------------------------------------------------------------------ /** */ void nSurfaceNode::SetShader(nFourCC fourcc, const char* name) { n_assert(name); ShaderEntry* shaderEntry = this->FindShaderEntry(fourcc); if (shaderEntry) { shaderEntry->Invalidate(); shaderEntry->SetName(name); } else { ShaderEntry newShaderEntry(fourcc, name); this->shaderArray.Append(newShaderEntry); } } //------------------------------------------------------------------------------ /** */ const char* nSurfaceNode::GetShader(nFourCC fourcc) const { ShaderEntry* shaderEntry = this->FindShaderEntry(fourcc); if (shaderEntry) { return shaderEntry->GetName(); } else { return 0; } } //------------------------------------------------------------------------------ /** */ bool nSurfaceNode::IsTextureUsed(nShaderState::Param /*param*/) { #if 0 // check in all shaders if anywhere the texture specified by param is used int i; int numShaders = this->shaderArray.Size(); for (i = 0; i < numShaders; i++) { const ShaderEntry& shaderEntry = this->shaderArray[i]; // first be sure that the shader entry could be loaded if (shaderEntry.IsShaderValid()) { nShader2* shader = shaderEntry.GetShader(); if (shader->IsParameterUsed(param)) { return true; } } } // fallthrough: texture not used by any shader return false; #else return true; #endif } //------------------------------------------------------------------------------ /** Setup shader attributes before rendering instances of this scene node. FIXME */ bool nSurfaceNode::Apply(nSceneGraph* sceneGraph) { n_assert(sceneGraph); int shaderIndex = sceneGraph->GetShaderIndex(); if (shaderIndex != -1) { nSceneShader& sceneShader = nSceneServer::Instance()->GetShaderAt(shaderIndex); nGfxServer2::Instance()->SetShader(sceneShader.GetShaderObject()); nAbstractShaderNode::Apply(sceneGraph); return true; } return false; } //------------------------------------------------------------------------------ /** Update shader and set as current shader in the gfx server. - 15-Jan-04 floh AreResourcesValid()/LoadResources() moved to scene server */ bool nSurfaceNode::Render(nSceneGraph* sceneGraph, nEntityObject* entityObject) { n_assert(sceneGraph); n_assert(entityObject); //nShader2* shader = nSceneServer::Instance()->GetShaderAt(sceneGraph->GetShaderIndex()).GetShaderObject(); // invoke shader manipulators this->InvokeAnimators(entityObject); /* //nGfxServer2* gfxServer = nGfxServer2::Instance(); // set texture transforms (that can be animated) //n_assert(nGfxServer2::MaxTextureStages >= 4); static matrix44 m; this->textureTransform[0].getmatrix44(m); gfxServer->SetTransform(nGfxServer2::Texture0, m); this->textureTransform[1].getmatrix44(m); gfxServer->SetTransform(nGfxServer2::Texture1, m); */ // transfer the rest of per-instance (animated, overriden) parameters // per instance-set parameters are handled at Apply() // also, shader overrides are handled at nGeometryNode::Render() nAbstractShaderNode::Render(sceneGraph, entityObject); return true; }
[ "magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91" ]
[ [ [ 1, 353 ] ] ]
4bd2d3863e213b995ce4c797f69651b760fb6ceb
be0db8bf2276da4b71a67723bbe8fb75e689bacb
/Src/App/init.cpp
d888c01b5df8390fb58162ef1efbd36db997300d
[]
no_license
jy02140486/cellwarfare
21a8eb793b94b8472905d793f4b806041baf57bb
85f026efd03f12dd828817159b9821eff4e4aff0
refs/heads/master
2020-12-24 15:22:58
2011-07-24 12:36:45
2011-07-24 12:36:45
32,970,508
0
0
null
null
null
null
UTF-8
C++
false
false
6,030
cpp
#include "app.h" #include "event.h" #include <time.h> bool T_App::init() { try { //initail window description mWinDesc.set_title("CellWarfare"); mWinDesc.set_allow_resize(true); mWinDesc.set_size(CL_Size (800, 600), false); CL_String resource("../Res/GUITheme/resources.xml"); CL_String theme("../Res/GUITheme/theme.css"); //initail resource manager mResManager.load(resource); ////initail gui theme mGUITheme.set_resources(mResManager); //initail gui mpDisplayWindow = new CL_DisplayWindow(mWinDesc); mpWinManager = new CL_GUIWindowManagerTexture(*mpDisplayWindow); mGui.set_window_manager(*mpWinManager); mGui.set_theme(mGUITheme); mGui.set_css_document(theme); mpWinManager->func_repaint().set(this, &T_App::render); //initail GUIComponet window CL_DisplayWindowDescription comWindowDesc; comWindowDesc.show_border(false); comWindowDesc.set_allow_resize(true); comWindowDesc.set_title("settings"); comWindowDesc.set_size(CL_Size(300, 570),false); comWindowDesc.set_allow_resize(true); comWindowDesc.set_layered(true); mpComWindow = new CL_Window(&mGui, comWindowDesc); mpComWindow->set_draggable(false); //initail events mInput = mpDisplayWindow->get_ic(); mKeyboard = mInput.get_keyboard(); mMouse = mInput.get_mouse(); //mJoystick = mInput.get_joystick(); mpConsole = new CL_ConsoleWindow("Console", 80, 100); entites=new EM(); entites->iniLVs(); words=new CL_Font(mpComWindow->get_gc(),"Tahoma",20); offset.x=320; offset.y=420; entites->initScrObjs(); body=new CL_Image(mpDisplayWindow->get_gc(),"../res/body.png"); stage_clear=new CL_Image(mpDisplayWindow->get_gc(),"../res/stage clear.png"); if(RandomVal::randombool()) gameover=new CL_Image(mpDisplayWindow->get_gc(),"../res/gameover2.png"); else gameover=new CL_Image(mpDisplayWindow->get_gc(),"../res/gameover.png"); all_clear=new CL_Image(mpDisplayWindow->get_gc(),"../res/allclear.png"); //init menu items mx=new CL_LineEdit(mpComWindow); mx->set_geometry(CL_Rect(40,40, CL_Size(80, 20))); my=new CL_LineEdit(mpComWindow); my->set_geometry(CL_Rect(40,80, CL_Size(80, 20))); cirfirm=new CL_PushButton(mpComWindow); cirfirm->set_text("enter"); cirfirm->set_geometry(CL_Rect(40,500, CL_Size(150, 30))); cirfirm->func_clicked().set(this,&T_App::ButtonClick); PainKiller=new CL_PushButton(mpComWindow); PainKiller->set_text("PainKiller"); PainKiller->set_geometry(CL_Rect(40,540, CL_Size(100, 20))); PainKiller->func_clicked().set(this,&T_App::takePill); CL_Point lboffset(10,10); CL_Size sspin(80,20); CL_Size slb(80,20); infoBF=new CL_Label(mpComWindow); infoBF->set_geometry(CL_Rect(10,110, CL_Size(290, 300))); infoBF->set_text("infobf"); infoBF->set_visible(false); lbcellsdeployed=new CL_Label(infoBF); lbcellsdeployed->set_geometry(CL_Rect(lboffset.x,lboffset.y+5, slb)); lbcellsdeployed->set_text("Cells deployed"); cellsdeployed=new CL_Spin(infoBF); cellsdeployed->set_geometry(CL_Rect(lboffset.x+80,lboffset.y, sspin)); cellsdeployed->set_step_size(1); cellsdeployed->set_ranges(0,100); cellsdeployed->set_value(entites->curLV->defbfs[0].ImmunityPoints); lbintruders=new CL_Label(infoBF); lbintruders->set_geometry(CL_Rect(lboffset.x,lboffset.y+35, slb)); lbintruders->set_text("Intruders"); intruders=new CL_Spin(infoBF); intruders->set_geometry(CL_Rect(lboffset.x+80,lboffset.y+30, sspin)); lbtimeleft=new CL_Label(infoBF); lbtimeleft->set_geometry(CL_Rect(lboffset.x,lboffset.y+65, slb)); lbtimeleft->set_text("Time left"); timeleft=new CL_ProgressBar(infoBF); timeleft->set_geometry(CL_Rect(lboffset.x+80,lboffset.y+65, slb)); timeleft->set_min(0); timeleft->set_max(40); timeleft->set_position(20); SendingCirfirm=new CL_PushButton(infoBF); SendingCirfirm->set_geometry(CL_Rect(lboffset.x,lboffset.y+95, slb)); SendingCirfirm->set_text("Send"); SendingCirfirm->func_clicked().set(this,&T_App::OnSendingCirfirmClick); //tatical layer TaticalBoard=new CL_Label(mpComWindow); TaticalBoard->set_geometry(CL_Rect(10,310, CL_Size(290, 200))); TaticalBoard->set_text("TaticalBoard"); TaticalBoard->set_visible(true); // TaticalBoard->set_constant_repaint(true); lbTcellsdeployed=new CL_Label(TaticalBoard); lbTcellsdeployed->set_geometry(CL_Rect(lboffset.x,lboffset.y+5, slb)); lbTcellsdeployed->set_text("Cells deployed"); lbTcellsdeployed->set_visible(true); Tcellsdeployed=new CL_Label(TaticalBoard); Tcellsdeployed->set_geometry(CL_Rect(lboffset.x+100,lboffset.y+5, slb)); Tcellsdeployed->set_text("Cells deployed"); Tcellsdeployed->set_visible(true); lbTintruders=new CL_Label(TaticalBoard); lbTintruders->set_geometry(CL_Rect(lboffset.x,lboffset.y+15, slb)); lbTintruders->set_text("Itruders"); lbTintruders->set_visible(true); Tintruders=new CL_Label(TaticalBoard); Tintruders->set_geometry(CL_Rect(lboffset.x+100,lboffset.y+15, slb)); Tintruders->set_text("Itruders"); Tintruders->set_visible(true); entites->hero->eventTimer->func_expired().set(this,&T_App::invading_LogicLayer_Failure); entites->hero->eventTimer->begin(true); //LibDebugOnConsole(); time(&Atime); } catch (CL_Exception &exception) { CL_Console::write_line("Exception:Init error", exception.get_message_and_stack_trace()); // mpConsole->display_close_message(); CL_Console::write_line(exception.get_message_and_stack_trace()); return true; } running=true; T_Event::eventInit(); T_App::eventInit(); // slotMouseDown = mMouse.sig_key_down().connect(this, // &T_App::onMouseDown); return true; } void T_App::OnSendingCirfirmClick() { if (entites->SOselected!=NULL) { entites->SOselected->datas->ImmunityPoints+=cellsdeployed->get_value(); if (entites->hero->ImmunityPoints->minusable(cellsdeployed->get_value())) { entites->hero->ImmunityPoints->minus(cellsdeployed->get_value()); } } }
[ "jy02140486@gmail.com@7e182df5-b8f1-272d-db4e-b61a9d634eb1" ]
[ [ [ 1, 198 ] ] ]
c94152890c940b22bdb79f243c4f1585d5936f63
024d621c20595be82b4622f534278009a684e9b7
/SupportPosCalculator.h
a5e6a26a02bc832a3e52b38065da83d11c7d94e0
[]
no_license
tj10200/Simple-Soccer
98a224c20b5e0b66f0e420d7c312a6cf6527069b
486a4231ddf66ae5984713a177297b0f9c83015f
refs/heads/master
2021-01-19 09:02:02
2011-03-15 01:38:15
2011-03-15 01:38:15
1,480,980
0
0
null
null
null
null
UTF-8
C++
false
false
2,396
h
#ifndef SUPPORTING_POS_CALCULATOR_H #define SUPPORTING_POS_CALCULATOR_H #include "GameHeaders.h" #include "Player.h" class SupportPosCalculator { private: D3DXVECTOR2 **regions, goal, RegSize; Player *teammate, *oppTeam, *ballCarrier; int rows, cols, numPlayers, homeTeamIdxOffset; double **passPotential, **goalPotential, **supportRegions, **distValue; bool regionsAvail; void passPotentialCalc (); void goalPotentialCalc (); void distFromAttackerCalc(); void setBallCarrier (); public: SupportPosCalculator (D3DXVECTOR2 **Regs, D3DXVECTOR2 Goal, Player *sameTeam, Player *opposing, int RegRows, int RegCols, int players, bool isHomeTeam, int regOffset){ regions = Regs; goal = Goal; teammate = sameTeam; oppTeam = opposing; passPotential = new double *[RegRows]; goalPotential = new double *[RegRows]; supportRegions = new double *[RegRows]; distValue = new double *[RegRows]; for (int x = 0; x < RegRows; x++) { passPotential[x] = new double [RegCols]; goalPotential[x] = new double [RegCols]; supportRegions[x]= new double [RegCols]; distValue[x] = new double [RegCols]; } rows = RegRows; cols = RegCols; numPlayers = players; homeTeamIdxOffset = regOffset; regionsAvail = false; } D3DXVECTOR2 getBestSupportPos (); double getPassPotential ( int regX, int regY); double getGoalPotential ( int regX, int regY); Player *getClosestTeammate ( Player p, Player *team); Player *getClosestToTgt ( Player *team, D3DXVECTOR2 tgt); D3DXVECTOR2 getGoalShot ( Player *p); D3DXVECTOR2 getPassShot ( Player *p, Player *team); void calcSupportingRegions ( Player *ballCarrier); D3DXVECTOR2 getSupportPos ( Player *p, Player *ball); bool isShotSafe ( D3DXVECTOR2 startLoc, D3DXVECTOR2 endLoc); }; #endif
[ "tjjohnson10200@gmail.com" ]
[ [ [ 1, 84 ] ] ]
a895c5eb6bec1153d70cf30ce6fc9a001a90652b
1e976ee65d326c2d9ed11c3235a9f4e2693557cf
/CommonSources/TransmitterPattern/Transmitter.h
a7656b3abfc3434e8609eb6ac9d03591993fcc53
[]
no_license
outcast1000/Jaangle
062c7d8d06e058186cb65bdade68a2ad8d5e7e65
18feb537068f1f3be6ecaa8a4b663b917c429e3d
refs/heads/master
2020-04-08 20:04:56
2010-12-25 10:44:38
2010-12-25 10:44:38
19,334,292
3
0
null
null
null
null
UTF-8
C++
false
false
2,349
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 #define MSG_TRANSMITTER_QUIT 0 class MessageDetails { public: virtual ~MessageDetails() {} }; class Receiver { public: virtual void OnMessage(UINT msgID, LPVOID sender, MessageDetails* detail) = 0; #ifdef _DEBUG virtual LPCTSTR GetReceiverName() = 0; #endif }; class Transmitter { public: virtual ~Transmitter() {} virtual void RegisterReceiver(Receiver& receiver) = 0; virtual void UnRegisterReceiver(Receiver& receiver) = 0; //===SendMessage //Sends a message directly to the Registered Receivers //- msgID: The App-Defined Identification of the message. *value 0 is reserved //- sender: [Optional]The sender of the message. //- detail: [Optional] Details for the message. // The receiver must be able to cast the derived MessageDetain through the ID virtual void SendMessage(UINT msgID, LPVOID sender = NULL, MessageDetails* detail = NULL) = 0; //===PostMessage //Queues the message in a storage. The message is being send in the next Heartbeat. //Extra options //- bGroupSimilar. Similar msgIDs may be grouped in one. virtual void PostMessage(UINT msgID, LPVOID sender = NULL, MessageDetails* detail = NULL, BOOL bGroupSimilar = FALSE) = 0; //===HeartBeat //- Posted Messages are send when HeartBeat is called virtual void HeartBeat() = 0; };
[ "outcast1000@dc1b949e-fa36-4f9e-8e5c-de004ec35678" ]
[ [ [ 1, 68 ] ] ]
64ceb84bfde0c56e82627a9bac15d50b077eed63
da32684647cac4dcdbb60db49496eb8d10a8ea6d
/Deadbeef/Classes/Box2D/Dynamics/b2Fixture.cpp
bb4ea5470d16a4bdaf17bc5606c94777b0d6c807
[]
no_license
jweinberg/deadbeef
a1f10bc37de3aee5ac6b5953d740be9990083246
8126802454ff5815a7a55feae82e80d026a89726
refs/heads/master
2016-09-06 06:13:46
2010-06-18 21:51:07
2010-06-18 21:51:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,173
cpp
/* * Copyright (c) 2006-2009 Erin Catto http://www.gphysics.com * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. */ #include "b2Fixture.h" #include "Contacts/b2Contact.h" #include "../Collision/Shapes/b2CircleShape.h" #include "../Collision/Shapes/b2PolygonShape.h" #include "../Collision/b2BroadPhase.h" #include "../Collision/b2Collision.h" #include "../Common/b2BlockAllocator.h" b2Fixture::b2Fixture() { m_userData = NULL; m_body = NULL; m_next = NULL; m_proxyId = b2BroadPhase::e_nullProxy; m_shape = NULL; m_density = 0.0f; m_physicsSprite = NULL; } b2Fixture::~b2Fixture() { b2Assert(m_shape == NULL); b2Assert(m_proxyId == b2BroadPhase::e_nullProxy); } void b2Fixture::Create(b2BlockAllocator* allocator, b2Body* body, const b2FixtureDef* def) { m_userData = def->userData; m_friction = def->friction; m_restitution = def->restitution; m_body = body; m_next = NULL; m_filter = def->filter; m_isSensor = def->isSensor; m_isMagnetic = def->isMagnetic; m_shape = def->shape->Clone(allocator); m_density = def->density; } void b2Fixture::Destroy(b2BlockAllocator* allocator) { // The proxy must be destroyed before calling this. b2Assert(m_proxyId == b2BroadPhase::e_nullProxy); // Free the child shape. switch (m_shape->m_type) { case b2Shape::e_circle: { b2CircleShape* s = (b2CircleShape*)m_shape; s->~b2CircleShape(); allocator->Free(s, sizeof(b2CircleShape)); } break; case b2Shape::e_polygon: { b2PolygonShape* s = (b2PolygonShape*)m_shape; s->~b2PolygonShape(); allocator->Free(s, sizeof(b2PolygonShape)); } break; default: b2Assert(false); break; } m_shape = NULL; } void b2Fixture::CreateProxy(b2BroadPhase* broadPhase, const b2Transform& xf) { b2Assert(m_proxyId == b2BroadPhase::e_nullProxy); // Create proxy in the broad-phase. m_shape->ComputeAABB(&m_aabb, xf); m_proxyId = broadPhase->CreateProxy(m_aabb, this); } void b2Fixture::DestroyProxy(b2BroadPhase* broadPhase) { if (m_proxyId == b2BroadPhase::e_nullProxy) { return; } // Destroy proxy in the broad-phase. broadPhase->DestroyProxy(m_proxyId); m_proxyId = b2BroadPhase::e_nullProxy; } void b2Fixture::Synchronize(b2BroadPhase* broadPhase, const b2Transform& transform1, const b2Transform& transform2) { if (m_proxyId == b2BroadPhase::e_nullProxy) { return; } // Compute an AABB that covers the swept shape (may miss some rotation effect). b2AABB aabb1, aabb2; m_shape->ComputeAABB(&aabb1, transform1); m_shape->ComputeAABB(&aabb2, transform2); m_aabb.Combine(aabb1, aabb2); b2Vec2 displacement = transform2.position - transform1.position; broadPhase->MoveProxy(m_proxyId, m_aabb, displacement); } void b2Fixture::SetFilterData(const b2Filter& filter) { m_filter = filter; if (m_body == NULL) { return; } // Flag associated contacts for filtering. b2ContactEdge* edge = m_body->GetContactList(); while (edge) { b2Contact* contact = edge->contact; b2Fixture* fixtureA = contact->GetFixtureA(); b2Fixture* fixtureB = contact->GetFixtureB(); if (fixtureA == this || fixtureB == this) { contact->FlagForFiltering(); } edge = edge->next; } } void b2Fixture::SetSensor(bool sensor) { m_isSensor = sensor; }
[ "bhelgeland@9c1d8119-421d-44e4-8328-69b580a11e1d" ]
[ [ [ 1, 165 ] ] ]
1b4652ce09bd2c88b5d27ad38a58c0cb9df76eec
59166d9d1eea9b034ac331d9c5590362ab942a8f
/ParticlePlayer/MainNode/UpdClbkMainNode.cpp
2c608e342c584f67905f27aeec17af4b43872bf5
[]
no_license
seafengl/osgtraining
5915f7b3a3c78334b9029ee58e6c1cb54de5c220
fbfb29e5ae8cab6fa13900e417b6cba3a8c559df
refs/heads/master
2020-04-09 07:32:31
2010-09-03 15:10:30
2010-09-03 15:10:30
40,032,354
0
3
null
null
null
null
WINDOWS-1251
C++
false
false
3,004
cpp
#include "UpdClbkMainNode.h" #include "KeyboardState.h" #include "CameraState.h" #include <osg/Math> #include <iostream> UpdClbkMainNode::UpdClbkMainNode() : m_fMoveSpeed( 0.0 ) { } void UpdClbkMainNode::operator()( osg::Node* node, osg::NodeVisitor* nv ) { //обработать вращения ProcessRotate(); //обработать перемещение ProcessMove(); // first update subgraph to make sure objects are all moved into position traverse(node,nv); } void UpdClbkMainNode::ProcessRotate() { //обработать вращения //получить доступ к состоянию клавиатуры binEvents &mEvents = KeyboardState::Instance().GetEvents(); //получить доступ к состоянию камеры binCameraState &mCamState = CameraState::Instance().GetCameraState(); mCamState.m_dR = mCamState.m_dR + mEvents.m_dX * 0.5; mCamState.m_dH = mCamState.m_dH + mEvents.m_dY * 0.5; //ограничение диапазона углов if ( mCamState.m_dH > 360.0 ) mCamState.m_dH -= 360.0; else if ( mCamState.m_dH < -360.0 ) mCamState.m_dH += 360.0; if ( mCamState.m_dR > 360.0 ) mCamState.m_dR -= 360.0; else if ( mCamState.m_dR < -360.0 ) mCamState.m_dR += 360.0; } void UpdClbkMainNode::ProcessMove() { //обработать перемещение //получить доступ к состоянию клавиатуры binEvents &mEvents = KeyboardState::Instance().GetEvents(); if ( mEvents.m_bLeft ) //перемещение камеры вперед MoveForward(); else if ( mEvents.m_bRight ) //перемещение камеры назад MoveBackward(); } void UpdClbkMainNode::MoveForward() { //перемещение камеры вперед //получить доступ к состоянию камеры binCameraState &mCamState = CameraState::Instance().GetCameraState(); double dZ = cos( osg::DegreesToRadians( -mCamState.m_dH + 90.0 ) ); double nD = sqrt( 1.0 - dZ * dZ ); double dX = -nD * sin( osg::DegreesToRadians( mCamState.m_dR ) ); double dY = -nD * cos( osg::DegreesToRadians( mCamState.m_dR ) ); mCamState.m_dX += dX * 0.01; mCamState.m_dY += dY * 0.01; mCamState.m_dZ += dZ * 0.01; std::cout << mCamState.m_dY << " "; } void UpdClbkMainNode::MoveBackward() { //перемещение камеры назад //получить доступ к состоянию камеры binCameraState &mCamState = CameraState::Instance().GetCameraState(); double dZ = -cos( osg::DegreesToRadians( -mCamState.m_dH + 90.0 ) ); double nD = sqrt( 1.0 - dZ * dZ ); double dX = nD * sin( osg::DegreesToRadians( mCamState.m_dR ) ); double dY = nD * cos( osg::DegreesToRadians( mCamState.m_dR ) ); mCamState.m_dX += dX * 0.01; mCamState.m_dY += dY * 0.01; mCamState.m_dZ += dZ * 0.01; std::cout << mCamState.m_dY << " "; }
[ "asmzx79@3290fc28-3049-11de-8daa-cfecb5f7ff5b" ]
[ [ [ 1, 108 ] ] ]
cb40a5319f9a5c372afccc7dfbd3157cea518a56
075043812c30c1914e012b52c60bc3be2cfe49cc
/src/SDLGUIlibTests/SDL_Fixture.h
b7fee6cd1013f277ad13175a51caadc584545e0f
[]
no_license
Luke-Vulpa/Shoko-Rocket
8a916d70bf777032e945c711716123f692004829
6f727a2cf2f072db11493b739cc3736aec40d4cb
refs/heads/master
2020-12-28 12:03:14
2010-02-28 11:58:26
2010-02-28 11:58:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
746
h
#pragma once #include <sdl.h> #include <iostream> #include <Widget.h> struct SDL_fixture { bool SDL_init_ok; SDL_Surface* screen; SDL_fixture() { SDL_init_ok = true; int init_result; if((init_result = SDL_Init(SDL_INIT_VIDEO)) != 0) { SDL_init_ok = false; std::cout << "Error starting SDL\n" << init_result << "\n"; } else { screen = SDL_SetVideoMode(640, 480, 32, SDL_DOUBLEBUF | SDL_HWSURFACE); if(!screen) { SDL_init_ok = false; std::cout << "Error starting SDL\n"; }else { // std::cout << "Starting SDL\n"; } } } ~SDL_fixture() { if(SDL_init_ok) { SDL_Quit(); //std::cout << "Shutting down SDL\n"; } Widget::ClearRoot(); } };
[ "danishcake@hotmail.com" ]
[ [ [ 1, 42 ] ] ]
ca47830e3446012cd8c35fb4140f006594e89045
3ac8c943b13d943fbd3b92787e40aa5519460a32
/Source/IPC/Semaphore.cpp
902ca06f146c6ecf022dfd6531720f5a1c7010ff
[ "BSD-3-Clause", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
locosoft1986/Microkernel-1
8069bd2be390d6d8ad10f73e8a944112a764a401
c9dfeec4581d4dd8b1e9020adb3778ad78b3e525
refs/heads/master
2021-01-24 04:54:08
2010-09-23 19:38:01
2010-09-23 19:38:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,142
cpp
#include <IPC/Semaphore.h> Semaphore::Semaphore(unsigned int atom) { atomic = atom; } Semaphore::~Semaphore() { } Semaphore &Semaphore::operator =(const Semaphore &x) { atomic = x.atomic; return *this; } unsigned int Semaphore::operator +=(unsigned int x) { return __sync_add_and_fetch(&atomic, x); } unsigned int Semaphore::operator -=(unsigned int x) { return __sync_sub_and_fetch(&atomic, x); } unsigned int Semaphore::operator |=(unsigned int x) { return __sync_or_and_fetch(&atomic, x); } unsigned int Semaphore::operator &=(unsigned int x) { return __sync_and_and_fetch(&atomic, x); } unsigned int Semaphore::operator ^=(unsigned int x) { return __sync_xor_and_fetch(&atomic, x); } bool Semaphore::operator ==(const Semaphore &x) { return (x.atomic == this->atomic); } bool Semaphore::operator !=(const Semaphore &x) { return !(*this == x); } Semaphore::operator unsigned int () const { return atomic; } bool Semaphore::CompareAndSwap(unsigned int oldValue, unsigned int newValue) { return __sync_bool_compare_and_swap(&atomic, oldValue, newValue); }
[ "edward.neal@gmail.com" ]
[ [ [ 1, 61 ] ] ]
63601d52d33c9d54071905905b58be453a896972
992d3f90ab0f41ca157000c4b18d071087d14d85
/draw/CPPCODER.CPP
df1cbad125fdc62a8c9606dc67eae4e1c7b1039d
[]
no_license
axemclion/visionizzer
cabc53c9be41c07c04436a4733697e4ca35104e3
5b0158f8a3614e519183055e50c27349328677e7
refs/heads/master
2020-12-25 19:04:17
2009-05-22 14:44:53
2009-05-22 14:44:53
29,331,323
0
0
null
null
null
null
UTF-8
C++
false
false
14,855
cpp
# include <process.h> # include <graphics.h> # include <dos.h> # include <stdio.h> # include <ctype.h> # include <stdlib.h> # include <string.h> # include <dir.h> # include <conio.h> # include <mouse.h> int fc(char *file1,char *file2,char *dest); void ccoder(char *); int main(int argc,char *argv[]) { if (argc < 1) return 1; ccoder(argv[1]); char path[100],path1[100]; strcpy(path,argv[1]); strcpy(path1,path); strcat(path1,"prog.java"); fc("code.cpp",NULL,path1); strcpy(path1,path); strcat(path1,"code.h"); remove(path1); remove("head"); fc("head","code.tmp",path1); remove("head"); FILE *fp = fopen("end.bat","wt"); fprintf(fp,"cls"); fclose(fp); strcpy(path1,path); return 0; } void ccoder(char *path) { char object[100]; remove("code.cpp"); strcat(path,"\\"); char *path1 =(char *)calloc(1,100); #ifdef AXE printf("%s",path); getch();getch(); click(); # endif char *name; if (!path1) return; strcpy(path1,path); FILE *fp,*prog,*draw; strcat(path1,"code.cpp"); prog=fopen("code.cpp","wt"); if (prog == NULL) return ; strcpy(path1,path); /**********writing to file ***********/ fprintf(prog,"import java.awt.*;\n"); fprintf(prog,"import javax.swing.*;\n"); fprintf(prog,"import java.applet.*;\n"); fp = fopen ("object.tmp","rt"); if (fp != NULL) { fprintf(prog,"\n\nvoid redraw();\n\n"); draw = fopen("draw.ini","rt"); int type=0,c=0; fgets(object,100,fp); if (object[strlen(object)-1] == '\n') object[strlen(object)-1] = NULL; fgets(path1,100,fp); do { rewind(draw); while (path1[c] != '=' && path1[c]!= NULL) c++; type = atoi(path1+c+1); c = 0; fscanf(draw,"%d %s",&c,path1); do{ char ss[100]; fscanf(draw,"%s\n",ss); if (type == c) break; fscanf(draw,"%d %s",&c,path1); }while(!feof(draw)); fprintf(prog,"%s %s(",path1,object); { FILE *head; head = fopen("head","at"); fprintf(head,"extern %s %s;\n",path1,object); fclose(head); } //fist arguement fgets(path1,100,fp); c=0; while (path1[c] != '=' && path1[c]!= NULL) c++; name = path1+c+1; if (name[strlen(name)-1] == '\n') name[strlen(name)-1] = NULL; if (isdigit(name[0])) fprintf(prog,"%d",atoi(name)); else fprintf(prog,"\"%s\"",name); fgets(path1,100,fp);c=0; do{ while (path1[c] != '=' && path1[c]!= NULL) c++; name = path1+c+1; if (name[strlen(name)-1] == '\n') name[strlen(name)-1] = NULL; if (isdigit(name[0])) fprintf(prog,",%d",atoi(name)); else fprintf(prog,",\"%s\"",name); fgets(path1,100,fp);c=0; }while (strcmp(path1,"**********\n") != 0 && !(feof(fp))); fprintf(prog,");\n"); fgets(object,100,fp);fgets(path1,100,fp); object[strlen(object)-1] = NULL; }while (!feof(fp)); fclose(draw); fclose(fp); } fprintf(prog,"\n\nint main()\n{\n"); fprintf(prog,"\tint gdriver = VGA, gmode=VGAMED, errorcode;\n");fprintf(prog,"\tinitgraph(&gdriver, &gmode,\"\");\n"); fprintf(prog,"\terrorcode = graphresult();");fprintf(prog,"\n\tif (errorcode != grOk) // an error occurred \n");fprintf(prog,"\t\t{\n"); fprintf(prog,"\t\tprintf(\"Graphics error:\");\n");fprintf(prog,"\t\tprintf(\"Press any key to halt:\");\n");fprintf(prog,"\t\tgetch();\n");fprintf(prog,"\t\texit(1);\n\t\t}\n"); fprintf(prog,"\nredraw();"); fprintf(prog,"\nmouse_present();\nshow_mouse();"); fprintf(prog,"\nwhile(1)\n{\nfocus = -1;key = 0;\n"); fprintf(prog,"\tmouse1 = mouse;\n\tmouse = status();"); fprintf(prog,"\tif (kbhit()) \n\t\tkey = getch();\n"); //start of events fp = fopen("object.tmp","rt"); draw = fopen("code.tmp","rt"); if (fp != NULL && draw != NULL) { fgets(object,100,fp); do{ object[strlen(object)-1] = NULL; fprintf(prog,"\tif (inarea(mouse.x,mouse.y,%s.x1,%s.y1,%s.x2,%s.y2))\n\t{\n\t\tfocus = %s.action();\n", object,object,object,object,object); //events are writen here rewind(draw); fgets(path1,100,draw); do{ int op = 0; while (path1[op++] != ' '); name=path1+op; if (path1[strlen(path1) -1] == '\n') path1[strlen(path1) -1] = NULL; if (strncmp(object,name,strlen(object)) == 0) fprintf(prog,"\t\t%s;\n",name); op = 1;fgetc(draw); while (op != 0) { if (path1[0] == '\"') while (fgetc(draw) == '\"'); else if (path1[0] == '\'') while (fgetc(draw) == '\''); else if (path1[0] =='{') op++; else if (path1[0] =='}') op--; path1[0] = fgetc(draw); }//read till end of function fgets(path1,100,draw); }while (!feof(draw)); //events are completed here fprintf(prog,"\t}//end of %s\n\n",object); while (strcmp(object,"**********\n") != 0) fgets(object,100,fp); fgets(object,100,fp); fgets(path1,100,fp); }while(!feof(fp)); fclose(fp); } fclose(draw); //end of events fprintf(prog,"\n}//end of main program execution loop"); fprintf(prog,"\n}//end of function main"); fprintf(prog,"\n\nvoid redraw()\n\t{\n"); fprintf(prog,"char pattern[8];\n"); fp = fopen("draw.tmp","rt"); while (!feof(fp) && fp != NULL) { fscanf(fp,"%s ",&object); int sx,sy,ex,ey,thk,ls,col,fs,fc; unsigned int fonts,fontn,fontdir; char cp[8]; sx=sy=ex=ey=thk=ls=col=fs=fc=fonts=fontn=fontdir=0; if (strcmp(object,"object") == 0) { fgets(object,100,fp); *(object + strlen(object) -1 ) = NULL; fprintf(prog,"%s.draw();\n",object); }//end of drawing objects else if (strcmp(object,"print") == 0) { fscanf(fp,"%03d,%03d,", &sx,&sy); fgets(object,100,fp); *(object + strlen(object) -1 ) = NULL; fprintf(prog,"gotoxy(%d,%d);\n",sx,sy); fprintf(prog,"printf(\"%s\");\n",object); }//end of text else if (strcmp(object,"line") == 0 || strcmp(object,"rectangle") == 0) { fscanf(fp,"%03d,%03d,%03d,%03d,%03d,%03d,%03d,%07d\n", &sx,&sy,&ex,&ey,&col,&thk,&ls,&fontn); fprintf(prog,"setcolor(%d);setlinestyle(%d,%d,%d);\n",col,ls,fontn,thk); if (strcmp(object,"rectangle") == 0) fprintf(prog,"rectangle(%d,%d,%d,%d);\n",sx,sy,ex,ey); else fprintf(prog,"line(%d,%d,%d,%d);\n",sx,sy,ex,ey); }//end of drawing a line else if (strcmp(object,"bar") == 0) { fscanf(fp,"%03d,%03d,%03d,%03d,%03d,%03d\n", &sx,&sy,&ex,&ey,&fc,&fs); fprintf(prog,"setfillstyle(%d,%d);\n",fs,fc); fprintf(prog,"bar(%d,%d,%d,%d);\n",sx,sy,ex,ey); }//end of drawing a rectangle else if (strcmp(object,"barp") == 0) { fscanf(fp,"%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d\n", &sx,&sy,&ex,&ey,&fc, &cp[0],&cp[1],&cp[2],&cp[3],&cp[4],&cp[5],&cp[6],&cp[7]); fprintf(prog,"\npattern[0] = %d;",cp[0]);fprintf(prog,"\npattern[1] = %d;",cp[1]);fprintf(prog,"\npattern[2] = %d;",cp[2]);fprintf(prog,"\npattern[3] = %d;",cp[3]); fprintf(prog,"\npattern[4] = %d;",cp[4]);fprintf(prog,"\npattern[5] = %d;",cp[5]);fprintf(prog,"\npattern[6] = %d;",cp[6]);fprintf(prog,"\npattern[7] = %d;",cp[7]); fprintf(prog,"\nsetfillpattern(pattern,%d);\n",fc); fprintf(prog,"bar(%d,%d,%d,%d);\n",sx,sy,ex,ey); } else if (strcmp(object,"text") == 0) { fscanf(fp,"%02d,%03d,%03d,%02d,%02d,%02d,", &col,&sx,&sy, &fontn,&fontdir,&fonts); fgets(object,100,fp); *(object + strlen(object) -1 ) = NULL; fprintf(prog,"setcolor(%d);\n",col); fprintf(prog,"settextstyle(%d,%d,%d);\n",fontn,fontdir,fonts); fprintf(prog,"outtextxy(%d,%d,\"%s\");\n",sx,sy,object); }//end of text else if (strcmp(object,"ellipse") == 0) { fscanf(fp,"%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d\n", &sx,&sy,&ex,&ey,&fonts,&fontn,&col,&thk); fprintf(prog,"setcolor(%d);\n",col); fprintf(prog,"setlinestyle(0,0,%d);\n",thk); fprintf(prog,"ellipse(%d,%d,%d,%d,%d,%d);\n",sx,sy,ex,ey,fonts,fontn); }//end of ellipse else if (strcmp(object,"pie") == 0) { fscanf(fp,"%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d\n", &sx,&sy,&ex,&ey,&fonts,&fontn, &col,&thk,&fc,&fs); fprintf(prog,"setcolor(%d);\n",col); fprintf(prog,"setlinestyle(0,0,%d);\n",thk); fprintf(prog,"setfillstyle(%d,%d);\n",fs,fc); fprintf(prog,"sector(%d,%d,%d,%d,%d,%d);\n",sx,sy,ex,ey,fonts,fontn); }//end of drawing simple piechart else if (strcmp(object,"piepattern") == 0) { int xradius,yradius; fscanf(fp,"%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d\n", &sx,&sy, &ex,&ey, &xradius,&yradius, &col,&thk,&fc, &cp[0],&cp[1],&cp[2],&cp[3],&cp[4],&cp[5],&cp[6],&cp[7]); fprintf(prog,"setcolor(%d);\n",col); fprintf(prog,"setlinestyle(0,0,%d);\n",thk); fprintf(prog,"\npattern[0] = %d;",cp[0]);fprintf(prog,"\npattern[1] = %d;",cp[1]);fprintf(prog,"\npattern[2] = %d;",cp[2]);fprintf(prog,"\npattern[3] = %d;",cp[3]); fprintf(prog,"\npattern[4] = %d;",cp[4]);fprintf(prog,"\npattern[5] = %d;",cp[5]);fprintf(prog,"\npattern[6] = %d;",cp[6]);fprintf(prog,"\npattern[7] = %d;",cp[7]); fprintf(prog,"setfillpattern(pattern,%d);\n",fc); fprintf(prog,"sector(%d,%d,%d,%d,%d,%d);\n",sx,sy,ex,ey,fonts,fontn); }//end of complex pie chart else if (strcmp(object,"fillellipse") == 0) { fscanf(fp,"%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d\n", &sx,&sy,&ex,&ey, &col,&thk,&fc,&fs); fprintf(prog,"setcolor(%d);\n",col); fprintf(prog,"setlinestyle(0,0,%d);\n",thk); fprintf(prog,"setfillstyle(%d,%d);\n",fs,fc); fprintf(prog,"fillellipse(%d,%d,%d,%d);\n",sx,sy,ex,ey); }//end of fillellipse simple else if (strcmp(object,"fillellipsep") == 0) { fscanf(fp,"%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d\n", &sx,&sy,&ex,&ey, &col,&thk,&fc, &cp[0],&cp[1],&cp[2],&cp[3],&cp[4],&cp[5],&cp[6],&cp[7]); fprintf(prog,"setcolor(%d);\n",col); fprintf(prog,"setlinestyle(0,0,%d);\n",thk); fprintf(prog,"\npattern[0] = %d;",cp[0]);fprintf(prog,"\npattern[1] = %d;",cp[1]);fprintf(prog,"\npattern[2] = %d;",cp[2]);fprintf(prog,"\npattern[3] = %d;",cp[3]); fprintf(prog,"\npattern[4] = %d;",cp[4]);fprintf(prog,"\npattern[5] = %d;",cp[5]);fprintf(prog,"\npattern[6] = %d;",cp[6]);fprintf(prog,"\npattern[7] = %d;",cp[7]); fprintf(prog,"setfillpattern(pattern,%d);\n",fc); fprintf(prog,"fillellipse(%d,%d,%d,%d);\n",sx,sy,ex,ey); }//end of complex ellipse filler else if (strcmp(object,"fillstyle") == 0) { fscanf(fp,"%03d,%03d,%02d,%02d,%02d\n", &sx,&sy,&col,&fc,&fs); fprintf(prog,"setfillstyle(%d,%d);\n",fs,fc); fprintf(prog,"floodfill(%d,%d,%d);\n",sx,sy,col); }//end of floodfilling else if (strcmp(object,"fillpattern") == 0) { fscanf(fp,"%03d,%03d,%02d,%02d,%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d\n", &sx,&sy,&col,&fc, &cp[0],&cp[1],&cp[2],&cp[3],&cp[4],&cp[5],&cp[6],&cp[7]); fprintf(prog,"\npattern[0] = %d;",cp[0]);fprintf(prog,"\npattern[1] = %d;",cp[1]);fprintf(prog,"\npattern[2] = %d;",cp[2]);fprintf(prog,"\npattern[3] = %d;",cp[3]); fprintf(prog,"\npattern[4] = %d;",cp[4]);fprintf(prog,"\npattern[5] = %d;",cp[5]);fprintf(prog,"\npattern[6] = %d;",cp[6]);fprintf(prog,"\npattern[7] = %d;",cp[7]); fprintf(prog,"setfillpattern(pattern,%d);\n",fc); fprintf(prog,"floodfill(%d,%d,%d);\n",sx,sy,col); }//end of fill pattern else if (strcmp(object,"polygon") == 0) { fscanf(fp,"%03d,%03d,%03d,%03d,%07d\n", &fontdir,&col,&ls,&thk,&fontn); int points[30]; fprintf(prog,"{\nint poly[] = {"); for (int i = 0; i < fontdir*2 && i < 30;i+=2) { fscanf(fp,"%03d,%03d",&points[i],&points[i+1]); fprintf(prog,"%3d,%3d,",points[i],points[i+1]); }//end of for next loop fprintf(prog,"0};\nsetcolor(%d);\n",col); fprintf(prog,"setlinestyle(%d,%d,%d);\n",ls,fontn,thk); fprintf(prog,"drawpoly(%d,poly);}\n",fontdir); }//end of simple polygon else if (strcmp(object,"fillpolygon") == 0) { fscanf(fp,"%03d,%03d,%03d,%03d,%03d,%03d,%07d\n", &fontdir,&col,&ls,&thk,&fc,&fs,&fontn); int points[30]; fprintf(prog,"{\nint poly[] = {"); for (int i = 0; i < fontdir*2 && i < 30;i+=2) { fscanf(fp,"%03d,%03d",&points[i],&points[i+1]); fprintf(prog,"%3d,%3d,",points[i],points[i+1]); }//end of for next loop fprintf(prog,"0};\nsetcolor(%d);\n",col); fprintf(prog,"setlinestyle(%d,0,%d);\n",ls,fontn,thk); fprintf(prog,"setfillstyle(%d,%d);\n",fs,fc); fprintf(prog,"fillpoly(%d,poly);}\n",fontdir); }//end of simple polygon filling simple else if (strcmp(object,"fillpolygonp") == 0) { fscanf(fp,"%03d,%03d,%03d,%03d,%03d,%07d,%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d\n", &fontdir,&col,&ls,&thk,&fc,&fontn, &cp[0],&cp[1],&cp[2],&cp[3],&cp[4],&cp[5],&cp[6],&cp[7]); int points[30]; fprintf(prog,"{\nint poly[] = {"); for (int i = 0; i < fonts*2 && i < 30;i+=2) { fscanf(fp,"%03d,%03d",&points[i],&points[i+1]); fprintf(prog,"%3d,%3d,",points[i],points[i+1]); }//end of for next loop fprintf(prog,"0};\nsetcolor(%d);\n",col); fprintf(prog,"setlinestyle(%d,%d,%d);\n",ls,fontn,thk); fprintf(prog,"\npattern[0] = %d;",cp[0]);fprintf(prog,"\npattern[1] = %d;",cp[1]);fprintf(prog,"\npattern[2] = %d;",cp[2]);fprintf(prog,"\npattern[3] = %d;",cp[3]); fprintf(prog,"\npattern[4] = %d;",cp[4]);fprintf(prog,"\npattern[5] = %d;",cp[5]);fprintf(prog,"\npattern[6] = %d;",cp[6]);fprintf(prog,"\npattern[7] = %d;",cp[7]); fprintf(prog,"setfillpattern(pattern,%d);\n",fc); fprintf(prog,"fillpoly(%d,poly);}\n",fontdir); }//end of simple polygon filling simple else if (strcmp(object,"bmp") == 0) { int sx,sy,ex,ey; fscanf(fp,"%03d,%03d,%03d,%03d,%s\n", &sx,&sy,&ex,&ey,&object); fprintf(prog,"loadbmp(\"%s\",%d,%d,%d,%d);\n",object,sx,sy,ex,ey); }//end of loading bitmaps }//end of parsing all values fclose(fp); fprintf(prog,"\n\t}//end of redrawing all objects\n\n"); fclose(prog); free(path); free(path1); }//end of function int fc(char *file1,char *file2,char *dest) { FILE *src,*dst; src = fopen(file1,"rt"); dst = fopen(dest,"at"); if (dst == NULL) return 1; char *buffer = (char *)calloc(1,100); if (src != NULL) { fgets(buffer,100,src); do{ fprintf(dst,"%s",buffer); fgets(buffer,100,src); }while (!feof(src)); fclose(src); } src = fopen(file2,"rt"); if (src != NULL) { fgets(buffer,100,src); do{ fprintf(dst,"%s",buffer); fgets(buffer,100,src); }while (!feof(src)); fclose(src); } free(buffer); fclose(dst); return 0; }
[ "github@nparashuram.com" ]
[ [ [ 1, 448 ] ] ]
README.md exists but content is empty. Use the Edit dataset card button to edit it.
Downloads last month
31
Edit dataset card