void ImageWidget::contextMenuEvent(QContextMenuEvent *event) { QMenu menu; if (mType == Photo) { if (!mReadOnly) { menu.addAction(i18n("Change photo..."), this, SLOT(changeImage())); menu.addAction(i18n("Change URL..."), this, SLOT(changeUrl())); } if (mHasImage) { menu.addAction(i18n("Save photo..."), this, SLOT(saveImage())); if (!mReadOnly) { menu.addAction(i18n("Remove photo"), this, SLOT(deleteImage())); } } } else { if (!mReadOnly) { menu.addAction(i18n("Change logo..."), this, SLOT(changeImage())); menu.addAction(i18n("Change URL..."), this, SLOT(changeUrl())); } if (mHasImage) { menu.addAction(i18n("Save logo..."), this, SLOT(saveImage())); if (!mReadOnly) { menu.addAction(i18n("Remove logo"), this, SLOT(deleteImage())); } } } menu.exec(event->globalPos()); }
TestSuiteBasic::TestSuiteBasic() { m_imgPeriod = 30; m_imgChange.setInterval(20); connect(&m_imgChange, SIGNAL(timeout()), this, SLOT(changeImage())); m_pngFileName = ""; m_dicomFileName = ""; m_imgMapToColors = vtkImageMapToColors::New(); m_lookupTable = vtkWindowLevelLookupTable::New(); }
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ // void testApp::dragEvent(ofDragInfo dragInfo) { if( dragInfo.files.size() > 0 ) { // We are going to assume you are only dropping images on here. string tmpFilePath = dragInfo.files.at(0); changeImage(tmpFilePath); } }
/** * \brief Constructeur de l'éditeur d'Image * \param i Image ressource */ ImageEditor::ImageEditor(Image *i, QWidget *parent) : BinaryEditor(i, parent), resource(i) { label = new QLabel(); image = new QPixmap(resource->getPath()); label->setPixmap(*image); layout->addWidget(label); if (resource->getPath() == ""){ imageButton = new QPushButton("Choisir une image"); } else { imageButton = new QPushButton("Changer l'image"); } layout->addWidget(imageButton); QObject::connect(imageButton, SIGNAL(clicked()), this, SLOT(changeImage())); }
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ // void testApp::setup() { // set this to NULL so we can check for that currentImagePixels = NULL; // Start with an image changeImage( "color-spectrum.jpeg" ); rgbLightAmount = 16; // allocate the right amount of color objects colors = new ofColor[rgbLightAmount]; mouseX = 0; mouseY = 0; // How many DMX channels we need to address, each 'pixel' needs 3 channels // and we add 1 as arrays start with 0 but DMX channels start with 1 dmxChannelAmount = (rgbLightAmount * 3) + 1; // allocate enough bytes for all the DMX channels we want and also start them at 0 dmxPacket = new unsigned char[dmxChannelAmount]; for( int i = 0; i < dmxChannelAmount; i++ ) { dmxPacket[i] = 0; } // clear it // Set the address, depending on whether we are on OSX or Windows, this might be different on your machine! #ifdef TARGET_WIN32 string serialPortAddress = "COM3"; #else string serialPortAddress = "/dev/tty.usbserial-EN079717"; #endif //Try to connect to that address, also give it the amount of channels we will be using bool isConnected = dmxOut.connect(serialPortAddress, dmxChannelAmount ); // Output an error to the console if we fail if( !isConnected ) { ofLogError() << "We failed to connect to " << serialPortAddress << endl; } }
void DisplayImageConverter::convertImages(const QImage & a, const QImage & b) { //allocate image if it isn't if (m_previewImage.isNull() || m_previewImage.size() != a.size()) { m_previewImage = QImage(a.size(), a.format()); } //composite images QPainter painter(&m_previewImage); painter.setCompositionMode(QPainter::CompositionMode_Source); painter.fillRect(m_previewImage.rect(), Qt::black); qreal alphaB = crossFadeValue.normalizedValue(); qreal alphaA = 1.0 - alphaB; if (alphaA <= alphaB) { painter.drawImage(0, 0, a); painter.setCompositionMode(QPainter::CompositionMode_SourceOver); painter.setOpacity(alphaB); painter.drawImage(0, 0, b); } else { painter.drawImage(0, 0, b); painter.setCompositionMode(QPainter::CompositionMode_SourceOver); painter.setOpacity(alphaA); painter.drawImage(0, 0, a); } //scale image down to real size m_displayImage = m_previewImage.scaled(displayWidth, displayHeight, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); //do image correction float brightness = displayBrightness / 50.0f; float contrast = (displayContrast + 50.0f) / 100.0f * 2.0f; float gamma = displayGamma / 220.0f; m_displayImage = changeImage(m_displayImage, brightness, contrast, gamma); //send results displayImageChanged(m_displayImage); previewImageChanged(m_previewImage); }
GroupWidget::GroupWidget(Group* g, MainWindow* w):QWidget() { group = g; mW = w; std::vector<int> ploplop; std::vector<int>* vect = g->getVect(); kontacts = new std::vector<Kontact*>; Kontact* kon; int i; int n = vect->size(); for(i=0; i<n; ++i) { kon = w->askKontact( (*vect)[i] ); if(kon != 0) kontacts->push_back(kon); ploplop.push_back( (*vect)[i] ); } //ici algo foireux std::vector<int>* ginc = g->getInclusion(); i = 0; int k,j; Group* gBis; std::vector<int> protection; protection.push_back( g->getId() ); while( i < ginc->size() ) { //On inclut les contact du groupe gBis = mW->getGroupById((*ginc)[i]); if( gBis!= 0 ) { k = gBis->getVect()->size(); protection.push_back( gBis->getId() ); for(j=0; j<k; ++j) { if( !contains( ploplop, (*(gBis->getVect()))[j] ) ) { kon = w->askKontact( (*(gBis->getVect()))[j] ); if(kon != 0) kontacts->push_back(kon); ploplop.push_back( (*(gBis->getVect()))[j] ); } } k= gBis->getInclusion()->size();; for(j=0; j<k; ++j) { if( !contains(protection, (*(gBis->getInclusion()))[j]) ) ginc->push_back( (*(gBis->getInclusion()))[j] ); } } ++i; } //retour à la normale sort( kontacts->begin(), kontacts->end(), rel); titre = new QLabel; titre->setText(tr("<h1>Groupe ")+ g->getName() +"</h1>"); titre->setTextInteractionFlags( Qt::TextSelectableByMouse ); titleLayout = new QHBoxLayout; imageButton = new QPushButton(); imageLabel = new QLabel(imageButton); imageLabel->setMaximumSize(50,50); imageLabel->setScaledContents(true); if(group->getImage() != "0") { imageLabel->setPixmap( group->getImage() ); debug( "Group image path :: " + group->getImage() ); } imageLabel->setMargin(5); imageButton->setMaximumSize(50,50); imageButton->setMinimumSize(50,50); titleLayout->addWidget(imageButton); titleLayout->addWidget(titre); doublonWidget = new DoublonWidget(kontacts, w, true); mainLayout = new QVBoxLayout; mainLayout->addLayout( titleLayout ); mainLayout->addWidget( doublonWidget ); buttonLayout = new QHBoxLayout; mAdd = new QPushButton(tr("Ajouter des kontacts")); mAdd->setMaximumSize(mAdd->sizeHint()); buttonLayout->addWidget(mAdd); mMailAll = new QPushButton(tr("Envoyer un mail à tous")); mMailAll->setMaximumSize(mMailAll->sizeHint()); buttonLayout->addWidget(mMailAll); mainLayout->addLayout(buttonLayout); this->setLayout( mainLayout ); connect(mMailAll, SIGNAL( clicked() ), this, SLOT( mailAll() ) ); connect(doublonWidget, SIGNAL( please(int) ), this, SLOT( pleaseTrt(int))); connect(mAdd, SIGNAL( clicked() ), this, SLOT( addK() )); connect(imageButton, SIGNAL( clicked() ), this, SLOT( changeImage() ) ); connect(mW, SIGNAL( printRequest() ), this, SLOT( print() ) ); }
void ChangeGUI::callChangeImage(int __value){ changeImage(__value); }
void BubbleHardwareManager::onComboBoardNameChanged(wxCommandEvent &event) { if (comboBoardName) { if (bubble && parent) { bool currentComponentSaved = bubble->isSaved(); wxString currentComponentName = bubble->getComponentFilesPath() + wxString(".mbqc"); //##Unhardcode if (getCurrentBoardProperties()) { //Find new seleted board's properties: BubbleBoardProperties *iterator = NULL; for (unsigned int i = 0; i < boardsProperties.GetCount(); i++) { iterator = &(boardsProperties.Item(i)); //##In theory, this is faster than the other index based form, but I'm not sure yet... if (iterator) { if (iterator->getName() == event.GetString()) { currentBoardProperties->set(iterator); } } } bubble->setBoardName(event.GetString(), parent); changeImage(); //##Debug: //wxMessageDialog dialog0(bubble->getParent(), getCurrentBoardProperties()->getPortType(), // getCurrentBoardProperties()->getName()); //##Debug. //dialog0.ShowModal(); //##Debug. if ( ((getCurrentBoardProperties())->getPortType() == wxString("HID")) || //##Unhardcode ((getCurrentBoardProperties())->getPortType() == wxString("HID2")) ) { setPortSelectorEnabled(false); setPortNameString((getCurrentBoardProperties())->getPortType()); } else { if (comboBootPortName) { wxString selectedPort = comboBootPortName->getText(); setPortSelectorEnabled(true); updatePorts(); if ( (comboBootPortName->getText() == wxString("HID")) || //##Unhardcode (comboBootPortName->getText() == wxString("HID2")) ) { setPortNameString(wxString("")); } else { if (comboBootPortName->textExists(selectedPort)) comboBootPortName->setSelection(selectedPort); else setPortNameString(wxString("")); } } } //Updates the generated code (for example, with the include files): bubble->loadBoardRelations(); if (getCurrentBoardProperties()) { if (buttonGoToDriversDir) { //Are there device drivers for this board? buttonGoToDriversDir->Enable(getCurrentBoardProperties()->getDriverPath() != wxString("")); //Are there links for this board? if (lblURL0) { lblURL0->SetURL(getCurrentBoardProperties()->getUrl0()); lblURL0->SetLabel(getCurrentBoardProperties()->getUrl0()); lblURL0->SetPosition(wxPoint(buttonGoToDriversDir->GetPosition().x, lblURL0->GetPosition().y)); } if (lblURL1) { lblURL1->SetURL(getCurrentBoardProperties()->getUrl1()); lblURL1->SetLabel(getCurrentBoardProperties()->getUrl1()); lblURL1->SetPosition(wxPoint(buttonGoToDriversDir->GetPosition().x, lblURL1->GetPosition().y)); } } } } ((MainFrame*)parent)->createComponent(true); if (currentComponentSaved) ((MainFrame*)parent)->loadFileComponent(currentComponentName); if ( ((MainFrame*)parent)->isShowingGeneratedCode() ) { ((MainFrame*)parent)->toggleGeneratedCode(); ((MainFrame*)parent)->toggleGeneratedCode(); } } } }
BubbleHardwareManager::BubbleHardwareManager( wxWindow* parent, wxWindowID id, Bubble *const bubble, const wxString& boardName, const wxColour& colour, const wxPoint& pos, const wxSize& size, long style, const wxString& name) : BubblePanel(parent, id, colour, true, pos, size, style, name ), parent(parent), bubble(bubble), boardName(boardName), currentBoardProperties(NULL), lblBootPortName(NULL), comboBootPortName(NULL), lblBoardName(NULL), comboBoardName(NULL), buttonReloadBlocks(NULL), buttonReloadHardware(NULL), lblURL0(NULL), lblURL1(NULL), buttonGoToDriversDir(NULL), buttonMainImage(NULL), emptyDummyString(wxString("")) { if (bubble == NULL) return; //Nothing to do. currentBoardProperties = new BubbleBoardProperties(); //Hide(); //##The following line crashes the application when the BubbleHardwareManager is closed by the user, so //##don't delete it, because it may be possibly a wxAUI's bug, and I would like to document it: //SetSize(400, 450); lblBoardName = new wxStaticText( this, wxNewId(), //## //##Future: Make configurable by the user if he want to see these //shorcuts on screen or not: _("Hardware (Alt+W):"), //##Load shorcuts from XML. wxPoint(10, 10), wxSize(150, 20), wxALIGN_CENTRE, wxString("lblBoardName") ); comboBoardName = new BubbleCombo( this, wxNewId(), wxImage(bubble->getThemePath() + wxString("/ComboSelectDefault.png")), wxImage(bubble->getThemePath() + wxString("/ComboSelectPressed.png")), wxImage(bubble->getThemePath() + wxString("/ComboSelectHover.png")), wxImage(bubble->getThemePath() + wxString("/ComboSelectDisabled.png")), false, wxPoint(10, 25), //##Make this automatic. wxSize(190, 16), //wxTAB_TRAVERSAL| //wxNO_BORDER| //wxBORDER_SIMPLE| //wxBORDER_RAISED| wxBORDER_SUNKEN| wxTRANSPARENT_WINDOW, //wxDefaultSize, //##wxALIGN_CENTRE, wxString("comboBoardName") ); if (comboBoardName) { comboBoardName->setSorted(false); bubble->loadHardwareTargets(this); boardName = "DuinoBot.v2.3 HID"; if (boardName == wxString("")) { selectFirstBoard(); } else { BubbleBoardProperties *initialBoard = NULL; initialBoard = &(boardsProperties.Item(0)); //Find board: bool found = false; BubbleBoardProperties *iterator = NULL; for (unsigned int i = 0; i < boardsProperties.GetCount(); i++) { iterator = &(boardsProperties.Item(i)); //##In theory, this is faster than the other index based form, but I'm not sure yet... if (iterator) { if (iterator->getName() == boardName) { initialBoard = iterator; currentBoardProperties->set(iterator); comboBoardName->setSelection(boardName); found = true; } } } if (!found) { selectFirstBoard(); } } comboBoardName->Connect(wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(BubbleHardwareManager::onComboBoardNameChanged), NULL, this ); } lblBootPortName = new wxStaticText( this, wxNewId(), //In the future there may be IP sockets, and other comm //channels, so here it's just "Port", not "Serial port": //##Future: Make configurable by the user if he want to see these //shorcuts on screen or not: _("Port (Alt+R):"), //##Load shorcuts from XML. wxPoint(210, 10), //##Un-hardcode! wxSize(150, 20), //##Un-hardcode! wxALIGN_CENTRE, wxString("lblBootSerialPortName") ); comboBootPortName = new BubbleCombo(this, wxNewId(), wxImage(bubble->getThemePath() + wxString("/ComboSelectDefault.png")), wxImage(bubble->getThemePath() + wxString("/ComboSelectPressed.png")), wxImage(bubble->getThemePath() + wxString("/ComboSelectHover.png")), wxImage(bubble->getThemePath() + wxString("/ComboSelectDisabled.png")), false, wxPoint(210, 25), //##Un-hardcode! wxSize(100, 16), //##Un-hardcode! wxBORDER_SUNKEN| wxTRANSPARENT_WINDOW, wxString("comboBootSerialPortName") ); if (comboBootPortName) { comboBootPortName->Connect( wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(BubbleHardwareManager::onUpdatePorts), NULL, this ); comboBootPortName->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(BubbleHardwareManager::onComboBootPortNameChanged), NULL, this ); updatePorts(); setPortType(); if (getCurrentBoardProperties()) { //This is necessary for the first time the system loads the boards: if ( (getCurrentBoardProperties()->getPortType() == wxString("HID")) || (getCurrentBoardProperties()->getPortType() == wxString("HID2")) ) { setPortSelectorEnabled(false); setPortNameString((getCurrentBoardProperties())->getPortType()); } } // comboBootPortName->setSelection(0); //##Un-hardcode and get the port from the config file... // wxString strCommRealName = wxString("//./") + comboBootPortName->getText(); // bubble->setBootPortName(strCommRealName); } buttonReloadBlocks = new wxButton( this, wxNewId(), _("Reload blocks"), wxPoint(10, 55), //##Un-hardcode! //wxDefaultSize, wxSize(160, 25), //##Future: The autosize (with the label) feature does now work. Make it work! wxBU_EXACTFIT ); //## if (buttonReloadBlocks) { buttonReloadBlocks->Connect(wxEVT_LEFT_UP, wxMouseEventHandler(BubbleHardwareManager::onButtonReloadBlocksLeftUp), NULL, this ); //buttonReloadBlocks->Hide(); //##Testing. // wxMessageDialog dialog0(bubble->getParent(), bubble->getProfile(), wxString("profile")); //##Debug. // dialog0.ShowModal(); //##Debug. // buttonReloadBlocks->Show(bubble->getProfile() == wxString("developer")); } buttonReloadHardware = new wxButton( this, wxNewId(), _("Reload hardware"), wxPoint(175, 55), //##Un-hardcode! //wxDefaultSize, wxSize(160, 25), //##Future: The autosize (with the label) feature does now work. Make it work! wxBU_EXACTFIT ); //## if (buttonReloadHardware) { buttonReloadHardware->Connect(wxEVT_LEFT_UP, wxMouseEventHandler(BubbleHardwareManager::onButtonButtonReloadHardwareLeftUp), NULL, this ); //buttonReloadHardware->Show(bubble->getProfile() == wxString("developer")); } buttonGoToDriversDir = new wxButton( this, wxNewId(), _("Open folder with drivers"), wxPoint(10, 85), //##Un-hardcode! //wxDefaultSize, wxSize(160, 25), //##Future: autosize. wxBU_EXACTFIT ); if (buttonGoToDriversDir) { buttonGoToDriversDir->Connect( wxEVT_LEFT_UP, wxMouseEventHandler(BubbleHardwareManager::onButtonGoToDriversDirLeftUp), NULL, this ); if (getCurrentBoardProperties()) { buttonGoToDriversDir->Enable(getCurrentBoardProperties()->getDriverPath() != wxString("")); lblURL0 = new wxHyperlinkCtrl( this, wxNewId(), getCurrentBoardProperties()->getUrl0(), getCurrentBoardProperties()->getUrl0(), wxPoint(buttonGoToDriversDir->GetPosition().x, buttonGoToDriversDir->GetPosition().y + buttonGoToDriversDir->GetSize().GetHeight() + 10), wxDefaultSize, wxHL_ALIGN_LEFT ); if (lblURL0) { lblURL0->SetVisitedColour(lblURL0->GetNormalColour()); //wxHyperlinkCtrl Bug: the first time, it should be created big. if (buttonReloadHardware) { lblURL0->SetSize(wxSize(buttonReloadHardware->GetPosition().x + buttonReloadHardware->GetSize().GetWidth() - buttonGoToDriversDir->GetPosition().x, lblURL0->GetSize().GetHeight() ) ); } lblURL1 = new wxHyperlinkCtrl( this, wxNewId(), getCurrentBoardProperties()->getUrl1(), getCurrentBoardProperties()->getUrl1(), wxPoint(lblURL0->GetPosition().x, lblURL0->GetPosition().y + lblURL0->GetSize().GetHeight() + 10), wxDefaultSize, wxHL_ALIGN_LEFT ); if (lblURL1) { lblURL1->SetVisitedColour(lblURL1->GetNormalColour()); if (lblURL0) lblURL1->SetSize(lblURL0->GetSize()); } } } } buttonMainImage = new BubbleButton( this, wxNewId(), wxPoint(0, 0), //##Un-hardcode! wxSize(32, 32) //##Un-hardcode! ); //##buttonIcon->SetValidator(wxDefaultValidator); changeImage(); //SetBackgroundColour(colour); SetBackgroundColourAndRefresh(colour); }
void CMO_line::update( float delta ) { if ( !m_Connected && CGameManager::GetInstance()->IsConnected(m_Index) == MO_LINE_CONNECTED) { CAudioManager::GetInstance()->PlayLineDrawRandomSE(); // 처음으로 연결되는 시점 // 이미지를 바꿔주고, 연결상태 플래그 변경 changeImage(); m_Connected = true; m_RecentConnection = true; CGameManager::GetInstance()->SetRecentConnectedLine(m_Index); // 애니메이션 관련 CCSpriteBatchNode* spritebatch = CCSpriteBatchNode::create(LineAnimationFileList[m_ImageFileIdx % 2].c_str()); CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache(); cache->addSpriteFramesWithFile(LineAnimationFileListPlist[m_ImageFileIdx % 2].c_str()); CCArray* animFrames = CCArray::createWithCapacity(48); char str[100] = {0}; for(int i = 1; i < 49; i++) { if(m_ImageFileIdx % 2==0) { sprintf(str, "ani_playscene_line_recent_v_000%02d.png", i); } else { sprintf(str, "ani_playscene_line_recent_000%02d.png", i); } CCSpriteFrame* frame = cache->spriteFrameByName( str ); animFrames->addObject(frame); } // 최근 연결 라인 강조 관련 CCSprite*pElement; if(m_ImageFileIdx % 2==0) { pElement = CCSprite::createWithSpriteFrameName("ani_playscene_line_recent_v_00001.png"); pElement->setAnchorPoint(ccp(1,0)); } else { pElement = CCSprite::createWithSpriteFrameName("ani_playscene_line_recent_00001.png"); pElement->setAnchorPoint(ccp(0,0)); } // 강조하는 라인으로 기존 라인을 덮어버림 ?? spritebatch->addChild(pElement); addChild(spritebatch,2); spritebatch->setTag(0); // 애니메이션 재생 CCAnimation* animation = CCAnimation::createWithSpriteFrames(animFrames,PLAYSCENE_ANIMATION_TIME/48); CCAction* myLine = CCAnimate::create(animation); pElement->runAction(myLine); } else if( m_Connected && m_RecentConnection && !(CGameManager::GetInstance()->GetRecentConnectedLine() == m_Index) ) { // 연결된 상태 + 강조된 상태 + 하지만 실제로 최근어 그어진 라인은 다른 라인 = 강조 상태 되돌리기 // 업데이트가 있어야만 진입하므로 실제로는 다른 선이 새로 그어질 때 호출 m_RecentConnection = false; removeChildByTag(0); pLine->setVisible(true); } }