/// /// ShowSelectPointer() void ShowSelectPointer(struct InstData *data, Object *obj) { ENTER(); // even if it seems to be a waste of performance, but // we unfortunately have to always set the window pointer // regardless of the point if it was previously set or not. // This is required as any other gadget or process might // reset the window pointer and as such we would end up // with no custom pointer as well. So we only check the window // sleep status here :( if(data->PointerObj != NULL && xget(_win(obj), MUIA_Window_Sleep) == FALSE) { // try to identify the black/white colors // of the current screen colormap if(data->activeSelectPointer == FALSE) IdentifyPointerColors(obj); // now we set the actual new custom window pointer. Please note // that we can't unfortunately check for data->activeSelectPointer // here because otherwise we might end up with the standard // window pointer when quickly switching pointer TE.mcc #if defined(__amigaos4__) SetWindowPointer(_window(obj), LIB_VERSION_IS_AT_LEAST(IntuitionBase, 53, 407) ? WA_PointerType : WA_Pointer, data->PointerObj, TAG_DONE); #elif defined(__MORPHOS__) SetWindowPointer(_window(obj), IS_MORPHOS2 ? WA_PointerType : WA_Pointer, data->PointerObj, TAG_DONE); #else if(LIB_VERSION_IS_AT_LEAST(IntuitionBase, 39, 0)) SetWindowPointer(_window(obj), WA_Pointer, data->PointerObj, TAG_DONE); else SetPointer(_window(obj), (APTR)data->PointerObj, selectPointerHeight, selectPointerWidth, selectPointerXOffset, selectPointerYOffset); #endif data->activeSelectPointer = TRUE; } LEAVE(); }
/// /// HideSelectPointer() void HideSelectPointer(struct InstData *data, Object *obj) { ENTER(); if(data->activeSelectPointer == TRUE && data->PointerObj != NULL) { #if defined(__amigaos4__) || defined(__MORPHOS__) SetWindowPointer(_window(obj), TAG_DONE); #else if(LIB_VERSION_IS_AT_LEAST(IntuitionBase, 39, 0)) SetWindowPointer(_window(obj), TAG_DONE); else ClearPointer(_window(obj)); #endif data->activeSelectPointer = FALSE; } LEAVE(); }
IPTR Prop__OM_DISPOSE(struct IClass *cl, Object *obj, Msg msg) { struct Prop_DATA *data = INST_DATA(cl, obj); if (data->prop_object && !data->usewinborder) { RemoveGadget(_window(obj), (struct Gadget *) data->prop_object); DisposeObject(data->prop_object); } DisposeImageContainer(data->buffer); DisposeImageContainer(data->temp); if (data->mapbuffer != NULL) FreeBitMap(data->mapbuffer); if (data->maptemp != NULL) FreeBitMap(data->maptemp); if (data->tmprp != NULL) FreeRastPort(data->tmprp); data->buffer = NULL; data->temp = NULL; data->mapbuffer = NULL; data->maptemp = NULL; data->tmprp = NULL; return DoSuperMethodA(cl, obj, msg); }
static BOOL MakePopupWin(Object *obj, struct Numericbutton_DATA *data) { const struct ZuneFrameGfx *zframe; struct RastPort *rp, *saverp; LONG winx, winy, winw, winh; LONG framew, frameh; LONG min, max; zframe = zune_zframe_get_with_state(obj, &muiGlobalInfo(obj)->mgi_Prefs->frames[MUIV_Frame_Slider], muiGlobalInfo(obj)->mgi_Prefs->frames[MUIV_Frame_Slider].state); data->pop_innerx = zframe->ileft; data->pop_innery = zframe->itop; data->knob_width = data->max_text_width + 4; data->knob_height = data->text_height + 2; framew = data->pop_innerx + zframe->iright; frameh = data->pop_innery + zframe->ibottom; longget(obj, MUIA_Numeric_Min, &min); longget(obj, MUIA_Numeric_Max, &max); winw = max - min + data->knob_width + framew; winh = data->knob_height + frameh; if (winw > _screen(obj)->Width) { winw = _screen(obj)->Width; } if ((winw < data->knob_width + framew) || (winh > _screen(obj)->Height)) { return FALSE; } data->pop_innerw = winw - framew; data->pop_innerh = winh - frameh; data->knob_left = DoMethod(obj, MUIM_Numeric_ValueToScale, 0, data->pop_innerw - data->knob_width); winx = _window(obj)->LeftEdge + _mleft(obj) - data->pop_innerx - 2 - data->knob_left; winy = _window(obj)->TopEdge + _mtop(obj) - 1- data->pop_innery; data->popwin = OpenWindowTags(NULL, WA_CustomScreen, (IPTR)_screen(obj), WA_Left, winx, WA_Top, winy, WA_Width, winw, WA_Height, winh, WA_AutoAdjust, TRUE, WA_Borderless, TRUE, WA_Activate, FALSE, WA_BackFill, (IPTR)LAYERS_NOBACKFILL, TAG_DONE); if (!data->popwin) { return FALSE; } rp = data->popwin->RPort; saverp = _rp(obj); _rp(obj) = rp; zframe->draw(zframe->customframe, muiRenderInfo(obj), 0, 0, winw, winh, 0, 0, winw, winh); DrawKnob(obj, data, TRUE); _rp(obj) = saverp; return TRUE; }
/// IdentifyPointerColors() static void IdentifyPointerColors(Object *obj) { int i; ULONG colors[3*3]; LONG blackDiff[3]; LONG whiteDiff[3]; LONG blackIndex; LONG whiteIndex; ENTER(); // get the current screen's pointer colors (17 to 19) GetRGB32(_window(obj)->WScreen->ViewPort.ColorMap, 17, 3, colors); for(i=0; i < 3; i++) { LONG dr; LONG dg; LONG db; // normalize the colors to 8 bit per gun as GetRGB32() returns // 32bit left aligned values colors[i*3+0] >>= 24; colors[i*3+1] >>= 24; colors[i*3+2] >>= 24; // calculate the geometric difference to the color black (=0x00000000) dr = 0x00000000 - colors[i*3+0]; dg = 0x00000000 - colors[i*3+1]; db = 0x00000000 - colors[i*3+2]; blackDiff[i] = dr * dr + dg * dg + db * db; // calculate the geometric difference to the color white (=0x000000ff) dr = 0x000000ff - colors[i*3+0]; dg = 0x000000ff - colors[i*3+1]; db = 0x000000ff - colors[i*3+2]; whiteDiff[i] = dr * dr + dg * dg + db * db; } // the smallest difference defines the color which is closest to black or // equal to black if(blackDiff[0] > blackDiff[1]) { if(blackDiff[1] > blackDiff[2]) blackIndex = 19; else blackIndex = 18; } else if(blackDiff[0] > blackDiff[2]) blackIndex = 19; else blackIndex = 17; // the smallest difference defines the color which is closest to white or // equal to white if(whiteDiff[0] > whiteDiff[1]) { if(whiteDiff[1] > whiteDiff[2]) whiteIndex = 19; else whiteIndex = 18; } else if(whiteDiff[0] > whiteDiff[2]) whiteIndex = 19; else whiteIndex = 17; // Here we expect the user to have set up quite "different" colors. That // means the color closest to white will never be close to black and vice // versa. According to these differences we spread the required bitplanes. if(whiteIndex == 17) { if(blackIndex == 18) { selectPointerBitmap.Planes[0] = (PLANEPTR)selectPointer_bp0; selectPointerBitmap.Planes[1] = (PLANEPTR)selectPointer_bp1; } else // blackIndex == 19 { selectPointerBitmap.Planes[0] = (PLANEPTR)selectPointer_bp2; selectPointerBitmap.Planes[1] = (PLANEPTR)selectPointer_bp1; } } else if(whiteIndex == 18) { if(blackIndex == 17) { selectPointerBitmap.Planes[0] = (PLANEPTR)selectPointer_bp1; selectPointerBitmap.Planes[1] = (PLANEPTR)selectPointer_bp0; } else // blackIndex == 19 { selectPointerBitmap.Planes[0] = (PLANEPTR)selectPointer_bp1; selectPointerBitmap.Planes[1] = (PLANEPTR)selectPointer_bp2; } } else // whiteIndex == 19 { if(blackIndex == 17) { selectPointerBitmap.Planes[0] = (PLANEPTR)selectPointer_bp2; selectPointerBitmap.Planes[1] = (PLANEPTR)selectPointer_bp0; } else // blackIndex == 18 { selectPointerBitmap.Planes[0] = (PLANEPTR)selectPointer_bp0; selectPointerBitmap.Planes[1] = (PLANEPTR)selectPointer_bp2; } } LEAVE(); }
int main(int argc, char *argv[]) { // Signal settings. double rate = 1e6; double freq = 10e3; double fc = 150e3; // Modulation settings double gain = 1; double rel_fc = fc / rate; double rel_fs = freq / rate; // Specific Modulation Settings. AmDemod::SideBand sideBand = AmDemod::SideBand::DOUBLE; unsigned int constSize = 2; int supp_carrier = 0; double mod_index = 0.5; // Frame size and FFT size. size_t N = 2048; size_t frameSize = 384; /*************************************************************************************************** * Create stream object * **************************************************************************************************/ // AM Stream function. StreamFunction * _streamFunction = new AmFunction(new cosFunction(freq), mod_index, rel_fc, sideBand, supp_carrier); // FM Stream Function // StreamFunction * _streamFunction = new FmFunction(new cosFunction(freq), mod_index, rel_fc); // MPSK Stream Function // StreamFunction * _streamFunction = new DigitalFunction(new MPskFunction(constSize), rel_fs, rel_fc); // ------------ Create Streamer Object ------------ // // UhdMock Object boost::scoped_ptr < Streamer > _dataStream(new UhdMock(_streamFunction, rate, gain, frameSize)); // UhdRead Object // boost::scoped_ptr < Streamer > _dataStream(new UhdRead(rate, freq, gain, frameSize)); /*************************************************************************************************** * Initialize utilities * **************************************************************************************************/ // Get shared buffer boost::shared_ptr < SharedBuffer<std::complex<double> > > _buffer(_dataStream->getBuffer()); boost::shared_ptr < SharedType<double> > _fc(_dataStream->getFc()); boost::shared_ptr < SharedType<double> > _window(_dataStream->getWindow()); // Create fft generator function. FFTGenerator _fftGen(_buffer, rate, N); AmcClassifier<double, AMC::ModType> * classifier = new AmcCvDecisionTree(); AMC::FeatureExtractor _featureExtractor(_buffer, classifier, N, rate); boost::shared_ptr < SharedType<AMC::ModType> > _modType(_featureExtractor.getSharedModType()); /*************************************************************************************************** * Create Demodulator * **************************************************************************************************/ // Create demodulator object. AmcRecv _amcRecv(_buffer, N); _amcRecv.setFc(_fc); _amcRecv.setModType(_modType); // Am Demodulator. _amcRecv.setDemod(new AmDemod(mod_index, rel_fc, sideBand, supp_carrier)); // Fm Demodulator. // _amcRecv.setDemod(new FmDemod(mod_index, rel_fc)); // MPSK Demodulator // _amcRecv.setDemod(new DigitalDemod(new MPskDemod(constSize), rel_fc)); /*************************************************************************************************** * Initialize GUI Objects * **************************************************************************************************/ // Initialize interface. QApplication _app(argc, argv); MainWindow _mainWindow(rate, N); _mainWindow.show(); /*************************************************************************************************** * Share some buffers * **************************************************************************************************/ _fftGen.setFc(_fc); _mainWindow.setData(_fftGen.getFreqVec(), _fftGen.getFftVec()); _mainWindow.setBuffer(_buffer); _mainWindow.setSharedModType(_modType); _mainWindow.setFc(_fc); _mainWindow.setWindow(_window); /*************************************************************************************************** * Start threads. * **************************************************************************************************/ _dataStream->startStream(); _amcRecv.startDemod(); _fftGen.startFft(); _featureExtractor.start(AMC::FeatureExtractor::ExtractionMode::CLASSIFY); return _app.exec(); }
IPTR Prop__OM_SET(struct IClass *cl, Object *obj, struct opSet *msg) { struct TagItem *tags,*tag; struct Prop_DATA *data = INST_DATA(cl, obj); int refresh = 0; int only_trigger = 0; for (tags = msg->ops_AttrList; (tag = NextTagItem((const struct TagItem **)&tags)); ) { switch (tag->ti_Tag) { case MUIA_Prop_Entries: if ((IPTR)data->entries != tag->ti_Data) { data->entries = tag->ti_Data; refresh = 1; } else { tag->ti_Tag = TAG_IGNORE; } break; case MUIA_Prop_First: if ((IPTR)data->first != tag->ti_Data) { data->first = tag->ti_Data; refresh = 1; } else { tag->ti_Tag = TAG_IGNORE; } break; case MUIA_Prop_Slider: break; case MUIA_Prop_Visible: if ((IPTR)data->visible != tag->ti_Data) { data->visible = tag->ti_Data; refresh = 1; } else { tag->ti_Tag = TAG_IGNORE; } break; case MUIA_Prop_OnlyTrigger: only_trigger = tag->ti_Data; break; case MUIA_Prop_DeltaFactor: data->deltafactor = tag->ti_Data; break; } } if (data->first < 0) data->first = 0; if (data->prop_object && refresh && !only_trigger) { calcscale16(data); /* Rendering will happen here!! This could make problems with virtual groups, forward this to MUIM_Draw??? */ SetAttrs(data->prop_object, ICA_TARGET, NULL, TAG_DONE); if (SetGadgetAttrs((struct Gadget*)data->prop_object,_window(obj),NULL, PGA_Top,downscale(data, data->first), PGA_Visible,downscale(data, data->visible), PGA_Total,downscale(data, data->entries), TAG_DONE)) RefreshGList((struct Gadget*)data->prop_object, _window(obj), NULL, 1); SetAttrs(data->prop_object, ICA_TARGET, ICTARGET_IDCMP, TAG_DONE); } return DoSuperMethodA(cl,obj,(Msg)msg); }
/* /// "CfgListDispatcher()" */ AROS_UFH3(IPTR, CfgListDispatcher, AROS_UFHA(struct IClass *, cl, A0), AROS_UFHA(Object *, obj, A2), AROS_UFHA(Msg, msg, A1)) { AROS_USERFUNC_INIT // There should never be an uninitialized pointer, but just in case, try to get an mungwall hit if so. struct CfgListData *data = (struct CfgListData *) 0xABADCAFE; // on OM_NEW the obj pointer will be void, so don't try to get the data base in this case. if(msg->MethodID != OM_NEW) data = INST_DATA(cl,obj); switch(msg->MethodID) { case OM_NEW: if(!(obj = (Object *) DoSuperMethodA(cl,obj,msg))) return(0); return((IPTR) obj); case MUIM_DragBegin: data->cl_Dragging = TRUE; break; case MUIM_DragFinish: data->cl_Dragging = FALSE; break; case MUIM_DragQuery: { struct MUI_List_TestPos_Result tpr; struct Window *win; win = _window(obj); if(!win) { return(MUIV_DragQuery_Refuse); } DoMethod(obj, MUIM_List_TestPos, win->MouseX, win->MouseY, &tpr); return((IPTR) (CheckDragAccept(obj, tpr.entry) ? MUIV_DragQuery_Accept : MUIV_DragQuery_Refuse)); } #ifndef MUI_LPR_FULLDROP #define MUI_LPR_FULLDROP (1<<15) #endif case MUIM_List_TestPos: { struct MUIP_List_TestPos *tpmsg = (struct MUIP_List_TestPos *) msg; struct MUI_List_TestPos_Result *res = tpmsg->res; IPTR rc; rc = DoSuperMethodA(cl, obj, msg); if(data->cl_Dragging && (res->entry != -1)) { if(!CheckDragAccept(obj, res->entry)) { res->entry = -1; // illegal combination } else { res->flags |= MUI_LPR_FULLDROP; } } return(rc); } case MUIM_DragDrop: { //struct MUIP_DragDrop *ddmsg = (struct MUIP_DragDrop *) msg; struct MUI_List_TestPos_Result tpr; struct Window *win; win = _window(obj); if(!win) { return(FALSE); } DoMethod(obj, MUIM_List_TestPos, win->MouseX, win->MouseY, &tpr); //DoMethod(obj, MUIM_List_TestPos, ddmsg->x, ddmsg->y, &tpr); if(CheckDragAccept(obj, tpr.entry)) { ApplyDragAction(obj, tpr.entry); } else { MUI_RequestA(_app(obj), _win(obj), 0, NULL, "Oops!", "Sorry, drag'n drop operation to\n" "that target is not supported.", NULL); return(FALSE); } return(TRUE); } } return(DoSuperMethodA(cl,obj,msg)); AROS_USERFUNC_EXIT }