void             ComputeRegFromStencil(
Region         **dep_reg_ptr,
Region         **ind_reg_ptr,
SubregionArray  *cr_array,        /* compute region SubregionArray */
Region          *send_reg,
Region          *recv_reg,
Stencil         *stencil)
{
   Region          *dep_reg;
   Region          *ind_reg;

   SubregionArray  *ir_array;
   SubregionArray  *dr_array;

   SubregionArray  *a0, *a1;

   int              i, j, k;

   (void)recv_reg;
   (void)stencil;

   /*-----------------------------------------------------------------------
    * Set up the dependent region
    *-----------------------------------------------------------------------*/

   dep_reg = NewRegion(SubregionArraySize(cr_array));

#ifndef NO_OVERLAP_COMM_COMP

   ForSubregionArrayI(i, dep_reg)
   {
      FreeSubregionArray(RegionSubregionArray(dep_reg, i));
      RegionSubregionArray(dep_reg, i) = 
	 UnionSubgridArray((SubgridArray *) RegionSubregionArray(send_reg, i));
   }
Example #2
0
widgetLandmark::widgetLandmark(QWidget *parent, jpsDatamanager *dmanager, jpsGraphicsView *gview):
    QTabWidget(parent),
    ui(new Ui::widgetLandmark)
{
    ui->setupUi(this);
    _dmanager=dmanager;
    _gview=gview;

    //Landmark type
    ui->Box_landmarkType->addItem("Landmark");
    ui->Box_landmarkType->addItem("Main Target");


    show_landmarks();

    connect(ui->apply_name_button,SIGNAL(clicked(bool)),this,SLOT(change_name()));
    connect(ui->closeButton,SIGNAL(clicked(bool)),this->parentWidget(),SLOT(define_landmark()));
    connect(ui->closeButton_2,SIGNAL(clicked(bool)),this->parentWidget(),SLOT(define_landmark()));
    connect(ui->closeButton_regions,SIGNAL(clicked(bool)),this->parentWidget(),SLOT(define_landmark()));
    connect(ui->cogmap_closeButton,SIGNAL(clicked(bool)),this->parentWidget(),SLOT(define_landmark()));
    connect(ui->list_landmarks,SIGNAL(activated(int)),this,SLOT(enable_room_selection()));
    connect(ui->list_landmarks,SIGNAL(activated(int)),this,SLOT(ShowLandmarkType()));
    connect(ui->list_landmarks,SIGNAL(currentIndexChanged(int)),_gview,SLOT(unmarkLandmark()));
    connect(ui->roomBox_landmarks,SIGNAL(activated(int)),this,SLOT(add_room_to_landmark()));
    connect(ui->add_button,SIGNAL(clicked(bool)),_gview,SLOT(StatPositionDef()));
    connect(_gview,SIGNAL(PositionDefCompleted()),this,SLOT(SetPosInCMap()));
    connect(ui->remove_button,SIGNAL(clicked(bool)),this,SLOT(RemoveAssociation()));
    connect(ui->button_showhide,SIGNAL(clicked(bool)),this,SLOT(ShowHideLandmark()));
    connect(ui->Box_landmarkType,SIGNAL(activated(int)),this,SLOT(SetLandmarkType()));

    //connectionDef
    connect(ui->add_button_connections,SIGNAL(clicked(bool)),this,SLOT(NewConnection()));
    connect(_gview,SIGNAL(DefConnection1Completed()),this,SLOT(AskForSecondLandmark()));
    connect(_gview,SIGNAL(DefConnection2Completed()),this,SLOT(SetLandmarksToConnection()));
    connect(ui->remove_button_connections,SIGNAL(clicked(bool)),this,SLOT(RemoveConnection()));

    //Region Def
    connect(ui->add_button_regions,SIGNAL(clicked(bool)),_gview,SLOT(ChangeRegionStatDef()));
    connect(_gview,SIGNAL(RegionDefCompleted()),this,SLOT(NewRegion()));
    connect(ui->remove_button_regions,SIGNAL(clicked(bool)),this,SLOT(RemoveRegion()));
    connect(ui->box_regions,SIGNAL(activated(int)),this,SLOT(SetLandmarkToRegion()));
    connect(ui->button_showhide_region,SIGNAL(clicked(bool)),this,SLOT(ShowHideRegion()));

    //saveCogMap
    connect(ui->save_button_cogmap,SIGNAL(clicked(bool)),this->parentWidget(),SLOT(SaveCogMapXML()));
    connect(ui->save_button_multiple_maps,SIGNAL(clicked(bool)),this,SLOT(CreateSimilarMaps()));

}
#else

   ForSubregionArrayI(i, dep_reg)
   {
      AppendSubregion(RegionSubregionArray(dep_reg, i),
		      SubregionArraySubregion(cr_array, i));
   }

#endif

   /*-----------------------------------------------------------------------
    * Set up the independent region
    *-----------------------------------------------------------------------*/

   ind_reg = NewRegion(SubregionArraySize(cr_array));

#ifndef OVERLAP_COMM_COMP

   ForSubregionArrayI(k, ind_reg)
   {
      ir_array = RegionSubregionArray(ind_reg, k);
      dr_array = RegionSubregionArray(dep_reg, k);

      AppendSubregion(DuplicateSubregion(SubregionArraySubregion(cr_array, k)),
		      ir_array);

      ForSubregionI(i, dr_array)
      {
	 a0 = NewSubregionArray();
Example #4
0
// Show font example
void font_show_font(font_data *data,BOOL refresh)
{
	struct Rectangle rect;
	struct Region *region;
	struct RastPort rp;

	// Get display rectangle
	GetObjectRect(data->list,GAD_FONT_DISPLAY,&rect);

	// Move rectangle in
	rect.MinX+=3;
	rect.MinY+=3;
	rect.MaxX-=3;
	rect.MaxY-=3;

	// Copy rastport
	rp=*data->window->RPort;

	// Refresh?
	if (refresh)
	{
		LockLayerInfo(&data->window->WScreen->LayerInfo);
		BeginRefresh(data->window);
	}

	// Clear background
	SetAPen(&rp,DRAWINFO(data->window)->dri_Pens[SHINEPEN]);
	RectFill(&rp,rect.MinX-1,rect.MinY-1,rect.MaxX+1,rect.MaxY+1);

	// Refreshing?
	if (refresh) EndRefresh(data->window,FALSE);

	// Create region
	if ((region=NewRegion()))
	{
		// Set rectangle
		OrRectRegion(region,&rect);

		// Install region
		InstallClipRegion(data->window->WLayer,region);
	}

	// Refreshing?
	if (refresh) BeginRefresh(data->window);

	// Got a font?
	if (data->font)
	{
		ULONG flags;
		short y;
		struct TextExtent extent;
		char *ptr,*end;

		// Set pen and font
		SetAPen(&rp,DRAWINFO(data->window)->dri_Pens[TEXTPEN]);
		SetDrMd(&rp,JAM1);
		SetFont(&rp,data->font);

		// Get style flags
		flags=0;
		if (GetGadgetValue(data->list,GAD_FONT_BOLD)) flags|=FSF_BOLD;
		if (GetGadgetValue(data->list,GAD_FONT_ITALIC)) flags|=FSF_ITALIC;
		if (GetGadgetValue(data->list,GAD_FONT_ULINE)) flags|=FSF_UNDERLINED;

		// Set styles
		SetSoftStyle(&rp,flags,FSF_BOLD|FSF_ITALIC|FSF_UNDERLINED);

		// Valid font to draw?
		if (data->font_text[0])
		{
			// Get end of the string
			end=data->font_text+strlen(data->font_text);

			// Initial coordinates
			y=rect.MinY;

			// Initialise position
			if (!(ptr=strchr(data->font_text,'A')))
				ptr=data->font_text;
			Move(&rp,rect.MinX,y+rp.TxBaseline);

			// Draw until we reach the bottom
			while (y<rect.MaxY)
			{
				// New line
				if (rp.cp_x>rect.MaxX)
				{
					// Bump position
					y+=rp.TxHeight+1;
					Move(&rp,rect.MinX,y+rp.TxBaseline);
				}

				// Otherwise
				else
				{
					short len,maxlen;

					// Get text that will fit
					len=
						TextFit(
							&rp,
							ptr,
							(maxlen=strlen(ptr)),
							&extent,
							0,1,
							rect.MaxX-rp.cp_x+1,
							rp.TxHeight);

					// Check against length, add extra character if ok
					if (len<maxlen) ++len;

					// Draw text
					Text(&rp,ptr,len);

					// Bump text position
					ptr+=len;

					// End of the string?
					if (ptr>=end) ptr=data->font_text;
				}
			}
		}
	}

	// Finished refreshing?
	if (refresh) EndRefresh(data->window,TRUE);

	// Remove region
	if (region)
	{
		InstallClipRegion(data->window->WLayer,0);
		DisposeRegion(region);
	}

	// Unlock layers if we refreshed
	if (refresh) UnlockLayerInfo(&data->window->WScreen->LayerInfo);
}
Example #5
0
File: mem01.c Project: palmerc/lab
boolean Mem_MoveChunk   (numtype       ChunkNum,  ft F,lt Z,zz *Status,  
                         addrtype     *FreeAddr,  sizeinbytes  *FreeSize)
{
addrtype      Source         = NullPtr;
addrtype      SourceRegion   = NullPtr;
sizeinbytes   SourceSize     = 0;
addrtype      TargetRegion   = NullPtr;
addrtype     *ChunkAddrPtr   = NullPtr;

 *FreeAddr      =  NullPtr;
 *FreeSize      =  0;

  if (DbmBug)
  if (TraceMsg (0, " BEFORE move ::    "))
      Mem_DumpChunkChunk (0, ChunkNum);

  SourceRegion  = Chunk_Addr (ChunkNum);
  SourceRegion  = (addrtype )((char *)SourceRegion - sizeof (chunkstruc));
  Source        = SourceRegion;

  SourceSize   = Unit_Size  (ChunkNum) *  Unit_Count (ChunkNum);
  SourceSize  += sizeof (chunkstruc);

  if (Normal(*Status))
  {
/*   This is a Normal Chunk Expansion                                      */
     if (NewRegion   (SourceSize,      McStat,     (addrtype *)&ChunkAddrPtr))
     {
        TargetRegion = ChunkAddrPtr;

        if (DbmBug || MemBug)
        {
           sprintf (Msg, TraceStr(41),
/* "     Copy from Source(* %8u) @%x TO Target @%x\n" */
                    SourceSize, SourceRegion, TargetRegion);
           TraceMsg (0, Msg);
        }

        memcpy  ((char *)ChunkAddrPtr, (char *)SourceRegion, SourceSize);

/*      Adjust for the chunkstruc Header Block                            */
        TargetRegion  = (addrtype )((char *)TargetRegion
                                          + sizeof (chunkstruc));
        ChunkAddrPtr  = (addrtype *)TargetRegion;

/*      Set the Chunk Stats on the New Chunk                              */
        Chunk_Addr(ChunkNum)    = TargetRegion;

        if (DbmBug)
        if (TraceMsg (0, " AFTER  move ::    "))
           Mem_DumpChunkChunk (0, ChunkNum);
     }

    *FreeAddr      =  Source;
    *FreeSize      =  SourceSize;

     if (DbmBug)
     {
        sprintf (Msg, 
          " Mem_MoveChunk [%6u] :: TO Target @%8x; Size :=%6u,  From @%8x.\n",
                 ChunkNum, TargetRegion, SourceSize, SourceRegion);
        TraceMsg (0, Msg);
     }
  }

TRACK(TrackBak,"Mem_MoveChunk\n");
return(STAT);
}
Example #6
0
static struct Region *shapefunc(struct Hook *hook, struct Layer *lay, struct ShapeHookMsg *msg)
{
    struct Region *newshape, *retregion = msg->ActualShape;
    WORD x2, y2;
  
    switch(msg->Action)
    {
    	case SHAPEHOOKACTION_CREATELAYER:
	case SHAPEHOOKACTION_SIZELAYER:
	case SHAPEHOOKACTION_MOVESIZELAYER:
	    x2 = msg->NewBounds.MaxX - msg->NewBounds.MinX;
	    y2 = msg->NewBounds.MaxY - msg->NewBounds.MinY;
	    
	    if ((newshape = NewRegion()))
	    {
	    	struct Rectangle rect;
		BOOL success = TRUE;
		
		rect.MinX = 9;
		rect.MinY = 0;
		rect.MaxX = x2 - 9;
		rect.MaxY = y2;
		success &= OrRectRegion(newshape, &rect);
		
		rect.MinX = 6;
		rect.MinY = 1;
		rect.MaxX = x2 - 6;
		rect.MaxY = y2 - 1;
		success &= OrRectRegion(newshape, &rect);
		
		rect.MinX = 4;
		rect.MinY = 2;
		rect.MaxX = x2 - 4;
		rect.MaxY = y2 - 2;		
		success &= OrRectRegion(newshape, &rect);
		
		rect.MinX = 3;
		rect.MinY = 3;
		rect.MaxX = x2 - 3;
		rect.MaxY = y2 - 3;
		success &= OrRectRegion(newshape, &rect);
		
		rect.MinX = 2;
		rect.MinY = 4;
		rect.MaxX = x2 - 2;
		rect.MaxY = y2 - 4;
		success &= OrRectRegion(newshape, &rect);
		
		rect.MinX = 1;
		rect.MinY = 6;
		rect.MaxX = x2 - 1;
		rect.MaxY = y2 - 6;
		success &= OrRectRegion(newshape, &rect);

		rect.MinX = 0;
		rect.MinY = 9;
		rect.MaxX = x2;
		rect.MaxY = y2 - 9;
		success &= OrRectRegion(newshape, &rect);
		
		if (success)
		{
	    	    if (msg->ActualShape) DisposeRegion(msg->ActualShape);
	    	    retregion = shape = newshape;
		}
		else
		{
		    DisposeRegion(newshape);
		}
		
	    } /* if ((newshape = NewRegion())) */
	    
    } /* switch(msg->Action) */
    
    return retregion;
}
Example #7
0
// Initialise backdrop info
void backdrop_init_info(
	BackdropInfo *info,
	struct Window *window,
	short no_icons)
{
	// Backdrop window pointer
	info->window=window;

	// Initialise size
	info->size.MinX=window->BorderLeft+info->left_border;
	info->size.MinY=window->BorderTop+info->top_border;
	info->size.MaxX=window->Width-window->BorderRight-info->right_border-1;
	info->size.MaxY=window->Height-window->BorderBottom-info->bottom_border-1;

	// Not re-initialising?
	if (no_icons!=-1)
	{
		BackdropObject *icon;

		// Clone rastport
		info->rp=*window->RPort;

		// Get font
		backdrop_get_font(info);

		// If not backdrop window, add scroll bars
		if (!(window->Flags&WFLG_BACKDROP))
		{
			// Create scroll bars
			if (AddScrollBars(window,&info->boopsi_list,GUI->draw_info,SCROLL_VERT|SCROLL_HORIZ|SCROLL_NOIDCMP))
			{
				// Get scrollers
				info->vert_scroller=FindBOOPSIGadget(&info->boopsi_list,GAD_VERT_SCROLLER);
				info->horiz_scroller=FindBOOPSIGadget(&info->boopsi_list,GAD_HORIZ_SCROLLER);

				// Add to window
				AddGList(window,info->vert_scroller,-1,-1,0);
				RefreshGList(info->vert_scroller,window,0,-1);
			}
		}

		// Get clip region
		info->clip_region=NewRegion();
		info->temp_region=NewRegion();

		// Allocate notification port
		if (info->notify_port=CreateMsgPort())
		{
			// Add notify request
			info->notify_req=AddNotifyRequest(DN_WRITE_ICON,0,info->notify_port);
		}

		// Lock icon list
		lock_listlock(&info->objects,0);

		// Remap existing icons
		for (icon=(BackdropObject *)info->objects.list.lh_Head;
			icon->node.ln_Succ;
			icon=(BackdropObject *)icon->node.ln_Succ)
		{
			// Remap the icon
			if (RemapIcon(icon->icon,info->window->WScreen,0))
			{
				// Had icon never been remapped before?
				if (!(icon->flags&BDOF_REMAPPED))
				{
					// Get new object size, etc
					backdrop_get_icon(info,icon,GETICON_KEEP|GETICON_POS_ONLY|GETICON_SAVE_POS|GETICON_REMAP);

					// Get new masks
					backdrop_get_masks(icon);
				}
			}
			
			// Set flag to say we've been remapped
			icon->flags|=BDOF_REMAPPED;
		}

		// Unlock icon list
		unlock_listlock(&info->objects);
	}

	// Install clip
	if (info->clip_region)
		backdrop_install_clip(info);
}
Example #8
0
static void Action(void)
{
    struct Region *clip, *oldclip;
    struct Rectangle rect1;
    struct Rectangle rect2;
    struct IntuiMessage *msg;
    WORD col = 1;
    BOOL installed = TRUE;
    BOOL quitme = FALSE;

    rect1.MinX =  20;rect1.MinY = 80;
    rect1.MaxX = 180;rect1.MaxY = 120;
    rect2.MinX =  80;rect2.MinY = 20;
    rect2.MaxX = 120;rect2.MaxY = 180;

    Move(rp, 20, 20);
    Draw(rp, 180, 180);

    clip = NewRegion();
    if (!clip) Cleanup("Can't create clip region!");

    OrRectRegion(clip, &rect1);
    OrRectRegion(clip, &rect2);

    oldclip = InstallClipRegion(lay, clip);

    SetAPen(rp,col);
    RectFill(rp,0,0,1000,1000);

    while(!quitme)
    {
	WaitPort(win->UserPort);
	while ((msg = (struct IntuiMessage *)GetMsg(win->UserPort)))
	{
	    switch(msg->Class)
	    {
	    case IDCMP_CLOSEWINDOW:
		quitme = TRUE;
		break;

	    case IDCMP_VANILLAKEY:
	        switch (msg->Code)
	        {
	        case 'c':
	        case 'C':
	        if (installed)
	        {
	            InstallClipRegion(lay, oldclip);
	            installed = FALSE;
	        }
	        else
	        {
	            oldclip = InstallClipRegion(lay, clip);
	            installed = TRUE;
	        }    
		/* Fallthrough */

	        default:
		    col = 3 - col;
		    SetAPen(rp,col);
		    RectFill(rp,0,0,1000,1000);
		    break;
		}

	    case IDCMP_REFRESHWINDOW:
		BeginRefresh(win);
		SetAPen(rp,col);
		RectFill(rp,0,0,1000,1000);					
		EndRefresh(win,TRUE);
		break;
	    }

	    ReplyMsg((struct Message *)msg);
	}
    }

    if (installed)
	InstallClipRegion(lay, oldclip);
    DisposeRegion(clip);
}
Example #9
0
    EXAMPLE

    BUGS

    SEE ALSO
	XorRegionRegion(), OrRegionRegion()

    INTERNALS

    HISTORY

*****************************************************************************/
{
    AROS_LIBFUNC_INIT

    struct Region *R3 = NewRegion();

    if (!R3)
    {
    	/* Out of memory, failed */
    	return NULL;
    }

    if (!R2->RegionRectangle)
    {
    	/* R2 is already empty, nothing to clear */
    	return R3;
    }

    if (!R1->RegionRectangle            ||
        !overlap(R1->bounds, R2->bounds))
Example #10
0
// Initialise a new lister
IPC_StartupCode(lister_init, Lister *, lister, static)
{
	// Store IPC and lister pointers
	lister->ipc=ipc;
	ipc->userdata=lister;

	// Store IPC pointer in backdrop info
	lister->backdrop_info->ipc=ipc;

	// Path history list
	lister->path_history=Att_NewList(LISTF_LOCK);

	// Initialise reselection
	InitReselect(&lister->reselect);
	lister->abort_signal=-1;

	// Create message ports and signals
	if (!(lister->app_port=CreateMsgPort()) ||
		!(lister->timer_port=CreateMsgPort()) ||
		(lister->hot_name_bit=AllocSignal(-1))==-1 ||
		(lister->abort_signal=AllocSignal(-1))==-1)
		return 0;

	// Allocate some timers
	if (!(lister->busy_timer=AllocTimer(UNIT_VBLANK,lister->timer_port)) ||
		!(lister->scroll_timer=AllocTimer(UNIT_VBLANK,lister->timer_port)) ||
		!(lister->edit_timer=AllocTimer(UNIT_VBLANK,lister->timer_port)) ||
		!(lister->foo_timer=AllocTimer(UNIT_VBLANK,lister->timer_port)))
		return 0;
	StartTimer(lister->foo_timer,5,0);

	// Create regions
	if (!(lister->title_region=NewRegion()) ||
		!(lister->refresh_extra=NewRegion()))
		return 0;

	// Lock buffer list
	lock_listlock(&GUI->buffer_list,TRUE);

	// Allocate initial buffer
	if (!(lister->cur_buffer=lister_get_empty_buffer()) &&
		!(lister->cur_buffer=lister_new_buffer(lister)))
		return 0;
	lister->cur_buffer->buf_CurrentLister=lister;

	// Unlock buffer list
	unlock_listlock(&GUI->buffer_list);

	// Allocate "special" buffer
	if (!(lister->special_buffer=buffer_new()))
		return 0;

	// Build popup menu
	lister_build_menu(lister);

	// Initialise flags
	lister->flags|=LISTERF_FIRST_TIME;
	lister->flags2|=LISTERF2_UNAVAILABLE;
	lister->tool_sel=-1;
	lister->toolbar_offset=0;

	// Fix priority
	lister->normal_pri=environment->env->settings.pri_lister[0];
	lister->busy_pri=environment->env->settings.pri_lister[1];
	SetTaskPri((struct Task *)lister->ipc->proc,lister->normal_pri);

	// Get font to use
	lister->lister_font.ta_Name=lister->font_name;
	lister->lister_font.ta_YSize=lister->font_size;
	lister->lister_font.ta_Flags=0;
	lister->lister_font.ta_Style=0;

	// Open font
	if ((lister->font=OpenDiskFont(&lister->lister_font)))
	{
		// Proportional	font?
		if (lister->font->tf_Flags&FPF_PROPORTIONAL)
			lister->more_flags|=LISTERF_PROP_FONT;

		// Set font in text area
		InitRastPort(&lister->text_area.rast);
		SetFont(&lister->text_area.rast,lister->font);
	}

	return 1;
}