53 #include "DataControlPlugin.hh"
55 #include <ACG/QtWidgets/QtMaterialDialog.hh>
59 #include <ObjectTypes/Light/LightWidget.hh>
69 QItemSelectionModel* selection =
view_->selectionModel();
71 if (selection == 0)
return;
74 QModelIndexList indexList = selection->selectedRows();
78 msgBox.setText(tr(
"Do you really want to remove the selected objects?"));
79 msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
80 msgBox.setDefaultButton(QMessageBox::Yes);
84 for (
int i = 0 ; i < indexList.size() ; ++i)
87 msgBox.setDetailedText(text);
89 if ( msgBox.exec() == QMessageBox::No)
92 for (
int i = 0 ; i < indexList.size() ; ++i) {
98 emit deleteObject(
id );
111 QItemSelectionModel* selection =
view_->selectionModel();
114 QModelIndexList indexList = selection->selectedRows ( 0 );
128 QItemSelectionModel* selection =
view_->selectionModel();
130 if (selection == 0)
return;
133 QModelIndexList indexList = selection->selectedRows();
135 for (
int i = 0 ; i < indexList.size() ; ++i) {
143 emit copyObject(
id, newObject );
159 QItemSelectionModel* selection =
view_->selectionModel();
162 QModelIndexList indexList = selection->selectedRows ( 0 );
167 for (
int i = 0; i < indexList.size(); ++i)
190 QItemSelectionModel* selection =
view_->selectionModel();
193 QModelIndexList indexList = selection->selectedRows ( 0 );
194 int selectedRows = indexList.size();
199 if ( selectedRows > 1 ) {
200 action = menu.addAction(
"Copy",
this,SLOT (
slotCopy() ));
201 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"edit-copy.png");
202 action->setIcon(icon);
203 menu.addAction(tr(
"Group"),
this,SLOT (
slotGroup() ));
208 if ( item->isGroup() ) {
209 action = menu.addAction(tr(
"Zoom to objects"),
this,SLOT (
slotZoomTo() ));
210 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"zoom-in.png");
211 action->setIcon(icon);
212 menu.addAction(tr(
"Ungroup"),
this,SLOT (
slotUngroup() ));
214 action = menu.addAction(tr(
"Rename"),
this,SLOT (
slotRename() ));
215 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"edit-rename.png");
216 action->setIcon(icon);
219 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-delete-item.png");
220 action->setIcon(icon);
227 QAction* header = menu.addAction(tr(
"Object ")+QString::number(
id)+
": "+item->
name());
234 action = menu.addAction(tr(
"Copy"),
this,SLOT (
slotCopy() ));
235 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"edit-copy.png");
236 action->setIcon(icon);
237 action = menu.addAction(tr(
"Rename"),
this,SLOT (
slotRename() ));
238 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"edit-rename.png");
239 action->setIcon(icon);
241 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-delete-item.png");
242 action->setIcon(icon);
249 action = menu.addAction(tr(
"Switch On"),
this,SLOT (
slotSwitchLight() ));
255 action = menu.addAction(tr(
"Switch Off"),
this,SLOT (
slotSwitchLight() ));
256 icon = QIcon (OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"LightOff.png");
258 action->setIcon(icon);
260 action = menu.addAction(tr(
"Edit Light"),
this,SLOT (
slotEditLight() ));
262 action->setIcon(icon);
265 action = menu.addAction(tr(
"Zoom to object"),
this,SLOT (
slotZoomTo() ));
266 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"zoom-in.png");
267 action->setIcon(icon);
269 action = menu.addAction(tr(
"Copy"),
this,SLOT (
slotCopy() ));
270 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"edit-copy.png");
271 action->setIcon(icon);
273 action = menu.addAction(tr(
"Rename"),
this,SLOT (
slotRename() ));
274 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"edit-rename.png");
275 action->setIcon(icon);
278 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-material.png");
279 action->setIcon(icon);
282 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-copyToTargets-material.png");
283 action->setIcon(icon);
286 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-copy-material.png");
287 action->setIcon(icon);
290 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-paste-material.png");
291 action->setIcon(icon);
293 menu.addAction(tr(
"Group"),
this,SLOT (
slotGroup() ));
297 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-delete-item.png");
298 action->setIcon(icon);
304 menu.exec(
view_->mapToGlobal( _pos) );
324 QVector<DataType> types;
328 if ( !types.contains( o_it->dataType() ) )
329 types.push_back( o_it->dataType() );
339 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"drawModes.png");
340 action = menu.addAction(icon,tr(
"Show all"),
this,SLOT (
showAll() ));
341 action->setData( QVariant() );
343 if (types.count() > 1)
344 for (
int i=0; i < types.count(); i++){
345 action = menu.addAction(icon, tr(
"Show all of type '") +
dataTypeName(types[i]) +
"'",
this,SLOT (
showAll() ));
346 action->setData( QVariant( types[i].value() ) );
350 action = menu.addAction(tr(
"Hide all"),
this,SLOT (
hideAll() ));
351 action->setData( QVariant() );
353 if (types.count() > 1)
354 for (
int i=0; i < types.count(); i++){
355 action = menu.addAction(tr(
"Hide all of type '") +
dataTypeName(types[i]) +
"'",
this,SLOT (
hideAll() ));
356 action->setData( QVariant( types[i].value() ) );
362 action = menu.addAction(tr(
"Select all"),
this,SLOT (
setAllSource() ));
363 action->setData( QVariant() );
365 if (types.count() > 1)
366 for (
int i=0; i < types.count(); i++){
367 action = menu.addAction(icon, tr(
"Select all of type '") +
dataTypeName(types[i]) +
"'",
this,SLOT (
setAllSource() ));
368 action->setData( QVariant( types[i].value() ) );
372 action = menu.addAction(tr(
"Deselect all"),
this,SLOT (
clearAllSource() ));
373 action->setData( QVariant() );
375 if (types.count() > 1)
376 for (
int i=0; i < types.count(); i++){
378 action->setData( QVariant( types[i].value() ) );
384 action = menu.addAction(tr(
"Select all"),
this,SLOT (
setAllTarget() ));
385 action->setData( QVariant() );
387 if (types.count() > 1)
388 for (
int i=0; i < types.count(); i++){
389 action = menu.addAction(icon, tr(
"Select all of type '") +
dataTypeName(types[i]) +
"'",
this,SLOT (
setAllTarget() ));
390 action->setData( QVariant( types[i].value() ) );
394 action = menu.addAction(tr(
"Deselect all"),
this,SLOT (
clearAllTarget() ));
395 action->setData( QVariant() );
397 if (types.count() > 1)
398 for (
int i=0; i < types.count(); i++){
400 action->setData( QVariant( types[i].value() ) );
419 QItemSelectionModel* selection =
view_->selectionModel();
422 QModelIndexList indexList = selection->selectedRows ( 0 );
423 int selectedRows = indexList.size();
424 if (selectedRows == 1){
431 QString newName = QInputDialog::getText(0, tr(
"Rename"),
434 if (ok && !newName.isEmpty()){
436 view_->resizeColumnToContents(0);
452 QAction* action =
dynamic_cast< QAction*
> ( sender() );
457 int id = action->data().toInt(&ok);
465 QItemSelectionModel* selection =
view_->selectionModel();
468 QModelIndexList indexList = selection->selectedRows ( 0 );
469 int selectedRows = indexList.size();
470 if (selectedRows == 1){
486 MaterialNode *
const materialNode = o_it->materialNode();
488 materialNode->
material() = sourceMaterial;
500 QAction* action =
dynamic_cast< QAction*
> ( sender() );
505 int id = action->data().toInt(&ok);
513 QItemSelectionModel* selection =
view_->selectionModel();
516 QModelIndexList indexList = selection->selectedRows ( 0 );
517 int selectedRows = indexList.size();
518 if (selectedRows == 1){
531 const QString materialJson = sourceMaterial.serializeToJson();
532 QApplication::clipboard()->setText(materialJson);
540 QAction* action =
dynamic_cast< QAction*
> ( sender() );
545 int id = action->data().toInt(&ok);
553 QItemSelectionModel* selection =
view_->selectionModel();
556 QModelIndexList indexList = selection->selectedRows ( 0 );
557 int selectedRows = indexList.size();
558 if (selectedRows == 1){
571 destMaterial.deserializeFromJson(QApplication::clipboard()->text());
582 QAction* action =
dynamic_cast< QAction*
> ( sender() );
587 int id = action->data().toInt(&ok);
595 QItemSelectionModel* selection =
view_->selectionModel();
598 QModelIndexList indexList = selection->selectedRows ( 0 );
599 int selectedRows = indexList.size();
600 if (selectedRows == 1){
614 dialog->setWindowFlags(dialog->windowFlags() | Qt::WindowStaysOnTopHint);
619 dialog->setWindowIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-material.png"));
640 QItemSelectionModel* selection =
view_->selectionModel();
643 QModelIndexList indexList = selection->selectedRows ( 0 );
644 int selectedRows = indexList.size();
645 if (selectedRows == 1) {
653 if(light == 0)
return;
670 QItemSelectionModel* selection =
view_->selectionModel();
673 QModelIndexList indexList = selection->selectedRows ( 0 );
674 int selectedRows = indexList.size();
675 if (selectedRows == 1) {
683 if(light == 0)
return;
686 widget->setWindowFlags(Qt::WindowStaysOnTopHint);
697 QItemSelectionModel* selection =
view_->selectionModel();
700 QModelIndexList indexList = selection->selectedRows ( 0 );
701 int selectedRows = indexList.size();
702 if (selectedRows == 1){
711 QList< BaseObject* > children = item->
getLeafs();
714 bool firstRound =
true;
718 for (
int i=0; i < children.size(); i++){
736 bbmin[0] = std::min( bbmin[0], cur_min[0]);
737 bbmin[1] = std::min( bbmin[1], cur_min[1]);
738 bbmin[2] = std::min( bbmin[2], cur_min[2]);
739 bbmax[0] = std::max( bbmax[0], cur_max[0]);
740 bbmax[1] = std::max( bbmax[0], cur_max[1]);
741 bbmax[2] = std::max( bbmax[0], cur_max[2]);
749 double bbradius = (bbmax - bbmin).norm();
769 if ((bbmin[0] > bbmax[0]) || (bbmin[1] > bbmax[1]) || (bbmin[2] > bbmax[2])){
770 std::cerr <<
"Error while computing bounding box!";
776 double bbradius = (bbmax - bbmin).norm();
bool enabled() const
Get light source status.
void disable()
disable LightSource
DLLEXPORT QIcon & typeIcon(DataType _id)
Get an QIcon associated with the given DataType.
void slotGroup()
Called by the popup menu to group items.
void slotUngroup()
Called by the popup menu to ungroup items.
DLLEXPORT QString dataTypeName(DataType _id)
Get DataType Human readable name ( this name might change. Use the typeName instead! ) ...
const QStringList ALL_OBJECTS
Iterable object range.
void slotNodeChanged(ACG::SceneGraph::BaseNode *_node)
Called when the material properties were changed inside the material dialog.
QString itemName(const QModelIndex &_index) const
Get the name of a TreeItem corresponding to a given ModelIndex.
void setAllSource()
Makes all available objects source.
void slotCopyMaterialToTargeted()
Called by the popup menu to copy material properties.
QString name() const
return the name of the object. The name defaults to NONAME if unset.
TreeModel * model_
The Treemodel organizing the data.
QTreeView * view_
Tree view.
int groupObjects(IdList _objectIDs, QString _groupName="")
Group given Objects together.
void slotSwitchLight()
Called by the popup menu in order to turn lights on/off.
QModelIndex popupIndex_
Index where a popup has been opened.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
bool getObject(int _identifier, BSplineCurveObject *&_object)
void slotZoomTo()
Called by the popup menu to zoom to an object.
void slotCustomContextMenuRequested(const QPoint &_pos)
Display a custom context window for the TreeView.
void clearAllSource()
remove source selection from all objects
virtual void show()
Sets the whole Scenegraph subtree of this node to visible.
MaterialNode * materialNode()
get a pointer to the materialnode
LightNode * lightNode()
Get the scenegraph Node.
void slotHeaderCustomContextMenuRequested(const QPoint &_pos)
Display a custom context window for the TreeViews header.
void slotEditLight()
Called by the popup menu in order to edit lights.
bool isGroup() const
Check if object is a group.
const QStringList TARGET_OBJECTS("target")
Iterable object range.
bool dataType(DataType _type) const
void showAll()
Shows all objects.
std::vector< int > IdList
Standard Type for id Lists used for scripting.
void slotPasteMaterialFromClipboard()
Called by the popup menu to paste material properties from clipboard.
void slotCopyMaterialToClipboard()
Called by the popup menu to copy material properties to clipboard.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
ACG::Vec3d eyePos(int _viewer)
Get the current viewer position.
void slotMaterialProperties()
Called by the popup menu to set material properties.
ACG::SceneGraph::Material & material()
Get material object reference.
void slotRename()
Called by the popup menu to rename items.
LightSource * lightSource()
int itemId(const QModelIndex &_index) const
Get the id of a TreeItem corresponding to a given ModelIndex.
QList< BaseObject * > getLeafs()
get all leafes of the tree below this object ( These will be all visible objects ) ...
void getBoundingBox(ACG::Vec3d &bbmin, ACG::Vec3d &bbmax)
get the bounding box of the object
void hideAll()
Hides all objects.
int headerPopupType_
Defines the section of the Popup.
void setAllTarget()
Makes all available objects target.
void slotCopy()
Called by the popup menu to copy items.
QHeaderView * viewHeader_
Pointer to the header to the view widget.
void slotPopupRemove()
Called by the popup menu to remove an object/group.
Add normals to mesh item (vertices/faces)
void enable()
enable LightSource
virtual bool visible()
return visiblity
virtual void setName(QString _name)
path to the file from which the object is loaded ( defaults to "." )
void clearAllTarget()
Unselect all objects.
TreeItem * getItem(const QModelIndex &_index) const
Get the TreeItem corresponding to a given ModelIndex.
void flyTo(const ACG::Vec3d &_position, const ACG::Vec3d &_center, double _time)
Fly to point and viewing direction (animated).
bool unGroupObject(int _id)