Implementation of "EDF 1702 GEOM: Displaying of GEOM object in 3D viewer while editing a group" and "EDF 1630 GEOM: Specific color when editing a group" issues.

This commit is contained in:
ana 2013-01-29 14:16:52 +00:00
parent 7191e58797
commit 03a4ab784b
8 changed files with 108 additions and 33 deletions

View File

@ -51,6 +51,7 @@
<parameter name="isos_color" value="200, 200, 200" />
<parameter name="toplevel_color" value="170, 85, 0" />
<parameter name="toplevel_dm" value="0" />
<parameter name="editgroup_color" value="170, 85, 0" />
<parameter name="type_of_marker" value="1" />
<parameter name="deflection_coeff" value="0.001" />
<parameter name="auto_create_base_objects" value="false" />

View File

@ -89,7 +89,7 @@ GEOM::GEOM_Gen_ptr GEOMBase_Helper::getGeomEngine()
GEOMBase_Helper::GEOMBase_Helper( SUIT_Desktop* desktop )
: myDesktop( desktop ), myViewWindow( 0 ), myDisplayer( 0 ), myCommand( 0 ), isPreview( false ),
myIsApplyAndClose( false ), myIsOptimizedBrowsing( false ), myIsWaitCursorEnabled( true ),
myIsDisableBrowsing(false)
myIsDisableBrowsing(false), myIsDisplayResult(true)
{
}
@ -876,7 +876,8 @@ bool GEOMBase_Helper::onAccept( const bool publish, const bool useTransaction, b
}
anEntryList << addInStudy( obj, aName.toLatin1().constData() );
// updateView=false
display( obj, false );
if( isDisplayResult() )
display( obj, false );
#ifdef WITHGENERICOBJ
// obj has been published in study. Its refcount has been incremented.
// It is safe to decrement its refcount
@ -889,7 +890,8 @@ bool GEOMBase_Helper::onAccept( const bool publish, const bool useTransaction, b
// was modified, and need to be re-cached in GEOM_Client before redisplay
clearShapeBuffer( obj );
// withChildren=true, updateView=false
redisplay( obj, true, false );
if( isDisplayResult() )
redisplay( obj, true, false );
}
}

View File

@ -191,6 +191,8 @@ protected:
virtual bool isWaitCursorEnabled() const {return myIsWaitCursorEnabled ;}
virtual void setIsDisableBrowsing( const bool theFlag ) { myIsDisableBrowsing = theFlag; }
virtual bool isDisableBrowsing() const { return myIsDisableBrowsing; }
virtual void setIsDisplayResult( const bool theFlag ) {myIsDisplayResult = theFlag; }
virtual bool isDisplayResult() const { return myIsDisplayResult; }
private:
QString getEntry( GEOM::GEOM_Object_ptr ) const;
@ -213,6 +215,7 @@ private:
bool myIsWaitCursorEnabled;
bool myIsDisableBrowsing; //This flag enable/disable selection
//in the Object Browser newly created objects.
bool myIsDisplayResult; //This flag display/hide newly created objects.
};
#endif // GEOMBASE_HELPER_H

View File

@ -3206,6 +3206,10 @@ Please, select face, shell or solid and try again</translation>
<source>PREF_PREDEF_MATERIALS</source>
<translation>Show predefined materials in popup menu</translation>
</message>
<message>
<source>PREF_EDITGROUP_COLOR</source>
<translation>Subshapes color for editing a group</translation>
</message>
<message>
<source>PREF_EDGE_WIDTH</source>
<translation>Edges width</translation>

View File

@ -3182,6 +3182,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
<source>PREF_PREDEF_MATERIALS</source>
<translation type="unfinished">Show predefined materials in popup menu</translation>
</message>
<message>
<source>PREF_EDITGROUP_COLOR</source>
<translation type="unfinished">Subshapes color for editing a group</translation>
</message>
<message>
<source>PREF_EDGE_WIDTH</source>
<translation>Epaisseur des arêtes</translation>

View File

@ -1825,6 +1825,9 @@ void GeometryGUI::createPreferences()
LightApp_Preferences::Selector,
"Geometry", "material" );
addPreference( tr( "PREF_EDITGROUP_COLOR" ), genGroup,
LightApp_Preferences::Color, "Geometry", "editgroup_color" );
const int nb = 4;
int wd[nb];
int iter=0;

View File

@ -33,6 +33,7 @@
#include <SalomeApp_Application.h>
#include <SalomeApp_Study.h>
#include <SalomeApp_Tools.h>
#include <LightApp_SelectionMgr.h>
@ -66,6 +67,9 @@
#include <GEOMImpl_Types.hxx>
#define GROUP_IDLST_COLOR Qt::blue // Specific color for the IDs of subShapes in the dialog box
#define GROUP_NEWIDLST_COLOR Qt::red // Specific color for the new IDs of subShapes in the dialog box
enum { ALL_SUBSHAPES = 0, GET_IN_PLACE, SUBSHAPES_OF_SHAPE2, SUBSHAPES_OF_INVISIBLE_SHAPE2 };
GroupGUI_GroupDlg::GroupGUI_GroupDlg (Mode mode, GeometryGUI* theGeometryGUI, QWidget* parent)
@ -189,8 +193,10 @@ GroupGUI_GroupDlg::~GroupGUI_GroupDlg()
if (myIsHiddenMain) {
GEOM_Displayer* aDisplayer = getDisplayer();
aDisplayer->Display(myMainObj);
aDisplayer->Display(myGroup);
myIsHiddenMain = false;
}
myDmMode = -1;
}
//=================================================================================
@ -199,6 +205,7 @@ GroupGUI_GroupDlg::~GroupGUI_GroupDlg()
//=================================================================================
void GroupGUI_GroupDlg::Init()
{
myDmMode = -1;
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
//unset shape type to avoid preparation of selection before exact user shape type selection
@ -236,9 +243,12 @@ void GroupGUI_GroupDlg::Init()
setShapeType((TopAbs_ShapeEnum)anOper->GetType(myGroup));
GEOM::ListOfLong_var aCurrList = anOper->GetObjects(myGroup);
for (int i = 0, n = aCurrList->length(); i < n; i++)
myIdList->addItem(new QListWidgetItem(QString("%1").arg(aCurrList[i])));
for (int i = 0, n = aCurrList->length(); i < n; i++) {
QListWidgetItem* itm = new QListWidgetItem( QString( "%1" ).arg( aCurrList[ i ] ) );
myGroupIdList.append( aCurrList[ i ] );
itm->setTextColor( QColor( GROUP_IDLST_COLOR ) );
myIdList->addItem( itm );
}
myEditCurrentArgument = 0;
}
connect(mySelBtn2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
@ -306,14 +316,18 @@ void GroupGUI_GroupDlg::ClickOnOk()
//=================================================================================
bool GroupGUI_GroupDlg::ClickOnApply()
{
if(!isApplyAndClose())
if(!isApplyAndClose()) {
setIsDisableBrowsing( true );
setIsDisplayResult( false );
}
if (!onAccept(myMode == CreateGroup, true,isApplyAndClose()))
if (!onAccept(myMode == CreateGroup, true, isApplyAndClose()))
return false;
if(!isApplyAndClose())
if(!isApplyAndClose()) {
setIsDisableBrowsing( false );
setIsDisplayResult( true );
}
if (myMode == CreateGroup)
{
@ -322,8 +336,19 @@ bool GroupGUI_GroupDlg::ClickOnApply()
ConstructorsClicked(getConstructorId());
}
else
{
int n = myIdList->count();
myGroupIdList.clear();
if (n > 0)
{
for (int i = 0; i < n; i++) {
QListWidgetItem* anItem = myIdList->item( i );
myGroupIdList.append( anItem->text().toInt() );
anItem->setTextColor( GROUP_IDLST_COLOR );
}
}
activateSelection();
}
return true;
}
@ -576,7 +601,7 @@ void GroupGUI_GroupDlg::selectAllSubShapes()
if (aSubShapes->length() > 0) {
if (subSelectionWay() == ALL_SUBSHAPES)
{
myIdList->clear(); // for sorted final list?
// myIdList->clear(); // for sorted final list?
if (!aShOp->IsDone())
return;
@ -600,12 +625,13 @@ void GroupGUI_GroupDlg::selectAllSubShapes()
QListWidgetItem* anItem = 0;
QString text = QString("%1").arg(anIndex);
if (!myInPlaceObj->_is_nil()) {
// if (!myInPlaceObj->_is_nil()) {
QList<QListWidgetItem*> found = myIdList->findItems(text, Qt::MatchExactly);
if (found.count()) anItem = found[0];
}
// }
if (!anItem) {
anItem = new QListWidgetItem(text);
anItem->setTextColor( myGroupIdList.contains(anIndex) ? QColor( GROUP_IDLST_COLOR ) : QColor( GROUP_NEWIDLST_COLOR ) );
myIdList->addItem(anItem);
}
anItem->setSelected(true);
@ -754,6 +780,7 @@ void GroupGUI_GroupDlg::add()
continue;
QListWidgetItem* anItem = new QListWidgetItem(QString("%1").arg(aMapIndex(i)));
anItem->setTextColor( myGroupIdList.contains( aMapIndex( i ) ) ? QColor( GROUP_IDLST_COLOR ) : QColor( GROUP_NEWIDLST_COLOR ) );
myIdList->addItem(anItem);
anItem->setSelected(true);
}
@ -835,7 +862,7 @@ void GroupGUI_GroupDlg::setShapeType(const TopAbs_ShapeEnum theType)
void GroupGUI_GroupDlg::activateSelection()
{
bool isApply = ((QPushButton*)sender() == buttonApply());
if(!isApply)
if(!isApplyAndClose())
erasePreview(false);
// local selection
@ -844,27 +871,42 @@ void GroupGUI_GroupDlg::activateSelection()
myIsShapeType) // check if shape type is already choosen by user
{
GEOM_Displayer* aDisplayer = getDisplayer();
//display mode for main shape
if ( myDmMode == -1 ) {
SALOME_View* view = GEOM_Displayer::GetActiveView();
if (view) {
CORBA::String_var aMainEntry = myMainObj->GetStudyEntry();
Handle(SALOME_InteractiveObject) io =
new SALOME_InteractiveObject (aMainEntry.in(), "GEOM", "TEMP_IO");
if ( view->isVisible( io ) ) {
Handle(GEOM_AISShape) aSh = GEOMBase::ConvertIOinGEOMAISShape( io, true );
if(!aSh.IsNull()) {
myDmMode = aSh->isTopLevel() ? aSh->prevDisplayMode() : aSh->DisplayMode();
}
// Hide main shape, if explode on VERTEX
if(getShapeType() != TopAbs_VERTEX) {
aDisplayer->Erase(myMainObj, false, false);
myIsHiddenMain = true;
}
}
else
myDmMode = SUIT_Session::session()->resourceMgr()->integerValue( "Geometry", "display_mode" );
}
}
aDisplayer->SetDisplayMode(myDmMode);
// Mantis issue 0021421: do not hide main shape, if explode on VERTEX
if (getShapeType() == TopAbs_VERTEX) {
if (myIsHiddenMain)
aDisplayer->Display(myMainObj);
}
else {
SALOME_View* view = GEOM_Displayer::GetActiveView();
if (view) {
CORBA::String_var aMainEntry = myMainObj->GetStudyEntry();
Handle(SALOME_InteractiveObject) io =
new SALOME_InteractiveObject (aMainEntry.in(), "GEOM", "TEMP_IO");
if (view->isVisible(io)) {
aDisplayer->Erase(myMainObj, false, false);
myIsHiddenMain = true;
}
}
}
if(!isApply) {
int prevDisplayMode = aDisplayer->SetDisplayMode(0);
aDisplayer->Erase(myGroup, false, false);
QColor aColor = SUIT_Session::session()->resourceMgr()->colorValue( "Geometry", "editgroup_color" );
Quantity_NameOfColor aCol = SalomeApp_Tools::color( aColor ).Name();
if(!isApplyAndClose()) {
SUIT_ViewWindow* aViewWindow = 0;
SUIT_Study* activeStudy = SUIT_Session::session()->activeApplication()->activeStudy();
if (activeStudy)
@ -895,8 +937,15 @@ void GroupGUI_GroupDlg::activateSelection()
for (; anExp.More(); anExp.Next()) {
TopoDS_Shape aSubShape = anExp.Current();
int index = aSubShapesMap.FindIndex(aSubShape);
QString anEntry = anEntryBase + QString("_%1").arg(index);
QString anEntry = QString( "TEMP_" ) + anEntryBase + QString("_%1").arg(index);
Handle(SALOME_InteractiveObject) io =
new SALOME_InteractiveObject(anEntry.toAscii(), "GEOM", "TEMP_IO");
if ( myGroupIdList.contains( index ) ) {
aDisplayer->SetColor( aCol );
}
else {
aDisplayer->UnsetColor();
}
SALOME_Prs* aPrs = aDisplayer->buildSubshapePresentation(aSubShape, anEntry, aView);
if (aPrs) {
displayPreview(aPrs, true, false); // append, do not update
@ -914,7 +963,14 @@ void GroupGUI_GroupDlg::activateSelection()
for (; aM2IPit.More(); aM2IPit.Next()) {
int index = aM2IPit.Key();
TopoDS_Shape aSubShape = aSubShapesMap.FindKey(index);
QString anEntry = anEntryBase + QString("_%1").arg(index);
QString anEntry = QString( "TEMP_" ) + anEntryBase + QString("_%1").arg(index);
if ( myGroupIdList.contains( index ) ) {
aDisplayer->SetColor( aCol );
}
else {
aDisplayer->UnsetColor();
}
SALOME_Prs* aPrs = aDisplayer->buildSubshapePresentation(aSubShape, anEntry, aView);
if (aPrs) {
@ -923,9 +979,9 @@ void GroupGUI_GroupDlg::activateSelection()
}
}
else ;
aDisplayer->UnsetDisplayMode();
aDisplayer->UnsetColor();
aDisplayer->UpdateViewer();
aDisplayer->SetDisplayMode(prevDisplayMode);
}
}

View File

@ -102,6 +102,8 @@ private:
GEOM::GEOM_Object_var myInPlaceObj;
int myInPlaceObjSelectState;
TColStd_DataMapOfIntegerInteger myMain2InPlaceIndices;
QList<int> myGroupIdList;
int myDmMode;
QPushButton* mySelBtn;
QLineEdit* myMainName;