text
stringlengths 8
6.88M
|
|---|
#pragma once
#include "SFML/Graphics.hpp"
#include <functional>
class Button
{
public:
Button(std::function<void()> foo);
~Button();
void SetOnClick(std::function<void()> foo);
void OnClick();
sf::Sprite icon;
private:
std::function<void()> function;
};
|
/*
* SharedPtr.h
*
* Created on: 2021. 9. 14.
* Author: dhjeong
*/
#ifndef RAIIANDMEM_SHAREDPTR_H_
#define RAIIANDMEM_SHAREDPTR_H_
#include <iostream>
#include <boost/shared_ptr.hpp>
#include "struct.h"
class SharedPtr {
public:
SharedPtr();
virtual ~SharedPtr();
void run();
void inside(boost::shared_ptr<DataInfo> &ptr);
};
#endif /* RAIIANDMEM_SHAREDPTR_H_ */
|
//Phoenix_RK
/*
https://leetcode.com/problems/rotting-oranges/
You are given an m x n grid where each cell can have one of three values:
0 representing an empty cell,
1 representing a fresh orange, or
2 representing a rotten orange.
Every minute, any fresh orange that is 4-directionally adjacent to a rotten orange becomes rotten.
Return the minimum number of minutes that must elapse until no cell has a fresh orange. If this is impossible, return -1.
Example 1:
Input: grid = [[2,1,1],[1,1,0],[0,1,1]]
Output: 4
Example 2:
Input: grid = [[2,1,1],[0,1,1],[1,0,1]]
Output: -1
Explanation: The orange in the bottom left corner (row 2, column 0) is never rotten, because rotting only happens 4-directionally.
Example 3:
Input: grid = [[0,2]]
Output: 0
Explanation: Since there are already no fresh oranges at minute 0, the answer is just 0.
Constraints:
m == grid.length
n == grid[i].length
1 <= m, n <= 10
grid[i][j] is 0, 1, or 2.
*/
class Solution {
public:
int orangesRotting(vector<vector<int>>& grid) {
int steps=-1;
int orange=0;
queue<pair<int,int>> q;
for(int i=0;i<grid.size();i++)
{
for(int j=0;j<grid[0].size();j++)
{
if(grid[i][j]>0)
orange++;
if(grid[i][j]==2)
q.push({i,j});
}
}
int x[4]={0,0,-1,1};
int y[4]={1,-1,0,0};
while(!q.empty())
{
steps++;
int s=q.size();
while(s--)
{
pair<int,int> temp=q.front();
q.pop();
orange--;
for(int i=0;i<4;i++)
{
int x_temp = temp.first + x[i];
int y_temp = temp.second + y[i];
if(x_temp>=0 && x_temp<grid.size() && y_temp>=0 && y_temp<grid[0].size() && grid[x_temp][y_temp]==1)
{
grid[x_temp][y_temp]=2;
q.push({x_temp,y_temp});
}
}
}
}
if(orange==0)
return max(0,steps);//if there are no oranges then steps would be -1 but actual ans should be 0
return -1;
}
};
|
// Copyright (c) Improbable Worlds Ltd, All Rights Reserved
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "GenericTeamAgentInterface.h"
#include "GDKShooterFunctionLibrary.generated.h"
/**
*
*/
UCLASS()
class GDKSHOOTER_API UGDKShooterFunctionLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, Category = "Teams")
static void SetGenericTeamId(AActor* Actor, FGenericTeamId NewTeamId);
UFUNCTION(BlueprintPure, Category = "Teams")
static FGenericTeamId GetGenericTeamId(AActor* Actor);
};
|
#ifndef __state__machine__
#define __state__machine__
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <ctime>
namespace smach {
std::string getCurrentDateString();
enum Transition {
Failure,
Success,
Continue,
Complete
};
const std::string INVALID_TRANSITION("INVALID/NOTSET");
const std::string COMPLETED_TRANSITION("COMPLETED");
/**
* @brief State is meant to be publicly inherited by any implemented state, should only have to override pure virtual executeState method
*/
class State {
public:
State() {};
virtual Transition executeState() = 0;
virtual ~State() {};
private:
}; // Class State
/**
* @brief StateMachine class manages transitions and states, logs progress, and prints debug messages
*/
class StateMachine {
public:
StateMachine();
void setLogFilePath(std::string fn) {log_path_ = fn; };
void registerState(std::string state_name, State* state);
void registerTransition(std::string state, Transition transition, std::string dest);
void runStartingFromState(std::string start_state);
private:
std::map<std::string, State*> state_map_; //< client is responsible for the state instances, TODO consider smart ptrs
std::vector<std::string> state_names_;
std::map<std::string, std::map<Transition, std::string>> transition_map_;
std::string log_path_;
std::string text_file_;
std::string dot_file_;
bool isStateFound(std::string state);
}; // Class StateMachine
} // ns smach
#endif
|
//
// Llamada.h
// ExamenFinal_Pregunta2
//
// Created by Daniel on 01/12/14.
// Copyright (c) 2014 Gotomo. All rights reserved.
//
#ifndef __ExamenFinal_Pregunta2__Llamada__
#define __ExamenFinal_Pregunta2__Llamada__
#include <iostream>
class Operador;
using namespace std;
class Llamada{
private:
public:
Llamada(Operador*);
string turno;
int hora, dia, mes, ano, duracion;
Operador* atendio;
};
#endif /* defined(__ExamenFinal_Pregunta2__Llamada__) */
|
#ifndef NETWORK_H
#define NETWORK_H
#include <iostream>
#include <stdio.h>
#include<string>
#include"Gsearch.h"
#include"mylynx.h"
using namespace std;
class network
{
private:
string uinput;
string output;
public:
int getwebpage(string);
vector<string> links;
void setuinput(string);
void operationtoggler();
};
/***************************************************************************************************************************************************************
class Func. Defns.
***************************************************************************************************************************************************************/
//takes a webadress or a search string as input and sets it as uinput member of class.
void network::setuinput(string in)
{
uinput=in;
}
//the main function which creates Gsearch object or mylynx object according to input given
void network::operationtoggler()
{
links.clear();
while (true)
{
if (uinput[0] == ' ' || uinput[0] == '\t')
{
uinput = uinput.substr (1);
}
else {break;}
}
while (true)
{
size_t found;
found=uinput.find(" ");
if (found!=string::npos)
{
uinput.replace(found,1,"+");
}
else{break;}
}
//checking whether its a link or a search string.
if(uinput.substr(0,4)=="http")
{
//building the shell comand to get the webpage into tmp.html
string s1="wget ";
string s2=" -O tmp.html";
string shellcmd;
shellcmd=s1+uinput+s2;
getwebpage(shellcmd);
//creating mylynx object and threby parsing and rendering
//the html file.
mylynx temp ("tmp.html");
temp.createTTR();
temp.smoothen();
temp.setsd();
temp.printmain();
links = temp.getLinks();
}
else
{
//building the shell command to get the webpage.
string s1,s2,shellcmd,renamecmd;
s1= "wget -U \"mozilla\" \"https://www.google.com/search?q=";
shellcmd=s1+uinput+"\"";
getwebpage(shellcmd);
//renaming the html file to tmp.html
string a,b,c,d;
getwebpage("rm tmp.html");
a="mv ";
b="search?q=";
c=" tmp.html";
renamecmd=a+b+uinput+c;
getwebpage(renamecmd);
//creating gsearch object and extracting search results.
Gsearch gun;
gun.mainrender();
gun.print();
links = gun.getResults();
}
}
//program to execute a shell command.
int network::getwebpage(string command) {
//cout<<command<<endl;
FILE *in;
char buff[512];
if(!(in = popen(command.c_str(), "r"))){
return 1;
}
while(fgets(buff, sizeof(buff), in)!=NULL){
cout << buff;
}
pclose(in);
return 0;
}
#endif
|
#include <systemc.h>
#include "counter.h"
void CounterMod8::counter() {
if (!reset.read()) {
count = 0;
}
else if(enable.read()) {
if (load.read()) {
count = in;
}
else {
count++;
}
}
out.write(count);
}
|
// Created on: 2015-10-29
// Created by: Irina KRYLOVA
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StepVisual_DraughtingCallout_HeaderFile
#define _StepVisual_DraughtingCallout_HeaderFile
#include <Standard.hxx>
#include <StepGeom_GeometricRepresentationItem.hxx>
#include <StepVisual_HArray1OfDraughtingCalloutElement.hxx>
class StepVisual_DraughtingCallout;
DEFINE_STANDARD_HANDLE(StepVisual_DraughtingCallout, StepGeom_GeometricRepresentationItem)
class StepVisual_DraughtingCallout : public StepGeom_GeometricRepresentationItem
{
public:
//! Returns a DraughtingCallout
Standard_EXPORT StepVisual_DraughtingCallout();
//! Init
Standard_EXPORT void Init (const Handle(TCollection_HAsciiString)& theName,
const Handle(StepVisual_HArray1OfDraughtingCalloutElement)& theContents);
//! Returns field Contents
inline Handle(StepVisual_HArray1OfDraughtingCalloutElement) Contents () const
{
return myContents;
}
//! Set field Contents
inline void SetContents (const Handle(StepVisual_HArray1OfDraughtingCalloutElement) &theContents)
{
myContents = theContents;
}
//! Returns number of Contents
inline Standard_Integer NbContents () const
{
return (myContents.IsNull() ? 0 : myContents->Length());
}
//! Returns Contents with the given number
inline StepVisual_DraughtingCalloutElement ContentsValue(const Standard_Integer theNum) const
{
return myContents->Value(theNum);
}
//! Sets Contents with given number
inline void SetContentsValue(const Standard_Integer theNum, const StepVisual_DraughtingCalloutElement& theItem)
{
myContents->SetValue (theNum, theItem);
}
DEFINE_STANDARD_RTTIEXT(StepVisual_DraughtingCallout,StepGeom_GeometricRepresentationItem)
private:
Handle(StepVisual_HArray1OfDraughtingCalloutElement) myContents;
};
#endif // _StepVisual_DraughtingCallout_HeaderFile
|
/**
******************************************************************************
* @file System_config.cpp
* @brief Deploy resources,tasks and services in this file.
******************************************************************************
* @note
* - Before running your Task you should first include your headers and init-
* ialize used resources in "System_Resource_Init()". This function will be
* called before tasks Start.
*
* - All tasks should be created in "System_Tasks_Init()".
* - FreeRTOS scheduler will be started after tasks are created.
*
===============================================================================
Task List
===============================================================================
* <table>
* <tr><th>Task Name <th>Priority <th>Frequency/Hz <th>Stack/Byte
* <tr><td> <td> <td> <td>
* </table>
*
*/
/* Includes ------------------------------------------------------------------*/
#include "System_Config.h"
#include "System_DataPool.h"
/* Service */
#include "simulation.h"
#include "win32_support.h"
/* User support package & SRML */
#include "User_Task.h"
/* Private variables ---------------------------------------------------------*/
/*Founctions------------------------------------------------------------------*/
/**
* @brief Load drivers ,modules, and data resources for tasks.
* @note Edit this function to add Init-functions and configurations.
*/
void System_Resource_Init(void)
{
/* Drivers Init ---------------------*/
/* RTOS resources Init --------------*/
/* Other resources Init -------------*/
LogOutputBacken_Init();
/* Modules Init ---------------------*/
/* Service configurations -----------*/
SerialPort_Vision.Register_RecvCallBack(VisionSerial_RxCpltCallback);
}
uint32_t getSimMicroSec(void) { return CoppeliaSim->GetSimMicroSec(); }
/**
* @brief Load and start User Tasks. This function run directly in "main()"
* @note Edit this function to add tasks into the activated tasks list.
*/
void System_Tasks_Init(void)
{
/* Syetem Service init --------------*/
/*Serial Communication service*/
Service_SerialPortCom_Init();
/*CoppeliaSim service*/
Service_CoppeliaSim_Init();
/* -------- */
// PID模块
myPIDTimer::getMicroTick_regist(GetMicroSecond);
gimbal.initPID(YAW_ANGLE_ENC, 1.0f, 0, 0, 0, 100.0f);
gimbal.initPID(YAW_SPEED, 0.5f, 0, 0, 0, 1.6f);
gimbal.initPID(YAW_ANGLE_IMU, 2.0f, 0, 0, 0, 100.0f);
gimbal.initPID(PITCH_SPEED, 1.0f, 0.5f, 0, 1.6f, 1.6f);
gimbal.initPID(PITCH_ANGLE, 2.0f, 0, 0, 0, 100.0f);
gimbal.pitchSpeed.I_SeparThresh = 0.5f;
chassis.initPID(1.0f, 0.0f, 0.0f, 100.0f, 1000.0f);
vision.yawPID.SetPIDParam(5E-5, 0, 4E-6, 0, 1.0f);
vision.yawPID.Target = 0;
vision.pitchPID.SetPIDParam(8E-5, 0, 6E-6, 0, 1.0f);
vision.pitchPID.Target = 0;
// 步兵模块
Infantry = CoppeliaSim->Add_Object("Infantry_1", OTHER_OBJECT, { SIM_ORIENTATION | CLIENT_RO, SIM_VELOCITY | CLIENT_RO });
Wheel[LB] = CoppeliaSim->Add_Object("Wheel_LB", JOINT, { SIM_VELOCITY | CLIENT_RW, SIM_POSITION | CLIENT_RO });
Wheel[LF] = CoppeliaSim->Add_Object("Wheel_LF", JOINT, { SIM_VELOCITY | CLIENT_RW, SIM_POSITION | CLIENT_RO });
Wheel[RB] = CoppeliaSim->Add_Object("Wheel_RB", JOINT, { SIM_VELOCITY | CLIENT_RW, SIM_POSITION | CLIENT_RO });
Wheel[RF] = CoppeliaSim->Add_Object("Wheel_RF", JOINT, { SIM_VELOCITY | CLIENT_RW, SIM_POSITION | CLIENT_RO });
Gimbal[YAW] = CoppeliaSim->Add_Object("GimbalYaw", JOINT, { SIM_VELOCITY | CLIENT_RW, SIM_POSITION | CLIENT_RO, SIM_FORCE | CLIENT_WO });
Gimbal[PITCH] = CoppeliaSim->Add_Object("GimbalPitch", JOINT, { SIM_VELOCITY | CLIENT_RW, SIM_POSITION | CLIENT_RO, SIM_FORCE | CLIENT_WO });
imuYawAngle = CoppeliaSim->Add_Object("Infantry_1.YawAng", SIM_FLOAT_SIGNAL, { SIM_SIGNAL_OP | CLIENT_RO });
imuPitchAngle = CoppeliaSim->Add_Object("Infantry_1.PitchAng", SIM_FLOAT_SIGNAL, { SIM_SIGNAL_OP | CLIENT_RO });
imuYawVel = CoppeliaSim->Add_Object("Infantry_1.YawVel", SIM_FLOAT_SIGNAL, { SIM_SIGNAL_OP | CLIENT_RO });
imuPitchVel = CoppeliaSim->Add_Object("Infantry_1.PitchVel", SIM_FLOAT_SIGNAL, { SIM_SIGNAL_OP | CLIENT_RO });
FireCmd = CoppeliaSim->Add_Object("Infantry_1.FireCmd", SIM_INTEGER_SIGNAL, { SIM_SIGNAL_OP | CLIENT_WO });
BulletSpeed = CoppeliaSim->Add_Object("Infantry_1.BulletSpeed", SIM_FLOAT_SIGNAL, { SIM_SIGNAL_OP | CLIENT_WO });
// 神符模块
RuneMotorRed = CoppeliaSim->Add_Object("BladeRed", JOINT, { SIM_VELOCITY | CLIENT_RW, SIM_POSITION | CLIENT_RO });
for (unsigned int i = 0; i < RUNE_ARMOR_NUM; i++)
{
Collision[i] = CoppeliaSim->Add_Object("RuneCollision_" + to_string(i + 1));
RuneLight[i] = CoppeliaSim->Add_Object("RuneLight_" + to_string(i + 1), SIM_INTEGER_SIGNAL, { SIM_SIGNAL_OP | CLIENT_WO });
}
/* Terrible memory check */
string check_result = "";
if (Infantry == nullptr)
check_result.append("\n\rInfantry pointer exploded !");
if (imuYawAngle == nullptr || imuPitchVel == nullptr || imuYawVel == nullptr || imuPitchVel == nullptr)
check_result.append("\n\imuData pointer exploded !");
if (FireCmd == nullptr)
check_result.append("\n\rFireCmd pointer exploded !");
if (BulletSpeed == nullptr)
check_result.append("\n\rBulletSpeed pointer exploded !");
if (RuneMotorRed == nullptr)
check_result.append("\n\rRuneMotorRed pointer exploded !");
for each (auto i in Wheel)
if (i == nullptr)
check_result.append("\n\rWheel pointer exploded !");
for each (auto i in Gimbal)
if (i == nullptr)
check_result.append("\n\rGimbal pointer exploded !");
for each (auto i in Collision)
if (i == nullptr)
check_result.append("\n\rCollision pointer exploded !");
for each (auto i in RuneLight)
if (i == nullptr)
check_result.append("\n\rRuneLight pointer exploded !");
// vrep中存在掉线模块
if (!check_result.empty())
{
std::cout << "----------------------------> Objects add failed ! <----------------------------";
std::cout << check_result << std::endl;
std::cout << "------------------------> Process will be suspended ! <-------------------------" << std::endl;
exit(0);
}
else
std::cout << "------------------------> Objects added successfully ! <------------------------" << std::endl;
/* Applications Init ----------------*/
User_Tasks_Init();
/* Start the tasks and timer running. */
vTaskStartScheduler();
}
/************************ COPYRIGHT(C) SCUT-ROBOTLAB **************************/
|
#include "StdAfx.h"
#include <stdlib.h> //get rand from here
#include "RandomWalker.h"
#include <algorithm>
using namespace std;
RandomWalker::RandomWalker(void)
{
counter = 10;
face = 'R';
skin = 4;
}
RandomWalker::~RandomWalker(void)
{
}
void RandomWalker::step()
{
if(--counter < 1)
{
counter = 10;
//move in a random direction
int newX = max(min(rand() % 3 - 1 + getMyX(), 5), 0);
int newY = max(min(rand() % 3 - 1 + getMyY(), 5), 0);
here->tryToMoveToCell(here->getDungeon()->getCell(newX, newY), false); //adjecency test is broken
int x = 1;
}
}
|
// naive O(n^3) implementation of matric multiplication
#include <iostream>
using namespace std;
int a[30][30], b[30][30];
int r1, c1, r2, c2;
int c(int i , int j){
int ans = 0;
for(int k = 0; k < c1; k++){
ans += a[i][k] * b[k][j];
}
return ans;
}
int main(){
int tc = 1;
while(cin >> r1 >> c1 >> r2 >> c2){
if(r1 == 0 && c1 == 0 && r2 == 0 && c2 == 0)
break;
cout << "Case #" << tc++ << ":" << endl;
for(int i = 0; i < r1; i++)
for(int j = 0; j < c1; j++)
cin >> a[i][j];
for(int i = 0; i < r2; i++)
for(int j = 0; j < c2; j++)
cin >> b[i][j];
if(r2 != c1){
cout << "undefined" << endl;
continue;
}
for(int i = 0; i < r1; i++){
cout << "| ";
for(int j = 0; j < c2; j++){
cout << c(i, j) << ' ';
}
cout << "|\n";
}
}
return 0;
}
|
#pragma once
class PdbModuleDetails : public IPdbModuleDetails
{
public:
PdbModuleDetails( PdbModule* );
virtual ~PdbModuleDetails();
// Set Properties
void SetCompilerName( const wstring& s );;
void SetGetBackEndBuildNumber( const wstring& s );
void SetManagedCode( bool b );
// Retrieve Properties.
const std::wstring& GetName() const;
const std::wstring& GetCompilerName() const;
const std::wstring& GetBackEndBuildNumber() const;
PdbLanguage GetLanguage() const;
PdbTargetCPU GetTargetCPU() const;
// Tests
bool IsManagedCode() const;
private:
PdbTargetCPU MapMachineTypeToTargetCPU(DWORD dwType) const;
wstring m_sCompilerName;
wstring m_sBackEndBuildNumber;
bool m_bManagedCode;
PdbLanguage m_PdbLanguage;
PdbTargetCPU m_PdbTargetCPU;
// Reference the Module
PdbModule* m_pModule;
};
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int n, m;
long long M, ans, a[maxn];
int main() {
scanf("%d%d%lld", &n, &m, &M);
for (int i = 1; i <= n; i++)
scanf("%d", &a[i]);
int x, y, k;
for (int i = 1; i <= m; i++) {
scanf("%d", &x);
if (x == 1) {
scanf("%d%d%d", &x, &y, &k);
for (int i = x; i <= y; i++)
a[i] = (a[i] * k) % M;
} else if (x == 2) {
scanf("%d%d%d", &x, &y, &k);
for (int i = x; i <= y; i++)
a[i] = (a[i] + k) % M;
} else if (x == 3) {
scanf("%d%d", &x, &y);
ans = 0;
for (int i = x; i <= y; i++)
ans = (ans + a[i]) % M;
printf("%d\n", ans);
}
}
return 0;
}
|
//
// GameController.cpp
// Puissance 4
//
// Created by Glorian on 16/04/2016.
// Copyright (c) 2016 Glorian . All rights reserved.
//
#include "GameController.h"
using namespace std;
GameController::GameController(Player j1, Player j2, int taille, int puissance){
Tableau table(taille, puissance);
GameLoop(table, j1, j2);
this->t = taille;
}
GameController::~GameController(){
}
void GameController::GameLoop(Tableau t, Player un, Player deux){
cout << "Début de la partie" << endl;
t.afficher();
bool end = false;
int c = 0;
while (end != true){
c = DemanderJeux("Joueur1");
end = t.addPion(un, c);
un.Jouer();
t.afficher();
if (end){
un.addVictoire();
cout << " Le Joueur 1 a gagné en " << deux.getnbrcout() << endl;
}
if (end != true){
c = DemanderJeux("Joueur2");
end = t.addPion(deux, c);
deux.Jouer();
t.afficher();
if (end){
deux.addVictoire();
cout << " Le Joueur 2 a gagné en " << un.getnbrcout() << endl;
}
}
}
afficherScore(t, un, deux);
MenuView mv(un, deux);
}
int GameController::DemanderJeux(string nom){
int c = 0;
bool valide = false;
while (!valide){
valide = true;
cout << "Tour de " << nom << endl;
cin >> c;
if(cin.fail())
{
cin.clear();
cin.ignore();
cout << "Veuillez entrer un entier uniquement" << endl;
valide = false;
}
}
return c;
}
void GameController::afficherScore(Tableau t, Player j1, Player j2){
cout << "Le joueur un a gagner " << j1.getVictoire() << " fois" << endl << "Le joueur deux a gagner " << j2.getVictoire() << " fois" << endl;
}
|
#include<stdio.h>
#include<conio.h>
#include<string>
#include<stdlib.h>
/*t main()
{
char n[6]="naren";
char *k = "kumar";
printf("%s",strcat(n,k));
getch();
}
*/
int main()
{
char *a[] = {"n" , "ku" , "s"};
printf("%d",sizeof(a));
getch();
}
|
#ifndef CMESSAGEMEDIATOR_H
#define CMESSAGEMEDIATOR_H
#include <QObject>
class CMessageEventMediator : public QObject
{
Q_OBJECT
public:
CMessageEventMediator(QObject *parent = 0);
~CMessageEventMediator();
Q_SIGNALS:
void sigLoginIn();
};
#endif // CMESSAGEMEDIATOR_H
|
/*****************************************************************************/
/* Class : Worker Version 1.0 */
/*****************************************************************************/
/* */
/* Function : This is our Workerthread, in which the clients code run */
/* (The Client code is in gfxmain()) */
/* Is in fact a singleton, e. g. there should be only one */
/* instance. */
/* Access to the only instance via GetTheWorker() */
/* */
/* Methodes : Worker() */
/* ~Worker() */
/* GetTheWorker() */
/* run() */
/* */
/* A lot of interfacefunctions between client and Qt */
/* Converts client calls to signals, a manages thus */
/* interthread communication */
/* */
/* Author : I. Oesch */
/* */
/* History : 02.09.2009 IO Created */
/* */
/* File : Worker.cpp */
/* */
/*****************************************************************************/
/* MagicSoft */
/*****************************************************************************/
/* imports */
#include<iostream>
#include <QCoreApplication>
#include <QStringList>
#include <QThreadPool>
//#include <QFileDialog>
#include <QPolygon>
#include "Worker.h"
#include <QTime>
/* Class constant declaration */
/* Class Type declaration */
/* Class data declaration */
extern volatile int vol;
extern "C" int gfxmain(int argc, char *argv[], const char *ApplicationPath);
/* Our only instance */
Worker *Worker::TheWorker = NULL;
/* Class procedure declaration */
/*****************************************************************************/
/* Class : MyRunableObject */
/*****************************************************************************/
/* */
/* Function : Helperclass for Multithreading, objects can be */
/* parametrized with a function to call */
/* */
/* Methodes : MyRunableObject() */
/* ~MyRunableObject() */
/* run() */
/* */
/* A lot of interfacefunctions between client and Qt */
/* Converts client calls to signals, a manages thus */
/* interthread communication */
/* */
/* Author : I. Oesch */
/* */
/* History : 02.04.2012 IO Created */
/* */
/* */
/*****************************************************************************/
class MyRunableObject : public QRunnable {
void *Parameter;
void (*Function)(void *);
public:
/* Creates a new runable object with Function to call and its parameter */
MyRunableObject(void *Para, void (*_Function)(void *)) : Parameter(Para), Function(_Function) {};
virtual ~MyRunableObject() {};
virtual void run ();
};
void MyRunableObject::run()
{
/* Call our function with its parameter */
if (Function != NULL) {
Function(Parameter);
}
}
/*****************************************************************************/
/* End Class : MyRunableObject */
/*****************************************************************************/
/*****************************************************************************/
/* Method : Worker */
/*****************************************************************************/
/* */
/* Function : Constructor for the Worker. Initializes the worker */
/* */
/* Type : Constructor */
/* */
/* Input Para : None */
/* */
/* Output Para : None */
/* */
/* Author : I. Oesch */
/* */
/* History : 15.12.2009 IO Created */
/* */
/*****************************************************************************/
Worker::Worker() : MyMutex(QMutex::Recursive)
{
/* procedure data */
/* procedure code */
stopped = false;
TheWorker = this;
}
/*****************************************************************************/
/* End Method : Worker */
/*****************************************************************************/
/*****************************************************************************/
/* Method : GetTheWorker */
/*****************************************************************************/
/* */
/* Function : Returns the only instance of our Worker. Creates a Worker */
/* if none exist */
/* */
/* Type : Constructor */
/* */
/* Input Para : None */
/* */
/* Output Para : Pointer to the worker instance */
/* */
/* Author : I. Oesch */
/* */
/* History : 15.12.2009 IO Created */
/* */
/*****************************************************************************/
Worker* Worker::GetTheWorker()
{
/* procedure data */
/* procedure code */
/* Create our only instance if not allready exist */
if (TheWorker == NULL) {
TheWorker = new Worker;
}
return TheWorker;
}
/*****************************************************************************/
/* End Method : GetTheWorker */
/*****************************************************************************/
/*****************************************************************************/
/* Method : run */
/*****************************************************************************/
/* */
/* Function : Runs the client code by calling gfxmain() */
/* if none exist */
/* */
/* Type : Protected */
/* */
/* Input Para : None */
/* */
/* Output Para : None */
/* */
/* Author : I. Oesch */
/* */
/* History : 15.12.2009 IO Created */
/* */
/*****************************************************************************/
void Worker::run()
{
/* procedure data */
/* procedure code */
/* Create standard arguments for gfxmain, using */
/* informtions from Qt of original arguments */
/* Get original arguments */
QStringList CommandLine = QCoreApplication::arguments();
/* And convert to c-main form */
int argc = CommandLine.size();
char **Argv = new char *[argc];
for (int i = 0; i < argc; ++i) {
QByteArray text = CommandLine.at(i).toLocal8Bit();
Argv[i] = new char[text.size() + 1];
strcpy(Argv[i], text.constData());
}
/* Get path to executable */
QString BasePath = QCoreApplication::applicationDirPath ();
/* Call usercode, passin standardargumets and applicationpath */
gfxmain(argc, Argv, BasePath.toLatin1().constData());
/* Shut down our application if gfxmain() returns */
stopped = false;
for (int i = 0; i < argc; ++i) {
delete[] Argv[i];
}
delete[] Argv;
emit Sclose();
}
/*****************************************************************************/
/* End Method : run */
/*****************************************************************************/
/*****************************************************************************/
/* Method : Interface functions */
/*****************************************************************************/
/* */
/* Function : Just convert calls from client code int signals */
/* and thus managing interthread communication. */
/* */
/* Type : Protected */
/* */
/* Input Para : Variable */
/* */
/* Output Para : Variable */
/* */
/* Author : I. Oesch */
/* */
/* History : 15.12.2009 IO Created */
/* */
/*****************************************************************************/
void Worker::stop()
{
stopped = true;
}
void Worker::SetAutoUpdate(int Mode)
{
emit SSetAutoUpdate(Mode != 0);
}
void Worker::SetDrawMode(int Mode)
{
emit SSetDrawMode(Mode);
}
void Worker::setfillstyle(int FillType, unsigned long RGBColor)
{
emit Ssetfillstyle(FillType, RGBColor);
}
void Worker::SetBackgroundColor(unsigned long RGBColor)
{
emit SSetBackgroundColor(RGBColor);
}
void Worker::bar(int x , int y, int w, int h)
{
emit Sbar(x, y, w, h);
}
void Worker::setcolor(unsigned long RGBColor)
{
emit Ssetcolor(RGBColor);
}
void Worker::setlinestyle(int LineStyle, int dummy, int Width)
{
emit Ssetlinestyle(Width);
(void)LineStyle; /*Silence unused param warning */
(void)dummy; /*Silence unused param warning */
}
int Worker::getTimeInmsc()
{
return QTime::currentTime().msecsSinceStartOfDay();
}
#if 0
// unused
void Worker::rectangle(int x, int y, int w, int h)
{
(void)x; /*Silence unused param warning */
(void)y; /*Silence unused param warning */
(void)w; /*Silence unused param warning */
(void)h; /*Silence unused param warning */
}
#endif
void Worker::ellipse(int x, int y, int w, int h)
{
emit SDrawEllipse(x, y, w, h);
}
;
void Worker::line(int x1 , int y1, int x2, int y2)
{
emit Sline(x1 , y1, x2, y2);
}
void Worker::polygon(int *Edges, int NumberOfEdges)
{
QPolygon *polygon = new QPolygon();
polygon->setPoints(NumberOfEdges, Edges);
emit Spolygon(polygon);
// Polygon will be deletet by recipient */
}
void Worker::polyline(int *Edges, int NumberOfEdges)
{
QPolygon *polygon = new QPolygon();
polygon->setPoints(NumberOfEdges, Edges);
emit Spolyline(polygon);
// Polygon will be deletet by recipient */
}
void Worker::putpixel(int x1 , int y1)
{
emit Spixel(x1, y1);
}
unsigned long Worker::GetPixelOSI (int x, int y)
{
unsigned long RGBColor;
emit SGetPixel(&RGBColor, x, y);
return RGBColor;
}
void Worker::outtextxy(int x, int y, const char *Text)
{
emit SDrawText(x, y, QString(Text));
}
/*****************************************************************************/
/* Procedure : SelectFont */
/*****************************************************************************/
/* */
/* Function : Selects a font for future Textdrawings */
/* */
/* Type : Global */
/* */
/* Input Para : FontName Name of the Font (eg. "Times") */
/* May be NULL if only size ore style of current */
/* are to be changed */
/* Points Fontsize */
/* Style May be any Combination of the Enum Fontstyle */
/* */
/* Output Para : None */
/* */
/* Author : I. Oesch */
/* */
/* History : 11.01.2010 IO Created */
/* */
/*****************************************************************************/
void Worker::SelectFont(const char *FontName, int Points, int Style)
{
/* procedure data */
/* procedure code */
/* Count Commands in interprocessqueue */
emit SIncrementUnhandledCommands();
/* Set the color for the text to be drawn with */
emit SSelectFont(FontName, Points, Style);
}
/*****************************************************************************/
/* End : SelectFont */
/*****************************************************************************/
/*****************************************************************************/
/* Procedure : GetTextDimensions */
/*****************************************************************************/
/* */
/* Function : Calculates the requred space for the given Text */
/* */
/* Type : Global */
/* */
/* Input Para : Text Text to find required space for */
/* */
/* Output Para : Textdimensons (Length, Height and underlength) */
/* */
/* Author : I. Oesch */
/* */
/* History : 11.01.2010 IO Created */
/* */
/*****************************************************************************/
TextDimensionType Worker::GetTextDimensions (const char *Text)
{
/* procedure data */
TextDimensionType TextInfo;
/* procedure code */
/* Set the color for the text to be drawn with */
emit SGetTextDimensions(&TextInfo, Text);
return TextInfo;
}
/*****************************************************************************/
/* End : GetTextDimensions */
/*****************************************************************************/
void Worker::initwindow(int Width, int Height)
{
emit SSetWindowSize(Width, Height);
emit SShow();
}
;
//void settextstyle(TRIPLEX_FONT, HORIZ_DIR, 0);
//void setusercharsize(1, 3, 1, 3);
void Worker::closegraph( )
{
emit SHide();
}
int Worker::getch()
{
int Code = 0;
emit SGetKeyEvent(&Code);
return Code;
}
int Worker::kbhit()
{
int Code = 0;
emit SGetBufferedKeyPressEvents(&Code);
return Code;
}
int Worker::kbEvent()
{
int Code = 0;
emit SGetBufferedKeyEvents(&Code);
return Code;
}
void Worker::GetMouseState (struct MouseInfo *Info)
{
emit SGetMouseState(Info);
}
void Worker::GetMouseEvent (struct MouseInfo *Info)
{
emit SGetMouseEvent(Info);
}
void Worker::delay(int Time)
{
msleep(Time);
}
void Worker::cleardevice()
{
emit Scleardevice();
}
int Worker::CreateImage(int Width, int Height)
{
int Id = 0;
emit SCreateImage(&Id, Width, Height);
return Id;
}
int Worker::CreateImage(int SrcID, int x, int y, int Width, int Height)
{
int Id = 0;
emit SCreateImage(&Id, SrcID, x, y, Width, Height);
return Id;
}
int Worker::SetEditedImage(int ImageId)
{
/* Count Commands in interprocessqueue */
emit SIncrementUnhandledCommands();
emit SSetEditedImage(ImageId);
return 0;
}
void Worker::GetImageSize(int ImageId, int *Width, int *Height)
{
emit SGetImageSize(ImageId, Width, Height);
}
ColorType *Worker::GetPixelDataPointer(int ImageId, int *Length)
{
void *Ptr = 0;
emit SGetPixelDataPointer(ImageId, &Ptr, Length);
return (ColorType *)Ptr;
}
int Worker::DrawImage(int ImageId, int x, int y)
{
emit SDrawImage(ImageId, x, y);
return 0;
}
void Worker::CopyToImage(int x, int y, int Width, int Height, int ImageId)
{
emit SCopyToImage(x, y, Width, Height, ImageId);
}
void Worker::AddAlphaMask(int ImageId, int Mode, unsigned long Color)
{
emit SAddAlphaMask(ImageId, Mode, Color);
}
int Worker::LoadImage(const char *FileName)
{
int Id = 0;
emit SLoadImage(&Id, FileName);
return Id;
}
void Worker::SaveImage(int Id, const char *FileName, const char *Format, int Quality)
{
emit SSaveImage(Id, FileName, Format, Quality);
}
void Worker::Rotate(float Angle)
{
emit SRotate(Angle);
}
void Worker::Translate(float dx, float dy)
{
emit STranslate(dx, dy);
}
void Worker::Scale(float Scalingx, float Scalingy)
{
emit SScale(Scalingx, Scalingy);
}
void Worker::ResetTransformations(void)
{
emit SResetTransformations();
}
int Worker::DestroyImage(int ImageId)
{
emit SDestroyImage(ImageId);
return 0;
}
void Worker::SetQtOptions(enum QTOptions Option, long int Value)
{
emit(SSetQtOptions(Option, Value));
}
void Worker::PlaySoundContinuous(const char *FileName)
{
emit SPlaySoundContinuous(QString(FileName));
}
void Worker::PlaySoundContinuous(void)
{
emit SStartPlaySoundContinuous();
}
void Worker::StopContinuousSound(void)
{
emit SStopContinuousSound();
}
void Worker::PlaySound(const char *FileName)
{
emit SPlaySound(FileName);
}
void Worker::StartTimer(int IntervalTime, void *Parameter, void (*Handler)(void *))
{
emit SStartTimer(IntervalTime, Parameter, (void *)Handler);
}
void Worker::StopTimer(void)
{
emit SStopTimer();
}
/*****************************************************************************/
/* End Method : Interfacefunctions */
/*****************************************************************************/
/*****************************************************************************/
/* Method : CreateThread */
/*****************************************************************************/
/* */
/* Function : Creates and starts a new Thread (Uses Threadpool from Qt) */
/* */
/* Type : Public */
/* */
/* Input Para : Parameter Parameter for Threadfunction */
/* Function Function to be called as new Thread with */
/* Parameter parameter. Thread will end if Function */
/* returns */
/* */
/* Output Para : True if thread was created and started sucessfully */
/* */
/* Author : I. Oesch */
/* */
/* History : 05.4.2012 IO Created */
/* */
/*****************************************************************************/
bool Worker::CreateThread(void *Parameter, void (*Function)(void *))
{
/* Method data declaration */
/* Method code declaration */
/* Only create Thread if got valid functionpointer */
if (Function != NULL) {
/* Create a new runable object for this function and send to threadpool */
/* for execution */
MyRunableObject *runnable = new MyRunableObject(Parameter, Function);
return QThreadPool::globalInstance()->tryStart (runnable);
} else {
return false;
}
}
/*****************************************************************************/
/* End Method : CreateThread */
/*****************************************************************************/
/*****************************************************************************/
/* Method : OpenFileDialog */
/*****************************************************************************/
/* */
/* Function : Opens a Filedialog and returns selected filename */
/* */
/* Type : Public */
/* */
/* Input Para : Mode Defines if load or save dialog */
/* Title Title of dialog */
/* Directory Starting directory, may be empty string */
/* Filter Filefilter in the form */
/* "My files (*.mf *.myf);;All Files (*.*)" */
/* Set to empty string of not used */
/* SelectedFilter Selected Filefilter */
/* Set to empty string of not used */
/* Options Optional behavior of Dialog, use FDO_USE_DEFAULT */
/* FilenameBuffer Buffer to store filename with path */
/* MaxNameLength Length of buffer, this is the maximum */
/* amount of characters placed in Buffer */
/* Filename will be truncated if too long */
/* */
/* Output Para : True if thread was created and started sucessfully */
/* */
/* Author : I. Oesch */
/* */
/* History : 05.4.2012 IO Created */
/* */
/*****************************************************************************/
bool Worker::OpenFileDialog(int Mode, const char *Title, const char *Directory, const char *Filter, const char *PreferredFilter, int Options, char *FilenameBuffer, int MaxNameLength, char *SelectedFilter, int MaxFilterLength)
{
#if 1
// Must run in GUI Main Thread
/* Method data declaration */
bool RCode;
/* Method code declaration */
emit SOpenFileDialog(&RCode, Mode, Title, Directory, Filter, PreferredFilter, Options, FilenameBuffer, MaxNameLength, SelectedFilter, MaxFilterLength);
return RCode;
#else
/* Method data declaration */
QString TheFileName;
QFileDialog::Options MyOptions(Options);
QString QSSelectedFilter(SelectedFilter);
/* Method code declaration */
/* Open selected kind of dialog */
if (Mode == FDM_FILE_SAVE) {
if (MyOptions == FDO_USE_DEFAULT) {
MyOptions = 0;
}
TheFileName = QFileDialog::getSaveFileName(NULL, QString(Title), QString(Directory), QString(Filter), &QSSelectedFilter, MyOptions);
} else if (Mode == FDM_DIRECTORY) {
if (MyOptions == FDO_USE_DEFAULT) {
MyOptions = QFileDialog::ShowDirsOnly;
}
TheFileName = QFileDialog::getExistingDirectory(NULL, Title, Directory, MyOptions);
} else {
if (MyOptions == FDO_USE_DEFAULT) {
MyOptions = 0;
}
TheFileName = QFileDialog::getOpenFileName(NULL, QString(Title), QString(Directory), QString(Filter), &QSSelectedFilter, MyOptions);
}
/* Copy resulting path to receiver array */
strncpy(FilenameBuffer, TheFileName.toLatin1().constData(), MaxNameLength);
if (SelectedFilter != NULL) {
/* Copy selected filter receiver array */
strncpy(SelectedFilter, QSSelectedFilter.toLatin1().constData(), MaxFilterLength);
}
/* return false if no file was selected */
if (TheFileName.isNull()) {
return false;
} else {
return true;
}
#endif
}
/*****************************************************************************/
/* End Method : OpenFileDialog */
/*****************************************************************************/
/*****************************************************************************/
/* End Class : Worker */
/*****************************************************************************/
|
#include<bits/stdc++.h>
using namespace std;
main()
{
char line[150], line2[150];
int i,j,k,l,m,n, len;
while(gets(line))
{
if(!(strcmp(line, "DONE"))) break;
else
{
for(i=0; line[i]!='\0'; i++)
{
while (!((line[i]>='a' && line[i]<='z') || (line[i]>='A' && line[i]<='Z' || line[i]=='\0')))
{
for(j=i; line[j]!='\0'; ++j)
{
line[j]=line[j+1];
}
line[j]='\0';
}
}
/*puts(line);
cout<<len;*/
for(k=0; line[k]!='\0'; k++)
{
if(line[k]>='A' && line[k]<='Z')
line[k]=line[k]+32;
}
//puts(line);
for(k=0,n=0; line[k]!='\0';n++, k++)
{
line2[n]=line[k];
}
line2[n]='\0';
//strcpy(line2,line);
// puts(line2);
//strrev(line2);
len=strlen(line2);
for(l=0,k=len-1; l<k ;l++,k--)
{
m=line2[k];
line[k]=line2[l];
line2[l]=m;
}
//puts(line2);
if(strcmp(line,line2)==0)
printf("You won't be eaten!\n");
else
printf("Uh oh..\n");
}
}
return 0;
}
|
#include <iostream>
#include <vector>
using namespace std;
struct TreeNode {
int val;
TreeNode* left;
TreeNode* right;
};
bool isSubTree(TreeNode* t1, TreeNode* t2) {
if(!t1)
return !t2;
if(t1->val != t2->val)
return false;
bool leftSubTree = isSubTree(t1->left, t2->left);
bool rightSubTree = isSubTree(t1->right, t2->right);
return leftSubTree && rightSubTree;
}
bool searchSubTree(TreeNode* t1, TreeNode* t2) {
if(!t2)
return true;
if(!t1)
return false;
if(t1->val == t2->val) {
bool subTree = isSubTree(t1, t2);
if(subTree)
return true;
}
bool leftSubTree = searchSubTree(t1->left, t2);
bool rightSubTree = searchSubTree(t1->right, t2);
return leftSubTree || rightSubTree;
}
TreeNode* makeTree(vector<int>& nums, int index){
if(index >= nums.size()){
return nullptr;
}
if(nums[index] == -1){
return nullptr;
}
TreeNode* node = new TreeNode();
node->val = nums[index];
node->left = makeTree(nums, (index + 1) * 2 - 1);
node->right = makeTree(nums, (index + 1) * 2);
return node;
}
void outputTree(TreeNode* node) {
if(!node)
return;
cout << node->val << endl;
outputTree(node->left);
outputTree(node->right);
}
int main(void){
vector<int> nums1 = {0, 1, 2, 3, 4, 5, 6, 7, 8};
vector<int> nums2 = {9, 10, 11};
TreeNode* t1 = makeTree(nums1, 0);
TreeNode* t2 = makeTree(nums2, 0);
outputTree(t1);
cout << (searchSubTree(t1, t2) ? "true" : "false") << endl;
vector<int> nums3 = {2, 5, 6};
TreeNode* t3 = makeTree(nums3, 0);
cout << (searchSubTree(t1, t3) ? "true" : "false") << endl;
return 0;
}
|
#ifndef BULLET_H
#define BULLET_H
#include <SFML\Graphics.hpp>
#include "Entity.h"
class Bullet: public Entity {
public:
Bullet(sf::Texture& text, int type, bool enemybullet);
virtual ~Bullet();
void fire(int x, int y); //Fire centre bullet
void fire1(int x, int y); //Fire left bullet
void fire2(int x, int y); //Fire right bullet
void enemyfire(int x, int y); //fire enemy bullets
//void dir(Player& player, Bullet& bullet); // Update directions of bullets for different directions (Uncomment in main and in bullet.cpp file )
void updateDir(float _Speed, int type);
virtual int checkColl(int x, int y);
bool destroy = false;
bool Enemybullet;
int type;
private:
};
#endif
|
#include <iostream>
using namespace std;
// bool sorted(int arr[], int n)
// {
// if (n == 1)
// {
// return true;
// }
// bool restArray = sorted(arr + 1, n - 1);
// return (arr[0] < arr[1] && restArray);
// }
// void dec(int n)
// {
// if (n == 0)
// {
// return;
// }
// cout << n << endl;
// dec(n - 1);
// }
// int main()
// {
// int arr[] = {1,
// 2,
// 53,
// 343};
// cout << sorted(arr, 5) << endl;
// return 0;
// }
int firstocc(int arr[], int n, int i, int key)
{
if (i == n)
{
return -1;
}
if (arr[i] = key)
{
return i;
}
return firstocc(arr, n, i + 1, key);
}
int lastocc(int arr[], int n, int i, int key)
{
if (i == n)
{
return -1;
}
int restArray = lastocc(arr, n, i + 1, key);
if (restArray != -1)
{
return restArray;
}
if (arr[i] == key)
{
return i;
}
return -1;
}
int main()
{
int arr[] = {4,
2,
1,
2,
5,
2,
7};
return 0;
}
|
//Turns the DEFINE_GUID for EventTraceGuid into a const.
#define INITGUID
#pragma warning(disable:4996)
#include <windows.h>
#include <stdio.h>
#include <wbemidl.h>
#include <wmistr.h>
#include <evntrace.h>
#include <tdh.h>
#include <in6addr.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <sstream>
#include <set>
#include <stdlib.h>
#include <memory>
#include <atlconv.h>
#include <unordered_map>
using namespace std;
#include "getAddress.h"
#pragma comment(lib, "tdh.lib")
#define LOGFILE_PATH L"G:\\source\\DIA_findSymbolByVA\\record.etl"
ULONG g_TimerResolution = 0;
BOOL g_bUserMode = FALSE;
TRACEHANDLE g_hTrace = 0;
void WINAPI ProcessEvent(PEVENT_RECORD pEvent);
BOOL pidInWhitelist(DWORD pid);
using namespace std;
wofstream outFile;
DWORD MessageCount;
DWORD curPID[4] = { 0L };
getAddress g;
string path = "";
set<DWORD> whiteListPID;
int CPID;
DWORD fileObject;
unordered_map<DWORD, string> fileNameMap;
void wmain(int argc, char* argv[])
{
short sum = 0;
whiteListPID.clear();
whiteListPID.insert(GetCurrentProcessId());
cout << "Initialized." << endl;
MessageCount = 0L;
begin:
TDHSTATUS status = ERROR_SUCCESS;//设置etw
EVENT_TRACE_LOGFILE trace;
TRACE_LOGFILE_HEADER* pHeader = &trace.LogfileHeader;
ZeroMemory(&trace, sizeof(EVENT_TRACE_LOGFILE));
trace.LoggerName = KERNEL_LOGGER_NAME;
trace.EventRecordCallback = (PEVENT_RECORD_CALLBACK)(ProcessEvent);
trace.ProcessTraceMode = PROCESS_TRACE_MODE_REAL_TIME | PROCESS_TRACE_MODE_EVENT_RECORD;
g_hTrace = OpenTrace(&trace);
if (INVALID_PROCESSTRACE_HANDLE == g_hTrace)
{
wprintf(L"OpenTrace failed with %lu\n", GetLastError());
goto cleanup;
}
g_bUserMode = pHeader->LogFileMode & EVENT_TRACE_PRIVATE_LOGGER_MODE;
if (pHeader->PointerSize != sizeof(PVOID))
{
pHeader = (PTRACE_LOGFILE_HEADER)((PUCHAR)pHeader +
2 * (pHeader->PointerSize - sizeof(PVOID)));
}
status = ProcessTrace(&g_hTrace, 1, 0, 0);
if (status != ERROR_SUCCESS && status != ERROR_CANCELLED)
{
wprintf(L"ProcessTrace failed with %lu\n", status);
goto cleanup;
}
cleanup:
if (INVALID_PROCESSTRACE_HANDLE != g_hTrace)
{
status = CloseTrace(g_hTrace);
}
outFile.clear();
WSACleanup();
goto begin;
}
VOID WINAPI ProcessEvent(PEVENT_RECORD pEvent)
{
DWORD status = ERROR_SUCCESS;
PBYTE pUserData = NULL;
UCHAR OPcode;
DWORD PointerSize = 0;
ULONGLONG TimeStamp = 0;
ULONGLONG Nanoseconds = 0;
string strName = "";
string parm = "";
CPID = 0;
OPcode = pEvent->EventHeader.EventDescriptor.Opcode;//OPcode是event type value
if (IsEqualGUID(pEvent->EventHeader.ProviderId, EventTraceGuid) &&
(!OPcode))
{
wprintf(L"A Event is being skipped\n");
}
else
if (
OPcode == 10
|| OPcode == 11
|| OPcode == 32
|| OPcode == 36
|| OPcode == 51
|| OPcode == 16
|| OPcode == 64
|| OPcode == 74
|| OPcode == 72
|| OPcode == 33
|| OPcode == 34
|| OPcode == 15
|| OPcode == 12
|| OPcode == 13
)
{
pUserData = (PBYTE)pEvent->UserData;
if (OPcode == 11 && pEvent->EventHeader.ProviderId.Data1 == 2586315456){
pUserData += 24;
USES_CONVERSION;
parm = string(W2A((wchar_t *)pUserData));
CPID = pEvent->EventHeader.ProcessId;
}else
if (OPcode == 12 && pEvent->EventHeader.ProviderId.Data1 == 2586315456){
pUserData += 24;
USES_CONVERSION;
parm = string(W2A((wchar_t *)pUserData));
CPID = pEvent->EventHeader.ProcessId;
}else
if (OPcode == 13 && pEvent->EventHeader.ProviderId.Data1 == 2586315456){
pUserData += 24;
USES_CONVERSION;
parm = string(W2A((wchar_t *)pUserData));
CPID = pEvent->EventHeader.ProcessId;
}else
if (OPcode == 15 && pEvent->EventHeader.ProviderId.Data1 == 2586315456){
pUserData += 24;
USES_CONVERSION;
parm = string(W2A((wchar_t *)pUserData));
CPID = pEvent->EventHeader.ProcessId;
}
if (OPcode == 33 && pEvent->EventHeader.ProviderId.Data1 == 1171836109){
pUserData += 24;
USES_CONVERSION;
parm = string(W2A((wchar_t *)pUserData));
CPID = pEvent->EventHeader.ProcessId;
}else
if (OPcode == 34 && pEvent->EventHeader.ProviderId.Data1 == 1171836109){
pUserData += 24;
USES_CONVERSION;
parm = string(W2A((wchar_t *)pUserData));
CPID = pEvent->EventHeader.ProcessId;
}
if (OPcode == 51){
DWORD address = *(DWORD *)pUserData;
address &= 0xFFFFFFF;
USES_CONVERSION;
if (g.addressToName.find(address) != g.addressToName.end())
strName = string(W2A(g.addressToName[address]));
CPID = curPID[pEvent->BufferContext.ProcessorNumber];
}
else
if (OPcode == 11 && pEvent->EventHeader.ProviderId.Data1 == 2924704302){
pUserData += 24;
USES_CONVERSION;
parm = string(W2A((wchar_t *)pUserData));
CPID = pEvent->EventHeader.ProcessId;
}
else
if (OPcode == 36 && pEvent->EventHeader.ProviderId.Data1 == 1030727889){
//CS
DWORD threadID = *(DWORD *)pUserData;
int processorID = pEvent->BufferContext.ProcessorNumber;
curPID[processorID] = GetProcessIdOfThread(OpenThread(THREAD_QUERY_INFORMATION, false, threadID));
}
else
if (OPcode == 16 && pEvent->EventHeader.ProviderId.Data1 == 2924704302){
pUserData += 24;
USES_CONVERSION;
parm = string(W2A((wchar_t *)pUserData));
CPID = pEvent->EventHeader.ProcessId;
}
else
if (OPcode == 72){
pUserData += 8;
DWORD threadID = *(DWORD *)pUserData;
CPID = GetProcessIdOfThread(OpenThread(THREAD_QUERY_INFORMATION, false, threadID));
pUserData += 8;
fileObject = *(DWORD *)pUserData;
parm=fileNameMap[fileObject];
}
else
if (OPcode == 32 && pUserData&& pEvent->EventHeader.ProviderId.Data1 == 2429279289){
fileObject = *(DWORD *)pUserData;
pUserData += 8;
//strName = "NtCreateFile";
USES_CONVERSION;
parm = string(W2A((wchar_t *)pUserData));
fileNameMap[fileObject] = parm;
goto cleanup;
}
else
if (OPcode == 64){
pUserData += 8;
DWORD threadID = *(DWORD *)pUserData;
CPID = GetProcessIdOfThread(OpenThread(THREAD_QUERY_INFORMATION, false, threadID));
pUserData += 8;
fileObject = *(DWORD*)pUserData;
pUserData += 20;
//strName = "NtCreateFile";
USES_CONVERSION;
parm = string(W2A((wchar_t *)pUserData));
fileNameMap[fileObject] = parm;
}
else
if (OPcode == 74){
pUserData += 8;
DWORD threadID = *(DWORD *)pUserData;
CPID = GetProcessIdOfThread(OpenThread(THREAD_QUERY_INFORMATION, false, threadID));
pUserData += 8;
fileObject = *(DWORD *)pUserData;
//strName = "NtCreateFile";
parm = fileNameMap[fileObject];
}
else
if (OPcode == 10){
pUserData += 0;
if (pEvent->EventHeader.ProviderId.Data1 == 749821213){
pUserData += 16;
CPID = *(DWORD*)pUserData;
pUserData += 40;
//strName = "NtOpenSection";
USES_CONVERSION;
parm = string(W2A((wchar_t*)pUserData));
}
else
if (pEvent->EventHeader.ProviderId.Data1 == 2924704302){
pUserData += 24;
//strName = "NtCreateKey";
USES_CONVERSION;
parm = string(W2A((wchar_t*)pUserData));
CPID = pEvent->EventHeader.ProcessId;
}
}
cleanup:
if (CPID)
{
if (!pidInWhitelist(CPID))
{
MessageCount++;
if (MessageCount % 10000 == 0)
{
wcout << L"published " << MessageCount << L" messages!" << endl;
}
}
}
if (ERROR_SUCCESS != status || NULL == pUserData)
{
CloseTrace(g_hTrace);
}
}
}
BOOL pidInWhitelist(DWORD pid){
string a;
set<DWORD>::iterator i = whiteListPID.find(pid);
if (i != whiteListPID.end())
return true;
else
return false;
}
|
//
// SDL_windows.cpp for training in /home/franco_n/tek_one/test/cpp/git/pokemon_poubelle/classes
//
// Made by François Clément
// Login <franco_n@epitech.net>
//
// Started on Tue Sep 15 18:53:18 2015 François Clément
// Last update Tue Sep 15 19:22:04 2015 François Clément
//
#include "SDL_windows.hh"
bool SDLwindows::createWindows(int x, int y, int bpp, int mode)
{
SDL_SetVideoMode(x, y, bpp, mode);
return true;
}
|
//---------彩票主程序----------
#include"caipiao.h"
const int M=0,N=400;
//----------------------------------------------
int main()
{
int a[2][33+16]={0}; //a[0][i]代表红球和蓝球
int b[N][7]={0}; //a[1][0]-----a[32]代表红球出现的次数,
shuchuhlq(a); //a[1][33]-----a[48]代表篮球出现的次数
wenjiansr(b);
jisuancishu(a,b);
lanqiujiange(b);
hongqiujiange(b);
lan4fq(b);
lan4qy(b);
fenqu11(b);
qiuyu11(b);
cin.get();
}
|
#ifndef __INCLUDE_UDP_SOCK_H__
#define __INCLUDE_UDP_SOCK_H__
#include "Def.h"
#include "Sock.h"
//UDP套接字类
class CUdpSock : public CSock
{
public:
CUdpSock();
~CUdpSock();
public:
//打开打开套接字
int Open( const char* ip, int port );
//设置远端地址
//参数:remote:远端网络地址
//返回值:0成功,-1失败
int SetRemote( const char* ip, int port );
//发送
//参数:buf:发送内容,len:发送长度
//返回值:0成功,-1失败
int Send( const char* buf, int len );
//接收
//参数:buf:接收缓存,len:缓存长度
//返回值:0成功,-1失败
int Recv( char* buf, int len );
public:
//设置多播发送报文的TTL
//返回值: -1 失败 0 成功
int SetMulticastTTL( uint8_t TTL );
//设置是否禁止组播数据回送,true-回送,false-不回送。
//返回值: -1 失败 0 成功
int SetMulticastLoop( bool isloop );
private:
struct sockaddr_in m_remote_addr;
};
#endif
|
/*
** $Id: ldebug.h,v 2.14 2015/05/22 17:45:56 roberto Exp $
** Auxiliary functions from Debug Interface module
** See Copyright Notice in lua.h
*/
#ifndef ldebug_h
#define ldebug_h
#include "lstate.h"
namespace youmecommon
{
#define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1)
#define getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : -1)
#define resethookcount(L) (L->hookcount = L->basehookcount)
LUAI_FUNC l_noret luaG_typeerror(lua_State *L, const TValue *o,
const char *opname);
LUAI_FUNC l_noret luaG_concaterror(lua_State *L, const TValue *p1,
const TValue *p2);
LUAI_FUNC l_noret luaG_opinterror(lua_State *L, const TValue *p1,
const TValue *p2,
const char *msg);
LUAI_FUNC l_noret luaG_tointerror(lua_State *L, const TValue *p1,
const TValue *p2);
LUAI_FUNC l_noret luaG_ordererror(lua_State *L, const TValue *p1,
const TValue *p2);
LUAI_FUNC l_noret luaG_runerror(lua_State *L, const char *fmt, ...);
LUAI_FUNC const char *luaG_addinfo(lua_State *L, const char *msg,
TString *src, int line);
LUAI_FUNC l_noret luaG_errormsg(lua_State *L);
LUAI_FUNC void luaG_traceexec(lua_State *L);
}
#endif
|
#ifndef GNRECT_H
#define GNRECT_H
template<typename T>
class GNMAIN_ENTRY GnRect : public GnMemoryObject
{
public:
T left;
T top;
T right;
T bottom;
public:
GnRect() : left(0), top(0), right(0), bottom(0)
{}
GnRect(T l, T t, T r, T b) : left(l), top(t), right(r), bottom(b)
{}
void MoveX(T val) {
left += val;
right += val;
}
void MoveY(T val) {
top += val;
bottom += val;
}
void SetWidth(T val) {
T delta = val - GetWidth();
right += delta;
}
void SetHeight(T val) {
T delta = val - GetHeight();
bottom += delta;
}
inline T GetWidth(){
return right - left;
};
inline T GetHeight(){
return bottom - top;
};
inline bool ContainsPoint(T x, T y) {
if (x >= left && x <= right && y >= top && y <= bottom )
return true;
return false;
}
inline bool ContainsPointX(T x) {
if (x >= left && x <= right )
return true;
return false;
}
inline bool ContainsPointY(T y) {
if ( y >= top && y <= bottom )
return true;
return false;
}
inline bool ContainsRect(GnRect<T>& rect) {
if ( ( ( rect.left >= left && rect.left <= right ) || ( rect.right >= left && rect.right <= right ) )
&& ( ( rect.top <= top && rect.top >= bottom ) || ( rect.bottom <= top && rect.bottom >= bottom ) ) )
return true;
return false;
}
inline bool ContainsRectHeight(GnRect<T>& rect) {
if( ( rect.top >= top && rect.top <= bottom ) || ( rect.bottom >= top && rect.bottom <= bottom ) )
return true;
return false;
}
inline bool ContainsRectWidth(GnRect<T>& rect) {
if ( ( rect.left >= left && rect.left <= right )
|| ( rect.right >= left && rect.right <= right ) )
return true;
return false;
}
};
class GNMAIN_ENTRY GnFRect : public GnRect<float>
{
GnDeclareDataStream;
GnFRect() {
}
GnFRect(float l, float t, float r, float b) : GnRect<float>(l, t, r, b){
}
};
class GNMAIN_ENTRY GnIRect : public GnRect<gint32>
{
GnDeclareDataStream;
GnIRect() {
}
GnIRect(gint32 l, gint32 t, gint32 r, gint32 b) : GnRect<gint32>(l, t, r, b){
}
};
#endif // GNRECT_H
|
#include "utils.hpp"
#include "loading_ptts.hpp"
namespace pc = proto::config;
namespace nora {
namespace config {
loading_ptts& loading_ptts_instance() {
static loading_ptts inst;
return inst;
}
void loading_ptts_set_funcs() {
loading_ptts_instance().check_func_ = [] (const auto& ptt) {
if (!check_conditions(ptt.conditions())) {
CONFIG_ELOG << " check conditions failed";
}
};
}
}
}
|
//
// uiWindow.cpp
// TuboWariProjection
//
// Created by Shuya Okumura on 2013/01/26.
//
//
#include "uiWindow.h"
//////////////////
//////GLOBAL//////
bool bTail = false;
bool trTail = false;
vector <ofPoint> messagePoint;
ofFloatColor mainPink = ofFloatColor(1.0f, 0.44f, 0.82f, 1.0f);
int currentScene = 0;
//main
ofFbo screenFbo;
ofFbo monitorFbo;
ofPoint point1 = ofPoint((float)PROJECTION_SIZE_W / 2, (float)PROJECTION_SIZE_H);
ofPoint point2 = ofPoint((float)PROJECTION_SIZE_W / 2, (float)PROJECTION_SIZE_H);
//grotesq
int grotesParticlesNum = 5000;
bool bGrotesq = false;
grotes grotesq;
bool bHaradaFire = false;
grotes haradaFire;
bool bHaradaFireFadeOut = false;
float haradaFireFadeOutAmt = 1.0f;
//xtions
ofFbo xtionFbo;
myXtionOperator xtions;
ofTexture tex[XTION_NUM];
bool bSetUp = false;
bool bShutDown = false;
bool trSaveDepthByFrame[XTION_NUM] = { false};//new!
bool trStopSaveDepthByFrame[XTION_NUM] = {false};
//openCv
bool bOpenCv = true;
ofColor openCvDrawColor = mainPink;
bool toggleCvFadeOut = false;
bool bCfinderDraw = true;
ofxCvContourFinder cfinder;
int gImgThreshold = 0;
bool bCvBlur = true;
bool bCvNoise = false;
float cvNoiseAmt = 40.0f;
bool bDrawScene1Blob = false;
bool bSeraBlobMappingDraw = false;
bool bSeraHeadMappingDraw = false;
ofPoint seraHeadPos[1] = {ofPoint(759.0f, 548.0f)};
bool bUpdateXtion[XTION_NUM] = {true};
bool bDraw[XTION_NUM] = {true, false, false};
int thresholdNear[XTION_NUM];//2
int thresholdFar[XTION_NUM];//3
float rotx[XTION_NUM] = {-10.8, 0.0f, -45.0f};//5
float roty[XTION_NUM] = {-59.4f, 0.0f, -9.0f};//6
float rotz[XTION_NUM] = {-21.6f, 0.0f, -12.6f};//7
ofVec3f axis[XTION_NUM] = {ofVec3f(2400.0f, 1920.0f, -5000.0f), ofVec3f(), ofVec3f(3680.0f, 320.0f, -4950.0f)};//8
float scale[XTION_NUM] = {0.85f, 1.0f, 0.90f};
float aspect[XTION_NUM] = {1.115f, 1.0f, 0.9875f };
float scaleZ[XTION_NUM] = {0.884f, 1.0f, 0.623f};
int bgCapturePlay[XTION_NUM] = {20};//1
bool bCaptureBg[XTION_NUM] = {false};
bool bUseBgDepth[XTION_NUM] = {false};//4
int depthSlider[XTION_NUM] = { 10000 };
bool trLoadBg[XTION_NUM] = {false};
bool bSaveBgAsImage[XTION_NUM] = {false};
bool trGetPointDepth[XTION_NUM] = {true};
bool bKirakiraIncrease = true;
ofPoint depthCheckPoint[XTION_NUM] = {ofPoint(0.0f, 0.0f)};///
ofPoint depthCheckPoint2[XTION_NUM] = {ofPoint((float)CAPTURE_WIDTH, (float)CAPTURE_HEIGHT)};
int depthPointValue[XTION_NUM] = {0};///
bool bDrawMesh = false;
float pointSize = 4.0;//9
int step = 2;//10
int minArea = 50;//11
int maxArea = 500000;//12
int nConsidered = 10;//13
bool bFindHoles = true;//14
bool bUseApproximation = true;//15
int choicedXtion = 0;
//point of mapping
bool bMappingDraw = false;
bool bMappingDrawOnMonitor = true;
ofPoint gekijo[8] = {
ofPoint(13.0f,81.5f),
ofPoint(1267.0f,80.0f),
ofPoint(1344.0f, 864.0f),
ofPoint(-68.0f, 879.0f),
ofPoint(204.0f,88.0f),
ofPoint(1077.0f,86.0f),
ofPoint(1056, 627.0f),
ofPoint(221.0f, 634.0f)};//間口
ofPoint rokkaPos[4] = {ofPoint(1022.0f, 480.0f),
ofPoint(1132.0f, 475.0f),
ofPoint(1114.0f, 688.0f),
ofPoint(1005.0f, 688.0f)
};
ofPoint rokkaPosDamy[4];
bool bRokkaDraw = false;
float lineWidth = 4.0f;
ofPoint targetPointA = ofVec3f(PROJECTION_SIZE_W / 2, PROJECTION_SIZE_H / 2);
bool bDoorDraw = false;
ofPoint doorPos[6] = {ofPoint(1228.0f,490.0f),
ofPoint(1364.0f, 572.0f),
ofPoint(1315.0f, 673.0f),
ofPoint(1333.0f, 892.0f),
ofPoint(1218.0f, 757.0f),
ofPoint(1230.0f, 688.0f)};
ofPoint doorPosDamy[6];
/////////maho////////////
bool trFadeOutLastMaho = false;
int startMahoTime, currentMahoTime = 0;
ofPoint hondanaPoints[HONDANA_INDEX_NUM] = {ofPoint(41.0f, 464.0f),
ofPoint(222.0f, 482.0f),
ofPoint(224.0f, 718.0f),
ofPoint(-6.0f, 905.0f),
ofPoint(-196.0f, 703.0f),
ofPoint(-250.0f, 555.0f)
};
float hondanaNoiseAmt = 15.0f;
int mahoIndex = 0;
int keenTime = 300;
int mahoPhase2Time[7] = {3000};
ofPoint mahoPos[2] = {ofPoint()};
int mahoPhase = 0;
bool trMaho = false;
//sera
ofPoint seraPos[1] = {ofPoint(512.0f, 480.0f)};
bool bSera = false;
float seraParticleKasokuAmt = 20.0f;
float seraParticleRadius = 6.0f;
ofPoint seraBlob[6] = {ofPoint(720.0f, 405.0f),
ofPoint(858.0f, 407.0f),
ofPoint(897.0f, 500),
ofPoint(856.0f, 603.0f),
ofPoint(718.0f, 605.0f),
ofPoint(692.0f, 493.0f),};
bool bDrawSeraBlob = false;
//harada door
float doorGunyaAmt = 5.0f;
//line
bool bLine1 = true;
int line1Num = 200;
float accelAmt = 98.75f;
float lineColorAmt = 0.35f;
//bunshi
bool bBunshi = false;
int bunshiNum = 55;//10 - 1000;
float mainParticleSize = 5.0f;
float radiusAmt = 0.4f;//0.1 - 3.0f;
float radiusMin = 1.6f;
float radiusMax = 2.8f;
float energyAmt = 0.5f;//1-10;
float kasokuAmt = 22.0f;//1.0 - 100.0f
float alphaAmt = 0.785f;
int mainBunshiLifeTime = 1445;
//line2
bool bLine2 = true;
int line2Num = 22;
float mahoLine2MinLength = 34.5f;//2.0f - 300.0f
float mahoLine2MaxLength = 110.5f;//
float lengthNoiseAmt = 16.4f;
float line2speed = 0.816f;//0 - 1
float mahoLine2AngleAmt = 0.30f;//0 - 60
float line2width = 2.5f;
//blobs
bool bBlob = true;
int blobPointNum = 33;//1 - 100 = 10
float sparkRangeMin = 10;//0 - 1000
float sparkRangeMax = 60;
//keen
bool trKeen = false;
float keenWidth = 4.8f;
ofPoint keenStart = ofPoint(500.0f, 500.0f);
ofPoint keenGoal = ofPoint(1000.0f, 1000.0f);
//kirakira
bool bKirakiraDraw = false;
ofPoint kirakiraPos[1] = {ofPoint(1000.0f, 500.0f)};
float hoshiSize = 50.0f; //5.0f
int hoshiMainLifeTime = 32;//100 - 10000
float kirakiraHankei = 175.0f;
int kirakiraAmt = 100;
float kirakiraColorRangeAmt = 0.015;//0.0f - 0.1
//chirachira
ofPoint chirachiraPos[1] = {ofPoint(0,0)};
bool bHondanaDraw = false;
//videos
ofQTKitPlayer himawari;
ofQTKitPlayer kaji;
ofPoint himawariPos = ofPoint(100.0f, 270.0f);
ofPoint kajiPos = ofPoint(0.0f, 0.0f);
bool trPlayHimawariVideo = false;
bool bHimawariVideoPlaying = false;
bool bHimawariAlphaStart = false;
bool trHimawariClear = false;
bool trPlayKajiVideo = false;
bool bKajiVideoPlaying = false;
bool bKajiAlphaStart = false;
bool trKajiClear = false;
bool trHimawariLoad = false;
bool trKajiLoad = false;
int fadeTimeMilis = 1000;//1000 - 10000
//custom testApp's
extern char fadeWhite;
extern char fadeMilli;
extern int WhiteFading;
extern int milli;
extern int FadingStartTime;
bool bBackWhite = false;
//setting
bool bMaskScreen = true;
lastParticles lastparticles;
//グローバルの初期化
uiWindow::uiWindow(){
for (int i = 0; i < XTION_NUM; i++) {
tex[i].allocate(CAPTURE_WIDTH, CAPTURE_HEIGHT, GL_RGB);
}
for (int i = 0; i < SCENE_SIZE; i++) {
phaseNoByScene[i] = 0;
}
// for (int i = 0; i < 6; i++) {
// seraBlob[i].y += 50.0f;
// }
}
void uiWindow::setup(){
//header
gui.setup("OPE 1");
//gui.setTextColorParadox(true);
gui.headerPage->addToggle("Map Draw onMonitor", bMappingDraw).setNewColumn(true).setFix(true);
gui.headerPage->addToggle("Map Draw onMonitor", bMappingDrawOnMonitor).setNewColumn(true);
gui.headerPage->addToggle("bOpenCv", bOpenCv);
gui.headerPage->addToggle("bMaskScreen", bMaskScreen);
//page 1 ope1========================
gui.addMulti2dSlider("OPE 1", 4, 1, kirakiraPos, 0.0f, (float)PROJECTION_SIZE_W, 0.0f, (float)PROJECTION_SIZE_H, 4.0f / 3.0f, true, 0.6f);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addComboBox("chiceXtion", choicedXtion, XTION_NUM + 1).setNewColumn(true);
gui.addValueMonitor("Phase", phaseNoByScene[1]);
gui.addSlider("cvNoiseAmt", cvNoiseAmt, 0.0f, 300.0f);
gui.addToggle("bCvNoise", bCvNoise);
gui.addToggle("bKirakiraDraw", bKirakiraDraw);
gui.addSlider("hoshiSize", hoshiSize, 0, 50);
gui.addSlider("ColorRangeAmt", kirakiraColorRangeAmt, 0.0f, 0.5f);
gui.addSlider("hoshiMainLifeTime", hoshiMainLifeTime, 5, 100);
gui.addSlider("kirakiraHankei", kirakiraHankei, 0.0f, 1000.0f);
gui.addSlider("kirakiraAmt", kirakiraAmt, 0, 100);
gui.addToggle("cFinderDraw", bCfinderDraw);
gui.addToggle("bCvBlur", bCvBlur);
gui.addSlider("gImgThreshold", gImgThreshold, 0, 255);
//page 2 ope2 =========================
gui.addPage("OPE 2");
gui.addMulti2dSlider("mahoPos", 4, 2, mahoPos, 0.0f, 1280.0f, 0.0f, 960.0f, 4/3, true, 0.6f);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addValueMonitor("Phase", phaseNoByScene[2]).setNewColumn(true);
gui.addButton("toggle maho", trMaho);
gui.addButton("Keen!!", trKeen);
gui.addSlider("keenTime", keenTime, 0, 700);
gui.addToggle("bLine1", bLine1);
gui.addToggle("bBunshi", bBunshi);
gui.addToggle("bLine2", bLine2);
gui.addToggle("bBlob", bBlob);
gui.addTitle("himawari").setNewColumn(true);
gui.addSlider2d("himawariPos", himawariPos, -200.0f, 1280.0f + 200.0f, -200.0f, 960.0f + 200.0f);
gui.addButton("trPlayHimawariVideo", trPlayHimawariVideo);
gui.addToggle("bHimawariVideoPlaying", bHimawariVideoPlaying).setFix(true);
gui.addToggle("bHimawariAlphaStart", bHimawariAlphaStart);
gui.addButton("trHimawariClear", trHimawariClear);
gui.addButton("trHimawariLoad", trHimawariLoad).setFix(true);
//page3 ope3 maho opencv sera======================
gui.addPage("OPE 3");
gui.addMulti2dSlider("mahoPos", 4, 2, mahoPos, 0.0f, 1280.0f, 0.0f, 960.0f, 4/3, true, 0.6f);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addComboBox("chiceXtion", choicedXtion, XTION_NUM + 1).setNewColumn(true);
gui.addValueMonitor("Phase", phaseNoByScene[3]);
gui.addButton("toggle maho", trMaho);
gui.addButton("Keen!!", trKeen);
gui.addSlider("keenTime", keenTime, 0, 700);
gui.addSlider("ParticleKasokuAmt", seraParticleKasokuAmt,5.0f, 30.0f);
gui.addSlider("seraParticleRadius", seraParticleRadius, 0.5, 20.0f);
gui.addToggle("bLine1", bLine1);
gui.addToggle("bBunshi", bBunshi);
gui.addToggle("bLine2", bLine2);
gui.addToggle("bBlob", bBlob);
gui.addToggle("cFinderDraw", bCfinderDraw);
gui.addSlider("Mesh_PointSize", pointSize, 0.001f, 10.0f);
gui.addToggle("bCvBlur", bCvBlur);
gui.addSlider("gImgThreshold", gImgThreshold, 0, 255);
gui.addToggle("bCvNoise", bCvNoise);
gui.addSlider("cvNoiseAmt", cvNoiseAmt, 0.0f, 300.0f);
//page4 ope4 maho opencv door harada======================
gui.addPage("OPE 4");
gui.addMulti2dSlider("mahoPos", 4, 2, mahoPos, 0.0f, 1280.0f, 0.0f, 960.0f, 4/3, true, 0.6f);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addValueMonitor("Phase", phaseNoByScene[4]).setNewColumn(true);
gui.addButton("toggle maho", trMaho);
gui.addButton("Keen!!", trKeen);
gui.addSlider("keenTime", keenTime, 0, 700);
gui.addToggle("bLine1", bLine1);
gui.addToggle("bBunshi", bBunshi);
gui.addToggle("bLine2", bLine2);
gui.addToggle("bBlob", bBlob);
gui.addToggle("cFinderDraw", bCfinderDraw).setNewColumn(true);
gui.addSlider("Mesh_PointSize", pointSize, 0.001f, 10.0f);
gui.addToggle("bCvBlur", bCvBlur);
gui.addSlider("gImgThreshold", gImgThreshold, 0, 255);
gui.addToggle("bCvNoise", bCvNoise);
gui.addSlider("cvNoiseAmt", cvNoiseAmt, 0.0f, 300.0f);
//page5 ope5 grotesq 1======================
gui.addPage("OPE 5");
gui.addMulti2dSlider("mahoPos", 4, 2, mahoPos, 0.0f, 1280.0f, 0.0f, 960.0f, 4/3, true, 0.6f);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addValueMonitor("Phase", phaseNoByScene[5]).setNewColumn(true);
//page6 ope6 maho harada fire======================
gui.addPage("OPE 6");
gui.addMulti2dSlider("mahoPos", 4, 2, mahoPos, 0.0f, 1280.0f, 0.0f, 960.0f, 4/3, true, 0.6f);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addValueMonitor("Phase", phaseNoByScene[6]).setNewColumn(true);
gui.addButton("toggle maho", trMaho);
gui.addButton("Keen!!", trKeen);
gui.addSlider("keenTime", keenTime, 0, 700);
gui.addSlider("grotesParticlesNum", grotesParticlesNum, 0, 10000);
gui.addToggle("bHaradaFireFadeOut", bHaradaFireFadeOut);
gui.addSlider("haradaFireFadeOutAmt", haradaFireFadeOutAmt, 0.0f, 100.0f);
gui.addToggle("bLine1", bLine1);
gui.addToggle("bBunshi", bBunshi);
gui.addToggle("bLine2", bLine2);
gui.addToggle("bBlob", bBlob);
gui.addToggle("cFinderDraw", bCfinderDraw).setNewColumn(true);
gui.addSlider("Mesh_PointSize", pointSize, 0.001f, 10.0f);
gui.addToggle("bCvBlur", bCvBlur);
gui.addSlider("gImgThreshold", gImgThreshold, 0, 255);
gui.addToggle("bCvNoise", bCvNoise);
gui.addSlider("cvNoiseAmt", cvNoiseAmt, 0.0f, 300.0f);
//page7 ope7 maho sushi======================
gui.addPage("OPE 7");
gui.addMulti2dSlider("mahoPos", 4, 2, mahoPos, 0.0f, 1280.0f, 0.0f, 960.0f, 4/3, true, 0.6f);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addValueMonitor("Phase", phaseNoByScene[7]).setNewColumn(true);
gui.addButton("toggle maho", trMaho);
gui.addButton("Keen!!", trKeen);
gui.addSlider("keenTime", keenTime, 0, 700);
//page8 ope8 gomory=====================
gui.addPage("OPE 8");
gui.addMulti2dSlider("mahoPos", 4, 2, mahoPos, 0.0f, 1280.0f, 0.0f, 960.0f, 4/3, true, 0.6f);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addValueMonitor("Phase", phaseNoByScene[7]).setNewColumn(true);
gui.addButton("toggle maho", trMaho);
gui.addButton("Keen!!", trKeen);
gui.addSlider("keenTime", keenTime, 0, 700);
//page9 ope9======================
gui.addPage("OPE 9");
gui.addMulti2dSlider("lastMaho", 4,2, mahoPos, 0.0f, 1280.0f, 0.0f, 960.0f, 4/3, true, 0.6f);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addButton("toggle maho", trMaho).setNewColumn(true);
gui.addToggle("trFadeLastMaho", trFadeOutLastMaho);
gui.addTitle("line");
gui.addToggle("bLine1", bLine1);
gui.addSlider("lineNumber", line1Num, 0, 500);
gui.addSlider("accelAmount", accelAmt, 0.0f, 200.0f);
gui.addSlider("alphaColorAmt", lineColorAmt, 0.0f, 1.0f);
gui.addTitle("bunshis");
gui.addToggle("bBunshi", bBunshi);
gui.addSlider("bunshiNum", bunshiNum, 10, 1000);
gui.addSlider("maniParticleSize", mainParticleSize, 0.1, 10.0f);
gui.addSlider("radiusAmt", radiusAmt, 0.0f, 1.0f);
gui.addRangeSlider("radiusRenge", radiusMin, radiusMax, 0.0f, 40.0f);
gui.addSlider("energyAmt", energyAmt, 0.0f, 5.0f);
gui.addSlider("kasokuAmt", kasokuAmt, 0.0f, 100.0f);
gui.addSlider("alphaAmt", alphaAmt, 0.0f, 1.0f);
gui.addSlider("mainLifeTime", mainBunshiLifeTime, 500, 4000);
gui.addTitle("line2");
gui.addToggle("bLine2", bLine2);
gui.addSlider("line2Num", line2Num, 0, 100);
gui.addSlider("line2Width", line2width, 0.0f, 20.0f);
gui.addRangeSlider("lenth_range", mahoLine2MinLength, mahoLine2MaxLength, 0.0, 300.0f);
gui.addSlider("lengthNoiseAmt", lengthNoiseAmt, 2.0f, 50.0f);
gui.addSlider("line2Speed", line2speed, 0.0f, 1.0f);
gui.addSlider("angleAmt", mahoLine2AngleAmt, 0.0f, 20.0f);
gui.addTitle("blob");
gui.addToggle("bBlob", bBlob);
gui.addSlider("pointNum", blobPointNum, 1, 100);
gui.addRangeSlider("sparkRange", sparkRangeMin, sparkRangeMax, 0.0f,200.0f);
//page10 ope10===============================
gui.addPage("OPE 10 LastMAHO");
gui.addTitle("line");
gui.addToggle("bLine1", bLine1);
gui.addSlider("lineNumber", line1Num, 0, 500).setFix(true);
gui.addSlider("accelAmount", accelAmt, 0.0f, 200.0f).setFix(true);
gui.addSlider("alphaColorAmt", lineColorAmt, 0.0f, 1.0f);
gui.addColorPicker("color1", mainPink).setFix(true);
//bunshis
gui.addBlank();
gui.addTitle("bunshis");
gui.addToggle("bBunshi", bBunshi);
gui.addSlider("bunshiNum", bunshiNum, 10, 1000).setFix(true);
gui.addSlider("maniParticleSize", mainParticleSize, 0.1, 10.0f).setFix(true);
gui.addSlider("radiusAmt", radiusAmt, 0.0f, 1.0f).setFix(true);
gui.addRangeSlider("radiusRenge", radiusMin, radiusMax, 0.0f, 40.0f).setFix(true);
gui.addSlider("energyAmt", energyAmt, 0.0f, 5.0f).setFix(true);
gui.addSlider("kasokuAmt", kasokuAmt, 0.0f, 100.0f).setFix(true);
gui.addSlider("alphaAmt", alphaAmt, 0.0f, 1.0f).setFix(true);
gui.addSlider("mainLifeTime", mainBunshiLifeTime, 500, 4000).setFix(true);
//line2
gui.addBlank();
gui.addTitle("line2");
gui.addToggle("bLine2", bLine2);
gui.addSlider("line2Num", line2Num, 0, 100);
gui.addSlider("line2Width", line2width, 0.0f, 20.0f);
gui.addRangeSlider("lenth_range", mahoLine2MinLength, mahoLine2MaxLength, 0.0, 300.0f);
gui.addSlider("lengthNoiseAmt", lengthNoiseAmt, 2.0f, 50.0f);
gui.addSlider("line2Speed", line2speed, 0.0f, 1.0f);
gui.addSlider("angleAmt", mahoLine2AngleAmt, 0.0f, 20.0f);
//blob
gui.addBlank();
gui.addTitle("blob");
gui.addToggle("bBlob", bBlob);
gui.addSlider("pointNum", blobPointNum, 1, 100);
gui.addRangeSlider("sparkRange", sparkRangeMin, sparkRangeMax, 0.0f, 1000.0f);
//Keen
gui.addTitle("Keen");
gui.addSlider("keenWidth", keenWidth, 0.0f, 50.0f);
gui.addSlider("keenTime", keenTime, 0, 700);
//////////////////-maho-//////////////////////
//page 11 ope11==============================
gui.addPage("OPE 11 Kaji");
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addTitle("kaji").setNewColumn(true);
gui.addSlider2d("kajiPos", kajiPos, -200.0f, 1280.0f + 200.0f, -200.0f, 960.0f + 200.0f);
gui.addButton("trPlayKajiVideo", trPlayKajiVideo);
gui.addToggle("bKajiVideoPlaying", bKajiVideoPlaying).setFix(true);
gui.addToggle("bKajiAlphaStart", bKajiAlphaStart);
gui.addButton("trKajiClear", trKajiClear);
gui.addButton("trKajiLoad", trKajiLoad);
//setting
gui.addPage("gekijo");
gui.addMulti2dSlider("gekijo", 4, 8, gekijo, 0.0f, 1280.0f, 0.0f, 960.0f, 4/3, true, 0.6f);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addPage("door");
gui.addMulti2dSlider("doorPos", 4, 6, doorPos, 0.0f, 1280.0f, 0.0f, 960.0f, 4/3, true, 0.6f);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addToggle("bDoorDraw", bDoorDraw).setNewColumn(true);
gui.addPage("Rokka");
gui.addMulti2dSlider("rokkaPos", 4, 4, rokkaPos, 0.0f, 1280.0f, 0.0f, 960.0f, 4/3, true, 0.6f);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addToggle("rokka Draw", bRokkaDraw).setNewColumn(true);
gui.addPage("Hondana");
gui.addMulti2dSlider("hondanaPoints", 4, HONDANA_INDEX_NUM, hondanaPoints, 0.0f, 1280.0f, 0.0f, 960.0f, 4/3, true, 0.6f);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addToggle("Hondana Draw", bHondanaDraw).setNewColumn(true);
gui.addSlider("hondanaNoiseAmt", hondanaNoiseAmt, 0.0f, 50.0f);
// gui.addPage("seraBlob");
// gui.addMulti2dSlider("seraBlob", 4, 6, seraBlob, 0.0f, 1280.0f, 0.0f, 960.0f, 4/3, true, 0.6f);
// gui.addBlank().setNewColumn(true);
// gui.addBlank().setNewColumn(true);
// gui.addBlank().setNewColumn(true);
// gui.addToggle("seraBlob Draw", bSeraBlobMappingDraw).setNewColumn(true);
gui.addPage("seraHead");
gui.addMulti2dSlider("seraHead", 4, 1, seraHeadPos, 0.0f, 1280.0f, 0.0f, 960.0f, 4/3, true, 0.6f);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
//gui.addToggle("seraBlob Draw", bSeraBlobMappingDraw).setNewColumn(true);
gui.addToggle("seraHead Draw", bSeraHeadMappingDraw).setNewColumn(true);
//xtion
for (int i = 0; i < XTION_NUM; i++) {
gui.addPage("Xtion" + ofToString(i));
gui.addMulti2dSlider("xtion" + ofToString(i), 4, 0, NULL, 0.0f, (float)PROJECTION_SIZE_W, 0.0f, (float)PROJECTION_SIZE_H, 4.0f / 3.0f, true, 0.6f);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addBlank().setNewColumn(true);
gui.addTitle("Xtion No." + ofToString(i + 1)).setNewColumn(true);
gui.addToggle("bUpdate", bUpdateXtion[i]);
gui.addToggle("bDraw", bDraw[i]);
gui.addSlider("scale", scale[i], 0.001f, 5.0f);
gui.addSlider("aspect x/y", aspect[i], 0.5f, 2.0f);
gui.addSlider("scaleZ", scaleZ[i], 0.2f, 2.0f);
gui.addTitle("translate");
gui.addSlider("axis.x", axis[i].x, -4000.0f, 4000.0f);
gui.addSlider("axis.y", axis[i].y, -4000.0f, 4000.0f);
gui.addSlider("axis.z", axis[i].z, -10000.0f, 0.0f);
gui.addSlider("rotx", rotx[i], -180, 180);
gui.addSlider("roty", roty[i], -180, 180);
gui.addSlider("rotz", rotz[i], -180, 180);
gui.addTitle("bgCapture").setNewColumn(true);
gui.addToggle("useBgDepth"+ ofToString(i+1), bUseBgDepth[i]);
gui.addContentSlider2d("depth", 1, tex[i], depthCheckPoint[i], depthCheckPoint2[i], 0.0f, (float)CAPTURE_WIDTH, 0.0f, (float)CAPTURE_HEIGHT, false);
gui.addRangeSlider("thresholds:near_far"+ ofToString(i+1), thresholdNear[i], thresholdFar[i], 0, 10000);
gui.addValueMonitor("depth_value", depthPointValue[i]);
gui.addSlider("depthSlider", depthSlider[i], 0, 10000);
gui.addButton("toggleBgSet", bCaptureBg[i]);
gui.addButton("save", bSaveBgAsImage[i]);
gui.addButton("load", trLoadBg[i]).setFix(true);
gui.addSlider("capturePlay", bgCapturePlay[i], 0, 200);
gui.addTitle("Xtion golobal");
gui.addToggle("xtionSetup", bSetUp).isFixed();
gui.addButton("xtionShutdown", bShutDown).isFixed();
gui.addToggle("bMeshDraw", bDrawMesh).isFixed();
}
gui.setPage(1);
exBdrawMesh = bDrawMesh;
}
void uiWindow::update(){
for (int i = 0; i < XTION_NUM; i++) {
const unsigned char * p = xtions.getDepthGenerator(i).getMonitorTexture();
tex[i].loadData(p, CAPTURE_WIDTH, CAPTURE_HEIGHT, GL_RGBA);
}
}
void guiM(string s){
ofSetColor(ofColor::red);
ofDrawBitmapString(s, ofPoint(130.0f, 154.0f));
}
void uiWindow::draw(){
ofPushStyle();
ofBackgroundGradient(ofColor::white, ofColor::gray);
ofSetColor(255);
monitorFboDraw(1, 1, 4, 0.713f);
gui.draw();
ofPopStyle();
///MontiroMessage
switch (gui.getCurrentPageNo()) {
case 1: //page1
guiM("Warning : did you set the xtion No? 0 is Blob, 1 is XTION 1");
break;
case 2:
guiM("Warning : did you set the xtion No? only xtion No.1\nWarning : did you set hondanaPos?\npos 0 : mahoPos on SMOLL SOFA pos1 : hondana\n1. mahoDraw 2. Keen draw 3.hondana noise\n3. himawariPlay 4. himawari fadeOut 5. himawari clear");
break;
case 3:
break;
default:
break;
}
///-MonitorMessage
}
void uiWindow::taskToggle(int scene, int & phase){
if (scene == 1) {
if (phase == 0) {
if (choicedXtion == 0) {
bDrawScene1Blob = true;
} else {
for (int i = 1; i <= XTION_NUM; i++) {
if (choicedXtion - 1 == i){
bDraw[i] = true;
}else bDraw[i] = false;
}
bOpenCv = true;
bCvNoise = true;
}
bKirakiraIncrease = true;
openCvDrawColor = mainPink;
} else if (phase == 1) {
bKirakiraDraw = true;
bCvNoise = false;
toggleCvFadeOut = true;
} else if (phase == 2) {
bDrawScene1Blob = false;
bOpenCv = false;
} else if (phase == 3) {
bKirakiraIncrease = false;
} else if (phase == 4) {
bKirakiraDraw = false;
}
} else if (scene == 2) {//himawari
if (phase == 0) {
trMaho = true;
} else if (phase == 1){
trKeen = true;
mahoIndex = 1;
} else if (phase == 2){
trPlayHimawariVideo = true;
} else if (phase == 3) {
bHimawariAlphaStart = true;
} else if (phase == 4) {
trHimawariClear = true;
mahoIndex = 0;
}
} else if (scene == 3) {//sera
if (phase == 0){
toggleCvFadeOut = false;
trMaho = true;
} else if (phase == 1){
mahoIndex = 2;
openCvDrawColor = mainPink;
trKeen = true;
} else if (phase == 2){
toggleCvFadeOut = true;
} else if (phase == 3) {
mahoIndex = 0;
openCvDrawColor = ofColor(0,0,0);
bSera = false;
bDrawSeraBlob = false;
bOpenCv = false;
}
} else if (scene == 4) {//harada
if (phase == 0){
trMaho = true;
} else if (phase == 1){
trKeen = true;
mahoIndex = 3;
cvNoiseAmt = 20.0f;
} else if (phase == 2){
mahoIndex = 0;
bOpenCv = false;//todo フェードアウトしたい
bCvBlur = false;
cvNoiseAmt = 0.0f;
bCvNoise = false;
}
} else if (scene == 5) {//カット
if (phase == 0){
mahoIndex = 0;
milli = 1000;
FadingStartTime = ofGetElapsedTimeMillis();
WhiteFading = 1;
bBackWhite = true;
} else if (phase == 1){
bGrotesq = true;
grotesq.setup();
grotesq.toggleGo();
} else if (phase == 2){
mahoPos[0] = ofPoint(2500.0f, 1000.0f);
} else if (phase == 3){
milli = 1000;
FadingStartTime = ofGetElapsedTimeMillis();
WhiteFading = 2;
} else if (phase == 4){
bBackWhite = false;
grotesq.clear();
}
} else if (scene == 6) {//haradaFire
if (phase == 0){
mahoIndex = 6;
trMaho = true;
} else if (phase == 1){
trKeen = true;
} else if (phase == 2){
bHaradaFireFadeOut = true;
} else if (phase == 3){
haradaFire.clear();
}
} else if (scene == 7) {//ロッカーから寿司
if (phase == 0){
trMaho = true;
} else if (phase == 1){
mahoIndex = 7;
trKeen = true;
} else if (phase == 2){
mahoIndex == 0;
}
} else if(scene == 11){
if (phase == 0) {
trPlayKajiVideo = true;
} else if (phase == 1){
bKajiAlphaStart = true;
} else if (phase >= 2) {
if (bKajiAlphaStart) {
trKajiClear = true;
}
}
} else if (scene == 8) {
if (phase == 0){
trMaho = true;
} else if (phase == 1){
mahoIndex = 8;
trKeen = true;
} else if (phase == 2){
mahoIndex == 0;
}
} else if (scene == 9) {
if (phase == 0){
mahoIndex = 9;
trMaho = true;
} else if (phase == 1){
//trKeen = true;
} else if (phase == 2){
mahoIndex == 0;
}
}
}
void uiWindow::ope1Setup(){
bDrawMesh = false;
bOpenCv = false;
bKirakiraDraw = false;
mahoIndex = 0;
for (int i = 0; i < 4; i++ ){
rokkaPosDamy[i] = rokkaPos[i];
}
//-----
gui.setPage(1);
currentScene = 1;
phaseNoByScene[currentScene] = 0;
}
void uiWindow::ope2Setup(){
if (!bKirakiraIncrease && bKirakiraDraw) bKirakiraIncrease = true;
bDrawMesh = false;
bOpenCv = false;
bKirakiraDraw = false;
bOpenCv = false;
mahoIndex = 0;
mahoPos[0].set(722.0f, 572.0f);
mahoPos[1].set(174.0f, 569.0f);
trHimawariLoad = true;
//------
gui.setPage(2);
currentScene = 2;
phaseNoByScene[currentScene] = 0;
}
void uiWindow::ope3Setup(){
bDrawMesh = false;
bOpenCv = false;
bSera = false;
bKirakiraDraw = false;
bDrawSeraBlob = false;
bDrawScene1Blob = false;
openCvDrawColor = mainPink;
mahoIndex = 0;
gui.setPage(3);
currentScene = 3;
phaseNoByScene[currentScene] = 0;
}
void uiWindow::ope4Setup(){
bDrawMesh = false;
bSera = false;
bKirakiraDraw = false;
bOpenCv = false;
mahoIndex = 0;
for (int i = 0; i < 6; i++) {
doorPosDamy[i] = doorPos[i];
}
mahoPos[1].set(1245.0f, 662.0f);
gui.setPage(4);
currentScene = 4;
phaseNoByScene[currentScene] = 0;
}
void uiWindow::ope5Setup(){
bDrawMesh = false;
bSera = false;
bKirakiraDraw = false;
bOpenCv = false;
bGrotesq = false;
bHaradaFire = false;
bDrawScene1Blob = false;
mahoIndex = 0;
gui.setPage(5);
currentScene = 5;
phaseNoByScene[currentScene] = 0;
}
void uiWindow::ope6Setup(){
bDrawMesh = false;
bSera = false;
bKirakiraDraw = false;
bOpenCv = false;
bGrotesq = false;
bHaradaFire = false;
bHaradaFireFadeOut = false;
haradaFire.clear();
mahoIndex = 0;
gui.setPage(6);
currentScene = 6;
phaseNoByScene[currentScene] = 0;
}
void uiWindow::ope7Setup(){
for (int i = 0; i < 4; i++) {
rokkaPosDamy[i] = rokkaPos[i];
}
bDrawMesh = false;
bSera = false;
bKirakiraDraw = false;
bOpenCv = false;
bGrotesq = false;
bHaradaFire = false;
trFadeOutLastMaho = false;
mahoIndex = 0;
gui.setPage(7);
currentScene = 7;
phaseNoByScene[currentScene] = 0;
}
void uiWindow::ope8Setup(){//gomory
for (int i = 0; i < 4; i++) {
doorPosDamy[i] = doorPos[i];
}
bDrawMesh = false;
bSera = false;
bKirakiraDraw = false;
bOpenCv = false;
bGrotesq = false;
bHaradaFire = false;
mahoIndex = 0;
gui.setPage(8);
currentScene = 8;
phaseNoByScene[currentScene] = 0;
}
void uiWindow::ope9Setup(){
bDrawMesh = false;
bSera = false;
bKirakiraDraw = false;
bOpenCv = false;
bGrotesq = false;
bHaradaFire = false;
mahoIndex = 0;
gui.setPage(9);
currentScene = 9;
phaseNoByScene[currentScene] = 0;
}
void uiWindow::ope11Setup(){
gui.setPage(11);
currentScene = 11;
phaseNoByScene[currentScene] = 0;
}
void uiWindow::keyPressed(int key){
switch (key) {
case 267:
gui.prevPage();
break;
case 268:
gui.nextPage();
break;
case 't':
trTail = true;
break;
case ' ':
taskToggle(currentScene, phaseNoByScene[currentScene]);
phaseNoByScene[currentScene]++;
break;
case '1':
ope1Setup();
break;
case '2':
ope2Setup();
break;
case '3':
ope3Setup();
break;
case '4':
ope4Setup();
break;
case '5':
ope5Setup();
break;
case '6':
ope6Setup();
break;
case '7':
ope7Setup();
break;
case '8':
ope8Setup();
break;
case '9':
ope9Setup();
break;
case 'k':
ope11Setup();
break;
default:
break;
}
}
//--------------------------------------------------------------
void uiWindow::monitorFboDraw(int controlNoFrom1,int blockNoFrom1, int blockNumByWidth, float scale){
ofPushStyle();
ofPushMatrix();
ofTranslate(11.0f , 134.84f);
float ww = blockNumByWidth * gui.config->width + gui.config->padding.x * (blockNumByWidth - 1);
ofDisableAlphaBlending();
ofSetColor(255);
monitorFbo.draw( ww * (1.0f - scale)/ 2.0f, ww * 3.0f / 4.0f * (1.0f - scale)/ 2.0f, ww * scale, ww * 3.0f / 4.0f * scale);
ofPopMatrix();
ofPopStyle();
}
void uiWindow::addMappingSetup(){
}
void uiWindow::consoleOut(){
}
|
#include "StdAfx.h"
#include "global.h"
float rand_num(int num)
{
return rand()%num;
}
float get_angle(float x1,float y1,float x2,float y2)
{
return atan2((y2-y1),(x2-x1))*180/3.14;
}
float get_distance(float x1,float y1,float x2,float y2)
{
return sqrt(pow(x2-x1,2)+pow(y2-y1,2));
}
|
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(const int argc, const char* const argv[]){
//int NUM_BINS = 9; //define the number of bins
int bin[9] = {};
//float voltage;
int valid = 0;
for (int i = 1; i < argc-1; i++){
float voltage = atof(argv[i]);
if((voltage > 0)&&(voltage < 150)){
valid++;
}
}
if(valid == 0){
cerr << "Error: Unable to compute histogram over data set because there are no valid readings" << endl;
return -1;
}
for (int i = 1; i < argc-1; i++){
float num = atof(argv[i]);
if (num > 150){
cout << "Warning: invalid voltage reading: " << num << " ignored in calculation" << endl;
}
else if (num < 0){
cout << "Warning invalid voltage reading: " << num << " ignored in calculation" << endl;
}
}
//Note that you MUST have a counter for your number of objects in your array. In this case, our counter will be the int value count.
int count = 0;
for (int i = 1; i < argc-1; i++){
float voltage = atof(argv[i]);
if((voltage > 0)&&(voltage < 150)){
count++;
}
}
for (int i = 1; i < argc-1 ; i++){
if(atof(argv[argc - 1]) >= 0){
cerr << "Error: Unable to compute histogram over data set because there is no negative terminator" << endl;
return -1;
}
}
for (int i =1; i < argc-1; i++){
float voltage = atof(argv[i]);
if (voltage > 0 && voltage < 106){
bin[0]++;
}
else if (voltage >= 106 && voltage < 109){
++bin[1];
}
else if (voltage >= 109 && voltage < 112){
++bin[2];
}
else if (voltage >= 112 && voltage < 115){
++bin[3];
}
else if (voltage >= 115 && voltage < 118){
++bin[4];
}
else if (voltage >= 118 && voltage < 121){
++bin[5];
}
else if (voltage >= 121 && voltage < 124){
++bin[6];
}
else if (voltage >= 124 && voltage <= 127){
++bin[7];
}
else if (voltage > 127 && voltage < 150){
++bin[8];
}
else{
++bin[9];
}
}
cout << "Number of voltage readings: " << count << endl;
cout << "Voltage readings (0-106): " << bin[0] << endl;
cout << "Voltage readings [106-109): " << bin[1] << endl;
cout << "Voltage readings [109-112): " << bin[2] << endl;
cout << "Voltage readings [112-115): " << bin[3] << endl;
cout << "Voltage readings [115-118): " << bin[4] << endl;
cout << "Voltage readings [118-121): " << bin[5] << endl;
cout << "Voltage readings [121-124): " << bin[6] << endl;
cout << "Voltage readings [124-127]: " << bin[7] << endl;
cout << "Voltage readings (127-150): " << bin[8] << endl;
cout << "Invalid readings: " << bin[9] << endl;
return 0;
}
|
#include "../interface/corrector.hh"
#include <iostream>
#include <sstream>
#include <TFile.h>
corrector::corrector(const std::string iFile,int iNFrac) {
TFile *lFile = new TFile(iFile.c_str());
fNEta = 61;
fNPhi = 72;
fNFrac = iNFrac;
fGraph = new TGraph***[fNEta];
lFile->Print();
for(int i0 = 0; i0 < fNEta; i0++) {
fGraph[i0] = new TGraph**[fNPhi];
for(int i1 = 0; i1 < fNPhi; i1++) {
fGraph[i0][i1] = new TGraph*[fNFrac];
for(int i2 = 0; i2 < fNFrac; i2++) {
std::stringstream pSS;
pSS << "eta_";
int pEta = i0;
if(iNFrac > 1) pEta = i0-30;
pSS << pEta;
if(iNFrac > 1) pSS << "phi_" << (i1+1);
pSS << "_frac_" << i2;
fGraph[i0][i1][i2] = (TGraph*) lFile->FindObjectAny(pSS.str().c_str());
}
}
}
}
double corrector::correct(double iHcal,double iEcal,int iEta,int iPhi) {
if(fNFrac == 1 && iEcal < 1. ) return 0;
if(fNFrac == 11 && iEcal+iHcal < 2. ) return 0;
fEcal = 0; if(iEcal > 0) fEcal = iEcal;
fHcal = 0; if(iHcal > 0) fHcal = iHcal;
double lFrac = fEcal/(fHcal+fEcal);
int lIFrac=int(lFrac*10.);
fIEta = iEta+30;
fIPhi = iPhi-1;
fFrac = lFrac;
if(lIFrac > fNFrac-1) lIFrac = 0;
fPtCorr = (fGraph[fIEta][fIPhi][lIFrac])->Eval(fHcal+fEcal);
if(fPtCorr < 1.) fPtCorr = 0;
return fPtCorr;
}
double corrector::ecalFrac() {
if(fEcal == 0) return 0;
double lEcalCorr = fGraph[fIEta][fIPhi][fNFrac-1]->Eval(fEcal);
return lEcalCorr/fPtCorr;
}
double corrector::hcalFrac() {
double lEcalCorr = fGraph[fIEta][fIPhi][10]->Eval(fEcal);
return (1.-lEcalCorr/fPtCorr);
}
|
/********************************************************************************
** Form generated from reading UI file 'mainwindow.ui'
**
** Created by: Qt User Interface Compiler version 5.8.0
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_MAINWINDOW_H
#define UI_MAINWINDOW_H
#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QDockWidget>
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QLabel>
#include <QtWidgets/QListWidget>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QMenu>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QSpacerItem>
#include <QtWidgets/QStatusBar>
#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
class Ui_MainWindow
{
public:
QAction *actionBarra_de_accesos_rapidos;
QAction *actionLista_de_alertas;
QAction *actionAcerca_de;
QAction *actionGrupo;
QAction *actionPesta_a;
QAction *actionCamara_2;
QAction *actionGrupo_2;
QAction *actionPesta_a_2;
QAction *actionIMap;
QAction *actionConfigur;
QAction *actionLogs;
QAction *actionBuscar_dispositivos;
QAction *actionRetransmitir_videos;
QAction *actionManual;
QAction *actionP_gina_web;
QAction *actionCerrar_sesi_n;
QAction *actionControles_de_PTZ;
QAction *actionEstilo;
QAction *actionContacto;
QAction *actionConfiguraciones_de_Playback;
QWidget *centralwidget;
QGridLayout *gridLayout;
QHBoxLayout *horizontalLayout;
QHBoxLayout *horizontalLayout_2;
QPushButton *setlive;
QPushButton *setrecord;
QSpacerItem *horizontalSpacer_6;
QPushButton *recorddate;
QLabel *recorddatelabel;
QLabel *recordtimeslider;
QPushButton *record_b_ret;
QPushButton *record_b_stop;
QPushButton *record_b_playx1;
QPushButton *record_b_playx2;
QPushButton *record_b_playx4;
QLabel *recordtimelabel;
QSpacerItem *horizontalSpacer_7;
QMenuBar *menubar;
QMenu *menuVer;
QMenu *menuAyuda;
QMenu *menuHerramientas;
QMenu *menuNuevo;
QMenu *menuNuevo_2;
QStatusBar *statusbar;
QDockWidget *dock_alerts;
QWidget *dockWidgetContents_4;
QGridLayout *gridLayout_4;
QListWidget *alertList;
QSpacerItem *horizontalSpacer_5;
QPushButton *maximizeptz;
QDockWidget *dock_menu;
QWidget *dockWidgetContents_5;
QGridLayout *gridLayout_3;
QPushButton *device_discover;
QSpacerItem *horizontalSpacer_3;
QPushButton *re_stream;
QSpacerItem *verticalSpacer;
QPushButton *config_button;
QPushButton *logs_button;
QPushButton *hand_cursor;
QPushButton *zoom_cursor;
QPushButton *add_view;
QPushButton *help_button;
QSpacerItem *horizontalSpacer_4;
QPushButton *rest_button;
QPushButton *playback_configs_button;
QLabel *rest_time;
QDockWidget *ptzDock;
QWidget *dockWidgetContents_8;
QGridLayout *gridLayout_2;
QSpacerItem *verticalSpacer_2;
QSpacerItem *verticalSpacer_3;
QPushButton *ptzzl;
QPushButton *ptzr;
QPushButton *ptzup;
QSpacerItem *horizontalSpacer;
QPushButton *ptzl;
QSpacerItem *horizontalSpacer_2;
QPushButton *ptzzi;
QPushButton *ptzdown;
QPushButton *presets;
QPushButton *ptztour;
void setupUi(QMainWindow *MainWindow)
{
if (MainWindow->objectName().isEmpty())
MainWindow->setObjectName(QStringLiteral("MainWindow"));
MainWindow->resize(981, 581);
QFont font;
font.setPointSize(8);
MainWindow->setFont(font);
MainWindow->setStyleSheet(QStringLiteral(""));
actionBarra_de_accesos_rapidos = new QAction(MainWindow);
actionBarra_de_accesos_rapidos->setObjectName(QStringLiteral("actionBarra_de_accesos_rapidos"));
actionBarra_de_accesos_rapidos->setFont(font);
actionLista_de_alertas = new QAction(MainWindow);
actionLista_de_alertas->setObjectName(QStringLiteral("actionLista_de_alertas"));
actionLista_de_alertas->setFont(font);
actionAcerca_de = new QAction(MainWindow);
actionAcerca_de->setObjectName(QStringLiteral("actionAcerca_de"));
actionAcerca_de->setFont(font);
actionGrupo = new QAction(MainWindow);
actionGrupo->setObjectName(QStringLiteral("actionGrupo"));
actionGrupo->setFont(font);
actionPesta_a = new QAction(MainWindow);
actionPesta_a->setObjectName(QStringLiteral("actionPesta_a"));
actionPesta_a->setFont(font);
actionCamara_2 = new QAction(MainWindow);
actionCamara_2->setObjectName(QStringLiteral("actionCamara_2"));
actionGrupo_2 = new QAction(MainWindow);
actionGrupo_2->setObjectName(QStringLiteral("actionGrupo_2"));
actionPesta_a_2 = new QAction(MainWindow);
actionPesta_a_2->setObjectName(QStringLiteral("actionPesta_a_2"));
actionIMap = new QAction(MainWindow);
actionIMap->setObjectName(QStringLiteral("actionIMap"));
actionConfigur = new QAction(MainWindow);
actionConfigur->setObjectName(QStringLiteral("actionConfigur"));
actionConfigur->setFont(font);
actionLogs = new QAction(MainWindow);
actionLogs->setObjectName(QStringLiteral("actionLogs"));
actionLogs->setFont(font);
actionBuscar_dispositivos = new QAction(MainWindow);
actionBuscar_dispositivos->setObjectName(QStringLiteral("actionBuscar_dispositivos"));
actionBuscar_dispositivos->setFont(font);
actionRetransmitir_videos = new QAction(MainWindow);
actionRetransmitir_videos->setObjectName(QStringLiteral("actionRetransmitir_videos"));
actionRetransmitir_videos->setFont(font);
actionManual = new QAction(MainWindow);
actionManual->setObjectName(QStringLiteral("actionManual"));
actionManual->setFont(font);
actionP_gina_web = new QAction(MainWindow);
actionP_gina_web->setObjectName(QStringLiteral("actionP_gina_web"));
actionP_gina_web->setFont(font);
actionCerrar_sesi_n = new QAction(MainWindow);
actionCerrar_sesi_n->setObjectName(QStringLiteral("actionCerrar_sesi_n"));
actionCerrar_sesi_n->setFont(font);
actionControles_de_PTZ = new QAction(MainWindow);
actionControles_de_PTZ->setObjectName(QStringLiteral("actionControles_de_PTZ"));
actionControles_de_PTZ->setFont(font);
actionEstilo = new QAction(MainWindow);
actionEstilo->setObjectName(QStringLiteral("actionEstilo"));
actionEstilo->setFont(font);
actionContacto = new QAction(MainWindow);
actionContacto->setObjectName(QStringLiteral("actionContacto"));
actionContacto->setFont(font);
actionConfiguraciones_de_Playback = new QAction(MainWindow);
actionConfiguraciones_de_Playback->setObjectName(QStringLiteral("actionConfiguraciones_de_Playback"));
actionConfiguraciones_de_Playback->setFont(font);
centralwidget = new QWidget(MainWindow);
centralwidget->setObjectName(QStringLiteral("centralwidget"));
gridLayout = new QGridLayout(centralwidget);
gridLayout->setObjectName(QStringLiteral("gridLayout"));
horizontalLayout = new QHBoxLayout();
horizontalLayout->setObjectName(QStringLiteral("horizontalLayout"));
gridLayout->addLayout(horizontalLayout, 1, 0, 1, 1);
horizontalLayout_2 = new QHBoxLayout();
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
setlive = new QPushButton(centralwidget);
setlive->setObjectName(QStringLiteral("setlive"));
setlive->setMaximumSize(QSize(50, 16777215));
QFont font1;
font1.setPointSize(8);
font1.setBold(true);
font1.setWeight(75);
setlive->setFont(font1);
setlive->setFlat(true);
horizontalLayout_2->addWidget(setlive);
setrecord = new QPushButton(centralwidget);
setrecord->setObjectName(QStringLiteral("setrecord"));
setrecord->setMaximumSize(QSize(70, 16777215));
setrecord->setFont(font1);
setrecord->setFlat(true);
horizontalLayout_2->addWidget(setrecord);
horizontalSpacer_6 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_2->addItem(horizontalSpacer_6);
recorddate = new QPushButton(centralwidget);
recorddate->setObjectName(QStringLiteral("recorddate"));
recorddate->setMinimumSize(QSize(25, 25));
recorddate->setMaximumSize(QSize(25, 25));
recorddate->setFont(font1);
recorddate->setFlat(true);
horizontalLayout_2->addWidget(recorddate);
recorddatelabel = new QLabel(centralwidget);
recorddatelabel->setObjectName(QStringLiteral("recorddatelabel"));
recorddatelabel->setFont(font);
horizontalLayout_2->addWidget(recorddatelabel);
recordtimeslider = new QLabel(centralwidget);
recordtimeslider->setObjectName(QStringLiteral("recordtimeslider"));
recordtimeslider->setMinimumSize(QSize(480, 25));
recordtimeslider->setMaximumSize(QSize(480, 25));
horizontalLayout_2->addWidget(recordtimeslider);
record_b_ret = new QPushButton(centralwidget);
record_b_ret->setObjectName(QStringLiteral("record_b_ret"));
record_b_ret->setMinimumSize(QSize(25, 25));
record_b_ret->setMaximumSize(QSize(25, 25));
record_b_ret->setFlat(true);
horizontalLayout_2->addWidget(record_b_ret);
record_b_stop = new QPushButton(centralwidget);
record_b_stop->setObjectName(QStringLiteral("record_b_stop"));
record_b_stop->setMinimumSize(QSize(25, 25));
record_b_stop->setMaximumSize(QSize(25, 25));
record_b_stop->setFlat(true);
horizontalLayout_2->addWidget(record_b_stop);
record_b_playx1 = new QPushButton(centralwidget);
record_b_playx1->setObjectName(QStringLiteral("record_b_playx1"));
record_b_playx1->setMinimumSize(QSize(25, 25));
record_b_playx1->setMaximumSize(QSize(25, 25));
record_b_playx1->setFlat(true);
horizontalLayout_2->addWidget(record_b_playx1);
record_b_playx2 = new QPushButton(centralwidget);
record_b_playx2->setObjectName(QStringLiteral("record_b_playx2"));
record_b_playx2->setMinimumSize(QSize(25, 25));
record_b_playx2->setMaximumSize(QSize(25, 25));
record_b_playx2->setFlat(true);
horizontalLayout_2->addWidget(record_b_playx2);
record_b_playx4 = new QPushButton(centralwidget);
record_b_playx4->setObjectName(QStringLiteral("record_b_playx4"));
record_b_playx4->setMinimumSize(QSize(25, 25));
record_b_playx4->setMaximumSize(QSize(25, 25));
record_b_playx4->setFlat(true);
horizontalLayout_2->addWidget(record_b_playx4);
recordtimelabel = new QLabel(centralwidget);
recordtimelabel->setObjectName(QStringLiteral("recordtimelabel"));
recordtimelabel->setFont(font);
horizontalLayout_2->addWidget(recordtimelabel);
horizontalSpacer_7 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_2->addItem(horizontalSpacer_7);
gridLayout->addLayout(horizontalLayout_2, 0, 0, 1, 1);
MainWindow->setCentralWidget(centralwidget);
menubar = new QMenuBar(MainWindow);
menubar->setObjectName(QStringLiteral("menubar"));
menubar->setGeometry(QRect(0, 0, 981, 17));
menuVer = new QMenu(menubar);
menuVer->setObjectName(QStringLiteral("menuVer"));
menuAyuda = new QMenu(menubar);
menuAyuda->setObjectName(QStringLiteral("menuAyuda"));
menuHerramientas = new QMenu(menubar);
menuHerramientas->setObjectName(QStringLiteral("menuHerramientas"));
menuNuevo = new QMenu(menubar);
menuNuevo->setObjectName(QStringLiteral("menuNuevo"));
menuNuevo_2 = new QMenu(menuNuevo);
menuNuevo_2->setObjectName(QStringLiteral("menuNuevo_2"));
menuNuevo_2->setFont(font);
MainWindow->setMenuBar(menubar);
statusbar = new QStatusBar(MainWindow);
statusbar->setObjectName(QStringLiteral("statusbar"));
MainWindow->setStatusBar(statusbar);
dock_alerts = new QDockWidget(MainWindow);
dock_alerts->setObjectName(QStringLiteral("dock_alerts"));
QIcon icon;
icon.addFile(QStringLiteral("../images/alert.jpg"), QSize(), QIcon::Normal, QIcon::Off);
dock_alerts->setWindowIcon(icon);
dock_alerts->setFloating(false);
dock_alerts->setFeatures(QDockWidget::AllDockWidgetFeatures);
dockWidgetContents_4 = new QWidget();
dockWidgetContents_4->setObjectName(QStringLiteral("dockWidgetContents_4"));
gridLayout_4 = new QGridLayout(dockWidgetContents_4);
gridLayout_4->setObjectName(QStringLiteral("gridLayout_4"));
alertList = new QListWidget(dockWidgetContents_4);
alertList->setObjectName(QStringLiteral("alertList"));
alertList->setMaximumSize(QSize(16777215, 5555555));
QFont font2;
font2.setPointSize(9);
alertList->setFont(font2);
alertList->setDragDropMode(QAbstractItemView::DragOnly);
alertList->setDefaultDropAction(Qt::IgnoreAction);
alertList->setSelectionMode(QAbstractItemView::NoSelection);
alertList->setMovement(QListView::Free);
gridLayout_4->addWidget(alertList, 0, 0, 1, 3);
horizontalSpacer_5 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
gridLayout_4->addItem(horizontalSpacer_5, 1, 1, 1, 1);
maximizeptz = new QPushButton(dockWidgetContents_4);
maximizeptz->setObjectName(QStringLiteral("maximizeptz"));
maximizeptz->setMinimumSize(QSize(22, 22));
maximizeptz->setMaximumSize(QSize(22, 22));
QFont font3;
font3.setBold(true);
font3.setWeight(75);
maximizeptz->setFont(font3);
maximizeptz->setFlat(true);
gridLayout_4->addWidget(maximizeptz, 1, 2, 1, 1);
dock_alerts->setWidget(dockWidgetContents_4);
MainWindow->addDockWidget(static_cast<Qt::DockWidgetArea>(8), dock_alerts);
dock_menu = new QDockWidget(MainWindow);
dock_menu->setObjectName(QStringLiteral("dock_menu"));
dock_menu->setMinimumSize(QSize(60, 401));
dock_menu->setMaximumSize(QSize(60, 524287));
dock_menu->setFeatures(QDockWidget::AllDockWidgetFeatures);
dockWidgetContents_5 = new QWidget();
dockWidgetContents_5->setObjectName(QStringLiteral("dockWidgetContents_5"));
gridLayout_3 = new QGridLayout(dockWidgetContents_5);
gridLayout_3->setObjectName(QStringLiteral("gridLayout_3"));
device_discover = new QPushButton(dockWidgetContents_5);
device_discover->setObjectName(QStringLiteral("device_discover"));
device_discover->setMinimumSize(QSize(28, 28));
device_discover->setMaximumSize(QSize(28, 28));
QIcon icon1;
icon1.addFile(QStringLiteral(":/new/buttons/images/device_discover.jpg"), QSize(), QIcon::Normal, QIcon::Off);
device_discover->setIcon(icon1);
device_discover->setIconSize(QSize(20, 20));
device_discover->setFlat(true);
gridLayout_3->addWidget(device_discover, 3, 1, 1, 1);
horizontalSpacer_3 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
gridLayout_3->addItem(horizontalSpacer_3, 2, 0, 1, 1);
re_stream = new QPushButton(dockWidgetContents_5);
re_stream->setObjectName(QStringLiteral("re_stream"));
re_stream->setMinimumSize(QSize(28, 28));
re_stream->setMaximumSize(QSize(28, 28));
QIcon icon2;
icon2.addFile(QStringLiteral(":/new/buttons/images/restream.jpg"), QSize(), QIcon::Normal, QIcon::Off);
re_stream->setIcon(icon2);
re_stream->setIconSize(QSize(20, 20));
re_stream->setFlat(true);
gridLayout_3->addWidget(re_stream, 2, 1, 1, 1);
verticalSpacer = new QSpacerItem(10, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
gridLayout_3->addItem(verticalSpacer, 9, 1, 1, 1);
config_button = new QPushButton(dockWidgetContents_5);
config_button->setObjectName(QStringLiteral("config_button"));
config_button->setMinimumSize(QSize(28, 28));
config_button->setMaximumSize(QSize(28, 28));
QIcon icon3;
icon3.addFile(QStringLiteral("../../../../Desktop/iconos vcenter/config.png"), QSize(), QIcon::Normal, QIcon::Off);
config_button->setIcon(icon3);
config_button->setIconSize(QSize(20, 20));
config_button->setFlat(true);
gridLayout_3->addWidget(config_button, 1, 1, 1, 1);
logs_button = new QPushButton(dockWidgetContents_5);
logs_button->setObjectName(QStringLiteral("logs_button"));
logs_button->setMinimumSize(QSize(28, 28));
logs_button->setMaximumSize(QSize(28, 28));
QIcon icon4;
icon4.addFile(QStringLiteral(":/new/buttons/images/log.jpg"), QSize(), QIcon::Normal, QIcon::Off);
logs_button->setIcon(icon4);
logs_button->setIconSize(QSize(20, 20));
logs_button->setFlat(true);
gridLayout_3->addWidget(logs_button, 4, 1, 1, 1);
hand_cursor = new QPushButton(dockWidgetContents_5);
hand_cursor->setObjectName(QStringLiteral("hand_cursor"));
hand_cursor->setMinimumSize(QSize(28, 28));
hand_cursor->setMaximumSize(QSize(28, 28));
hand_cursor->setFlat(true);
gridLayout_3->addWidget(hand_cursor, 10, 1, 1, 1);
zoom_cursor = new QPushButton(dockWidgetContents_5);
zoom_cursor->setObjectName(QStringLiteral("zoom_cursor"));
zoom_cursor->setMinimumSize(QSize(28, 28));
zoom_cursor->setMaximumSize(QSize(28, 28));
zoom_cursor->setFlat(true);
gridLayout_3->addWidget(zoom_cursor, 11, 1, 1, 1);
add_view = new QPushButton(dockWidgetContents_5);
add_view->setObjectName(QStringLiteral("add_view"));
add_view->setMinimumSize(QSize(28, 28));
add_view->setMaximumSize(QSize(28, 28));
QIcon icon5;
icon5.addFile(QStringLiteral(":/new/buttons/images/add_grey.jpg"), QSize(), QIcon::Normal, QIcon::Off);
add_view->setIcon(icon5);
add_view->setIconSize(QSize(20, 20));
add_view->setAutoDefault(false);
add_view->setFlat(true);
gridLayout_3->addWidget(add_view, 0, 1, 1, 1);
help_button = new QPushButton(dockWidgetContents_5);
help_button->setObjectName(QStringLiteral("help_button"));
help_button->setMinimumSize(QSize(28, 28));
help_button->setMaximumSize(QSize(28, 28));
QIcon icon6;
icon6.addFile(QStringLiteral(":/new/buttons/images/help_grey.jpg"), QSize(), QIcon::Normal, QIcon::Off);
help_button->setIcon(icon6);
help_button->setIconSize(QSize(20, 20));
help_button->setFlat(true);
gridLayout_3->addWidget(help_button, 5, 1, 1, 1);
horizontalSpacer_4 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
gridLayout_3->addItem(horizontalSpacer_4, 3, 2, 1, 1);
rest_button = new QPushButton(dockWidgetContents_5);
rest_button->setObjectName(QStringLiteral("rest_button"));
rest_button->setMinimumSize(QSize(28, 28));
rest_button->setMaximumSize(QSize(28, 28));
rest_button->setFlat(true);
gridLayout_3->addWidget(rest_button, 7, 1, 1, 1);
playback_configs_button = new QPushButton(dockWidgetContents_5);
playback_configs_button->setObjectName(QStringLiteral("playback_configs_button"));
playback_configs_button->setMinimumSize(QSize(28, 28));
playback_configs_button->setMaximumSize(QSize(28, 28));
playback_configs_button->setFont(font3);
playback_configs_button->setFlat(true);
gridLayout_3->addWidget(playback_configs_button, 6, 1, 1, 1);
rest_time = new QLabel(dockWidgetContents_5);
rest_time->setObjectName(QStringLiteral("rest_time"));
QFont font4;
font4.setPointSize(6);
rest_time->setFont(font4);
rest_time->setAlignment(Qt::AlignCenter);
gridLayout_3->addWidget(rest_time, 8, 1, 1, 1);
dock_menu->setWidget(dockWidgetContents_5);
MainWindow->addDockWidget(static_cast<Qt::DockWidgetArea>(2), dock_menu);
ptzDock = new QDockWidget(MainWindow);
ptzDock->setObjectName(QStringLiteral("ptzDock"));
ptzDock->setMaximumSize(QSize(180, 524287));
QIcon icon7;
icon7.addFile(QStringLiteral("../images/icon/grid.png"), QSize(), QIcon::Normal, QIcon::Off);
ptzDock->setWindowIcon(icon7);
ptzDock->setFeatures(QDockWidget::AllDockWidgetFeatures);
dockWidgetContents_8 = new QWidget();
dockWidgetContents_8->setObjectName(QStringLiteral("dockWidgetContents_8"));
gridLayout_2 = new QGridLayout(dockWidgetContents_8);
gridLayout_2->setObjectName(QStringLiteral("gridLayout_2"));
verticalSpacer_2 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
gridLayout_2->addItem(verticalSpacer_2, 0, 2, 1, 1);
verticalSpacer_3 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
gridLayout_2->addItem(verticalSpacer_3, 4, 2, 1, 1);
ptzzl = new QPushButton(dockWidgetContents_8);
ptzzl->setObjectName(QStringLiteral("ptzzl"));
ptzzl->setMinimumSize(QSize(22, 22));
ptzzl->setMaximumSize(QSize(22, 22));
QIcon icon8;
icon8.addFile(QStringLiteral("../images/icon/ptz_zoomout.png"), QSize(), QIcon::Normal, QIcon::Off);
ptzzl->setIcon(icon8);
ptzzl->setFlat(true);
gridLayout_2->addWidget(ptzzl, 2, 4, 1, 1);
ptzr = new QPushButton(dockWidgetContents_8);
ptzr->setObjectName(QStringLiteral("ptzr"));
ptzr->setMinimumSize(QSize(22, 22));
ptzr->setMaximumSize(QSize(22, 22));
QIcon icon9;
icon9.addFile(QStringLiteral("../images/icon/ptz_right.png"), QSize(), QIcon::Normal, QIcon::Off);
ptzr->setIcon(icon9);
ptzr->setFlat(true);
gridLayout_2->addWidget(ptzr, 2, 3, 1, 1);
ptzup = new QPushButton(dockWidgetContents_8);
ptzup->setObjectName(QStringLiteral("ptzup"));
ptzup->setMinimumSize(QSize(24, 23));
ptzup->setMaximumSize(QSize(24, 23));
QIcon icon10;
icon10.addFile(QStringLiteral("../images/icon/ptz_up.png"), QSize(), QIcon::Normal, QIcon::Off);
ptzup->setIcon(icon10);
ptzup->setIconSize(QSize(22, 18));
ptzup->setFlat(true);
gridLayout_2->addWidget(ptzup, 1, 2, 1, 1);
horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
gridLayout_2->addItem(horizontalSpacer, 2, 0, 1, 1);
ptzl = new QPushButton(dockWidgetContents_8);
ptzl->setObjectName(QStringLiteral("ptzl"));
ptzl->setMinimumSize(QSize(22, 22));
ptzl->setMaximumSize(QSize(22, 22));
QIcon icon11;
icon11.addFile(QStringLiteral("../images/icon/ptz_left.png"), QSize(), QIcon::Normal, QIcon::Off);
icon11.addFile(QStringLiteral("../images/icon/ptz_left.png"), QSize(), QIcon::Normal, QIcon::On);
ptzl->setIcon(icon11);
ptzl->setFlat(true);
gridLayout_2->addWidget(ptzl, 2, 1, 1, 1);
horizontalSpacer_2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
gridLayout_2->addItem(horizontalSpacer_2, 2, 5, 1, 1);
ptzzi = new QPushButton(dockWidgetContents_8);
ptzzi->setObjectName(QStringLiteral("ptzzi"));
ptzzi->setMinimumSize(QSize(22, 22));
ptzzi->setMaximumSize(QSize(22, 22));
QIcon icon12;
icon12.addFile(QStringLiteral("../images/icon/ptz_zoomin.png"), QSize(), QIcon::Normal, QIcon::Off);
ptzzi->setIcon(icon12);
ptzzi->setFlat(true);
gridLayout_2->addWidget(ptzzi, 1, 4, 1, 1);
ptzdown = new QPushButton(dockWidgetContents_8);
ptzdown->setObjectName(QStringLiteral("ptzdown"));
ptzdown->setMinimumSize(QSize(24, 23));
ptzdown->setMaximumSize(QSize(24, 23));
QIcon icon13;
icon13.addFile(QStringLiteral("../images/icon/ptz_down.png"), QSize(), QIcon::Normal, QIcon::Off);
ptzdown->setIcon(icon13);
ptzdown->setIconSize(QSize(22, 18));
ptzdown->setFlat(true);
gridLayout_2->addWidget(ptzdown, 3, 2, 1, 1);
presets = new QPushButton(dockWidgetContents_8);
presets->setObjectName(QStringLiteral("presets"));
presets->setMinimumSize(QSize(22, 22));
presets->setMaximumSize(QSize(22, 22));
presets->setFont(font);
presets->setFlat(true);
gridLayout_2->addWidget(presets, 3, 4, 1, 1);
ptztour = new QPushButton(dockWidgetContents_8);
ptztour->setObjectName(QStringLiteral("ptztour"));
ptztour->setMinimumSize(QSize(22, 22));
ptztour->setMaximumSize(QSize(22, 22));
QIcon icon14;
icon14.addFile(QStringLiteral("../images/icon/ptz_tour.png"), QSize(), QIcon::Normal, QIcon::Off);
ptztour->setIcon(icon14);
ptztour->setFlat(true);
gridLayout_2->addWidget(ptztour, 3, 3, 1, 1);
ptzDock->setWidget(dockWidgetContents_8);
MainWindow->addDockWidget(static_cast<Qt::DockWidgetArea>(8), ptzDock);
QWidget::setTabOrder(add_view, config_button);
QWidget::setTabOrder(config_button, re_stream);
QWidget::setTabOrder(re_stream, device_discover);
QWidget::setTabOrder(device_discover, logs_button);
QWidget::setTabOrder(logs_button, help_button);
QWidget::setTabOrder(help_button, alertList);
menubar->addAction(menuNuevo->menuAction());
menubar->addAction(menuVer->menuAction());
menubar->addAction(menuAyuda->menuAction());
menubar->addAction(menuHerramientas->menuAction());
menuVer->addAction(actionBarra_de_accesos_rapidos);
menuVer->addAction(actionLista_de_alertas);
menuVer->addAction(actionControles_de_PTZ);
menuVer->addAction(actionEstilo);
menuAyuda->addSeparator();
menuAyuda->addAction(actionAcerca_de);
menuAyuda->addAction(actionManual);
menuAyuda->addAction(actionP_gina_web);
menuAyuda->addAction(actionContacto);
menuHerramientas->addAction(actionConfigur);
menuHerramientas->addAction(actionConfiguraciones_de_Playback);
menuHerramientas->addAction(actionLogs);
menuHerramientas->addAction(actionBuscar_dispositivos);
menuHerramientas->addAction(actionRetransmitir_videos);
menuNuevo->addAction(menuNuevo_2->menuAction());
menuNuevo->addSeparator();
menuNuevo->addAction(actionCerrar_sesi_n);
menuNuevo->addAction(actionGrupo);
menuNuevo->addAction(actionPesta_a);
menuNuevo_2->addAction(actionGrupo_2);
menuNuevo_2->addAction(actionCamara_2);
menuNuevo_2->addAction(actionPesta_a_2);
menuNuevo_2->addAction(actionIMap);
retranslateUi(MainWindow);
add_view->setDefault(false);
QMetaObject::connectSlotsByName(MainWindow);
} // setupUi
void retranslateUi(QMainWindow *MainWindow)
{
MainWindow->setWindowTitle(QApplication::translate("MainWindow", "vCenterViewer 2.3", Q_NULLPTR));
actionBarra_de_accesos_rapidos->setText(QApplication::translate("MainWindow", "Barra de accesos rapidos", Q_NULLPTR));
actionLista_de_alertas->setText(QApplication::translate("MainWindow", "Lista de alertas", Q_NULLPTR));
actionAcerca_de->setText(QApplication::translate("MainWindow", "Acerca de vCenter", Q_NULLPTR));
actionGrupo->setText(QApplication::translate("MainWindow", "Guardar", Q_NULLPTR));
actionPesta_a->setText(QApplication::translate("MainWindow", "Guardar y salir", Q_NULLPTR));
actionCamara_2->setText(QApplication::translate("MainWindow", "Camara", Q_NULLPTR));
actionGrupo_2->setText(QApplication::translate("MainWindow", "Sub grupo", Q_NULLPTR));
actionPesta_a_2->setText(QApplication::translate("MainWindow", "Grilla", Q_NULLPTR));
actionIMap->setText(QApplication::translate("MainWindow", "EMap", Q_NULLPTR));
actionConfigur->setText(QApplication::translate("MainWindow", "Configuraciones", Q_NULLPTR));
actionLogs->setText(QApplication::translate("MainWindow", "Logs", Q_NULLPTR));
actionBuscar_dispositivos->setText(QApplication::translate("MainWindow", "Buscar dispositivos", Q_NULLPTR));
actionRetransmitir_videos->setText(QApplication::translate("MainWindow", "Retransmitir videos", Q_NULLPTR));
actionManual->setText(QApplication::translate("MainWindow", "Manual", Q_NULLPTR));
actionP_gina_web->setText(QApplication::translate("MainWindow", "P\303\241gina web", Q_NULLPTR));
actionCerrar_sesi_n->setText(QApplication::translate("MainWindow", "Cerrar sesi\303\263n", Q_NULLPTR));
actionControles_de_PTZ->setText(QApplication::translate("MainWindow", "Controles de PTZ", Q_NULLPTR));
actionEstilo->setText(QApplication::translate("MainWindow", "Cambiar colores", Q_NULLPTR));
actionContacto->setText(QApplication::translate("MainWindow", "Contacto", Q_NULLPTR));
actionConfiguraciones_de_Playback->setText(QApplication::translate("MainWindow", "Configuraciones de Playback", Q_NULLPTR));
setlive->setText(QApplication::translate("MainWindow", "VIVO", Q_NULLPTR));
setrecord->setText(QApplication::translate("MainWindow", "GRABACI\303\223N", Q_NULLPTR));
recorddate->setText(QString());
recorddatelabel->setText(QApplication::translate("MainWindow", "fecha", Q_NULLPTR));
recordtimeslider->setText(QString());
record_b_ret->setText(QString());
record_b_stop->setText(QString());
record_b_playx1->setText(QString());
record_b_playx2->setText(QString());
record_b_playx4->setText(QString());
recordtimelabel->setText(QApplication::translate("MainWindow", "hora", Q_NULLPTR));
menuVer->setTitle(QApplication::translate("MainWindow", "Ver", Q_NULLPTR));
menuAyuda->setTitle(QApplication::translate("MainWindow", "Ayuda", Q_NULLPTR));
menuHerramientas->setTitle(QApplication::translate("MainWindow", "Herramientas", Q_NULLPTR));
menuNuevo->setTitle(QApplication::translate("MainWindow", "Inicio", Q_NULLPTR));
menuNuevo_2->setTitle(QApplication::translate("MainWindow", "Nuevo", Q_NULLPTR));
#ifndef QT_NO_ACCESSIBILITY
dock_alerts->setAccessibleName(QApplication::translate("MainWindow", "Alertas", Q_NULLPTR));
#endif // QT_NO_ACCESSIBILITY
dock_alerts->setWindowTitle(QApplication::translate("MainWindow", "Alertas", Q_NULLPTR));
#ifndef QT_NO_TOOLTIP
maximizeptz->setToolTip(QApplication::translate("MainWindow", "<html><head/><body><p><span style=\" font-size:8pt; font-weight:400;\">Men\303\272 de alertas</span></p></body></html>", Q_NULLPTR));
#endif // QT_NO_TOOLTIP
maximizeptz->setText(QString());
#ifndef QT_NO_TOOLTIP
device_discover->setToolTip(QApplication::translate("MainWindow", "<html><head/><body><p>Buscar dispositivos</p></body></html>", Q_NULLPTR));
#endif // QT_NO_TOOLTIP
device_discover->setText(QString());
#ifndef QT_NO_TOOLTIP
re_stream->setToolTip(QApplication::translate("MainWindow", "<html><head/><body><p>Re-transmitir una camara</p></body></html>", Q_NULLPTR));
#endif // QT_NO_TOOLTIP
re_stream->setText(QString());
#ifndef QT_NO_TOOLTIP
config_button->setToolTip(QApplication::translate("MainWindow", "<html><head/><body><p>Configuraciones globales</p></body></html>", Q_NULLPTR));
#endif // QT_NO_TOOLTIP
config_button->setText(QString());
#ifndef QT_NO_TOOLTIP
logs_button->setToolTip(QApplication::translate("MainWindow", "<html><head/><body><p>Ver archivos de log</p></body></html>", Q_NULLPTR));
#endif // QT_NO_TOOLTIP
logs_button->setText(QString());
hand_cursor->setText(QString());
zoom_cursor->setText(QString());
#ifndef QT_NO_TOOLTIP
add_view->setToolTip(QApplication::translate("MainWindow", "<html><head/><body><p>Agregar nueva ..</p></body></html>", Q_NULLPTR));
#endif // QT_NO_TOOLTIP
add_view->setText(QString());
#ifndef QT_NO_TOOLTIP
help_button->setToolTip(QApplication::translate("MainWindow", "<html><head/><body><p>Acerca del programa</p></body></html>", Q_NULLPTR));
#endif // QT_NO_TOOLTIP
help_button->setText(QString());
#ifndef QT_NO_TOOLTIP
rest_button->setToolTip(QApplication::translate("MainWindow", "<html><head/><body><p>Comenzar descanso</p></body></html>", Q_NULLPTR));
#endif // QT_NO_TOOLTIP
rest_button->setText(QString());
#ifndef QT_NO_TOOLTIP
playback_configs_button->setToolTip(QApplication::translate("MainWindow", "<html><head/><body><p><span style=\" font-weight:400;\">Configuraciones de playback</span></p></body></html>", Q_NULLPTR));
#endif // QT_NO_TOOLTIP
playback_configs_button->setText(QString());
rest_time->setText(QApplication::translate("MainWindow", "00:00", Q_NULLPTR));
#ifndef QT_NO_ACCESSIBILITY
ptzDock->setAccessibleName(QApplication::translate("MainWindow", "PTZ", Q_NULLPTR));
#endif // QT_NO_ACCESSIBILITY
ptzDock->setWindowTitle(QApplication::translate("MainWindow", "Control", Q_NULLPTR));
#ifndef QT_NO_TOOLTIP
ptzzl->setToolTip(QApplication::translate("MainWindow", "<html><head/><body><p><span style=\" font-size:8pt;\">Zoom (-)</span></p></body></html>", Q_NULLPTR));
#endif // QT_NO_TOOLTIP
ptzzl->setText(QString());
#ifndef QT_NO_TOOLTIP
ptzr->setToolTip(QApplication::translate("MainWindow", "<html><head/><body><p><span style=\" font-size:8pt;\">Mover hacia la derecha</span></p></body></html>", Q_NULLPTR));
#endif // QT_NO_TOOLTIP
ptzr->setText(QString());
#ifndef QT_NO_TOOLTIP
ptzup->setToolTip(QApplication::translate("MainWindow", "<html><head/><body><p><span style=\" font-size:8pt;\">Mover hacia arriba</span></p></body></html>", Q_NULLPTR));
#endif // QT_NO_TOOLTIP
ptzup->setText(QString());
#ifndef QT_NO_TOOLTIP
ptzl->setToolTip(QApplication::translate("MainWindow", "<html><head/><body><p><span style=\" font-size:8pt;\">Mover hacia la izquierda</span></p></body></html>", Q_NULLPTR));
#endif // QT_NO_TOOLTIP
ptzl->setText(QString());
#ifndef QT_NO_TOOLTIP
ptzzi->setToolTip(QApplication::translate("MainWindow", "<html><head/><body><p><span style=\" font-size:8pt;\">Zoom (+)</span></p></body></html>", Q_NULLPTR));
#endif // QT_NO_TOOLTIP
ptzzi->setText(QString());
#ifndef QT_NO_TOOLTIP
ptzdown->setToolTip(QApplication::translate("MainWindow", "<html><head/><body><p><span style=\" font-size:8pt;\">Mover hacia abajo</span></p></body></html>", Q_NULLPTR));
#endif // QT_NO_TOOLTIP
ptzdown->setText(QString());
#ifndef QT_NO_TOOLTIP
presets->setToolTip(QApplication::translate("MainWindow", "<html><head/><body><p>Seleccionar preset</p></body></html>", Q_NULLPTR));
#endif // QT_NO_TOOLTIP
presets->setText(QString());
#ifndef QT_NO_TOOLTIP
ptztour->setToolTip(QApplication::translate("MainWindow", "<html><head/><body><p>Comenzar tour</p></body></html>", Q_NULLPTR));
#endif // QT_NO_TOOLTIP
ptztour->setText(QString());
} // retranslateUi
};
namespace Ui {
class MainWindow: public Ui_MainWindow {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_MAINWINDOW_H
|
// Created on: 1993-06-23
// Created by: Jean Yves LEBEY
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _TopOpeBRepDS_Interference_HeaderFile
#define _TopOpeBRepDS_Interference_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <TopOpeBRepDS_Transition.hxx>
#include <Standard_Integer.hxx>
#include <TopOpeBRepDS_Kind.hxx>
#include <Standard_Transient.hxx>
#include <Standard_OStream.hxx>
class TopOpeBRepDS_Interference;
DEFINE_STANDARD_HANDLE(TopOpeBRepDS_Interference, Standard_Transient)
//! An interference is the description of the
//! attachment of a new geometry on a geometry. For
//! example an intersection point on an Edge or on a
//! Curve.
//!
//! The Interference contains the following data :
//!
//! - Transition : How the interference separates the
//! existing geometry in INSIDE and OUTSIDE.
//!
//! - SupportType : Type of the object supporting the
//! interference. (FACE, EDGE, VERTEX, SURFACE, CURVE).
//!
//! - Support : Index in the data structure of the
//! object supporting the interference.
//!
//! - GeometryType : Type of the geometry of the
//! interference (SURFACE, CURVE, POINT).
//!
//! - Geometry : Index in the data structure of the
//! geometry.
class TopOpeBRepDS_Interference : public Standard_Transient
{
public:
Standard_EXPORT TopOpeBRepDS_Interference();
Standard_EXPORT TopOpeBRepDS_Interference(const TopOpeBRepDS_Transition& Transition, const TopOpeBRepDS_Kind SupportType, const Standard_Integer Support, const TopOpeBRepDS_Kind GeometryType, const Standard_Integer Geometry);
Standard_EXPORT TopOpeBRepDS_Interference(const Handle(TopOpeBRepDS_Interference)& I);
Standard_EXPORT const TopOpeBRepDS_Transition& Transition() const;
Standard_EXPORT TopOpeBRepDS_Transition& ChangeTransition();
Standard_EXPORT void Transition (const TopOpeBRepDS_Transition& T);
//! return GeometryType + Geometry + SupportType + Support
Standard_EXPORT void GKGSKS (TopOpeBRepDS_Kind& GK, Standard_Integer& G, TopOpeBRepDS_Kind& SK, Standard_Integer& S) const;
Standard_EXPORT TopOpeBRepDS_Kind SupportType() const;
Standard_EXPORT Standard_Integer Support() const;
Standard_EXPORT TopOpeBRepDS_Kind GeometryType() const;
Standard_EXPORT Standard_Integer Geometry() const;
Standard_EXPORT void SetGeometry (const Standard_Integer GI);
Standard_EXPORT void SupportType (const TopOpeBRepDS_Kind ST);
Standard_EXPORT void Support (const Standard_Integer S);
Standard_EXPORT void GeometryType (const TopOpeBRepDS_Kind GT);
Standard_EXPORT void Geometry (const Standard_Integer G);
Standard_EXPORT Standard_Boolean HasSameSupport (const Handle(TopOpeBRepDS_Interference)& Other) const;
Standard_EXPORT Standard_Boolean HasSameGeometry (const Handle(TopOpeBRepDS_Interference)& Other) const;
DEFINE_STANDARD_RTTIEXT(TopOpeBRepDS_Interference,Standard_Transient)
protected:
private:
TopOpeBRepDS_Transition myTransition;
Standard_Integer mySupport;
Standard_Integer myGeometry;
TopOpeBRepDS_Kind mySupportType;
TopOpeBRepDS_Kind myGeometryType;
};
#endif // _TopOpeBRepDS_Interference_HeaderFile
|
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
struct frete{
float preco;
float distancia;
int idx_preco;
int idx_dist;
};
struct fretista{
float preco;
int idx;
};
struct distancia{
float distancia;
int idx;
};
bool comparaPreco (fretista &a, fretista &b) { return a.preco > b.preco; } // > para decrescente e < para crescente
bool comparaDistancia (distancia &a, distancia &b) { return a.distancia < b.distancia; } // > para decrescente e < para crescente
bool comparaIdx (frete &a, frete &b) { return a.idx_dist < b.idx_dist; } // > para decrescente e < para crescente
int main(){
vector<frete> fretes;
vector<fretista> precos;
vector<distancia> distancias;
int size;
// cout << "Quantos fretes serão realizados?\n";
cin >> size;
struct distancia tmp_dist;
for(int i = 0; i < size; i++){
// cout << "(" << i + 1 << "/" << size << ")\n";
// cout << "Entre com o valor(dist): \n";
cin >> tmp_dist.distancia;
tmp_dist.idx = i;
distancias.push_back(tmp_dist);
}
struct fretista tmp_preco;
for(int i = 0; i < size; i++){
// cout << "(" << i + 1 << "/" << size << ")\n";
// cout << "Entre com o valor(preco): \n";
cin >> tmp_preco.preco;
tmp_preco.idx = i;
precos.push_back(tmp_preco);
}
sort(precos.begin(), precos.end(), comparaPreco);
sort(distancias.begin(), distancias.end(), comparaDistancia);
float menor_custo = 0;
struct frete tmp_frete;
for(int i = 0; i < size; i++){
tmp_frete.preco = precos[i].preco;
tmp_frete.distancia = distancias[i].distancia;
tmp_frete.idx_preco = precos[i].idx;
tmp_frete.idx_dist = distancias[i].idx;
menor_custo += tmp_frete.preco*tmp_frete.distancia;
fretes.push_back(tmp_frete);
}
sort(fretes.begin(), fretes.end(), comparaIdx);
// cout << "----------------------------------------------\n";
cout << menor_custo << "\n";
for(int i = 0; i < size; i++){
cout << fretes[i].idx_preco << "\n";
}
// for(int i = 0; i < size; i++){
// cout << precos[i].idx << "\n";
// }
return 0;
}
|
// Copyright Lionel Miele-Herndon 2020
#include "A_Gun.h"
#include "Components/SkeletalMeshComponent.h"
#include "Kismet/GameplayStatics.h"
#include "DrawDebugHelpers.h"
// Sets default values
AA_Gun::AA_Gun()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
Root = CreateDefaultSubobject<USceneComponent>(TEXT("Root"));
SetRootComponent(Root);
Mesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("Mesh"));
Mesh->SetupAttachment(Root);
}
// Called when the game starts or when spawned
void AA_Gun::BeginPlay()
{
Super::BeginPlay();
}
bool AA_Gun::GunTrace(FHitResult& Hit, FVector& ShotDirection)
{
//get hit point and draw a debug point where the linetrace hits
AController* OwnerController = GetOwnerController();
if (OwnerController == nullptr) return false;
FVector OwnerLocation;
FRotator OwnerRotation;
ShotDirection = -OwnerRotation.Vector();
OwnerController->GetPlayerViewPoint(OwnerLocation, OwnerRotation);
FVector End = OwnerLocation + OwnerRotation.Vector() * MaxRange;
FCollisionQueryParams Params;
Params.AddIgnoredActor(this);
Params.AddIgnoredActor(GetOwner());
return GetWorld()->LineTraceSingleByChannel(Hit, OwnerLocation, End, ECollisionChannel::ECC_GameTraceChannel1, Params);
}
AController* AA_Gun::GetOwnerController() const
{
APawn* OwnerPawn = Cast<APawn>(GetOwner());
if (OwnerPawn == nullptr) return nullptr;
return OwnerPawn->GetController();
}
// Called every frame
void AA_Gun::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void AA_Gun::Pull_Trigger()
{
//muzzle flash
UGameplayStatics::SpawnEmitterAttached(MuzzleFlash, Mesh, TEXT("MuzzleFlashSocket"));
//bang sound
//UGameplayStatics::SpawnSoundAttached(MuzzleSound, Mesh, TEXT("MuzzleFlashSocket"));
FHitResult Hit;
FVector ShotDirection;
bool bSuccess = GunTrace(Hit, ShotDirection);
if (bSuccess)
{
UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), HitFlash, Hit.Location, ShotDirection.Rotation());
UGameplayStatics::SpawnSoundAtLocation(GetWorld(), HitSound, Hit.Location, ShotDirection.Rotation(), 0.66);
AActor* HitActor = Hit.GetActor();
if (HitActor != nullptr)
{
FPointDamageEvent DamageEvent(Damage, Hit, ShotDirection, nullptr);
AController* OwnerController = GetOwnerController();
HitActor->TakeDamage(Damage, DamageEvent, OwnerController, this);
}
else
{
UE_LOG(LogTemp, Warning, TEXT("No actor found."));
}
}
}
|
//
// Game.cpp
// MirrorChess
//
// Created by Sergio Colado on 22.04.20.
// Copyright © 2020 Sergio Colado. All rights reserved.
//
#include "Game.hpp"
#include <iostream>
#include "utils.hpp"
using namespace sf;
Game::Game(): board("chess-board")
{
}
void Game::init()
{
render();
}
void Game::handleInput()
{
Event event;
mousePos = Mouse::getPosition(*windowPtr);
while (windowPtr->pollEvent(event))
{
switch (event.type)
{
case Event::Closed:
windowPtr->close();
break;
case Event::MouseButtonPressed:
if (event.key.code == Mouse::Left)
{
inputState = InputState::Pressed;
}
break;
case Event::MouseButtonReleased:
inputState = InputState::Released;
break;
default:
break;
}
}
}
void Game::render()
{
RenderWindow window(VideoMode(800, 800), "Mirror Chess");
windowPtr = &window;
while (window.isOpen())
{
handleInput();
update();
window.clear();
window.draw(board.getSpriteRef());
for (int i = 0; i < board.getNumberOfPieces(); i++)
{
window.draw(board.getPieceRef("black", i));
}
for (int i = 0; i < board.getNumberOfPieces(); i++)
{
window.draw(board.getPieceRef("white", i));
}
window.display();
}
}
void Game::update()
{
switch (inputState)
{
case InputState::Pressed:
board.update(mousePos, true);
break;
case InputState::Released:
board.update(mousePos, false);
inputState = InputState::Inactive;
break;
default:
break;
}
}
|
#ifndef NEUMANN_HH
#define NEUMANN_HH
#include <cstdint>
#include <memory>
#include "trng.hh"
class TRNG_VonNeumannDebias : public TRNG
{
public:
TRNG_VonNeumannDebias(std::shared_ptr<TRNG> baseTRNG) { mBaseTRNG = baseTRNG; }
void start() override { mBaseTRNG->start(); }
void stop() override { mBaseTRNG->stop(); }
bool selfTestPassed() const override { return mBaseTRNG->selfTestPassed(); }
int fillBuffer(uint8_t* buffer, int size) override;
private:
std::shared_ptr<TRNG> mBaseTRNG;
int cnt_input[2] { 0,0 };
int cnt_output[2] { 0,0 };
int cnt_total_input = 0, cnt_total_output = 0;
};
#endif
|
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#define min(x, y) (x > y ? y : x)
#define LIMITED 1000000007
using namespace std;
/*
W = 1
pat = 1 (0)
W = 2
pat = 2 (1)
W = 3
pat = 3 (1)
W = 4
pat = 5 (2,1)
W = 5
pat = 8 (3,2)
W = 6
pat = 13 (5,3,4)
W = 7
pat = 21 (8,5,6)
W = 8
pat = 34 (13,8,10,9)
*/
int sum[9] = {0, 1, 2, 3, 5, 8, 13, 21, 34};
int pat[9][7] = {
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{1, 0, 0, 0, 0, 0, 0},
{1, 1, 0, 0, 0, 0, 0},
{2, 1, 2, 0, 0, 0, 0},
{3, 2, 2, 3, 0, 0, 0},
{5, 3, 4, 3, 5, 0, 0},
{8, 5, 6, 6, 5, 8, 0},
{13, 8, 10, 9, 10, 8, 13},
};
long long anstable[100][8] = {0};
void calc_dp(int H, int W)
{
anstable[0][0] = 1;
for (int i = 1; i <= H; i++)
{
for (int j = 0; j < W; j++)
{
if (j != 0)
{
anstable[i][j] = anstable[i - 1][j - 1] * pat[W][j - 1] + anstable[i-1][j] * (sum[W] - pat[W][j] - pat[W][j-1]) + anstable[i-1][j+1] * pat[W][j];
}
else
{
anstable[i][j] = anstable[i-1][j] * (sum[W] - pat[W][j]) + anstable[i-1][j+1] * pat[W][j];
}
anstable[i][j] %= LIMITED;
//printf("i%d j%d :%d\n",i,j,anstable[i][j]);
}
}
}
int main()
{
int H, W, K;
cin >> H >> W >> K;
calc_dp(H, W);
cout << anstable[H][K-1] << endl;
}
|
#if CONFIG_FREERTOS_UNICORE
#define ARDUINO_RUNNING_CORE 0
#else
#define ARDUINO_RUNNING_CORE 1
#endif
#define mqttServer "192.168.137.69"
//#define mqttServer "broker.hivemq.com "
#define WiFiSSID "thao"
#define WiFiPass "thao12345"
#define PubTopic "ESP32"
#include <WiFi.h>
#include <PubSubClient.h>
#include <SPI.h>
#include <MFRC522.h>
MFRC522 mfrc522(5, 13);
void TaskBlink( void *pvParameters );
void TaskMQTT( void *pvParameters );
TaskHandle_t Task2Blink;
TaskHandle_t Task1MQTT;
WiFiClient espClient;
PubSubClient client(espClient);
//#######################################
//----------GLOBAL VARIABLES------------
char Data[10] = "";
//#######################################
void setup() {
// initialize serial communication at 115200 bits per second:
Serial.begin(115200);
// Now set up two tasks to run independently.
xTaskCreatePinnedToCore(
TaskBlink
, "TaskBlink" // A name just for humans
, 16384 // This stack size can be checked & adjusted by reading the Stack Highwater
, NULL
, 2 // Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest.
, &Task2Blink
, ARDUINO_RUNNING_CORE);
xTaskCreatePinnedToCore(
TaskMQTT
, "TaskMQTT"
, 16384 // Stack size
, NULL
, 1 // Priority
, &Task1MQTT
, ARDUINO_RUNNING_CORE);
// Now the task scheduler, which takes over control of scheduling individual tasks, is automatically started.
}
void loop()
{
// Empty. Things are done in Tasks.
}
/*--------------------------------------------------*/
/*---------------------- Tasks ---------------------*/
/*--------------------------------------------------*/
void TaskBlink(void *pvParameters) // This is a task.
{
(void) pvParameters;
SPI.begin();
mfrc522.PCD_Init();
SemaphoreHandle_t RFIDMutex;
RFIDMutex = xSemaphoreCreateMutex();
for (;;) // A Task shall never return or exit.
{
if (mfrc522.PICC_IsNewCardPresent() && mfrc522.PICC_ReadCardSerial()) {
xSemaphoreTake(RFIDMutex,portMAX_DELAY);
sprintf(Data, "%u", RFIDCard ());
Serial.println (PublishMQTT (PubTopic, 0,Data, "/0", "/0"));
xSemaphoreGive(RFIDMutex);
}
}
}
void TaskMQTT(void *pvParameters) // This is a task.
{
(void) pvParameters;
SemaphoreHandle_t RFIDMutex;
RFIDMutex = xSemaphoreCreateMutex();
vTaskSuspend(Task2Blink);
ConnectToWiFi (WiFiSSID, WiFiPass);
client.setServer(mqttServer, 1883);
client.setCallback (callback);
ConnectMQTT(PubTopic, "Center610", 1);
vTaskResume(Task2Blink);
for (;;)
{
if (!client.connected()) {
ConnectMQTT(PubTopic, "Center610", 1);
}
client.loop();
}
}
void callback(char* topic, byte* payload, unsigned int length) {
String arrivedData;
Serial.print("Message arrived [");
Serial.print(topic);
Serial.print("] ");
for (int i=0;i<length;i++) {
arrivedData += (char)payload[i];
}
Serial.println();
Serial.println("########################");
Serial.println(arrivedData);
Serial.println("########################");
Serial.println();
}
void ConnectMQTT(const char* CliendID, const char* SubTopic, int qos) {
// Loop until we're reconnected
while (!client.connected()) {
Serial.println ("Attempting MQTT connection...");
// Attempt to connect, just a name to identify the client
if (client.connect(CliendID)) {
Serial.println("connected");
client.subscribe (SubTopic, qos);
// Once connected, publish an announcement...
} else {
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
// Wait 5 seconds before retrying
vTaskDelay(5000);
}
}
}
int ConnectToWiFi (const char* ssid, const char* password){
Serial.print("Attempting to connect to WPA SSID: ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
vTaskDelay(100);
Serial.print (".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
return WiFi.status();
}
const char* PublishMQTT (const char *ClientID,int SendingInterval ,char *str1, char *str2, char *str3){
char *Buffer = (char *) malloc(1 + strlen(str1)+ strlen(str2)+ strlen(str3));
strcpy(Buffer, str1);
strcat(Buffer, ";");
strcat(Buffer, str2);
strcat(Buffer, ";");
strcat(Buffer, str3);
client.publish( ClientID, Buffer);
vTaskDelay(SendingInterval);
Buffer = NULL;
free (Buffer);
return "Sending Data";
}
unsigned long RFIDCard (){
unsigned long UID = 0, UIDtemp = 0;
for (byte i = 0; i < mfrc522.uid.size; i++) {
UIDtemp = mfrc522.uid.uidByte[i];
UID = UID*256+UIDtemp;
}
mfrc522.PICC_HaltA();
return UID;
}
|
#ifndef REDDIALOG_H
#define REDDIALOG_H
#include <QDialog>
class RedDialog : public QDialog
{
Q_OBJECT
public:
explicit RedDialog(QWidget *parent = nullptr);
protected:
void paintEvent(QPaintEvent *event) override;
};
#endif // REDDIALOG_H
|
#include <iostream>
#include <string>
#include <ctime>
using namespace std;
int solve(int);
int solve(int, int, int, int, int, int);
int main() {
clock_t start = clock();
int result = solve(100);
clock_t end = clock();
cout << result << ' ' << (static_cast<double>(end) - start) / CLOCKS_PER_SEC << endl;
system("PAUSE");
}
int sum = 0;
int solve(int length) {
for (int i = 1; i <= 9; ++i) {
int count = 0;
for (int j = 1; j <= 9; ++j) {
count += solve(length, 1, (i * j)/10, (i * j)%10, i, j);
}
sum += i * count;
cout << i << ' ' << count << endl;
}
return sum%100000;
}
int solve(int length, int place, int remainder, int digit, int firstDigit, int multi) {
int count = 0;
int next = digit * multi + remainder;
int nextRemainder = next/10;
int nextDigit = next % 10;
if (nextRemainder == 0 && nextDigit == firstDigit && digit != 0) {
++count;
}
if (place < length - 1) {
count += solve(length, place + 1, nextRemainder, nextDigit, firstDigit, multi);
}
if (place < 5) {
sum += digit * count * pow(10, place);
}
return count;
}
|
class Solution {
public:
bool escapeGhosts(vector<vector<int>>& ghosts, vector<int>& target) {
int N = ghosts.size();
int ourDistance = abs(target[0]) + abs(target[1]);
for(vector<int> &ghost : ghosts){
int ghostDistance = abs(ghost[0] -target[0]) + abs(ghost[1] - target[1]);
if(ghostDistance <= ourDistance)
return false;
}
return true;
}
};
|
#pragma once
#include "../../../Toolbox/Toolbox.h"
#include "../../Drawable/Drawable.h"
#include <functional>
namespace ae
{
/// \ingroup graphics
/// <summary>
/// 2D quad that covers the entire screen. Setup to be used directly in normalized device coordinates.
/// </summary>
class AERO_CORE_EXPORT FullscreenQuadMesh : public Drawable
{
public:
/// <summary>Initialize the full-screen quad mesh.</summary>
/// <param name="_NewMaterialInstance">
/// Must create a new material instance for this sprite ?<para/>
/// If set to False, the default 2D material is taken and will be shared with all others sprite and 2D shapes with the default material.
/// </param>
FullscreenQuadMesh( Bool _NewMaterialInstance = True );
private:
/// <summary>Vertices to render that hold the texture.</summary>
Vertex2DArray m_QuadVertices;
/// <summary>Indices of the triangles made with the vertices.</summary>
IndexArray m_QuadIndices;
};
} // ae
|
#include <reactor/net/EPollPoller.h>
#include <assert.h>
#include <errno.h>
#include <string.h>
#include <sys/epoll.h>
#include <unistd.h>
#include <reactor/base/SimpleLogger.h>
#include <reactor/net/Channel.h>
using namespace reactor::base;
namespace reactor {
namespace net {
EPollPoller::EPollPoller(int size):
Poller(),
epfd_(::epoll_create(size)),
channels_() {
}
EPollPoller::~EPollPoller() {
::close(epfd_);
}
void EPollPoller::update_channel(Channel *channel) {
auto it = channels_.find(channel->fd());
struct epoll_event epoll_event;
int ret = 0;
epoll_event.data.fd = channel->fd();
epoll_event.events = to_epoll_events(channel->events());
if (it == channels_.end()) {
assert(channel->index() == -1);
channels_[channel->fd()] = channel;
channel->set_index(channel->fd()); // index>=0表示channel已被添加
ret = epoll_ctl(epfd_, EPOLL_CTL_ADD, channel->fd(), &epoll_event);
} else {
assert(channel->index() == channel->fd());
ret = epoll_ctl(epfd_, EPOLL_CTL_MOD, channel->fd(), &epoll_event);
}
if (ret < 0) {
LOG(Error) << strerror(errno);
}
}
void EPollPoller::remove_channel(Channel *channel) {
if (channel->index() >= 0) {
assert(channel->index() == channel->fd());
int ret = static_cast<int>(channels_.erase(channel->fd()));
assert(ret == 1);
struct epoll_event epoll_event;
epoll_event.data.fd = channel->fd();
epoll_event.events = 0;
ret = epoll_ctl(epfd_, EPOLL_CTL_DEL, channel->fd(), &epoll_event);
if (ret < 0) {
LOG(Error) << strerror(errno);
}
channel->set_index(-1);
}
}
int EPollPoller::poll(ChannelList *active_channels, int timeout_ms) {
std::vector<struct epoll_event> events(channels_.size());
int nevent = epoll_wait(epfd_, &events[0], static_cast<int>(events.size()), timeout_ms);
if (nevent < 0) {
LOG(Error) << strerror(errno);
} else if (nevent > 0) {
for (int i = 0; i < nevent; i++) {
int fd = events[i].data.fd;
int revents = EVENT_NONE;
Channel *channel = channels_[fd];
if (events[i].events & EPOLLIN) { revents |= EVENT_READ; }
if (events[i].events & EPOLLOUT) { revents |= EVENT_WRITE; }
if (events[i].events & EPOLLRDHUP) { revents |= EVENT_CLOSE; }
if (events[i].events & EPOLLHUP) { revents |= EVENT_CLOSE; }
if (events[i].events & EPOLLERR) { revents |= EVENT_ERROR; }
if ((revents & EVENT_CLOSE) && (revents & EVENT_READ)) {
revents &= ~EVENT_CLOSE;
}
channel->set_revents(static_cast<short>(revents));
active_channels->push_back(channel);
}
}
return nevent;
}
uint32_t EPollPoller::to_epoll_events(int events) {
uint32_t epoll_events = 0;
if (events & EVENT_READ) { epoll_events |= EPOLLIN; }
if (events & EVENT_WRITE) { epoll_events |= EPOLLOUT; }
if (events & EVENT_CLOSE) { epoll_events |= EPOLLRDHUP; }
// epoll_wait will always wait for EPOLLERR, no need to set it
// epoll_wait will always wait for EPOLLHUP, no need to set it
return epoll_events;
}
} // namespace net
} // namespace reactor
|
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "Item.h"
#include "Runtime/Engine/Classes/Components/DestructibleComponent.h"
#include "DestructibleJunk.generated.h"
/**
*
*/
UCLASS()
class HYPOXIA_API ADestructibleJunk : public AItem
{
GENERATED_BODY()
protected:
UPROPERTY(VisibleAnywhere)
UDestructibleComponent* DestructibleMesh;
public:
ADestructibleJunk();
//virtual void BeginPlay() override;
/*virtual void Tick(float) override;
virtual void Drop() override;*/
virtual bool Pickup(USceneComponent*, EControllerHand) override;
virtual void DoHit(FVector ImpactPoint, FVector NormalImpulse) override;
virtual void OnHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, FVector NormalImpulse, const FHitResult& Hit) override;
private:
bool Broken = false;
};
|
#include<iostream>
using namespace std;
int main() {
// Беззнаковые типы данных
cout << "Знаковые типы данны" << endl;
short varShort = -32; // Тип short - для очень небольших целых чисел
int varInteger = 2147; // Тип int - для небольших целых чисел
long varLong = 9'223; // Тип long - для больших целых чисел
long long varLongLong = 9'223'807; // Тип long long для очень больших целых чисел
float varFloat = 25.2; // Тип float - для маленьких дробных чисел
double varDouble = 2255.335; // Тип double - для больших дробных чисел
char varChar = 'c'; // Тип char - для символов
cout << varShort << endl;
cout << varInteger << endl;
cout << varLong << endl;
cout << varLongLong << endl;
cout << varFloat << endl;
cout << varDouble << endl;
cout << varChar << endl;
// Знаковые типы данных
cout << "Беззнаковые типы данных" << endl;
unsigned short uVarShort = 32; // Тип short - для очень небольших целых беззнаковых чисел
unsigned int uVarInteger = 2147; // Тип int - для небольших целых беззнаковых чисел
cout << uVarShort << endl;
cout << uVarInteger << endl;
return 0;
}
|
#include "GApp.h"
void GApp::onCleanup(void)
{
SDL_Quit();
}
|
#include "Contact.hpp"
std::string Contact::_fields_name[11] = {
"First Name",
"Last Name",
"Nickname",
"Login",
"Address",
"E-mail",
"Phone",
"Birthday",
"Favorite Meal",
"Underwear Color",
"Darkest Secret"
};
Contact::Contact()
{
}
Contact::~Contact()
{
}
bool Contact::create_contact(void)
{
int len = 0;
for(int i = 0; i < FIELDS_NUM; i++)
{
std::cout << this->_fields_name[i] << ": ";
std::getline(std::cin, this->_fields[i]);
len += this->_fields[i].length();
}
if (len > 0)
return (true);
std::cout << " ! Error! Empty contact.\n";
return (false);
}
void Contact::display_contact(void) const
{
for(int i = 0; i < FIELDS_NUM; i++)
std::cout << this->_fields_name[i] << ": " << this->_fields[i] << std::endl;
}
void Contact::display_descr(int index) const
{
std::cout << std::setw(10) << std::right << index + 1 << "|";
for(int i = 0; i < 3; i++)
{
if (this->_fields[i].length() <= 10)
std::cout << std::setw(10) << this->_fields[i];
else
std::cout << std::setw(9) << this->_fields[i].substr(0, 9) << ".";
std::cout << "|";
}
std::cout << std::endl;
}
|
#pragma once
#include <memory>
#include <string>
#include <vector>
#include <wrl/client.h>
struct IWICImagingFactory;
namespace imageutil {
class Image
{
std::vector<unsigned char> m_buffer;
int m_width;
int m_height;
int m_pixelBytes;
public:
Image(int w, int h, int pixelBytes);
int Width()const{ return m_width; }
int Stride()const{ return m_width*m_pixelBytes; }
int Height()const{ return m_height; }
unsigned char* Pointer(){ return m_buffer.empty() ? nullptr : &m_buffer[0]; }
UINT Size()const{ return static_cast<UINT>(m_buffer.size()); }
};
class Factory
{
IWICImagingFactory *m_factory;
public:
Factory();
~Factory();
std::shared_ptr<Image> Load(const std::wstring &path);
};
}
|
// RekeningTabungan.h
#ifndef REKENINGTABUNGAN_H
#define REKENINGTABUNGAN_H
#include "Rekening.h"
class RekeningTabungan : public Rekening {
public:
// Konstruktor menginisialisi saldo (parameter 1) dan biaya transaksi (parameter 2)
// Set biaya transaksi 0.0 apabila biaya transaksi bernilai negatif
RekeningTabungan(double, double);
// Getter, Setter
void setBiayaTransaksi(double);
double getBiayaTransaksi() const;
// Member Function
// Panggil fungsi simpanUang dari parent class
// Kurangkan saldo dengan biaya transaksi
void simpanUang(double);
// Panggil fungsi tarikUang dari parent class
// Kurangkan saldo dengan biaya transaksi hanya jika penarikan uang berhasil
// Saldo mungkin saja menjadi negatif apabila setelah penarikan, saldo < biaya transaksi
// Kembalikan boolean yang mengindikasikan apakah uang berhasil ditarik atau tidak
bool tarikUang(double);
private:
double biayaTransaksi;
};
#endif
|
#pragma once
#include <tuple>
#include <vector>
#include <string>
#include <windows.h>
#include "result.h"
Result<DWORD> send_bytes(HANDLE handle, std::string writeBuffer, int len);
Result<std::tuple<DWORD, DWORD>> recv_bytes(HANDLE handle, char * readBuffer, int size);
Result<std::tuple<DWORD, std::vector<char>>> get_more_data(HANDLE handle);
HANDLE connect_to_pipe(std::string pipe, DWORD connection_delay);
|
#include "CLArguments.h"
#include <iostream>
namespace cppag
{
std::vector <std::string> CLArguments::mArguments;
CLArguments::CLArguments(int argc, char** argv)
{
for(int i = 0; i < argc; ++i)
{
if(i==0)
{
std::string temp=argv[0];
//Windows or Unix style?
if(temp.find('/', 0)!=std::string::npos) //found /, search for /
{
temp.erase(temp.find_last_of("/", temp.length())+1, temp.length());
}
else //didn't find /, search for \.
{
temp.erase(temp.find_last_of("\\", temp.length())+1, temp.length());
}
mArguments.push_back(temp);
}
else
{
mArguments.push_back(argv[i]);
}
}
}
std::string CLArguments::getWorkingDirectory()
{
return (mArguments[0]);
}
std::string CLArguments::matchPath(std::string dir)
{
if(dir.find_first_of("/")==0
|| dir.find(":")!=std::string::npos)
{
return (dir);
}
std::string result=getWorkingDirectory()+dir;
return(result);
}
}
|
/*
** FILENAME CSerialPort.h
**
** PURPOSE This class can read, write and watch one serial port.
** It sends messages to its owner when something happends on the port
** The class creates a thread for reading and writing so the main
** program is not blocked.
**
** CREATION DATE 15-09-1997
** LAST MODIFICATION 12-11-1997
**
** AUTHOR Remon Spekreijse
**
**
*/
#ifndef __SERIALPORT_H__
#define __SERIALPORT_H__
#define WM_COMM_BREAK_DETECTED WM_USER+1 // A break was detected on input.
#define WM_COMM_CTS_DETECTED WM_USER+2 // The CTS (clear-to-send) signal changed state.
#define WM_COMM_DSR_DETECTED WM_USER+3 // The DSR (data-set-ready) signal changed state.
#define WM_COMM_ERR_DETECTED WM_USER+4 // A line-status error occurred. Line-status errors are CE_FRAME, CE_OVERRUN, and CE_RXPARITY.
#define WM_COMM_RING_DETECTED WM_USER+5 // A ring indicator was detected.
#define WM_COMM_RLSD_DETECTED WM_USER+6 // The RLSD (receive-line-signal-detect) signal changed state.
#define WM_COMM_RXCHAR WM_USER+7 // A character was received and placed in the input buffer.
#define WM_COMM_RXFLAG_DETECTED WM_USER+8 // The event character was received and placed in the input buffer.
#define WM_COMM_TXEMPTY_DETECTED WM_USER+9 // The last character in the output buffer was sent.
// small buffer for input - should be ok for this app, not enough for many others
// beware
#define IN_BUFFER_SIZE 64
class CSerialPort
{
public:
// contruction and destruction
CSerialPort();
virtual ~CSerialPort();
// port initialisation
// BOOL InitPort(UINT portnr = 1, UINT baud = 57600, char parity = 'N', UINT databits = 8, UINT stopsbits = 1, DWORD dwCommEvents = EV_RXCHAR | EV_CTS, UINT nBufferSize = 512);
BOOL InitPort(UINT portnr = 5, UINT baud = 115000, char parity = 'N', UINT databits = 8, UINT stopsbits = 1, DWORD dwCommEvents = EV_RXCHAR | EV_CTS, UINT nBufferSize = 512);
void ClosePort();
// start/stop comm watching
BOOL StartMonitoring();
BOOL RestartMonitoring();
BOOL StopMonitoring();
DWORD GetWriteBufferSize();
DWORD GetCommEvents();
DCB GetDCB();
void WriteToPort(unsigned char* string, int len);
void WriteToPort(unsigned char chr);
// whether we have sent the current packet
bool sentPacket;
void writeInBuffer(unsigned char in)
{
inBuffer[bufferWrite] = in;
if (bufferWrite<IN_BUFFER_SIZE-1)
bufferWrite++; // this algorithm just means that when we reach the end of our buffer, we just keep writing over the last byte
// hopefully won't come up!
}
unsigned char readInBuffer()
{
if (bufferWrite>0 && bufferRead!=bufferWrite)
{
int temp = inBuffer[bufferRead];
bufferRead++;
if (bufferRead==bufferWrite)
{
bufferWrite=0;
bufferRead=0;
}
return temp;
}
if (bufferRead==bufferWrite)
{
bufferWrite=0;
bufferRead=0;
}
return 0;
}
bool inBufferData()
{return !(bufferRead==bufferWrite);}
bool getConnected()
{return connected;}
protected:
// protected memberfunctions
void ProcessErrorMessage(char* ErrorText);
static UINT CommThread( LPVOID pParam );
static void ReceiveChar(CSerialPort* port, COMSTAT comstat);
static void WriteChar(CSerialPort* port);
// thread
CWinThread* m_Thread;
// synchronisation objects
CRITICAL_SECTION m_csCommunicationSync;
BOOL m_bThreadAlive;
// handles
HANDLE m_hShutdownEvent;
HANDLE m_hComm;
HANDLE m_hWriteEvent;
// Event array.
// One element is used for each event. There are two event handles for each port.
// A Write event and a receive character event which is located in the overlapped structure (m_ov.hEvent).
// There is a general shutdown when the port is closed.
HANDLE m_hEventArray[3];
// structures
OVERLAPPED m_ov;
COMMTIMEOUTS m_CommTimeouts;
DCB m_dcb;
// misc
UINT m_nPortNr;
unsigned char* m_szWriteBuffer;
unsigned short m_WriteBufferSize;
DWORD m_dwCommEvents;
DWORD m_nWriteBufferSize;
// bool for connection
bool connected;
// we have a small internal buffer which we upload characters into
// we then read them with the same timer that commands the write scehdule
// simplifies programming for subsequent developers
unsigned char inBuffer[IN_BUFFER_SIZE];
int bufferWrite;
int bufferRead;
};
#endif __SERIALPORT_H__
|
#include "Parser.h"
#include <iostream>
#include <string>
#include <fstream>
Parser::Parser(std::string fileInput)
{
file = fileInput;
inputFile.open(file);
}
bool Parser::hasMoreCommands()
{
return !(inputFile.eof());
}
void Parser::advance()
{
if (hasMoreCommands())
{
std::getline(inputFile, currentCommand);
while (currentCommand[0] == '/' || currentCommand.length() == 0 && hasMoreCommands())
{
std::getline(inputFile, currentCommand);
//get rid of the in-line comments
int findComment = currentCommand.find("/");
if (findComment != std::string::npos)
{
currentCommand = currentCommand.substr(0, findComment);
}
}
}
}
std::string Parser::commandType()
{
int spacePos = currentCommand.find(" ");
//if there is no space in the line, then it is an arithmetic command
if (spacePos == std::string::npos)
{
return "C_ARITHMETIC";
}
else
{
std::string commandTypeStr = currentCommand.substr(0, spacePos);
if (commandTypeStr == "push")
{
return "C_PUSH";
}
else if (commandTypeStr == "pop")
{
return "C_POP";
}
else if (commandTypeStr == "label")
{
return "C_LABEL";
}
else if (commandTypeStr == "goto")
{
return "C_GOTO";
}
else if (commandTypeStr.substr(0, 2) == "if")
{
return "C_IF";
}
else if (commandTypeStr == "function")
{
return "C_FUNCTION";
}
else if (commandTypeStr == "return")
{
return "C_RETURN";
}
else if(commandTypeStr == "call")
{
return "C_CALL";
}
else
{
return "error";
}
}
}
std::string Parser::arg1()
{
int space1 = currentCommand.find(" ");
if (space1 == std::string::npos)
{
return currentCommand;
}
else
{
int space2 = currentCommand.find(" ", space1 + 1);
return currentCommand.substr(space1 + 1, space2 - space1 - 1);
}
}
int Parser::arg2()
{
int space1_1 = currentCommand.find(" ");
int space2_1 = currentCommand.find(" ", space1_1 + 1);
std::string index = currentCommand.substr(space2_1 + 1);
return (std::stoi(index));
}
//Parser destructor
Parser::~Parser()
{
if (inputFile.is_open())
{
inputFile.close();
}
}
|
#include "sfmlDrawManager.h"
#include "resourceManager.h"
#include <SFML/Graphics/Color.hpp>
#include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/Graphics/Text.hpp>
#include <SFML/System/Vector2.hpp>
#include <memory>
SFMLDrawManager::SFMLDrawManager(sf::RenderWindow *window,
SFMLResourceManager *resourceManager)
: window(window), resourceManager(resourceManager) { }
SFMLDrawManager::~SFMLDrawManager() { }
void SFMLDrawManager::drawRectangle(Point<float> pos, Point<float> size,
Color color) {
sf::RectangleShape rect(sf::Vector2f(size.x, size.y));
auto offsetPos = Point<float>(pos.x + offset.x, pos.y + offset.y);
rect.setPosition(sf::Vector2f(offsetPos.x, offsetPos.y));
rect.setFillColor(colorToSFMLColor(color));
window->draw(rect);
}
void SFMLDrawManager::drawLine(Point<float> v1, Point<float> v2, Color color) {
sf::Vertex line[] = {
sf::Vertex(sf::Vector2f(v1.x + offset.x, v1.y + offset.y),
colorToSFMLColor(color)),
sf::Vertex(sf::Vector2f(v2.x + offset.x, v2.y + offset.y),
colorToSFMLColor(color))
};
window->draw(line, 2, sf::Lines);
}
void SFMLDrawManager::drawText(Point<float> pos, std::string text, int fontSize,
Color color) {
auto font = resourceManager->getFont();
sf::Text drawableText(text, font, fontSize);
drawableText.setFillColor(sf::Color(color.r, color.g,
color.b));
drawableText.setPosition(sf::Vector2f(pos.x-offset.x, pos.y-offset.y));
window->draw(drawableText);
}
void SFMLDrawManager::drawBitmap(Point<float> pos, Bitmap *bitmap) {
pos = Point<float>(pos.x + offset.x, pos.y + offset.y);
bitmap->draw(pos, this);
}
void SFMLDrawManager::drawSFMLImage(Point<float> pos, sf::Image *image) {
texture.loadFromImage(*image);
sprite.setTexture(texture);
sprite.setPosition(sf::Vector2f(pos.x, pos.y));
window->draw(sprite);
}
sf::Color SFMLDrawManager::colorToSFMLColor(Color c) {
return sf::Color(c.r, c.g, c.b, c.a);
}
|
#pragma once
enum enMouseEve {
enLeftClick,
enMiddleClick,
enRightClick,
enNotchUp,
enNotchDown,
enNumMouseEve
};
namespace Mouse {
int GetMouseNotch();
void UpdateMouseInput();
bool isTrigger(enMouseEve);
bool isPress(enMouseEve);
CVector3 GetCursorPos();
}
|
#pragma once
#include <ctime>
#include <chrono>
#include <string>
namespace meplay {
class MPTimeTester final
{
public:
MPTimeTester(const std::string& name,uint64_t nMinDelay = 0);
~MPTimeTester();
public:
void Show(uint64_t nMinDelay = 0)const;
private:
std::chrono::time_point<std::chrono::steady_clock> m_timepoint;
std::string m_sName;
uint64_t m_nMinDelay;
};
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n;
int a[N];
int32_t main()
{
int t;
cin >> t;
while (t--)
{
cin >> n;
vector<int> even, odd;
for (int i = 1; i <= 2 * n; i++)
{
cin >> a[i];
if (a[i] % 2)
odd.push_back(i);
else
even.push_back(i);
}
vector<pair<int, int>> ans;
for (int i = 0; i + 1 < odd.size(); i += 2)
ans.push_back({odd[i], odd[i + 1]});
for (int i = 0; i + 1 < even.size(); i += 2)
ans.push_back({even[i], even[i + 1]});
for (int i = 0; i < n - 1; i++)
cout << ans[i].first << " " << ans[i].second << endl;
}
return 0;
}
|
#pragma once
namespace leaves { namespace pipeline
{
// traits for numeric types
template <typename T>
struct numeric_traits;
template <>
struct numeric_traits<float>
{
static constexpr data_format format() noexcept
{
return data_format::float_;
}
static constexpr size_t reg() noexcept
{
return 1;
}
static constexpr size_t size() noexcept
{
return 4;
}
};
template <>
struct numeric_traits<float2>
{
static constexpr data_format format() noexcept
{
return data_format::float2;
}
static constexpr size_t reg() noexcept
{
return 2;
}
static constexpr size_t size() noexcept
{
return 8;
}
};
template <>
struct numeric_traits<float3>
{
static constexpr data_format format() noexcept
{
return data_format::float3;
}
static constexpr size_t reg() noexcept
{
return 3;
}
static constexpr size_t size() noexcept
{
return 12;
}
};
template <>
struct numeric_traits<float4>
{
static constexpr data_format format() noexcept
{
return data_format::float4;
}
static constexpr size_t reg() noexcept
{
return 4;
}
static constexpr size_t size() noexcept
{
return 16;
}
};
template <>
struct numeric_traits<float2x2>
{
static constexpr data_format format() noexcept
{
return data_format::float2x2;
}
static constexpr size_t reg() noexcept
{
return 4;
}
static constexpr size_t size() noexcept
{
return 32;
}
};
template <>
struct numeric_traits<float2x3>
{
static constexpr data_format format() noexcept
{
return data_format::float2x3;
}
static constexpr size_t reg() noexcept
{
return 4;
}
static constexpr size_t size() noexcept
{
return 32;
}
};
template <>
struct numeric_traits<float2x4>
{
static constexpr data_format format() noexcept
{
return data_format::float2x4;
}
static constexpr size_t reg() noexcept
{
return 4;
}
static constexpr size_t size() noexcept
{
return 32;
}
};
template <>
struct numeric_traits<float3x2>
{
static constexpr data_format format() noexcept
{
return data_format::float3x2;
}
static constexpr size_t reg() noexcept
{
return 4;
}
static constexpr size_t size() noexcept
{
return 48;
}
};
template <>
struct numeric_traits<float3x3>
{
static constexpr data_format format() noexcept
{
return data_format::float3x3;
}
static constexpr size_t reg() noexcept
{
return 4;
}
static constexpr size_t size() noexcept
{
return 48;
}
};
template <>
struct numeric_traits<float3x4>
{
static constexpr data_format format() noexcept
{
return data_format::float3x4;
}
static constexpr size_t reg() noexcept
{
return 4;
}
static constexpr size_t size() noexcept
{
return 48;
}
};
template <>
struct numeric_traits<float4x2>
{
static constexpr data_format format() noexcept
{
return data_format::float4x2;
}
static constexpr size_t reg() noexcept
{
return 4;
}
static constexpr size_t size() noexcept
{
return 64;
}
};
template <>
struct numeric_traits<float4x3>
{
static constexpr data_format format() noexcept
{
return data_format::float4x3;
}
static constexpr size_t reg() noexcept
{
return 4;
}
static constexpr size_t size() noexcept
{
return 64;
}
};
template <>
struct numeric_traits<float4x4>
{
static constexpr data_format format() noexcept
{
return data_format::float4x4;
}
static constexpr size_t reg() noexcept
{
return 4;
}
static constexpr size_t size() noexcept
{
return 64;
}
};
template <typename T, size_t N>
using type_at = std::remove_cv_t<std::remove_reference_t<
typename boost::fusion::result_of::at_c<T, N>::type >> ;
template <typename T>
using is_sequence = boost::fusion::traits::is_sequence<T>;
template <typename T>
using sequence_size = boost::fusion::result_of::size<T>;
template <typename T>
struct array_traits
{
using type = T;
using numeric_traits_t = numeric_traits<type>;
static constexpr size_t count = 1;
};
template <typename T, size_t N>
struct array_traits<T[N]>
{
static_assert(N > 1, "N must be bigger than 1!");
using type = T;
using numeric_traits_t = numeric_traits<type>;
static constexpr size_t count = N;
};
template <typename T, size_t N>
struct array_traits<std::array<T, N>>
{
static_assert(N > 1, "N must be bigger than 1!");
using type = T;
using numeric_traits_t = numeric_traits<type>;
static constexpr size_t count = N;
};
} }
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#ifndef cmPropertyDefinition_h
#define cmPropertyDefinition_h
#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include "cmProperty.h"
/** \class cmPropertyDefinition
* \brief Property meta-information
*
* This class contains the following meta-information about property:
* - Name;
* - Various documentation strings;
* - The scope of the property;
* - If the property is chained.
*/
class cmPropertyDefinition
{
public:
/// Define this property
void DefineProperty(const std::string& name, cmProperty::ScopeType scope,
const char* ShortDescription,
const char* FullDescription, bool chained);
/// Default constructor
cmPropertyDefinition() { this->Chained = false; }
/// Is the property chained?
bool IsChained() const { return this->Chained; }
/// Get the scope
cmProperty::ScopeType GetScope() const { return this->Scope; }
/// Get the documentation (short version)
const std::string& GetShortDescription() const
{
return this->ShortDescription;
}
/// Get the documentation (full version)
const std::string& GetFullDescription() const
{
return this->FullDescription;
}
protected:
std::string Name;
std::string ShortDescription;
std::string FullDescription;
cmProperty::ScopeType Scope;
bool Chained;
};
#endif
|
// https://oj.leetcode.com/problems/valid-palindrome/
class Solution {
public:
bool isPalindrome(string s) {
if (s.size() == 0) {
return true;
}
size_t len = s.size();
size_t i = 0, j = len - 1;
while (i < j) {
if (!isalnum(s[i])) {
i++;
continue;
}
if (!isalnum(s[j])) {
j--;
continue;
}
if (tolower(s[i]) != tolower(s[j])) {
return false;
}
i++;
j--;
}
return true;
}
};
|
#ifndef _PlayerTimer_H
#define _PlayerTimer_H
#include <time.h>
#include "CDL_Timer_Handler.h"
#define LEAVE_TIMER 20
#define HEART_TIMER 21
#define START_TIMER 22
#define BET_TIMER 23
#define CHECK_TIMER 24
class Player;
class Player;
class PlayerTimer;
class CTimer_Handler:public CCTimer
{
public:
virtual int ProcessOnTimerOut();
void SetTimeEventObj(PlayerTimer * obj, int timeid, int uid = 0);
void StartTimer(long interval)
{
CCTimer::StartTimer(interval*1000);
}
private:
int timeid;
int uid;
PlayerTimer * handler;
};
class PlayerTimer
{
public:
PlayerTimer(){} ;
virtual ~PlayerTimer() {};
void init(Player* player);
//操作超时函数
public:
void stopAllTimer();
void startLeaveTimer(int timeout);
void stopLeaveTimer();
void startHeartTimer(int uid,int timeout);
void stopHeartTimer();
void startGameStartTimer(int uid,int timeout);
void stopGameStartTimer();
void startBetCoinTimer(int uid,int timeout);
void stopBetCoinTimer();
void startCheckTimer(int uid,int timeout);
void stopCheckTimer();
//发送通知函数
public:
int KnowProcess();
int UnKnowProcess();
private:
Player* player;
int ProcessOnTimerOut(int Timerid, int uid);
//处理机器人下注超时
CTimer_Handler m_BetTimer;
//随机出去
CTimer_Handler m_LeaveTimer;
//心跳时间
CTimer_Handler m_HeartTimer;
//心跳时间
CTimer_Handler m_CheckTimer;
//超时回调函数
private:
int LeaveTimerTimeOut();
int HeatTimeOut(int uid);
int StartGameTimeOut(int uid);
int BetTimeOut(int uid);
int CheckTimeOut(int uid);
private:
friend class CTimer_Handler;
};
#endif
|
#ifndef AWS_TOKENIZER_H
#define AWS_TOKENIZER_H
/*
* aws/tokenizer.h
* AwesomeScript Tokenizer
* Author: Dominykas Djacenka
* Email: Chaosteil@gmail.com
*/
#include <istream>
#include <sstream>
#include <string>
#include "exception.h"
#include "token.h"
namespace AwS{
//! Converts a stream to Tokens.
/*!
* Uses any input stream to return valid to parse Tokens.
* The tokenizer skips comments and retrns tokens one by one.
*/
class Tokenizer{
public:
//! Constructor.
/*!
* \param input The input stream which provides text to convert the text to Tokens. The stream has to be open as long as the Tokenizer works.
*/
Tokenizer(std::istream& input);
//! Destructor.
~Tokenizer();
//! Gets the next Token from the input stream.
/*!
* \return A valid Token. If reading from the stream is finished, NULL is returned.
*/
Token* readNextToken();
private:
//! The state of the comment reading.
enum CommentState{
Comment_None = 0, //!< Not in a Coment, normal reading.
Comment_Line, //!< In a line, reads till EOL.
Comment_Block //!< In a comment block, reads till end of block.
};
//! Reads the current word, as identified by readNextToken().
/*!
* The word won't contain any special symbols except underscores. Can also contain numbers.
* \return A valid Token or NULL if invalid.
*/
Token* _readWord();
//! Reads the current number, as identified by readNextToken().
/*!
* The Token will be a normal integer or a float.
* \return A valid Token or NULL if invalid.
*/
Token* _readNumber();
//! Reads the current string, as identified by readNextToken().
/*!
* The string Token will contain a string without quotes.
* \return A valid Token or NULL if invalid.
*/
Token* _readString();
//! Reads the current symbol, as identified by readNextToken().
/*!
* A symbol consists of either one or two characters.
* \return A valid Token or NULL if invalid.
*/
Token* _readSymbol();
void _readNextChar();
bool _isFinished();
void _skipWhitespace();
void _skipComment();
void _storeCharReadNext();
std::string _extractString();
void _checkUnexpectedEnd() throw(Exception);
void _invalidCharacter() throw(Exception);
static bool _isNumber(const char letter);
static bool _isSymbol(const char letter);
static bool _isLetter(const char letter);
static bool _isLowercaseLetter(const char letter);
static bool _isUppercaseLetter(const char letter);
std::istream& _input;
char _currentChar;
long _currentLine;
std::stringstream _tokenValueBuffer;
CommentState _commentState;
enum _Error{
Unknown = 0,
EndOfSource,
InvalidCharacter
};
};
};
#endif
|
//
// main.cpp
// simpleJson
//
// Created by brainelectronics on 29.04.20.
// Copyright (c) 2020 brainelectronics. All rights reserved.
//
#include "main.h"
#include "jsonHelper.h"
int main(int argc, const char * argv[])
{
// allocate head and tmp node in the heap
struct Node* head = getNode();
// struct Node* tmp = getNode();
// create some basic json
// add an unsigned char (0...255) Node to the linked list
uint8_t abcU8 = 129;
addU8IntegerNode(&head, "uint8Node", &abcU8);
// add a signed char (-128...127) Node to the linked list
int8_t abcS8 = -123;
addS8IntegerNode(&head, "int8Node", &abcS8);
// add an unsigned int (0...65536) Node to the linked list
uint16_t abcU16 = 32800;
addU16IntegerNode(&head, "uint16Node", &abcU16);
// add a signed int (-32768...32767) Node to the linked list
int16_t abcS16 = -32760;
addS16IntegerNode(&head, "int16Node", &abcS16);
// add an unsigned long int (0...4294967295) Node to the linked list
uint32_t abcU32 = 2147483648; // maximum seems int32_t limits
addU32IntegerNode(&head, "uint32Node", &abcU32);
// add a signed long int (-2147483648...2147483647) Node to the linked list
int32_t abcS32 = -2147483648;
addS32IntegerNode(&head, "int32Node", &abcS32);
// add a float Node to the linked list
float abcF = 1.23456;
addFloatNode(&head, "floatNode", &abcF);
// add an integer Node to the linked list
int abc = 123;
addIntegerNode(&head, "intNode", &abc);
// add a string Node to the linked list
char* pSomeString = (char *) calloc(255, sizeof(char));
sprintf(pSomeString, "asdf bla bla %d", 1234);
addStringNode(&head, "strNode", pSomeString);
// add array Node to the linked list
int arr2[] = { 11, 22, 33, 44, 55, 66, 77 };
int numOfElements = sizeof(arr2) / sizeof(arr2[0]);
addArrayNode(&head, "arrayNode", arr2, numOfElements);
// add a nested Node list to the linked list
struct Node* nestedHead = addNestedNode(&head, "nodeNode");
// append a nested integer Node to the first sub Node (optional)
int bcd = 234;
addIntegerNode(&nestedHead, "intNestedNode", &bcd);
// append a nested string Node to the first sub Node (optional)
char* pNestedString = (char *) calloc(255, sizeof(char));
sprintf(pNestedString, "Hello World! @ %d", 9876);
addStringNode(&nestedHead, "strNestedNode", pNestedString);
// append a nested array Node to the first sub Node (optional)
int nestedArray[] = { 123, 456, 789 };
int nestedArrayElements = sizeof(nestedArray) / sizeof(nestedArray[0]);
addArrayNode(&nestedHead, "arrayNestedNode", nestedArray, nestedArrayElements);
// append a nested nested Node to the first sub Node (optional)
struct Node* nestedNestedHead = addNestedNode(&nestedHead, "nodeNestedNode");
// append a nested integer Node to the first sub Node (optional)
int cde = 345;
addIntegerNode(&nestedNestedHead, "intNestedNestedNode", &cde);
// append a nested integer Node to the first sub sub Node (optional)
int bcde = 2345;
addIntegerNode(&nestedHead, "intNestedNode2", &bcde);
// add an integer Node to the linked list
int abcd = 1234;
addIntegerNode(&head, "intNode2", &abcd);
// print the content of the linked list (JSON) so far
printf("Finished JSON creation\n");
printJson(&head, PRETTY);
printf("\n");
/*
// overwrite an existing integer Node with string
char* pOverwrittenIntString = (char *) calloc(255, sizeof(char));
sprintf(pOverwrittenIntString, "This integer Node is now a string Node");
addStringNode(&head, "intNode2", pOverwrittenIntString);
// print the content of the updated linked list (JSON)
printf("After overwriting intNode2 with string value\n");
printJson(&head, PRETTY);
printf("\n");
// search for node in the linked list
printf("\n\n\nSearching for Node\n");
tmp = searchForKeyString(&head, "nodeNode");
if (tmp != NULL)
{
printf("SUCCESS\nBEGIN OF \"%s\" CONTENT\n", tmp->keyStr);
if (tmp->type != aNode) {
// if found Node is an integer, string or array Node
printNodeContent(tmp);
}
else if (tmp->type == aNode)
{
// if it's a nested Node, take head of Node's content
tmp = (Node*)tmp->ptr;
printJson(&tmp, PRETTY);
}
printf("\nEND OF CONTENT\n");
}
else
{
printf("No matching node found\n");
}
printf("Updating some values of the JSON\n");
// update an existing Node or create a new Node
int newAbc = 246;
addIntegerNode(&head, "intNode", &newAbc);
// add a string Node to the linked list
char* pNewSomeString = (char *) calloc(255, sizeof(char));
sprintf(pNewSomeString, "qwertz bla bla %d", 2345);
addStringNode(&head, "strNode", pNewSomeString);
// append a nested array Node to the first sub Node (optional)
int newArray[] = { 111, 222, 333, 444, 555, 666, 777, 888 };
int newArrayElements = sizeof(newArray) / sizeof(newArray[0]);
addArrayNode(&head, "arrayNode", newArray, newArrayElements);
// search and get nested Node's content head
// or create new nested Node if None has been found
struct Node* foundNestedHead = getNestedNodeHead(&head, "strNode", true);
// add a new string and a new integer Node
char* pNewNestedSomeString = (char *) calloc(255, sizeof(char));
sprintf(pNewNestedSomeString, "Darlings bum bum %d.%d.%d", 26, 3, 18);
addStringNode(&foundNestedHead, "newStrNestedNode", pNewNestedSomeString);
int newInt = 999;
addIntegerNode(&head, "intNestedNode", &newInt);
// print the content of the updated linked list (JSON)
printf("Finished JSON update\n");
printJson(&head, PRETTY);
printf("\n");
printf("Clearing nested Node's content\n");
// clear nested Node's content
struct Node* clearedNestedHead = clearNestedNodeContent(&head, "nodeNode");
// print the content of the updated linked list (JSON)
printf("After cleaning\n");
printJson(&head, PRETTY);
printf("\n");
// search and get nested Node's content head
// or create new nested Node if None has been found
clearedNestedHead = getNestedNodeHead(&head, "nodeNode", true);
// add some new string and integer Node to clear nested Node
// update existing string Node
char* pStrNestedSomeString = (char *) calloc(255, sizeof(char));
sprintf(pStrNestedSomeString, "qwertz");
addStringNode(&clearedNestedHead, "newStrNestedNode", pStrNestedSomeString);
addIntegerNode(&clearedNestedHead, "intNode", &newAbc);
// print the content of the updated linked list (JSON)
printf("After adding one new nested string Node to nestedNode\n");
printJson(&head, PRETTY);
printf("\n");
*/
return 0;
}
|
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <iomanip>
#include <set>
#include <climits>
#include <ctime>
#include <complex>
#include <cmath>
#include <string>
#include <cctype>
#include <cstring>
#include <algorithm>
using namespace std;
#define endl '\n'
typedef pair<int,int> pii;
typedef long double ld;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
const int maxn=1005;
const int INF=0x3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-9;
inline int sgn(double a){return a<-eps? -1:a>eps;}
int n,k;
int a[maxn];
int dp[maxn*maxn];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
cin>>n>>k;
for(int i=0;i<n;i++){
cin>>a[i];
}
sort(a,a+n);
n=unique(a,a+n)-a;
n--;
// cout<<n<<endl;
for(int i=1;i<=n;i++)
a[i]-=a[0];
for(int i=1;i<=a[n]*k;i++){
dp[i]=k+1;
}
dp[0]=0;
for(int i=1;i<=n;i++){
for(int j=a[i];j<=a[i]*k;j++){
dp[j]=min(dp[j],dp[j-a[i]]+1);
}
}
for(int i=0;i<=a[n]*k;i++){
//cout<<i<<' '<<dp[i]<<endl;
if(dp[i]<=k){
cout<<i+a[0]*k<<' ';
}
}
return 0;
}
|
/* struct Node {
int data;
struct Node *next;
Node(int x) {
data = x;
next = NULL;
}
};
*/
/* Should return data of n'th node from the end of linked list.
* head: head of the linked list
* n: nth node from end to find
*/
int getNthFromLast(Node *head, int n)
{
// only gravity will pull me down
// Nth node from end of linked list
Node *tmp = head;
int x=n-1;
while(x && tmp->next) {
tmp = tmp->next;
x--;
}
if(x != 0)
return -1;
while(tmp->next) {
tmp = tmp->next;
head = head->next;
}
return head->data;
}
|
#include "settings.h"
Settings::Settings()
{
restore();
}
void Settings::restore()
{
autorun = true;
dateFormat = "dd/MM/yyyy";
rDisplay = repeatedDisplay::Future;
showNumber = false;
}
void Settings::save() const
{
QSettings settings(filePath, QSettings::IniFormat);
settings.setValue("Autorun", autorun);
settings.setValue("Date_format", dateFormat);
settings.setValue("Display_repeated", static_cast<int>(rDisplay));
settings.setValue("showNumber", showNumber);
if(autorun)
{
#ifdef Q_OS_WIN
QSettings autorunSetting("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run",
QSettings::NativeFormat);
autorunSetting.setValue("Note Keeper", QCoreApplication::applicationFilePath().replace('/','\\'));
#endif
}
else
{
#ifdef Q_OS_WIN
QSettings autorunSetting("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run",
QSettings::NativeFormat);
autorunSetting.remove("Note Keeper");
#endif
}
}
void Settings::load()
{
QFile file(filePath);
if(file.exists())
{
QSettings settings(filePath, QSettings::IniFormat);
autorun = settings.value("Autorun").toBool();
dateFormat = settings.value("Date_format").toString();
rDisplay = static_cast<repeatedDisplay>(settings.value("Display_repeated").toInt());
showNumber = settings.value("showNumber").toBool();
}
else
{
save();
}
}
|
#ifndef PLAYER_H
#define PLAYER_H
#include <SFML\Graphics.hpp>
class Player
{
public:
Player();
~Player();
protected:
};
#endif // !PLAYER_H
|
/* -*- c++ -*- */
/*
* Copyright 2015 <+YOU OR YOUR COMPANY+>.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <volk/volk.h>
#include <gnuradio/io_signature.h>
#include "float_array_impl.h"
namespace gr {
namespace grand {
float_array::sptr
float_array::make(jfloatArray array, int len, JavaVM *vm)
{
return gnuradio::get_initial_sptr
(new float_array_impl(array, len, vm));
}
float_array_impl::float_array_impl(jfloatArray array, int len, JavaVM *vm)
: gr::sync_block("float_array",
gr::io_signature::make(1, 1, sizeof(float)),
gr::io_signature::make(0, 0, 0))
{
d_vm = vm;
d_array = array;
d_env = NULL;
d_index = 0;
d_len = len;
d_cpp_array = (float*)volk_malloc(d_len*sizeof(float),
volk_get_alignment());
}
float_array_impl::~float_array_impl()
{
volk_free(d_cpp_array);
}
bool
float_array_impl::start()
{
// We need to get the Java environment from the JVM for the work
// thread fo the block. Almost certainly the first call to
// GetEnv will fail since we haven't attached it, yet, but this
// will take care of that.
int ret = d_vm->GetEnv((void**)&d_env, JNI_VERSION_1_6);
if(ret == JNI_EDETACHED) {
GR_WARN("float_array", "GetEnv: not attached");
if(d_vm->AttachCurrentThread(&d_env, NULL) != 0) {
GR_ERROR("float_array", "Failed AttachCurrentThread");
throw std::runtime_error("Failed AttachCurrentThread");
}
}
else if(ret == JNI_EVERSION) {
GR_ERROR("float_array", "JNI Version not supported");
throw std::runtime_error("JNI Version not supported");
}
return block::start();
}
bool
float_array_impl::stop()
{
d_vm->DetachCurrentThread();
return block::stop();
}
void
float_array_impl::set_array(jfloatArray array, int len)
{
d_array = array;
d_len = len;
d_index = 0;
delete [] d_cpp_array;
d_cpp_array = (float*)volk_malloc(d_len*sizeof(float),
volk_get_alignment());
}
int
float_array_impl::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const float *in = (const float*)input_items[0];
// Lock access to the array until we've written the full d_len
if(d_index == 0) {
d_env->MonitorEnter(d_array);
}
int ncopy = std::min((d_len-d_index), noutput_items);
memcpy(&d_cpp_array[d_index], in, ncopy*sizeof(float));
d_index += ncopy;
// Have the full array, copy it back to the Java array and
// unlock our hold on the data.
if(d_index == d_len) {
d_env->SetFloatArrayRegion(d_array, 0, d_len, d_cpp_array);
d_env->MonitorExit(d_array);
d_index = 0;
}
return ncopy;
}
} /* namespace grand */
} /* namespace gr */
|
// ofile.cpp
#include "BlobCrystallinOligomer/monomer.h"
#include "BlobCrystallinOligomer/ofile.h"
#include "BlobCrystallinOligomer/particle.h"
namespace ofile {
using monomer::Monomer;
using nlohmann::json;
using particle::Particle;
using shared_types::distT;
using shared_types::CoorSet;
using std::ifstream;
using std::string;
OutputFile::OutputFile() {
}
OutputFile::OutputFile(string filename):
m_file {filename},
m_filename {filename} {
}
void OutputFile::close() {
m_file.close();
}
VSFOutputFile::VSFOutputFile() {
}
VSFOutputFile::VSFOutputFile(string filename, Config& conf):
OutputFile {filename} {
write_structure(conf);
}
void VSFOutputFile::write_structure(Config& conf) {
// This is a bit of a hack for the radius
int i {0};
for (auto m: conf.get_monomers()) {
for (auto p: m.get().get_particles()) {
m_file << "atom " << i << " ";
m_file << "type " << p.get().get_type() << " ";
m_file << "resid " << m.get().get_index() << " ";
m_file << "radius " << conf.get_radius() << "\n";
i++;
}
}
m_file << "\n";
distT x {conf.get_box_len()};
m_file << "pbc " << x << " " << x << " " << x << "\n";
m_file << "\n";
}
VCFOutputFile::VCFOutputFile() {
}
VCFOutputFile::VCFOutputFile(string filename):
OutputFile {filename} {
}
void VCFOutputFile::write_step(Config& conf, stepT) {
m_file << "t" << "\n";
for (Monomer& mono: conf.get_monomers()) {
for (Particle& part: mono.get_particles()) {
auto pos {part.get_pos(CoorSet::current)};
m_file << pos[0] << " " << pos[1] << " " << pos[2] << "\n";
}
}
m_file << "\n";
}
void VCFOutputFile::open_write_step_close(Config& conf, stepT step) {
m_file.open(m_filename);
write_step(conf, step);
m_file.close();
}
VTFOutputFile::VTFOutputFile(string filename, Config& conf):
OutputFile {filename} {
write_structure(conf);
}
void VTFOutputFile::open_write_close(Config& conf, stepT step) {
m_file.open(m_filename);
write_structure(conf);
write_step(conf, step);
m_file.close();
}
PatchOutputFile::PatchOutputFile(string filename):
OutputFile {filename} {
}
void PatchOutputFile::write_step(Config& conf) {
for (Monomer& mono: conf.get_monomers()) {
for (Particle& part: mono.get_particles()) {
auto ore = part.get_ore(CoorSet::current);
for (int i {0}; i != 3; i++) {
m_file << ore.patch_norm[i] << " ";
}
for (int i {0}; i != 3; i++) {
m_file << ore.patch_orient[i] << " ";
}
for (int i {0}; i != 3; i++) {
m_file << ore.patch_orient2[i] << " ";
}
}
}
m_file << "\n";
}
void PatchOutputFile::open_write_step_close(Config& conf) {
m_file.open(m_filename);
write_step(conf);
m_file.close();
}
}
|
#include<iostream>
using namespace std;
int main()
{
int x;
cout<<"Enter value of x:";
cin>>x;
cout<<"The value of x is:"<<x;
return 0;
}
|
#include "mathutil.h"
#include <GL/glew.h>
#include <sr1/vector>
#include <sr1/memory>
#include <sr1/noncopyable>
#include <sr1/zero_initialized>
#include "stb_truetype.h"
//Maria's Work
namespace rend
{
struct Context;
struct Font : public std::sr1::noncopyable
{
~Font();
void initFont(std::vector<unsigned char> buffer);
void printFont(float x, float y, char *text);
private:
friend struct Context;
std::sr1::shared_ptr<Context> context;
std::sr1::zero_initialized<GLuint> id;
//std::vector<unsigned char> ttf_buffer;
unsigned char temp_bitmap[512 * 512];
stbtt_bakedchar cdata[96]; // ASCII 32..126 is 95 glyphs
//GLuint getId();
};
}
|
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StdLPersistent_NamedData_HeaderFile
#define _StdLPersistent_NamedData_HeaderFile
#include <StdObjMgt_Attribute.hxx>
#include <StdLPersistent_HArray1.hxx>
#include <StdLPersistent_HArray2.hxx>
#include <TDataStd_NamedData.hxx>
#include <TCollection_HExtendedString.hxx>
class StdLPersistent_NamedData : public StdObjMgt_Attribute<TDataStd_NamedData>
{
template <class HValuesArray>
class pMapData
{
public:
typedef typename HValuesArray::ValueType ValueType;
inline void Read (StdObjMgt_ReadData& theReadData)
{ theReadData >> myKeys >> myValues; }
inline void Write (StdObjMgt_WriteData& theWriteData) const
{ theWriteData << myKeys << myValues; }
inline operator bool() const
{ return !myKeys.IsNull(); }
const TCollection_ExtendedString& Key (Standard_Integer theIndex) const
{ return myKeys->Array()->Value(theIndex)->ExtString()->String(); }
ValueType Value (Standard_Integer theIndex) const
{ return myValues ? myValues->Array()->Value(theIndex) : 0; }
private:
Handle(StdLPersistent_HArray1::Persistent) myKeys;
Handle(HValuesArray) myValues;
};
public:
//! Read persistent data from a file.
inline void Read (StdObjMgt_ReadData& theReadData)
{
theReadData >> myDimensions;
myInts .Read (theReadData);
myReals .Read (theReadData);
myStrings .Read (theReadData);
myBytes .Read (theReadData);
myIntArrays .Read (theReadData);
myRealArrays.Read (theReadData);
}
//! Write persistent data to a file.
inline void Write (StdObjMgt_WriteData& theWriteData) const
{
theWriteData << myDimensions;
myInts.Write(theWriteData);
myReals.Write(theWriteData);
myStrings.Write(theWriteData);
myBytes.Write(theWriteData);
myIntArrays.Write(theWriteData);
myRealArrays.Write(theWriteData);
}
//! Gets persistent child objects
void PChildren(StdObjMgt_Persistent::SequenceOfPersistent&) const {}
//! Returns persistent type name
Standard_CString PName() const { return "PDataStd_NamedData"; }
//! Import transient attribute from the persistent data.
void Import (const Handle(TDataStd_NamedData)& theAttribute) const;
private:
inline Standard_Integer lower (Standard_Integer theIndex) const;
inline Standard_Integer upper (Standard_Integer theIndex) const;
private:
Handle(StdLPersistent_HArray2::Integer) myDimensions;
pMapData<StdLPersistent_HArray1::Integer> myInts;
pMapData<StdLPersistent_HArray1::Real> myReals;
pMapData<StdLPersistent_HArray1::Persistent> myStrings;
pMapData<StdLPersistent_HArray1::Byte> myBytes;
pMapData<StdLPersistent_HArray1::Persistent> myIntArrays;
pMapData<StdLPersistent_HArray1::Persistent> myRealArrays;
};
#endif
|
/*
* Stopping Times
* Copyright (C) Leonardo Marchetti 2011 <leonardomarchetti@gmail.com>
*/
template <typename FP>
WrappedFunction2D<FP>::WrappedFunction2D(FP (*fptr)(FP, FP)) : fptr_(fptr){}
template <typename FP>
WrappedFunction2D<FP>::~WrappedFunction2D(){}
template <typename FP>
FP WrappedFunction2D<FP>::operator()(FP x, FP y)
{
return (*fptr_)(x, y);
}
|
// Created on: 2002-08-02
// Created by: Alexander KARTOMIN (akm)
// Copyright (c) 2002-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _LProp3d_SLProps_HeaderFile
#define _LProp3d_SLProps_HeaderFile
#include <Adaptor3d_Surface.hxx>
#include <LProp_Status.hxx>
class LProp3d_SLProps
{
public:
DEFINE_STANDARD_ALLOC
//! Initializes the local properties of the surface <S>
//! for the parameter values (<U>, <V>).
//! The current point and the derivatives are
//! computed at the same time, which allows an
//! optimization of the computation time.
//! <N> indicates the maximum number of derivations to
//! be done (0, 1, or 2). For example, to compute
//! only the tangent, N should be equal to 1.
//! <Resolution> is the linear tolerance (it is used to test
//! if a vector is null).
Standard_EXPORT LProp3d_SLProps(const Handle(Adaptor3d_Surface)& S, const Standard_Real U, const Standard_Real V, const Standard_Integer N, const Standard_Real Resolution);
//! idem as previous constructor but without setting the value
//! of parameters <U> and <V>.
Standard_EXPORT LProp3d_SLProps(const Handle(Adaptor3d_Surface)& S, const Standard_Integer N, const Standard_Real Resolution);
//! idem as previous constructor but without setting the value
//! of parameters <U> and <V> and the surface.
//! the surface can have an empty constructor.
Standard_EXPORT LProp3d_SLProps(const Standard_Integer N, const Standard_Real Resolution);
//! Initializes the local properties of the surface S
//! for the new surface.
Standard_EXPORT void SetSurface (const Handle(Adaptor3d_Surface)& S);
//! Initializes the local properties of the surface S
//! for the new parameter values (<U>, <V>).
Standard_EXPORT void SetParameters (const Standard_Real U, const Standard_Real V);
//! Returns the point.
Standard_EXPORT const gp_Pnt& Value() const;
//! Returns the first U derivative.
//! The derivative is computed if it has not been yet.
Standard_EXPORT const gp_Vec& D1U();
//! Returns the first V derivative.
//! The derivative is computed if it has not been yet.
Standard_EXPORT const gp_Vec& D1V();
//! Returns the second U derivatives
//! The derivative is computed if it has not been yet.
Standard_EXPORT const gp_Vec& D2U();
//! Returns the second V derivative.
//! The derivative is computed if it has not been yet.
Standard_EXPORT const gp_Vec& D2V();
//! Returns the second UV cross-derivative.
//! The derivative is computed if it has not been yet.
Standard_EXPORT const gp_Vec& DUV();
//! returns True if the U tangent is defined.
//! For example, the tangent is not defined if the
//! two first U derivatives are null.
Standard_EXPORT Standard_Boolean IsTangentUDefined();
//! Returns the tangent direction <D> on the iso-V.
Standard_EXPORT void TangentU (gp_Dir& D);
//! returns if the V tangent is defined.
//! For example, the tangent is not defined if the
//! two first V derivatives are null.
Standard_EXPORT Standard_Boolean IsTangentVDefined();
//! Returns the tangent direction <D> on the iso-V.
Standard_EXPORT void TangentV (gp_Dir& D);
//! Tells if the normal is defined.
Standard_EXPORT Standard_Boolean IsNormalDefined();
//! Returns the normal direction.
Standard_EXPORT const gp_Dir& Normal();
//! returns True if the curvature is defined.
Standard_EXPORT Standard_Boolean IsCurvatureDefined();
//! returns True if the point is umbilic (i.e. if the
//! curvature is constant).
Standard_EXPORT Standard_Boolean IsUmbilic();
//! Returns the maximum curvature
Standard_EXPORT Standard_Real MaxCurvature();
//! Returns the minimum curvature
Standard_EXPORT Standard_Real MinCurvature();
//! Returns the direction of the maximum and minimum curvature
//! <MaxD> and <MinD>
Standard_EXPORT void CurvatureDirections (gp_Dir& MaxD, gp_Dir& MinD);
//! Returns the mean curvature.
Standard_EXPORT Standard_Real MeanCurvature();
//! Returns the Gaussian curvature
Standard_EXPORT Standard_Real GaussianCurvature();
private:
Handle(Adaptor3d_Surface) mySurf;
Standard_Real myU;
Standard_Real myV;
Standard_Integer myDerOrder;
Standard_Integer myCN;
Standard_Real myLinTol;
gp_Pnt myPnt;
gp_Vec myD1u;
gp_Vec myD1v;
gp_Vec myD2u;
gp_Vec myD2v;
gp_Vec myDuv;
gp_Dir myNormal;
Standard_Real myMinCurv;
Standard_Real myMaxCurv;
gp_Dir myDirMinCurv;
gp_Dir myDirMaxCurv;
Standard_Real myMeanCurv;
Standard_Real myGausCurv;
Standard_Integer mySignificantFirstDerivativeOrderU;
Standard_Integer mySignificantFirstDerivativeOrderV;
LProp_Status myUTangentStatus;
LProp_Status myVTangentStatus;
LProp_Status myNormalStatus;
LProp_Status myCurvatureStatus;
};
#endif // _LProp3d_SLProps_HeaderFile
|
#include <cstdio>
#include <iostream>
using namespace std;
string add(string s1, string s2) { //s1更长
if(s1.length() < s2.length()) {
string temp = s1;
s1 = s2;
s2 = temp;
}
for(int i = s1.length() - 1, j = s2.length() - 1; i >= 0; i--, j--) {
s1[i] += j >= 0 ? s2[j] - '0' : 0;
if(s1[i] - '0' >= 10) { //进位
s1[i] = (s1[i] - '0') % 10 + '0';
if(i) s1[i - 1]++; //是否需要补位
else s1 = '1' + s1;
}
}
return s1;
}
int main() {
string a, b;
while(cin >> a >> b){
cout << add(a, b) << endl;
}
return 0;
}
|
/*
* UDPTransportStreamer.h
*
* Created on: 5 Apr 2011
* Author: two
*/
#ifndef UDPTRANSPORTSTREAMER_H_
#define UDPTRANSPORTSTREAMER_H_
#include "MyThread.h"
#include <iostream>
#include <time.h>
#include "Packetiser.h" // for timeDifCalc function
extern "C" {
#include <sys/socket.h>
#include <sys/types.h> /* socket types */
#include <netinet/in.h>
#include <arpa/inet.h>
#include <pthread.h>
};
using namespace std;
class UDPTransportStreamer: public MyThread
{
public:
struct sockaddr_in m_CliAddr;
int m_fdSocket;
socklen_t m_slFromLen;
struct timeval m_tvLastSTRT;
int m_nTimeOut; // time out of STRT to send messages.
bool m_bClientDead;
public:
UDPTransportStreamer();
UDPTransportStreamer(struct sockaddr_in addr, int fdSocket, socklen_t fromLen);
bool isAddr(struct sockaddr_in *addr);
void setTimeOut(int sec);
void gotSTRTat(struct timeval* time);
bool isClientDead();
void Setup();
void Execute();
void sendPacket(char* buffer, int size);
virtual ~UDPTransportStreamer();
};
#endif /* UDPTRANSPORTSTREAMER_H_ */
|
#include<random>
#include<iostream>
#include<string>
using namespace std;
const int N = 4;
int score[2] = { 0, 0 };
const int GOAL = 1 << (3 * N - 1);
char grid[N][N] ;
char uncovered[N][N];
void print_grid() {
for (int i = 0; i < ((N + 4) * N + 1); cout<< "-", i++);
cout << "\n";
for (int i = 0; i < N; i++) {
cout << "|";
for (int j = 0; j < N; j++) {
string e = "";
for (int t = 0; t < 3; e += " ", t++);
e += (grid[i][j]);
for (int t = 0; t < 3; e += " ", t++);
cout << e << "|";
}
cout << "\n";
for (int t = 0; t < ((N + 4) * N + 1); cout << "-", t++);
cout << "\n";
}
}
void generate_cell()
{
srand(time(0));
score[0] = 0;
score[1] = 0;
string str = "AABBCCDDEEFFGGHH";
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N; j++)
{
int rand_index = (rand() % str.length());
uncovered[i][j] = str[rand_index];
str.erase(rand_index, 1);
}
}
}
bool check_tie()
{
if (score[0] == 4 and score[1] == 4)
return true;
return false;
}
bool is_valid_position(int i, int j, int k,int l)
{
if (0 > i || i > 3)
return false;
if (0 > j || j > 3)
return false;
if (0 > k || k > 3)
return false;
if (0 > l || l > 3)
return false;
return true;
}
bool uncover_cells(int i, int j,int k, int l)
{
grid[i][j] = uncovered[i][j];
grid[k][l] = uncovered[k][l];
print_grid();
if (uncovered[i][j] != uncovered[k][l])
{
grid[i][j] = '?';
grid[k][l] = '?';
cout<< "sorry... your guess is wrong \n\n\n";
return false;
}
else {
cout<<"your guess is right\n";
return true;
}
}
void grid_clear()
{
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N; j++)
{
grid[i][j] = '?';
}
}
}
void play_game()
{
cout << "memory Game!"<<endl;
cout << "Welcome..."<<endl;
cout << "============================"<<endl;
int player = 0;
while (true)
{
cout << "player " << player << " turn"<<endl;
print_grid();
int i = 0; int j = 0; int k = 0; int l=0;
cout << "Enter the row index and column index for the first cell: ";
cin >> i >> j ;
cout << "Enter the row index and column index for the second cell: ";
cin >> k >> l ;
while (not is_valid_position(i, j, k, l) || grid[i][j] != '?' || grid[k][l] != '?' || ((i == k) and (j == l)))
{
cout << ("enter valid cells")<<endl;
cout << "Enter the row index and column index for the first cell: ";
cin >> i >> j;
cout << "Enter the row index and column index for the second cell: ";
cin >> k >> l;
}
if (uncover_cells(i, j, k, l))
{
score[player] += 1;
cout <<"player "<< player << " score is " << score[player] << "\n\n" ;
}
if (score[player] == 5)
{
cout<<"player " << player << " won" <<endl ;
break;
}
player = 1 - player;
if (check_tie())
{
cout << ("its a tie")<<endl;
break;
}
}
}
int main()
{
for(int i=0;i<N;i++)
{
for (int j = 0; j < N; j++)
{
grid[i][j] = '?';
}
}
while (true)
{
grid_clear();
generate_cell();
play_game();
char c;
cout << "Play Again [Y/N] ";
cin >> c;
if (c != 'y' && c != 'Y')
break;
}
}
|
/*
* Light.cpp
*
* author: Thomas Blackwell
* CS Username: tablackw
* email: tablackwell@email.wm.edu
*
* Contains the method definitions for the Light class.
*/
#include <math.h>
#include "Light.hpp"
#include <iostream>
// Constructor method for light
Light::Light(double x, double y, double z){
Vector loc(x,y,z);
this->loc = loc;
}
// Illuminate method: returns the lighted color of the closest sphere after being passed after
// applying three different forms of lighting to each color channel of the pixel.
COLOR_T Light::illuminate(RAY_T ray, COLOR_T obj_color, Vector int_pt, Vector normal){
COLOR_T color;
// Calculates ambient lighting in a lazy fashion - hardcoded values
color.r = 0.1 * obj_color.r;
color.g = 0.1 * obj_color.g;
color.b = 0.1 * obj_color.b;
//Diffuse lighting
Vector L = loc - int_pt;
L.normalize();
double dot = L.dot(normal);
// If dot is sufficient, apply the diffuse lighting.
if(dot > 0){
color.r += dot * obj_color.r;
color.g += dot * obj_color.g;
color.b += dot * obj_color.b;
// Specular lighting - basically "shines a light" on the spheres. Gives it
// the white circle on its surface.
Vector R = L - (normal * 2 * dot);
R.normalize();
double dot2 = R.dot(ray.dir);
// Only applies the specular lighting if the diffuse lighting is present.
if(dot2 >0){
// Modifies values of the color channels
color.r += pow(dot2,200);
color.g += pow(dot2,200);
color.b += pow(dot2,200);
}
}
// return our properly modified color.
return color;
}
|
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <memory.h>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <functional>
#include <numeric>
#include <sstream>
typedef long double LD;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;
#define PI 3.1415926535897932384626433832795
#define sqr(x) ((x)*(x))
using namespace std;
int ed[1111];
int a[11];
int main() {
freopen("jewelry.in", "r", stdin);
freopen("jewelry.out", "w", stdout);
for (int i= 0; i < 9; ++i)
scanf("%d", &a[i]);
for (int i = 1; i < 512; ++i) {
ed[i] = ed[i & (i - 1)] + 1;
if (ed[i] != 7) continue;
LL sum = 0;
for (int j = 0; j < 9; ++j) if (i & (1 << j)) {
sum += a[j];
}
if (sum == 100) {
for (int j = 0; j < 9; ++j) if (i & (1 << j)) {
cout << a[j] << endl;
}
return 0;
}
}
throw 1;
return 0;
}
|
/* -*- Mode: c++; tab-width: 4; c-basic-offset: 4 -*-
*
* Copyright (C) 1995-2007 Opera Software AS. All rights reserved.
*
* This file is part of the Opera web browser.
* It may not be distributed under any circumstances.
*
* Arjan van Leeuwen (arjanl)
*/
#include "core/pch.h"
#ifdef M2_SUPPORT
#include "adjunct/desktop_util/string/stringutils.h"
#include "adjunct/m2/src/util/inputconvertermanager.h"
/***********************************************************************************
** Convert (decode) a 8-bit string with the specified charset to utf-16
**
** InputConverterManager::ConvertToChar16
***********************************************************************************/
OP_STATUS InputConverterManager::ConvertToChar16(const OpStringC8& charset,
const OpStringC8& source,
OpString16& dest,
BOOL accept_illegal_characters,
BOOL append,
int length)
{
// Lockdown, getting and using the converters is not thread-safe
DesktopMutexLock lock(m_mutex);
// Get correct converter
InputConverter* conv;
RETURN_IF_ERROR(GetConverter(charset, conv));
// Start converting
int existing_length = append ? dest.Length() : 0;
// Actual conversion
OP_STATUS ret = ConvertToChar16(conv, source, dest, append, length);
// Check if the conversion went ok, and if not, if we can try another one
if ((OpStatus::IsError(ret) || (conv->GetNumberOfInvalid() > 0 && !accept_illegal_characters)) &&
!strni_eq(conv->GetCharacterSet(), "ISO-8859-1", 10))
{
// Not satisfactory, try with a iso-8859-1 input converter instead
// Remove any appended strings
if (dest.HasContent())
dest[existing_length] = 0;
return ConvertToChar16("iso-8859-1", source, dest, TRUE, append, length);
}
return ret;
}
/***********************************************************************************
** Convert with known input converter
**
** InputConverterManager::ConvertToChar16
***********************************************************************************/
OP_STATUS InputConverterManager::ConvertToChar16(InputConverter* converter, const OpStringC8& source, OpString16& dest, BOOL append, int length)
{
if (!append)
dest.Empty();
int src_len = length == KAll ? source.Length() : length;
int read = 0;
int total_written = UNICODE_SIZE(dest.Length());
const char* src = source.CStr();
uni_char* dest_ptr;
while (src_len > 0)
{
dest_ptr = dest.Reserve(UNICODE_DOWNSIZE(total_written) + src_len);
if (!dest_ptr)
return OpStatus::ERR_NO_MEMORY;
total_written += converter->Convert(src, src_len, ((char*)dest_ptr) + total_written, UNICODE_SIZE(dest.Capacity()) - total_written, &read);
if (!read) //We have data in the buffer that will not be converted. For now, we bail out with an OK
break;
src += read;
src_len -= read;
dest_ptr[UNICODE_DOWNSIZE(total_written)] = 0; // NULL-termination
}
return OpStatus::OK;
}
/***********************************************************************************
** Get a converter
**
** InputConverterManager::GetConverter
** @param charset Charset to find
** @param input_converter Where to store the converter
***********************************************************************************/
OP_STATUS InputConverterManager::GetConverter(const OpStringC8& charset, InputConverter*& input_converter)
{
// If we requested an empty charset, use iso-8859-1 instead
if (charset.IsEmpty())
return GetConverter("iso-8859-1", input_converter);
CharsetMap* map;
// Check if the converter is already there
if (OpStatus::IsSuccess(m_charset_map.GetData(charset.CStr(), &map)))
{
input_converter = map->converter;
input_converter->Reset();
return OpStatus::OK;
}
// We don't have the converter, create a new converter
map = OP_NEW(CharsetMap, ());
OpAutoPtr<CharsetMap> new_map(map);
if (!map)
return OpStatus::ERR_NO_MEMORY;
// If we can't find the converter, use iso-8859-1
#ifdef ENCODINGS_CAP_MUST_ALLOW_UTF7
if (OpStatus::IsError(InputConverter::CreateCharConverter(charset.CStr(), &map->converter, TRUE)))
#else
if (OpStatus::IsError(InputConverter::CreateCharConverter(charset.CStr(), &map->converter)))
#endif // ENCODINGS_CAP_MUST_ALLOW_UTF7
return GetConverter("iso-8859-1", input_converter);
RETURN_IF_ERROR(map->charset.Set(charset));
// Insert charset-map into the map hashtable so we can find it later
RETURN_IF_ERROR(m_charset_map.Add(map->charset.CStr(), map));
new_map.release();
// Return the input converter
input_converter = map->converter;
return OpStatus::OK;
}
#endif // M2_SUPPORT
|
#include "stdafx.h"
#include "GraphicsEngine.h"
#include "ShaderResources.h"
#include "CShaderResource.h"
GraphicsEngine::GraphicsEngine()
{
}
GraphicsEngine::~GraphicsEngine()
{
Release();
}
void GraphicsEngine::BegineRender() {
float ClearColor[4] = { 0.5f, 0.5f, 0.5f, 1.0f };
m_pd3dDeviceContext->OMSetRenderTargets(1, &m_backBuffer, m_depthStencilView);
m_pd3dDeviceContext->ClearRenderTargetView(m_backBuffer, ClearColor);
m_pd3dDeviceContext->ClearDepthStencilView(m_depthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0);
}
void GraphicsEngine::EndRender() {
m_pSwapChain->Present(2, 0);
}
void GraphicsEngine::Release()
{
if (m_rasterizerState != NULL) {
m_rasterizerState->Release();
m_rasterizerState = NULL;
}
if (m_depthStencil != NULL) {
m_depthStencil->Release();
m_depthStencil = NULL;
}
if (m_depthStencilView != NULL) {
m_depthStencilView->Release();
m_depthStencilView = NULL;
}
if (m_backBuffer != NULL) {
m_backBuffer->Release();
m_backBuffer = NULL;
}
if (m_pSwapChain != NULL) {
m_pSwapChain->Release();
m_pSwapChain = NULL;
}
if (m_pd3dDeviceContext != NULL) {
m_pd3dDeviceContext->Release();
m_pd3dDeviceContext = NULL;
}
if (m_pd3dDevice != NULL) {
m_pd3dDevice->Release();
m_pd3dDevice = NULL;
}
}
void GraphicsEngine::InitDirectX(HWND hwnd) {
DXGI_SWAP_CHAIN_DESC sd;
ZeroMemory(&sd, sizeof(sd));
sd.BufferCount = 1;
sd.BufferDesc.Width = (UINT)FRAME_BUFFER_W;
sd.BufferDesc.Height = (UINT)FRAME_BUFFER_H;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sd.BufferDesc.RefreshRate.Numerator = 60;
sd.BufferDesc.RefreshRate.Denominator = 1;
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.OutputWindow = hwnd;
sd.SampleDesc.Count = 1;
sd.SampleDesc.Quality = 0;
sd.Windowed = TRUE;
D3D_FEATURE_LEVEL featureLevels[] =
{
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0,
};
D3D11CreateDeviceAndSwapChain(
NULL,
D3D_DRIVER_TYPE_HARDWARE,
NULL,
0,
featureLevels,
sizeof(featureLevels) / sizeof(featureLevels[0]),
D3D11_SDK_VERSION,
&sd,
&m_pSwapChain,
&m_pd3dDevice,
&m_featureLevel,
&m_pd3dDeviceContext
);
ID3D11Texture2D* pBackBuffer = NULL;
m_pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&pBackBuffer);
m_pd3dDevice->CreateRenderTargetView(pBackBuffer, NULL, &m_backBuffer);
pBackBuffer->Release();
{
D3D11_TEXTURE2D_DESC texDesc;
ZeroMemory(&texDesc, sizeof(texDesc));
texDesc.Width = (UINT)FRAME_BUFFER_W;
texDesc.Height = (UINT)FRAME_BUFFER_H;
texDesc.MipLevels = 1;
texDesc.ArraySize = 1;
texDesc.Format = DXGI_FORMAT_D32_FLOAT;
texDesc.SampleDesc.Count = 1;
texDesc.SampleDesc.Quality = 0;
texDesc.Usage = D3D11_USAGE_DEFAULT;
texDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
texDesc.CPUAccessFlags = 0;
texDesc.MiscFlags = 0;
m_pd3dDevice->CreateTexture2D(&texDesc, NULL, &m_depthStencil);
//深度ステンシルビューを作成。
D3D11_DEPTH_STENCIL_VIEW_DESC descDSV;
ZeroMemory(&descDSV, sizeof(descDSV));
descDSV.Format = texDesc.Format;
descDSV.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
descDSV.Texture2D.MipSlice = 0;
m_pd3dDevice->CreateDepthStencilView(m_depthStencil, &descDSV, &m_depthStencilView);
}
D3D11_RASTERIZER_DESC desc = {};
desc.CullMode = D3D11_CULL_NONE;
desc.FillMode = D3D11_FILL_SOLID;
desc.DepthClipEnable = true;
desc.MultisampleEnable = true;
m_pd3dDevice->CreateRasterizerState(&desc, &m_rasterizerState);
D3D11_VIEWPORT viewport;
viewport.Width = FRAME_BUFFER_W;
viewport.Height = FRAME_BUFFER_H;
viewport.TopLeftX = 0;
viewport.TopLeftY = 0;
viewport.MinDepth = 0.0f;
viewport.MaxDepth = 1.0f;
m_pd3dDeviceContext->RSSetViewports(1, &viewport);
m_pd3dDeviceContext->RSSetState(m_rasterizerState);
m_spriteBatch = std::make_unique<DirectX::SpriteBatch>(m_pd3dDeviceContext);
m_spriteFont = std::make_unique<DirectX::SpriteFont>(m_pd3dDevice, L"Assets/font/myfile.spritefont");
m_spriteFontJa = std::make_unique<DirectX::SpriteFont>(m_pd3dDevice, L"Assets/font/myfileJa.spritefont");
m_spriteFontJaBig = std::make_unique<DirectX::SpriteFont>(m_pd3dDevice, L"Assets/font/myfileJaBig.spritefont");
m_spriteFontJPLog = std::make_unique<DirectX::SpriteFont>(m_pd3dDevice, L"Assets/font/MSmyfileJa.spritefont");
m_effectEngine.Init();
}
void GraphicsEngine::ChangeRenderTarget(ID3D11RenderTargetView* renderTarget, ID3D11DepthStencilView* depthStensil, D3D11_VIEWPORT* viewport)
{
ID3D11RenderTargetView* rtTbl[] = {
renderTarget
};
//レンダリングターゲットの切り替え。
m_pd3dDeviceContext->OMSetRenderTargets(1, rtTbl, depthStensil);
if (viewport != nullptr) {
//ビューポートが指定されていたら、ビューポートも変更する。
m_pd3dDeviceContext->RSSetViewports(1, viewport);
}
}
void GraphicsEngine::ChangeRenderTarget(RenderTarget* renderTarget, D3D11_VIEWPORT* viewport)
{
ChangeRenderTarget(
renderTarget->GetRenderTargetView(),
renderTarget->GetDepthStensilView(),
viewport
);
}
|
#pragma once
#include <Tanker/Crypto/SymmetricKey.hpp>
#include <Tanker/Device.hpp>
#include <Tanker/DeviceKeys.hpp>
#include <Tanker/Entry.hpp>
#include <Tanker/Groups/Group.hpp>
#include <Tanker/Groups/GroupProvisionalUser.hpp>
#include <Tanker/Trustchain/Actions/KeyPublish.hpp>
#include <Tanker/Trustchain/DeviceId.hpp>
#include <Tanker/Trustchain/GroupId.hpp>
#include <Tanker/Trustchain/ResourceId.hpp>
#include <Tanker/Trustchain/UserId.hpp>
#include <Tanker/Types/ProvisionalUserKeys.hpp>
#include <gsl-lite.hpp>
#include <optional>
#include <tconcurrent/coroutine.hpp>
#include <functional>
#include <memory>
#include <stdexcept>
#include <string>
#include <vector>
namespace Tanker
{
namespace DataStore
{
class RecordNotFound : public std::exception
{
public:
RecordNotFound(std::string msg) : _msg(std::move(msg))
{
}
char const* what() const noexcept override
{
return _msg.c_str();
}
private:
std::string _msg;
};
class ADatabase
{
public:
virtual ~ADatabase() = default;
tc::cotask<void> inTransaction(std::function<tc::cotask<void>()> const& f);
virtual tc::cotask<void> putUserPrivateKey(
Crypto::PublicEncryptionKey const& publicKey,
Crypto::PrivateEncryptionKey const& privateKey) = 0;
virtual tc::cotask<Crypto::EncryptionKeyPair> getUserKeyPair(
Crypto::PublicEncryptionKey const& publicKey) = 0;
virtual tc::cotask<std::optional<Crypto::EncryptionKeyPair>>
getUserOptLastKeyPair() = 0;
virtual tc::cotask<std::optional<uint64_t>> findTrustchainLastIndex() = 0;
virtual tc::cotask<std::optional<Crypto::PublicSignatureKey>>
findTrustchainPublicSignatureKey() = 0;
virtual tc::cotask<void> setTrustchainLastIndex(uint64_t) = 0;
virtual tc::cotask<void> setTrustchainPublicSignatureKey(
Crypto::PublicSignatureKey const&) = 0;
virtual tc::cotask<void> addTrustchainEntry(Entry const& Entry) = 0;
virtual tc::cotask<std::optional<Entry>> findTrustchainEntry(
Crypto::Hash const& hash) = 0;
virtual tc::cotask<void> putContact(
Trustchain::UserId const& userId,
std::optional<Crypto::PublicEncryptionKey> const& publicKey) = 0;
virtual tc::cotask<std::optional<Crypto::PublicEncryptionKey>>
findContactUserKey(Trustchain::UserId const& userId) = 0;
virtual tc::cotask<std::optional<Trustchain::UserId>>
findContactUserIdByPublicEncryptionKey(
Crypto::PublicEncryptionKey const& userPublicKey) = 0;
virtual tc::cotask<void> setContactPublicEncryptionKey(
Trustchain::UserId const& userId,
Crypto::PublicEncryptionKey const& userPublicKey) = 0;
virtual tc::cotask<void> putResourceKey(
Trustchain::ResourceId const& resourceId,
Crypto::SymmetricKey const& key) = 0;
virtual tc::cotask<std::optional<Crypto::SymmetricKey>> findResourceKey(
Trustchain::ResourceId const& resourceId) = 0;
virtual tc::cotask<void> putProvisionalUserKeys(
Crypto::PublicSignatureKey const& appPublicSigKey,
Crypto::PublicSignatureKey const& tankerPublicSigKey,
ProvisionalUserKeys const& provisionalUserKeys) = 0;
virtual tc::cotask<std::optional<ProvisionalUserKeys>>
findProvisionalUserKeys(
Crypto::PublicSignatureKey const& appPublicSigKey,
Crypto::PublicSignatureKey const& tankerPublicSigKey) = 0;
virtual tc::cotask<std::optional<Tanker::ProvisionalUserKeys>>
findProvisionalUserKeysByAppPublicEncryptionKey(
Crypto::PublicEncryptionKey const& appPublicEncryptionKey) = 0;
virtual tc::cotask<std::optional<DeviceKeys>> getDeviceKeys() = 0;
virtual tc::cotask<void> setDeviceKeys(DeviceKeys const& deviceKeys) = 0;
virtual tc::cotask<void> setDeviceId(
Trustchain::DeviceId const& deviceId) = 0;
virtual tc::cotask<std::optional<Trustchain::DeviceId>> getDeviceId() = 0;
virtual tc::cotask<void> putDevice(Trustchain::UserId const& userId,
Device const& device) = 0;
virtual tc::cotask<std::optional<Device>> findDevice(
Trustchain::DeviceId const& id) = 0;
virtual tc::cotask<std::vector<Device>> getDevicesOf(
Trustchain::UserId const& id) = 0;
virtual tc::cotask<std::optional<Trustchain::UserId>> findDeviceUserId(
Trustchain::DeviceId const& id) = 0;
virtual tc::cotask<void> updateDeviceRevokedAt(
Trustchain::DeviceId const& id, uint64_t revokedAtBlkIndex) = 0;
virtual tc::cotask<void> putInternalGroup(InternalGroup const& group) = 0;
virtual tc::cotask<void> putExternalGroup(ExternalGroup const& group) = 0;
virtual tc::cotask<std::optional<Group>> findGroupByGroupId(
Trustchain::GroupId const& groupId) = 0;
virtual tc::cotask<std::optional<Group>> findGroupByGroupPublicEncryptionKey(
Crypto::PublicEncryptionKey const& publicEncryptionKey) = 0;
virtual tc::cotask<void> nuke() = 0;
protected:
virtual tc::cotask<void> startTransaction() = 0;
virtual tc::cotask<void> commitTransaction() = 0;
virtual tc::cotask<void> rollbackTransaction() = 0;
};
using DatabasePtr = std::unique_ptr<ADatabase>;
tc::cotask<DatabasePtr> createDatabase(
std::string const& dbPath,
std::optional<Crypto::SymmetricKey> const& userSecret = {},
bool exclusive = true);
}
}
|
#include <iostream>
#include <windows.h> // knihovny
#include <conio.h>
using namespace std;
int main()
{
int delka,d,i,p=0;
char zn[100]="",text[100]="";
cout << "Pro sifrovani stisknete [1]"; // menu
cout << "\nPro desifrovani stisknete [2]";
if (getch()=='1') // ceka na stisk klavesy, pokud se zmackne 1 spusti se sifrovani
{
system("cls"); // vymaze predely text
SetConsoleTitle("Sifrovani"); // zmeni titul konzole
cout << "Zadej text na zasifrovani(pri delsi zprave nepouzivejte spec. znaky prosim):\n " ;
cin.getline(text,100);
delka=strlen(text); // urci delku retezce
cout << "\n Zasifrovana zprava: ";
for (i=0;i<delka;i++)
text[i]=text[i]+i-delka; // zasifruje retezec
cout << text;
cout << "\n Ulozeno do souboru sifra.txt"; // vypise retezec
FILE *sou;
sou = fopen ("sifra.txt","w");
fprintf (sou, "%s", text); // ulozi retezec do souboru
fclose(sou);
}
else if (getch()=='2') // ceka na stisk klavesy, pokud se zmackne 2 spusti se desifrovani
{
system("cls");
SetConsoleTitle("Desifrovani");
FILE *sou2;
sou2=fopen("sifra.txt","r");
while (!feof(sou2))
{
fgets(zn,100,sou2);
putchar(zn[p]);
p++;
}
fclose(sou2);
system("cls");
cout << "\n Sifrovana zprava: ";
cout << zn;
delka=strlen(zn);
for (i=delka;i>=0;i--) // udela opacny postup, tudiz desifruje retezec
zn[i]=zn[i]-i+delka;
cout << "\n Desifrovana zprava: ";
cout << zn;
cout << "\n Otevreno ze souboru sifra.txt";
}
else // pokud se nezmackne 1,2 tak vypise text
{
system("cls");
cout << "Spatny stisk klavesy, prosim opakujte restartovanim programu.";
system("PAUSE > NUL");
return 0;
}
system("PAUSE > NUL");
return 0;
}
|
/*
* Stopping Times
* Copyright (C) Leonardo Marchetti 2011 <leonardomarchetti@gmail.com>
*/
#ifndef _TEST_DE_SOLVER_H_
#define _TEST_DE_SOLVER_H_
#include "sde.h"
#include "test.h"
#include "test-poly.h"
#include "logger.h"
#include <boost/function.hpp>
namespace StoppingTimes{ namespace Testing{
class TestDESolver: public Test {
public:
TestDESolver(int id);
bool load(const char* path);
void run(Logger * logger);
~TestDESolver();
protected:
private:
double xf_;
double f0_;
double df0_;
int numberOfSteps_;
boost::function<double(double, double, double)> ddf_;
double expectedResult_;
TestPoly muPoly_;
TestPoly sigmaPoly_;
SDE<double> *eq_;
};
}}
#endif // _TEST_DE_SOLVER_H_
|
/**
* “Experience is the name everyone gives to their mistakes.” – Oscar Wilde
*
* author : prodipdatta7
* created : Monday 08-June, 2020 10:19:04 PM
**/
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <iterator>
#include <bitset>
#include <assert.h>
#include <new>
#include <sstream>
#include <time.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")
using namespace std ;
using namespace __gnu_pbds ;
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define debug(x) cerr << #x << " = " << x << '\n' ;
#define rep(i,b,e) for(__typeof(e) i = (b) ; i != (e + 1) - 2 * ((b) > (e)) ; i += 1 - 2 * ((b) > (e)))
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mem(a) memset(a , 0 ,sizeof a)
#define memn(a) memset(a , -1 ,sizeof a)
#define fread freopen("input.txt","r",stdin)
#define fwrite freopen("output.txt","w",stdout)
#define TN typename
#define FastIO ios_base::sync_with_stdio(false) ; cin.tie(NULL) ; cout.tie(NULL) ;
typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
typedef tree <int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_multiset;
/*
Note : There is a problem with erase() function in ordered_multiset (for less_equal<int> tag).
lower_bound() works as upper_bound() and vice-versa.
Be careful to use.
i) find_by_order(k) : kth smallest element counting from 0 .
ii) order_of_key(k) : number of elements strictly smaller than k.
*/
/*###############-> Input Section <-###############*/
template <TN T> inline void Int(T &a) {
bool minus = false; a = 0; char ch = getchar();
while (true) { if (ch == '-' or (ch >= '0' && ch <= '9')) break; ch = getchar(); }
if (ch == '-') minus = true; else a = ch - '0';
while (true) { ch = getchar(); if (ch < '0' || ch > '9') break; a = a * 10 + (ch - '0'); }
if (minus)a *= -1 ;
}
template < TN T, TN T1 > inline void Int(T &a, T1 &b) {Int(a), Int(b) ;}
template < TN T, TN T1, TN T2 > inline void Int(T &a, T1 &b, T2 &c) {Int(a, b), Int(c) ;}
template < TN T, TN T1, TN T2, TN T3 > inline void Int(T &a, T1 &b, T2 &c, T3 &d) {Int(a, b), Int(c, d) ;}
template < TN T, TN T1, TN T2, TN T3, TN T4> inline void Int(T &a, T1 &b, T2 &c, T3 &d, T4 &e) {Int(a, b), Int(c, d, e) ;}
/*###############-> Debugger <-###############*/
#ifndef ONLINE_JUDGE
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<TN T, TN... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << ' ' ;
err(++it, args...);
}
#else
#define error(args...)
#endif
template<class ValueType>
bool unstable_remove(
typename std::vector<ValueType>& container,
typename std::vector<ValueType>::iterator it
) {
auto lastEl = container.end() - 1;
if (it != lastEl) {
*it = std::move(*lastEl);
}
container.pop_back();
}
/******************************************
#Rows are numbered from top to bottom.
#Columns are numbered from left to right.
Moves : L, U, R, D, LU, RU, RD, LD.
******************************************/
int dx[8] = {0, -1, 0, 1, -1, -1, 1, 1} ;
int dy[8] = { -1, 0, 1, 0, -1, 1, 1, -1} ;
/*###############-> Constraints <-###############*/
const int N = (int)2e5 + 5 ;
const int maxN = (int)1e6 + 6 ;
const ll Mod = (ll)1e9 + 7 ;
const int inf = (int)2e9 ;
const ll Inf = (ll)1e18 ;
const int mod = (int)1e9 + 7 ;
const double EPS = (double)1e-9 ;
inline int add(int a, int b, int mod) {a += b ; return a >= mod ? a - mod : a ;}
inline int sub(int a, int b, int mod) {a -= b ; return a < 0 ? a + mod : a ;}
inline int mul(int a, int b, int mod) {return (ll)a * b % mod ;}
/*...... ! Code starts from here ! ......*/
int tin[N], dep[N], subSize[N], c[N], t ;
vvi g ;
vector < pii > v, T[N << 2] ;
void dfs(int s, int p) {
dep[s] = 1 + dep[p] ;
subSize[s] = 1 ;
tin[s] = ++t ;
v[t] = make_pair(dep[s], c[s]) ;
for (int i : g[s]) {
if (i == p)continue ;
dfs(i, s) ;
subSize[s] += subSize[i] ;
}
}
void build(int i, int b, int e) {
if (b == e) {
T[i].push_back(v[b]) ;
return ;
}
int mid = b + e >> 1 ;
build(i << 1, b, mid) ;
build(i << 1 | 1, mid + 1, e) ;
merge(all(T[i << 1]), all(T[i << 1 | 1]), back_inserter(T[i])) ;
for (int j = 1 ; j < sz(T[i]) ; ++j) {
if (T[i][j].ss > T[i][j - 1].ss)T[i][j].ss = T[i][j - 1].ss ;
}
// for(int j = 0 ; j < sz(T[i]) ; ++j)
// error(i, T[i][j].ff, T[i][j].ss)
}
int query(int i, int b, int e, int l, int r, int d) {
if (e < l or b > r)return inf ;
if (l <= b and e <= r) {
int lf = 0, rg = sz(T[i]) - 1, res = inf ;
while (lf <= rg) {
int m = lf + rg >> 1 ;
if (T[i][m].ff <= d) {
res = T[i][m].ss ;
lf = m + 1 ;
}
else rg = m - 1 ;
}
return res ;
}
int mid = b + e >> 1 ;
return min(query(i << 1, b, mid, l, r, d), query(i << 1 | 1, mid + 1, e, l, r, d)) ;
}
void solve() {
int n, r; Int(n, r) ;
for (int i = 1 ; i <= n ; ++i)
Int(c[i]) ;
g.resize(n + 1) ;
for (int i = 1 ; i < n ; ++i) {
int x, y ; Int(x, y) ;
g[x].push_back(y) ;
g[y].push_back(x) ;
}
v.resize(n + 1) ;
dfs(r, 0) ;
// for(int i = 1 ; i <= n ; ++i){
// error(i, v[i].ff, v[i].ss)
// }
build(1, 1, n) ;
int q ; Int(q) ;
int last = 0 ;
while (q--) {
int x, k ; Int(x, k) ;
x = ((x + last) % n) + 1, k = ((k + last) % n) ;
//error(x, k)
int l = tin[x], r = l + subSize[x] - 1 ;
//error(l, r, k)
last = query(1, 1, n, l, r, dep[x] + k) ;
printf("%d\n", last);
}
}
int main() {
#ifndef ONLINE_JUDGE
clock_t tStart = clock();
//freopen("input.txt", "r", stdin) ;
//freopen("output.txt", "w", stdout) ;
#endif
int test = 1 , tc = 0 ;
//Int(test) ;
while (test--) {
solve() ;
}
#ifndef ONLINE_JUDGE
fprintf(stderr, "\nRuntime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
#endif
return 0 ;
}
|
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepExtrema_ExtPC_HeaderFile
#define _BRepExtrema_ExtPC_HeaderFile
#include <Extrema_ExtPC.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <Standard_DefineAlloc.hxx>
class TopoDS_Vertex;
class TopoDS_Edge;
class BRepExtrema_ExtPC
{
public:
DEFINE_STANDARD_ALLOC
BRepExtrema_ExtPC()
{
}
//! It calculates all the distances. <br>
Standard_EXPORT BRepExtrema_ExtPC(const TopoDS_Vertex& V,const TopoDS_Edge& E);
Standard_EXPORT void Initialize(const TopoDS_Edge& E);
//! An exception is raised if the fields have not been initialized. <br>
Standard_EXPORT void Perform(const TopoDS_Vertex& V);
//! True if the distances are found. <br>
Standard_Boolean IsDone() const
{
return myExtPC.IsDone();
}
//! Returns the number of extremum distances. <br>
Standard_Integer NbExt() const
{
return myExtPC.NbExt();
}
//! Returns True if the <N>th extremum distance is a minimum. <br>
Standard_Boolean IsMin(const Standard_Integer N) const
{
return myExtPC.IsMin(N);
}
//! Returns the value of the <N>th extremum square distance. <br>
Standard_Real SquareDistance(const Standard_Integer N) const
{
return myExtPC.SquareDistance(N);
}
//! Returns the parameter on the edge of the <N>th extremum distance. <br>
Standard_Real Parameter(const Standard_Integer N) const
{
return myExtPC.Point(N).Parameter();
}
//! Returns the Point of the <N>th extremum distance. <br>
gp_Pnt Point(const Standard_Integer N) const
{
return myExtPC.Point(N).Value();
}
//! if the curve is a trimmed curve, <br>
//! dist1 is a square distance between <P> and the point <br>
//! of parameter FirstParameter <pnt1> and <br>
//! dist2 is a square distance between <P> and the point <br>
//! of parameter LastParameter <pnt2>. <br>
void TrimmedSquareDistances(Standard_Real& dist1,Standard_Real& dist2,gp_Pnt& pnt1,gp_Pnt& pnt2) const
{
myExtPC.TrimmedSquareDistances(dist1,dist2,pnt1,pnt2);
}
private:
Extrema_ExtPC myExtPC;
Handle(BRepAdaptor_Curve) myHC;
};
#endif
|
//
// Created by 史浩 on 2023/3/28.
//
#include "GLLooper.h"
GLLooper* glLooper=0;
|
#include "particles.h"
#include "imgui.h"
#include "utility.h"
#include "shaders.h"
#include "glbuffers.h"
#include <random>
#include <glad/glad.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
float GetRand(float min, float max, std::mt19937& rng) {
std::uniform_real_distribution<float> uid(min, max);
return uid(rng);
}
float MinMax(float min, float x, float max) {
return std::min(max, std::max(min, x));
}
float GetNormRand(float min, float max, std::mt19937& rng) {
std::normal_distribution<float> uid(0, 0.5);
return MinMax(min, uid(rng) * (max - min) / 2 + (min + max) / 2, max);
}
void ParticleRender::Load(glm::vec2 pos) {
glGenBuffers(1, ¶metersBuffer);
transform[0] = pos[0] - std::fmod(pos[0], 8.0f);
transform[1] = pos[1] - std::fmod(pos[1], 8.0f);
parameters.resize(10);
Update();
}
void ParticleRender::Reset() {
glDeleteBuffers(1, ¶metersBuffer);
}
void ParticleRender::Update() {
std::random_device rd;
std::mt19937 rng(rd());
for (size_t i = 0; i < parameters.size(); i++) {
parameters[i][0] = GetNormRand(-values[0], values[0], rng);
for (int j = 1; j < 4; j++) {
parameters[i][j] = GetRand(-values[j], values[j], rng);
}
}
Shaders().Shaders[to_ui32(ShadersId::Particle)].Select();
Buffers().ParticleBuffer.Bind();
glBindBuffer(GL_ARRAY_BUFFER, parametersBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(glm::vec4) * parameters.size(), ¶meters[0], GL_STATIC_DRAW);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(glm::vec4), (void*)0);
ObjectBuffer::Unbind();
}
void ParticleRender::GUI() {
int count = parameters.size();
bool needUpdate = false;
ImGui::Begin("Parameters", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
needUpdate = ImGui::SliderInt("Count", &count, 1, 1000) || needUpdate;
ImGui::SliderFloat("X", &transform[0], 0, 2000);
ImGui::SliderFloat("Y", &transform[1], 0, 1000);
ImGui::SliderFloat("W", &transform[2], 0, 100);
ImGui::SliderFloat("H", &transform[3], 0, 100);
ImGui::SliderFloat("Speed", &speed, 0, 10);
ImGui::SliderInt("Coord module", &coordMod, 1, 16);
ImGui::SliderInt("Point size", &pointSize, 1, 16);
ImGui::End();
ImGui::Begin("Values", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
needUpdate = ImGui::SliderFloat("A", &values[0], 0, 10) || needUpdate;
needUpdate = ImGui::SliderFloat("B", &values[1], 0, 10) || needUpdate;
needUpdate = ImGui::SliderFloat("C", &values[2], 0, 10) || needUpdate;
needUpdate = ImGui::SliderFloat("D", &values[3], 0, 10) || needUpdate;
ImGui::End();
parameters.resize(count);
if (needUpdate) {
Update();
}
}
void ParticleRender::Draw(uint32_t dt, bool gui) {
if (gui) GUI();
const Shader& partShader = Shaders().Shaders[to_ui32(ShadersId::Particle)];
partShader.Select();
Buffers().ParticleBuffer.Bind();
time += dt * speed / 1000000.0f;
partShader.SetFloat("Time", time);
partShader.SetFloat("MaxX", values[0]);
partShader.SetInt32("CoordMod", coordMod);
partShader.SetVec4("Transform", transform);
glPointSize(static_cast<float>(pointSize));
glBindBuffer(GL_ARRAY_BUFFER, parametersBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(glm::vec4) * parameters.size(), ¶meters[0], GL_STATIC_DRAW);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(glm::vec4), (void*)0);
glDrawArraysInstanced(GL_POINTS, 0, 1, parameters.size());
ObjectBuffer::Unbind();
}
|
#pragma once
#include "aeTexture2DResource.h"
namespace aeEngineSDK
{
struct aeMaterialProperty
{
};
class AE_ENGINE_EXPORT aeMaterial
{
private:
friend class aeResourceManager;
public:
aeMaterial();
aeMaterial(const aeMaterial& M);
~aeMaterial();
String GetName();
private:
Vector<aeTexture2DResource> m_aTextures;
Vector<aeMaterialProperty*> m_aProperties;
String m_pszName;
};
class AE_ENGINE_EXPORT aeMaterialResource : public aeEngineResource
{
private:
friend class aeResourceManager;
public:
aeMaterialResource();
aeMaterialResource(const aeMaterialResource& MR);
~aeMaterialResource();
public:
void Release() override;
AE_ENGINE_RESOURCE_ID GetID() const override;
String GetName() const override;
private:
SPtr<aeMaterial> m_pMaterial;
};
}
|
#include<bits/stdc++.h>
using namespace std;
char as[1010];
int a[42];
main()
{
int k;
while(cin>>k)
{
getchar();
cin>>as;
bool flag = true;
int i, j, p;
for(i=0; i<26; i++)a[i]=0;
for(i=0; i<strlen(as); i++)
a[as[i]-'a']++;
for(i=0; i<26; i++)
{
if(a[i]%k!=0)flag=false;
}
if(flag)
{
for(i=0; i<k; i++)
{
for(j=0; j<26; j++)
{
for(p=0; p< a[j]/k; p++)
printf("%c", j+'a');
}
}
}
else
printf("-1\n");
}
return 0;
}
|
/*
Nabaztag.cpp - Arduino library to send data to Nabaztag via I2C (RFID injected)
Copyright (c) 2011 Tobias Bielohlawek. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <Nabaztag.h>
#include <Wire.h>
#include <utility/twi.h>
void receiveCallback(int length)
{
Nabaztag.processReceive(length);
}
void requestCallback()
{
Nabaztag.processRequest();
}
volatile boolean NabaztagInjector::inited = false;
volatile boolean NabaztagInjector::sendEnabled = false;
int NabaztagInjector::rfidPort = 0;
byte NabaztagInjector::in[16];
uint8_t NabaztagInjector::out[32];
size_t NabaztagInjector::outSize = 0;
ByteBuffer NabaztagInjector::sendBuffer;
// Constructors ////////////////////////////////////////////////////////////////
NabaztagInjector::NabaztagInjector()
{
}
// Public //////////////////////////////////////////////////////
void NabaztagInjector::begin(int _rfidPort)
{
rfidPort = _rfidPort;
if(rfidPort > 0) {
pinMode(rfidPort, OUTPUT);
digitalWrite(rfidPort, LOW);
}
sendBuffer.init(SEND_BUFFER_SIZE);
Wire.begin(CRX14_ADR);
Wire.onReceive(receiveCallback);
Wire.onRequest(requestCallback);
enableRFID();
}
void NabaztagInjector::inject(uint8_t* data, uint8_t length)
{
for(int i = 0; i < length; i++) {
sendBuffer.put(data[i]);
}
disableRFID(); //aka start injection :-)
}
void NabaztagInjector::inject(uint8_t data)
{
inject(&data, 1);
}
void NabaztagInjector::inject(char* data)
{
inject((uint8_t*)data, strlen(data));
}
void NabaztagInjector::inject(int data)
{
inject((uint8_t)data);
}
// Callbacks //////////////////////////////////////////////////////
void NabaztagInjector::processReceive(int length) {
noInterrupts();
for(int i = 0; i < length; i++) {
byte data = Wire.read();
in[i] = data;
}
byte cmd = getCommand(length);
if( cmd == CMD_INIT ) inited = true;
if( cmd == CMD_CLOSE ) inited = false;
if( inited ) {
if( cmd == CMD_READ ) sendEnabled = true; //aparently a send is always expected after a read
if( cmd == CMD_INITATE ) { //not sure for CMD_SELECT, but code shows that it need response
byte s = ( sendBuffer.getSize() > 0 ) ? 1 : 0;
byte outNew[] = { s, 1 };
outSize = 2;
memcpy(out, outNew, outSize);
}
if( cmd == CMD_SLOT ) {
byte outNew[] = { 18, 0x01, 0x00, 0x0F, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; //length, BitMask, TagID
outSize = 19;
memcpy(out, outNew, outSize);
}
if( cmd == CMD_SELECT ) { //not sure for CMD_SELECT, but code shows that it need response
byte outNew[] = { 1, 1 };
outSize = 2;
memcpy(out, outNew, outSize);
}
if( cmd == CMD_GET_UID ) {
outSize = 9;
prepareOutBuffer();
}
}
interrupts();
}
void NabaztagInjector::processRequest() {
if( sendEnabled && outSize > 0 ) {
Wire.write(out, outSize);
if( sendBuffer.getSize() < 1 ) { //all data is send
inited = false;
enableRFID();
}
outSize = 0;
sendEnabled = false;
}
}
// Private //////////////////////////////////////////////////////
void NabaztagInjector::enableRFID() {
if(rfidPort > 0) {
twi_setAddress(DUMMY_ADR);
digitalWrite(rfidPort, HIGH);
}
}
void NabaztagInjector::disableRFID() {
if(rfidPort > 0) {
twi_setAddress(CRX14_ADR);
digitalWrite(rfidPort, LOW);
}
}
byte NabaztagInjector::getCommand(int length) {
switch( length ) {
case 4:
if( in[0] == 0x01 && in[1] == 0x02 && in[2] == 0x06 && in[3] == 0x00 ) return CMD_INITATE;
if( in[0] == 0x01 && in[1] == 0x02 && in[2] == 0x0E ) return CMD_SELECT; //forth byte is variable
break;
case 3:
if( in[0] == 0x01 && in[1] == 0x01 && in[2] == 0x0B ) return CMD_GET_UID;
if( in[0] == 0x01 && in[1] == 0x01 && in[2] == 0x0F ) return CMD_COMP;
break;
case 2:
if( in[0] == 0x00 && in[1] == 0x10 ) return CMD_INIT;
if( in[0] == 0x00 && in[1] == 0x00 ) return CMD_CLOSE;
break;
case 1:
if( in[0] == 0x01 ) return CMD_READ;
if( in[0] == 0x03 ) return CMD_SLOT;
break;
}
return CMD_UNKNOWN;
}
void NabaztagInjector::prepareOutBuffer() {
out[0] = 0x00; //Dummy first Byte
//it's "Little Endian" vs. "Big Endian" so cwe have to reverse data input
for( int i = 8; i > 0; i-- ) {
if( sendBuffer.getSize() > 0 ) {
out[i] = sendBuffer.get();
}
else {
out[i] = 0xFF; //fill up with bits -> see README.md
}
}
}
// Preinstantiate Objects //////////////////////////////////////////////////////
NabaztagInjector Nabaztag = NabaztagInjector();
|
#include "HallRegistProc.h"
#include "HallManager.h"
#include "ClientHandler.h"
#include "ServerManager.h"
#include "Logger.h"
HallRegistProc::HallRegistProc()
{
this->name = "HallRegistProc" ;
}
HallRegistProc::~HallRegistProc()
{
}
int HallRegistProc::doRequest(CDLSocketHandler* socketHandler, InputPacket* inputPacket, Context* pt)
{
_NOTUSED(pt);
ClientHandler* clientHandler = reinterpret_cast <ClientHandler*> (socketHandler);
int cmd = inputPacket->GetCmdType() ;
int hallid = inputPacket->ReadInt();
_LOG_DEBUG_("ParseData hallid=[%d]\n",hallid);
if(clientHandler)
{
clientHandler->setHandleType(HALLSRV_HANDLE);
HallManager::getInstance()->addHallHandler(hallid , clientHandler);
OutputPacket ReportPkg;
ReportPkg.Begin(ALLOC_TRAN_GAMEINFO);
ServerManager::getInstance()->buildPacketToHall(ReportPkg);
ReportPkg.End();
this->send(clientHandler, &ReportPkg, false);
return 0;
}
else
{
_LOG_ERROR_("RespData errmsg=[%s]\n","ClientHandler can't cast to HallHandler ClientHandler is NULL");
return -1;
}
}
int HallRegistProc::doResponse(CDLSocketHandler* socketHandler, InputPacket* inputPacket, Context* pt)
{
_NOTUSED(socketHandler);
_NOTUSED(inputPacket);
_NOTUSED(pt);
return 0;
}
|
/*
* Copyright (C) 2013 Tom Wong. All rights reserved.
*/
#include "gtmainsettings.h"
#include <QtCore/QSettings>
GT_BEGIN_NAMESPACE
GtMainSettings::GtMainSettings(QObject *parent)
: QObject(parent)
{
}
GtMainSettings::~GtMainSettings()
{
}
void GtMainSettings::load()
{
QSettings settings;
m_geometry = settings.value("geometry").toByteArray();
m_docSplitter = settings.value("docSplitter").toByteArray();
m_recentFiles = settings.value("recentFiles").toStringList();
m_lastOpenPath = settings.value("lastOpenPath").toString();
}
void GtMainSettings::save()
{
QSettings settings;
settings.setValue("geometry", m_geometry);
settings.setValue("docSplitter", m_docSplitter);
settings.setValue("recentFiles", m_recentFiles);
settings.setValue("lastOpenPath", m_lastOpenPath);
}
void GtMainSettings::setGeometry(const QByteArray &geometry)
{
m_geometry = geometry;
}
void GtMainSettings::setDocSplitter(const QByteArray &docSplitter)
{
m_docSplitter = docSplitter;
}
void GtMainSettings::setRecentFiles(const QStringList &files)
{
m_recentFiles = files;
}
void GtMainSettings::setLastOpenPath(const QString &path)
{
m_lastOpenPath = path;
}
GT_END_NAMESPACE
|
// Copyright (c) 2021 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BinTools_ObjectType_HeaderFile
#define _BinTools_ObjectType_HeaderFile
//! Enumeration defining objects identifiers in the shape read/write format.
enum BinTools_ObjectType
{
BinTools_ObjectType_Unknown = 0,
BinTools_ObjectType_Reference8, //!< 8-bits reference
BinTools_ObjectType_Reference16, //!< 16-bits reference
BinTools_ObjectType_Reference32, //!< 32-bits reference
BinTools_ObjectType_Reference64, //!< 64-bits reference
BinTools_ObjectType_Location,
BinTools_ObjectType_SimpleLocation,
BinTools_ObjectType_EmptyLocation,
BinTools_ObjectType_LocationEnd,
BinTools_ObjectType_Curve,
BinTools_ObjectType_EmptyCurve,
BinTools_ObjectType_Curve2d,
BinTools_ObjectType_EmptyCurve2d,
BinTools_ObjectType_Surface,
BinTools_ObjectType_EmptySurface,
BinTools_ObjectType_Polygon3d,
BinTools_ObjectType_EmptyPolygon3d,
BinTools_ObjectType_PolygonOnTriangulation,
BinTools_ObjectType_EmptyPolygonOnTriangulation,
BinTools_ObjectType_Triangulation,
BinTools_ObjectType_EmptyTriangulation,
BinTools_ObjectType_EmptyShape = 198, //!< identifier of the null shape
BinTools_ObjectType_EndShape = 199, //!< identifier of the shape record end
// here is the space for TopAbs_ShapeEnum+Orientation types
};
#endif // _BinTools_ObjectType_HeaderFile
|
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
typedef long long ll;
using namespace std;
const int N = 200111;
struct Tp {
ll d, t;
bool operator<(const Tp& c) const {
return d < c.d || (d == c.d && t < c.t);
}
} A[N];
bool alive[N];
int main() {
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
int n, t;
scanf("%d%d", &n, &t);
for (int i = 1; i <= n; ++i) {
alive[i] = true;
int d, t;
scanf("%d%d", &d, &t);
A[i].d = d;
A[i].t = t;
}
sort(A + 1, A + n + 1);
vector< pair<ll, int> > tt;
for (int i = 1; i <= n; ++i) {
tt.push_back(make_pair(A[i].d + A[i].t, i));
}
sort(tt.begin(), tt.end());
int ans = 0;
for (int who = 0; who < n; ++who) {
int x = tt[who].second;
if (!alive[x]) continue;
int y = x;
while (y + 1 <= n && alive[y + 1] && A[y].d + t > A[y + 1].d) {
if (A[y + 1].t < A[x].t) break;
alive[y] = false;
++y;
}
ans = max(ans, y - x + 1);
}
cout << ans << endl;
return 0;
}
|
#pragma once
#include <functional>
#include <Poco/SharedPtr.h>
namespace BeeeOn {
/**
* Class for asynchronous executing tasks.
*/
class AsyncExecutor {
public:
typedef Poco::SharedPtr<AsyncExecutor> Ptr;
AsyncExecutor();
virtual ~AsyncExecutor();
/**
* Add task to queue for executing
*/
virtual void invoke(std::function<void()> f) = 0;
};
}
|
#include "LDR.h"
#include <iostream>
#include <fstream>
using namespace std;
double readLight()
{
double adc_val = 0;
double light = 0;
// Input from file:
fstream LDRFile (LDR_PATH, fstream::in);
LDRFile >> adc_val;
LDRFile.close();
// Calibrate values:
light = (adc_val*1.8)/4095;
return light;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.