コード例 #1
0
ファイル: mainwindow.cpp プロジェクト: rio-2607/image_process
void MainWindow::onOpenFile()
{
    QString loadFileName = QFileDialog::getOpenFileName(this, tr("打开图片"),\
                                                     ".", tr("jpg文件(*.jpg);;png文件(*.png);;bmp文件(*.bmp);;jpeg文件(*.jpeg);;所有文件(*.*)"));

    if( loadFileName.isEmpty() )
    {
        return;
    }



    imageToOperation.load(loadFileName);
    imageOperation = imageToOperation;
    imageProcess.getImageInfo(imageToOperation);
    rgb2Gray->setEnabled(true);
    if (!imageToOperation.load(loadFileName))
    {
        QMessageBox::critical(NULL, tr("打开文件错误"), \
                             tr("打开文件bmp格式文件,失败!"));
        return;
    }
    setMenuEnabled(true);
    setWindowTitle(loadFileName);
    update();
}
コード例 #2
0
	void CMazeGameMenu::showVideoSettings()
	{
		if (_currentMenu == CurrentMenu::VideoSettings)
		{ 
			return; //already showing the video settings
		}
		LOG(DEBUG) << "Showing video settings";
		_menuBackground->setVisible(true);
		switch (_currentMenu)
		{
		case CurrentMenu::GameSettings:
			setMenuEnabled(false, _gameSettingsElements);
			break;
		case CurrentMenu::MainMenu:
			setMenuEnabled(false, _mainMenuElements);
			break;
		default:
			break;
		}
		setMenuEnabled(true, _videoSettingsElements);
		_currentMenu = CurrentMenu::VideoSettings;
	}
コード例 #3
0
	void CMazeGameMenu::hideMenu()
	{
		if (_currentMenu == CurrentMenu::None)
		{
			return; //already showing no menu
		}
		LOG(DEBUG) << "Hiding menu";
		_menuBackground->setVisible(false);
		switch (_currentMenu)
		{
		case CurrentMenu::MainMenu:
			setMenuEnabled(false, _mainMenuElements);
			break;
		case CurrentMenu::VideoSettings:
			setMenuEnabled(false, _videoSettingsElements);
			break;
		case CurrentMenu::GameSettings:
			setMenuEnabled(false, _gameSettingsElements);
			break;
		default: //this would never happen...
			break;
		}
		_currentMenu = CurrentMenu::None;
	}
コード例 #4
0
ファイル: mainwindow.cpp プロジェクト: rio-2607/image_process
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    imageLabel = new QLabel;
    imageLabel->setBackgroundRole(QPalette::NoRole);
    imageLabel->setSizePolicy(QSizePolicy::Ignored,QSizePolicy::Ignored);
    imageLabel->setScaledContents(true); //选择自动适应框的变化,就是无论将对话框,缩小放大都不影响像素,作用在看图片的时候,图片的像素会跟着相框调整

    scrollArea = new QScrollArea;       //滚动区域
    scrollArea->setBackgroundRole(QPalette::Dark);
    scrollArea->setWidget(imageLabel);


    setCentralWidget(scrollArea);
    createActions();
    createMenus();
    resize(600,500);
    setWindowTitle(tr("Digital Image Processing"));

    setMenuEnabled(false);




//    for(int i=0;i<256;i++)
//        grayCount[i] = 0;
    drawHisWindow = new drawHistogram(this);
    subWindow = new subMainWindow(this);

    xOffset = 0;
    yOffset = 0;
    paraDialog = new parameterDialog(this);
    connect(paraDialog,SIGNAL(sendParameter(int,int)),this,SLOT(getParameterAndProcess(int,int)));
    templateDialog = new templateSetting(this);
    connect(templateDialog,SIGNAL(sendSelect(int)),this,SLOT(getTemplateSelectAndProcess(int)));
    thresholdSetDialog = new setThreshold(this);
    connect(thresholdSetDialog,SIGNAL(sendThreshold(int)),this,SLOT(getThresholdAndProcess(int)));
    linerTransformDilaog = new linerTransformSettingDialog(this);
    connect(linerTransformDilaog,SIGNAL(sendParamer(int,int)),\
            this,SLOT(getLinerTransformParamerAndProcess(int,int)));
    graySettingDialog = new grayExtendDialog(this);
    connect(graySettingDialog,SIGNAL(sendParamer(int,int,int,int)),this,SLOT(getCoorsAndProcess(int,int,int,int)));
    dialogOfZoom = new zoomDialog(this);
    connect(dialogOfZoom,SIGNAL(sendParamer(float)),this,SLOT(getScaleAndProcess(float)));
}
コード例 #5
0
	void CMazeGameMenu::init(irr::gui::IGUIEnvironment * const in_guiEnv, const irr::core::recti & in_menuRect)
	{
		//TODO: Add cool images as buttons.
		LOG(DEBUG) << "Initializing menu";
		_mainMenuElements.clear();
		_gameSettingsElements.clear();
		_videoSettingsElements.clear();
		_guiEnv = in_guiEnv;
		auto backgroundImg = in_guiEnv->addImage(irr::core::recti(irr::core::vector2di(0, 0), in_guiEnv->getVideoDriver()->getScreenSize()));
		backgroundImg->setScaleImage(true);
		backgroundImg->setColor(irr::video::SColor(150, 255, 255, 255));
		backgroundImg->setImage(in_guiEnv->getVideoDriver()->getTexture("../media/p-of-eternity-maze-by-malcolm.jpg"));
		auto backImg = in_guiEnv->addImage(irr::core::recti(
			irr::core::vector2di(in_menuRect.UpperLeftCorner.X * (1.0f - ElementSeparationRatio), in_menuRect.UpperLeftCorner.Y * (1.0f - ElementSeparationRatio)), 
			irr::core::dimension2di(in_menuRect.getSize().Width *(1.0f + ElementSeparationRatio), in_menuRect.getSize().Height *(1.0f + ElementSeparationRatio + ElementHeightRatio))), backgroundImg);
		backImg->setScaleImage(true);
		backImg->setColor(irr::video::SColor(200, 255, 255, 255));
		backImg->setImage(in_guiEnv->getVideoDriver()->getTexture("../media/irrlicht2_up.jpg"));
		_menuBackground = backgroundImg;
		in_guiEnv->getSkin()->setFont(in_guiEnv->getFont("../media/fonthaettenschweiler.bmp"));
		//set the main menu.
		auto in_videoDriver = in_guiEnv->getVideoDriver();
		irr::core::dimension2di elementSize = in_menuRect.getSize(); 
		elementSize.Height *= ElementHeightRatio;
		int elementSeperation = in_menuRect.getHeight() * ElementSeparationRatio;
		irr::core::vector2di elementPosition(in_menuRect.UpperLeftCorner);
		auto button = in_guiEnv->addButton(irr::core::recti(elementPosition, elementSize), nullptr, MenuElement::BackToGameBtn,L"Back to Game");
		//button->setImage(in_videoDriver->getTexture("../media/backToGame.jpg"));
		_mainMenuElements.push_back(button);
		elementPosition.Y += elementSeperation + elementSize.Height;
		button = in_guiEnv->addButton(irr::core::recti(elementPosition, elementSize), nullptr, MenuElement::NewGameBtn, L"New Game");
		//button->setImage(in_videoDriver->getTexture("../media/newGame.jpg"));
		_mainMenuElements.push_back(button);
		elementPosition.Y += elementSeperation + elementSize.Height;
		button = in_guiEnv->addButton(irr::core::recti(elementPosition, elementSize), nullptr, MenuElement::GameSettingsBtn, L"Game Settings");
		//button->setImage(in_videoDriver->getTexture("../media/gameSettings.jpg"));
		_mainMenuElements.push_back(button);
		elementPosition.Y += elementSeperation + elementSize.Height;
		button = in_guiEnv->addButton(irr::core::recti(elementPosition, elementSize), nullptr, MenuElement::VideoSettingsBtn, L"Video Settings");
		//button->setImage(in_videoDriver->getTexture("../media/videoSettings.jpg"));
		_mainMenuElements.push_back(button);
		elementPosition.Y += elementSeperation + elementSize.Height;
		button = in_guiEnv->addButton(irr::core::recti(elementPosition, elementSize), nullptr, MenuElement::QuitBtn, L"Quit");
		//button->setImage(in_videoDriver->getTexture("../media/quitGame.jpg"));
		_mainMenuElements.push_back(button);
		//set the video settings menu
		elementPosition.Y = in_menuRect.UpperLeftCorner.Y;
		auto resImage = in_guiEnv->addImage(irr::core::recti(elementPosition, elementSize));
		resImage->setText(L"Select the desired resolution");
		//resImage->setImage(in_videoDriver->getTexture("../media/Resolution.jpg"));
		_videoSettingsElements.push_back(resImage);
		elementPosition.Y += elementSeperation + elementSize.Height;
		auto listBox = in_guiEnv->addListBox(irr::core::recti(elementPosition, irr::core::dimension2di(elementSize.Width,in_menuRect.getHeight()- (elementSize.Height + 2.0f * elementSeperation))), nullptr, MenuElement::ResolutionDropDown, true);
		listBox->addItem(L"800x600");
		listBox->addItem(L"1024x768");
		listBox->addItem(L"1200x1600");
		listBox->setSelected(0);
		_videoSettingsElements.push_back(listBox);
		//add buttons at the bottom to both game and setting menu
		elementPosition.Y = in_menuRect.UpperLeftCorner.Y + in_menuRect.getHeight();
		elementSize.Width = (elementSize.Width - elementSeperation) / 2.0f;
		button = in_guiEnv->addButton(irr::core::recti(elementPosition, elementSize), nullptr, MenuElement::BackToMainMenuBtn, L"Back to Main Menu");
		//button->setImage(in_videoDriver->getTexture("../media/backToMainMenu.jpg"));
		_videoSettingsElements.push_back(button);
		_gameSettingsElements.push_back(button);
		elementPosition.X += elementSize.Width + elementSeperation;
		button = in_guiEnv->addButton(irr::core::recti(elementPosition, elementSize), nullptr, MenuElement::SetVideoSettingsBtn, L"Apply (restart game)");
		//button->setImage(in_videoDriver->getTexture("../media/setVideoSettings.jpg"));
		_videoSettingsElements.push_back(button);
		button = in_guiEnv->addButton(irr::core::recti(elementPosition, elementSize), nullptr, MenuElement::SetGameSettingsBtn, L"Apply (restart game)");
		//button->setImage(in_videoDriver->getTexture("../media/setGameSettings.jpg"));
		_gameSettingsElements.push_back(button);
		//set the game settings menu
		elementPosition.Y = in_menuRect.UpperLeftCorner.Y;
		auto spinBox = in_guiEnv->addSpinBox(L"Number of AI players", irr::core::recti(elementPosition, elementSize),true,nullptr,MenuElement::MazeNumOfAI);
		spinBox->setDecimalPlaces(0);
		spinBox->setRange(0.0f, 10.0f);
		spinBox->setValue(3.0f);
		_gameSettingsElements.push_back(spinBox);
		elementPosition.Y += elementSeperation + elementSize.Height;
		spinBox = in_guiEnv->addSpinBox(L"AI level", irr::core::recti(elementPosition, elementSize), true, nullptr, MenuElement::MazeAIDifficultyLevel);
		spinBox->setDecimalPlaces(0);
		spinBox->setRange(1.0f, 10.0f);
		spinBox->setValue(3.0f);
		_gameSettingsElements.push_back(spinBox);
		elementPosition.Y += elementSeperation + elementSize.Height;
		spinBox = in_guiEnv->addSpinBox(L"Maze Width", irr::core::recti(elementPosition, elementSize), true, nullptr, MenuElement::MazeWidth);
		spinBox->setDecimalPlaces(0);
		spinBox->setRange(20.0f, 60.0f);
		spinBox->setStepSize(2.0f);
		spinBox->setValue(30.0f);
		_gameSettingsElements.push_back(spinBox);
		elementPosition.Y += elementSeperation + elementSize.Height;
		spinBox = in_guiEnv->addSpinBox(L"Maze Height", irr::core::recti(elementPosition, elementSize), true, nullptr, MenuElement::MazeHeight);
		spinBox->setDecimalPlaces(0);
		spinBox->setRange(20.0f, 60.0f);
		spinBox->setStepSize(2.0f);
		spinBox->setValue(30.0f);
		_gameSettingsElements.push_back(spinBox);
		elementPosition = in_menuRect.UpperLeftCorner;
		_gameSettingsElements.push_back( in_guiEnv->addStaticText(L"Number of AI players:", irr::core::recti(elementPosition, elementSize)));
		elementPosition.Y += elementSeperation + elementSize.Height;
		_gameSettingsElements.push_back(in_guiEnv->addStaticText(L"AI Level:", irr::core::recti(elementPosition, elementSize)));
		elementPosition.Y += elementSeperation + elementSize.Height;
		_gameSettingsElements.push_back(in_guiEnv->addStaticText(L"Maze Width:", irr::core::recti(elementPosition, elementSize)));
		elementPosition.Y += elementSeperation + elementSize.Height;
		_gameSettingsElements.push_back(in_guiEnv->addStaticText(L"Maze Length:", irr::core::recti(elementPosition, elementSize)));
		elementPosition.Y += elementSeperation + elementSize.Height;

		//hide all menu elements
		setMenuEnabled(false, _mainMenuElements);
		setMenuEnabled(false, _gameSettingsElements);
		setMenuEnabled(false, _videoSettingsElements);
		_menuBackground->setVisible(false);
		_currentMenu = CurrentMenu::None;

		LOG(DEBUG) << "Finished initializing menu";
	}