mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-03 17:56:21 +03:00
0028314: Application Framework - Display mode is not saved within XML OCAF document
A rebased up-to-date version: - a bug is fixed (storage and retrieval of display mode in XML file format) - draw-commands to manipulate the display and selection mode are implemented - a test command "caf presentation M1" is created
This commit is contained in:
parent
41fbbba8c4
commit
c9776c7ac0
@ -598,6 +598,79 @@ static Standard_Integer DPrsStd_AISHasOwnTransparency (Draw_Interpretor& di,
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DPrsStd_AISMode
|
||||
//purpose : AISMode (DOC,entry,[Mode])
|
||||
//=======================================================================
|
||||
static Standard_Integer DPrsStd_AISMode(Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
TDF_Label L;
|
||||
Handle(TDocStd_Document) D;
|
||||
Handle(TPrsStd_AISPresentation) prs;
|
||||
if (nb >= 3 && nb <= 4)
|
||||
{
|
||||
if (!DDocStd::GetDocument(arg[1],D))
|
||||
return 1;
|
||||
if (!DDF::FindLabel(D->GetData(),arg[2],L))
|
||||
return 1;
|
||||
if (!L.FindAttribute(TPrsStd_AISPresentation::GetID(), prs))
|
||||
return 1;
|
||||
if (nb == 4)
|
||||
{
|
||||
Standard_Integer mode = Draw::Atoi(arg[3]);
|
||||
prs->SetMode(mode);
|
||||
TPrsStd_AISViewer::Update(L);
|
||||
}
|
||||
else if (nb == 3)
|
||||
{
|
||||
Standard_Integer mode = prs->Mode();
|
||||
di<<mode;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
di<<"DPrsStd_AISMode : Error\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DPrsStd_AISSelMode
|
||||
//purpose : AISSelMode (DOC,entry,[SelMode])
|
||||
//=======================================================================
|
||||
static Standard_Integer DPrsStd_AISSelMode(Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
TDF_Label L;
|
||||
Handle(TDocStd_Document) D;
|
||||
Handle(TPrsStd_AISPresentation) prs;
|
||||
if (nb >= 3 && nb <= 4)
|
||||
{
|
||||
if (!DDocStd::GetDocument(arg[1],D))
|
||||
return 1;
|
||||
if (!DDF::FindLabel(D->GetData(),arg[2],L))
|
||||
return 1;
|
||||
if (!L.FindAttribute(TPrsStd_AISPresentation::GetID(), prs))
|
||||
return 1;
|
||||
if (nb == 4)
|
||||
{
|
||||
// Set selection mode.
|
||||
Standard_Integer selMode = Draw::Atoi(arg[3]);
|
||||
prs->SetSelectionMode(selMode);
|
||||
TPrsStd_AISViewer::Update(L);
|
||||
}
|
||||
else if (nb == 3)
|
||||
{
|
||||
// Print selection mode.
|
||||
Standard_Integer selMode = prs->SelectionMode();
|
||||
di<<selMode;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
di<<"DPrsStd_AISSelMode : Error\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AISPresentationCommands
|
||||
@ -677,4 +750,12 @@ void DPrsStd::AISPresentationCommands (Draw_Interpretor& theCommands)
|
||||
theCommands.Add ("AISRemove",
|
||||
"AISRemove (DOC, entry)",
|
||||
__FILE__, DPrsStd_AISRemove, g);
|
||||
|
||||
theCommands.Add ("AISMode",
|
||||
"AISMode (DOC, entry, [Mode])",
|
||||
__FILE__, DPrsStd_AISMode, g);
|
||||
|
||||
theCommands.Add ("AISSelMode",
|
||||
"AISSelMode (DOC, entry, [SelMode])",
|
||||
__FILE__, DPrsStd_AISSelMode, g);
|
||||
}
|
||||
|
@ -234,12 +234,10 @@ void XmlMDataXtd_PresentationDriver::Paste
|
||||
theTarget.Element().setAttribute(::WidthString(), aRNbStr.ToCString());
|
||||
}
|
||||
|
||||
#ifdef OCC6010
|
||||
// mode
|
||||
if (aTPrs->HasOwnMode())
|
||||
{
|
||||
aNb = aTPrs->Mode();
|
||||
theTarget.Element().setAttribute(::ModeString(), aNb);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
27
tests/caf/presentation/M1
Normal file
27
tests/caf/presentation/M1
Normal file
@ -0,0 +1,27 @@
|
||||
#INTERFACE CAF
|
||||
# Presentation attributes
|
||||
#
|
||||
# Testing attribute: TPrsStd_AISPresentation
|
||||
#
|
||||
# Testing command: AISMode, storage of display mode in XML file
|
||||
#
|
||||
|
||||
NewDocument D1 XmlOcaf
|
||||
AISInitViewer D1
|
||||
box b 100 100 100
|
||||
SetShape D1 0:1 b
|
||||
AISSet D1 0:1 NS
|
||||
AISDisplay D1 0:1
|
||||
AISMode D1 0:1 1
|
||||
|
||||
SaveAs D1 testmode.xml
|
||||
Close D1
|
||||
Open testmode.xml D2
|
||||
AISInitViewer D2
|
||||
AISDisplay D2 0:1
|
||||
set mode [AISMode D2 0:1]
|
||||
if { ${mode} != 1 } {
|
||||
puts ${mode}
|
||||
puts "Storage of display mode of TPrsStd_AISPresentation attribute in XML document: Error"
|
||||
return
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user