//called when a property has been modified from the outside BOOL CPropertyWnd::PropertyModified(CPackerProperty* pProp) { //first off notify the packer m_pIPacker->PropertyChanged(pProp, &m_pPropMgr->GetPropList(), m_pPropMgr); //now the enabled status could have changed, so refresh it UpdateControlEnabledStatus(); //also update the values UpdateControlValues(); return TRUE; }
void TkpDisplayScrollbar( ClientData clientData) /* Information about window. */ { register TkScrollbar *scrollPtr = (TkScrollbar *) clientData; register MacScrollbar *macScrollPtr = (MacScrollbar *) clientData; register Tk_Window tkwin = scrollPtr->tkwin; MacDrawable *macDraw; CGrafPtr saveWorld; GDHandle saveDevice; GWorldPtr destPort; WindowRef windowRef; if ((scrollPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { goto done; } /* * Draw the focus or any 3D relief we may have. */ if (scrollPtr->highlightWidth != 0) { GC fgGC, bgGC; bgGC = Tk_GCForColor(scrollPtr->highlightBgColorPtr, Tk_WindowId(tkwin)); if (scrollPtr->flags & GOT_FOCUS) { fgGC = Tk_GCForColor(scrollPtr->highlightColorPtr, Tk_WindowId(tkwin)); TkpDrawHighlightBorder(tkwin, fgGC, bgGC, scrollPtr->highlightWidth, Tk_WindowId(tkwin)); } else { TkpDrawHighlightBorder(tkwin, bgGC, bgGC, scrollPtr->highlightWidth, Tk_WindowId(tkwin)); } } Tk_Draw3DRectangle(tkwin, Tk_WindowId(tkwin), scrollPtr->bgBorder, scrollPtr->highlightWidth, scrollPtr->highlightWidth, Tk_Width(tkwin) - 2*scrollPtr->highlightWidth, Tk_Height(tkwin) - 2*scrollPtr->highlightWidth, scrollPtr->borderWidth, scrollPtr->relief); /* * Set up port for drawing Macintosh control. */ macDraw = (MacDrawable *) Tk_WindowId(tkwin); destPort = TkMacGetDrawablePort(Tk_WindowId(tkwin)); GetGWorld(&saveWorld, &saveDevice); SetGWorld(destPort, NULL); TkMacSetUpClippingRgn(Tk_WindowId(tkwin)); if (macScrollPtr->sbHandle == NULL) { Rect r; WindowRef frontNonFloating; r.left = r.top = 0; r.right = r.bottom = 1; macScrollPtr->sbHandle = NewControl((WindowRef) destPort, &r, "\p", false, (short) 500, 0, 1000, scrollBarProc, (SInt32) scrollPtr); /* * If we are foremost than make us active. */ if (TkMacHaveAppearance() >= 0x110) { frontNonFloating = FrontNonFloatingWindow(); } else { frontNonFloating = FrontWindow(); } if ((WindowPtr) destPort == FrontWindow() || TkpIsWindowFloating((WindowPtr) destPort)) { macScrollPtr->macFlags |= ACTIVE; } } /* * Update the control values before we draw. */ windowRef = (**macScrollPtr->sbHandle).contrlOwner; UpdateControlValues(macScrollPtr); if (macScrollPtr->macFlags & ACTIVE) { Draw1Control(macScrollPtr->sbHandle); if (macScrollPtr->macFlags & DRAW_GROW) { DrawGrowIcon(windowRef); } } else { (**macScrollPtr->sbHandle).contrlHilite = 255; Draw1Control(macScrollPtr->sbHandle); if (macScrollPtr->macFlags & DRAW_GROW) { DrawGrowIcon(windowRef); Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), scrollPtr->bgBorder, Tk_Width(tkwin) - 13, Tk_Height(tkwin) - 13, Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT); } } SetGWorld(saveWorld, saveDevice); done: scrollPtr->flags &= ~REDRAW_PENDING; }
void TkpDisplayScrollbar( ClientData clientData) /* Information about window. */ { TkScrollbar *scrollPtr = (TkScrollbar *) clientData; MacScrollbar *macScrollPtr = (MacScrollbar *) clientData; Tk_Window tkwin = scrollPtr->tkwin; MacDrawable *macDraw; CGrafPtr saveWorld; GDHandle saveDevice; GWorldPtr destPort; WindowRef windowRef; if ((scrollPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { goto done; } /* * Draw the focus or any 3D relief we may have. */ if (scrollPtr->highlightWidth != 0) { GC fgGC, bgGC; bgGC = Tk_GCForColor(scrollPtr->highlightBgColorPtr, Tk_WindowId(tkwin)); if (scrollPtr->flags & GOT_FOCUS) { fgGC = Tk_GCForColor(scrollPtr->highlightColorPtr, Tk_WindowId(tkwin)); TkpDrawHighlightBorder(tkwin, fgGC, bgGC, scrollPtr->highlightWidth, Tk_WindowId(tkwin)); } else { TkpDrawHighlightBorder(tkwin, bgGC, bgGC, scrollPtr->highlightWidth, Tk_WindowId(tkwin)); } } Tk_Draw3DRectangle(tkwin, Tk_WindowId(tkwin), scrollPtr->bgBorder, scrollPtr->highlightWidth, scrollPtr->highlightWidth, Tk_Width(tkwin) - 2*scrollPtr->highlightWidth, Tk_Height(tkwin) - 2*scrollPtr->highlightWidth, scrollPtr->borderWidth, scrollPtr->relief); /* * Set up port for drawing Macintosh control. */ macDraw = (MacDrawable *) Tk_WindowId(tkwin); destPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin)); GetGWorld(&saveWorld, &saveDevice); SetGWorld(destPort, NULL); TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin)); if (macScrollPtr->sbHandle == NULL) { Rect r; SInt16 initialValue; SInt16 minValue; SInt16 maxValue; SInt16 procID; WindowRef frontNonFloating; r.left = r.top = 0; r.right = r.bottom = 1; minValue = MIN_SCROLLBAR_VALUE; maxValue = MAX_SCROLLBAR_VALUE; initialValue = (minValue + maxValue)/2; procID = kControlScrollBarLiveProc; windowRef = GetWindowFromPort(destPort); CreateScrollBarControl(windowRef, &r, initialValue, minValue, maxValue, maxValue - minValue, true, NULL, &(macScrollPtr->sbHandle)); SetControlReference(macScrollPtr->sbHandle, (SInt32) scrollPtr); /* * If we are foremost then make us active. */ frontNonFloating = FrontNonFloatingWindow(); if ((windowRef == FrontWindow()) || TkpIsWindowFloating(windowRef)) { macScrollPtr->macFlags |= ACTIVE; } } /* * Adjust the control size based on its width... */ if (macScrollPtr->info.width < 13) { SetControlData(macScrollPtr->sbHandle, kControlNoPart, kControlSizeTag, sizeof(kControlSizeSmall), (void *) kControlSizeSmall); } else { SetControlData(macScrollPtr->sbHandle, kControlNoPart, kControlSizeTag, sizeof(kControlSizeSmall), (void *) kControlSizeLarge); } /* * Update the control values before we draw. */ windowRef = GetControlOwner (macScrollPtr->sbHandle); UpdateControlValues(macScrollPtr); if (macScrollPtr->macFlags & ACTIVE) { Draw1Control(macScrollPtr->sbHandle); if (macScrollPtr->macFlags & DRAW_GROW) { DrawGrowIcon(windowRef); } } else { HiliteControl (macScrollPtr->sbHandle, 255 ); Draw1Control(macScrollPtr->sbHandle); if (macScrollPtr->macFlags & DRAW_GROW) { DrawGrowIcon(windowRef); Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), scrollPtr->bgBorder, Tk_Width(tkwin) - 13, Tk_Height(tkwin) - 13, Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT); } } SetGWorld(saveWorld, saveDevice); done: scrollPtr->flags &= ~REDRAW_PENDING; }
void TkpDisplayScrollbar( ClientData clientData) /* Information about window. */ { TkScrollbar *scrollPtr = (TkScrollbar *) clientData; MacScrollbar *macScrollPtr = (MacScrollbar *) clientData; Tk_Window tkwin = scrollPtr->tkwin; CGrafPtr destPort, savePort; Boolean portChanged; WindowRef windowRef; if ((scrollPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { goto done; } /* * Draw the focus or any 3D relief we may have. */ if (scrollPtr->highlightWidth != 0) { GC fgGC, bgGC; bgGC = Tk_GCForColor(scrollPtr->highlightBgColorPtr, Tk_WindowId(tkwin)); if (scrollPtr->flags & GOT_FOCUS) { fgGC = Tk_GCForColor(scrollPtr->highlightColorPtr, Tk_WindowId(tkwin)); TkpDrawHighlightBorder(tkwin, fgGC, bgGC, scrollPtr->highlightWidth, Tk_WindowId(tkwin)); } else { TkpDrawHighlightBorder(tkwin, bgGC, bgGC, scrollPtr->highlightWidth, Tk_WindowId(tkwin)); } } Tk_Draw3DRectangle(tkwin, Tk_WindowId(tkwin), scrollPtr->bgBorder, scrollPtr->highlightWidth, scrollPtr->highlightWidth, Tk_Width(tkwin) - 2*scrollPtr->highlightWidth, Tk_Height(tkwin) - 2*scrollPtr->highlightWidth, scrollPtr->borderWidth, scrollPtr->relief); if (macScrollPtr->sbHandle == NULL) { Rect r = {0, 0, 1, 1}; windowRef = TkMacOSXDrawableWindow(Tk_WindowId(tkwin)); CreateScrollBarControl(windowRef, &r, 0, 0, 0, 0, true, NULL, &(macScrollPtr->sbHandle)); SetControlReference(macScrollPtr->sbHandle, (SInt32) scrollPtr); if (IsWindowActive(windowRef)) { macScrollPtr->macFlags |= ACTIVE; } } /* * Update the control values before we draw. */ UpdateControlValues(macScrollPtr); /* * Set up port for drawing Macintosh control. */ destPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin)); portChanged = QDSwapPort(destPort, &savePort); TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin)); /* * Scrollbars do not erase the complete control bounds if they are wider * than the standard width, so manually erase the extra space. */ if (!EmptyRect(&macScrollPtr->eraseRect)) { EraseRect(&macScrollPtr->eraseRect); } Draw1Control(macScrollPtr->sbHandle); if (portChanged) { QDSwapPort(savePort, NULL); } done: scrollPtr->flags &= ~REDRAW_PENDING; }
void CGUIFaceInVideoView::OnDraw(CDC* pDC) { CGUIFaceInVideoDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if (pDoc == NULL) return; CIplImage *pImgIn; CvPoint *pPointL, *pPointR; int nNameTag, nBestMatch; char strMessage[200]; CPerceptualVisionSystem *pPVS = pDoc->getPVS(); bool bRes = pPVS->initializeNextFrame(); if (bRes == false) return; // if want to show it but not process it, change it. sprintf(strMessage, "%i msec", pPVS->m_tBetweenFrames); OnDraw_LogWindow(pDC, strMessage, set_window(0,0), 0); pDoc->m_gui.check_start = pDoc->m_gui.check_start; if (pDoc->m_gui.check_start == true) { int z; for (z=0; z < pPVS->m_pianoPlaying.m_nNumHands; z++) pPVS->m_pianoPlaying.m_Hand[z].destroy(); pPVS->m_pianoPlaying.m_nNumHands = 0; } ////////////AVI RECORDING////////////////// if (pDoc->m_recordCheck == true) // For saving video file made of video frames { pPVS->m_imgIn.draw(pDC->m_hDC, set_window(0,3), false, false); OnDraw_LogWindow(pDC, "Start recording..", set_window(0,3), 1); pPVS->m_bRecording = true; if (pPVS->m_bRecordingStarted == false) { // open a dialog box. TCHAR szFilter[] = _T ( "Movie Files (*.avi)" ); CFileDialog *dlg = new CFileDialog( FALSE, _T("avi"), _T("*.avi"), OFN_ENABLESIZING | OFN_OVERWRITEPROMPT, szFilter, (CWnd*)this); char strAviFullName[200], strAviLocalName[200]; if(dlg->DoModal() == IDOK) strcpy(strAviFullName, dlg->GetPathName()); pPVS->m_pCvVideoWriter = NULL; pPVS->m_pCvVideoWriter = cvCreateVideoWriter(strAviFullName, // Uncompressed CV_FOURCC('D','I','B',' '), 10.0, cvSize(160,120) ); pPVS->m_bRecordingStarted = true;// Open AVI file } //Add frame to AVI if (pPVS->m_pCvVideoWriter) cvWriteFrame( pPVS->m_pCvVideoWriter, pPVS->m_imgIn.getIplImage() ); return; } else { pPVS->m_bRecording = false; if (pPVS->m_bRecordingStarted == true) { pPVS->m_bRecordingStarted = false; // Close AVI if (pPVS->m_pCvVideoWriter) cvReleaseVideoWriter( &pPVS->m_pCvVideoWriter ); } } ////////////////END AVI RECORDING//////////////// /////////////////////// // return; //////// debuging..... /////////////////////// /***************************************************************************************/ /*** Grab data from MIDI **************************************************/ /***************************************************************************************/ int q, keyValue, octave; bool keyChange[200]; // bKeyChanged[nTotalPianoKeys] //To indicate Changes only //For printing Purposes if (m_bMidiCheck==false) { m_Midi->clearAllEvents(); } //DO MIDI INFORMATION if (USING_MIDI == 1 && m_bMidiCheck==true) { //Get MIDI Events m_Midi->getAllEvents(); //Update User Selected Offsets pPVS->m_pianoPlaying.m_Piano.UpdateOctave(m_nKeyOffset, m_nOctave); //No Changes to Start for (q=0; q < 200; q++) keyChange[q] = false; //Go Through All MIDI events for (q=0; q < m_Midi->numNotes; q++) { //If Key Has Been Pressed, set it as True if (keyDown[int(m_Midi->noteArray[q])] == true) { keyDown[int(m_Midi->noteArray[q])] = false; keyChange[int(m_Midi->noteArray[q])] = true; //Indicate Change } //Vice Versa else { keyDown[int(m_Midi->noteArray[q])] = true; keyChange[int(m_Midi->noteArray[q])] = true; //Indicate Change } } }//END MIDI /***************************************************************************************/ /*** Grab data from video camera / AVI **************************************************/ /***************************************************************************************/ sprintf(strMessage, "%i: %i (%i) msec ", pPVS->m_nFrame, pPVS->m_tBetweenFrames, pPVS->m_tBetweenFramesNow); // OnDraw_LogWindow(pDC, strMessage, set_window(0,2), 1); //Motion Channel Calculations pPVS->m_chanMotion.updateImages(&pPVS->m_imgIn); pPVS->m_chanMotion.compute_dI(); pPVS->m_chanMotion.compute_FG(3, 0); //////////////////////////PIANO PLAYING SECTION//////////////////////////// //Update Images pPVS->m_pianoPlaying.updateImages(&pPVS->m_imgIn); //Do Backgorund Initialization && Piano Key (width) Calibration if (runOnce == 0) { pPVS->m_pianoPlaying.setBackgroundImage(&pPVS->m_imgIn); runOnce++; } //Image Adjustment, based on Piano Orientation and Positioning pPVS->m_pianoPlaying.AdjustImages(); //Update Control Values from GUI UpdateControlValues(&(pPVS->m_pianoPlaying)); //Main Piano Playing Function pPVS->m_pianoPlaying.createHandsImage(); m_bDetectHands = false; //Reset Hand Detecting Flag /* // no Filter2D CIplImage img1; // , img2; img1.initializeAs(&pPVS->m_imgBW); // img2.initializeAs(&pPVS->m_imgBW); IplImage *ipl; ipl = cvCreateImage( cvGetSize(pPVS->m_imgBW.getIplImage()), IPL_DEPTH_16S , 1 ); cvAnd(pPVS->m_imgBW.getIplImage(), pPVS->m_pianoPlaying.m_imb_handsImage.getIplImage(), img1.getIplImage()); cvSobel(img1.getIplImage(), ipl, 1,0,3); cvConvert (&ipl, img1.getIplImage()); img1.draw(pDC->m_hDC, set_window(0,3)); img1.destroy(); cvReleaseImage(&ipl); // img2.destroy(); */ #if 1 //<< Clustering CIplImage imc, imcClusters; imc.initializeAs(&pPVS->m_imgIn); imcClusters.initializeAs(&pPVS->m_imgBW); cvZero( imc.getIplImage() ); pImgIn = & pPVS->m_pianoPlaying.m_imb_handsImage; // m_chanColour.m_imbSkinYCrCb; // ; CIplImage *pImgOut = & imcClusters; cvZero( pImgOut->getIplImage()); // pImgIn->draw(pDC->m_hDC, set_window(0,3)); int nClustersDetected, nMaxClusters; // a) PVI_BLOB *blobs = new PVI_BLOB[5]; nMaxClusters = 4; nClustersDetected = detectClusters_wKmeans( pImgIn, pImgOut, nMaxClusters, &nClustersDetected, &blobs); delete blobs; colourizeClusters(*pImgOut, imc, nClustersDetected); imc.draw(pDC->m_hDC, set_window(0,1)); sprintf(strMessage, "%i hands", nClustersDetected); OnDraw_LogWindow(pDC,strMessage, set_window(0,1), 0); /* // nClustersDetected = clusterize_wKmeans( pImgIn, pImgOut, 2, 1, &imc); // imc.draw(pDC->m_hDC, set_window(1,iActiveCamera+1)); // b) int nXclose=4, nYclose=4, nCosine=0; nClustersDetected = detectClusters_wProximity( pImgIn, pImgOut, nXclose, nYclose, nCosine, &imc); imc.draw(pDC->m_hDC, set_window(4,0)); sprintf(strMessage, "%i", nClustersDetected); OnDraw_LogWindow(pDC,strMessage, set_window(4,0), 0); imc.destroy(); imcClusters.destroy(); // if (nClustersDetected > pPVS->m_pianoPlaying.m_nNumHands) // m_bDetectHands = true; */ #endif //>> Clustering /***************************************************************************************/ /*** Use MIDI data do detect hand/finger **************************************************/ /***************************************************************************************/ CvFont cvFont; cvInitFont( &cvFont, CV_FONT_HERSHEY_SIMPLEX, 1, 1, 0.0, 2 ); CvPoint ptBtmLeft; // To do : midi for hand blob detection //DO MIDI INFORMATION if (USING_MIDI == 1 && m_bMidiCheck==true) { char keyPressString[200]; //Printable String int i=0; //Print Counter numStrings=0; //FOR each possible MIDI Key for (q=0; q < 200; q++) { //Calculate Key and Octave Values keyValue = (q) % 12; octave = (q - keyValue)/12; //IF Key is ON if (keyDown[q] == true) { //Get Bounding Box of Key CvRect myRect = pPVS->m_pianoPlaying.m_Piano.ReturnKeyBounds(keyValue, octave); //Select Hand that this Key intersects with int selectedHand = pPVS->m_pianoPlaying.SelectHand(&myRect); //Highlight Selected Key pPVS->m_pianoPlaying.DrawBox(pPVS->m_pianoPlaying.m_imc_displayImage.getIplImage(), myRect.x, myRect.y, myRect.x + myRect.width, myRect.y + myRect.height, 3); //Put Information to String if (selectedHand != -1) { int selectedFinger = pPVS->m_pianoPlaying.m_Hand[selectedHand].SelectFinger(&myRect); if (selectedFinger == -1) sprintf(keyPressString, "MIDI: %d -> Octave: %d, Key: %d -> Hand: %d", q, octave, keyValue, selectedHand); else { sprintf(keyPressString, "MIDI: %d -> Octave: %d, Key: %d -> Hand: %d, Finger: %d", q, octave, keyValue, selectedHand, selectedFinger+1); sprintf(strMessage, "%i", selectedFinger); ptBtmLeft = cvPoint(myRect.x, myRect.y-5); cvPutText( pPVS->m_pianoPlaying.m_imc_displayImage.getIplImage(), strMessage, ptBtmLeft, &cvFont, CV_RGB(0, 200, 200)); } } else sprintf(keyPressString, "MIDI: %d -> Octave: %d, Key: %d", q, octave, keyValue); //IF Key Was JUST Pressed if (keyChange[q] == true) { //Write Information to File fprintf(pPVS->m_pianoPlaying.fDataFile, "%s\n", keyPressString); } //Add String To List if (numStrings < 200) { sprintf(MIDIString[numStrings], "%s", keyPressString); numStrings++; } }//END IF //IF Key is OFF else { //Put Information to String sprintf(keyPressString, "Key Value: %d -> Octave: %d, Key: %d - RELEASED", q, octave, keyValue); //IF Key Was JUST Released if (keyChange[q] == true) //Write Information to File fprintf(pPVS->m_pianoPlaying.fDataFile, "%s\n", keyPressString); }//END ELSE }//END FOR Each Key }//END MIDI /***************************************************************************************/ /*** Draw all **************************************************/ /***************************************************************************************/ //DRAW IMAGES pPVS->m_pianoPlaying.m_imc_displayImage.draw(pDC->m_hDC, set_window(1, 0)); pPVS->m_pianoPlaying.m_imc_backgroundImage.draw(pDC->m_hDC, set_window(2,0)); // pPVS->m_pianoPlaying.m_imb_handsImage.draw(pDC->m_hDC, set_window(3,0)); // pPVS->m_pianoPlaying.m_imb_edgeDetectedImage.draw(pDC->m_hDC, set_window(4,0)); /* pPVS->m_pianoPlaying.m_imb_fingerDetectedImage. draw(pDC->m_hDC, set_window(1,1)); pPVS->m_pianoPlaying.m_imc_displayImage. draw(pDC->m_hDC, set_window(2,1)); pPVS->m_pianoPlaying.m_imc_backgroundImage. draw(pDC->m_hDC, set_window(3,1)); */ pPVS->m_pianoPlaying.m_Piano.boxes.draw(pDC->m_hDC, set_window(1, 1)); pPVS->m_pianoPlaying.m_Piano.polarizedImage.draw(pDC->m_hDC, set_window(2, 1)); //pPVS->m_pianoPlaying.m_ORIMAGE.draw(pDC->m_hDC, set_window(3, 1)); //pPVS->m_pianoPlaying.m_Hand[0].m_edgeImage.draw(pDC->m_hDC, set_window(3, 1)); int f, h; if (pPVS->m_pianoPlaying.m_nNumHands > 0) { h=0; if (pPVS->m_pianoPlaying.m_Hand[h].ready == true) { // pPVS->m_pianoPlaying.m_Hand[h].m_fingImg[f].draw(pDC->m_hDC, set_window(f, h+2)); for (f=0; f < 5; f++) { pPVS->m_pianoPlaying.m_Hand[h].m_fingImg[f].draw(pDC->m_hDC, set_window(f, h+2)); //cvSet( (pPVS->m_imgOut.getIplImage()), CV_RGB(0, 100*h, f*50), // (pPVS->m_pianoPlaying.m_Hand[h].m_fingImg[f].getIplImage())); } } } char clearString[150]; int i; for (i=0; i < 150; i++) clearString[i] = ' '; //////////////////////////END ARJUN//////////////////////////// // // pPVS->m_imgIn.draw(pDC->m_hDC, set_window(0,0), false, false); pPVS->m_imgOut.draw(pDC->m_hDC, set_window(0,0), false, false); nNameTag = pDoc->m_gui.slider4;//-1; // ************************************************************************************************ if (!pDoc->m_gui.check_start) // It has to be checked to start the video processing return; // ************************************************************************************************ pDoc->m_bWorkWithFiles = false; if (m_bTraceMode == true && pDoc->m_gui.check2) // if scenario, wait to continue if (MessageBox("Proceed to next face?",NULL,MB_OKCANCEL) != IDOK) exit(1); }