//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Notify this dialog box that the active image has changed //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //! \brief notify this dialog box that the active image has changed //! \param[in] img new changed image void IPDialog::imageChanged(QImage img) { // update the changed image m_retProcImg = img; m_origImg = img.scaled(128, 128, Qt::KeepAspectRatio); m_resultImg = img.scaled(128, 128, Qt::KeepAspectRatio); // reprocess with the new image (same parameters) switch(m_currentFuct) { case COLOR: processColor(); break; case THRESHOLD: processThreshold(); break; case EDGE: processEdge(); break; default: break; } // show the appropriate display if (m_dispOrig ->isChecked()) m_ipDisplay ->storeImage(tr("Original"), m_origImg); else m_ipDisplay ->storeImage(tr("Result"), m_resultImg); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Slot for spin box changed; change slider //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //! \brief slot for spin box changed; change slider //! \param[in] num new threshold value void IPDialog::spinChanged(int num) { m_thresSlider ->setValue(num); // notify slider // reprocess image with new threshold value if (m_currentFuct == THRESHOLD) processThreshold(); else if (m_currentFuct == EDGE) processEdge(); }
Boolean FcloneNode::walk(void){ switch(entryPoint){ case firstVertex: if(v==ZERO)nodeErr(4); if(v->Qideal())nodeErr(11); startUp(); virginCloneVertex(v->bv,vClone->bv); entryPoint=nextVertex; //control flows directly to GLrun case nextVertex: return(processVertex()); case firstEdge:{ // Process the first edge, if there is one. // if there is no defined edge, control flows to GLnextVertex Ptr DEREF=v&v->bv; GLref startRef; v->xGetPacketRef(startRef,GLr,DEREF); v-v->bv; if(isNull(startRef)){ entryPoint=nextVertex; // no real link return(TRUE); } // start search for first edge at the very beginning GLref entryPacketRef; v->xsetToFirstPacket(entryPacketRef,startRef); if(itsStepper->firstEdge(entryPacketRef)){ // first edge detected GLref ref; v->xEdgeEntryToOwner(ref,itsStepper->refDatum); v->cv=ref; entryPoint=nextEdge; return(processEdge()); } else{ // real link has no edges entryPoint=nextVertex; return(TRUE); } } case nextEdge:{ if(itsStepper->nextEdge()){ // next edge detected GLref ref; v->xEdgeEntryToOwner(ref,itsStepper->refDatum); v->cv=ref; entryPoint=nextEdge; return(processEdge()); } else{ // real link has no more edges entryPoint=nextVertex; return(TRUE); } } default: nodeErr(6); } nodeErr(8); }
Boolean FTTdriverNode::walk(void){ // the following code is identical to that of FGLwalkNode::walk(). // We need to repeat it here so that FTTdriverNode overriding // subroutines virginVertex and processEdge will be called // // Is there a more elegant solution that doesn't require // code replication? switch(entryPoint){ case firstVertex: if(v==ZERO)nodeErr(4); if(v->Qideal())nodeErr(11); // OUTPUT DISPLAY //@rn tout <= "*** pass " <= pTree->passNumber <=" ***" <= "\n"; //@rn ask me if I care // END OUTPUT DISPLAY startUp(); virginVertex(v->bv); entryPoint=nextVertex; case nextVertex: return(processVertex()); case firstEdge:{ // Process the first edge, if there is one. // if there is no defined edge, control flows to GLnextVertex Ptr DEREF=v&v->bv; GLref startRef; v->xGetPacketRef(startRef,GLr,DEREF); v-v->bv; if(isNull(startRef)){ entryPoint=nextVertex; // no real link return(TRUE); } // start search for first edge at the very beginning GLref entryPacketRef; v->xsetToFirstPacket(entryPacketRef,startRef); if(itsStepper->firstEdge(entryPacketRef)){ // first edge detected GLref ref; v->xEdgeEntryToOwner(ref,itsStepper->refDatum); v->cv=ref; entryPoint=nextEdge; return(processEdge()); } else{ // real link has no edges entryPoint=nextVertex; return(TRUE); } } case nextEdge:{ if(itsStepper->nextEdge()){ // next edge detected GLref ref; v->xEdgeEntryToOwner(ref,itsStepper->refDatum); v->cv=ref; entryPoint=nextEdge; return(processEdge()); } else{ // real link has no more edges entryPoint=nextVertex; return(TRUE); } } default: nodeErr(6); } nodeErr(8); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CONSTRUCTOR //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //! \brief Constructor IPDialog::IPDialog(QWidget *p, Qt::WindowFlags f) : QWidget(p, f) { // initialize image processing class m_ip = new IP(); // create display layout QGridLayout *dispLay = new QGridLayout; m_ipDisplay = new OpenGLWidget(); m_ipDisplay ->setFixedSize(128, 128); dispLay ->addWidget(m_ipDisplay, 0, 0, 2, 2, Qt::AlignCenter); m_dispOrig = new QRadioButton(tr("Original")); m_dispResult = new QRadioButton(tr("Result")); m_dispResult ->setChecked(true); // display result by default dispLay ->addWidget(m_dispOrig, 0, 2, Qt::AlignCenter); dispLay ->addWidget(m_dispResult, 1, 2, Qt::AlignCenter); m_boxDisp = new QGroupBox(tr("Display"), this); m_boxDisp ->setLayout(dispLay); // initialize all dynamic layout options m_thresSlider = new QSlider(Qt::Horizontal); m_thresSlider ->setTickPosition(QSlider::TicksBelow); m_thresSlider ->setRange(0, 255); m_thresSlider ->setValue(128); m_thresSlider ->setTickInterval(10); m_thresSpin = new QSpinBox; m_thresSpin ->setRange(0, 255); m_thresSpin ->setValue(128); m_thresSpin ->setKeyboardTracking(false); m_colorRed = new QRadioButton(tr("Red")); m_colorBlue = new QRadioButton(tr("Blue")); m_colorGreen = new QRadioButton(tr("Green")); m_colorGray = new QRadioButton(tr("Gray")); m_thresInd = new QRadioButton(tr("Individual")); m_thresAll = new QRadioButton(tr("All")); m_edgePrewitt = new QRadioButton(tr("Prewitt")); m_edgeSobel = new QRadioButton(tr("Sobel")); m_edgeLoG = new QRadioButton(tr("LoG")); // dynamic layout depends on function selected m_optLay = new QGridLayout; // set different layout depending on the options m_boxOpt = new QGroupBox(this); m_boxOpt ->setLayout(m_optLay); // initialize confirmation buttons m_butOk = new QPushButton(tr("OK")); m_butCancel = new QPushButton(tr("Cancel")); m_butApply = new QPushButton(tr("Apply")); // map confirmation buttons signal m_signalMap = new QSignalMapper(this); m_signalMap ->setMapping(m_butOk, 1); m_signalMap ->setMapping(m_butCancel, 2); m_signalMap ->setMapping(m_butApply, 3); QHBoxLayout *hLay = new QHBoxLayout(); hLay ->addWidget(m_butOk); hLay ->addWidget(m_butCancel); hLay ->addWidget(m_butApply); // set up the entire dialog layout m_ipLayout = new QVBoxLayout(this); m_ipLayout ->addWidget(m_boxDisp); m_ipLayout ->setStretchFactor(m_boxDisp, 1); m_ipLayout ->addWidget(m_boxOpt); m_ipLayout ->addLayout(hLay); setLayout (m_ipLayout); // set up all connections connect(m_thresSlider, SIGNAL(valueChanged(int)), this, SLOT(sliderChanged(int))); connect(m_thresSpin, SIGNAL(valueChanged(int)), this, SLOT(spinChanged(int))); connect(m_dispOrig, SIGNAL(toggled(bool)), this, SLOT(imgButToggled(bool))); // true = orig; false = result connect(m_colorRed, SIGNAL(released()), this, SLOT(processColor())); connect(m_colorGreen, SIGNAL(released()), this, SLOT(processColor())); connect(m_colorBlue, SIGNAL(released()), this, SLOT(processColor())); connect(m_colorGray, SIGNAL(released()), this, SLOT(processColor())); connect(m_thresInd, SIGNAL(released()), this, SLOT(processThreshold())); connect(m_thresAll, SIGNAL(released()), this, SLOT(processThreshold())); connect(m_edgePrewitt, SIGNAL(released()), this, SLOT(processEdge())); connect(m_edgeSobel, SIGNAL(released()), this, SLOT(processEdge())); connect(m_edgeLoG, SIGNAL(released()), this, SLOT(processEdge())); connect(m_butOk, SIGNAL(clicked()), m_signalMap, SLOT(map())); connect(m_butCancel, SIGNAL(clicked()), m_signalMap, SLOT(map())); connect(m_butApply, SIGNAL(clicked()), m_signalMap, SLOT(map())); connect(m_signalMap, SIGNAL(mapped(int)), this, SIGNAL(done(int))); }