示例#1
0
ShaderSimpleDepth::ShaderSimpleDepth(bool doubleSided):
	m_with_color(false),
	m_ambiant(Geom::Vec4f(0.05f,0.05f,0.1f,0.0f)),
	m_diffuse(Geom::Vec4f(0.1f,1.0f,0.1f,0.0f)),
	m_lightPos(Geom::Vec3f(10.0f,10.0f,1000.0f)),
	m_vboPos(NULL),
	m_vboColor(NULL)
{
	m_nameVS = "ShaderSimpleDepth_vs";
	m_nameFS = "ShaderSimpleDepth_fs";
//	m_nameGS = "ShaderSimpleDepth_gs";

	// get choose GL defines (2 or 3)
	// ans compile shaders
	std::string glxvert(*GLSLShader::DEFINES_GL);
	glxvert.append(vertexShaderText);
	std::string glxfrag(*GLSLShader::DEFINES_GL);
	if (doubleSided)
		glxfrag.append("#define DOUBLE_SIDED\n");
	glxfrag.append(fragmentShaderText);

	loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str());

	// and get and fill uniforms
	getLocations();
	sendParams();
}
ShaderExplodeVolumesLines::ShaderExplodeVolumesLines()
{
	m_nameVS = "ShaderExplodeVolumesLines_vs";
	m_nameFS = "ShaderExplodeVolumesLines_fs";
	m_nameGS = "ShaderExplodeVolumesLines_gs";

	std::string glxvert(*GLSLShader::DEFINES_GL);
	glxvert.append(vertexShaderText);

	std::string glxgeom(GLSLShader::defines_Geom("triangles", "line_strip", 4));
	glxgeom.append(geometryShaderText);

	std::string glxfrag(*GLSLShader::DEFINES_GL);
	glxfrag.append(fragmentShaderText);

	loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str(), glxgeom.c_str(), GL_TRIANGLES , GL_LINE_STRIP,4);

	getLocations();

	//Default values
	m_explodeV = 0.9f;
	m_color = Geom::Vec4f(0.05f, 0.05f, 0.05f, 0.0f);
	m_plane   = Geom::Vec4f(0.0f, 0.0f, 1000.f, 1000000000000000000000000000.0f);
	setParams(m_explodeV, m_color, m_plane);
}
示例#3
0
ShaderIsoLines::ShaderIsoLines(int maxNbIsoPerTriangle)
{
	m_nameVS = "shaderIsoLines_vs";
	m_nameFS = "shaderIsoLines_fs";
	m_nameGS = "shaderIsoLines_gs";

	std::string glxvert(GLSLShader::defines_gl());
	glxvert.append(vertexShaderText);

	std::string glxgeom = GLSLShader::defines_Geom("triangles", "line_strip", 2*maxNbIsoPerTriangle);
	glxgeom.append(geometryShaderText);

	std::string glxfrag(GLSLShader::defines_gl());
	glxfrag.append(fragmentShaderText);

	loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str(), glxgeom.c_str(), GL_TRIANGLES, GL_LINE_STRIP, 2*maxNbIsoPerTriangle);

	getLocations();

	//Default values

	setColors(Geom::Vec4f(1.0f,0.0f,0.0f,1.0f),Geom::Vec4f(0.0f,1.0f,0.0f,1.0f));
	setDataBound(0.0f,1.0f);
	setNbIso(32);
}
示例#4
0
UtlBoolean 
UserLocationDB::hasLocation( const UtlString& identityString ) const
{
   ResultSet resultSet;
   getLocations( identityString, resultSet );
   return ( resultSet.getSize() > 0 );
}
示例#5
0
unsigned int ShaderPhong::setAttributeColor(VBO* vbo)
{
    m_vboColor = vbo;
    if (!m_with_color)
    {
        m_with_color=true;
        // set the define and recompile shader
        std::string gl3vert(GLSLShader::defines_gl());
        gl3vert.append("#define WITH_COLOR 1\n");
        gl3vert.append(vertexShaderText);
        std::string gl3frag(GLSLShader::defines_gl());
        gl3frag.append("#define WITH_COLOR 1\n");
        gl3frag.append(fragmentShaderText);
        loadShadersFromMemory(gl3vert.c_str(), gl3frag.c_str());

        // and treat uniforms
        getLocations();
        sendParams();
    }
    // bind th VA with WBO
    bind();
    unsigned int id = bindVA_VBO("VertexColor", vbo);
    unbind();
    return id;
}
示例#6
0
void ShaderColorDarts::restoreUniformsAttribs()
{
	getLocations();
	sendParams();

	bind();
	bindVA_VBO("VertexPosition", m_vboPos);
	unbind();
}
示例#7
0
void ShaderScalarField::restoreUniformsAttribs()
{
	getLocations();
	sendParams();

	bind();
	bindVA_VBO("VertexPosition", m_vboPos);
	bindVA_VBO("VertexScalar", m_vboScal);
	unbind();
}
示例#8
0
void ShaderSimpleFlat::restoreUniformsAttribs()
{
	getLocations();
	sendParams();

	bind();
	bindVA_VBO("VertexPosition", m_vboPos);
	if (m_vboColor)
		bindVA_VBO("VertexColor", m_vboColor);

	unbind();
}
示例#9
0
void ShaderPhong::restoreUniformsAttribs()
{
    getLocations();
    sendParams();

    bind();
    bindVA_VBO("VertexPosition", m_vboPos);
    bindVA_VBO("VertexNormal", m_vboNormal);
    if (m_vboColor)
        bindVA_VBO("VertexColor", m_vboColor);

    unbind();
}
示例#10
0
GameLogic::GameLogic(double x, double y, double size)
:   GameGrid(x, y, size),
mActive(true),
mCurrentPlayer(0)
{
    std::vector<Square *> locations = getLocations();
    GameBoard *board;
    for (auto itr : locations) {
        board = new GameBoard(*itr);
        board->adjust(1, 1, -2);
        mBoards.push_back(board);
        delete itr;
    }
}
示例#11
0
ShaderPhong::ShaderPhong(bool withClipping, bool withEyePosition) :
    m_with_color(false),
    m_with_eyepos(withEyePosition),
    m_doubleSided(1),
    m_ambiant(Geom::Vec4f(0.05f,0.05f,0.1f,0.0f)),
    m_diffuse(Geom::Vec4f(0.1f,1.0f,0.1f,0.0f)),
    m_specular(Geom::Vec4f(1.0f,1.0f,1.0f,0.0f)),
    m_shininess(100.0f),
    m_lightPos(Geom::Vec3f(10.0f,10.0f,1000.0f)),
    m_backColor(0.0f,0.0f,0.0f,0.0f),
    m_vboPos(NULL),
    m_vboNormal(NULL),
    m_vboColor(NULL),
    m_planeClip(Geom::Vec4f(0.0f,0.0f,0.0f,0.0f))
{
    std::string glxvert(GLSLShader::defines_gl());
    std::string glxfrag(GLSLShader::defines_gl());

    if (withClipping)
    {
        m_nameVS = "ShaderPhongClip_vs";
        m_nameFS = "ShaderPhongClip_fs";
        if (m_with_eyepos)
            glxvert.append("#define WITH_EYEPOSITION");
        glxvert.append(vertexShaderClipText);
        // Use double sided lighting if set
        //if (doubleSided)
        //	glxfrag.append("#define DOUBLE_SIDED\n");
        glxfrag.append(fragmentShaderClipText);
    }
    else
    {
        m_nameVS = "ShaderPhong_vs";
        m_nameFS = "ShaderPhong_fs";
        if (m_with_eyepos)
            glxvert.append("#define WITH_EYEPOSITION");
        glxvert.append(vertexShaderText);
        // Use double sided lighting if set
        //if (doubleSided)
        //	glxfrag.append("#define DOUBLE_SIDED\n");
        glxfrag.append(fragmentShaderText);
    }

    loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str());

    // and get and fill uniforms
    getLocations();
    sendParams();
}
示例#12
0
void EditLocationDialog::getLocations(QWidget *parent, const QString &loc, QStringList *out)
{
	out->clear();
	PlaylistFile playlist;
	if (playlist.parse(loc)) {
		auto const *locations = playlist.locations();
		if (!locations->empty()) {
			getLocations(parent, locations, out);
		} else {
			QMessageBox::warning(parent, qApp->applicationName(), tr("The playlist does not contain a valid item."));
		}
	} else {
		out->push_back(loc);
	}
}
示例#13
0
ShaderScalarField::ShaderScalarField() :
	m_minValue(0.0f),
	m_maxValue(0.0f),
	m_expansion(0)
{
	std::string glxvert(*GLSLShader::DEFINES_GL);
	glxvert.append(vertexShaderText);

	std::string glxfrag(*GLSLShader::DEFINES_GL);
	glxfrag.append(fragmentShaderText);

	loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str());

	// get and fill uniforms
	getLocations();
	sendParams();
}
示例#14
0
void ShaderPhong::unsetAttributeColor()
{
    m_vboColor = NULL;
    if (m_with_color)
    {
        m_with_color = false;
        // unbind the VA
        bind();
        unbindVA("VertexColor");
        unbind();
        // recompile shader
        std::string gl3vert(GLSLShader::defines_gl());
        gl3vert.append(vertexShaderText);
        std::string gl3frag(GLSLShader::defines_gl());
        gl3frag.append(fragmentShaderText);
        loadShadersFromMemory(gl3vert.c_str(), gl3frag.c_str());
        // and treat uniforms
        getLocations();
        sendParams();
    }
}
示例#15
0
void EditLocationDialog::accept()
{
	QString loc = location();
	if (loc.startsWith("http://")) {
		QStringList list = loc.split(' ', QString::SkipEmptyParts);
		if (list.size() == 1) {
			loc = list[0];
			getLocations(this, loc, &list);
			bool ret = false;
			QString newtext;
			if (list.isEmpty()) {
				newtext = loc; // revert to old text
				ret = true;
			} else if (list.size() == 1) {
				if (list[0] == loc) {
					// nop (normally return)
				} else {
					newtext = list[0];
					ret = true;
				}
			} else if (list.size() > 1) {
				for (QString const &loc : list) {
					if (newtext.isEmpty()) {
						newtext + ' ';
					}
					newtext += loc;
				}
				ret = true;
			}
			if (ret) {
				ui->lineEdit->setText(newtext);
				return;
			}
		}
	}
	QDialog::accept();
}
示例#16
0
ShaderExplodeVolumesAlpha::ShaderExplodeVolumesAlpha(bool withColorPerFace):
m_wcpf(withColorPerFace)
{
	m_nameVS = "ShaderExplodeVolumes_vs";
	m_nameFS = "ShaderExplodeVolumes_fs";
	m_nameGS = "ShaderExplodeVolumes_gs";

	std::string glxvert(*GLSLShader::DEFINES_GL);
	glxvert.append(vertexShaderText);

	std::string glxgeom;
	glxgeom.append(GLSLShader::defines_Geom("lines_witw_adjacency", "triangle_strip", 3));

	if (withColorPerFace)
		glxgeom.append("#define WITH_COLORPF 1\n");
	glxgeom.append(geometryShaderText);

	std::string glxfrag(*GLSLShader::DEFINES_GL);
	glxfrag.append(fragmentShaderText);

	loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str(), glxgeom.c_str(), GL_LINES_ADJACENCY_EXT , GL_TRIANGLE_STRIP,4);

	getLocations();

	//Default values
	m_ambient = Geom::Vec4f(0.05f, 0.05f, 0.1f, 0.0f);
	m_backColor = Geom::Vec4f(1.0f, 0.1f, 0.1f, 0.0f);
	m_light_pos = Geom::Vec3f(10.0f, 10.0f, 1000.0f);
	m_plane   = Geom::Vec4f(0.0f, 0.0f, 1000.f, 1000000000000000000000000000.0f);
	m_depthPeeling = 0;

	setAmbient(m_ambient);
	setBackColor(m_backColor);
	setLightPosition(m_light_pos);
	setClippingPlane(m_plane);
	setDepthPeeling(m_depthPeeling);
}
ShaderExplodeSmoothVolumes::ShaderExplodeSmoothVolumes(bool withColorPerFace, bool withExplodeFace):
	m_wcpf(withColorPerFace),
	m_wef(withExplodeFace)
{
	m_nameVS = "ShaderExplodeSmoothVolumes_vs";
	m_nameFS = "ShaderExplodeSmoothVolumes_fs";
	m_nameGS = "ShaderExplodeSmoothVolumes_gs";

	std::string glxvert(GLSLShader::defines_gl());
	glxvert.append(vertexShaderText);

	std::string glxgeom;
	glxgeom.append(GLSLShader::defines_Geom("lines_adjacency", "triangle_strip", 3));

	if (withColorPerFace)
		glxgeom.append("#define WITH_COLORPF 1\n");
	if (withExplodeFace)
		glxgeom.append("#define WITH_EXPLODE_FACE 1\n");
	glxgeom.append(geometryShaderText);

	std::string glxfrag(GLSLShader::defines_gl());
	glxfrag.append(fragmentShaderText);

	loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str(), glxgeom.c_str(), GL_LINES_ADJACENCY_EXT , GL_TRIANGLE_STRIP,4);

	getLocations();

	//Default values
	m_explodeV = 0.9f;
	m_explodeF = 0.9f;
	m_ambiant = Geom::Vec4f(0.05f, 0.05f, 0.1f, 0.0f);
	m_light_pos = Geom::Vec3f(10.0f, 10.0f, 1000.0f);
	m_plane   = Geom::Vec4f(0.0f, 0.0f, 1000.f, 1000000000000000000000000000.0f);

	setParams(m_explodeV, m_explodeF, m_ambiant, m_light_pos, m_plane);
}
示例#18
0
ShaderColorDarts::ShaderColorDarts() :
	m_lineWidth(0.01f),
	m_opacity(1.0f),
	m_planeClip(0.0f,0.0f,0.0f,0.0f)
{
	m_nameVS = "ShaderColorDarts_vs";
	m_nameFS = "ShaderColorDarts_fs";
	m_nameGS = "ShaderColorDarts_gs";

	std::string glxvert(GLSLShader::defines_gl());
	glxvert.append(vertexShaderText);

	std::string glxgeom = GLSLShader::defines_Geom("lines", "triangle_strip", 8);
	glxgeom.append(geometryShaderText);

	std::string glxfrag(GLSLShader::defines_gl());
	glxfrag.append(fragmentShaderText);

	loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str(), glxgeom.c_str(), GL_LINES, GL_TRIANGLE_STRIP,8);

	// get and fill uniforms
	getLocations();
	sendParams();
}
示例#19
0
ShaderSimpleFlat::ShaderSimpleFlat(bool withClipping, bool doubleSided):
	m_with_color(false),
	m_doubleSided(doubleSided),
	m_ambiant(Geom::Vec4f(0.05f,0.05f,0.1f,0.0f)),
	m_diffuse(Geom::Vec4f(0.1f,1.0f,0.1f,0.0f)),
	m_lightPos(Geom::Vec3f(10.0f,10.0f,1000.0f)),
	m_backColor(0.0f,0.0f,0.0f,0.0f),
	m_vboPos(NULL),
	m_vboColor(NULL),
	m_planeClip(Geom::Vec4f(0.0f,0.0f,0.0f,0.0f))
{
	std::string glxvert(GLSLShader::defines_gl());
	std::string glxfrag(GLSLShader::defines_gl());

	if (withClipping)
	{
		m_nameVS = "ShaderSimpleFlatClip_vs";
		m_nameFS = "ShaderSimpleFlatClip_fs";
		glxvert.append(vertexShaderClipText);
		glxfrag.append(fragmentShaderClipText);
	}
	else
	{
		m_nameVS = "ShaderSimpleFlat_vs";
		m_nameFS = "ShaderSimpleFlat_fs";
		// get choose GL defines (2 or 3)
		// ans compile shaders
		glxvert.append(vertexShaderText);
		glxfrag.append(fragmentShaderText);
	}

	loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str());
	// and get and fill uniforms
	getLocations();
	sendParams();
}
示例#20
0
void
prompt_and_wait() {

	// Main Menu
	#define ITEM_APPLY_SDCARD        0
	#define ITEM_NANDROID_MENU     	 1
	#define ITEM_MAIN_WIPE_MENU      2
	#define ITEM_ADVANCED_MENU       3
	#define ITEM_MOUNT_MENU       	 4
	#define ITEM_USB_TOGGLE          5
	#define ITEM_REBOOT              6
	#define ITEM_SHUTDOWN		7


    finish_recovery(NULL);
    ui_reset_progress();

    // buying a split second for mmc driver to load to avoid error on some devices
    getLocations();
    tw_set_defaults();
    read_s_file();
    
	char** headers = prepend_title((const char**)MENU_HEADERS);
    char* MENU_ITEMS[] = {  "Install Zip",
                            "Nandroid Menu",
                            "Wipe Menu",
                            "Advanced Menu",
                            "Mount Menu",
                            "USB Storage Toggle",
                            "Reboot system now",
                            "Power down system",
                            NULL };
	
    for (;;) {

        go_home = 0;
        go_menu = 0;
        menu_loc_idx = 0;
		ui_reset_progress();
    	
        int chosen_item = get_menu_selection(headers, MENU_ITEMS, 0, 0);

        // device-specific code may take some action here.  It may
        // return one of the core actions handled in the switch
        // statement below.
        chosen_item = device_perform_action(chosen_item);

        // delay reading settings during boot due to timings issues with sdcard not being available
        // read settings file once and only once after the user makes a menu selection
        if (need_to_read_settings_file) {
        	need_to_read_settings_file = 0;
        }
        
        switch (chosen_item) {
            case ITEM_APPLY_SDCARD:
                install_zip_menu(0);
                break;

            case ITEM_NANDROID_MENU:
            	nandroid_menu();
            	break;
            	
            case ITEM_MAIN_WIPE_MENU:
                main_wipe_menu();
                break;

            case ITEM_ADVANCED_MENU:
            	advanced_menu();
                break;

            case ITEM_MOUNT_MENU:
            	mount_menu(0);
                break;
                
            case ITEM_USB_TOGGLE:
            	usb_storage_toggle();
                break;

            case ITEM_REBOOT:
                return;

	    case ITEM_SHUTDOWN:
	        __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_POWER_OFF, NULL);
		break;
        }
        if (go_menu) {
        	advanced_menu();
        }
    }
}
示例#21
0
文件: RdaNetcdf.cpp 项目: WFRT/Comps
float InputRdaNetcdf::getValueCore(const Key::Input& iKey) const {
   float returnValue = Global::MV;

   std::string filename = getFilename(iKey);
   NcFile ncfile(filename.c_str());

   std::string localVariable;
   bool found = getLocalVariableName(iKey.variable, localVariable);
   assert(found);
   Key::Input key = iKey;

   // Pre-fill incase file does not contain some keys
   std::vector<float>    offsets = getOffsets();
   const std::vector<Location>& locations = getLocations();
   for(int o = 0; o < offsets.size(); o++) {
      key.offset = offsets[o];
      for(key.location = 0; key.location < locations.size(); key.location++) {
         if((mCacheOtherOffsets || iKey.offset == key.offset) ||
               (mCacheOtherLocations || iKey.location == key.location)) {
            Input::addToCache(key, Global::MV);
         }
      }
   }

   if(ncfile.is_valid() && localVariable != "") {
      // Record data
      NcVar* ncvar          = ncfile.get_var(localVariable.c_str());
      NcVar* ncTimes        = ncfile.get_var("time_observation");
      NcVar* ncStationIds   = ncfile.get_var("parent_index");
      NcDim* ncNamesDim     = ncfile.get_dim("id_len");
      NcDim* ncRecordsDim   = ncfile.get_dim("recNum");
      long   numRecords = ncRecordsDim->size();
      float  values[numRecords];
      float  stationIds[numRecords];
      int    times[numRecords];

      long count[1] = {numRecords};
      ncvar->get(values, count);
      ncTimes->get(times, count);
      ncStationIds->get(stationIds, count);

      // Station data
      NcVar* ncNames        = ncfile.get_var("station_id");
      NcDim* ncLocationDim  = ncfile.get_dim("station");
      long   numCurrLocations = ncLocationDim->size();
      long   namesLength      = ncNamesDim->size();
      char   names[numCurrLocations*namesLength];

      long count2[2] = {numCurrLocations, namesLength};
      ncNames->get(names, count2);

      ncfile.close();
      // Set all values to missing
      std::vector<float> vec;
      vec.resize(locations.size()*offsets.size(), Global::MV);

      // Read data
      for(int i = 0; i < numRecords; i++) {
         int id = stationIds[i];
         int namesIndex = id*namesLength;
         std::string name = std::string(&names[namesIndex], namesLength);
         std::map<std::string,int>::const_iterator it = mLocationNames.find(name);
         if(it != mLocationNames.end()) {
            key.location = it->second;
            key.member = 0;
            int time = times[i];

            int year  = Global::getYear(key.date);
            int month = Global::getMonth(key.date);
            int day   = Global::getDay(key.date);
            boost::gregorian::date epochDate(1970, 1, 1);
            boost::gregorian::date currDate(year, month, day);
            boost::gregorian::date_period diff(epochDate, currDate);
            int daysSinceEpoch = diff.length().days();

            int offsetIndex = round((float) (time - 86400*daysSinceEpoch)/3600);
            int secondsOffHour = (time - 86400*daysSinceEpoch) % 3600;
            if(secondsOffHour < 0) 
               secondsOffHour = 3600 + secondsOffHour;
            if(secondsOffHour > 1800) {
               secondsOffHour = 3600 - secondsOffHour;
            }
            assert(offsetIndex >= 0);
            if(secondsOffHour < mTimeTolerance && offsetIndex < 24) {
               assert(key.location < locations.size());
               int ind = offsetIndex*locations.size() + key.location;
               assert(offsetIndex >= 0 && offsetIndex < offsets.size());
               key.offset = offsets[offsetIndex];
               assert(ind < (int) vec.size() && ind >= 0);
               //std::cout << key.location << " " << key.offset << std::endl;
               // Rda dataset uses a different missing value indicator
               if(values[i] == mMV)
                  values[i] = Global::MV;
               if((mCacheOtherOffsets || iKey.offset == key.offset) ||
                  (mCacheOtherLocations || iKey.location == key.location)) {
                  Input::addToCache(key, values[i]);
                  if(iKey == key) {
                     returnValue = values[i];
                  }
               }
            }
         }
      }
   }
   return returnValue;
}
示例#22
0
void MoralityServer::getCommand(int PlayerID, MoralThread *theThread, QByteArray packetcommand)
{
    qDebug() << "GETTING COMMAND FROM THE THREAD" <<endl;
    qDebug() << "COMMAND: " << packetcommand << endl;
    // RESPOND TO THE CLIENT REQUEST HERE!
    // Response to the client would be more difficult and would have to have repeating keys for which we can use regular expressions to split
    //    LOCATION::ID1-1,ID2-4,ID3-19 // {socket descriptor that your computer would turn into player 0, 1, 2, ... n players
    //    WINNING ::ID                 // Which socket descriptor won
    //    SCORE   ::ID1-900,ID2-100000 // etc.
    QString incomingcommand(packetcommand);
    if (!incomingcommand.contains("//") || !incomingcommand.contains("::"))
        return; // DONT DO ANYTHING WITH EMPTY LINES
    QStringList BytesCommand = incomingcommand.split("//",QString::SkipEmptyParts);
    qint16 bytesize(BytesCommand[0].toInt());
    //    if (BytesCommand[1].size() != bytesize)  // no it's not really bytes
    //        qDebug() << "incorrect packet size!"; // but do nothing... really how big are our packets? 20 bytes?
    QStringList CKeyVal = BytesCommand[1].split("::");
    QString commandString;
    if (CKeyVal[0] == "LOCATION")
    {
        commandString="LOCATION::";
        qDebug() << CKeyVal[1] << endl;
        int newlocation = CKeyVal[1].toInt();
        qDebug() << newlocation << endl;
        moveToLocation(PlayerID, newlocation);
        commandString.append(getLocations());
    }
    else if (CKeyVal[0] == "WINNING")
    {
        commandString="WINNING::";
        commandString.append(QString::number(PlayerID)); // just broadcast this to all players
    }
    else if (CKeyVal[0] == "SCORE")
    {
        // After winning is received on the server, clients will send a SCORE VALUE...
        // when received from all clients, will emit back in unison

        //        commandString="SCORE::";
        //        commandString.append() NOT SURE ABOUT THIS YET SCORE OR ALIGNMENT
        //        IT COULD BE DISPLAYED SOMEHOW
    }
    else if (CKeyVal[0] == "DAMAGE")
    {
        emit sendCommand(packetcommand); // the same one that came from the client since already in the right format
        return;
    }
    else if (incomingcommand.contains("SOCKETID"))
    {
        commandString="SOCKETID::";
        commandString.append(QString::number(theThread->getSocketDescriptor()));
        QString command;
        command = QString::number(commandString.size()); // packet size
        command.append(tr("//"));
        command.append(commandString);
        QByteArray newPacketCommand;
        newPacketCommand.append(command);
        for (int i =0; i < Morals.size(); i++)
        {
            if (Morals[i]->getSocketDescriptor() == theThread->getSocketDescriptor())
            {
                Morals[i]->commandToSocket(newPacketCommand);
                return;
            }
        }
    }
    else
    {
        return;
    }
    QString command;
    command = QString::number(commandString.size()); // packet size
    command.append(tr("//"));
    command.append(commandString);
    QByteArray newPacketCommand;
    newPacketCommand.append(command);
    for (int i =0; i < Morals.size(); i++)
    {
        Morals[i]->commandToSocket(newPacketCommand);
    }
    qDebug() << "THE PACKET: " << newPacketCommand <<endl;
}
示例#23
0
void analyzeContinuously(HumdrumFile& infile, int windowsize,
      double stepsize, double* majorKey, double* minorKey) {

   Array<Array<double> > segments;
   infile.analyzeRhythm("4");
   int segmentCount = int(infile.getTotalDuration() / stepsize + 0.5);

   if (segmentCount < windowsize) {
      cout << "Not enough data for requested analysis" << endl;
      return;
   }

   segments.setSize(segmentCount);
   segments.allowGrowth(0);
   int i;
   for (i=0; i<segments.getSize(); i++) {
      segments[i].setSize(12);
      segments[i].allowGrowth(0);
      segments[i].setAll(0);
   }
	    
   loadHistograms(segments, infile, segmentCount);

   if (debugQ) {
      printHistogramTotals(segments);
   }

   Array<Array<double> > pitchhist; 
   Array<Array<double> > correlations;

   pitchhist.setSize(segmentCount-windowsize);
   correlations.setSize(segmentCount-windowsize);
   pitchhist.allowGrowth(0);
   correlations.allowGrowth(0);
   for (i=0; i<segmentCount-windowsize; i++) {
      pitchhist[i].setSize(13);  //last spot for best key
      pitchhist[i].allowGrowth(0);
      correlations[i].setSize(24);
      correlations[i].allowGrowth(0);
   }

   for (i=0; i<segmentCount - windowsize; i++) {
      createHistogram(pitchhist[i], i, windowsize, segments);
      identifyKeyDouble(pitchhist[i], correlations[i], majorKey, minorKey);
   }


   Array<double> measures;
   getLocations(measures, infile, segmentCount);

   cout << "**key\t**rval\t**conf\t**start\t**mid\t**end\n";
   for (i=0; i<pitchhist.getSize(); i++) {
      printBestKey(int(pitchhist[i][12] + 0.5));
      cout << "\t";
      printCorrelation(correlations[i][int(pitchhist[i][12]+ 0.1)], roundQ);
      cout << "\t";
      cout << getConfidence(correlations[i], int(pitchhist[i][12]+0.1));
      cout << "\t";
      cout << "=" << measures[i];
      cout << "\t";
      cout << "=" << int((measures[i] + measures[i+windowsize])/2+0.49);
      cout << "\t";
      cout << "=" << measures[i+windowsize];
      cout << endl;
   }
   cout << "*-\t*-\t*-\t*-\t*-\t*-\n";

}