/*
 * setMarginWidth - Set the margin width.
 *
 * parameter _margineWidth - GLfloat
 */
void SliceWidget::setMarginWidth(GLfloat _marginWidth) {
    marginWidth = _marginWidth;
    if (isManaged) {
        parent->requestResize(this, calcNaturalSize());
    } else
        resize(GLMotif::Box(GLMotif::Vector(0.0f, 0.0f, 0.0f), calcNaturalSize()));
} // end setMarginWidth()
Пример #2
0
void PopupWindow::setCloseButton(bool enable)
	{
	if(enable&&closeButton==0)
		{
		/* Create the close button: */
		closeButton=new NewButton("HideButton",this,false);
		closeButton->setBorderWidth(titleBar->getBorderWidth());
		closeButton->setBorderType(titleBar->getBorderType());
		closeButton->setBorderColor(titleBar->getBorderColor());
		closeButton->setBackgroundColor(titleBar->getBackgroundColor());
		closeButton->setArmedBackgroundColor(titleBar->getBackgroundColor());
		closeButton->setForegroundColor(titleBar->getForegroundColor());
		closeButton->getSelectCallbacks().add(this,&PopupWindow::closeButtonCallback);
		Glyph* cbGlyph=new Glyph("Glyph",closeButton,GlyphGadget::CROSS,GlyphGadget::IN);
		cbGlyph->setBorderWidth(0.0f);
		
		closeButton->manageChild();
		
		/* Resize the widget: */
		resize(Box(Vector(0.0f,0.0f,0.0f),calcNaturalSize()));
		}
	
	if(!enable&&closeButton!=0)
		{
		/* Delete the close button: */
		deleteChild(closeButton);
		closeButton=0;
		
		/* Resize the widget: */
		resize(Box(Vector(0.0f,0.0f,0.0f),calcNaturalSize()));
		}
	}
Пример #3
0
void ColorMap::setMarginWidth(GLfloat newMarginWidth)
	{
	/* Set the new margin width: */
	marginWidth=newMarginWidth;
	
	if(isManaged)
		{
		/* Try adjusting the widget size to accomodate the new margin width: */
		parent->requestResize(this,calcNaturalSize());
		}
	else
		resize(Box(Vector(0.0f,0.0f,0.0f),calcNaturalSize()));
	}
Пример #4
0
void ColorMap::setPreferredSize(const Vector& newPreferredSize)
	{
	/* Set the new preferred size: */
	preferredSize=newPreferredSize;
	
	if(isManaged)
		{
		/* Try adjusting the widget size to accomodate the new preferred size: */
		parent->requestResize(this,calcNaturalSize());
		}
	else
		resize(Box(Vector(0.0f,0.0f,0.0f),calcNaturalSize()));
	}
Пример #5
0
void DropdownBox::setArrowSize(GLfloat newArrowSize)
	{
	/* Adjust the arrow glyph: */
	arrow.setGlyphSize(newArrowSize);
	
	/* Adjust the label position: */
	setInsets(0.0f,arrow.getPreferredBoxSize()+spacing);
	
	/* Try adjusting the widget size to accomodate the new setting: */
	if(isManaged)
		parent->requestResize(this,calcNaturalSize());
	else
		resize(Box(Vector(0.0f,0.0f,0.0f),calcNaturalSize()));
	}
/*
 * setPreferredSize - Set color map preferred size.
 *
 * parameter _preferredSize - const GLMotif::Vector&
 */
void SliceWidget::setPreferredSize(const GLMotif::Vector& _preferredSize) {
    preferredSize = _preferredSize;
    if (isManaged) {
        parent->requestResize(this, calcNaturalSize());
    } else
        resize(GLMotif::Box(GLMotif::Vector(0.0f, 0.0f, 0.0f), calcNaturalSize()));
    GLfloat x1 = SliceWidgetAreaBox.getCorner(0)[0];
    GLfloat x2 = SliceWidgetAreaBox.getCorner(1)[0];
    GLfloat y1 = SliceWidgetAreaBox.getCorner(0)[1];
    GLfloat y2 = SliceWidgetAreaBox.getCorner(2)[1];
    GLfloat z = SliceWidgetAreaBox.getCorner(0)[2];
    GLfloat width = x2 - x1;
    GLfloat height = y2 - y1;
} // end setPreferredSize()
Пример #7
0
void Pager::removeChild(Widget* removeChild)
	{
	/* Find the given widget in the list of children: */
	WidgetList::iterator cIt;
	unsigned int childIndex=0;
	for(cIt=children.begin();cIt!=children.end()&&*cIt!=removeChild;++cIt,++childIndex)
		;
	if(cIt!=children.end())
		{
		/* Remove the child from the list: */
		children.erase(cIt);
		
		/* Remove the child's associated page button from the list: */
		deleteChild(pageButtons[childIndex]);
		pageButtons.erase(pageButtons.begin()+childIndex);
		
		/* Update the child insertion position: */
		if(nextChildIndex>GLint(children.size()))
			nextChildIndex=GLint(children.size());
		
		if(isManaged)
			{
			/* Try to resize the widget to calculate the new layout: */
			parent->requestResize(this,calcNaturalSize());
			}
		}
	}
Пример #8
0
void Popup::setTitleSpacing(GLfloat newTitleSpacing)
	{
	/* Change the title spacing: */
	titleSpacing=newTitleSpacing;
	
	/* Resize the widget: */
	resize(Box(Vector(0.0f,0.0f,0.0f),calcNaturalSize()));
	}
Пример #9
0
void Popup::setMarginWidth(GLfloat newMarginWidth)
	{
	/* Change the margin width: */
	marginWidth=newMarginWidth;
	
	/* Resize the widget: */
	resize(Box(Vector(0.0f,0.0f,0.0f),calcNaturalSize()));
	}
Пример #10
0
void PopupWindow::setChildBorderWidth(GLfloat newChildBorderWidth)
	{
	/* Change the child border width: */
	childBorderWidth=newChildBorderWidth;
	
	/* Resize the widget: */
	resize(Box(Vector(0.0f,0.0f,0.0f),calcNaturalSize()));
	}
Пример #11
0
void ColorBar::setValueRange(double newValueMin,double newValueMax)
	{
	/* Set the new value range: */
	valueMin=newValueMin;
	valueMax=newValueMax;
	
	/* Update the tick marks: */
	updateTickMarks();
	
	if(isManaged)
		{
		/* Try adjusting the widget size to accomodate the new label: */
		parent->requestResize(this,calcNaturalSize());
		}
	else
		resize(Box(Vector(0.0f,0.0f,0.0f),calcNaturalSize()));
	}
Пример #12
0
void PopupWindow::setTitleString(const char* newTitleString)
	{
	/* Change the title bar's label string: */
	titleBar->setString(newTitleString);
	
	/* Resize the widget: */
	resize(Box(Vector(0.0f,0.0f,0.0f),calcNaturalSize()));
	}
Пример #13
0
void DropdownBox::clearItems(void)
	{
	/* Remove all buttons from the drop-down list: */
	while(numItems>0)
		{
		items->removeWidgets(numItems-1);
		--numItems;
		}
	
	/* Reset the selected item: */
	selectedItem=-1;
	
	/* Resize the widget to accomodate the new list: */
	if(isManaged)
		parent->requestResize(this,calcNaturalSize());
	else
		resize(Box(Vector(0.0f,0.0f,0.0f),calcNaturalSize()));
	}
Пример #14
0
void ScaleBar::pointerButtonDown(GLMotif::Event& event)
	{
	Scalar newScale=currentScale;
	
	/* Check if the event happened in the left or right corner: */
	float relEventPos=(event.getWidgetPoint().getPoint()[0]-getInterior().origin[0])/getInterior().size[0];
	if(relEventPos<=0.333f)
		{
		/* Calculate the next smaller quasi-binary scale factor: */
		newScale=Scalar(getSmallerQuasiBinary(currentScale));
		}
	else if(relEventPos>=0.667f)
		{
		/* Calculate the next bigger quasi-binary scale factor: */
		newScale=Scalar(getBiggerQuasiBinary(currentScale));
		}
	
	if(newScale!=currentScale&&activateNavigationTool(reinterpret_cast<const Tool*>(this)))
		{
		/* Adjust the navigation transformation: */
		Scalar newNavScale;
		const Geometry::LinearUnit& unit=getCoordinateManager()->getUnit();
		if(unit.isImperial())
			{
			/* Calculate scale factor through imperial units: */
			newNavScale=getInchFactor()*newScale/unit.getInchFactor();
			}
		else
			{
			/* Calculate scale factor through metric units: */
			newNavScale=getMeterFactor()*newScale/unit.getMeterFactor();
			}
		
		/* Get the current navigation transformation and calculate the display center position in navigation coordinates: */
		const NavTransform& nav=getNavigationTransformation();
		Point center=nav.inverseTransform(getDisplayCenter());
		
		/* Create the new navigation transformation: */
		NavTransform newNav=NavTransform(nav.getTranslation(),nav.getRotation(),newNavScale);
		newNav.leftMultiply(NavTransform::translate(getDisplayCenter()-newNav.transform(center)));
		setNavigationTransformation(newNav);
		
		deactivateNavigationTool(reinterpret_cast<const Tool*>(this));
		currentScale=newScale;
		
		/* Update the scale bar: */
		calcSize(newNav);
		
		/* Resize the widget so that the clicked point stays in the same place: */
		GLMotif::Vector newSize=calcNaturalSize();
		GLfloat newInteriorWidth=newSize[0]-2.0f*getBorderWidth();
		GLfloat newOrigin=event.getWidgetPoint().getPoint()[0]-newInteriorWidth*relEventPos-getBorderWidth();
		resize(GLMotif::Box(GLMotif::Vector(newOrigin,0.0f,0.0f),newSize));
		}
	}
Пример #15
0
void Pager::setMarginWidth(GLfloat newMarginWidth)
	{
	/* Set the margin width: */
	marginWidth=newMarginWidth;
	
	if(isManaged)
		{
		/* Try to resize the widget to accomodate the new setting: */
		parent->requestResize(this,calcNaturalSize());
		}
	}
Пример #16
0
void PopupWindow::setTitleBorderWidth(GLfloat newTitleBorderWidth)
	{
	/* Set border width of the title bar: */
	titleBar->setBorderWidth(newTitleBorderWidth);
	if(hideButton!=0)
		hideButton->setBorderWidth(newTitleBorderWidth);
	if(closeButton!=0)
		closeButton->setBorderWidth(newTitleBorderWidth);
	
	/* Resize the widget: */
	resize(Box(Vector(0.0f,0.0f,0.0f),calcNaturalSize()));
	}
Пример #17
0
void DropdownBox::addItem(const char* newItem)
	{
	/* Get the style sheet: */
	// const GLMotif::StyleSheet& ss=*getManager()->getStyleSheet();
	
	/* Create a new button in the drop-down list: */
	char itemButtonName[40];
	snprintf(itemButtonName,sizeof(itemButtonName),"ItemButton%d",numItems);
	Button* button=new Button(itemButtonName,items,newItem);
	button->setBorderType(Widget::PLAIN);
	button->setBorderWidth(0.0f);
	button->setHAlignment(GLFont::Left);
	button->getSelectCallbacks().add(itemSelectedCallbackWrapper,this);
	++numItems;
	
	/* Resize the widget to accomodate the new item: */
	if(isManaged)
		parent->requestResize(this,calcNaturalSize());
	else
		resize(Box(Vector(0.0f,0.0f,0.0f),calcNaturalSize()));
	}
Пример #18
0
void Popup::addChild(Widget* newChild)
	{
	/* Delete the current child: */
	delete child;
	child=0;
	
	/* Add the new child: */
	child=newChild;
	
	/* Resize the widget: */
	resize(Box(Vector(0.0f,0.0f,0.0f),calcNaturalSize()));
	}
Пример #19
0
void PopupWindow::addChild(Widget* newChild)
	{
	if(newChild!=titleBar&&newChild!=hideButton&&newChild!=closeButton)
		{
		/* Delete the current child: */
		deleteChild(child);
		
		/* Add the new child: */
		child=newChild;
		
		/* Resize the widget: */
		resize(Box(Vector(0.0f,0.0f,0.0f),calcNaturalSize()));
		}
	}
Пример #20
0
ScaleBar::ScaleBar(const char* sName,GLMotif::WidgetManager* sManager)
	:GLMotif::Widget(sName,0,false),manager(sManager),
	 targetLength(getDisplaySize()*Scalar(0.2)),
	 currentMantissa(1),currentExponent(0),currentNavLength(1),currentScale(1),
	 lengthLabel(0),scaleLabel(0),
	 currentPhysLength(0)
	{
	/* Set widget parameters: */
	setBorderWidth(0.0f);
	setBorderType(GLMotif::Widget::PLAIN);
	
	/* Set default background and foreground colors: */
	Color bgColor=Vrui::getBackgroundColor();
	bgColor[3]=0.0f;
	Color fgColor;
	for(int i=0;i<3;++i)
		fgColor[i]=1.0f-bgColor[i];
	fgColor[3]=1.0f;
	setBorderColor(bgColor);
	setBackgroundColor(bgColor);
	setForegroundColor(fgColor);
	
	/* Create the initial scale bar length label: */
	if(getCoordinateManager()->getUnit().unit!=Geometry::LinearUnit::UNKNOWN)
		{
		char labelText[10];
		snprintf(labelText,sizeof(labelText),"1 %s",getCoordinateManager()->getUnit().getAbbreviation());
		lengthLabel=new GLLabel(labelText,*getUiFont());
		}
	else
		lengthLabel=new GLLabel("1",*getUiFont());
	lengthLabel->setBackground(bgColor);
	lengthLabel->setForeground(fgColor);
	scaleLabel=new GLLabel("1:1",*getUiFont());
	scaleLabel->setBackground(bgColor);
	scaleLabel->setForeground(fgColor);
	
	/* Calculate the initial navigation-space scale bar length: */
	calcSize(getNavigationTransformation());
	
	/* Resize the widget: */
	GLMotif::Vector newSize=calcNaturalSize();
	GLMotif::Vector newOrigin=GLMotif::Vector(0.0f,0.0f,0.0f);
	newOrigin[0]=-newSize[0]*0.5f;
	resize(GLMotif::Box(newOrigin,newSize));
	
	/* Register a navigation change callback with the Vrui kernel: */
	getNavigationTransformationChangedCallbacks().add(this,&ScaleBar::navigationChangedCallback);
	}
Пример #21
0
void ScaleBar::navigationChangedCallback(NavigationTransformationChangedCallbackData* cbData)
	{
	/* Check if the navigation scale changed: */
	if(cbData->oldTransform.getScaling()!=cbData->newTransform.getScaling())
		{
		/* Update the scale bar: */
		calcSize(cbData->newTransform);
		
		/* Resize the widget: */
		GLMotif::Vector newSize=calcNaturalSize();
		GLMotif::Vector newOrigin=GLMotif::Vector(0.0f,0.0f,0.0f);
		newOrigin[0]=-newSize[0]*0.5f;
		resize(GLMotif::Box(newOrigin,newSize));
		}
	}
Пример #22
0
void PopupWindow::removeChild(Widget* removeChild)
	{
	/* Check if the given widget is really the child: */
	if(child!=0&&child==removeChild)
		{
		/* Tell the child that it is being removed: */
		child->unmanageChild();
		
		/* Remove the child: */
		child=0;
		}
	
	/* Resize the widget: */
	resize(Box(Vector(0.0f,0.0f,0.0f),calcNaturalSize()));
	}
Пример #23
0
void Popup::setTitle(const char* titleString)
	{
	/* Delete the current title: */
	delete title;
	title=0;
	
	if(titleString!=0)
		{
		/* Create a new title widget: */
		title=new Label("_Title",this,titleString,false);
		title->setHAlignment(GLFont::Center);
		}
	
	/* Resize the widget: */
	resize(Box(Vector(0.0f,0.0f,0.0f),calcNaturalSize()));
	}
Пример #24
0
void Pager::addChild(Widget* newChild)
	{
	/* Do nothing if the new child is actually a page button: */
	if(addingPageButton)
		return;
	
	/* Add the child to the list at the selected position: */
	children.insert(children.begin()+nextChildIndex,newChild);
	
	/* Create a new page button: */
	char pbName[20];
	snprintf(pbName,sizeof(pbName),"PageButton%u",nextPageIndex);
	++nextPageIndex;
	Button* newPageButton;
	addingPageButton=true;
	if(!nextPageName.empty())
		{
		newPageButton=new Button(pbName,this,nextPageName.c_str());
		nextPageName="";
		}
	else
		{
		/* Create a default page button label: */
		char pbLabel[20];
		snprintf(pbLabel,sizeof(pbLabel),"Page %u",nextPageIndex);
		newPageButton=new Button(pbName,this,pbLabel);
		}
	addingPageButton=false;
	newPageButton->setBorderWidth(newPageButton->getBorderWidth()*0.5f);
	newPageButton->getSelectCallbacks().add(this,&Pager::pageButtonSelectCallback);
	
	/* Add the page button to the list: */
	pageButtons.insert(pageButtons.begin()+nextChildIndex,newPageButton);
	
	/* Select the just-added child: */
	setCurrentChildIndex(nextChildIndex);
	
	/* Prepare for the next page: */
	nextChildIndex=GLint(children.size());
	
	if(isManaged)
		{
		/* Try to resize the widget to accomodate the new child: */
		parent->requestResize(this,calcNaturalSize());
		}
	}
Пример #25
0
void PopupWindow::pointerMotion(Event& event)
	{
	if(isResizing)
		{
		const Point& p=event.getWidgetPoint().getPoint();
		
		/* Get the current exterior box: */
		Box exterior=getExterior();
		
		/* Get the minimal exterior size: */
		Vector minSize=calcNaturalSize();
		
		/* Resize the box horizontally: */
		if(resizeBorderMask&0x1)
			{
			GLfloat right=exterior.origin[0]+exterior.size[0];
			GLfloat newLeft=p[0]+resizeOffset[0];
			GLfloat newSize=right-newLeft;
			if(newSize<minSize[0])
				newSize=minSize[0];
			exterior.origin[0]=right-newSize;
			exterior.size[0]=newSize;
			}
		else if(resizeBorderMask&0x2)
			{
			GLfloat left=exterior.origin[0];
			GLfloat newRight=p[0]+resizeOffset[0];
			GLfloat newSize=newRight-left;
			if(newSize<minSize[0])
				newSize=minSize[0];
			exterior.size[0]=newSize;
			}
		
		/* Resize the box vertically: */
		if(resizeBorderMask&0x4)
			{
			GLfloat top=exterior.origin[1]+exterior.size[1];
			GLfloat newBottom=p[1]+resizeOffset[1];
			GLfloat newSize=top-newBottom;
			if(newSize<minSize[1])
				newSize=minSize[1];
			exterior.origin[1]=top-newSize;
			exterior.size[1]=newSize;
			}
		else if(resizeBorderMask&0x8)
			{
			GLfloat bottom=exterior.origin[1];
			GLfloat newTop=p[1]+resizeOffset[1];
			GLfloat newSize=newTop-bottom;
			if(newSize<minSize[1])
				newSize=minSize[1];
			exterior.size[1]=newSize;
			}
		
		if(exterior.size[0]!=getExterior().size[0]||exterior.size[1]!=getExterior().size[1])
			{
			/* Resize the popup window: */
			resize(exterior);
			}
		}
	}