void MidiKeyboardComponent::drawBlackNote (int /*midiNoteNumber*/, Graphics& g, Rectangle<float> area, bool isDown, bool isOver, Colour noteFillColour) { auto c = noteFillColour; if (isDown) c = c.overlaidWith (findColour (keyDownOverlayColourId)); if (isOver) c = c.overlaidWith (findColour (mouseOverKeyOverlayColourId)); g.setColour (c); g.fillRect (area); if (isDown) { g.setColour (noteFillColour); g.drawRect (area); } else { g.setColour (c.brighter()); auto sideIndent = 1.0f / 8.0f; auto topIndent = 7.0f / 8.0f; auto w = area.getWidth(); auto h = area.getHeight(); switch (orientation) { case horizontalKeyboard: g.fillRect (area.reduced (w * sideIndent, 0).removeFromTop (h * topIndent)); break; case verticalKeyboardFacingLeft: g.fillRect (area.reduced (0, h * sideIndent).removeFromRight (w * topIndent)); break; case verticalKeyboardFacingRight: g.fillRect (area.reduced (0, h * sideIndent).removeFromLeft (w * topIndent)); break; default: break; } } }
int main(int argc, char **argv) { // Have a look in the header file above (it won't exist until you've run // lesson_10_generate). At the bottom is the signature of the function we generated: // int brighter(buffer_t *_input_buffer, uint8_t _offset, buffer_t *_brighter_buffer); // The ImageParam inputs have become pointers to "buffer_t" // structs. This is struct that Halide uses to represent arrays of // data. Unless you're calling the Halide pipeline from pure C // code, you don't want to use it directly. Halide::Buffer will // implicitly convert to a buffer_t *, so we can pass // Halide::Buffer objects in those slots. // The return value is an error code. It's zero on success. // Let's make a buffer for our input and output. Halide::Buffer<uint8_t> input(640, 480), output(640, 480); // Halide::Buffer also has constructors that wrap existing // data instead of allocating new memory. Use these if you // have your own Image type that you want to use. int offset = 5; int error = brighter(input, offset, output); if (error) { printf("Halide returned an error: %d\n", error); return -1; } // Now let's check the filter performed as advertised. It was // supposed to add the offset to every input pixel. for (int y = 0; y < 480; y++) { for (int x = 0; x < 640; x++) { uint8_t input_val = input(x, y); uint8_t output_val = output(x, y); uint8_t correct_val = input_val + offset; if (output_val != correct_val) { printf("output(%d, %d) was %d instead of %d\n", x, y, output_val, correct_val); return -1; } } } // Everything worked! printf("Success!\n"); return 0; }
void ImageNavigator::initializeActions() { setAttribute(Qt::WA_DeleteOnClose); menu = mainMenuBar->addMenu("Focus Viewer"); QSignalMapper *signalMap = new QSignalMapper(this); QAction *showFullScreenAction = new QAction(tr("Show Full Screen"), this); showFullScreenAction->setShortcut(tr("Ctrl+F")); showFullScreenAction->setCheckable(true); connect(showFullScreenAction, SIGNAL(toggled(bool)), this, SLOT(enableFullScreen(bool))); menu->addAction(showFullScreenAction); toggleInfoToolAction = new QAction(tr("Display Coordinate Info"), this); toggleInfoToolAction->setShortcut(tr("I")); toggleInfoToolAction->setCheckable(true); addAction(toggleInfoToolAction); connect(toggleInfoToolAction, SIGNAL(triggered()), this, SLOT(toggleInfoTool())); menu->addAction(toggleInfoToolAction); // #ifdef Q_OS_MAC QMenu *zoomMenu = new QMenu("Zoom", this); menu->addMenu(zoomMenu); QAction *zoomInAction = new QAction(tr("Zoom In"), this); zoomInAction->setShortcut(tr(".")); addAction(zoomInAction); connect(zoomInAction, SIGNAL(triggered()), this, SLOT(zoomIn())); zoomMenu->addAction(zoomInAction); QAction *zoomOutAction = new QAction(tr("Zoom Out"), this); zoomOutAction->setShortcut(tr(",")); addAction(zoomOutAction); connect(zoomOutAction, SIGNAL(triggered()), this, SLOT(zoomOut())); zoomMenu->addAction(zoomOutAction); QAction *zoomStandardAction = new QAction(tr("Zoom Standard"), this); zoomStandardAction->setShortcut(tr("Space")); addAction(zoomStandardAction); connect(zoomStandardAction, SIGNAL(triggered()), this, SLOT(zoomStandard())); zoomMenu->addAction(zoomStandardAction); menu->addMenu(zoomMenu); //#endif toggleColorToolAction = new QAction(tr("Adjust Contrast/Brightness"), this); toggleColorToolAction->setShortcut(tr("O")); toggleColorToolAction->setCheckable(true); addAction(toggleColorToolAction); connect(toggleColorToolAction, SIGNAL(triggered()), this, SLOT(toggleColorTool())); menu->addAction(toggleColorToolAction); // #ifdef Q_OS_MAC // CHEN: 4.1.2015 // if(imageType =="fft") // { QMenu *brighterMenu = new QMenu("Quick-Adjust Brightness", this); menu->addMenu(brighterMenu); QAction *brighterAction = new QAction(tr("Brighter"), this); brighterAction->setShortcut(tr("b")); addAction(brighterAction); connect(brighterAction, SIGNAL(triggered()), this, SLOT(brighter())); brighterMenu->addAction(brighterAction); QAction *darkerAction = new QAction(tr("Darker"), this); darkerAction->setShortcut(tr("n")); addAction(darkerAction); connect(darkerAction, SIGNAL(triggered()), this, SLOT(darker())); brighterMenu->addAction(darkerAction); // } // #endif toggleMouseAssignAction = new QAction(tr("Show Mouse Button Assignment"), this); toggleMouseAssignAction->setShortcut(tr("M")); toggleMouseAssignAction->setCheckable(true); addAction(toggleMouseAssignAction); connect(toggleMouseAssignAction, SIGNAL(triggered()), this, SLOT(toggleAssignTool())); menu->addAction(toggleMouseAssignAction); QAction *screenshot = new QAction(tr("Screen Shot"), this); screenshot->setShortcut(tr("G")); addAction(screenshot); connect(screenshot, SIGNAL(triggered()), image, SLOT(grabScreen())); menu->addAction(screenshot); int projectMode = projectData.projectMode().toInt(); if (imageType == "fft") { viewDisplayParametersAction = new QAction(tr("Display Parameters"), this); viewDisplayParametersAction->setShortcut(tr("D")); viewDisplayParametersAction->setCheckable(true); addAction(viewDisplayParametersAction); connect(viewDisplayParametersAction, SIGNAL(triggered()), this, SLOT(toggleDisplayParameters())); menu->addAction(viewDisplayParametersAction); toggleCTFViewAction = new QAction(tr("View CTF"), this); toggleCTFViewAction->setShortcut(tr("C")); // toggleCTFViewAction->setShortcutContext(Qt::WidgetWithChildrenShortcut); toggleCTFViewAction->setCheckable(true); addAction(toggleCTFViewAction); connect(toggleCTFViewAction, SIGNAL(triggered()), this, SLOT(toggleCTFView())); //connect(toggleCTFViewAction,SIGNAL(triggered()),image,SLOT(toggleCTFView())); menu->addAction(toggleCTFViewAction); if (projectMode == 1) { QAction *displayMillerIndicesAction = new QAction(tr("Show Miller Indices"), this); displayMillerIndicesAction->setShortcut(tr("Shift+D")); displayMillerIndicesAction->setCheckable(true); addAction(displayMillerIndicesAction); connect(displayMillerIndicesAction, SIGNAL(triggered()), signalMap, SLOT(map())); signalMap->setMapping(displayMillerIndicesAction, "millerindices"); menu->addAction(displayMillerIndicesAction); QAction *viewPSPeaksAction = new QAction(tr("View Peak List"), this); viewPSPeaksAction->setShortcut(tr("Shift+P")); viewPSPeaksAction->setCheckable(true); addAction(viewPSPeaksAction); connect(viewPSPeaksAction, SIGNAL(triggered()), signalMap, SLOT(map())); signalMap->setMapping(viewPSPeaksAction, "pspeaklist"); connect(signalMap, SIGNAL(mapped(const QString &)), image, SLOT(toggleVisible(const QString &))); menu->addAction(viewPSPeaksAction); QAction *loadPSPeaksAction = new QAction(tr("Load Peak List"), this); loadPSPeaksAction->setShortcut(tr("Shift+L")); addAction(loadPSPeaksAction); connect(loadPSPeaksAction, SIGNAL(triggered()), this, SLOT(selectPSList())); menu->addAction(loadPSPeaksAction); } QMenu *spotSelection = new QMenu("Spot Selection"); if (projectMode == 1) menu->addMenu(spotSelection); togglePeakListAction = new QAction(tr("Identify Spots"), spotSelection); togglePeakListAction->setShortcut(tr("P")); togglePeakListAction->setCheckable(true); if (projectMode == 1) { addAction(togglePeakListAction); connect(togglePeakListAction, SIGNAL(triggered()), image, SLOT(togglePeakList())); spotSelection->addAction(togglePeakListAction); } enterSpotSelectionModeAction = new QAction(tr("Enter Spot Selection Mode"), spotSelection); enterSpotSelectionModeAction->setCheckable(true); enterSpotSelectionModeAction->setShortcut(tr("Ctrl+P")); if (projectMode == 1) { addAction(enterSpotSelectionModeAction); connect(enterSpotSelectionModeAction, SIGNAL(triggered()), this, SLOT(toggleSpotSelectMode())); spotSelection->addAction(enterSpotSelectionModeAction); } savePeakListAction = new QAction(tr("Save Spot List"), spotSelection); savePeakListAction->setShortcut(tr("Ctrl+Shift+S")); if (projectMode == 1) { addAction(savePeakListAction); savePeakListAction->setDisabled(true); connect(savePeakListAction, SIGNAL(triggered()), image, SLOT(savePeakList())); spotSelection->addAction(savePeakListAction); } loadPeakListAction = new QAction(tr("Reload Spot List"), spotSelection); loadPeakListAction->setShortcut(tr("Ctrl+R")); if (projectMode == 1) { addAction(loadPeakListAction); loadPeakListAction->setDisabled(true); connect(loadPeakListAction, SIGNAL(triggered()), image, SLOT(loadPeakList())); connect(loadPeakListAction, SIGNAL(triggered()), image, SLOT(update())); spotSelection->addAction(loadPeakListAction); } clearPeakListAction = new QAction(tr("Clear Spot List"), spotSelection); clearPeakListAction->setShortcut(tr("Ctrl+Shift+C")); if (projectMode == 1) { addAction(clearPeakListAction); clearPeakListAction->setDisabled(true); connect(clearPeakListAction, SIGNAL(triggered()), image, SLOT(clearPeakList())); spotSelection->addAction(clearPeakListAction); } QMenu *latticeRefinement = new QMenu("Lattice Refinement"); if (projectMode == 1) menu->addMenu(latticeRefinement); toggleLatticeViewAction = new QAction(tr("View Lattice"), latticeRefinement); toggleLatticeViewAction->setShortcut(tr("L")); toggleLatticeViewAction->setCheckable(true); if (projectMode == 1) { addAction(toggleLatticeViewAction); connect(toggleLatticeViewAction, SIGNAL(triggered()), image, SLOT(toggleLatticeView())); latticeRefinement->addAction(toggleLatticeViewAction); QAction *toggleSecondLatticeViewAction = new QAction(tr("View Second Lattice"), latticeRefinement); toggleSecondLatticeViewAction->setShortcut(tr("S")); toggleSecondLatticeViewAction->setCheckable(true); addAction(toggleSecondLatticeViewAction); connect(toggleSecondLatticeViewAction, SIGNAL(triggered()), image, SLOT(toggleSecondLatticeView())); latticeRefinement->addAction(toggleSecondLatticeViewAction); } enterLatticeRefinementModeAction = new QAction(tr("Enter Lattice Refinement Mode"), latticeRefinement); enterLatticeRefinementModeAction->setShortcut(tr("Shift+R")); enterLatticeRefinementModeAction->setCheckable(true); if (projectMode == 1) { addAction(enterLatticeRefinementModeAction); connect(enterLatticeRefinementModeAction, SIGNAL(triggered()), this, SLOT(toggleLatticeRefinementMode())); latticeRefinement->addAction(enterLatticeRefinementModeAction); } addRefinementPointAction = new QAction(tr("Add Refinement Spot"), latticeRefinement); addRefinementPointAction->setShortcuts(QList<QKeySequence>() << tr("Enter") << tr("Return")); addRefinementPointAction->setEnabled(false); if (projectMode == 1) { addAction(addRefinementPointAction); connect(addRefinementPointAction, SIGNAL(triggered()), latticeTool, SLOT(insertPoint())); latticeRefinement->addAction(addRefinementPointAction); } } else { toggleLatticeViewAction = new QAction(tr("View Lattice"), this); toggleLatticeViewAction->setShortcut(tr("L")); toggleLatticeViewAction->setCheckable(true); if (projectMode == 1) { addAction(toggleLatticeViewAction); menu->addAction(toggleLatticeViewAction); connect(toggleLatticeViewAction, SIGNAL(triggered()), signalMap, SLOT(map())); signalMap->setMapping(toggleLatticeViewAction, "realLattice"); connect(signalMap, SIGNAL(mapped(const QString &)), image, SLOT(toggleVisible(const QString &))); } toggleParticlesViewAction = new QAction(tr("View Particles"), this); toggleParticlesViewAction->setShortcut(tr("P")); toggleParticlesViewAction->setCheckable(true); if (projectMode == 2) { addAction(toggleParticlesViewAction); menu->addAction(toggleParticlesViewAction); connect(toggleParticlesViewAction, SIGNAL(triggered()), image, SLOT(toggleParticleView())); } QMenu *fftSelectionMenu = new QMenu("Selection based FFT"); QAction *fftSelectionAction = new QAction(tr("FFT of Selection"), this); fftSelectionMenu->addAction(fftSelectionAction); fftSelectionAction->setShortcut(tr("Shift+F")); fftSelectionAction->setCheckable(true); addAction(fftSelectionAction); connect(fftSelectionAction, SIGNAL(triggered()), this, SLOT(toggleFFTSelection())); if (projectMode == 1) { QAction *setReferenceOriginAction = new QAction(tr("Set Reference Origin"), this); fftSelectionMenu->addAction(setReferenceOriginAction); setReferenceOriginAction->setShortcut(tr("Shift+O")); addAction(setReferenceOriginAction); connect(setReferenceOriginAction, SIGNAL(triggered()), this, SLOT(setReferenceOrigin())); connect(setReferenceOriginAction, SIGNAL(triggered()), spotSelect, SLOT(updateReferenceOrigin())); } menu->addMenu(fftSelectionMenu); selectionMenu = new QMenu("Polygonal Selection"); if (projectMode == 1) { QAction *selectionAreaAction = new QAction(tr("Polygonal Selection Masking"), this); selectionMenu->addAction(selectionAreaAction); selectionAreaAction->setShortcut(tr("Shift+S")); selectionAreaAction->setCheckable(true); addAction(selectionAreaAction); connect(selectionAreaAction, SIGNAL(triggered()), this, SLOT(toggleCreatePathMode())); QAction *saveSelectionArea = new QAction(tr("Save Selection"), this); selectionMenu->addAction(saveSelectionArea); saveSelectionArea->setShortcut(tr("Ctrl+Shift+S")); addAction(saveSelectionArea); connect(saveSelectionArea, SIGNAL(triggered()), image, SLOT(saveSelectionList())); QAction *clearSelectionArea = new QAction(tr("Clear Selection"), this); selectionMenu->addAction(clearSelectionArea); clearSelectionArea->setShortcut(tr("Ctrl+Shift+C")); addAction(clearSelectionArea); connect(clearSelectionArea, SIGNAL(triggered()), image, SLOT(clearSelectionVertices())); menu->addMenu(selectionMenu); QMenu *referenceMenu = new QMenu("Unbending References", menu); QAction *toggleBoxa1Action = new QAction(tr("View Boxa1"), this); toggleBoxa1Action->setCheckable(true); referenceMenu->addAction(toggleBoxa1Action); addAction(toggleBoxa1Action); connect(toggleBoxa1Action, SIGNAL(triggered()), this, SLOT(toggleBoxa1())); QAction *toggleBoxa2Action = new QAction(tr("View Boxa2"), this); toggleBoxa2Action->setCheckable(true); referenceMenu->addAction(toggleBoxa2Action); addAction(toggleBoxa2Action); connect(toggleBoxa2Action, SIGNAL(triggered()), this, SLOT(toggleBoxa2())); QAction *toggleBoxb1Action = new QAction(tr("View Boxb1"), this); toggleBoxb1Action->setCheckable(true); referenceMenu->addAction(toggleBoxb1Action); addAction(toggleBoxb1Action); connect(toggleBoxb1Action, SIGNAL(triggered()), this, SLOT(toggleBoxb1())); QAction *toggleBoxb2Action = new QAction(tr("View Boxb2"), this); toggleBoxb2Action->setCheckable(true); referenceMenu->addAction(toggleBoxb2Action); addAction(toggleBoxb2Action); connect(toggleBoxb2Action, SIGNAL(triggered()), this, SLOT(toggleBoxb2())); menu->addMenu(referenceMenu); QAction *setPhaseOriginAction = new QAction(tr("Set Phase Origin"), this); menu->addAction(setPhaseOriginAction); setPhaseOriginAction->setShortcut(tr("Shift+P")); addAction(setPhaseOriginAction); connect(setPhaseOriginAction, SIGNAL(triggered()), this, SLOT(setPhaseOrigin())); } } if (projectMode == 1) { QAction *showTiltAxisAction = new QAction(tr("View Tilt Axis in Raw Image (TLTAXIS)"), this); menu->addAction(showTiltAxisAction); showTiltAxisAction->setCheckable(true); showTiltAxisAction->setShortcut(tr("T")); addAction(showTiltAxisAction); connect(showTiltAxisAction, SIGNAL(triggered()), signalMap, SLOT(map())); signalMap->setMapping(showTiltAxisAction, "tiltaxis"); connect(signalMap, SIGNAL(mapped(const QString &)), image, SLOT(toggleVisible(const QString &))); QAction *showTaxisAction = new QAction(tr("View Tilt Axis in Final Map (TAXA)"), this); menu->addAction(showTaxisAction); showTaxisAction->setCheckable(true); showTaxisAction->setShortcut(tr("Shift+T")); addAction(showTaxisAction); connect(showTaxisAction, SIGNAL(triggered()), signalMap, SLOT(map())); signalMap->setMapping(showTaxisAction, "tiltaxa"); connect(signalMap, SIGNAL(mapped(const QString &)), image, SLOT(toggleVisible(const QString &))); } QAction *helpAction = new QAction(tr("Help"), this); helpAction->setShortcut(tr("H")); helpAction->setCheckable(true); addAction(helpAction); connect(helpAction, SIGNAL(triggered()), this, SLOT(toggleHelp())); menu->addAction(helpAction); closeAction = new QAction(tr("Close"), this); closeAction->setShortcut(tr("Esc")); addAction(closeAction); connect(closeAction, SIGNAL(triggered()), this, SLOT(closeCurrent())); menu->addAction(closeAction); // menuBar->addMenu(menu); }
hsv_colour hsv_colour::with_brightness(double aNewBrightness) const { return brighter(0.0, aNewBrightness); }
hsv_colour hsv_colour::brighter(double aDelta) const { return brighter(1.0, aDelta); }