示例#1
0
int main()
{
	std::string dir_name = "/tmp/1/1/1";
	native_dir dir(dir_name);
	assert(!dir.exist());
	assert(!dir.create_dir(false));
	assert(dir.create_dir(true));

	printf("press a key to continue the test of delete function.\n");
	getchar();
	native_dir dir2("/tmp/1");
	assert(!dir2.delete_dir(false));
	assert(dir2.delete_dir(true));

	dir_name = "1/1/1";
	native_dir dir3(dir_name);
	assert(!dir3.exist());
	assert(!dir3.create_dir(false));
	assert(dir3.create_dir(true));

	printf("press a key to continue the test of delete function.\n");
	getchar();
	native_dir dir4("1");
	assert(!dir4.delete_dir(false));
	assert(dir4.delete_dir(true));
}
示例#2
0
	void SpotLight::ApplyLight()
	{
		// Set spot light position and direction
		Float3 dir3(GetWorldMatrixPtr()->_31, GetWorldMatrixPtr()->_32, GetWorldMatrixPtr()->_33);
		dir3.normalize();

		XMFLOAT3 pos(&GetWorldMatrixPtr()->_41);

		cBufferData.spotLight.direction = XMFLOAT3(dir3.x, dir3.y, dir3.z);
		cBufferData.spotLight.position = pos;

		D3D11_MAPPED_SUBRESOURCE edit;
		Renderer::theContextPtr->Map(cBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &edit);
		memcpy(edit.pData, &cBufferData, sizeof(cBufferData));
		Renderer::theContextPtr->Unmap(cBuffer, 0);

		Renderer::theContextPtr->VSSetConstantBuffers(cBufferData.SPOT_LIGHT_REGISTER_SLOT, 1, &cBuffer.p);
		Renderer::theContextPtr->PSSetConstantBuffers(cBufferData.SPOT_LIGHT_REGISTER_SLOT, 1, &cBuffer.p);


		// Check if the camera is inside the lit area
		Float3 toCamera = ViewPortManager::GetReference().GetActiveViewPosition() 
			- *(Float3 *)&pos.x;
		toCamera.normalize();

		if(toCamera.dotProduct(dir3) > cBufferData.spotLight.cutoff)
			techniqueNameOverride = "RenderSpotLightInside";
		else
			techniqueNameOverride = "RenderSpotLightOutside";
		AddToContextSet();
	}
TEST( ResourceDependenciesGraph, removingDir )
{
   ResourceDependenciesGraph graph;

   FilePath file( "/directory1/a.res" );
   FilePath res1( "/directory2/b.tmat" );
   FilePath res2( "/directory3/c.tmat" );
   FilePath dir1( "/directory1" );
   FilePath dir2( "/directory2" );
   FilePath dir3( "/directory3" );
   graph.addDependency( file, res1 );
   graph.addDependency( file, res2 );

   CPPUNIT_ASSERT_EQUAL( ( uint ) 2, graph.getAffectedResources( file ).size() );

   graph.onDirRemoved( dir2 );
   CPPUNIT_ASSERT_EQUAL( ( uint ) 1, graph.getAffectedResources( file ).size() );
   CPPUNIT_ASSERT_EQUAL( res2.getRelativePath(), graph.getAffectedResources( file ).front().getRelativePath() );

   graph.onDirRemoved( dir3 );
   CPPUNIT_ASSERT_EQUAL( ( uint ) 0, graph.getAffectedResources( file ).size() );

   graph.addDependency( file, res1 );
   graph.addDependency( file, res2 );
   CPPUNIT_ASSERT_EQUAL( ( uint ) 2, graph.getAffectedResources( file ).size() );

   graph.onDirRemoved( dir1 );
   CPPUNIT_ASSERT_EQUAL( ( uint ) 0, graph.getAffectedResources( file ).size() );
}
bool IfcGeom::is_convex(const TopoDS_Wire& wire) {
	for ( TopExp_Explorer exp1(wire,TopAbs_VERTEX); exp1.More(); exp1.Next() ) {
		TopoDS_Vertex V1 = TopoDS::Vertex(exp1.Current());
		gp_Pnt P1 = BRep_Tool::Pnt(V1);
		// Store the neighboring points
		std::vector<gp_Pnt> neighbors;
		for ( TopExp_Explorer exp3(wire,TopAbs_EDGE); exp3.More(); exp3.Next() ) {
			TopoDS_Edge edge = TopoDS::Edge(exp3.Current());
			std::vector<gp_Pnt> edge_points;
			for ( TopExp_Explorer exp2(edge,TopAbs_VERTEX); exp2.More(); exp2.Next() ) {
				TopoDS_Vertex V2 = TopoDS::Vertex(exp2.Current());
				gp_Pnt P2 = BRep_Tool::Pnt(V2);
				edge_points.push_back(P2);
			}
			if ( edge_points.size() != 2 ) continue;
			if ( edge_points[0].IsEqual(P1,GetValue(GV_POINT_EQUALITY_TOLERANCE))) neighbors.push_back(edge_points[1]);
			else if ( edge_points[1].IsEqual(P1, GetValue(GV_POINT_EQUALITY_TOLERANCE))) neighbors.push_back(edge_points[0]);
		}
		// There should be two of these
		if ( neighbors.size() != 2 ) return false;
		// Now find the non neighboring points
		std::vector<gp_Pnt> non_neighbors;
		for ( TopExp_Explorer exp2(wire,TopAbs_VERTEX); exp2.More(); exp2.Next() ) {
			TopoDS_Vertex V2 = TopoDS::Vertex(exp2.Current());
			gp_Pnt P2 = BRep_Tool::Pnt(V2);
			if ( P1.IsEqual(P2,GetValue(GV_POINT_EQUALITY_TOLERANCE)) ) continue;
			bool found = false;
			for( std::vector<gp_Pnt>::const_iterator it = neighbors.begin(); it != neighbors.end(); ++ it ) {
				if ( (*it).IsEqual(P2,GetValue(GV_POINT_EQUALITY_TOLERANCE)) ) { found = true; break; }
			}
			if ( ! found ) non_neighbors.push_back(P2);
		}
		// Calculate the angle between the two edges of the vertex
		gp_Dir dir1(neighbors[0].XYZ() - P1.XYZ());
		gp_Dir dir2(neighbors[1].XYZ() - P1.XYZ());
		const double angle = acos(dir1.Dot(dir2)) + 0.0001;
		// Now for the non-neighbors see whether a greater angle can be found with one of the edges
		for ( std::vector<gp_Pnt>::const_iterator it = non_neighbors.begin(); it != non_neighbors.end(); ++ it ) {
			gp_Dir dir3((*it).XYZ() - P1.XYZ());
			const double angle2 = acos(dir3.Dot(dir1));
			const double angle3 = acos(dir3.Dot(dir2));
			if ( angle2 > angle || angle3 > angle ) return false;
		}
	}
	return true;
}
示例#5
0
void ViBenchMarker3::benchmark()
{
	QDir dir("/home/visore/Visore Projects/Files/");
	QStringList dirs = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
	for(int i = 0; i < dirs.size(); ++i)
	{
		QDir dir3("/home/visore/Visore Projects/Results/"+dirs[i]);
		if(!dir3.exists()) dir3.mkpath(dir3.absolutePath());

		QDir dir2(dir.absoluteFilePath(dirs[i]));
		QStringList files2 = dir2.entryList(QDir::Files);
		for(int j = 0; j < files2.size(); ++j)
		{
			mFiles.enqueue(dir2.absoluteFilePath(files2[j]));
			mResults.enqueue(dir3.absoluteFilePath(files2[j])+".txt");
		}
	}
	mTotalFiles = mFiles.size();
	nextFile();
}
    void TestQueueRemovesAndCreatesDirectories() throw (Exception)
    {
        FileFinder checkpoints("checkpoints2", RelativeTo::ChasteTestOutput);
        // Remove directory in case it was there from previous executions.
        PetscTools::Barrier("TestQueueRemovesAndCreatesDirectories-0");
        if (PetscTools::AmMaster())
        {
            ABORT_IF_THROWS(checkpoints.Remove());
        }
        PetscTools::Barrier("TestQueueRemovesAndCreatesDirectories-1");
        TS_ASSERT(!checkpoints.Exists());
        PetscTools::Barrier("TestQueueRemovesAndCreatesDirectories-2");

        OutputDirectoryFifoQueue fifo_queue("checkpoints2", 2);
        TS_ASSERT(checkpoints.IsDir());

        fifo_queue.CreateNextDir("0.1");
        FileFinder dir1("0.1", checkpoints);
        TS_ASSERT(dir1.IsDir());

        fifo_queue.CreateNextDir("0.2");
        FileFinder dir2("0.2", checkpoints);
        TS_ASSERT(dir2.IsDir());
        TS_ASSERT(dir1.IsDir());

        PetscTools::Barrier("TestQueueRemovesAndCreatesDirectories-3");
        fifo_queue.CreateNextDir("0.3");
        FileFinder dir3("0.3", checkpoints);
        TS_ASSERT(dir3.IsDir());
        TS_ASSERT(dir2.IsDir());
        TS_ASSERT(!dir1.Exists());

        PetscTools::Barrier("TestQueueRemovesAndCreatesDirectories-4");
        fifo_queue.CreateNextDir("0.4");
        FileFinder dir4("0.4", checkpoints);
        TS_ASSERT(dir4.IsDir());
        TS_ASSERT(dir3.IsDir());
        TS_ASSERT(!dir2.Exists());
        TS_ASSERT(!dir1.Exists());
    }
示例#7
0
文件: single.C 项目: sonia3994/WbLS
void compare_wls1(TString filename="../p15m_nwls/wcsim.root",TString histoname="p15m_nwls", Int_t *flag, TString rootfile = "temp.root") {

    TFile *file1;
    if (*flag!=0) {
        //file1 = new TFile(rootfile,"Update");
        file1 = new TFile(rootfile,"RECREATE");
    } else {
        file1 = new TFile(rootfile,"RECREATE");
    }
    TString filename1;
    filename1 = histoname + "_digi";
    TTree *T = new TTree(filename1,filename1);
    T->SetDirectory(file1);
    Double_t diginpe,digitime,cor_digitime,digitheta,dis_digihit;
    Int_t neve;

    Double_t mom;
    Double_t pos_x,pos_y,pos_z;
    Double_t dir_x,dir_y,dir_z;
    Double_t tube_x,tube_y,tube_z;
    Double_t totankdis;
    Double_t vertex[3],dir[3];

    Double_t tube_pos[3];

    T->Branch("digi_eve",&neve,"data/I");
    T->Branch("diginpe",&diginpe,"data/D");
    T->Branch("digitime",&digitime,"data/D");
    T->Branch("cor_digitime",&cor_digitime,"data/D");
    T->Branch("digitheta",&digitheta,"data/D");
    T->Branch("dis_dighit",&dis_digihit,"data/D");

    T->Branch("mom",&mom,"data/D");
    T->Branch("totankdis",&totankdis,"data/D");
    T->Branch("pos_x",&vertex[0],"data/D");
    T->Branch("pos_y",&vertex[1],"data/D");
    T->Branch("pos_z",&vertex[2],"data/D");

    T->Branch("dir_x",&dir[0],"data/D");
    T->Branch("dir_y",&dir[1],"data/D");
    T->Branch("dir_z",&dir[2],"data/D");

    T->Branch("tube_x",&tube_pos[0],"data/D");
    T->Branch("tube_y",&tube_pos[1],"data/D");
    T->Branch("tube_z",&tube_pos[2],"data/D");

    filename1 = histoname + "_hit";
    TTree *t1 = new TTree(filename1,filename1);
    t1->SetDirectory(file1);

    Double_t wavelength, truetime, corr_time,theta,distance,index;
    Int_t qe_flag,parentid,tubeid,totalpe;

    Int_t ntracks;

    t1->Branch("ntracks",&ntracks,"data/I");
    t1->Branch("neve",&neve,"data/I");
    t1->Branch("wavelength",&wavelength,"data/D");
    t1->Branch("truetime",&truetime,"data/D");
    t1->Branch("corr_time",&corr_time,"data/D");
    t1->Branch("theta",&theta,"data/D");
    t1->Branch("distance",&distance,"data/D");
    t1->Branch("index",&index,"data/D");

    t1->Branch("mom",&mom,"data/D");
    t1->Branch("totankdis",&totankdis,"data/D");
    t1->Branch("pos_x",&vertex[0],"data/D");
    t1->Branch("pos_y",&vertex[1],"data/D");
    t1->Branch("pos_z",&vertex[2],"data/D");

    t1->Branch("dir_x",&dir[0],"data/D");
    t1->Branch("dir_y",&dir[1],"data/D");
    t1->Branch("dir_z",&dir[2],"data/D");

    t1->Branch("tube_x",&tube_pos[0],"data/D");
    t1->Branch("tube_y",&tube_pos[1],"data/D");
    t1->Branch("tube_z",&tube_pos[2],"data/D");

    // t1->Branch("pos_x",&pos_x,"data/D");
//   t1->Branch("pos_y",&pos_y,"data/D");
//   t1->Branch("pos_z",&pos_z,"data/D");

//   t1->Branch("dir_x",&dir_x,"data/D");
//   t1->Branch("dir_y",&dir_y,"data/D");
//   t1->Branch("dir_z",&dir_z,"data/D");

//   t1->Branch("tube_x",&tube_x,"data/D");
//   t1->Branch("tube_y",&tube_y,"data/D");
//   t1->Branch("tube_z",&tube_z,"data/D");

    t1->Branch("qe_flag",&qe_flag,"data/I");
    t1->Branch("parentid",&parentid,"data/I");
    t1->Branch("tubeid",&tubeid,"data/I");
    t1->Branch("totalpe",&totalpe,"data/I");


    TFile *file = new TFile(filename);
    TTree  *wcsimT = file->Get("wcsimT");
    WCSimRootEvent *wcsimrootsuperevent = new WCSimRootEvent();
    wcsimT->SetBranchAddress("wcsimrootevent",&wcsimrootsuperevent);
    wcsimT->GetBranch("wcsimrootevent")->SetAutoDelete(kTRUE);



    TTree *gtree = file->Get("wcsimGeoT");
    WCSimRootGeom *wcsimrootgeom = new WCSimRootGeom();
    gbranch = gtree->GetBranch("wcsimrootgeom");
    gbranch->SetAddress(&wcsimrootgeom);
    gtree->GetEntry(0);

    WCSimRootPMT *pmt;

    Double_t pmt_pos[500000][3];

    for (Int_t i=0; i!=wcsimrootgeom->GetWCNumPMT(); i++) {
        pmt_pos[i][0] = (wcsimrootgeom->GetPMT(i)).GetPosition(0);
        pmt_pos[i][1] = (wcsimrootgeom->GetPMT(i)).GetPosition(1);
        pmt_pos[i][2] = (wcsimrootgeom->GetPMT(i)).GetPosition(2);
    }

    //in terms of wavelength (total NPE) real hit
    filename1 = histoname + "_total_wl";
    TH1F *hqx = new TH1F(filename1,filename1,600,200,800);

    //NPE in each event sum over digi hit
    filename1 = histoname + "_total_npe";
    TH1F *hqx2 = new TH1F(filename1,filename1,1000,0.,10000);

    //digitized hit time
    filename1 = histoname + "_digitime";
    TH1F *hqx1 = new TH1F(filename1,filename1,500,900,1400);

    //corrected digitized hit time
    filename1 = histoname + "_cor_digitime";
    TH1F *hqx4 = new TH1F(filename1,filename1,1000,400,1400);

    //digitized hit angle
    filename1 = histoname + "_digitheta";
    TH1F *hqx5 = new TH1F(filename1,filename1,180,0,180);



    //TH2F *h1 = new TH2F("h1","h1",100,1000,20000,100,90000,140000);

    Double_t index = 1.333;



    neve = *flag;

    cout << histoname << "\t" << wcsimT->GetEntries() << endl;
    for (Int_t j=0; j!=wcsimT->GetEntries(); j++) {
        //for (Int_t j=0;j!=90;j++){
        // cout << j << endl;
        wcsimT->GetEvent(j);
        neve ++;

        WCSimRootTrigger *wcsimrootevent = wcsimrootsuperevent->GetTrigger(0);
        temp = (TClonesArray*)wcsimrootevent->GetTracks();

        Int_t ntrack =  wcsimrootevent->GetNtrack();
        //cout << ntrack << endl;
        ntracks = ntrack;

        mom = ((WCSimRootTrack*)temp->At(ntrack-1))->GetP();
        //get the vertex information
        vertex[0] = ((WCSimRootTrack*)temp->At(ntrack-1))->GetStart(0);
        vertex[1] = ((WCSimRootTrack*)temp->At(ntrack-1))->GetStart(1);
        vertex[2] = ((WCSimRootTrack*)temp->At(ntrack-1))->GetStart(2);

        //get position information
        dir[0] = ((WCSimRootTrack*)temp->At(ntrack-1))->GetDir(0);
        dir[1] = ((WCSimRootTrack*)temp->At(ntrack-1))->GetDir(1);
        dir[2] = ((WCSimRootTrack*)temp->At(ntrack-1))->GetDir(2);

        totankdis=ToTankDistance(vertex,dir);

        TVector3 vertex3(vertex[0],vertex[1],vertex[2]);
        TVector3 dir3(dir[0],dir[1],dir[2]);


        //loop through digi hit
        int max = wcsimrootevent->GetNcherenkovdigihits();

        double sum = 0;

        for (int i=0; i<max; i++) {
            // cout << max << "\t" << i << endl;
            WCSimRootCherenkovDigiHit *cDigiHit = ((WCSimRootCherenkovDigiHit*)wcsimrootevent->GetCherenkovDigiHits()->At(i));
            hqx1->Fill(cDigiHit->GetT());
            tube_pos[0] =  pmt_pos[(cDigiHit->GetTubeId()-1)][0];
            tube_pos[1] =  pmt_pos[(cDigiHit->GetTubeId()-1)][1];
            tube_pos[2] =  pmt_pos[(cDigiHit->GetTubeId()-1)][2];

            TVector3 hit3(tube_pos[0],tube_pos[1],tube_pos[2]);
            TVector3 dis = hit3-vertex3;

            diginpe = cDigiHit->GetQ();
            digitime = cDigiHit->GetT();
            cor_digitime = digitime-dis.Mag()/299792458.*1.333*1.e7;
            digitheta = dis.Angle(dir3)/3.1415926*180.;
            dis_digihit = dis.Mag();


            hqx4->Fill(cor_digitime,diginpe);
            hqx5->Fill(digitheta,diginpe);
            sum += diginpe;

            T->Fill();
        }
        hqx2->Fill(sum);


        //loop through real hit



        //loop through PMT hit first
        max = wcsimrootevent-> GetNcherenkovhits();
        //cout << max << endl;
        if (max ==0) {
            t1->Fill();
        }
        for (int i=0; i<max; i++) {
            WCSimRootCherenkovHit* wcsimrootcherenkovhit =
                dynamic_cast<WCSimRootCherenkovHit*>((wcsimrootevent->GetCherenkovHits())->At(i));

            totalpe = wcsimrootcherenkovhit->GetTotalPe(1);
            tubeid = wcsimrootcherenkovhit->GetTubeID() ;

            //loop through hit time etc
            for (int k=0; k<totalpe; k++) {
                TObject *element2 = (wcsimrootevent->GetCherenkovHitTimes())->
                                    At(wcsimrootcherenkovhit->GetTotalPe(0)+k);
                WCSimRootCherenkovHitTime *wcsimrootcherenkovhittime
                    = dynamic_cast<WCSimRootCherenkovHitTime*>(element2);

                wavelength =wcsimrootcherenkovhittime->GetWavelength();
                qe_flag = wcsimrootcherenkovhittime->GetQe_flag();
                truetime = wcsimrootcherenkovhittime->GetTruetime();
                parentid = wcsimrootcherenkovhittime->GetParentID();

                pos_x = wcsimrootcherenkovhittime->GetPosX() ;
                pos_y = wcsimrootcherenkovhittime->GetPosY() ;
                pos_z = wcsimrootcherenkovhittime->GetPosZ() ;
                dir_x = wcsimrootcherenkovhittime->GetDirX() ;
                dir_y = wcsimrootcherenkovhittime->GetDirY() ;
                dir_z = wcsimrootcherenkovhittime->GetDirZ() ;

                tube_pos[0] =  pmt_pos[tubeid-1][0];
                tube_pos[1] =  pmt_pos[tubeid-1][1];
                tube_pos[2] =  pmt_pos[tubeid-1][2];

                tube_x = tube_pos[0];
                tube_y = tube_pos[1];
                tube_z = tube_pos[2];



                TVector3 hit3(tube_pos[0],tube_pos[1],tube_pos[2]);
                TVector3 dis = hit3-vertex3;

                distance = dis.Mag();
                theta = dis.Angle(dir3)/3.1415926*180.;
                //index = index(wavelength);
                index = 1.34;
                corr_time = truetime - distance/299792458.*1e7*index;

                if (qe_flag==1) {
                    hqx->Fill(wavelength);
                }

                t1->Fill();
            }
        }



    }

    if (flag==1) {
        hqx->SetDirectory(file1);
        hqx2->SetDirectory(file1);
        hqx1->SetDirectory(file1);
        hqx4->SetDirectory(file1);
        hqx5->SetDirectory(file1);
        file1->Write();
        file1->Close();
    } else {
        hqx->SetDirectory(file1);
        hqx2->SetDirectory(file1);
        hqx1->SetDirectory(file1);
        hqx4->SetDirectory(file1);
        hqx5->SetDirectory(file1);
        file1->Write();
        file1->Close();
    }

    *flag = neve;

}
示例#8
0
void TsDataAccessorFile::testGetFoldersList()
{
  // Valid folders
  QTemporaryDir dir(QDir::tempPath() + QString::fromStdString("/2016"));

  QTemporaryDir subdir1(dir.path() + QString::fromStdString("/10"));
  QTemporaryDir subdir2(dir.path() + QString::fromStdString("/11"));
  QTemporaryDir subdir3(dir.path() + QString::fromStdString("/12"));

  QTemporaryDir subdir4(subdir1.path() + QString::fromStdString("/03"));
  QTemporaryDir subdir5(subdir3.path() + QString::fromStdString("/11"));

  QTemporaryDir subdir6(subdir4.path() + QString::fromStdString("/final"));
  QTemporaryDir subdir7(subdir4.path() + QString::fromStdString("/final"));

  QTemporaryDir subdir8(subdir5.path() + QString::fromStdString("/final"));

  // Invalid folders

  QTemporaryDir dir2(QDir::tempPath() + QString::fromStdString("/2016"));

  QTemporaryDir subdir9(dir2.path() + QString::fromStdString("/03"));
  QTemporaryDir subdir10(subdir9.path() + QString::fromStdString("/aa"));

  QTemporaryDir dir3(QDir::tempPath() + QString::fromStdString("/2020"));
  QTemporaryDir dir4(QDir::tempPath() + QString::fromStdString("/folder"));

  terrama2::core::DataProvider* dataProvider = new terrama2::core::DataProvider();
  terrama2::core::DataProviderPtr dataProviderPtr(dataProvider);

  terrama2::core::DataSeries* dataSeries = new terrama2::core::DataSeries();
  terrama2::core::DataSeriesPtr dataSeriesPtr(dataSeries);

  TestDataAccessorFile da(dataProviderPtr, dataSeriesPtr);

  std::vector<std::string> fileList;

  fileList.push_back(QDir::tempPath().toStdString());

  {
    auto foldersList = da.getFoldersList(fileList, "/%YYYY*/%MM*/%DD*/final*");

    if(foldersList.size() < 3)
      QFAIL("Wrong number of folders matched!");
  }

  {
    auto foldersList = da.getFoldersList(fileList, "%YYYY*/%MM*/%DD*/final*");

    if(foldersList.size() < 3)
      QFAIL("Wrong number of folders matched!");
  }

  // empty mask
  {
    auto foldersList = da.getFoldersList(fileList, "");

    if(foldersList.size() != 1)
      QFAIL("Wrong number of folders matched!");
  }

  // considered as empty mask
  {
    auto foldersList = da.getFoldersList(fileList, "/");

    if(foldersList.size() != 1)
      QFAIL("Wrong number of folders matched!");
  }

  // considered as empty mask
  {
    auto foldersList = da.getFoldersList(fileList, "//");

    if(foldersList.size() != 1)
      QFAIL("Wrong number of folders matched!");
  }

  // ignore the extras '/'
  {
    auto foldersList = da.getFoldersList(fileList, "%YYYY*//%MM*/%DD*//final*");

    if(foldersList.size() < 3)
      QFAIL("Wrong number of folders matched!");
  }

  // the folders doesn't match
  {
    auto foldersList = da.getFoldersList(fileList, "%YYYY*/nonexistent/%DD*");

    if(!foldersList.empty())
      QFAIL("Wrong number of folders matched!");
  }
}
示例#9
0
void TsDataAccessorFile::testGetFilesList()
{
  // Valid folders
  QTemporaryDir dir(QDir::tempPath() + QString::fromStdString("/2016"));

  QTemporaryDir subdir1(dir.path() + QString::fromStdString("/10"));
  QTemporaryDir subdir2(dir.path() + QString::fromStdString("/11"));
  QTemporaryDir subdir3(dir.path() + QString::fromStdString("/12"));

  QTemporaryDir subdir4(subdir1.path() + QString::fromStdString("/03"));
  QTemporaryDir subdir5(subdir3.path() + QString::fromStdString("/11"));

  QTemporaryDir subdir6(subdir2.path() + QString::fromStdString("/final"));
  QTemporaryDir subdir7(subdir4.path() + QString::fromStdString("/final"));

  QTemporaryDir subdir8(subdir5.path() + QString::fromStdString("/final"));

  // Invalid folders

  QTemporaryDir subdir9(dir.path() + QString::fromStdString("/03"));
  QTemporaryDir subdir10(subdir9.path() + QString::fromStdString("/aa"));

  QTemporaryDir dir3(QDir::tempPath() + QString::fromStdString("/2020"));
  QTemporaryDir dir4(QDir::tempPath() + QString::fromStdString("/folder"));

  terrama2::core::DataProvider* dataProvider = new terrama2::core::DataProvider();
  terrama2::core::DataProviderPtr dataProviderPtr(dataProvider);

  terrama2::core::DataSeries* dataSeries = new terrama2::core::DataSeries();
  terrama2::core::DataSeriesPtr dataSeriesPtr(dataSeries);

  TestDataAccessorFile da(dataProviderPtr, dataSeriesPtr);

  std::vector<std::string> baseDirList;

  baseDirList.push_back(QDir::tempPath().toStdString());

  QTemporaryFile file1(subdir7.path() + QString::fromStdString("/file_2017_06_01_14:40_XXXXXX.file"));
  QTemporaryFile file2(subdir7.path() + QString::fromStdString("/file_2017_06_01_14:41_XXXXXX.file"));
  QTemporaryFile file3(subdir8.path() + QString::fromStdString("/file_2017_06_02_12:00_XXXXXX.file"));

  file1.open();
  file2.open();
  file3.open();

  {
    std::string fileMask = "file_%YYYY_%MM_%DD_%hh:%mm_*.file";
    std::string foldermask = "/%YYYY*/%MM*/%DD*/final*/";

    terrama2::core::Filter filter;
    std::string timezone = "03";
    auto remover = std::make_shared<terrama2::core::FileRemover>();

    QFileInfoList fileList;

    for(auto& baseDir : baseDirList)
      fileList.append(da.getFilesList(baseDir, fileMask, foldermask, filter, timezone, remover));

    if(fileList.size() < 3)
      QFAIL("Wrong number of folders matched!");
  }

}
dgUnsigned32 dgUniversalConstraint::JacobianDerivative (dgContraintDescritor& params)
{
	dgInt32 ret;
	dgFloat32 sinAngle;
	dgFloat32 cosAngle;
	dgMatrix matrix0;
	dgMatrix matrix1;

	CalculateGlobalMatrixAndAngle (matrix0, matrix1);

	const dgVector& dir0 = matrix0.m_front;
	const dgVector& dir1 = matrix1.m_up;
	dgVector dir2 (dir0 * dir1);

	dgVector dir3 (dir2 * dir0);
	dir3 = dir3.Scale3 (dgRsqrt (dir3 % dir3));

	const dgVector& p0 = matrix0.m_posit;
	const dgVector& p1 = matrix1.m_posit;

	dgVector q0 (p0 + dir3.Scale3(MIN_JOINT_PIN_LENGTH));
	dgVector q1 (p1 + dir1.Scale3(MIN_JOINT_PIN_LENGTH));

	dgPointParam pointDataP;
	dgPointParam pointDataQ;
	InitPointParam (pointDataP, m_stiffness, p0, p1);
	InitPointParam (pointDataQ, m_stiffness, q0, q1);

	CalculatePointDerivative (0, params, dir0, pointDataP, &m_jointForce[0]); 
	CalculatePointDerivative (1, params, dir1, pointDataP, &m_jointForce[1]); 
	CalculatePointDerivative (2, params, dir2, pointDataP, &m_jointForce[2]); 
	CalculatePointDerivative (3, params, dir0, pointDataQ, &m_jointForce[3]); 
	ret = 4;


//	dgVector sinAngle0 (matrix1.m_up * matrix0.m_up);
//	m_angle0 = dgAsin (ClampValue (sinAngle0 % dir0, -0.9999999f, 0.9999999f));
//	if ((matrix0.m_up % matrix1.m_up) < dgFloat32 (0.0f)) {
//		m_angle0 = (m_angle0 >= dgFloat32 (0.0f)) ? dgPI - m_angle0 : dgPI + m_angle0;
//	}

	sinAngle = (matrix1.m_up * matrix0.m_up) % matrix0.m_front;
	cosAngle = matrix0.m_up % matrix1.m_up;
//	dgAssert (dgAbsf (m_angle0 - dgAtan2 (sinAngle, cosAngle)) < 1.0e-1f);
	m_angle0 = dgAtan2 (sinAngle, cosAngle);

//	dgVector sinAngle1 (matrix0.m_front * matrix1.m_front);
//	m_angle1 = dgAsin (ClampValue (sinAngle1 % dir1, -0.9999999f, 0.9999999f));
//	if ((matrix0.m_front % matrix1.m_front) < dgFloat32 (0.0f)) {
//		m_angle1 = (m_angle1 >= dgFloat32 (0.0f)) ? dgPI - m_angle1 : dgPI + m_angle1;
//	}

	sinAngle = (matrix0.m_front * matrix1.m_front) % matrix1.m_up;
	cosAngle = matrix0.m_front % matrix1.m_front;
//	dgAssert (dgAbsf (m_angle1 - dgAtan2 (sinAngle, cosAngle)) < 1.0e-1f);
	m_angle1 = dgAtan2 (sinAngle, cosAngle);

	if (m_jointAccelFnt) {
		dgUnsigned32 code;
		dgJointCallbackParam axisParam[2];

		// linear acceleration
		axisParam[0].m_accel = dgFloat32 (0.0f);
		axisParam[0].m_timestep = params.m_timestep;
		axisParam[0].m_minFriction = DG_MIN_BOUND;
		axisParam[0].m_maxFriction = DG_MAX_BOUND;

		// angular acceleration
		axisParam[1].m_accel = dgFloat32 (0.0f);
		axisParam[1].m_timestep = params.m_timestep;
		axisParam[1].m_minFriction = DG_MIN_BOUND;
		axisParam[1].m_maxFriction = DG_MAX_BOUND;

		code = m_jointAccelFnt (*this, axisParam);
		if (code & 1) {
			if ((axisParam[0].m_minFriction > DG_MIN_BOUND) || (axisParam[0].m_maxFriction < DG_MAX_BOUND)) {
				params.m_forceBounds[ret].m_low = axisParam[0].m_minFriction;
				params.m_forceBounds[ret].m_upper = axisParam[0].m_maxFriction;
				params.m_forceBounds[ret].m_normalIndex = DG_BILATERAL_FRICTION_CONSTRAINT;
			}

//			CalculatePointDerivative (ret, params, dir0, pointDataP, &m_jointForce[ret]); 
			CalculateAngularDerivative (ret, params, dir0, m_stiffness, dgFloat32 (0.0f), &m_jointForce[ret]);
			//params.m_jointAccel[ret] = axisParam[0].m_accel;
			SetMotorAcceleration (ret, axisParam[0].m_accel, params);
			ret ++;
		}

		if (code & 2) {
			if ((axisParam[1].m_minFriction > DG_MIN_BOUND) || (axisParam[1].m_maxFriction < DG_MAX_BOUND)) {
				params.m_forceBounds[ret].m_low = axisParam[1].m_minFriction;
				params.m_forceBounds[ret].m_upper = axisParam[1].m_maxFriction;
				params.m_forceBounds[ret].m_normalIndex = DG_BILATERAL_FRICTION_CONSTRAINT;
			}
			CalculateAngularDerivative (ret, params, dir1, m_stiffness, dgFloat32 (0.0f), &m_jointForce[ret]);
			//params.m_jointAccel[ret] = axisParam[1].m_accel;
			SetMotorAcceleration (ret, axisParam[1].m_accel, params);
			ret ++;

		}
	}
	return dgUnsigned32 (ret);
}
示例#11
0
void CustomUniversal::SubmitConstraints(dFloat timestep, int threadIndex)
{
    dMatrix matrix0;
    dMatrix matrix1;

    // calculate the position of the pivot point and the Jacobian direction vectors, in global space.
    CalculateGlobalMatrix(matrix0, matrix1);

    // Restrict the movement on the pivot point along all tree orthonormal direction
    NewtonUserJointAddLinearRow(m_joint, &matrix0.m_posit[0], &matrix1.m_posit[0], &matrix1.m_front[0]);
    NewtonUserJointAddLinearRow(m_joint, &matrix0.m_posit[0], &matrix1.m_posit[0], &matrix1.m_up[0]);
    NewtonUserJointAddLinearRow(m_joint, &matrix0.m_posit[0], &matrix1.m_posit[0], &matrix1.m_right[0]);


    // get the pin fixed to the first body
    const dVector& dir0 = matrix0.m_front;
    // get the pin fixed to the second body
    const dVector& dir1 = matrix1.m_up;

    // construct an orthogonal coordinate system with these two vectors
    dVector dir2(dir0 * dir1);
    dir2 = dir2.Scale(1.0f / dSqrt(dir2 % dir2));
    dVector dir3(dir1 * dir2);

    dFloat sinAngle = ((dir3 * dir0) % dir2);
    dFloat cosAngle = dir3 % dir0;
    NewtonUserJointAddAngularRow(m_joint, -dAtan2(sinAngle, cosAngle), &dir2[0]);

    dFloat sinAngle_0;
    dFloat cosAngle_0;
    CalculatePitchAngle(matrix0, matrix1, sinAngle_0, cosAngle_0);
    dFloat angle0 = -m_curJointAngle_0.Update(cosAngle_0, sinAngle_0);

    dFloat sinAngle_1;
    dFloat cosAngle_1;
    CalculateYawAngle(matrix0, matrix1, sinAngle_1, cosAngle_1);
    dFloat angle1 = -m_curJointAngle_1.Update(cosAngle_1, sinAngle_1);

    dVector omega0(0.0f, 0.0f, 0.0f, 0.0f);
    dVector omega1(0.0f, 0.0f, 0.0f, 0.0f);
    NewtonBodyGetOmega(m_body0, &omega0[0]);
    if (m_body1) {
        NewtonBodyGetOmega(m_body1, &omega1[0]);
    }

    // calculate the desired acceleration
    dVector relOmega(omega0 - omega1);
    m_jointOmega_0 = relOmega % matrix0.m_front;
    m_jointOmega_1 = relOmega % matrix1.m_up;

    // check is the joint limit are enable
    if (m_limit_0_On) {
        if (angle0 < m_minAngle_0) {
            dFloat relAngle = angle0 - m_minAngle_0;

            // tell joint error will minimize the exceeded angle error
            NewtonUserJointAddAngularRow(m_joint, relAngle, &matrix0.m_front[0]);

            // need high stiffeners here
            NewtonUserJointSetRowStiffness(m_joint, 1.0f);

            // allow the joint to move back freely
            NewtonUserJointSetRowMaximumFriction(m_joint, 0.0f);

        } else if (angle0 > m_maxAngle_0) {
            dFloat relAngle = angle0 - m_maxAngle_0;

            // tell joint error will minimize the exceeded angle error
            NewtonUserJointAddAngularRow(m_joint, relAngle, &matrix0.m_front[0]);

            // need high stiffness here
            NewtonUserJointSetRowStiffness(m_joint, 1.0f);

            // allow the joint to move back freely
            NewtonUserJointSetRowMinimumFriction(m_joint, 0.0f);
        }

        // check is the joint limit motor is enable
    } else if (m_angularMotor_0_On) {
        // calculate the desired acceleration
        //         dFloat relOmega = (omega0 - omega1) % matrix0.m_front;
        dFloat relAccel = m_angularAccel_0 - m_angularDamp_0 * m_jointOmega_0;

        // add and angular constraint row to that will set the relative acceleration to zero
        NewtonUserJointAddAngularRow(m_joint, 0.0f, &matrix0.m_front[0]);

        // override the joint acceleration.
        NewtonUserJointSetRowAcceleration(m_joint, relAccel);
    }

    // if limit are enable ...
    if (m_limit_1_On) {
        if (angle1 < m_minAngle_1) {
            dFloat relAngle = angle1 - m_minAngle_1;

            // tell joint error will minimize the exceeded angle error
            NewtonUserJointAddAngularRow(m_joint, relAngle, &matrix1.m_up[0]);

            // need high stiffeners here
            NewtonUserJointSetRowStiffness(m_joint, 1.0f);

            // allow the joint to move back freely
            NewtonUserJointSetRowMaximumFriction(m_joint, 0.0f);

        } else if (angle1 > m_maxAngle_1) {
            dFloat relAngle = angle1 - m_maxAngle_1;

            // tell joint error will minimize the exceeded angle error
            NewtonUserJointAddAngularRow(m_joint, relAngle, &matrix1.m_up[0]);

            // need high stiffness here
            NewtonUserJointSetRowStiffness(m_joint, 1.0f);

            // allow the joint to move back freely
            NewtonUserJointSetRowMinimumFriction(m_joint, 0.0f);
        }
    } else if (m_angularMotor_1_On) {
        // calculate the desired acceleration
        dFloat relAccel = m_angularAccel_1 - m_angularDamp_1 * m_jointOmega_1;

        // add and angular constraint row to that will set the relative acceleration to zero
        NewtonUserJointAddAngularRow(m_joint, 0.0f, &matrix1.m_up[0]);

        // override the joint acceleration.
        NewtonUserJointSetRowAcceleration(m_joint, relAccel);
    }
}
void CustomUniversal::SubmitConstraints (dFloat timestep, int threadIndex)
{
	dFloat angle;
	dFloat sinAngle;
	dFloat cosAngle;
	dMatrix matrix0;
	dMatrix matrix1;

	// calculate the position of the pivot point and the Jacobian direction vectors, in global space. 
	CalculateGlobalMatrix (m_localMatrix0, m_localMatrix1, matrix0, matrix1);

	// get the pin fixed to the first body
	const dVector& dir0 = matrix0.m_front;
	// get the pin fixed to the second body
	const dVector& dir1 = matrix1.m_up;

	// construct an orthogonal coordinate system with these two vectors
	dVector dir2 (dir0 * dir1);
	dir2 = dir2.Scale (1.0f / dSqrt (dir2 % dir2));

	const dVector& p0 = matrix0.m_posit;
	const dVector& p1 = matrix1.m_posit;
	NewtonUserJointAddLinearRow (m_joint, &p0[0], &p1[0], &dir0[0]);
	NewtonUserJointSetRowStiffness (m_joint, 1.0f);
	NewtonUserJointAddLinearRow (m_joint, &p0[0], &p1[0], &dir1[0]);
	NewtonUserJointSetRowStiffness (m_joint, 1.0f);
	NewtonUserJointAddLinearRow (m_joint, &p0[0], &p1[0], &dir2[0]);
	NewtonUserJointSetRowStiffness (m_joint, 1.0f);


	dVector dir3 (dir2 * dir0);
	dVector q0 (p0 + dir3.Scale(MIN_JOINT_PIN_LENGTH));
	dVector q1 (p1 + dir1.Scale(MIN_JOINT_PIN_LENGTH));
	NewtonUserJointAddLinearRow (m_joint, &q0[0], &q1[0], &dir0[0]);
	NewtonUserJointSetRowStiffness (m_joint, 1.0f);


	// check is the joint limit are enable
	if (m_limit_0_On) {
		sinAngle = (matrix0.m_up * matrix1.m_up) % matrix0.m_front;
		cosAngle = matrix0.m_up % matrix1.m_up;
		angle = dAtan2 (sinAngle, cosAngle);

		if (angle < m_minAngle_0) {
			dFloat relAngle;
			relAngle = angle - m_minAngle_0;

			// tell joint error will minimize the exceeded angle error
			NewtonUserJointAddAngularRow (m_joint, relAngle, &matrix0.m_front[0]);

			// need high stiffeners here
			NewtonUserJointSetRowStiffness (m_joint, 1.0f);

			// allow the joint to move back freely
			NewtonUserJointSetRowMaximumFriction (m_joint, 0.0f);

		} else if (angle > m_maxAngle_0) {
			dFloat relAngle;
			relAngle = angle - m_maxAngle_0;

			// tell joint error will minimize the exceeded angle error
			NewtonUserJointAddAngularRow (m_joint, relAngle, &matrix0.m_front[0]);

			// need high stiffness here
			NewtonUserJointSetRowStiffness (m_joint, 1.0f);

			// allow the joint to move back freely 
			NewtonUserJointSetRowMinimumFriction (m_joint, 0.0f);
		}

		// check is the joint limit motor is enable
	} else if (m_angularMotor_0_On) {

		dFloat relOmega;
		dFloat relAccel;
		dVector omega0 (0.0f, 0.0f, 0.0f);
		dVector omega1 (0.0f, 0.0f, 0.0f);

		// get relative angular velocity
		NewtonBodyGetOmega(m_body0, &omega0[0]);
		if (m_body1) {
			NewtonBodyGetOmega(m_body1, &omega1[0]);
		}

		// calculate the desired acceleration
		relOmega = (omega0 - omega1) % matrix0.m_front;
		relAccel = m_angularAccel_0 - m_angularDamp_0 * relOmega;

		// add and angular constraint row to that will set the relative acceleration to zero
		NewtonUserJointAddAngularRow (m_joint, 0.0f, &matrix0.m_front[0]);

		// override the joint acceleration.
		NewtonUserJointSetRowAcceleration (m_joint, relAccel);
	}


	// if limit are enable ...
	if (m_limit_1_On) {
		sinAngle = (matrix0.m_front * matrix1.m_front) % matrix1.m_up;
		cosAngle = matrix0.m_front % matrix1.m_front;
		angle = dAtan2 (sinAngle, cosAngle);
 
		if (angle < m_minAngle_1) {
			dFloat relAngle;
			relAngle = angle - m_minAngle_1;

			// tell joint error will minimize the exceeded angle error
			NewtonUserJointAddAngularRow (m_joint, relAngle, &matrix1.m_up[0]);

			// need high stiffeners here
			NewtonUserJointSetRowStiffness (m_joint, 1.0f);

			// allow the joint to move back freely 
			NewtonUserJointSetRowMaximumFriction (m_joint, 0.0f);

		} else if (angle > m_maxAngle_1) {
			dFloat relAngle;
			relAngle = angle - m_maxAngle_1;
			
			// tell joint error will minimize the exceeded angle error
			NewtonUserJointAddAngularRow (m_joint, relAngle, &matrix1.m_up[0]);

			// need high stiffness here
			NewtonUserJointSetRowStiffness (m_joint, 1.0f);

			// allow the joint to move back freely
			NewtonUserJointSetRowMinimumFriction (m_joint, 0.0f);
  		}
	} else if (m_angularMotor_1_On) {
		dFloat relOmega;
		dFloat relAccel;
		dVector omega0 (0.0f, 0.0f, 0.0f);
		dVector omega1 (0.0f, 0.0f, 0.0f);

		// get relative angular velocity
		NewtonBodyGetOmega(m_body0, &omega0[0]);
		if (m_body1) {
			NewtonBodyGetOmega(m_body1, &omega1[0]);
		}

		// calculate the desired acceleration
		relOmega = (omega0 - omega1) % matrix1.m_up;
		relAccel = m_angularAccel_1 - m_angularDamp_1 * relOmega;

		// add and angular constraint row to that will set the relative acceleration to zero
		NewtonUserJointAddAngularRow (m_joint, 0.0f, &matrix1.m_up[0]);
		
		// override the joint acceleration.
		NewtonUserJointSetRowAcceleration (m_joint, relAccel);
	}
 }
示例#13
0
CenterWindow::CenterWindow(QWidget *parent) :
    FCenterWindow(parent)
{
    this->version = "3.1.0";
    QDir dir;
    QDir dir2(dir.homePath()+"/视频");
    QDir dir3(dir.homePath()+"/Videos");
    QString dbPath;
    if(dir2.exists())
    {
        dbPath = dir.homePath()+"/视频/MvGather/Database";
    }else if(dir3.exists())
    {
        dbPath = dir.homePath()+"/Videos/MvGather/Database";
    }else
    {
        dbPath = dir.homePath()+"/MvGather";
    }
    dir.mkpath(dbPath);
    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");//添加数据库驱动,这里用sqlite
    db.setDatabaseName(dbPath+"/MvGather.db");
    //    db.setDatabaseName("MvGather.db");
    if(db.open())
    {
        //tvId:该视频唯一编号,tvName:视频中文名.tvno_hrefs:集数与相应地址...historyNo:上次观看到的集数;quality:清晰度;tvUrl:yunfan视频列表地址;source:视频来源标识
        QSqlQuery query_creat_tb("CREATE TABLE IF NOT EXISTS playlistTB(tvId VARCHAR( 30 ) NOT NULL,tvName VARCHAR( 30 ),tvno_hrefs VARCHAR(100),historyNo VARCHAR( 30 ),quality VARCHAR( 30 ),tvUrl VARCHAR(100),source VARCHAR( 30 ))");
        query_creat_tb.exec();
        //taskId:创建下载任务的id;url任务原地址;fileSavePath:文件保存目录,percent完成的百分比
        QSqlQuery query_creat_tb2("CREATE TABLE IF NOT EXISTS dtaskTB(taskId VARCHAR(30) NOT NULL,url VARCHAR(200) NOT NULL,fileSavePath VARCHAR(200) NOT NULL,percent VARCHAR(5))");
        query_creat_tb2.exec();
    }


    playerWidget = new PlayerWidget(this);
    addWidget(tr("播放器"), tr("Player"), playerWidget);

    browseWidget = new  BrowseWidget(this);
    addWidget(tr("视频库"), tr("MvList"), browseWidget);

    recommendWidget = new RecommendWidget(this);
    addWidget(tr("推荐"), tr("MvRecomend"), recommendWidget);

    magnetWidget = new MagnetWidget(this);
    addWidget(tr("磁力链"), tr("Magnet"), magnetWidget);

    downloadManageWidget = new QScrollArea(this);
    addWidget(tr("下载"), tr("Download"), downloadManageWidget);

    downloadManageScrollAreaWidget = new QWidget(downloadManageWidget);
    downloadManageWidget->setWidget(downloadManageScrollAreaWidget);
    downloadManageScrollAreaWidgetMainLayout = new QVBoxLayout;
    downloadManageScrollAreaWidgetMainLayout->setAlignment(Qt::AlignTop);
    downloadManageScrollAreaWidget->setLayout(downloadManageScrollAreaWidgetMainLayout);

    downloadManageScrollAreaWidget->setStyleSheet("background:transparent");

    getNavgationBar()->setCurrentIndex(0);
    setAlignment(TopCenter);

    QSettings settings("MvGather", "xusongjie");
    QString preferQualitysSetting = settings.value("app/preferQualitys", "").toString();
    if(preferQualitysSetting =="")
    {
        preferQualitysSetting="高清#超清#M3U8#分段_高清_FLV#分段_高清_MP4#分段_高清_M3U8#分段_720P_FLV#分段_720P_MP4#分段_720P_M3U8#分段_1080P_FLV#分段_1080P_MP4#分段_1080P_M3U8#分段_超清_FLV#分段_超清_MP4#分段_超清_M3U8#分段_标清_FLV#分段_标清_MP4#分段_标清_M3U8#分段_高码1080P_FLV#分段_高码1080P_MP4#分段_高码1080P_M3U8#分段_原画_FLV#分段_原画_MP4#分段_原画_M3U8#分段_4K_FLV#分段_4K_MP4#分段_4K_M3U8#分段_高码4K_FLV#分段_高码4K_MP4#分段_高码4K_M3U8#分段_低清_FLV#分段_低清_MP4#分段_低清_M3U8#单段_高清_MP4#单段_高清_M3U8#单段_高清_FLV#单段_720P_FLV#单段_720P_MP4#单段_720P_M3U8#单段_1080P_FLV#单段_1080P_MP4#单段_1080P_M3U8#单段_超清_FLV#单段_超清_MP4#单段_超清_M3U8#单段_标清_FLV#单段_标清_MP4#单段_标清_M3U8#单段_高码1080P_FLV#单段_高码1080P_MP4#单段_高码1080P_M3U8#单段_原画_FLV#单段_原画_MP4#单段_原画_M3U8#单段_4K_FLV#单段_4K_MP4#单段_4K_M3U8#单段_高码4K_FLV#单段_高码4K_MP4#单段_高码4K_M3U8#单段_低清_FLV#单段_低清_MP4#单段_低清_M3U8";
        settings.setValue("app/preferQualitys",preferQualitysSetting);
    }


    connect(browseWidget,SIGNAL(play(QString)),this,SLOT(addMvToPlaylist(QString)));

    connect(playerWidget,SIGNAL(hideToFullScreen(bool)),this,SLOT(getIntofullScreenMode(bool)));
    connect(playerWidget,SIGNAL(getIntoWideModel(bool)),this,SLOT(getIntoWideModel(bool)));

    connect(magnetWidget,SIGNAL(addDownloadTask(QString)),this,SLOT(addDownloadTask(QString)));
    connect(recommendWidget,SIGNAL(addDownloadTaskSignal(QString)),this,SLOT(addDownloadTask(QString)));

    connect(getNavgationBar(),SIGNAL(indexChanged(int)),this,SLOT(firstLoadList(int)));

    hideMouseTimer = new QTimer;
    connect(hideMouseTimer,SIGNAL(timeout()),this,SLOT(hideMouse()));
    hideMouseTimer->start(500);

    loadDownloadSettings();
}
示例#14
0
void Camera::update(){
    
    if (flags & CAM_POS_DIRTY ||
        flags & CAM_DIR_DIRTY) {
        
        if (cameraMode == CameraMode::CAM_MODEL_UVN_SIMPLE) {
            // var 表示的是 target
            Vec3 dir3 = dir - pos;
            dir3.normalize();
            
            // 计算 uvn
            n = -dir3;
            Vec3::cross(dir3,Vec3::UNIT_Y,&u);
            u.normalize();
            
            Vec3::cross(u,dir3,&v);
            v.normalize();
            
            
            float inv_uvn_arr[16]={
                u.x,v.x,n.x,0,
                u.y,v.y,n.y,0,
                u.z,v.z,n.z,0,
                0,0,0,1
            };
            Mat4 inv_uvn(inv_uvn_arr);
            
            Mat4 inv_trans;
            Mat4::createTranslation(-pos, &inv_trans);
            
            Mat4::multiply(inv_uvn,inv_trans,&mcam);
            
        }else if (cameraMode == CameraMode::CAM_MODEL_UVN_SPHERICAL){
            // var 表示的是方位
            // 这里假设不围绕z轴旋转
            
            // 仰角
            float fi = dir.x;
            
            // 方位角
            float st = dir.y;
            
            float sin_fi = sinf(MATH_DEG_TO_RAD(fi));
            float cos_fi = cosf(MATH_DEG_TO_RAD(fi));
            
            float sin_st = sinf(MATH_DEG_TO_RAD(st));
            float cos_st = cosf(MATH_DEG_TO_RAD(st));
            
            // 计算uvn
            float x = -cos_fi * sin_st;
            float y = sin_fi;
            float z = -cos_fi * cos_st;
            
            Vec3 dir3(x,y,z);
            n = -dir3;
            Vec3::cross(dir3,Vec3::UNIT_Y,&u);
            u.normalize();
            
            Vec3::cross(u,dir3,&v);
            v.normalize();
            
            float inv_uvn_arr[16]={
                u.x,v.x,n.x,0,
                u.y,v.y,n.y,0,
                u.z,v.z,n.z,0,
                0,0,0,1
            };
            Mat4 inv_uvn(inv_uvn_arr);
            
            Mat4 inv_trans;
            Mat4::createTranslation(-pos, &inv_trans);
            
            Mat4::multiply(inv_uvn,inv_trans,&mcam);
            
        }else if (cameraMode == CameraMode::CAM_MODEL_EULER){
            
            // 先提取欧拉角的三个角度
            float angle_x = MATH_DEG_TO_RAD(dir.x);
            float angle_y = MATH_DEG_TO_RAD(dir.y);
            float angle_z = MATH_DEG_TO_RAD(dir.z);
            
            // 构造绕x的旋转矩阵
            Mat4 rotateX;
            Mat4::createRotationX(angle_x,&rotateX);
            rotateX.transpose();
            
            Mat4 rotateY;
            Mat4::createRotationY(angle_y,&rotateY);
            rotateY.transpose();
            
            Mat4 rotateZ;
            Mat4::createRotationZ(angle_z,&rotateZ);
            rotateZ.transpose();
            
            Mat4 inv_trans;
            Mat4::createTranslation(-pos,&inv_trans);
            
            Mat4 temp1,temp2;
            
            // 根据定义的顺序来计算
            switch (eulerRotSeq) {
                case EulerCameraRotSeq::CAM_ROT_SEQ_XYZ:
                    Mat4::multiply(rotateX,rotateY,&temp1);
                    Mat4::multiply(temp1,rotateZ,&temp2);
                    Mat4::multiply(temp2,inv_trans,&mcam);
                    break;
                case EulerCameraRotSeq::CAM_ROT_SEQ_XZY:
                    Mat4::multiply(rotateX,rotateZ,&temp1);
                    Mat4::multiply(temp1,rotateY,&temp2);
                    Mat4::multiply(temp2,inv_trans,&mcam);
                    break;
                case EulerCameraRotSeq::CAM_ROT_SEQ_YXZ:
                    Mat4::multiply(rotateY,rotateX,&temp1);
                    Mat4::multiply(temp1,rotateZ,&temp2);
                    Mat4::multiply(temp2,inv_trans,&mcam);
                    break;
                case EulerCameraRotSeq::CAM_ROT_SEQ_YZX:
                    Mat4::multiply(rotateY,rotateZ,&temp1);
                    Mat4::multiply(temp1,rotateX,&temp2);
                    Mat4::multiply(temp2,inv_trans,&mcam);
                    break;
                case EulerCameraRotSeq::CAM_ROT_SEQ_ZXY:
                    Mat4::multiply(rotateZ,rotateX,&temp1);
                    Mat4::multiply(temp1,rotateY,&temp2);
                    Mat4::multiply(temp2,inv_trans,&mcam);
                    break;
                case EulerCameraRotSeq::CAM_ROT_SEQ_ZYX:
                    Mat4::multiply(rotateZ,rotateY,&temp1);
                    Mat4::multiply(temp1,rotateX,&temp2);
                    Mat4::multiply(temp2,inv_trans,&mcam);
                    break;
                default:
                    printf("unsupperted rot seq.....\n");
                    break;
            }
            
            // uvn
            temp2.transpose();
            temp2.getColumnX(&u);
            temp2.getColumnY(&v);
            temp2.getColumnZ(&n);
        }
        
        buidProjScreenMatrixAndClipPlane();
        
        flags = 0;
    }
}
示例#15
0
Camera::Camera(const Point3& cam_pos,
       const Vec3& var, // simple_uvn 模式下表示 观察点, 球面 uvn 模式下表示相机的方位
       float cam_near,
       float cam_far,
       float cam_fovy,
       float screen_w,
       float screen_h,
       CameraMode uvnMode
       ){
 
    flags = 0;
    cameraMode = uvnMode;
    pos = cam_pos;
    near = cam_near;
    far = cam_far;
    fovy = cam_fovy;
    viewport_w = screen_w;
    viewport_h = screen_h;
    
    aspect_ratio = viewport_w/viewport_h;
    
    if (uvnMode == CameraMode::CAM_MODEL_UVN_SIMPLE) {
        // var 表示的是 target
        Vec3 dir3 = var - pos;
        dir3.normalize();
        
        // 计算 uvn
        n = -dir3;
        Vec3::cross(dir3,Vec3::UNIT_Y,&u);
        u.normalize();
        
        Vec3::cross(u,dir3,&v);
        v.normalize();
    }else if (uvnMode == CameraMode::CAM_MODEL_UVN_SPHERICAL){
        // var 表示的是方位
        // 这里假设不围绕z轴旋转
        dir = var;
        
        // 仰角
        float fi = dir.x;
        
        // 方位角
        float st = dir.y;
        
        float sin_fi = sinf(MATH_DEG_TO_RAD(fi));
        float cos_fi = cosf(MATH_DEG_TO_RAD(fi));
        
        float sin_st = sinf(MATH_DEG_TO_RAD(st));
        float cos_st = cosf(MATH_DEG_TO_RAD(st));
        
        // 计算uvn
        float x = -cos_fi * sin_st;
        float y = sin_fi;
        float z = -cos_fi * cos_st;
        
        Vec3 dir3(x,y,z);
        n = -dir3;
        Vec3::cross(dir3,Vec3::UNIT_Y,&u);
        u.normalize();
        
        Vec3::cross(u,dir3,&v);
        v.normalize();

    }else{
        printf("unsupport uvn mode.....\n");
    }
    
    float inv_uvn_arr[16]={
        u.x,v.x,n.x,0,
        u.y,v.y,n.y,0,
        u.z,v.z,n.z,0,
        0,0,0,1
    };
    Mat4 inv_uvn(inv_uvn_arr);
    
    Mat4 inv_trans;
    Mat4::createTranslation(-pos, &inv_trans);
    
    Mat4::multiply(inv_uvn,inv_trans,&mcam);
    
    buidProjScreenMatrixAndClipPlane();
}