コード例 #1
0
ファイル: GUIManager.cpp プロジェクト: Nvveen/Revolution
bool GUIManager::handleBigScrollbarChanged ( CEGUI::EventArgs const & e )
{
  CEGUI::WindowManager & wm = CEGUI::WindowManager::getSingleton();
  try {
    if (_selectedDM != NULL) {
      CEGUI::Window *desc = wm.getWindow("Sheet/DimensionText");
      CEGUI::Scrollbar *sb = static_cast<CEGUI::Scrollbar *>(
          static_cast<CEGUI::WindowEventArgs const &>(e).window);
      float f = sb->getScrollPosition();
      std::vector<unsigned int> const & dims = _selectedDM->getDimensions();
      unsigned int newDim = dims[int(f*(dims.size()-1))];
      std::ostringstream ss; ss << newDim;
      desc->setText(ss.str());
      CEGUI::Scrollbar *otherSB;
      switch (_selectedDM->type) {
        case DM_Height:
          otherSB = static_cast<CEGUI::Scrollbar *>(wm.getWindow(
                "Sheet/DatasetFrame/TabControl/HTab/Scrollbar"));
          break;
        case DM_Pattern:
          otherSB = static_cast<CEGUI::Scrollbar *>(wm.getWindow(
                "Sheet/DatasetFrame/TabControl/PTab/Scrollbar"));
          break;
        case DM_Color:
          otherSB = static_cast<CEGUI::Scrollbar *>(wm.getWindow(
                "Sheet/DatasetFrame/TabControl/CTab/Scrollbar"));
          break;
        default:
          break;
      };
      otherSB->setScrollPosition(f);
      _selectedDM->activate(newDim);
    }
  }
  catch (DataManagerException & e) {
    std::cerr << e.what() << std::endl;
  }
  return true;
}
//---------------------------------------------------------------------------------------
bool DigitalForensicsVisualisation::visualise(const CEGUI::EventArgs &e)
{
	try
	{
		mSceneMgr->getRootSceneNode()->removeAndDestroyChild("FilesNode");
		mSceneMgr->destroyAllMovableObjects(); //does not destroy movable texts, they are needed to be destroyed manually
		mSceneMgr->destroyAllManualObjects();
		cubeCount = pyramidCount = cylinderCount = 0;

		for (unsigned long int i = 0; i < textArrIndex; ++i)
		{
			textArr[textArrIndex]->~MovableText();
			
			textArr[textArrIndex] = NULL;
		}

		textArrIndex = 0;
	}
	catch(std::exception& e)
	{
		//do nothing
		OutputDebugString("DID NOTHING\nn\nn\nn\nn\nn\nn\nn\nn\nn\nn\nn\nnREALLYDIDNOTHING\nn");
	}

	beginProgress();

	const float radius = 1000;
	const float thickness = radius - 45;
	

	try
	{

		MYSQL_RES *res_set; /* Create a pointer to recieve the return value.*/
		MYSQL_ROW row;  /* Assign variable for rows. */
 
		OutputDebugString(buildQuery().c_str());
		res_set = mysqlExecute(buildQuery().c_str());
		unsigned long long int numrows = mysql_num_rows(res_set); /* Create the count to print all rows */
 

		float distFromCentre = radius - thickness;
		unsigned long long int itemIndex = 0;
		char containerName[50]; //for container
		char fileName[50]; //for fileName
		char fontName[50]; //for fontName

		filesNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("FilesNode");
		filesNode->setPosition (0, -300, -500);

		srand(time(NULL));

		

		for (float y = radius - thickness; y <= radius; y += Ogre::Math::PI * 6)
		{

			//progress_bar->setProgress(progress_bar->getProgress() + ( 1/ (Ogre::Math::PI / (thickness * thickness))));

			for (float theta = 0; theta <= Ogre::Math::PI * 1.8; theta += Ogre::Math::PI / (distFromCentre / 6)) 
			{
				if ((row = mysql_fetch_row(res_set)) == NULL)
					goto exit;

			
				try
				{	

					app.e.name = row[0];
					app.e.directory = row[1];
					app.e.size = std::stoull(row[2]); //for unsigned long long
					
					app.e.setExtension();
					std::string ext = app.e.extension;
			
					for (unsigned int i = 0; i < ext.length(); ++i)
					{
						ext[i] = std::toupper(ext[i]);
					}

					app.e.extension = ext;

					app.e.write_permission = std::stoi(row[4]);
					app.e.access_permission = std::stoi(row[5]);
					app.e.creation_time = row[6];
					app.e.access_time = row[7];
					app.e.modification_time = row[8];
					app.e.c = std::stoi(row[9]);
					app.e.a = std::stoi(row[10]);
					app.e.m = std::stoi(row[11]);
			
				}
				catch(std::exception& e)
				{	
					OutputDebugString(e.what());
					OutputDebugString("SIZEEXCEPTIONNN\nn\n\nn\nn\nn\nn\nn\nn\nn\nn\nn\nn\nn\nn\nn\nn\nn\n\nn\nn\nn\nn\nnn\nn\nSIZEEXCEPTIONNN\nn\n");
					app.e.creation_time = app.e.modification_time = app.e.access_time = app.e.name = "exception occured";
				
				}

				sprintf(containerName,"container_%d",itemIndex);
				sprintf(fontName,"font_%d", itemIndex);
				sprintf(fileName, "file_%d", itemIndex++);

				Ogre::SceneNode* container = filesNode->createChildSceneNode(containerName);
				Ogre::SceneNode* fsn = container->createChildSceneNode(fileName);
				Ogre::SceneNode* fontNode = container->createChildSceneNode(fontName);
				Ogre::SceneNode* textureNode;
				bool isTexture = app.e.isTextureFile();
				if (isTexture)
				{
					try
					{
					
						char textureName[50];
						sprintf(textureName,"texture_%d",itemIndex-1);
						std::stringstream ss;
						ss << app.e.directory << "/" << app.e.name;
						//loads and adds the image to the resources/////
						
						Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName("MyMaterial2");
						Ogre::MaterialPtr matClone = material->clone(textureName);
						loadImageFile(textureName,ss.str());
						matClone->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(textureName);
						
						textureNode = container->createChildSceneNode(textureName);
						textureNode->attachObject(rectangle(textureName));
						textureNode->setPosition(y * cos(theta), 0, y * sin(theta));
						textureNode->scale(.09,((float) app.e.size / 20000000 + 0.1),.09);
					}
					catch(std::exception e)
					{
						
						OutputDebugStringA("\nm\nm\nm\nm\nm\nm\nm\nm");
						OutputDebugStringA(e.what());
					};


					


				}

				ColorMap cm(app.e.extension);
			

				if (colorTree.search(cm) == NULL)
					colorTree.insert(cm);
				else
					cm = colorTree.search(cm)->data;
				

		

			
				
				if ((app.e.write_permission == 1) && (app.e.access_permission == 1))
					fsn ->attachObject(cube(true, cm));
				else if ((app.e.write_permission == 1) && (app.e.access_permission == 0))
					fsn->attachObject(cube(false, cm));
				else if ((app.e.write_permission == 0) && (app.e.access_permission == 1))
				{
					fsn -> attachObject(pyramid(cm));
					fsn -> scale (1.3, 1.3, 1.3);
				}
				else
				{
					fsn->attachObject(cylinder(cm));
					fsn->pitch((Ogre::Radian) Ogre::Math::PI);
					if (isTexture)
						textureNode->scale(.8,1,.8);
					
				}
				std::stringstream ss;
				ss << "file name: " << app.e.name << "\n\nlast access time: " << app.e.access_time << "\nmodification time: " 
					<< app.e.modification_time << "\ncreation time: " << app.e.creation_time;
				std::string s = ss.str();
			
				textArr[textArrIndex] = new Ogre::MovableText("tayyar", (s));
				textArr[textArrIndex] ->setTextAlignment(Ogre::MovableText::H_CENTER, Ogre::MovableText::V_CENTER); // Center horizontally and display above the node	
				textArr[textArrIndex] ->setColor(Ogre::ColourValue(1,1,1,.65));

				fontNode->attachObject(textArr[textArrIndex++]);

				fsn->setPosition(y * cos(theta), 0, y * sin(theta));
				fontNode->setPosition(fsn->getPosition().x + 6, fsn->getPosition().y, fsn->getPosition().z + 3.75);
			

				fsn->scale(.09,((float) app.e.size / 20000000 + 0.1),.09);

		

				OutputDebugString(fileName);
				OutputDebugString("\n");
			
			}

			distFromCentre += Ogre::Math::PI * 6;
		
		}

	
	}
	catch(std::exception& e)
	{
		OutputDebugString(e.what());
		OutputDebugString("EXCEPTIONNN\nn\n\nn\nn\nn\nn\nn\nn\nn\nn\nn\nn\nn\nn\nn\nn\nn\n\nn\nn\nn\nn\nnn\nn\nEXCEPTIONNN\nn\n");
					
	}
	
	exit:
	endProgress();
	return true;
}